]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Detection of revoked OpenPGP userID's.
authorTimo Schulz <twoaday@gnutls.org>
Mon, 18 Mar 2002 18:25:24 +0000 (18:25 +0000)
committerTimo Schulz <twoaday@gnutls.org>
Mon, 18 Mar 2002 18:25:24 +0000 (18:25 +0000)
lib/gnutls_errors_int.h
lib/gnutls_openpgp.c

index 4969b3fa963fef39537cd92257b454cca5efbe8d..35d904ae0ec15c2fa55f7ead7e644a3473d784fe 100644 (file)
@@ -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
 
index f1b0fad2ce149628d6167a0bcf8d44c32c401260..25863981251dc369c7d31ee58861e2e958f84e84 100644 (file)
@@ -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 );