From 20bc8071fc75929f7d62614183db75d0927603ac Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 3 Jan 2020 13:52:36 +0000 Subject: [PATCH 1/3] Fix creating a key backup with cross signing diabled It broke if no scret key callback was supplied but a cross-signing identity did exist (as hopefully explained in comment). Fixes https://github.com/vector-im/riot-web/issues/11763 --- src/client.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 3503530b7..00cf2824d 100644 --- a/src/client.js +++ b/src/client.js @@ -1505,8 +1505,11 @@ MatrixClient.prototype.createKeyBackupVersion = async function(info) { // favour of just signing with the cross-singing master key. await this._crypto._signObject(data.auth_data); - if (this._crypto._crossSigningInfo.getId()) { + if (this._cryptoCallbacks.getSecretStorageKey && this._crypto._crossSigningInfo.getId()) { // now also sign the auth data with the cross-signing master key + // we check for the callback explicitly here because we still want to be able + // to create an un-cross-signed key backup if there is a cross-signing key but + // no callback supplied. await this._crypto._crossSigningInfo.signObject(data.auth_data, "master"); } From fbb355c5c9d93cad932a6da7564a0c744746038b Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 3 Jan 2020 14:02:38 +0000 Subject: [PATCH 2/3] Thank you once again, o great linter, for saving our lines from being too long --- src/client.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 00cf2824d..e89ea5035 100644 --- a/src/client.js +++ b/src/client.js @@ -1505,7 +1505,10 @@ MatrixClient.prototype.createKeyBackupVersion = async function(info) { // favour of just signing with the cross-singing master key. await this._crypto._signObject(data.auth_data); - if (this._cryptoCallbacks.getSecretStorageKey && this._crypto._crossSigningInfo.getId()) { + if ( + this._cryptoCallbacks.getSecretStorageKey && + this._crypto._crossSigningInfo.getId() + ) { // now also sign the auth data with the cross-signing master key // we check for the callback explicitly here because we still want to be able // to create an un-cross-signed key backup if there is a cross-signing key but From 5487cf20707cd51e94e53de8b01eb70ab22993bc Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 3 Jan 2020 14:36:04 +0000 Subject: [PATCH 3/3] Fix callback check We need to check for getCrossSisgningKey but that was added unconditionally elsewhere - only add it if we actually have a getSecretStorageKey callback to use. --- src/client.js | 2 +- src/crypto/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.js b/src/client.js index e89ea5035..1ba3c4604 100644 --- a/src/client.js +++ b/src/client.js @@ -1506,7 +1506,7 @@ MatrixClient.prototype.createKeyBackupVersion = async function(info) { await this._crypto._signObject(data.auth_data); if ( - this._cryptoCallbacks.getSecretStorageKey && + this._cryptoCallbacks.getCrossSigningKey && this._crypto._crossSigningInfo.getId() ) { // now also sign the auth data with the cross-signing master key diff --git a/src/crypto/index.js b/src/crypto/index.js index fa547c395..b2c4001c0 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -218,7 +218,7 @@ export default function Crypto(baseApis, sessionStore, userId, deviceId, ); // Assuming no app-supplied callback, default to getting from SSSS. - if (!cryptoCallbacks.getCrossSigningKey) { + if (!cryptoCallbacks.getCrossSigningKey && cryptoCallbacks.getSecretStorageKey) { cryptoCallbacks.getCrossSigningKey = async (type) => { return CrossSigningInfo.getFromSecretStorage(type, this._secretStorage); };