1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00
This commit is contained in:
Hubert Chathi
2021-07-07 19:50:16 -04:00
parent c8a7820cb3
commit e275301e8b

View File

@@ -684,13 +684,6 @@ export class Curve25519 implements BackupAlgorithm {
} }
} }
// FIXME: this should go into ./aes
interface AesData {
iv: string,
ciphertext: string,
mac: string,
}
function randomBytes(size: number): Uint8Array { function randomBytes(size: number): Uint8Array {
const crypto: {randomBytes: (number) => Uint8Array} | undefined = getCrypto() as any; const crypto: {randomBytes: (number) => Uint8Array} | undefined = getCrypto() as any;
if (crypto) { if (crypto) {
@@ -721,7 +714,7 @@ export class Aes256 implements BackupAlgorithm {
if (!authData) { if (!authData) {
throw new Error("auth_data missing"); throw new Error("auth_data missing");
} }
const key = await getKey() const key = await getKey();
if (authData.mac) { if (authData.mac) {
const { mac } = await calculateKeyCheck(key, authData.iv); const { mac } = await calculateKeyCheck(key, authData.iv);
if (authData.mac.replace(/=+$/g, '') !== mac.replace(/=+/g, '')) { if (authData.mac.replace(/=+$/g, '') !== mac.replace(/=+/g, '')) {