From: Timo Schulz Date: Mon, 18 Mar 2002 18:25:24 +0000 (+0000) Subject: Detection of revoked OpenPGP userID's. X-Git-Tag: gnutls_0_3_92~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd6afee6568b09d561dcae72771e1e41d5079897;p=thirdparty%2Fgnutls.git Detection of revoked OpenPGP userID's. --- diff --git a/lib/gnutls_errors_int.h b/lib/gnutls_errors_int.h index 4969b3fa96..35d904ae0e 100644 --- a/lib/gnutls_errors_int.h +++ b/lib/gnutls_errors_int.h @@ -76,6 +76,7 @@ #define GNUTLS_E_ASN1_SYNTAX_ERROR -76 #define GNUTLS_E_ASN1_DER_OVERFLOW -77 #define GNUTLS_E_TOO_MANY_EMPTY_PACKETS -78 +#define GNUTLS_E_OPENPGP_UID_REVOKED -79 #define GNUTLS_E_UNIMPLEMENTED_FEATURE -250 diff --git a/lib/gnutls_openpgp.c b/lib/gnutls_openpgp.c index f1b0fad2ce..2586398125 100644 --- a/lib/gnutls_openpgp.c +++ b/lib/gnutls_openpgp.c @@ -316,10 +316,10 @@ datum_to_kbnode( const gnutls_datum *raw, KBNODE *r_pkt ) goto leave; } else - rc = 0; + rc = 0; leave: - cdk_iobuf_close(buf); + cdk_iobuf_close( buf ); *r_pkt = (!rc)? pkt : NULL; return rc; @@ -915,7 +915,8 @@ gnutls_openpgp_extract_key_name( const gnutls_datum *cert, if ( idx < 0 || idx > gnutls_openpgp_count_key_names( cert ) ) return GNUTLS_E_UNKNOWN_ERROR; - + + memset(dn, 0, sizeof *dn); rc = datum_to_kbnode( cert, &kb_pk ); if ( rc ) return rc; @@ -925,26 +926,23 @@ gnutls_openpgp_extract_key_name( const gnutls_datum *cert, { for ( pos=0, pkt=kb_pk; pkt; pkt=pkt->next ) { - if ( pkt->pkt->pkttype == PKT_USER_ID && pos == idx ) + if ( pkt->pkt->pkttype == PKT_USER_ID && ++pos == idx ) break; } } if ( pkt ) uid = pkt->pkt->pkt.user_id; - if (!uid) + if ( !uid ) { rc = GNUTLS_E_UNKNOWN_ERROR; goto leave; } - memset(dn, 0, sizeof *dn); - size = uid->len < OPENPGP_NAME_SIZE? uid->len : OPENPGP_NAME_SIZE; + size = uid->len < OPENPGP_NAME_SIZE? uid->len : OPENPGP_NAME_SIZE-1; memcpy(dn->name, uid->name, size); dn->name[size] = '\0'; /* make sure it's a string */ - /* - * Extract the email address from the userID string and save it to - * the email field. - */ + /* Extract the email address from the userID string and save + it to the email field. */ email = strchr(uid->name, '<'); if ( email ) pos1 = email-uid->name+1; @@ -958,6 +956,11 @@ gnutls_openpgp_extract_key_name( const gnutls_datum *cert, memcpy(dn->email, uid->name+pos1, size); dn->email[size-1] = '\0'; /* make sure it's a string */ } + if ( uid->is_revoked ) + { + rc = GNUTLS_E_OPENPGP_UID_REVOKED; + goto leave; + } leave: cdk_kbnode_release( kb_pk );