From 060f2cf54f19beba7160fcf69b133c09c0e9078b Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 6 Aug 2020 15:10:47 +0100 Subject: [PATCH] Enable sharing of master cross-signing key We've realised it's beneficial to support sharing the master cross-singing key so that new devices can fully manage cross-signing on your account. Part of https://github.com/vector-im/element-web/issues/13896 --- src/CrossSigningManager.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/CrossSigningManager.js b/src/CrossSigningManager.js index a584a69d35..fe07a821c6 100644 --- a/src/CrossSigningManager.js +++ b/src/CrossSigningManager.js @@ -132,24 +132,14 @@ const onSecretRequested = async function({ if (name.startsWith("m.cross_signing")) { const callbacks = client.getCrossSigningCacheCallbacks(); if (!callbacks.getCrossSigningKeyCache) return; - /* Explicit enumeration here is deliberate – never share the master key! */ - if (name === "m.cross_signing.self_signing") { - const key = await callbacks.getCrossSigningKeyCache("self_signing"); - if (!key) { - console.log( - `self_signing requested by ${deviceId}, but not found in cache`, - ); - } - return key && encodeBase64(key); - } else if (name === "m.cross_signing.user_signing") { - const key = await callbacks.getCrossSigningKeyCache("user_signing"); - if (!key) { - console.log( - `user_signing requested by ${deviceId}, but not found in cache`, - ); - } - return key && encodeBase64(key); + const keyId = name.replace("m.cross_signing.", ""); + const key = await callbacks.getCrossSigningKeyCache(keyId); + if (!key) { + console.log( + `${keyId} requested by ${deviceId}, but not found in cache`, + ); } + return key && encodeBase64(key); } else if (name === "m.megolm_backup.v1") { const key = await client._crypto.getSessionBackupPrivateKey(); if (!key) {