1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Fix MatrixRTC sender key wrapping (#4441)

This commit is contained in:
Hugh Nimmo-Smith
2024-10-07 11:34:23 +01:00
committed by GitHub
parent da044820d7
commit 3386c66b98
2 changed files with 47 additions and 6 deletions

View File

@@ -448,13 +448,12 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
}
private getNewEncryptionKeyIndex(): number {
const userId = this.client.getUserId();
const deviceId = this.client.getDeviceId();
if (this.currentEncryptionKeyIndex === -1) {
return 0;
}
if (!userId) throw new Error("No userId!");
if (!deviceId) throw new Error("No deviceId!");
return (this.getKeysForParticipantInternal(userId, deviceId)?.length ?? 0) % 16;
// maximum key index is 255
return (this.currentEncryptionKeyIndex + 1) % 256;
}
/**