From 432856ff0ed1cdac79194574ef53a2fc805a1c01 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Wed, 29 Jan 2025 16:45:32 +0100 Subject: [PATCH] Fix signing using keys without preferred hash algorithms (#1820) --- src/key/helper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/key/helper.js b/src/key/helper.js index 89338510..50c151b0 100644 --- a/src/key/helper.js +++ b/src/key/helper.js @@ -127,7 +127,7 @@ export async function getPreferredHashAlgo(targetKeys, signingKeyPacket, date = const supportedAlgosPerTarget = await Promise.all(targetKeys.map(async (key, i) => { const selfCertification = await key.getPrimarySelfSignature(date, targetUserIDs[i], config); const targetPrefs = selfCertification.preferredHashAlgorithms; - return targetPrefs; + return targetPrefs || []; })); const supportedAlgosMap = new Map(); // use Map over object to preserve numeric keys for (const supportedAlgos of supportedAlgosPerTarget) { @@ -151,7 +151,7 @@ export async function getPreferredHashAlgo(targetKeys, signingKeyPacket, date = .filter(hashAlgo => isSupportedHashAlgo(hashAlgo)) .sort((algoA, algoB) => getHashByteLength(algoA) - getHashByteLength(algoB)); const strongestHashAlgo = sortedHashAlgos[0]; - // defaultAlgo is always implicilty supported, and might be stronger than the rest + // defaultAlgo is always implicitly supported, and might be stronger than the rest return getHashByteLength(strongestHashAlgo) >= getHashByteLength(defaultAlgo) ? strongestHashAlgo : defaultAlgo; };