@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.
Files changed (252) hide show
  1. package/dist/cjs/certificate/AttestationCertificateManager.d.ts +3 -3
  2. package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
  3. package/dist/cjs/certificate/AttestationCertificateManager.js +12 -10
  4. package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
  5. package/dist/cjs/certificate/CertificateAuthority.d.ts +5 -3
  6. package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
  7. package/dist/cjs/certificate/CertificateAuthority.js +19 -11
  8. package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
  9. package/dist/cjs/certificate/CertificateManager.d.ts +18 -15
  10. package/dist/cjs/certificate/CertificateManager.d.ts.map +1 -1
  11. package/dist/cjs/certificate/CertificateManager.js +92 -83
  12. package/dist/cjs/certificate/CertificateManager.js.map +2 -2
  13. package/dist/cjs/certificate/CertificationDeclarationManager.d.ts +7 -1
  14. package/dist/cjs/certificate/CertificationDeclarationManager.d.ts.map +1 -1
  15. package/dist/cjs/certificate/CertificationDeclarationManager.js +2 -2
  16. package/dist/cjs/certificate/CertificationDeclarationManager.js.map +1 -1
  17. package/dist/cjs/certificate/DeviceCertification.d.ts +2 -2
  18. package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
  19. package/dist/cjs/certificate/DeviceCertification.js +10 -4
  20. package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
  21. package/dist/cjs/common/FailsafeContext.js +1 -1
  22. package/dist/cjs/common/FailsafeContext.js.map +1 -1
  23. package/dist/cjs/events/OccurrenceManager.d.ts +1 -0
  24. package/dist/cjs/events/OccurrenceManager.d.ts.map +1 -1
  25. package/dist/cjs/events/OccurrenceManager.js +14 -8
  26. package/dist/cjs/events/OccurrenceManager.js.map +1 -1
  27. package/dist/cjs/fabric/Fabric.d.ts +6 -4
  28. package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
  29. package/dist/cjs/fabric/Fabric.js +33 -20
  30. package/dist/cjs/fabric/Fabric.js.map +1 -1
  31. package/dist/cjs/fabric/FabricAuthority.d.ts +1 -1
  32. package/dist/cjs/fabric/FabricAuthority.d.ts.map +1 -1
  33. package/dist/cjs/fabric/FabricAuthority.js +7 -7
  34. package/dist/cjs/fabric/FabricAuthority.js.map +1 -1
  35. package/dist/cjs/fabric/FabricManager.d.ts +3 -2
  36. package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
  37. package/dist/cjs/fabric/FabricManager.js +8 -3
  38. package/dist/cjs/fabric/FabricManager.js.map +1 -1
  39. package/dist/cjs/fabric/TestFabric.d.ts.map +1 -1
  40. package/dist/cjs/fabric/TestFabric.js +15 -19
  41. package/dist/cjs/fabric/TestFabric.js.map +1 -1
  42. package/dist/cjs/groups/FabricGroups.d.ts.map +1 -1
  43. package/dist/cjs/groups/FabricGroups.js +11 -7
  44. package/dist/cjs/groups/FabricGroups.js.map +1 -1
  45. package/dist/cjs/groups/KeySets.d.ts +2 -2
  46. package/dist/cjs/groups/KeySets.d.ts.map +1 -1
  47. package/dist/cjs/groups/KeySets.js +2 -2
  48. package/dist/cjs/groups/KeySets.js.map +1 -1
  49. package/dist/cjs/groups/MessagingState.d.ts +2 -2
  50. package/dist/cjs/groups/MessagingState.d.ts.map +1 -1
  51. package/dist/cjs/groups/MessagingState.js +4 -2
  52. package/dist/cjs/groups/MessagingState.js.map +1 -1
  53. package/dist/cjs/interaction/FabricAccessControl.js +1 -1
  54. package/dist/cjs/interaction/FabricAccessControl.js.map +1 -1
  55. package/dist/cjs/mdns/MdnsBroadcaster.d.ts +3 -3
  56. package/dist/cjs/mdns/MdnsBroadcaster.d.ts.map +1 -1
  57. package/dist/cjs/mdns/MdnsBroadcaster.js +7 -4
  58. package/dist/cjs/mdns/MdnsBroadcaster.js.map +1 -1
  59. package/dist/cjs/mdns/MdnsScanner.d.ts +1 -1
  60. package/dist/cjs/mdns/MdnsScanner.d.ts.map +1 -1
  61. package/dist/cjs/mdns/MdnsScanner.js +2 -6
  62. package/dist/cjs/mdns/MdnsScanner.js.map +1 -1
  63. package/dist/cjs/mdns/MdnsService.d.ts.map +1 -1
  64. package/dist/cjs/mdns/MdnsService.js +2 -1
  65. package/dist/cjs/mdns/MdnsService.js.map +1 -1
  66. package/dist/cjs/peer/ControllerCommissioner.js +1 -1
  67. package/dist/cjs/peer/ControllerCommissioner.js.map +1 -1
  68. package/dist/cjs/peer/ControllerCommissioningFlow.d.ts +1 -1
  69. package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
  70. package/dist/cjs/peer/ControllerCommissioningFlow.js +3 -4
  71. package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
  72. package/dist/cjs/protocol/DeviceCommissioner.d.ts.map +1 -1
  73. package/dist/cjs/protocol/DeviceCommissioner.js +1 -1
  74. package/dist/cjs/protocol/DeviceCommissioner.js.map +1 -1
  75. package/dist/cjs/protocol/ExchangeManager.d.ts +4 -2
  76. package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
  77. package/dist/cjs/protocol/ExchangeManager.js +11 -6
  78. package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
  79. package/dist/cjs/protocol/MessageCounter.d.ts +4 -4
  80. package/dist/cjs/protocol/MessageCounter.d.ts.map +1 -1
  81. package/dist/cjs/protocol/MessageCounter.js +7 -6
  82. package/dist/cjs/protocol/MessageCounter.js.map +1 -1
  83. package/dist/cjs/session/GroupSession.d.ts.map +1 -1
  84. package/dist/cjs/session/GroupSession.js +7 -2
  85. package/dist/cjs/session/GroupSession.js.map +1 -1
  86. package/dist/cjs/session/InsecureSession.d.ts +2 -0
  87. package/dist/cjs/session/InsecureSession.d.ts.map +1 -1
  88. package/dist/cjs/session/InsecureSession.js +2 -2
  89. package/dist/cjs/session/InsecureSession.js.map +1 -1
  90. package/dist/cjs/session/NodeSession.d.ts +3 -1
  91. package/dist/cjs/session/NodeSession.d.ts.map +1 -1
  92. package/dist/cjs/session/NodeSession.js +21 -13
  93. package/dist/cjs/session/NodeSession.js.map +1 -1
  94. package/dist/cjs/session/SessionManager.d.ts +1 -0
  95. package/dist/cjs/session/SessionManager.d.ts.map +1 -1
  96. package/dist/cjs/session/SessionManager.js +13 -3
  97. package/dist/cjs/session/SessionManager.js.map +1 -1
  98. package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
  99. package/dist/cjs/session/case/CaseClient.js +16 -15
  100. package/dist/cjs/session/case/CaseClient.js.map +1 -1
  101. package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
  102. package/dist/cjs/session/case/CaseServer.js +22 -18
  103. package/dist/cjs/session/case/CaseServer.js.map +1 -1
  104. package/dist/cjs/session/pase/PaseClient.d.ts +4 -4
  105. package/dist/cjs/session/pase/PaseClient.d.ts.map +1 -1
  106. package/dist/cjs/session/pase/PaseClient.js +11 -9
  107. package/dist/cjs/session/pase/PaseClient.js.map +1 -1
  108. package/dist/cjs/session/pase/PaseServer.d.ts.map +1 -1
  109. package/dist/cjs/session/pase/PaseServer.js +6 -5
  110. package/dist/cjs/session/pase/PaseServer.js.map +1 -1
  111. package/dist/esm/certificate/AttestationCertificateManager.d.ts +3 -3
  112. package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
  113. package/dist/esm/certificate/AttestationCertificateManager.js +13 -11
  114. package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
  115. package/dist/esm/certificate/CertificateAuthority.d.ts +5 -3
  116. package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
  117. package/dist/esm/certificate/CertificateAuthority.js +19 -11
  118. package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
  119. package/dist/esm/certificate/CertificateManager.d.ts +18 -15
  120. package/dist/esm/certificate/CertificateManager.d.ts.map +1 -1
  121. package/dist/esm/certificate/CertificateManager.js +92 -84
  122. package/dist/esm/certificate/CertificateManager.js.map +2 -2
  123. package/dist/esm/certificate/CertificationDeclarationManager.d.ts +7 -1
  124. package/dist/esm/certificate/CertificationDeclarationManager.d.ts.map +1 -1
  125. package/dist/esm/certificate/CertificationDeclarationManager.js +2 -2
  126. package/dist/esm/certificate/CertificationDeclarationManager.js.map +1 -1
  127. package/dist/esm/certificate/DeviceCertification.d.ts +2 -2
  128. package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
  129. package/dist/esm/certificate/DeviceCertification.js +11 -5
  130. package/dist/esm/certificate/DeviceCertification.js.map +1 -1
  131. package/dist/esm/common/FailsafeContext.js +1 -1
  132. package/dist/esm/common/FailsafeContext.js.map +1 -1
  133. package/dist/esm/events/OccurrenceManager.d.ts +1 -0
  134. package/dist/esm/events/OccurrenceManager.d.ts.map +1 -1
  135. package/dist/esm/events/OccurrenceManager.js +14 -8
  136. package/dist/esm/events/OccurrenceManager.js.map +1 -1
  137. package/dist/esm/fabric/Fabric.d.ts +6 -4
  138. package/dist/esm/fabric/Fabric.d.ts.map +1 -1
  139. package/dist/esm/fabric/Fabric.js +33 -21
  140. package/dist/esm/fabric/Fabric.js.map +1 -1
  141. package/dist/esm/fabric/FabricAuthority.d.ts +1 -1
  142. package/dist/esm/fabric/FabricAuthority.d.ts.map +1 -1
  143. package/dist/esm/fabric/FabricAuthority.js +8 -15
  144. package/dist/esm/fabric/FabricAuthority.js.map +1 -1
  145. package/dist/esm/fabric/FabricManager.d.ts +3 -2
  146. package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
  147. package/dist/esm/fabric/FabricManager.js +9 -3
  148. package/dist/esm/fabric/FabricManager.js.map +1 -1
  149. package/dist/esm/fabric/TestFabric.d.ts.map +1 -1
  150. package/dist/esm/fabric/TestFabric.js +16 -20
  151. package/dist/esm/fabric/TestFabric.js.map +1 -1
  152. package/dist/esm/groups/FabricGroups.d.ts.map +1 -1
  153. package/dist/esm/groups/FabricGroups.js +12 -8
  154. package/dist/esm/groups/FabricGroups.js.map +1 -1
  155. package/dist/esm/groups/KeySets.d.ts +2 -2
  156. package/dist/esm/groups/KeySets.d.ts.map +1 -1
  157. package/dist/esm/groups/KeySets.js +3 -3
  158. package/dist/esm/groups/KeySets.js.map +1 -1
  159. package/dist/esm/groups/MessagingState.d.ts +2 -2
  160. package/dist/esm/groups/MessagingState.d.ts.map +1 -1
  161. package/dist/esm/groups/MessagingState.js +4 -2
  162. package/dist/esm/groups/MessagingState.js.map +1 -1
  163. package/dist/esm/interaction/FabricAccessControl.js +1 -1
  164. package/dist/esm/interaction/FabricAccessControl.js.map +1 -1
  165. package/dist/esm/mdns/MdnsBroadcaster.d.ts +3 -3
  166. package/dist/esm/mdns/MdnsBroadcaster.d.ts.map +1 -1
  167. package/dist/esm/mdns/MdnsBroadcaster.js +7 -5
  168. package/dist/esm/mdns/MdnsBroadcaster.js.map +1 -1
  169. package/dist/esm/mdns/MdnsScanner.d.ts +1 -1
  170. package/dist/esm/mdns/MdnsScanner.d.ts.map +1 -1
  171. package/dist/esm/mdns/MdnsScanner.js +2 -6
  172. package/dist/esm/mdns/MdnsScanner.js.map +1 -1
  173. package/dist/esm/mdns/MdnsService.d.ts.map +1 -1
  174. package/dist/esm/mdns/MdnsService.js +3 -1
  175. package/dist/esm/mdns/MdnsService.js.map +1 -1
  176. package/dist/esm/peer/ControllerCommissioner.js +1 -1
  177. package/dist/esm/peer/ControllerCommissioner.js.map +1 -1
  178. package/dist/esm/peer/ControllerCommissioningFlow.d.ts +1 -1
  179. package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
  180. package/dist/esm/peer/ControllerCommissioningFlow.js +3 -5
  181. package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
  182. package/dist/esm/protocol/DeviceCommissioner.d.ts.map +1 -1
  183. package/dist/esm/protocol/DeviceCommissioner.js +1 -2
  184. package/dist/esm/protocol/DeviceCommissioner.js.map +1 -1
  185. package/dist/esm/protocol/ExchangeManager.d.ts +4 -2
  186. package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
  187. package/dist/esm/protocol/ExchangeManager.js +11 -6
  188. package/dist/esm/protocol/ExchangeManager.js.map +1 -1
  189. package/dist/esm/protocol/MessageCounter.d.ts +4 -4
  190. package/dist/esm/protocol/MessageCounter.d.ts.map +1 -1
  191. package/dist/esm/protocol/MessageCounter.js +8 -7
  192. package/dist/esm/protocol/MessageCounter.js.map +1 -1
  193. package/dist/esm/session/GroupSession.d.ts.map +1 -1
  194. package/dist/esm/session/GroupSession.js +7 -3
  195. package/dist/esm/session/GroupSession.js.map +1 -1
  196. package/dist/esm/session/InsecureSession.d.ts +2 -0
  197. package/dist/esm/session/InsecureSession.d.ts.map +1 -1
  198. package/dist/esm/session/InsecureSession.js +2 -2
  199. package/dist/esm/session/InsecureSession.js.map +1 -1
  200. package/dist/esm/session/NodeSession.d.ts +3 -1
  201. package/dist/esm/session/NodeSession.d.ts.map +1 -1
  202. package/dist/esm/session/NodeSession.js +22 -14
  203. package/dist/esm/session/NodeSession.js.map +1 -1
  204. package/dist/esm/session/SessionManager.d.ts +1 -0
  205. package/dist/esm/session/SessionManager.d.ts.map +1 -1
  206. package/dist/esm/session/SessionManager.js +13 -4
  207. package/dist/esm/session/SessionManager.js.map +1 -1
  208. package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
  209. package/dist/esm/session/case/CaseClient.js +17 -16
  210. package/dist/esm/session/case/CaseClient.js.map +1 -1
  211. package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
  212. package/dist/esm/session/case/CaseServer.js +23 -19
  213. package/dist/esm/session/case/CaseServer.js.map +1 -1
  214. package/dist/esm/session/pase/PaseClient.d.ts +4 -4
  215. package/dist/esm/session/pase/PaseClient.d.ts.map +1 -1
  216. package/dist/esm/session/pase/PaseClient.js +12 -10
  217. package/dist/esm/session/pase/PaseClient.js.map +1 -1
  218. package/dist/esm/session/pase/PaseServer.d.ts.map +1 -1
  219. package/dist/esm/session/pase/PaseServer.js +6 -6
  220. package/dist/esm/session/pase/PaseServer.js.map +1 -1
  221. package/package.json +6 -6
  222. package/src/certificate/AttestationCertificateManager.ts +12 -10
  223. package/src/certificate/CertificateAuthority.ts +20 -11
  224. package/src/certificate/CertificateManager.ts +77 -72
  225. package/src/certificate/CertificationDeclarationManager.ts +3 -3
  226. package/src/certificate/DeviceCertification.ts +10 -4
  227. package/src/common/FailsafeContext.ts +1 -1
  228. package/src/events/OccurrenceManager.ts +16 -9
  229. package/src/fabric/Fabric.ts +36 -20
  230. package/src/fabric/FabricAuthority.ts +8 -16
  231. package/src/fabric/FabricManager.ts +10 -3
  232. package/src/fabric/TestFabric.ts +17 -22
  233. package/src/groups/FabricGroups.ts +20 -8
  234. package/src/groups/KeySets.ts +2 -2
  235. package/src/groups/MessagingState.ts +6 -3
  236. package/src/interaction/FabricAccessControl.ts +1 -1
  237. package/src/mdns/MdnsBroadcaster.ts +11 -4
  238. package/src/mdns/MdnsScanner.ts +2 -6
  239. package/src/mdns/MdnsService.ts +3 -1
  240. package/src/peer/ControllerCommissioner.ts +1 -1
  241. package/src/peer/ControllerCommissioningFlow.ts +4 -6
  242. package/src/protocol/DeviceCommissioner.ts +1 -2
  243. package/src/protocol/ExchangeManager.ts +13 -6
  244. package/src/protocol/MessageCounter.ts +11 -3
  245. package/src/session/GroupSession.ts +7 -3
  246. package/src/session/InsecureSession.ts +4 -3
  247. package/src/session/NodeSession.ts +25 -14
  248. package/src/session/SessionManager.ts +14 -4
  249. package/src/session/case/CaseClient.ts +18 -16
  250. package/src/session/case/CaseServer.ts +22 -17
  251. package/src/session/pase/PaseClient.ts +11 -9
  252. package/src/session/pase/PaseServer.ts +6 -5
@@ -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 #groupManager: FabricGroups;
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.#groupManager = new FabricGroups(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.#groupManager.storage = storage;
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.#groupManager;
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 Crypto.signEcdsa(this.#keyPair, data);
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 CertificateManager.verifyIntermediateCaCertificate(rootCert, icaCert);
167
+ await this.#certs.verifyIntermediateCaCertificate(rootCert, icaCert);
159
168
  }
160
169
  // Validate NOC Certificate against ICA Certificate
161
- await CertificateManager.verifyNodeOperationalCertificate(nocCert, rootCert, icaCert);
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 Crypto.signHmac(this.groups.keySets.currentKeyForId(0).key, this.#generateSalt(nodeId, random));
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.allKeysForId(0).map(({ key }) => Crypto.signHmac(key, salt));
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 Crypto.createKeyPair());
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 CertificateManager.createCertificateSigningRequest(this.#keyPair);
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 CertificateManager.verifyRootCertificate(decodedRootCertificate);
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 CertificateManager.verifyIntermediateCaCertificate(rootCert, icaCert);
353
+ await this.#certs.verifyIntermediateCaCertificate(rootCert, icaCert);
338
354
  }
339
- await CertificateManager.verifyNodeOperationalCertificate(nocCert, rootCert, icaCert);
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 Crypto.createHkdfKey(
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 Crypto.createHkdfKey(
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(context: FabricAuthorityContext) {
64
- this.#ca = context.ca;
65
- this.#fabrics = context.fabrics;
66
- this.#config = context.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 = Crypto.getRandomData(CRYPTO_SYMMETRIC_KEY_LENGTH);
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
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { CertificateAuthority } from "#certificate/CertificateAuthority.js";
8
- import { ImplementationError, nonentropic } from "#general";
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
- return forFabric(index, async () => {
44
- const authority = new FabricAuthority({
45
- ca: await CertificateAuthority.create(),
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
- const createFabric = authority.createFabric.bind(authority);
55
- authority.createFabric = () => forFabric(index ?? 1, createFabric);
47
+ if (!fabrics) {
48
+ fabrics = new FabricManager(MockCrypto(index));
49
+ }
56
50
 
57
- return authority;
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, Crypto, InternalError, MatterFlowError, StorageContext } from "#general";
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 Crypto.createHkdfKey(epochKey0, operationalId, GROUP_SECURITY_INFO);
125
+ const operationalEpochKey0 = await this.#fabric.crypto.createHkdfKey(
126
+ epochKey0,
127
+ operationalId,
128
+ GROUP_SECURITY_INFO,
129
+ );
126
130
  const operationalEpochKey1 =
127
- epochKey1 !== null ? await Crypto.createHkdfKey(epochKey1, operationalId, GROUP_SECURITY_INFO) : null;
131
+ epochKey1 !== null
132
+ ? await this.#fabric.crypto.createHkdfKey(epochKey1, operationalId, GROUP_SECURITY_INFO)
133
+ : null;
128
134
  const operationalEpochKey2 =
129
- epochKey2 !== null ? await Crypto.createHkdfKey(epochKey2, operationalId, GROUP_SECURITY_INFO) : 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 ? await this.#keySets.sessionIdFromKey(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 ? await this.#keySets.sessionIdFromKey(operationalEpochKey2) : null,
149
+ operationalEpochKey2 !== null
150
+ ? await this.#keySets.sessionIdFromKey(this.#fabric.crypto, operationalEpochKey2)
151
+ : null,
140
152
  });
141
153
  }
142
154
 
@@ -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 Crypto.createHkdfKey(operationalGroupKey, new Uint8Array(), GROUP_KEY_INFO, 2);
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("FabricAccessControlManager");
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(network: Network, options?: { enableIpv4?: boolean; multicastInterface?: string }) {
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(Crypto.getRandomData(8)).toUpperCase();
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(Crypto.getRandomData(8)).toUpperCase();
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}`;
@@ -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
- get type() {
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
- if (timer !== undefined) {
506
- timer.stop();
507
- }
503
+ timer?.stop();
508
504
  if (resolvePromise) {
509
505
  resolver();
510
506
  }
@@ -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
- /** CertificateManager of the controller. */
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: Crypto.getRandomData(32),
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: Crypto.getRandomData(32) },
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 CertificateManager.getPublicKeyFromCsr(certSigningRequest);
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: Crypto.getRandomData(32),
155
+ salt: this.#context.fabrics.crypto.randomBytes(32),
157
156
  }),
158
157
  );
159
158