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-06-03 18:52:06 -04:00
parent e22ecc6b6d
commit ca85dfc6ff
2 changed files with 15 additions and 17 deletions

View File

@@ -1865,7 +1865,7 @@ MatrixClient.prototype.prepareKeyBackupVersion = async function(
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
const {algorithm, auth_data, recovery_key, privateKey} = const { algorithm, auth_data, recovery_key, privateKey } =
await this._crypto._backupManager.prepareKeyBackupVersion(password); await this._crypto._backupManager.prepareKeyBackupVersion(password);
if (secureSecretStorage) { if (secureSecretStorage) {
@@ -2260,10 +2260,9 @@ MatrixClient.prototype._restoreKeyBackup = async function(
source: "backup", source: "backup",
}); });
// await this._crypto.setTrustedBackupPubKey(backupPubKey);
await this.checkKeyBackup(); await this.checkKeyBackup();
return {total: totalKeyCount, imported: keys.length}; return { total: totalKeyCount, imported: keys.length };
}; };
MatrixClient.prototype.deleteKeysFromBackup = function(roomId, sessionId, version) { MatrixClient.prototype.deleteKeysFromBackup = function(roomId, sessionId, version) {

View File

@@ -20,15 +20,15 @@ limitations under the License.
* Classes for dealing with key backup. * Classes for dealing with key backup.
*/ */
import {MatrixClient} from "../client"; import { MatrixClient } from "../client";
import {logger} from "../logger"; import { logger } from "../logger";
import {MEGOLM_ALGORITHM, verifySignature} from "./olmlib"; import { MEGOLM_ALGORITHM, verifySignature } from "./olmlib";
import {DeviceInfo} from "./deviceinfo" import { DeviceInfo } from "./deviceinfo"
import {DeviceTrustLevel} from './CrossSigning'; import { DeviceTrustLevel } from './CrossSigning';
import {keyFromPassphrase} from './key_passphrase'; import { keyFromPassphrase } from './key_passphrase';
import {sleep} from "../utils"; import { sleep } from "../utils";
import {IndexedDBCryptoStore} from './store/indexeddb-crypto-store'; import { IndexedDBCryptoStore } from './store/indexeddb-crypto-store';
import {encodeRecoveryKey} from './recoverykey'; import { encodeRecoveryKey } from './recoverykey';
const KEY_BACKUP_KEYS_PER_REQUEST = 200; const KEY_BACKUP_KEYS_PER_REQUEST = 200;
@@ -220,7 +220,7 @@ export class BackupManager {
} }
} }
return {backupInfo, trustInfo}; return { backupInfo, trustInfo };
} }
/** /**
@@ -435,7 +435,7 @@ export class BackupManager {
for (const session of sessions) { for (const session of sessions) {
const roomId = session.sessionData.room_id; const roomId = session.sessionData.room_id;
if (data[roomId] === undefined) { if (data[roomId] === undefined) {
data[roomId] = {sessions: {}}; data[roomId] = { sessions: {} };
} }
const sessionData = await this.baseApis._crypto._olmDevice.exportInboundGroupSession( const sessionData = await this.baseApis._crypto._olmDevice.exportInboundGroupSession(
@@ -464,7 +464,7 @@ export class BackupManager {
await this.baseApis.sendKeyBackup( await this.baseApis.sendKeyBackup(
undefined, undefined, this.backupInfo.version, undefined, undefined, this.backupInfo.version,
{rooms: data}, { rooms: data },
); );
await this.baseApis._crypto._cryptoStore.unmarkSessionsNeedingBackup(sessions); await this.baseApis._crypto._cryptoStore.unmarkSessionsNeedingBackup(sessions);
@@ -573,7 +573,6 @@ export class Curve25519 implements BackupAlgorithm {
const derivation = await keyFromPassphrase(key); const derivation = await keyFromPassphrase(key);
authData.private_key_salt = derivation.salt; authData.private_key_salt = derivation.salt;
authData.private_key_iterations = derivation.iterations; authData.private_key_iterations = derivation.iterations;
// FIXME: algorithm?
authData.public_key = decryption.init_with_private_key(derivation.key); authData.public_key = decryption.init_with_private_key(derivation.key);
} }
const publicKey = new global.Olm.PkEncryption(); const publicKey = new global.Olm.PkEncryption();
@@ -604,7 +603,7 @@ export class Curve25519 implements BackupAlgorithm {
if (backupPubKey !== this.authData.public_key) { if (backupPubKey !== this.authData.public_key) {
// eslint-disable-next-line no-throw-literal // eslint-disable-next-line no-throw-literal
throw {errcode: MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY}; throw { errcode: MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY };
} }
const keys = []; const keys = [];