mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-24 06:25:50 +00:00
Fix signing using keys without preferred hash algorithms
This commit is contained in:
parent
b2bd8a0fdd
commit
f20e84f2bc
@ -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;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user