From 1b94b3c4def3e06e9ad260e6d0fad2f6261971f0 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 9 Apr 2020 16:00:08 +0200 Subject: throw something more informative when we cant find a key to decrypt with --- src/crypto/SecretStorage.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crypto/SecretStorage.js b/src/crypto/SecretStorage.js index 123fecf4..fc4420d3 100644 --- a/src/crypto/SecretStorage.js +++ b/src/crypto/SecretStorage.js @@ -363,6 +363,11 @@ export class SecretStorage extends EventEmitter { } } + if (Object.keys(keys) === 0) { + throw new Error(`Could not decrypt ${name} because none of ` + + `the keys it is encrypted with are for a supported algorithm`); + } + let keyId; let decryption; try { -- cgit v1.2.1 From cc8e8434ecc2ab8be7fae9f641d8716b03eb5a67 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 9 Apr 2020 15:58:43 +0000 Subject: Update src/crypto/SecretStorage.js Co-Authored-By: J. Ryan Stinnett --- src/crypto/SecretStorage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/SecretStorage.js b/src/crypto/SecretStorage.js index fc4420d3..fba19f47 100644 --- a/src/crypto/SecretStorage.js +++ b/src/crypto/SecretStorage.js @@ -363,7 +363,7 @@ export class SecretStorage extends EventEmitter { } } - if (Object.keys(keys) === 0) { + if (Object.keys(keys).length === 0) { throw new Error(`Could not decrypt ${name} because none of ` + `the keys it is encrypted with are for a supported algorithm`); } -- cgit v1.2.1