From 7c1943ef4ef216887049ae2d490b769655c6790f Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 9 Apr 2019 13:22:35 +0100 Subject: [PATCH 1/2] Key backup: Handle case where your onw sig is invalid Sometimes life is just like that --- src/components/views/settings/KeyBackupPanel.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/views/settings/KeyBackupPanel.js b/src/components/views/settings/KeyBackupPanel.js index cc1b3fd017..82d464c05e 100644 --- a/src/components/views/settings/KeyBackupPanel.js +++ b/src/components/views/settings/KeyBackupPanel.js @@ -227,11 +227,17 @@ export default class KeyBackupPanel extends React.PureComponent { "Backup has a signature from unknown device with ID %(deviceId)s.", { deviceId: sig.deviceId }, { verify }, ); - } else if (sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key()) { + } else if (sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key() && sig.valid) { sigStatus = _t( "Backup has a valid signature from this device", {}, { validity }, ); + } else if (sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key() && !sig.valid) { + // it can happen... + sigStatus = _t( + "Backup has an invalid signature from this device", + {}, { validity }, + ); } else if (sig.valid && sig.device.isVerified()) { sigStatus = _t( "Backup has a valid signature from " + From 0f1ebf8095b52b23f694c43721159c65592ad15f Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 9 Apr 2019 13:47:25 +0100 Subject: [PATCH 2/2] Factor out this device check & reorder conditionals --- src/components/views/settings/KeyBackupPanel.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/views/settings/KeyBackupPanel.js b/src/components/views/settings/KeyBackupPanel.js index 82d464c05e..7667e11d46 100644 --- a/src/components/views/settings/KeyBackupPanel.js +++ b/src/components/views/settings/KeyBackupPanel.js @@ -221,18 +221,19 @@ export default class KeyBackupPanel extends React.PureComponent { {sub} ; const device = sub => {deviceName}; + const fromThisDevice = sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key(); let sigStatus; if (!sig.device) { sigStatus = _t( "Backup has a signature from unknown device with ID %(deviceId)s.", { deviceId: sig.deviceId }, { verify }, ); - } else if (sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key() && sig.valid) { + } else if (sig.valid && fromThisDevice) { sigStatus = _t( "Backup has a valid signature from this device", {}, { validity }, ); - } else if (sig.device.getFingerprint() === MatrixClientPeg.get().getDeviceEd25519Key() && !sig.valid) { + } else if (!sig.valid && fromThisDevice) { // it can happen... sigStatus = _t( "Backup has an invalid signature from this device",