Use preferred AEAD mode for secret key encryption (#1776)

When config.aeadProtect is enabled, use config.preferredAEADAlgorithm
to decide the AEAD mode when encrypting secret keys.
This commit is contained in:
Daniel Huigens 2024-07-05 13:50:11 +02:00 committed by GitHub
parent 42938c871a
commit 00e147f5c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -392,7 +392,7 @@ class SecretKeyPacket extends PublicKeyPacket {
if (config.aeadProtect) {
this.s2kUsage = 253;
this.aead = enums.aead.eax;
this.aead = config.preferredAEADAlgorithm;
const mode = crypto.getAEADMode(this.aead);
this.isLegacyAEAD = this.version === 5; // v4 is always re-encrypted with standard format instead.
this.usedModernAEAD = !this.isLegacyAEAD; // legacy AEAD does not guarantee integrity of public key material