From f8407f2ed06cdc0cca8c2421023255886c12ea6d Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Mon, 15 Apr 2019 10:22:12 +0100 Subject: [PATCH] Add support for issuer fingerprint subpackets A new subpacket containing the entire fingerprint of the signature issuer has been added in RFC4880bis. This improves the old issuer keyid subpacket type. --- decodekey.c | 14 +++++++++++++- openpgp.h | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/decodekey.c b/decodekey.c index 0ff0625..8e7d544 100644 --- a/decodekey.c +++ b/decodekey.c @@ -48,6 +48,8 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, int offset = 0; int length = 0; int packetlen = 0; + struct openpgp_fingerprint fp; + int i; assert(data != NULL); @@ -122,6 +124,16 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, *keyid += data[offset+packetlen - 1]; } break; + case OPENPGP_SIGSUB_ISSUER_FINGER: + if ((packetlen - 2) <= MAX_FINGERPRINT_LEN && + keyid != NULL) { + fp.length = packetlen - 2; + for (i = 0; i < fp.length; i++) { + fp.fp[i] = data[offset + i + 2]; + } + *keyid = fingerprint2keyid(&fp); + } + break; case OPENPGP_SIGSUB_EXPIRY: case OPENPGP_SIGSUB_EXPORTABLE: case OPENPGP_SIGSUB_TRUSTSIG: @@ -134,7 +146,7 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, case OPENPGP_SIGSUB_REVOCATION_KEY: case OPENPGP_SIGSUB_ISSUER_UID: case OPENPGP_SIGSUB_URL: - case OPENPGP_SIGSUB_ISSUER_FINGER: + case OPENPGP_SIGSUB_X_ISSUER_FINGER: case OPENPGP_SIGSUB_NOTATION: case OPENPGP_SIGSUB_PREFHASH: case OPENPGP_SIGSUB_PREFCOMPRESS: diff --git a/openpgp.h b/openpgp.h index 73a6f38..768a6f2 100644 --- a/openpgp.h +++ b/openpgp.h @@ -101,7 +101,7 @@ #define OPENPGP_SIGSUB_ISSUER 16 #define OPENPGP_SIGSUB_ISSUER_UID 17 /* Legacy */ #define OPENPGP_SIGSUB_URL 18 /* Legacy */ -#define OPENPGP_SIGSUB_ISSUER_FINGER 19 /* Legacy */ +#define OPENPGP_SIGSUB_X_ISSUER_FINGER 19 /* Legacy */ #define OPENPGP_SIGSUB_NOTATION 20 #define OPENPGP_SIGSUB_PREFHASH 21 #define OPENPGP_SIGSUB_PREFCOMPRESS 22 @@ -115,5 +115,6 @@ #define OPENPGP_SIGSUB_FEATURES 30 #define OPENPGP_SIGSUB_SIGNATURE_TARGET 31 #define OPENPGP_SIGSUB_EMBEDDED_SIG 32 +#define OPENPGP_SIGSUB_ISSUER_FINGER 33 #endif /* __OPENPGP_H__ */ -- 2.39.5