From: Jonathan McDowell Date: Sat, 2 Jan 2021 11:31:27 +0000 (+0000) Subject: Don't take creation time from unhashed subpackets X-Git-Tag: onak-0.6.2~8 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=b817e792ee453485b117eefad128971c59ea576f;p=onak.git Don't take creation time from unhashed subpackets When looking at the subpackets for a signature don't use the unhashed set to obtain the creation time, and only use them for the keyid if it wasn't present in the hashed section. Fixes #3 --- diff --git a/decodekey.c b/decodekey.c index 481b8aa..f8cc407 100644 --- a/decodekey.c +++ b/decodekey.c @@ -230,17 +230,27 @@ onak_status_t sig_info(struct openpgp_packet *packet, uint64_t *keyid, break; case 4: case 5: + if (keyid != NULL) { + *keyid = 0; + } res = parse_subpackets(&packet->data[4], packet->length - 4, &length, keyid, creation); if (res != ONAK_E_OK) { return res; } - res = parse_subpackets(&packet->data[length + 4], - packet->length - (4 + length), - &length, keyid, creation); - if (res != ONAK_E_OK) { - return res; + /* + * Only look at the unhashed subpackets if we want the + * keyid and it wasn't in the signed subpacket + * section. + */ + if (keyid != NULL && *keyid == 0) { + res = parse_subpackets(&packet->data[length + 4], + packet->length - (4 + length), + &length, keyid, NULL); + if (res != ONAK_E_OK) { + return res; + } } break; default: