gpg: Get the signature keyid from the issuer fpr.

* g10/parse-packet.c (parse_signature): Parse the ISSUER_FPR subpacket
and use that to get the keyid.
--

Because ADSKs are created w/o the issuer subpacket (despite that this
is still a v4 signature) we need to get the key id from the
issuer_fpr.  This does not harm and we still fallback to the the
issuer.  Note that for ease of future backporting we also take v5
fingerprints into account.
This commit is contained in:
Werner Koch 2023-03-03 10:09:32 +01:00
parent 202ed9e281
commit fde59f9ae6
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 15 additions and 2 deletions

View File

@ -2189,8 +2189,21 @@ parse_signature (IOBUF inp, int pkttype, unsigned long pktlen,
&& opt.verbose && !glo_ctrl.silence_parse_warnings)
log_info ("signature packet without timestamp\n");
p = parse_sig_subpkt2 (sig, SIGSUBPKT_ISSUER);
if (p)
/* Set the key id. We first try the issuer fingerprint and if
* this is not found fallback to the issuer. Note that
* only the issuer packet is also searched in the unhashed area. */
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_ISSUER_FPR, &len);
if (p && len == 21 && p[0] == 4)
{
sig->keyid[0] = buf32_to_u32 (p + 1 + 12);
sig->keyid[1] = buf32_to_u32 (p + 1 + 16);
}
else if (p && len == 33 && p[0] == 5)
{
sig->keyid[0] = buf32_to_u32 (p + 1 );
sig->keyid[1] = buf32_to_u32 (p + 1 + 4);
}
else if ((p = parse_sig_subpkt2 (sig, SIGSUBPKT_ISSUER)))
{
sig->keyid[0] = buf32_to_u32 (p);
sig->keyid[1] = buf32_to_u32 (p + 4);