From c116f2b1bc0e9a340bffdcc64288b1987e38f03b Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 28 Apr 2020 16:56:37 +0100 Subject: [PATCH 1/2] Remove redundant key backup setup path Bootstrap was create key backup twice due to some code duplication we missed in previous refactorings. Fixes https://github.com/vector-im/riot-web/issues/13423 --- src/crypto/index.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/crypto/index.js b/src/crypto/index.js index 5b6010040..ff27e6f3a 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -755,14 +755,6 @@ Crypto.prototype.bootstrapSecretStorage = async function({ } } - if (setupNewKeyBackup && !keyBackupInfo) { - const info = await this._baseApis.prepareKeyBackupVersion( - null /* random key */, - { secureSecretStorage: true }, - ); - await this._baseApis.createKeyBackupVersion(info); - } - // Call `getCrossSigningKey` for side effect of caching private keys for // future gossiping to other devices if enabled via app level callbacks. if (this._crossSigningInfo._cacheCallbacks) { From e775515c382ba1e1df11eb642f78391844df3240 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 28 Apr 2020 17:20:49 +0100 Subject: [PATCH 2/2] Remove the other copy instead --- src/crypto/index.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/crypto/index.js b/src/crypto/index.js index ff27e6f3a..daf6b78ca 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -596,14 +596,6 @@ Crypto.prototype.bootstrapSecretStorage = async function({ if (oldKeyInfo && oldKeyInfo.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) { await ensureCanCheckPassphrase(oldKeyId, oldKeyInfo); } - - if (setupNewKeyBackup) { - const info = await this._baseApis.prepareKeyBackupVersion( - null /* random key */, - { secureSecretStorage: true }, - ); - await this._baseApis.createKeyBackupVersion(info); - } } else if (!inStorage && keyBackupInfo) { // we have an existing backup, but no SSSS @@ -755,6 +747,14 @@ Crypto.prototype.bootstrapSecretStorage = async function({ } } + if (setupNewKeyBackup && !keyBackupInfo) { + const info = await this._baseApis.prepareKeyBackupVersion( + null /* random key */, + { secureSecretStorage: true }, + ); + await this._baseApis.createKeyBackupVersion(info); + } + // Call `getCrossSigningKey` for side effect of caching private keys for // future gossiping to other devices if enabled via app level callbacks. if (this._crossSigningInfo._cacheCallbacks) {