]> the.earth.li Git - onak.git/commitdiff
Don't take creation time from unhashed subpackets
authorJonathan McDowell <noodles@earth.li>
Sat, 2 Jan 2021 11:31:27 +0000 (11:31 +0000)
committerJonathan McDowell <noodles@earth.li>
Sat, 2 Jan 2021 11:31:27 +0000 (11:31 +0000)
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

decodekey.c

index 481b8aaa94e68cae12de3c5f1df987300a349465..f8cc40771c63f85e845216b7b0c0a128e5e8fbda 100644 (file)
@@ -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: