[svn] ksba - r308 - in trunk: . src

svn author wk cvs at cvs.gnupg.org
Wed Jul 1 16:42:34 CEST 2009


Author: wk
Date: 2009-07-01 16:42:34 +0200 (Wed, 01 Jul 2009)
New Revision: 308

Modified:
   trunk/NEWS
   trunk/src/ChangeLog
   trunk/src/dn.c
Log:
Handle BER encoded DNs. Those are not very useful 
but in some context allowed.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-06-29 13:40:07 UTC (rev 307)
+++ trunk/src/ChangeLog	2009-07-01 14:42:34 UTC (rev 308)
@@ -1,3 +1,8 @@
+2009-07-01  Werner Koch  <wk at g10code.com>
+
+	* dn.c (oid_name_tbl): Add dotted string representation of OIDs.
+	(append_atv): Try to match BER encoded OIDs.
+
 2009-06-29  Werner Koch  <wk at g10code.com>
 
 	* oid.c (ksba_oid_to_str): Add an overflow check so that we can

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2009-06-29 13:40:07 UTC (rev 307)
+++ trunk/NEWS	2009-07-01 14:42:34 UTC (rev 308)
@@ -1,7 +1,8 @@
 Noteworthy changes in version 1.0.7
 ------------------------------------------------
 
- * Detect overflow while parsing OIDs.
+ * Detect overflow while parsing OIDs.  Map BER encoded OIDs to well
+   known names.
 
 
 Noteworthy changes in version 1.0.6 (2009-06-05)

Modified: trunk/src/dn.c
===================================================================
--- trunk/src/dn.c	2009-06-29 13:40:07 UTC (rev 307)
+++ trunk/src/dn.c	2009-07-01 14:42:34 UTC (rev 308)
@@ -40,37 +40,31 @@
               */
   const char *description;
   size_t      oidlen;
-  const unsigned char *oid;
+  const unsigned char *oid;  /* DER encoded OID.  */
+  const char *oidstr;        /* OID as dotted string.  */
 } oid_name_tbl[] = { 
-{"CN", 1, "CommonName",            3, "\x55\x04\x03"}, /* 2.5.4.3 */
-{"SN", 2, "Surname",               3, "\x55\x04\x04"}, /* 2.5.4.4 */
-{"SERIALNUMBER", 2, "SerialNumber",3, "\x55\x04\x05"}, /* 2.5.4.5 */
-{"C",  1, "CountryName",           3, "\x55\x04\x06"}, /* 2.5.4.6 */
-{"L" , 1, "LocalityName",          3, "\x55\x04\x07"}, /* 2.5.4.7 */
-{"ST", 1, "StateOrProvince",       3, "\x55\x04\x08"}, /* 2.5.4.8 */
-{"STREET", 1, "StreetAddress",     3, "\x55\x04\x09"}, /* 2.5.4.9 */
-{"O",  1, "OrganizationName",      3, "\x55\x04\x0a"}, /* 2.5.4.10 */
-{"OU", 1, "OrganizationalUnit",    3, "\x55\x04\x0b"}, /* 2.5.4.11 */
-{"T",  2, "Title",                 3, "\x55\x04\x0c"}, /* 2.5.4.12 */
-{"D",
-       3, "Description",           3, "\x55\x04\x0d"}, /* 2.5.4.13 */
-{"BC",
-       3, "BusinessCategory",      3, "\x55\x04\x0f"}, /* 2.5.4.15 */
-{"ADDR",
-       2, "PostalAddress",         3, "\x55\x04\x11"}, /* 2.5.4.16 */
-{"POSTALCODE" , 0, "PostalCode",   3, "\x55\x04\x11"}, /* 2.5.4.17 */
-{"GN", 2, "GivenName",             3, "\x55\x04\x2a"}, /* 2.5.4.42 */
-{"PSEUDO", 2, "Pseudonym",         3, "\x55\x04\x41"}, /* 2.5.4.65 */
+{"CN", 1, "CommonName",            3, "\x55\x04\x03", "2.5.4.3" },
+{"SN", 2, "Surname",               3, "\x55\x04\x04", "2.5.4.4" },
+{"SERIALNUMBER", 2, "SerialNumber",3, "\x55\x04\x05", "2.5.4.5" },
+{"C",  1, "CountryName",           3, "\x55\x04\x06", "2.5.4.6" },
+{"L" , 1, "LocalityName",          3, "\x55\x04\x07", "2.5.4.7" },
+{"ST", 1, "StateOrProvince",       3, "\x55\x04\x08", "2.5.4.8" },
+{"STREET", 1, "StreetAddress",     3, "\x55\x04\x09", "2.5.4.9" },
+{"O",  1, "OrganizationName",      3, "\x55\x04\x0a", "2.5.4.10" },
+{"OU", 1, "OrganizationalUnit",    3, "\x55\x04\x0b", "2.5.4.11" },
+{"T",  2, "Title",                 3, "\x55\x04\x0c", "2.5.4.12" },
+{"D",  3, "Description",           3, "\x55\x04\x0d", "2.5.4.13" },
+{"BC", 3, "BusinessCategory",      3, "\x55\x04\x0f", "2.5.4.15" },
+{"ADDR", 2, "PostalAddress",       3, "\x55\x04\x11", "2.5.4.16" },
+{"POSTALCODE" , 0, "PostalCode",   3, "\x55\x04\x11", "2.5.4.17" },
+{"GN", 2, "GivenName",             3, "\x55\x04\x2a", "2.5.4.42" },
+{"PSEUDO", 2, "Pseudonym",         3, "\x55\x04\x41", "2.5.4.65" },
 {"DC", 1, "domainComponent",      10, 
-       "\x09\x92\x26\x89\x93\xF2\x2C\x64\x01\x19"},
-                            /* 0.9.2342.19200300.100.1.25 */
+    "\x09\x92\x26\x89\x93\xF2\x2C\x64\x01\x19", "0.9.2342.19200300.100.1.25" },
 {"UID", 1, "userid",              10,
-       "\x09\x92\x26\x89\x93\xF2\x2C\x64\x01\x01"},
-                            /* 0.9.2342.19200300.100.1.1  */
-
-{"EMAIL", 3, "emailAddress",               9,
-       "\x2A\x86\x48\x86\xF7\x0D\x01\x09\x01" },  /* 1.2.840.113549.1.9.1 */
-
+    "\x09\x92\x26\x89\x93\xF2\x2C\x64\x01\x01", "0.9.2342.19200300.100.1.1 " },
+{"EMAIL", 3, "emailAddress",       9,
+    "\x2A\x86\x48\x86\xF7\x0D\x01\x09\x01",     "1.2.840.113549.1.9.1" },
 { NULL }
 };
 
@@ -555,13 +549,32 @@
   if (name)
     put_stringbuf (sb, name);
   else
-    { /* No name in table: use the oid */
-      char *p = ksba_oid_to_str (image+node->off+node->nhdr, node->len);
+    { /* No name for the OID in the table; at least not DER encoded.
+         Now convert the OID to a string, try to find it in the table
+         again and use the string as last resort.  */
+      char *p;
+
+      p = ksba_oid_to_str (image+node->off+node->nhdr, node->len);
       if (!p)
         return gpg_error (GPG_ERR_ENOMEM);
-      put_stringbuf (sb, p);
+
+      for (i=0; *p && oid_name_tbl[i].name; i++)
+        {
+          if (oid_name_tbl[i].source == 1 
+              && !strcmp (p, oid_name_tbl[i].oidstr))
+            {
+              name = oid_name_tbl[i].name;
+              break;
+            }
+        }
+      if (name)
+        put_stringbuf (sb, name);
+      else
+        {
+          put_stringbuf (sb, p);
+          use_hex = 1;
+        }
       xfree (p);
-      use_hex = 1;
     }
   put_stringbuf (sb, "=");
   node = node->right;




More information about the Gnupg-commits mailing list