@matter/protocol 0.13.1-alpha.0-20250506-f9ad9c3d8 → 0.13.1-alpha.0-20250508-047aa0277

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 (109) hide show
  1. package/dist/cjs/certificate/AttestationCertificateManager.d.ts +7 -13
  2. package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
  3. package/dist/cjs/certificate/AttestationCertificateManager.js +37 -29
  4. package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
  5. package/dist/cjs/certificate/CertificateAuthority.d.ts +1 -6
  6. package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
  7. package/dist/cjs/certificate/CertificateAuthority.js +56 -38
  8. package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
  9. package/dist/cjs/certificate/CertificateManager.d.ts +8 -8
  10. package/dist/cjs/certificate/CertificateManager.d.ts.map +1 -1
  11. package/dist/cjs/certificate/CertificateManager.js +20 -16
  12. package/dist/cjs/certificate/CertificateManager.js.map +1 -1
  13. package/dist/cjs/certificate/DeviceCertification.d.ts +1 -1
  14. package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
  15. package/dist/cjs/certificate/DeviceCertification.js +24 -26
  16. package/dist/cjs/certificate/DeviceCertification.js.map +2 -2
  17. package/dist/cjs/common/FailsafeContext.d.ts +2 -2
  18. package/dist/cjs/common/FailsafeContext.d.ts.map +1 -1
  19. package/dist/cjs/common/FailsafeContext.js +20 -13
  20. package/dist/cjs/common/FailsafeContext.js.map +1 -1
  21. package/dist/cjs/fabric/Fabric.d.ts +8 -6
  22. package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
  23. package/dist/cjs/fabric/Fabric.js +15 -9
  24. package/dist/cjs/fabric/Fabric.js.map +1 -1
  25. package/dist/cjs/fabric/FabricAuthority.d.ts.map +1 -1
  26. package/dist/cjs/fabric/FabricAuthority.js +5 -3
  27. package/dist/cjs/fabric/FabricAuthority.js.map +1 -1
  28. package/dist/cjs/fabric/FabricManager.d.ts +1 -1
  29. package/dist/cjs/fabric/FabricManager.d.ts.map +1 -1
  30. package/dist/cjs/fabric/FabricManager.js +2 -2
  31. package/dist/cjs/fabric/FabricManager.js.map +1 -1
  32. package/dist/cjs/peer/ControllerCommissioningFlow.js +2 -2
  33. package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
  34. package/dist/cjs/session/SessionManager.d.ts +4 -0
  35. package/dist/cjs/session/SessionManager.d.ts.map +1 -1
  36. package/dist/cjs/session/SessionManager.js +11 -2
  37. package/dist/cjs/session/SessionManager.js.map +1 -1
  38. package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
  39. package/dist/cjs/session/case/CaseClient.js +13 -10
  40. package/dist/cjs/session/case/CaseClient.js.map +1 -1
  41. package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
  42. package/dist/cjs/session/case/CaseServer.js +11 -8
  43. package/dist/cjs/session/case/CaseServer.js.map +1 -1
  44. package/dist/cjs/session/pase/PaseClient.js +1 -1
  45. package/dist/cjs/session/pase/PaseClient.js.map +1 -1
  46. package/dist/cjs/session/pase/PaseServer.js +1 -1
  47. package/dist/cjs/session/pase/PaseServer.js.map +1 -1
  48. package/dist/esm/certificate/AttestationCertificateManager.d.ts +7 -13
  49. package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
  50. package/dist/esm/certificate/AttestationCertificateManager.js +37 -29
  51. package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
  52. package/dist/esm/certificate/CertificateAuthority.d.ts +1 -6
  53. package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
  54. package/dist/esm/certificate/CertificateAuthority.js +57 -38
  55. package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
  56. package/dist/esm/certificate/CertificateManager.d.ts +8 -8
  57. package/dist/esm/certificate/CertificateManager.d.ts.map +1 -1
  58. package/dist/esm/certificate/CertificateManager.js +20 -16
  59. package/dist/esm/certificate/CertificateManager.js.map +1 -1
  60. package/dist/esm/certificate/DeviceCertification.d.ts +1 -1
  61. package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
  62. package/dist/esm/certificate/DeviceCertification.js +24 -26
  63. package/dist/esm/certificate/DeviceCertification.js.map +2 -2
  64. package/dist/esm/common/FailsafeContext.d.ts +2 -2
  65. package/dist/esm/common/FailsafeContext.d.ts.map +1 -1
  66. package/dist/esm/common/FailsafeContext.js +28 -14
  67. package/dist/esm/common/FailsafeContext.js.map +1 -1
  68. package/dist/esm/fabric/Fabric.d.ts +8 -6
  69. package/dist/esm/fabric/Fabric.d.ts.map +1 -1
  70. package/dist/esm/fabric/Fabric.js +15 -9
  71. package/dist/esm/fabric/Fabric.js.map +1 -1
  72. package/dist/esm/fabric/FabricAuthority.d.ts.map +1 -1
  73. package/dist/esm/fabric/FabricAuthority.js +5 -3
  74. package/dist/esm/fabric/FabricAuthority.js.map +1 -1
  75. package/dist/esm/fabric/FabricManager.d.ts +1 -1
  76. package/dist/esm/fabric/FabricManager.d.ts.map +1 -1
  77. package/dist/esm/fabric/FabricManager.js +2 -2
  78. package/dist/esm/fabric/FabricManager.js.map +1 -1
  79. package/dist/esm/peer/ControllerCommissioningFlow.js +2 -2
  80. package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
  81. package/dist/esm/session/SessionManager.d.ts +4 -0
  82. package/dist/esm/session/SessionManager.d.ts.map +1 -1
  83. package/dist/esm/session/SessionManager.js +11 -2
  84. package/dist/esm/session/SessionManager.js.map +1 -1
  85. package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
  86. package/dist/esm/session/case/CaseClient.js +13 -10
  87. package/dist/esm/session/case/CaseClient.js.map +1 -1
  88. package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
  89. package/dist/esm/session/case/CaseServer.js +11 -8
  90. package/dist/esm/session/case/CaseServer.js.map +1 -1
  91. package/dist/esm/session/pase/PaseClient.js +1 -1
  92. package/dist/esm/session/pase/PaseClient.js.map +1 -1
  93. package/dist/esm/session/pase/PaseServer.js +1 -1
  94. package/dist/esm/session/pase/PaseServer.js.map +1 -1
  95. package/package.json +6 -6
  96. package/src/certificate/AttestationCertificateManager.ts +37 -27
  97. package/src/certificate/CertificateAuthority.ts +60 -38
  98. package/src/certificate/CertificateManager.ts +20 -16
  99. package/src/certificate/DeviceCertification.ts +28 -32
  100. package/src/common/FailsafeContext.ts +29 -14
  101. package/src/fabric/Fabric.ts +17 -9
  102. package/src/fabric/FabricAuthority.ts +5 -4
  103. package/src/fabric/FabricManager.ts +2 -2
  104. package/src/peer/ControllerCommissioningFlow.ts +2 -2
  105. package/src/session/SessionManager.ts +13 -2
  106. package/src/session/case/CaseClient.ts +13 -10
  107. package/src/session/case/CaseServer.ts +11 -8
  108. package/src/session/pase/PaseClient.ts +1 -1
  109. package/src/session/pase/PaseServer.ts +1 -1
@@ -171,17 +171,17 @@ export class Fabric {
171
171
  return Crypto.sign(this.#keyPair, data);
172
172
  }
173
173
 
174
- verifyCredentials(operationalCert: Uint8Array, intermediateCACert?: Uint8Array) {
174
+ async verifyCredentials(operationalCert: Uint8Array, intermediateCACert?: Uint8Array) {
175
175
  const rootCert = TlvRootCertificate.decode(this.rootCert);
176
176
  const nocCert = TlvOperationalCertificate.decode(operationalCert);
177
177
  const icaCert =
178
178
  intermediateCACert !== undefined ? TlvIntermediateCertificate.decode(intermediateCACert) : undefined;
179
179
  if (icaCert !== undefined) {
180
180
  // Validate ICACertificate against Root Certificate
181
- CertificateManager.verifyIntermediateCaCertificate(rootCert, icaCert);
181
+ await CertificateManager.verifyIntermediateCaCertificate(rootCert, icaCert);
182
182
  }
183
183
  // Validate NOC Certificate against ICA Certificate
184
- CertificateManager.verifyNodeOperationalCertificate(nocCert, rootCert, icaCert);
184
+ await CertificateManager.verifyNodeOperationalCertificate(nocCert, rootCert, icaCert);
185
185
  }
186
186
 
187
187
  matchesFabricIdAndRootPublicKey(fabricId: FabricId, rootPublicKey: Uint8Array) {
@@ -331,7 +331,7 @@ export class Fabric {
331
331
  }
332
332
 
333
333
  export class FabricBuilder {
334
- #keyPair = Crypto.createKeyPair();
334
+ #keyPair: PrivateKey;
335
335
  #rootVendorId?: VendorId;
336
336
  #rootCert?: Uint8Array;
337
337
  #intermediateCACert?: Uint8Array;
@@ -344,6 +344,14 @@ export class FabricBuilder {
344
344
  #fabricIndex?: FabricIndex;
345
345
  #label = "";
346
346
 
347
+ constructor(key: PrivateKey) {
348
+ this.#keyPair = key;
349
+ }
350
+
351
+ static async create() {
352
+ return new FabricBuilder(await Crypto.createKeyPair());
353
+ }
354
+
347
355
  get publicKey() {
348
356
  return this.#keyPair.publicKey;
349
357
  }
@@ -356,9 +364,9 @@ export class FabricBuilder {
356
364
  return CertificateManager.createCertificateSigningRequest(this.#keyPair);
357
365
  }
358
366
 
359
- setRootCert(rootCert: Uint8Array) {
367
+ async setRootCert(rootCert: Uint8Array) {
360
368
  const decodedRootCertificate = TlvRootCertificate.decode(rootCert);
361
- CertificateManager.verifyRootCertificate(decodedRootCertificate);
369
+ await CertificateManager.verifyRootCertificate(decodedRootCertificate);
362
370
  this.#rootCert = rootCert;
363
371
  this.#rootPublicKey = decodedRootCertificate.ellipticCurvePublicKey;
364
372
  return this;
@@ -368,7 +376,7 @@ export class FabricBuilder {
368
376
  return this.#rootCert;
369
377
  }
370
378
 
371
- setOperationalCert(operationalCert: Uint8Array, intermediateCACert?: Uint8Array) {
379
+ async setOperationalCert(operationalCert: Uint8Array, intermediateCACert?: Uint8Array) {
372
380
  if (intermediateCACert !== undefined && intermediateCACert.length === 0) {
373
381
  intermediateCACert = undefined;
374
382
  }
@@ -396,9 +404,9 @@ export class FabricBuilder {
396
404
  const icaCert =
397
405
  intermediateCACert !== undefined ? TlvIntermediateCertificate.decode(intermediateCACert) : undefined;
398
406
  if (icaCert !== undefined) {
399
- CertificateManager.verifyIntermediateCaCertificate(rootCert, icaCert);
407
+ await CertificateManager.verifyIntermediateCaCertificate(rootCert, icaCert);
400
408
  }
401
- CertificateManager.verifyNodeOperationalCertificate(nocCert, rootCert, icaCert);
409
+ await CertificateManager.verifyNodeOperationalCertificate(nocCert, rootCert, icaCert);
402
410
 
403
411
  this.#operationalCert = operationalCert;
404
412
  this.#intermediateCACert = intermediateCACert;
@@ -110,15 +110,16 @@ export class FabricAuthority {
110
110
  logger.warn(`Using test vendor ID 0x${vendorId.toString(16)} for controller fabric`);
111
111
  }
112
112
 
113
- const fabricBuilder = new FabricBuilder()
114
- .setRootCert(this.#ca.rootCert)
113
+ const fabricBuilder = await FabricBuilder.create();
114
+ await fabricBuilder.setRootCert(this.#ca.rootCert);
115
+ fabricBuilder
115
116
  .setRootNodeId(rootNodeId)
116
117
  .setIdentityProtectionKey(ipkValue)
117
118
  .setRootVendorId(this.#config.adminVendorId ?? DEFAULT_ADMIN_VENDOR_ID)
118
119
  .setLabel(this.#config.adminFabricLabel);
119
120
 
120
- fabricBuilder.setOperationalCert(
121
- this.#ca.generateNoc(
121
+ await fabricBuilder.setOperationalCert(
122
+ await this.#ca.generateNoc(
122
123
  fabricBuilder.publicKey,
123
124
  this.#config.fabricId ?? DEFAULT_FABRIC_ID,
124
125
  rootNodeId,
@@ -210,11 +210,11 @@ export class FabricManager {
210
210
  return this.fabrics.map(translator);
211
211
  }
212
212
 
213
- findFabricFromDestinationId(destinationId: Uint8Array, initiatorRandom: Uint8Array) {
213
+ async findFabricFromDestinationId(destinationId: Uint8Array, initiatorRandom: Uint8Array) {
214
214
  this.#construction.assert();
215
215
 
216
216
  for (const fabric of this.#fabrics.values()) {
217
- const candidateDestinationId = fabric.getDestinationId(fabric.nodeId, initiatorRandom);
217
+ const candidateDestinationId = await fabric.getDestinationId(fabric.nodeId, initiatorRandom);
218
218
  if (!Bytes.areEqual(candidateDestinationId, destinationId)) continue;
219
219
  return fabric;
220
220
  }
@@ -762,7 +762,7 @@ export class ControllerCommissioningFlow {
762
762
  }
763
763
  // TODO: validate csrSignature using device public key
764
764
  const { certSigningRequest } = TlvCertSigningRequest.decode(nocsrElements);
765
- const operationalPublicKey = CertificateManager.getPublicKeyFromCsr(certSigningRequest);
765
+ const operationalPublicKey = await CertificateManager.getPublicKeyFromCsr(certSigningRequest);
766
766
 
767
767
  await operationalCredentialsClusterClient.addTrustedRootCertificate(
768
768
  {
@@ -770,7 +770,7 @@ export class ControllerCommissioningFlow {
770
770
  },
771
771
  { useExtendedFailSafeMessageResponseTimeout: true },
772
772
  );
773
- const peerOperationalCert = this.ca.generateNoc(
773
+ const peerOperationalCert = await this.ca.generateNoc(
774
774
  operationalPublicKey,
775
775
  this.fabric.fabricId,
776
776
  this.interactionClient.address.nodeId,
@@ -110,6 +110,8 @@ export interface SessionManagerContext {
110
110
  owner?: unknown;
111
111
  }
112
112
 
113
+ const ID_SPACE_UPPER_BOUND = 0xffff;
114
+
113
115
  /**
114
116
  * Manages Matter sessions associated with peer connections.
115
117
  */
@@ -126,6 +128,7 @@ export class SessionManager {
126
128
  readonly #construction: Construction<SessionManager>;
127
129
  readonly #observers = new ObserverGroup();
128
130
  readonly #subscriptionUpdateMutex = new Mutex(this);
131
+ #idUpperBound = ID_SPACE_UPPER_BOUND;
129
132
 
130
133
  constructor(context: SessionManagerContext) {
131
134
  this.#context = context;
@@ -342,9 +345,9 @@ export class SessionManager {
342
345
  async getNextAvailableSessionId() {
343
346
  await this.#construction;
344
347
 
345
- for (let i = 0; i < 0xffff; i++) {
348
+ for (let i = 0; i < this.#idUpperBound; i++) {
346
349
  const id = this.#nextSessionId;
347
- this.#nextSessionId = (this.#nextSessionId + 1) & 0xffff;
350
+ this.#nextSessionId = (this.#nextSessionId + 1) & this.#idUpperBound;
348
351
  if (this.#nextSessionId === 0) this.#nextSessionId++;
349
352
 
350
353
  if (this.getSession(id) === undefined) {
@@ -592,6 +595,14 @@ export class SessionManager {
592
595
  }
593
596
  return clearedCount;
594
597
  }
598
+
599
+ /**
600
+ * Compress range of IDs. This is intended for testing.
601
+ */
602
+ compressIdRange(upperBound: number) {
603
+ this.#idUpperBound = upperBound;
604
+ this.#nextSessionId = Crypto.getRandomUInt32() % upperBound;
605
+ }
595
606
  }
596
607
 
597
608
  namespace SessionManager {
@@ -41,7 +41,7 @@ export class CaseClient {
41
41
  const initiatorRandom = Crypto.getRandom();
42
42
  const initiatorSessionId = await this.#sessions.getNextAvailableSessionId(); // Initiator Session Id
43
43
  const { operationalIdentityProtectionKey, operationalCert: nodeOpCert, intermediateCACert } = fabric;
44
- const { publicKey: initiatorEcdhPublicKey, ecdh } = Crypto.ecdhGeneratePublicKey();
44
+ const { publicKey: initiatorEcdhPublicKey, ecdh } = await Crypto.ecdhGeneratePublicKey();
45
45
 
46
46
  // Send sigma1
47
47
  let sigma1Bytes;
@@ -57,7 +57,7 @@ export class CaseClient {
57
57
  const initiatorResumeMic = Crypto.encrypt(resumeKey, new Uint8Array(0), RESUME1_MIC_NONCE);
58
58
  sigma1Bytes = await messenger.sendSigma1({
59
59
  initiatorSessionId,
60
- destinationId: fabric.getDestinationId(peerNodeId, initiatorRandom),
60
+ destinationId: await fabric.getDestinationId(peerNodeId, initiatorRandom),
61
61
  initiatorEcdhPublicKey,
62
62
  initiatorRandom,
63
63
  resumptionId,
@@ -67,7 +67,7 @@ export class CaseClient {
67
67
  } else {
68
68
  sigma1Bytes = await messenger.sendSigma1({
69
69
  initiatorSessionId,
70
- destinationId: fabric.getDestinationId(peerNodeId, initiatorRandom),
70
+ destinationId: await fabric.getDestinationId(peerNodeId, initiatorRandom),
71
71
  initiatorEcdhPublicKey,
72
72
  initiatorRandom,
73
73
  initiatorSessionParams: this.#sessions.sessionParameters,
@@ -133,12 +133,12 @@ export class CaseClient {
133
133
  ...exchange.session.parameters,
134
134
  ...(responderSessionParams ?? {}),
135
135
  };
136
- const sharedSecret = Crypto.ecdhGenerateSecret(peerEcdhPublicKey, ecdh);
136
+ const sharedSecret = await Crypto.ecdhGenerateSecret(peerEcdhPublicKey, ecdh);
137
137
  const sigma2Salt = Bytes.concat(
138
138
  operationalIdentityProtectionKey,
139
139
  responderRandom,
140
140
  peerEcdhPublicKey,
141
- Crypto.hash(sigma1Bytes),
141
+ await Crypto.hash(sigma1Bytes),
142
142
  );
143
143
  const sigma2Key = await Crypto.hkdf(sharedSecret, sigma2Salt, KDFSR2_INFO);
144
144
  const peerEncryptedData = Crypto.decrypt(sigma2Key, peerEncrypted, TBE_DATA2_NONCE);
@@ -159,7 +159,7 @@ export class CaseClient {
159
159
  subject: { fabricId: peerFabricIdNOCert, nodeId: peerNodeIdNOCert },
160
160
  } = TlvOperationalCertificate.decode(peerNewOpCert);
161
161
 
162
- Crypto.verify(PublicKey(peerPublicKey), peerSignatureData, peerSignature);
162
+ await Crypto.verify(PublicKey(peerPublicKey), peerSignatureData, peerSignature);
163
163
 
164
164
  if (peerNodeIdNOCert !== peerNodeId) {
165
165
  throw new UnexpectedDataError(
@@ -182,10 +182,13 @@ export class CaseClient {
182
182
  );
183
183
  }
184
184
  }
185
- fabric.verifyCredentials(peerNewOpCert, peerIntermediateCACert);
185
+ await fabric.verifyCredentials(peerNewOpCert, peerIntermediateCACert);
186
186
 
187
187
  // Generate and send sigma3
188
- const sigma3Salt = Bytes.concat(operationalIdentityProtectionKey, Crypto.hash([sigma1Bytes, sigma2Bytes]));
188
+ const sigma3Salt = Bytes.concat(
189
+ operationalIdentityProtectionKey,
190
+ await Crypto.hash([sigma1Bytes, sigma2Bytes]),
191
+ );
189
192
  const sigma3Key = await Crypto.hkdf(sharedSecret, sigma3Salt, KDFSR3_INFO);
190
193
  const signatureData = TlvSignedData.encode({
191
194
  nodeOpCert,
@@ -193,7 +196,7 @@ export class CaseClient {
193
196
  ecdhPublicKey: initiatorEcdhPublicKey,
194
197
  peerEcdhPublicKey,
195
198
  });
196
- const signature = fabric.sign(signatureData);
199
+ const signature = await fabric.sign(signatureData);
197
200
  const encryptedData = TlvEncryptedDataSigma3.encode({ nodeOpCert, intermediateCACert, signature });
198
201
  const encrypted = Crypto.encrypt(sigma3Key, encryptedData, TBE_DATA3_NONCE);
199
202
  const sigma3Bytes = await messenger.sendSigma3({ encrypted });
@@ -203,7 +206,7 @@ export class CaseClient {
203
206
  const { caseAuthenticatedTags } = resumptionRecord ?? {}; // Even if resumption does not work try to reuse the caseAuthenticatedTags
204
207
  const secureSessionSalt = Bytes.concat(
205
208
  operationalIdentityProtectionKey,
206
- Crypto.hash([sigma1Bytes, sigma2Bytes, sigma3Bytes]),
209
+ await Crypto.hash([sigma1Bytes, sigma2Bytes, sigma3Bytes]),
207
210
  );
208
211
  secureSession = await this.#sessions.createSecureSession({
209
212
  sessionId: initiatorSessionId,
@@ -148,15 +148,15 @@ export class CaseServer implements ProtocolHandler {
148
148
  ) {
149
149
  // Generate sigma 2
150
150
  // TODO: Pass through a group id?
151
- const fabric = this.#fabrics.findFabricFromDestinationId(destinationId, peerRandom);
151
+ const fabric = await this.#fabrics.findFabricFromDestinationId(destinationId, peerRandom);
152
152
  const { operationalCert: nodeOpCert, intermediateCACert, operationalIdentityProtectionKey } = fabric;
153
153
  const { publicKey: responderEcdhPublicKey, sharedSecret } =
154
- Crypto.ecdhGeneratePublicKeyAndSecret(peerEcdhPublicKey);
154
+ await Crypto.ecdhGeneratePublicKeyAndSecret(peerEcdhPublicKey);
155
155
  const sigma2Salt = Bytes.concat(
156
156
  operationalIdentityProtectionKey,
157
157
  responderRandom,
158
158
  responderEcdhPublicKey,
159
- Crypto.hash(sigma1Bytes),
159
+ await Crypto.hash(sigma1Bytes),
160
160
  );
161
161
  const sigma2Key = await Crypto.hkdf(sharedSecret, sigma2Salt, KDFSR2_INFO);
162
162
  const signatureData = TlvSignedData.encode({
@@ -165,7 +165,7 @@ export class CaseServer implements ProtocolHandler {
165
165
  ecdhPublicKey: responderEcdhPublicKey,
166
166
  peerEcdhPublicKey,
167
167
  });
168
- const signature = fabric.sign(signatureData);
168
+ const signature = await fabric.sign(signatureData);
169
169
  const encryptedData = TlvEncryptedDataSigma2.encode({
170
170
  nodeOpCert,
171
171
  intermediateCACert,
@@ -187,7 +187,10 @@ export class CaseServer implements ProtocolHandler {
187
187
  sigma3Bytes,
188
188
  sigma3: { encrypted: peerEncrypted },
189
189
  } = await messenger.readSigma3();
190
- const sigma3Salt = Bytes.concat(operationalIdentityProtectionKey, Crypto.hash([sigma1Bytes, sigma2Bytes]));
190
+ const sigma3Salt = Bytes.concat(
191
+ operationalIdentityProtectionKey,
192
+ await Crypto.hash([sigma1Bytes, sigma2Bytes]),
193
+ );
191
194
  const sigma3Key = await Crypto.hkdf(sharedSecret, sigma3Salt, KDFSR3_INFO);
192
195
  const peerDecryptedData = Crypto.decrypt(sigma3Key, peerEncrypted, TBE_DATA3_NONCE);
193
196
  const {
@@ -196,7 +199,7 @@ export class CaseServer implements ProtocolHandler {
196
199
  signature: peerSignature,
197
200
  } = TlvEncryptedDataSigma3.decode(peerDecryptedData);
198
201
 
199
- fabric.verifyCredentials(peerNewOpCert, peerIntermediateCACert);
202
+ await fabric.verifyCredentials(peerNewOpCert, peerIntermediateCACert);
200
203
 
201
204
  const peerSignatureData = TlvSignedData.encode({
202
205
  nodeOpCert: peerNewOpCert,
@@ -213,12 +216,12 @@ export class CaseServer implements ProtocolHandler {
213
216
  throw new UnexpectedDataError(`Fabric ID mismatch: ${fabric.fabricId} !== ${peerFabricId}`);
214
217
  }
215
218
 
216
- Crypto.verify(PublicKey(peerPublicKey), peerSignatureData, peerSignature);
219
+ await Crypto.verify(PublicKey(peerPublicKey), peerSignatureData, peerSignature);
217
220
 
218
221
  // All good! Create secure session
219
222
  const secureSessionSalt = Bytes.concat(
220
223
  operationalIdentityProtectionKey,
221
- Crypto.hash([sigma1Bytes, sigma2Bytes, sigma3Bytes]),
224
+ await Crypto.hash([sigma1Bytes, sigma2Bytes, sigma3Bytes]),
222
225
  );
223
226
  const secureSession = await this.#sessions.createSecureSession({
224
227
  sessionId: responderSessionId,
@@ -82,7 +82,7 @@ export class PaseClient {
82
82
 
83
83
  // Compute pake1 and read pake2
84
84
  const { w0, w1 } = await Spake2p.computeW0W1(pbkdfParameters, setupPin);
85
- const spake2p = Spake2p.create(Crypto.hash([SPAKE_CONTEXT, requestPayload, responsePayload]), w0);
85
+ const spake2p = Spake2p.create(await Crypto.hash([SPAKE_CONTEXT, requestPayload, responsePayload]), w0);
86
86
  const X = spake2p.computeX();
87
87
  await messenger.sendPasePake1({ x: X });
88
88
 
@@ -144,7 +144,7 @@ export class PaseServer implements ProtocolHandler {
144
144
  });
145
145
 
146
146
  // Process pake1 and send pake2
147
- const spake2p = Spake2p.create(Crypto.hash([SPAKE_CONTEXT, requestPayload, responsePayload]), this.w0);
147
+ const spake2p = Spake2p.create(await Crypto.hash([SPAKE_CONTEXT, requestPayload, responsePayload]), this.w0);
148
148
  const { x: X } = await messenger.readPasePake1();
149
149
  const Y = spake2p.computeY();
150
150
  const { Ke, hAY, hBX } = await spake2p.computeSecretAndVerifiersFromX(this.L, X, Y);