When decrypting a v6 PKESK in constant-time, use the v2 SEIPD algorithm

Rather than using the config to determine which algorithms to try
to decrypt session keys for, try the algorithm we know the message
was encrypted with.
This commit is contained in:
Daniel Huigens 2023-03-18 00:30:30 +01:00 committed by larabr
parent 7e382e6e43
commit 0e08abb3e2

View File

@ -243,7 +243,11 @@ export class Message {
// NB: as a result, if the data is encrypted with a non-suported cipher, decryption will always fail.
const serialisedPKESK = pkeskPacket.write(); // make copies to be able to decrypt the PKESK packet multiple times
await Promise.all(Array.from(config.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms).map(async sessionKeyAlgorithm => {
await Promise.all((
expectedSymmetricAlgorithm ?
[expectedSymmetricAlgorithm] :
Array.from(config.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms)
).map(async sessionKeyAlgorithm => {
const pkeskPacketCopy = new PublicKeyEncryptedSessionKeyPacket();
pkeskPacketCopy.read(serialisedPKESK);
const randomSessionKey = {