@matter/protocol 0.15.0-alpha.0-20250613-a55f991d4 → 0.15.0-alpha.0-20250616-4b3754906
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/certificate/AttestationCertificateManager.d.ts +3 -3
- package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/AttestationCertificateManager.js +12 -10
- package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.d.ts +5 -3
- package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.js +19 -11
- package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
- package/dist/cjs/certificate/CertificateManager.d.ts +18 -15
- package/dist/cjs/certificate/CertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateManager.js +92 -83
- package/dist/cjs/certificate/CertificateManager.js.map +2 -2
- package/dist/cjs/certificate/CertificationDeclarationManager.d.ts +7 -1
- package/dist/cjs/certificate/CertificationDeclarationManager.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificationDeclarationManager.js +2 -2
- package/dist/cjs/certificate/CertificationDeclarationManager.js.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.d.ts +2 -2
- package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.js +10 -4
- package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
- package/dist/cjs/common/FailsafeContext.js +1 -1
- package/dist/cjs/common/FailsafeContext.js.map +1 -1
- package/dist/cjs/fabric/Fabric.d.ts +6 -4
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +33 -20
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.d.ts +1 -1
- package/dist/cjs/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricAuthority.js +7 -7
- package/dist/cjs/fabric/FabricAuthority.js.map +1 -1
- package/dist/cjs/fabric/FabricManager.d.ts +3 -2
- package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
- package/dist/cjs/fabric/FabricManager.js +8 -3
- package/dist/cjs/fabric/FabricManager.js.map +1 -1
- package/dist/cjs/fabric/TestFabric.d.ts.map +1 -1
- package/dist/cjs/fabric/TestFabric.js +15 -19
- package/dist/cjs/fabric/TestFabric.js.map +1 -1
- package/dist/cjs/groups/FabricGroups.d.ts.map +1 -1
- package/dist/cjs/groups/FabricGroups.js +11 -7
- package/dist/cjs/groups/FabricGroups.js.map +1 -1
- package/dist/cjs/groups/KeySets.d.ts +2 -2
- package/dist/cjs/groups/KeySets.d.ts.map +1 -1
- package/dist/cjs/groups/KeySets.js +2 -2
- package/dist/cjs/groups/KeySets.js.map +1 -1
- package/dist/cjs/groups/MessagingState.d.ts +2 -2
- package/dist/cjs/groups/MessagingState.d.ts.map +1 -1
- package/dist/cjs/groups/MessagingState.js +4 -2
- package/dist/cjs/groups/MessagingState.js.map +1 -1
- package/dist/cjs/mdns/MdnsBroadcaster.d.ts +3 -3
- package/dist/cjs/mdns/MdnsBroadcaster.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsBroadcaster.js +7 -4
- package/dist/cjs/mdns/MdnsBroadcaster.js.map +1 -1
- package/dist/cjs/mdns/MdnsService.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsService.js +2 -1
- package/dist/cjs/mdns/MdnsService.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js +1 -1
- package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +3 -4
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.d.ts.map +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.js +1 -1
- package/dist/cjs/protocol/DeviceCommissioner.js.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.d.ts +4 -2
- package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/cjs/protocol/ExchangeManager.js +11 -6
- package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
- package/dist/cjs/protocol/MessageCounter.d.ts +4 -4
- package/dist/cjs/protocol/MessageCounter.d.ts.map +1 -1
- package/dist/cjs/protocol/MessageCounter.js +7 -6
- package/dist/cjs/protocol/MessageCounter.js.map +1 -1
- package/dist/cjs/session/GroupSession.d.ts.map +1 -1
- package/dist/cjs/session/GroupSession.js +7 -2
- package/dist/cjs/session/GroupSession.js.map +1 -1
- package/dist/cjs/session/InsecureSession.d.ts +2 -0
- package/dist/cjs/session/InsecureSession.d.ts.map +1 -1
- package/dist/cjs/session/InsecureSession.js +2 -2
- package/dist/cjs/session/InsecureSession.js.map +1 -1
- package/dist/cjs/session/NodeSession.d.ts +3 -1
- package/dist/cjs/session/NodeSession.d.ts.map +1 -1
- package/dist/cjs/session/NodeSession.js +21 -13
- package/dist/cjs/session/NodeSession.js.map +1 -1
- package/dist/cjs/session/SessionManager.d.ts +1 -0
- package/dist/cjs/session/SessionManager.d.ts.map +1 -1
- package/dist/cjs/session/SessionManager.js +13 -3
- package/dist/cjs/session/SessionManager.js.map +1 -1
- package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseClient.js +16 -15
- package/dist/cjs/session/case/CaseClient.js.map +1 -1
- package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseServer.js +22 -18
- package/dist/cjs/session/case/CaseServer.js.map +1 -1
- package/dist/cjs/session/pase/PaseClient.d.ts +4 -4
- package/dist/cjs/session/pase/PaseClient.d.ts.map +1 -1
- package/dist/cjs/session/pase/PaseClient.js +11 -9
- package/dist/cjs/session/pase/PaseClient.js.map +1 -1
- package/dist/cjs/session/pase/PaseServer.d.ts.map +1 -1
- package/dist/cjs/session/pase/PaseServer.js +6 -5
- package/dist/cjs/session/pase/PaseServer.js.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.d.ts +3 -3
- package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.js +13 -11
- package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.d.ts +5 -3
- package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.js +19 -11
- package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
- package/dist/esm/certificate/CertificateManager.d.ts +18 -15
- package/dist/esm/certificate/CertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateManager.js +92 -84
- package/dist/esm/certificate/CertificateManager.js.map +2 -2
- package/dist/esm/certificate/CertificationDeclarationManager.d.ts +7 -1
- package/dist/esm/certificate/CertificationDeclarationManager.d.ts.map +1 -1
- package/dist/esm/certificate/CertificationDeclarationManager.js +2 -2
- package/dist/esm/certificate/CertificationDeclarationManager.js.map +1 -1
- package/dist/esm/certificate/DeviceCertification.d.ts +2 -2
- package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceCertification.js +11 -5
- package/dist/esm/certificate/DeviceCertification.js.map +1 -1
- package/dist/esm/common/FailsafeContext.js +1 -1
- package/dist/esm/common/FailsafeContext.js.map +1 -1
- package/dist/esm/fabric/Fabric.d.ts +6 -4
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +33 -21
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/fabric/FabricAuthority.d.ts +1 -1
- package/dist/esm/fabric/FabricAuthority.d.ts.map +1 -1
- package/dist/esm/fabric/FabricAuthority.js +8 -15
- package/dist/esm/fabric/FabricAuthority.js.map +1 -1
- package/dist/esm/fabric/FabricManager.d.ts +3 -2
- package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
- package/dist/esm/fabric/FabricManager.js +9 -3
- package/dist/esm/fabric/FabricManager.js.map +1 -1
- package/dist/esm/fabric/TestFabric.d.ts.map +1 -1
- package/dist/esm/fabric/TestFabric.js +16 -20
- package/dist/esm/fabric/TestFabric.js.map +1 -1
- package/dist/esm/groups/FabricGroups.d.ts.map +1 -1
- package/dist/esm/groups/FabricGroups.js +12 -8
- package/dist/esm/groups/FabricGroups.js.map +1 -1
- package/dist/esm/groups/KeySets.d.ts +2 -2
- package/dist/esm/groups/KeySets.d.ts.map +1 -1
- package/dist/esm/groups/KeySets.js +3 -3
- package/dist/esm/groups/KeySets.js.map +1 -1
- package/dist/esm/groups/MessagingState.d.ts +2 -2
- package/dist/esm/groups/MessagingState.d.ts.map +1 -1
- package/dist/esm/groups/MessagingState.js +4 -2
- package/dist/esm/groups/MessagingState.js.map +1 -1
- package/dist/esm/mdns/MdnsBroadcaster.d.ts +3 -3
- package/dist/esm/mdns/MdnsBroadcaster.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsBroadcaster.js +7 -5
- package/dist/esm/mdns/MdnsBroadcaster.js.map +1 -1
- package/dist/esm/mdns/MdnsService.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsService.js +3 -1
- package/dist/esm/mdns/MdnsService.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioner.js +1 -1
- package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +3 -5
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/protocol/DeviceCommissioner.d.ts.map +1 -1
- package/dist/esm/protocol/DeviceCommissioner.js +1 -2
- package/dist/esm/protocol/DeviceCommissioner.js.map +1 -1
- package/dist/esm/protocol/ExchangeManager.d.ts +4 -2
- package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
- package/dist/esm/protocol/ExchangeManager.js +11 -6
- package/dist/esm/protocol/ExchangeManager.js.map +1 -1
- package/dist/esm/protocol/MessageCounter.d.ts +4 -4
- package/dist/esm/protocol/MessageCounter.d.ts.map +1 -1
- package/dist/esm/protocol/MessageCounter.js +8 -7
- package/dist/esm/protocol/MessageCounter.js.map +1 -1
- package/dist/esm/session/GroupSession.d.ts.map +1 -1
- package/dist/esm/session/GroupSession.js +7 -3
- package/dist/esm/session/GroupSession.js.map +1 -1
- package/dist/esm/session/InsecureSession.d.ts +2 -0
- package/dist/esm/session/InsecureSession.d.ts.map +1 -1
- package/dist/esm/session/InsecureSession.js +2 -2
- package/dist/esm/session/InsecureSession.js.map +1 -1
- package/dist/esm/session/NodeSession.d.ts +3 -1
- package/dist/esm/session/NodeSession.d.ts.map +1 -1
- package/dist/esm/session/NodeSession.js +22 -14
- package/dist/esm/session/NodeSession.js.map +1 -1
- package/dist/esm/session/SessionManager.d.ts +1 -0
- package/dist/esm/session/SessionManager.d.ts.map +1 -1
- package/dist/esm/session/SessionManager.js +13 -4
- package/dist/esm/session/SessionManager.js.map +1 -1
- package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
- package/dist/esm/session/case/CaseClient.js +17 -16
- package/dist/esm/session/case/CaseClient.js.map +1 -1
- package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
- package/dist/esm/session/case/CaseServer.js +23 -19
- package/dist/esm/session/case/CaseServer.js.map +1 -1
- package/dist/esm/session/pase/PaseClient.d.ts +4 -4
- package/dist/esm/session/pase/PaseClient.d.ts.map +1 -1
- package/dist/esm/session/pase/PaseClient.js +12 -10
- package/dist/esm/session/pase/PaseClient.js.map +1 -1
- package/dist/esm/session/pase/PaseServer.d.ts.map +1 -1
- package/dist/esm/session/pase/PaseServer.js +6 -6
- package/dist/esm/session/pase/PaseServer.js.map +1 -1
- package/package.json +6 -6
- package/src/certificate/AttestationCertificateManager.ts +12 -10
- package/src/certificate/CertificateAuthority.ts +20 -11
- package/src/certificate/CertificateManager.ts +77 -72
- package/src/certificate/CertificationDeclarationManager.ts +3 -3
- package/src/certificate/DeviceCertification.ts +10 -4
- package/src/common/FailsafeContext.ts +1 -1
- package/src/fabric/Fabric.ts +36 -20
- package/src/fabric/FabricAuthority.ts +8 -16
- package/src/fabric/FabricManager.ts +10 -3
- package/src/fabric/TestFabric.ts +17 -22
- package/src/groups/FabricGroups.ts +20 -8
- package/src/groups/KeySets.ts +2 -2
- package/src/groups/MessagingState.ts +6 -3
- package/src/mdns/MdnsBroadcaster.ts +11 -4
- package/src/mdns/MdnsService.ts +3 -1
- package/src/peer/ControllerCommissioner.ts +1 -1
- package/src/peer/ControllerCommissioningFlow.ts +4 -6
- package/src/protocol/DeviceCommissioner.ts +1 -2
- package/src/protocol/ExchangeManager.ts +13 -6
- package/src/protocol/MessageCounter.ts +11 -3
- package/src/session/GroupSession.ts +7 -3
- package/src/session/InsecureSession.ts +4 -3
- package/src/session/NodeSession.ts +25 -14
- package/src/session/SessionManager.ts +14 -4
- package/src/session/case/CaseClient.ts +18 -16
- package/src/session/case/CaseServer.ts +22 -17
- package/src/session/pase/PaseClient.ts +11 -9
- package/src/session/pase/PaseServer.ts +6 -5
|
@@ -5,15 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { CertificateAuthority } from "#certificate/CertificateAuthority.js";
|
|
8
|
-
import {
|
|
9
|
-
Bytes,
|
|
10
|
-
Crypto,
|
|
11
|
-
CRYPTO_SYMMETRIC_KEY_LENGTH,
|
|
12
|
-
Environment,
|
|
13
|
-
Environmental,
|
|
14
|
-
ImplementationError,
|
|
15
|
-
Logger,
|
|
16
|
-
} from "#general";
|
|
8
|
+
import { Bytes, CRYPTO_SYMMETRIC_KEY_LENGTH, Environment, Environmental, ImplementationError, Logger } from "#general";
|
|
17
9
|
import { CaseAuthenticatedTag, FabricId, FabricIndex, NodeId, VendorId } from "#types";
|
|
18
10
|
import { Fabric, FabricBuilder } from "./Fabric.js";
|
|
19
11
|
import { FabricManager } from "./FabricManager.js";
|
|
@@ -60,10 +52,10 @@ export class FabricAuthority {
|
|
|
60
52
|
#fabrics: FabricManager;
|
|
61
53
|
#config: FabricAuthorityConfiguration;
|
|
62
54
|
|
|
63
|
-
constructor(
|
|
64
|
-
this.#ca =
|
|
65
|
-
this.#fabrics =
|
|
66
|
-
this.#config =
|
|
55
|
+
constructor({ ca, fabrics, config }: FabricAuthorityContext) {
|
|
56
|
+
this.#ca = ca;
|
|
57
|
+
this.#fabrics = fabrics;
|
|
58
|
+
this.#config = config;
|
|
67
59
|
}
|
|
68
60
|
|
|
69
61
|
/**
|
|
@@ -108,8 +100,8 @@ export class FabricAuthority {
|
|
|
108
100
|
* Create a new fabric under our control.
|
|
109
101
|
*/
|
|
110
102
|
async createFabric() {
|
|
111
|
-
const rootNodeId = NodeId.randomOperationalNodeId();
|
|
112
|
-
const ipkValue =
|
|
103
|
+
const rootNodeId = NodeId.randomOperationalNodeId(this.#fabrics.crypto);
|
|
104
|
+
const ipkValue = this.#fabrics.crypto.randomBytes(CRYPTO_SYMMETRIC_KEY_LENGTH);
|
|
113
105
|
|
|
114
106
|
let vendorId = this.#config.adminVendorId;
|
|
115
107
|
if (vendorId === undefined) {
|
|
@@ -117,7 +109,7 @@ export class FabricAuthority {
|
|
|
117
109
|
logger.warn(`Using test vendor ID 0x${vendorId.toString(16)} for controller fabric`);
|
|
118
110
|
}
|
|
119
111
|
|
|
120
|
-
const fabricBuilder = await FabricBuilder.create();
|
|
112
|
+
const fabricBuilder = await FabricBuilder.create(this.#fabrics.crypto);
|
|
121
113
|
await fabricBuilder.setRootCert(this.#ca.rootCert);
|
|
122
114
|
fabricBuilder
|
|
123
115
|
.setRootNodeId(rootNodeId)
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import {
|
|
8
8
|
Bytes,
|
|
9
9
|
Construction,
|
|
10
|
+
Crypto,
|
|
10
11
|
Environment,
|
|
11
12
|
Environmental,
|
|
12
13
|
ImplementationError,
|
|
@@ -33,6 +34,7 @@ export enum FabricAction {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export class FabricManager {
|
|
37
|
+
#crypto: Crypto;
|
|
36
38
|
#nextFabricIndex = 1;
|
|
37
39
|
readonly #fabrics = new Map<FabricIndex, Fabric>();
|
|
38
40
|
#initializationDone = false;
|
|
@@ -45,7 +47,8 @@ export class FabricManager {
|
|
|
45
47
|
};
|
|
46
48
|
#construction: Construction<FabricManager>;
|
|
47
49
|
|
|
48
|
-
constructor(storage?: StorageContext) {
|
|
50
|
+
constructor(crypto: Crypto, storage?: StorageContext) {
|
|
51
|
+
this.#crypto = crypto;
|
|
49
52
|
this.#storage = storage;
|
|
50
53
|
|
|
51
54
|
let construct;
|
|
@@ -60,7 +63,7 @@ export class FabricManager {
|
|
|
60
63
|
|
|
61
64
|
const fabrics = await this.#storage.get<Fabric.Config[]>("fabrics", []);
|
|
62
65
|
for (const fabricConfig of fabrics) {
|
|
63
|
-
this.#addFabric(new Fabric(fabricConfig));
|
|
66
|
+
this.#addFabric(new Fabric(crypto, fabricConfig));
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
this.#nextFabricIndex = await this.#storage.get("nextFabricIndex", this.#nextFabricIndex);
|
|
@@ -72,6 +75,10 @@ export class FabricManager {
|
|
|
72
75
|
this.#construction = Construction(this, construct);
|
|
73
76
|
}
|
|
74
77
|
|
|
78
|
+
get crypto() {
|
|
79
|
+
return this.#crypto;
|
|
80
|
+
}
|
|
81
|
+
|
|
75
82
|
get construction() {
|
|
76
83
|
return this.#construction;
|
|
77
84
|
}
|
|
@@ -81,7 +88,7 @@ export class FabricManager {
|
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
static [Environmental.create](env: Environment) {
|
|
84
|
-
const instance = new FabricManager(env.get(StorageManager).createContext("fabrics"));
|
|
91
|
+
const instance = new FabricManager(env.get(Crypto), env.get(StorageManager).createContext("fabrics"));
|
|
85
92
|
env.set(FabricManager, instance);
|
|
86
93
|
return instance;
|
|
87
94
|
}
|
package/src/fabric/TestFabric.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { CertificateAuthority } from "#certificate/CertificateAuthority.js";
|
|
8
|
-
import { ImplementationError,
|
|
8
|
+
import { ImplementationError, MockCrypto } from "#general";
|
|
9
9
|
import { FabricIndex, VendorId } from "#types";
|
|
10
10
|
import { FabricAuthority } from "./FabricAuthority.js";
|
|
11
11
|
import { FabricManager } from "./FabricManager.js";
|
|
@@ -40,22 +40,25 @@ export namespace TestFabric {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
config: {
|
|
47
|
-
adminFabricLabel: `mock-fabric-${index}`,
|
|
48
|
-
adminVendorId: VendorId(0xfff1),
|
|
49
|
-
fabricIndex: FabricIndex(index),
|
|
50
|
-
},
|
|
51
|
-
fabrics: fabrics ?? new FabricManager(),
|
|
52
|
-
});
|
|
43
|
+
if (index < 1 || index > 254) {
|
|
44
|
+
throw new ImplementationError("Test fabric indexes must be in the range 1-254");
|
|
45
|
+
}
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
if (!fabrics) {
|
|
48
|
+
fabrics = new FabricManager(MockCrypto(index));
|
|
49
|
+
}
|
|
56
50
|
|
|
57
|
-
|
|
51
|
+
const authority = new FabricAuthority({
|
|
52
|
+
ca: await CertificateAuthority.create(fabrics.crypto),
|
|
53
|
+
config: {
|
|
54
|
+
adminFabricLabel: `mock-fabric-${index}`,
|
|
55
|
+
adminVendorId: VendorId(0xfff1),
|
|
56
|
+
fabricIndex: FabricIndex(index),
|
|
57
|
+
},
|
|
58
|
+
fabrics,
|
|
58
59
|
});
|
|
60
|
+
|
|
61
|
+
return authority;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
export interface Options {
|
|
@@ -63,11 +66,3 @@ export namespace TestFabric {
|
|
|
63
66
|
fabrics?: FabricManager;
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
|
-
|
|
67
|
-
async function forFabric<T>(index: number, actor: () => Promise<T>): Promise<T> {
|
|
68
|
-
if (index < 1 || index > 254) {
|
|
69
|
-
throw new ImplementationError("Test fabric indexes must be in the range 1-254");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return nonentropic(index, actor);
|
|
73
|
-
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Fabric } from "#fabric/Fabric.js";
|
|
7
|
-
import { BasicMap, Bytes,
|
|
7
|
+
import { BasicMap, Bytes, InternalError, MatterFlowError, StorageContext } from "#general";
|
|
8
8
|
import { GroupKeySet, KeySets, OperationalKeySet } from "#groups/KeySets.js";
|
|
9
9
|
import { MessagingState } from "#groups/MessagingState.js";
|
|
10
10
|
import { GroupId } from "#types";
|
|
@@ -26,7 +26,7 @@ export class FabricGroups {
|
|
|
26
26
|
constructor(fabric: Fabric, storage?: StorageContext) {
|
|
27
27
|
this.#fabric = fabric;
|
|
28
28
|
this.#groups = new Groups(fabric, this.#keySets);
|
|
29
|
-
this.#messagingState = new MessagingState(storage);
|
|
29
|
+
this.#messagingState = new MessagingState(fabric.crypto, storage);
|
|
30
30
|
|
|
31
31
|
// KeySet with ID 0 is always the Fabric IPK, so we initialize from there because this is not stored
|
|
32
32
|
// in Key Management Cluster
|
|
@@ -122,21 +122,33 @@ export class FabricGroups {
|
|
|
122
122
|
|
|
123
123
|
// Lets pre-calculate the operational keys
|
|
124
124
|
const operationalId = this.#fabric.operationalId;
|
|
125
|
-
const operationalEpochKey0 = await
|
|
125
|
+
const operationalEpochKey0 = await this.#fabric.crypto.createHkdfKey(
|
|
126
|
+
epochKey0,
|
|
127
|
+
operationalId,
|
|
128
|
+
GROUP_SECURITY_INFO,
|
|
129
|
+
);
|
|
126
130
|
const operationalEpochKey1 =
|
|
127
|
-
epochKey1 !== null
|
|
131
|
+
epochKey1 !== null
|
|
132
|
+
? await this.#fabric.crypto.createHkdfKey(epochKey1, operationalId, GROUP_SECURITY_INFO)
|
|
133
|
+
: null;
|
|
128
134
|
const operationalEpochKey2 =
|
|
129
|
-
epochKey2 !== null
|
|
135
|
+
epochKey2 !== null
|
|
136
|
+
? await this.#fabric.crypto.createHkdfKey(epochKey2, operationalId, GROUP_SECURITY_INFO)
|
|
137
|
+
: null;
|
|
130
138
|
this.#keySets.add({
|
|
131
139
|
...groupKeySet,
|
|
132
140
|
operationalEpochKey0,
|
|
133
|
-
groupSessionId0: await this.#keySets.sessionIdFromKey(operationalEpochKey0),
|
|
141
|
+
groupSessionId0: await this.#keySets.sessionIdFromKey(this.#fabric.crypto, operationalEpochKey0),
|
|
134
142
|
operationalEpochKey1,
|
|
135
143
|
groupSessionId1:
|
|
136
|
-
operationalEpochKey1 !== null
|
|
144
|
+
operationalEpochKey1 !== null
|
|
145
|
+
? await this.#keySets.sessionIdFromKey(this.#fabric.crypto, operationalEpochKey1)
|
|
146
|
+
: null,
|
|
137
147
|
operationalEpochKey2,
|
|
138
148
|
groupSessionId2:
|
|
139
|
-
operationalEpochKey2 !== null
|
|
149
|
+
operationalEpochKey2 !== null
|
|
150
|
+
? await this.#keySets.sessionIdFromKey(this.#fabric.crypto, operationalEpochKey2)
|
|
151
|
+
: null,
|
|
140
152
|
});
|
|
141
153
|
}
|
|
142
154
|
|
package/src/groups/KeySets.ts
CHANGED
|
@@ -141,9 +141,9 @@ export class KeySets<T extends OperationalKeySet> extends BasicSet<T> {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/** Calculates a group session id based on the operational group key. */
|
|
144
|
-
async sessionIdFromKey(operationalGroupKey: Uint8Array) {
|
|
144
|
+
async sessionIdFromKey(crypto: Crypto, operationalGroupKey: Uint8Array) {
|
|
145
145
|
// GroupKeyHash is an array of 2 bytes (16 bits) per Crypto_KDF
|
|
146
|
-
const groupKeyHash = await
|
|
146
|
+
const groupKeyHash = await crypto.createHkdfKey(operationalGroupKey, new Uint8Array(), GROUP_KEY_INFO, 2);
|
|
147
147
|
|
|
148
148
|
// GroupSessionId is computed by considering the GroupKeyHash as a Big-Endian value. GroupSessionId is a scalar.
|
|
149
149
|
// Its use in fields within messages may cause a re-serialization into a different byte order than the one used
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2022-2025 Matter.js Authors
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { Bytes, ImplementationError, InternalError, StorageContext } from "#general";
|
|
6
|
+
import { Bytes, Crypto, ImplementationError, InternalError, StorageContext } from "#general";
|
|
7
7
|
import { PersistedMessageCounter } from "#protocol/MessageCounter.js";
|
|
8
8
|
import { MessageReceptionStateEncryptedWithRollover } from "#protocol/MessageReceptionState.js";
|
|
9
9
|
import { NodeId } from "#types";
|
|
@@ -19,9 +19,12 @@ export class MessagingState {
|
|
|
19
19
|
|
|
20
20
|
/** Message reception state for data messages per Operational key and source node. */
|
|
21
21
|
readonly #messageDataReceptionState = new Map<string, Map<NodeId, MessageReceptionStateEncryptedWithRollover>>();
|
|
22
|
+
|
|
23
|
+
#crypto: Crypto;
|
|
22
24
|
#storage?: StorageContext;
|
|
23
25
|
|
|
24
|
-
constructor(storage?: StorageContext) {
|
|
26
|
+
constructor(crypto: Crypto, storage?: StorageContext) {
|
|
27
|
+
this.#crypto = crypto;
|
|
25
28
|
if (storage !== undefined) {
|
|
26
29
|
this.#storage = storage;
|
|
27
30
|
}
|
|
@@ -44,7 +47,7 @@ export class MessagingState {
|
|
|
44
47
|
const operationalKeyHex = Bytes.toHex(operationalKey);
|
|
45
48
|
let counter = this.#groupDataCounters.get(operationalKeyHex);
|
|
46
49
|
if (counter === undefined) {
|
|
47
|
-
counter = new PersistedMessageCounter(this.#storage, `${operationalKeyHex}-data`);
|
|
50
|
+
counter = new PersistedMessageCounter(this.#crypto, this.#storage, `${operationalKeyHex}-data`);
|
|
48
51
|
this.#groupDataCounters.set(operationalKeyHex, counter);
|
|
49
52
|
}
|
|
50
53
|
return counter;
|
|
@@ -68,21 +68,28 @@ const DEFAULT_PAIRING_HINT = {
|
|
|
68
68
|
export class MdnsBroadcaster {
|
|
69
69
|
readonly #activeCommissioningAnnouncements = new Set<number>();
|
|
70
70
|
readonly #activeOperationalAnnouncements = new Map<number, { fabricIndex: FabricIndex; forInstance: string }[]>();
|
|
71
|
+
readonly #crypto: Crypto;
|
|
71
72
|
readonly #network: Network;
|
|
72
73
|
readonly #mdnsServer: MdnsServer;
|
|
73
74
|
readonly #enableIpv4?: boolean;
|
|
74
75
|
readonly #instances = new BasicSet<MdnsInstanceBroadcaster>();
|
|
75
76
|
|
|
76
|
-
static async create(
|
|
77
|
+
static async create(
|
|
78
|
+
crypto: Crypto,
|
|
79
|
+
network: Network,
|
|
80
|
+
options?: { enableIpv4?: boolean; multicastInterface?: string },
|
|
81
|
+
) {
|
|
77
82
|
const { enableIpv4, multicastInterface } = options ?? {};
|
|
78
83
|
return new MdnsBroadcaster(
|
|
84
|
+
crypto,
|
|
79
85
|
network,
|
|
80
86
|
await MdnsServer.create(network, { enableIpv4, netInterface: multicastInterface }),
|
|
81
87
|
enableIpv4,
|
|
82
88
|
);
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
constructor(network: Network, mdnsServer: MdnsServer, enableIpv4?: boolean) {
|
|
91
|
+
constructor(crypto: Crypto, network: Network, mdnsServer: MdnsServer, enableIpv4?: boolean) {
|
|
92
|
+
this.#crypto = crypto;
|
|
86
93
|
this.#network = network;
|
|
87
94
|
this.#mdnsServer = mdnsServer;
|
|
88
95
|
this.#enableIpv4 = enableIpv4;
|
|
@@ -182,7 +189,7 @@ export class MdnsBroadcaster {
|
|
|
182
189
|
this.#activeCommissioningAnnouncements.add(announcedNetPort);
|
|
183
190
|
|
|
184
191
|
const shortDiscriminator = (discriminator >> 8) & 0x0f;
|
|
185
|
-
const instanceId = Bytes.toHex(
|
|
192
|
+
const instanceId = Bytes.toHex(this.#crypto.randomBytes(8)).toUpperCase();
|
|
186
193
|
const vendorQname = getVendorQname(vendorId);
|
|
187
194
|
const deviceTypeQname = getDeviceTypeQname(deviceType);
|
|
188
195
|
const shortDiscriminatorQname = getShortDiscriminatorQname(shortDiscriminator);
|
|
@@ -360,7 +367,7 @@ export class MdnsBroadcaster {
|
|
|
360
367
|
}),
|
|
361
368
|
);
|
|
362
369
|
|
|
363
|
-
const instanceId = Bytes.toHex(
|
|
370
|
+
const instanceId = Bytes.toHex(this.#crypto.randomBytes(8)).toUpperCase();
|
|
364
371
|
const deviceTypeQname = `_T${deviceType}._sub.${MATTER_COMMISSIONER_SERVICE_QNAME}`;
|
|
365
372
|
const vendorQname = `_V${vendorId}._sub.${MATTER_COMMISSIONER_SERVICE_QNAME}`;
|
|
366
373
|
const deviceQname = `${instanceId}.${MATTER_COMMISSIONER_SERVICE_QNAME}`;
|
package/src/mdns/MdnsService.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
Construction,
|
|
9
|
+
Crypto,
|
|
9
10
|
Diagnostic,
|
|
10
11
|
Environment,
|
|
11
12
|
Environmental,
|
|
@@ -43,9 +44,10 @@ export class MdnsService {
|
|
|
43
44
|
this.limitedToNetInterface = vars.get("mdns.networkInterface", options?.networkInterface);
|
|
44
45
|
|
|
45
46
|
this.#construction = Construction(this, async () => {
|
|
47
|
+
const crypto = environment.get(Crypto);
|
|
46
48
|
const network = environment.get(Network);
|
|
47
49
|
|
|
48
|
-
this.#broadcaster = await MdnsBroadcaster.create(network, {
|
|
50
|
+
this.#broadcaster = await MdnsBroadcaster.create(crypto, network, {
|
|
49
51
|
enableIpv4: this.enableIpv4,
|
|
50
52
|
multicastInterface: this.limitedToNetInterface,
|
|
51
53
|
});
|
|
@@ -381,7 +381,7 @@ export class ControllerCommissioner {
|
|
|
381
381
|
/** Finds an unused random Node-ID to use for commissioning if not already provided. */
|
|
382
382
|
#determineAddress(fabric: Fabric, nodeId?: NodeId) {
|
|
383
383
|
while (true) {
|
|
384
|
-
const address = fabric.addressOf(nodeId ?? NodeId.randomOperationalNodeId());
|
|
384
|
+
const address = fabric.addressOf(nodeId ?? NodeId.randomOperationalNodeId(fabric.crypto));
|
|
385
385
|
try {
|
|
386
386
|
this.#assertPeerAddress(address);
|
|
387
387
|
} catch (error) {
|
|
@@ -13,7 +13,6 @@ import { TimeSynchronizationCluster } from "#clusters/time-synchronization";
|
|
|
13
13
|
import {
|
|
14
14
|
Bytes,
|
|
15
15
|
ChannelType,
|
|
16
|
-
Crypto,
|
|
17
16
|
Diagnostic,
|
|
18
17
|
Logger,
|
|
19
18
|
MatterError,
|
|
@@ -32,7 +31,6 @@ import {
|
|
|
32
31
|
VendorId,
|
|
33
32
|
} from "#types";
|
|
34
33
|
import { CertificateAuthority } from "../certificate/CertificateAuthority.js";
|
|
35
|
-
import { CertificateManager } from "../certificate/CertificateManager.js";
|
|
36
34
|
import { ClusterClient } from "../cluster/client/ClusterClient.js";
|
|
37
35
|
import { ClusterClientObj } from "../cluster/client/ClusterClientTypes.js";
|
|
38
36
|
import { TlvCertSigningRequest } from "../common/OperationalCredentialsTypes.js";
|
|
@@ -207,7 +205,7 @@ export class ControllerCommissioningFlow {
|
|
|
207
205
|
/** InteractionClient for the initiated PASE session */
|
|
208
206
|
interactionClient: InteractionClient,
|
|
209
207
|
|
|
210
|
-
/**
|
|
208
|
+
/** CertificateAuthority of the controller. */
|
|
211
209
|
ca: CertificateAuthority,
|
|
212
210
|
|
|
213
211
|
/** Fabric of the controller. */
|
|
@@ -759,7 +757,7 @@ export class ControllerCommissioningFlow {
|
|
|
759
757
|
const { attestationElements, attestationSignature } =
|
|
760
758
|
await operationalCredentialsClusterClient.attestationRequest(
|
|
761
759
|
{
|
|
762
|
-
attestationNonce:
|
|
760
|
+
attestationNonce: this.fabric.crypto.randomBytes(32),
|
|
763
761
|
},
|
|
764
762
|
{ useExtendedFailSafeMessageResponseTimeout: true },
|
|
765
763
|
);
|
|
@@ -801,7 +799,7 @@ export class ControllerCommissioningFlow {
|
|
|
801
799
|
const operationalCredentialsClusterClient = this.#getClusterClient(OperationalCredentials.Cluster);
|
|
802
800
|
const { nocsrElements, attestationSignature: csrSignature } =
|
|
803
801
|
await operationalCredentialsClusterClient.csrRequest(
|
|
804
|
-
{ csrNonce:
|
|
802
|
+
{ csrNonce: this.fabric.crypto.randomBytes(32) },
|
|
805
803
|
{ useExtendedFailSafeMessageResponseTimeout: true },
|
|
806
804
|
);
|
|
807
805
|
if (nocsrElements.length === 0 || csrSignature.length === 0) {
|
|
@@ -810,7 +808,7 @@ export class ControllerCommissioningFlow {
|
|
|
810
808
|
}
|
|
811
809
|
// TODO: validate csrSignature using device public key
|
|
812
810
|
const { certSigningRequest } = TlvCertSigningRequest.decode(nocsrElements);
|
|
813
|
-
const operationalPublicKey = await
|
|
811
|
+
const operationalPublicKey = await this.ca.certs.getPublicKeyFromCsr(certSigningRequest);
|
|
814
812
|
|
|
815
813
|
await operationalCredentialsClusterClient.addTrustedRootCertificate(
|
|
816
814
|
{
|
|
@@ -9,7 +9,6 @@ import { FailsafeContext } from "#common/FailsafeContext.js";
|
|
|
9
9
|
import { CommissioningMode } from "#common/InstanceBroadcaster.js";
|
|
10
10
|
import { FabricManager } from "#fabric/FabricManager.js";
|
|
11
11
|
import {
|
|
12
|
-
Crypto,
|
|
13
12
|
Diagnostic,
|
|
14
13
|
Environment,
|
|
15
14
|
Environmental,
|
|
@@ -153,7 +152,7 @@ export class DeviceCommissioner {
|
|
|
153
152
|
this.#context.secureChannelProtocol.setPaseCommissioner(
|
|
154
153
|
await PaseServer.fromPin(this.#context.sessions, this.#context.commissioningConfig.values.passcode, {
|
|
155
154
|
iterations: 1000,
|
|
156
|
-
salt:
|
|
155
|
+
salt: this.#context.fabrics.crypto.randomBytes(32),
|
|
157
156
|
}),
|
|
158
157
|
);
|
|
159
158
|
|
|
@@ -104,6 +104,7 @@ export class MessageChannel implements Channel<Message> {
|
|
|
104
104
|
* Interfaces {@link ExchangeManager} with other components.
|
|
105
105
|
*/
|
|
106
106
|
export interface ExchangeManagerContext {
|
|
107
|
+
crypto: Crypto;
|
|
107
108
|
transportInterfaces: TransportInterfaceSet;
|
|
108
109
|
sessionManager: SessionManager;
|
|
109
110
|
channelManager: ChannelManager;
|
|
@@ -113,7 +114,7 @@ export class ExchangeManager {
|
|
|
113
114
|
readonly #transportInterfaces: TransportInterfaceSet;
|
|
114
115
|
readonly #sessionManager: SessionManager;
|
|
115
116
|
readonly #channelManager: ChannelManager;
|
|
116
|
-
readonly #exchangeCounter
|
|
117
|
+
readonly #exchangeCounter: ExchangeCounter;
|
|
117
118
|
readonly #exchanges = new Map<number, MessageExchange>();
|
|
118
119
|
readonly #protocols = new Map<number, ProtocolHandler>();
|
|
119
120
|
readonly #listeners = new Map<TransportInterface, TransportInterface.Listener>();
|
|
@@ -125,6 +126,7 @@ export class ExchangeManager {
|
|
|
125
126
|
this.#transportInterfaces = context.transportInterfaces;
|
|
126
127
|
this.#sessionManager = context.sessionManager;
|
|
127
128
|
this.#channelManager = context.channelManager;
|
|
129
|
+
this.#exchangeCounter = new ExchangeCounter(context.crypto);
|
|
128
130
|
|
|
129
131
|
for (const transportInterface of this.#transportInterfaces) {
|
|
130
132
|
this.#addListener(transportInterface);
|
|
@@ -143,6 +145,7 @@ export class ExchangeManager {
|
|
|
143
145
|
|
|
144
146
|
static [Environmental.create](env: Environment) {
|
|
145
147
|
const instance = new ExchangeManager({
|
|
148
|
+
crypto: env.get(Crypto),
|
|
146
149
|
transportInterfaces: env.get(TransportInterfaceSet),
|
|
147
150
|
sessionManager: env.get(SessionManager),
|
|
148
151
|
channelManager: env.get(ChannelManager),
|
|
@@ -515,13 +518,17 @@ export class ExchangeManager {
|
|
|
515
518
|
}
|
|
516
519
|
|
|
517
520
|
export class ExchangeCounter {
|
|
518
|
-
|
|
521
|
+
#exchangeCounter: number;
|
|
522
|
+
|
|
523
|
+
constructor(crypto: Crypto) {
|
|
524
|
+
this.#exchangeCounter = crypto.randomUint16;
|
|
525
|
+
}
|
|
519
526
|
|
|
520
527
|
getIncrementedCounter() {
|
|
521
|
-
this
|
|
522
|
-
if (this
|
|
523
|
-
this
|
|
528
|
+
this.#exchangeCounter++;
|
|
529
|
+
if (this.#exchangeCounter > 0xffff) {
|
|
530
|
+
this.#exchangeCounter = 0;
|
|
524
531
|
}
|
|
525
|
-
return this
|
|
532
|
+
return this.#exchangeCounter;
|
|
526
533
|
}
|
|
527
534
|
}
|
|
@@ -43,7 +43,7 @@ export enum MessageCounterTypes {
|
|
|
43
43
|
* Rollover can be allowed or forbidden and a callback can be provided to be notified before a rollover would happen.
|
|
44
44
|
*/
|
|
45
45
|
export class MessageCounter {
|
|
46
|
-
protected messageCounter
|
|
46
|
+
protected messageCounter: number;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Creates a new message counter with a random start value. If a aboutToRolloverCallback is provided this
|
|
@@ -51,9 +51,14 @@ export class MessageCounter {
|
|
|
51
51
|
* a number of messages before the rollover callback is called (Default 1000).
|
|
52
52
|
*/
|
|
53
53
|
constructor(
|
|
54
|
+
crypto: Crypto,
|
|
54
55
|
protected readonly aboutToRolloverCallback?: () => void,
|
|
56
|
+
|
|
57
|
+
// Counter is a 28 bit random number plus 1
|
|
55
58
|
protected readonly rolloverInfoDifference = ROLLOVER_INFO_DIFFERENCE,
|
|
56
|
-
) {
|
|
59
|
+
) {
|
|
60
|
+
this.messageCounter = (crypto.randomUint32 >>> 4) + 1;
|
|
61
|
+
}
|
|
57
62
|
|
|
58
63
|
async getIncrementedCounter() {
|
|
59
64
|
this.messageCounter++;
|
|
@@ -82,6 +87,7 @@ export class PersistedMessageCounter extends MessageCounter {
|
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
static async create(
|
|
90
|
+
crypto: Crypto,
|
|
85
91
|
storageContext: StorageContext,
|
|
86
92
|
storageKey: string,
|
|
87
93
|
aboutToRolloverCallback?: () => void,
|
|
@@ -89,6 +95,7 @@ export class PersistedMessageCounter extends MessageCounter {
|
|
|
89
95
|
) {
|
|
90
96
|
return asyncNew(
|
|
91
97
|
PersistedMessageCounter,
|
|
98
|
+
crypto,
|
|
92
99
|
storageContext,
|
|
93
100
|
storageKey,
|
|
94
101
|
aboutToRolloverCallback,
|
|
@@ -97,12 +104,13 @@ export class PersistedMessageCounter extends MessageCounter {
|
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
constructor(
|
|
107
|
+
crypto: Crypto,
|
|
100
108
|
private readonly storageContext: StorageContext,
|
|
101
109
|
private readonly storageKey: string,
|
|
102
110
|
aboutToRolloverCallback?: () => void,
|
|
103
111
|
rolloverInfoDifference = ROLLOVER_INFO_DIFFERENCE,
|
|
104
112
|
) {
|
|
105
|
-
super(aboutToRolloverCallback, rolloverInfoDifference);
|
|
113
|
+
super(crypto, aboutToRolloverCallback, rolloverInfoDifference);
|
|
106
114
|
this.#construction = Construction(this, async () => {
|
|
107
115
|
if (await storageContext.has(storageKey)) {
|
|
108
116
|
this.messageCounter = await storageContext.get<number>(storageKey);
|
|
@@ -9,7 +9,6 @@ import { Fabric } from "#fabric/Fabric.js";
|
|
|
9
9
|
import { FabricManager } from "#fabric/FabricManager.js";
|
|
10
10
|
import {
|
|
11
11
|
Bytes,
|
|
12
|
-
Crypto,
|
|
13
12
|
CryptoDecryptError,
|
|
14
13
|
ImplementationError,
|
|
15
14
|
InternalError,
|
|
@@ -126,7 +125,12 @@ export class GroupSession extends SecureSession {
|
|
|
126
125
|
|
|
127
126
|
return {
|
|
128
127
|
header,
|
|
129
|
-
applicationPayload:
|
|
128
|
+
applicationPayload: this.#fabric.crypto.encrypt(
|
|
129
|
+
this.#operationalGroupKey,
|
|
130
|
+
applicationPayload,
|
|
131
|
+
nonce,
|
|
132
|
+
headerBytes,
|
|
133
|
+
),
|
|
130
134
|
};
|
|
131
135
|
}
|
|
132
136
|
|
|
@@ -179,7 +183,7 @@ export class GroupSession extends SecureSession {
|
|
|
179
183
|
try {
|
|
180
184
|
message = MessageCodec.decodePayload({
|
|
181
185
|
header,
|
|
182
|
-
applicationPayload:
|
|
186
|
+
applicationPayload: fabric.crypto.decrypt(key, applicationPayload, nonce, aad),
|
|
183
187
|
});
|
|
184
188
|
found = true;
|
|
185
189
|
break; // Exit loop on first successful decryption
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { Logger, MatterFlowError } from "#general";
|
|
7
|
+
import { Crypto, Logger, MatterFlowError } from "#general";
|
|
8
8
|
import { NodeId } from "#types";
|
|
9
9
|
import { DecodedMessage, DecodedPacket, Message, MessageCodec, Packet, SessionType } from "../codec/MessageCodec.js";
|
|
10
10
|
import { Fabric } from "../fabric/Fabric.js";
|
|
@@ -23,19 +23,20 @@ export class InsecureSession extends Session {
|
|
|
23
23
|
readonly type = SessionType.Unicast;
|
|
24
24
|
|
|
25
25
|
constructor(args: {
|
|
26
|
+
crypto: Crypto;
|
|
26
27
|
manager?: SessionManager;
|
|
27
28
|
messageCounter: MessageCounter;
|
|
28
29
|
initiatorNodeId?: NodeId;
|
|
29
30
|
sessionParameters?: SessionParameterOptions;
|
|
30
31
|
isInitiator?: boolean;
|
|
31
32
|
}) {
|
|
32
|
-
const { initiatorNodeId, isInitiator } = args;
|
|
33
|
+
const { crypto, initiatorNodeId, isInitiator } = args;
|
|
33
34
|
super({
|
|
34
35
|
...args,
|
|
35
36
|
setActiveTimestamp: !isInitiator, // When we are the initiator we assume the node is in idle mode
|
|
36
37
|
messageReceptionState: new MessageReceptionStateUnencryptedWithRollover(),
|
|
37
38
|
});
|
|
38
|
-
this.#initiatorNodeId = initiatorNodeId ?? NodeId.randomOperationalNodeId();
|
|
39
|
+
this.#initiatorNodeId = initiatorNodeId ?? NodeId.randomOperationalNodeId(crypto);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
get isSecure() {
|