summaryrefslogtreecommitdiffstats
path: root/kbx/keybox-blob.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2001-12-14 21:48:07 +0100
committerWerner Koch <wk@gnupg.org>2001-12-14 21:48:07 +0100
commit134d401a4ea111b423660b81c062c49d1d6bd449 (patch)
treebea2388bc7226317ff7443cfc90a63d99485ba4c /kbx/keybox-blob.c
parent* verify.c (gpgsm_verify): Add hash debug helpers (diff)
downloadgnupg2-134d401a4ea111b423660b81c062c49d1d6bd449.tar.xz
gnupg2-134d401a4ea111b423660b81c062c49d1d6bd449.zip
* keybox-blob.c (x509_email_kludge): New.
(_keybox_create_x509_blob): Insert an extra email address if the subject's DN has an email part. * keybox-defs.h: Added the xtoi_2 and digitp macros.
Diffstat (limited to 'kbx/keybox-blob.c')
-rw-r--r--kbx/keybox-blob.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/kbx/keybox-blob.c b/kbx/keybox-blob.c
index 1f5fe2bbd..44d53d3d0 100644
--- a/kbx/keybox-blob.c
+++ b/kbx/keybox-blob.c
@@ -773,21 +773,29 @@ _keybox_create_pgp_blob (KEYBOXBLOB *r_blob, KBNODE keyblock)
static char *
x509_email_kludge (const char *name)
{
-#if 0
- if (!strncmp (name, "1.2.840.113549.1.9.1=#", 22)
- && hexdigitp (name+22) && hexdigitp (name+23))
- { /* this looks pretty much like an email address in the
- subjects DN we use this to add an additional user ID
- entry. This way, openSSL generated keys get a nicer and
- usable listing */
- char *buf = NULL;
-
- /* FIXME */
+ const unsigned char *p;
+ unsigned char *buf;
+ int n;
- return buf;
- }
-#endif
- return NULL;
+ if (strncmp (name, "1.2.840.113549.1.9.1=#", 22))
+ return NULL;
+ /* This looks pretty much like an email address in the subject's DN
+ we use this to add an additional user ID entry. This way,
+ openSSL generated keys get a nicer and usable listing */
+ name += 22;
+ for (n=0, p=name; hexdigitp (p) && hexdigitp (p+1); p +=2, n++)
+ ;
+ if (*p != '#' || !n)
+ return NULL;
+ buf = xtrymalloc (n+3);
+ if (!buf)
+ return NULL; /* oops, out of core */
+ *buf = '<';
+ for (n=1, p=name; *p != '#'; p +=2, n++)
+ buf[n] = xtoi_2 (p);
+ buf[n++] = '>';
+ buf[n] = 0;
+ return buf;
}