mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-06-24 15:12:31 +00:00
Fix signing using keys without preferred hash algorithms (#1820)
This commit is contained in:
parent
b2bd8a0fdd
commit
432856ff0e
@ -127,7 +127,7 @@ export async function getPreferredHashAlgo(targetKeys, signingKeyPacket, date =
|
|||||||
const supportedAlgosPerTarget = await Promise.all(targetKeys.map(async (key, i) => {
|
const supportedAlgosPerTarget = await Promise.all(targetKeys.map(async (key, i) => {
|
||||||
const selfCertification = await key.getPrimarySelfSignature(date, targetUserIDs[i], config);
|
const selfCertification = await key.getPrimarySelfSignature(date, targetUserIDs[i], config);
|
||||||
const targetPrefs = selfCertification.preferredHashAlgorithms;
|
const targetPrefs = selfCertification.preferredHashAlgorithms;
|
||||||
return targetPrefs;
|
return targetPrefs || [];
|
||||||
}));
|
}));
|
||||||
const supportedAlgosMap = new Map(); // use Map over object to preserve numeric keys
|
const supportedAlgosMap = new Map(); // use Map over object to preserve numeric keys
|
||||||
for (const supportedAlgos of supportedAlgosPerTarget) {
|
for (const supportedAlgos of supportedAlgosPerTarget) {
|
||||||
@ -151,7 +151,7 @@ export async function getPreferredHashAlgo(targetKeys, signingKeyPacket, date =
|
|||||||
.filter(hashAlgo => isSupportedHashAlgo(hashAlgo))
|
.filter(hashAlgo => isSupportedHashAlgo(hashAlgo))
|
||||||
.sort((algoA, algoB) => getHashByteLength(algoA) - getHashByteLength(algoB));
|
.sort((algoA, algoB) => getHashByteLength(algoA) - getHashByteLength(algoB));
|
||||||
const strongestHashAlgo = sortedHashAlgos[0];
|
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;
|
return getHashByteLength(strongestHashAlgo) >= getHashByteLength(defaultAlgo) ? strongestHashAlgo : defaultAlgo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user