Add config option to allow insecure decryption with RSA signing keys (#1148)

This commit is contained in:
larabr
2020-08-28 16:09:56 +02:00
committed by GitHub
parent cc1bdcbae8
commit 2eab8a1ebc
3 changed files with 83 additions and 0 deletions

View File

@@ -120,6 +120,14 @@ export default {
* @property {Boolean} revocations_expire If true, expired revocation signatures are ignored
*/
revocations_expire: false,
/**
* Allow decryption using RSA keys without `encrypt` flag.
* This setting is potentially insecure, but it is needed to get around an old openpgpjs bug
* where key flags were ignored when selecting a key for encryption.
* @memberof module:config
* @property {Boolean} allow_insecure_decryption_with_signing_keys
*/
allow_insecure_decryption_with_signing_keys: false,
/**
* @memberof module:config

View File

@@ -366,6 +366,12 @@ export function isValidDecryptionKeyPacket(signature) {
if (!signature.verified) { // Sanity check
throw new Error('Signature not verified');
}
if (config.allow_insecure_decryption_with_signing_keys) {
// This is only relevant for RSA keys, all other signing ciphers cannot decrypt
return true;
}
return !signature.keyFlags ||
(signature.keyFlags[0] & enums.keyFlags.encrypt_communication) !== 0 ||
(signature.keyFlags[0] & enums.keyFlags.encrypt_storage) !== 0;