@matter/protocol 0.15.0-alpha.0-20250612-ddd428561 → 0.15.0-alpha.0-20250614-b9829e223
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/events/OccurrenceManager.d.ts +1 -0
- package/dist/cjs/events/OccurrenceManager.d.ts.map +1 -1
- package/dist/cjs/events/OccurrenceManager.js +14 -8
- package/dist/cjs/events/OccurrenceManager.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/interaction/FabricAccessControl.js +1 -1
- package/dist/cjs/interaction/FabricAccessControl.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/MdnsScanner.d.ts +1 -1
- package/dist/cjs/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/cjs/mdns/MdnsScanner.js +2 -6
- package/dist/cjs/mdns/MdnsScanner.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/events/OccurrenceManager.d.ts +1 -0
- package/dist/esm/events/OccurrenceManager.d.ts.map +1 -1
- package/dist/esm/events/OccurrenceManager.js +14 -8
- package/dist/esm/events/OccurrenceManager.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/interaction/FabricAccessControl.js +1 -1
- package/dist/esm/interaction/FabricAccessControl.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/MdnsScanner.d.ts +1 -1
- package/dist/esm/mdns/MdnsScanner.d.ts.map +1 -1
- package/dist/esm/mdns/MdnsScanner.js +2 -6
- package/dist/esm/mdns/MdnsScanner.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/events/OccurrenceManager.ts +16 -9
- 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/interaction/FabricAccessControl.ts +1 -1
- package/src/mdns/MdnsBroadcaster.ts +11 -4
- package/src/mdns/MdnsScanner.ts +2 -6
- 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
package/src/fabric/Fabric.ts
CHANGED
|
@@ -49,6 +49,7 @@ export type ExposedFabricInformation = {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
export class Fabric {
|
|
52
|
+
readonly #certs: CertificateManager;
|
|
52
53
|
readonly fabricIndex: FabricIndex;
|
|
53
54
|
readonly fabricId: FabricId;
|
|
54
55
|
readonly nodeId: NodeId;
|
|
@@ -63,14 +64,18 @@ export class Fabric {
|
|
|
63
64
|
readonly operationalCert: Uint8Array;
|
|
64
65
|
readonly #keyPair: Key;
|
|
65
66
|
readonly #sessions = new Set<Session>();
|
|
66
|
-
readonly #
|
|
67
|
+
readonly #groups: FabricGroups;
|
|
67
68
|
readonly #aclManager: FabricAccessControl;
|
|
68
69
|
#label: string;
|
|
69
70
|
#removeCallbacks = new Array<() => MaybePromise<void>>();
|
|
70
71
|
#persistCallback: ((isUpdate?: boolean) => MaybePromise<void>) | undefined;
|
|
71
72
|
#storage?: StorageContext;
|
|
72
73
|
|
|
73
|
-
constructor(config: Fabric.Config) {
|
|
74
|
+
constructor(certs: CertificateManager | Crypto, config: Fabric.Config) {
|
|
75
|
+
if (!(certs instanceof CertificateManager)) {
|
|
76
|
+
certs = new CertificateManager(certs);
|
|
77
|
+
}
|
|
78
|
+
this.#certs = certs;
|
|
74
79
|
this.fabricIndex = config.fabricIndex;
|
|
75
80
|
this.fabricId = config.fabricId;
|
|
76
81
|
this.nodeId = config.nodeId;
|
|
@@ -86,7 +91,11 @@ export class Fabric {
|
|
|
86
91
|
this.#label = config.label;
|
|
87
92
|
this.#keyPair = PrivateKey(config.keyPair);
|
|
88
93
|
this.#aclManager = new FabricAccessControl(this);
|
|
89
|
-
this.#
|
|
94
|
+
this.#groups = new FabricGroups(this);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get crypto() {
|
|
98
|
+
return this.#certs.crypto;
|
|
90
99
|
}
|
|
91
100
|
|
|
92
101
|
get config(): Fabric.Config {
|
|
@@ -125,7 +134,7 @@ export class Fabric {
|
|
|
125
134
|
|
|
126
135
|
set storage(storage: StorageContext) {
|
|
127
136
|
this.#storage = storage;
|
|
128
|
-
this.#
|
|
137
|
+
this.#groups.storage = storage;
|
|
129
138
|
}
|
|
130
139
|
|
|
131
140
|
get storage(): StorageContext | undefined {
|
|
@@ -133,7 +142,7 @@ export class Fabric {
|
|
|
133
142
|
}
|
|
134
143
|
|
|
135
144
|
get groups() {
|
|
136
|
-
return this.#
|
|
145
|
+
return this.#groups;
|
|
137
146
|
}
|
|
138
147
|
|
|
139
148
|
get acl() {
|
|
@@ -145,7 +154,7 @@ export class Fabric {
|
|
|
145
154
|
}
|
|
146
155
|
|
|
147
156
|
sign(data: Uint8Array) {
|
|
148
|
-
return
|
|
157
|
+
return this.#certs.crypto.signEcdsa(this.#keyPair, data);
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
async verifyCredentials(operationalCert: Uint8Array, intermediateCACert?: Uint8Array) {
|
|
@@ -155,10 +164,10 @@ export class Fabric {
|
|
|
155
164
|
intermediateCACert !== undefined ? TlvIntermediateCertificate.decode(intermediateCACert) : undefined;
|
|
156
165
|
if (icaCert !== undefined) {
|
|
157
166
|
// Validate ICACertificate against Root Certificate
|
|
158
|
-
await
|
|
167
|
+
await this.#certs.verifyIntermediateCaCertificate(rootCert, icaCert);
|
|
159
168
|
}
|
|
160
169
|
// Validate NOC Certificate against ICA Certificate
|
|
161
|
-
await
|
|
170
|
+
await this.#certs.verifyNodeOperationalCertificate(nocCert, rootCert, icaCert);
|
|
162
171
|
}
|
|
163
172
|
|
|
164
173
|
matchesFabricIdAndRootPublicKey(fabricId: FabricId, rootPublicKey: Uint8Array) {
|
|
@@ -186,7 +195,10 @@ export class Fabric {
|
|
|
186
195
|
* returns the time-wise valid operational keys for that groupId.
|
|
187
196
|
*/
|
|
188
197
|
async currentDestinationIdFor(nodeId: NodeId, random: Uint8Array) {
|
|
189
|
-
return await
|
|
198
|
+
return await this.#certs.crypto.signHmac(
|
|
199
|
+
this.groups.keySets.currentKeyForId(0).key,
|
|
200
|
+
this.#generateSalt(nodeId, random),
|
|
201
|
+
);
|
|
190
202
|
}
|
|
191
203
|
|
|
192
204
|
/**
|
|
@@ -196,7 +208,9 @@ export class Fabric {
|
|
|
196
208
|
async destinationIdsFor(nodeId: NodeId, random: Uint8Array) {
|
|
197
209
|
const salt = this.#generateSalt(nodeId, random);
|
|
198
210
|
// Check all keys of keyset 0 - typically it is only the IPK
|
|
199
|
-
const destinationIds = this.groups.keySets
|
|
211
|
+
const destinationIds = this.groups.keySets
|
|
212
|
+
.allKeysForId(0)
|
|
213
|
+
.map(({ key }) => this.#certs.crypto.signHmac(key, salt));
|
|
200
214
|
return await Promise.all(destinationIds);
|
|
201
215
|
}
|
|
202
216
|
|
|
@@ -260,6 +274,7 @@ export class Fabric {
|
|
|
260
274
|
}
|
|
261
275
|
|
|
262
276
|
export class FabricBuilder {
|
|
277
|
+
#certs: CertificateManager;
|
|
263
278
|
#keyPair: PrivateKey;
|
|
264
279
|
#rootVendorId?: VendorId;
|
|
265
280
|
#rootCert?: Uint8Array;
|
|
@@ -273,12 +288,13 @@ export class FabricBuilder {
|
|
|
273
288
|
#fabricIndex?: FabricIndex;
|
|
274
289
|
#label = "";
|
|
275
290
|
|
|
276
|
-
constructor(key: PrivateKey) {
|
|
291
|
+
constructor(crypto: Crypto, key: PrivateKey) {
|
|
292
|
+
this.#certs = new CertificateManager(crypto);
|
|
277
293
|
this.#keyPair = key;
|
|
278
294
|
}
|
|
279
295
|
|
|
280
|
-
static async create() {
|
|
281
|
-
return new FabricBuilder(await
|
|
296
|
+
static async create(crypto: Crypto) {
|
|
297
|
+
return new FabricBuilder(crypto, await crypto.createKeyPair());
|
|
282
298
|
}
|
|
283
299
|
|
|
284
300
|
get publicKey() {
|
|
@@ -290,12 +306,12 @@ export class FabricBuilder {
|
|
|
290
306
|
}
|
|
291
307
|
|
|
292
308
|
createCertificateSigningRequest() {
|
|
293
|
-
return
|
|
309
|
+
return this.#certs.createCertificateSigningRequest(this.#keyPair);
|
|
294
310
|
}
|
|
295
311
|
|
|
296
312
|
async setRootCert(rootCert: Uint8Array) {
|
|
297
313
|
const decodedRootCertificate = TlvRootCertificate.decode(rootCert);
|
|
298
|
-
await
|
|
314
|
+
await this.#certs.verifyRootCertificate(decodedRootCertificate);
|
|
299
315
|
this.#rootCert = rootCert;
|
|
300
316
|
this.#rootPublicKey = decodedRootCertificate.ellipticCurvePublicKey;
|
|
301
317
|
return this;
|
|
@@ -334,9 +350,9 @@ export class FabricBuilder {
|
|
|
334
350
|
const icaCert =
|
|
335
351
|
intermediateCACert !== undefined ? TlvIntermediateCertificate.decode(intermediateCACert) : undefined;
|
|
336
352
|
if (icaCert !== undefined) {
|
|
337
|
-
await
|
|
353
|
+
await this.#certs.verifyIntermediateCaCertificate(rootCert, icaCert);
|
|
338
354
|
}
|
|
339
|
-
await
|
|
355
|
+
await this.#certs.verifyNodeOperationalCertificate(nocCert, rootCert, icaCert);
|
|
340
356
|
|
|
341
357
|
this.#operationalCert = operationalCert;
|
|
342
358
|
this.#intermediateCACert = intermediateCACert;
|
|
@@ -410,14 +426,14 @@ export class FabricBuilder {
|
|
|
410
426
|
this.#fabricIndex = fabricIndex;
|
|
411
427
|
const saltWriter = new DataWriter();
|
|
412
428
|
saltWriter.writeUInt64(this.#fabricId);
|
|
413
|
-
const operationalId = await
|
|
429
|
+
const operationalId = await this.#certs.crypto.createHkdfKey(
|
|
414
430
|
this.#rootPublicKey.slice(1),
|
|
415
431
|
saltWriter.toByteArray(),
|
|
416
432
|
COMPRESSED_FABRIC_ID_INFO,
|
|
417
433
|
8,
|
|
418
434
|
);
|
|
419
435
|
|
|
420
|
-
return new Fabric({
|
|
436
|
+
return new Fabric(this.#certs, {
|
|
421
437
|
fabricIndex: this.#fabricIndex,
|
|
422
438
|
fabricId: this.#fabricId,
|
|
423
439
|
nodeId: this.#nodeId,
|
|
@@ -428,7 +444,7 @@ export class FabricBuilder {
|
|
|
428
444
|
rootVendorId: this.#rootVendorId,
|
|
429
445
|
rootCert: this.#rootCert,
|
|
430
446
|
identityProtectionKey: this.#identityProtectionKey, // Epoch Key
|
|
431
|
-
operationalIdentityProtectionKey: await
|
|
447
|
+
operationalIdentityProtectionKey: await this.#certs.crypto.createHkdfKey(
|
|
432
448
|
this.#identityProtectionKey,
|
|
433
449
|
operationalId,
|
|
434
450
|
GROUP_SECURITY_INFO,
|
|
@@ -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;
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "#types";
|
|
22
22
|
import { AccessControl as AccessControlContext } from "../action/server/AccessControl.js";
|
|
23
23
|
|
|
24
|
-
const logger = Logger.get("
|
|
24
|
+
const logger = Logger.get("FabricAccessControl");
|
|
25
25
|
|
|
26
26
|
export type AclEntry = Omit<AccessControl.AccessControlEntry, "privilege"> & {
|
|
27
27
|
privilege: AccessLevel;
|
|
@@ -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/MdnsScanner.ts
CHANGED
|
@@ -120,9 +120,7 @@ export interface MdnsScannerTargetCriteria {
|
|
|
120
120
|
* queries to discover various types of Matter device types and listens for announcements.
|
|
121
121
|
*/
|
|
122
122
|
export class MdnsScanner implements Scanner {
|
|
123
|
-
|
|
124
|
-
return ChannelType.UDP;
|
|
125
|
-
}
|
|
123
|
+
readonly type = ChannelType.UDP;
|
|
126
124
|
|
|
127
125
|
static async create(network: Network, options?: { enableIpv4?: boolean; netInterface?: string }) {
|
|
128
126
|
const { enableIpv4, netInterface } = options ?? {};
|
|
@@ -502,9 +500,7 @@ export class MdnsScanner implements Scanner {
|
|
|
502
500
|
const { timer, resolver, resolveOnUpdatedRecords, commissionable } = waiter;
|
|
503
501
|
if (isUpdatedRecord && !resolveOnUpdatedRecords) return;
|
|
504
502
|
logger.debug(`Finishing waiter for query ${queryId}, resolving: ${resolvePromise}`);
|
|
505
|
-
|
|
506
|
-
timer.stop();
|
|
507
|
-
}
|
|
503
|
+
timer?.stop();
|
|
508
504
|
if (resolvePromise) {
|
|
509
505
|
resolver();
|
|
510
506
|
}
|
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
|
|