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:
larabr
2024-11-20 16:57:38 +01:00
parent bbdaad0cba
commit 4d2d8740dc
2 changed files with 34 additions and 2 deletions

View File

@@ -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');
}
}
/**