mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-13 11:55:01 +00:00
Fix decryption support for non-standard, legacy AEAD messages and keys that used experimentalGCM
This adds back support for decrypting password-protected messages which were encrypted in OpenPGP.js v5 with custom config settings `config.aeadProtect = true` together with `config.preferredAEADAlgorithm = openpgp.enums.aead.experimentalGCM`. Public-key-encrypted messages are affected if they were encrypted using the same config, while also providing `encryptionKeys` that declared `experimentalGCM` in their AEAD prefs. Such keys could be generated in OpenPGP.js v5 by setting the aforementioned config values.
This commit is contained in:
@@ -472,8 +472,17 @@ export function generateSessionKey(algo) {
|
||||
* @throws {Error} on invalid algo
|
||||
*/
|
||||
export function getAEADMode(algo) {
|
||||
const algoName = enums.read(enums.aead, algo);
|
||||
return mode[algoName];
|
||||
switch (algo) {
|
||||
case enums.aead.eax:
|
||||
return mode.eax;
|
||||
case enums.aead.ocb:
|
||||
return mode.ocb;
|
||||
case enums.aead.gcm:
|
||||
case enums.aead.experimentalGCM:
|
||||
return mode.gcm;
|
||||
default:
|
||||
throw new Error('Unsupported AEAD mode');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user