-/*
- * parse_subpackets - Parse the subpackets of a Type 4 signature.
- * @data: The subpacket data.
- * @keyid: A pointer to where we should return the keyid.
- *
- * This function parses the subkey data of a Type 4 signature and fills
- * in the supplied variables. It also returns the length of the data
- * processed.
- */
-int parse_subpackets(unsigned char *data, uint64_t *keyid)
-{
- int offset = 0;
- int length = 0;
- int packetlen = 0;
-
- assert(data != NULL);
-
- length = (data[0] << 8) + data[1] + 2;
-
- offset = 2;
- while (offset < length) {
- packetlen = data[offset++];
- if (packetlen > 191 && packetlen < 255) {
- packetlen = ((packetlen - 192) << 8) +
- data[offset++] + 192;
- } else if (packetlen == 255) {
- packetlen = data[offset++];
- packetlen <<= 8;
- packetlen = data[offset++];
- packetlen <<= 8;
- packetlen = data[offset++];
- packetlen <<= 8;
- packetlen = data[offset++];
- }
- switch (data[offset]) {
- case 2:
- /*
- * Signature creation time. Might want to output this?
- */
- break;
- case 0x83:
- /*
- * Signature expiration time. Might want to output this?
- */
- break;
- case 16:
- *keyid = data[offset+packetlen - 8];
- *keyid <<= 8;
- *keyid += data[offset+packetlen - 7];
- *keyid <<= 8;
- *keyid += data[offset+packetlen - 6];
- *keyid <<= 8;
- *keyid += data[offset+packetlen - 5];
- *keyid <<= 8;
- *keyid += data[offset+packetlen - 4];
- *keyid <<= 8;
- *keyid += data[offset+packetlen - 3];
- *keyid <<= 8;
- *keyid += data[offset+packetlen - 2];
- *keyid <<= 8;
- *keyid += data[offset+packetlen - 1];
- break;
- case 23:
- /*
- * Key server preferences. Including no-modify.
- */
- break;
- case 25:
- /*
- * Primary UID.
- */
- break;
- default:
- /*
- * We don't care about unrecognized packets unless bit
- * 7 is set in which case we prefer an error than
- * ignoring it.
- */
- assert(!(data[offset] & 0x80));
- }
- offset += packetlen;
- }
-
- return length;
-}
-