Check whether signing key was non-expired at signature creation time
This commit is contained in:
parent
787965981a
commit
c7339f6f78
|
@ -614,12 +614,14 @@ Message.prototype.verifyDetached = function(signature, keys, date=new Date()) {
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
async function createVerificationObject(signature, literalDataList, keys, date=new Date()) {
|
async function createVerificationObject(signature, literalDataList, keys, date=new Date()) {
|
||||||
let keyPacket = null;
|
let primaryKey = null;
|
||||||
|
let signingKey = null;
|
||||||
await Promise.all(keys.map(async function(key) {
|
await Promise.all(keys.map(async function(key) {
|
||||||
// Look for the unique key that matches issuerKeyId of signature
|
// Look for the unique key that matches issuerKeyId of signature
|
||||||
const result = await key.getSigningKey(signature.issuerKeyId, null);
|
const result = await key.getSigningKey(signature.issuerKeyId, null);
|
||||||
if (result) {
|
if (result) {
|
||||||
keyPacket = result.keyPacket;
|
primaryKey = key;
|
||||||
|
signingKey = result;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -627,13 +629,19 @@ async function createVerificationObject(signature, literalDataList, keys, date=n
|
||||||
const verifiedSig = {
|
const verifiedSig = {
|
||||||
keyid: signature.issuerKeyId,
|
keyid: signature.issuerKeyId,
|
||||||
verified: (async () => {
|
verified: (async () => {
|
||||||
if (!keyPacket) {
|
if (!signingKey) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const verified = await signature.verify(keyPacket, signature.signatureType, literalDataList[0]);
|
const verified = await signature.verify(signingKey.keyPacket, signature.signatureType, literalDataList[0]);
|
||||||
const sig = await signaturePacket;
|
const sig = await signaturePacket;
|
||||||
if (sig.isExpired(date)) {
|
if (sig.isExpired(date) || !(
|
||||||
return false;
|
sig.created >= signingKey.getCreationTime() &&
|
||||||
|
sig.created < await (signingKey === primaryKey ?
|
||||||
|
signingKey.getExpirationTime() :
|
||||||
|
signingKey.getExpirationTime(primaryKey, date)
|
||||||
|
)
|
||||||
|
)) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return verified;
|
return verified;
|
||||||
})(),
|
})(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user