Minor: fix packet validity check for new curve25519 keys without key flags

The code used to wrongly consider e.g. x25519 keys without key flags as valid signing keys.
Keys without key flags are very rare nowadays, so this fix has low impact.
This commit is contained in:
larabr 2023-09-18 14:25:45 +02:00
parent 2ba8229d23
commit f90c53ae65

View File

@ -367,6 +367,7 @@ export function isValidSigningKeyPacket(keyPacket, signature) {
return keyAlgo !== enums.publicKey.rsaEncrypt && return keyAlgo !== enums.publicKey.rsaEncrypt &&
keyAlgo !== enums.publicKey.elgamal && keyAlgo !== enums.publicKey.elgamal &&
keyAlgo !== enums.publicKey.ecdh && keyAlgo !== enums.publicKey.ecdh &&
keyAlgo !== enums.publicKey.x25519 &&
(!signature.keyFlags || (!signature.keyFlags ||
(signature.keyFlags[0] & enums.keyFlags.signData) !== 0); (signature.keyFlags[0] & enums.keyFlags.signData) !== 0);
} }
@ -377,6 +378,7 @@ export function isValidEncryptionKeyPacket(keyPacket, signature) {
keyAlgo !== enums.publicKey.rsaSign && keyAlgo !== enums.publicKey.rsaSign &&
keyAlgo !== enums.publicKey.ecdsa && keyAlgo !== enums.publicKey.ecdsa &&
keyAlgo !== enums.publicKey.eddsa && keyAlgo !== enums.publicKey.eddsa &&
keyAlgo !== enums.publicKey.ed25519 &&
(!signature.keyFlags || (!signature.keyFlags ||
(signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 || (signature.keyFlags[0] & enums.keyFlags.encryptCommunication) !== 0 ||
(signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0); (signature.keyFlags[0] & enums.keyFlags.encryptStorage) !== 0);