diff options
author | Werner Koch <wk@gnupg.org> | 2001-12-14 14:43:42 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2001-12-14 14:43:42 +0100 |
commit | 7606e3b33a57016b39b02857a7094e378a245ec3 (patch) | |
tree | efbf689db541926ab5a8683e2c39a4e4793e93d4 | |
parent | * util.h (digitp, hexdigitp): New ctype like macros. (diff) | |
download | gnupg2-7606e3b33a57016b39b02857a7094e378a245ec3.tar.xz gnupg2-7606e3b33a57016b39b02857a7094e378a245ec3.zip |
* util.h (digitp, hexdigitp): New ctype like macros.
(atoi_1,atoi_2,atoi_4,xtoi_1,xtoi_2): New.
* command.c: Removed the conversion macros as they are now in
../common/util.h.
-rw-r--r-- | agent/ChangeLog | 5 | ||||
-rw-r--r-- | agent/command.c | 15 | ||||
-rw-r--r-- | assuan/assuan-handler.c | 3 | ||||
-rw-r--r-- | common/util.h | 4 | ||||
-rw-r--r-- | kbx/keybox-blob.c | 29 | ||||
-rw-r--r-- | sm/server.c | 2 |
6 files changed, 41 insertions, 17 deletions
diff --git a/agent/ChangeLog b/agent/ChangeLog index 0d59e84e4..6971b206c 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,8 @@ +2001-12-14 Werner Koch <wk@gnupg.org> + + * command.c: Removed the conversion macros as they are now in + ../common/util.h. + 2001-12-14 Marcus Brinkmann <marcus@g10code.de> * query.c (LINELENGTH): Removed. diff --git a/agent/command.c b/agent/command.c index 33e61f69c..bbee7b412 100644 --- a/agent/command.c +++ b/agent/command.c @@ -37,16 +37,7 @@ #define set_error(e,t) assuan_set_error (ctx, ASSUAN_ ## e, (t)) -#define digitp(a) ((a) >= '0' && (a) <= '9') -#define hexdigitp(a) (digitp (a) \ - || ((a) >= 'A' && (a) <= 'F') \ - || ((a) >= 'a' && (a) <= 'f')) -#define atoi_1(p) (*(p) - '0' ) -#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1)) -/* assumes ASCII and pre-checked values */ -#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ - *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) -#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) + #if MAX_DIGEST_LEN < 20 #error MAX_DIGEST_LEN shorter than keygrip @@ -129,7 +120,7 @@ cmd_sigkey (ASSUAN_CONTEXT ctx, char *line) unsigned char *buf; /* parse the hash value */ - for (p=line,n=0; hexdigitp (*p); p++, n++) + for (p=line,n=0; hexdigitp (p); p++, n++) ; if (*p) return set_error (Parameter_Error, "invalid hexstring"); @@ -169,7 +160,7 @@ cmd_sethash (ASSUAN_CONTEXT ctx, char *line) ctrl->digest.algo = algo; /* parse the hash value */ - for (p=line,n=0; hexdigitp (*p); p++, n++) + for (p=line,n=0; hexdigitp (p); p++, n++) ; if (*p) return set_error (Parameter_Error, "invalid hexstring"); diff --git a/assuan/assuan-handler.c b/assuan/assuan-handler.c index 614f83d8a..8ec8b2301 100644 --- a/assuan/assuan-handler.c +++ b/assuan/assuan-handler.c @@ -458,7 +458,8 @@ assuan_process_next (ASSUAN_CONTEXT ctx) * * Return all active filedescriptors for the given context. This * function can be used to select on the fds and call - * assuan_process_next() if there is an active one. + * assuan_process_next() if there is an active one. The first fd in + * the array is the one used for the command connection. * * Note, that write FDs are not yet supported. * diff --git a/common/util.h b/common/util.h index e30923330..35529253a 100644 --- a/common/util.h +++ b/common/util.h @@ -58,8 +58,8 @@ int map_assuan_err (int err); /* some macros to replace ctype ones and avoid locale problems */ #define digitp(p) (*(p) >= '0' && *(p) <= '9') #define hexdigitp(a) (digitp (a) \ - || ((a) >= 'A' && (a) <= 'F') \ - || ((a) >= 'a' && (a) <= 'f')) + || (*(a) >= 'A' && *(a) <= 'F') \ + || (*(a) >= 'a' && *(a) <= 'f')) /* the atoi macros assume that the buffer has only valid digits */ #define atoi_1(p) (*(p) - '0' ) #define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1)) diff --git a/kbx/keybox-blob.c b/kbx/keybox-blob.c index 18503a576..1f5fe2bbd 100644 --- a/kbx/keybox-blob.c +++ b/kbx/keybox-blob.c @@ -121,7 +121,6 @@ X.509 specific are noted like [X.509: xxx] #include "keybox-defs.h" - /* special values of the signature status */ #define SF_NONE(a) ( !(a) ) #define SF_NOKEY(a) ((a) & (1<<0)) @@ -768,6 +767,31 @@ _keybox_create_pgp_blob (KEYBOXBLOB *r_blob, KBNODE keyblock) #endif /*KEYBOX_WITH_OPENPGP*/ #ifdef KEYBOX_WITH_X509 + +/* return an allocated string with the email address extracted from a + DN */ +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 */ + + return buf; + } +#endif + return NULL; +} + + + /* Note: We should move calculation of the digest into libksba and remove that parameter */ int @@ -813,6 +837,7 @@ _keybox_create_x509_blob (KEYBOXBLOB *r_blob, KsbaCert cert, names[blob->nuids++] = p; for (i=0; (p = ksba_cert_get_subject (cert, i)); i++) { + if (blob->nuids >= max_names) { unsigned char **tmp; @@ -826,6 +851,8 @@ _keybox_create_x509_blob (KEYBOXBLOB *r_blob, KsbaCert cert, } } names[blob->nuids++] = p; + if (!i && (p=x509_email_kludge (p))) + names[blob->nuids++] = p; /* due to !i we don't need to check bounds*/ } /* space for signature information */ diff --git a/sm/server.c b/sm/server.c index 59a40eae7..a4c06318b 100644 --- a/sm/server.c +++ b/sm/server.c @@ -316,7 +316,7 @@ cmd_message (ASSUAN_CONTEXT ctx, char *line) if (strncmp (line, "FD=", 3)) return set_error (Syntax_Error, "FD=<n> expected"); line += 3; - if (!digitp (*line)) + if (!digitp (line)) return set_error (Syntax_Error, "number required"); fd = strtoul (line, &endp, 10); if (*endp) |