diff options
author | Werner Koch <wk@gnupg.org> | 2009-03-06 18:31:27 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2009-03-06 18:31:27 +0100 |
commit | a9c317a95c440a083809346d61cdb78abff71b12 (patch) | |
tree | 6f5199efe8fba5473afc346f003abe74f6ab424e /common | |
parent | New PIN Callback attributes in gpg-agent. (diff) | |
download | gnupg2-a9c317a95c440a083809346d61cdb78abff71b12.tar.xz gnupg2-a9c317a95c440a083809346d61cdb78abff71b12.zip |
New gpg-agent command to list key information.
Gpgsm does now print the S/N of cards.
Consider ephemeral keys during listing an export.
Diffstat (limited to 'common')
-rw-r--r-- | common/ChangeLog | 4 | ||||
-rw-r--r-- | common/sexputil.c | 38 | ||||
-rw-r--r-- | common/util.h | 4 |
3 files changed, 44 insertions, 2 deletions
diff --git a/common/ChangeLog b/common/ChangeLog index 61ae679b4..f5ba7d725 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,7 @@ +2009-03-06 Werner Koch <wk@g10code.com> + + * sexputil.c (make_canon_sexp): New. + 2009-03-03 Werner Koch <wk@g10code.com> * exechelp.c (do_exec): Make sure that /dev/null connected FDs are diff --git a/common/sexputil.c b/common/sexputil.c index 4907a9355..4ff7b4955 100644 --- a/common/sexputil.c +++ b/common/sexputil.c @@ -1,5 +1,5 @@ /* sexputil.c - Utility functions for S-expressions. - * Copyright (C) 2005, 2007 Free Software Foundation, Inc. + * Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -34,6 +34,42 @@ #include "util.h" #include "sexp-parse.h" + +/* Helper function to create a a canonical encoded S-expression from a + Libgcrypt S-expression object. The function returns 0 on success + and the malloced canonical S-expression is stored at R_BUFFER and + the allocated length at R_BUFLEN. On error an error code is + returned and (NULL, 0) stored at R_BUFFER and R_BUFLEN. If the + allocated buffer length is not required, NULL by be used for + R_BUFLEN. */ +gpg_error_t +make_canon_sexp (gcry_sexp_t sexp, unsigned char **r_buffer, size_t *r_buflen) +{ + size_t len; + unsigned char *buf; + + *r_buffer = NULL; + if (r_buflen) + *r_buflen = 0;; + + len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0); + if (!len) + return gpg_error (GPG_ERR_BUG); + buf = xtrymalloc (len); + if (!buf) + return gpg_error_from_syserror (); + len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, buf, len); + if (!len) + return gpg_error (GPG_ERR_BUG); + + *r_buffer = buf; + if (r_buflen) + *r_buflen = len; + + return 0; +} + + /* Return the so called "keygrip" which is the SHA-1 hash of the public key parameters expressed in a way depended on the algorithm. diff --git a/common/util.h b/common/util.h index 66569e27e..d117f86bf 100644 --- a/common/util.h +++ b/common/util.h @@ -1,5 +1,5 @@ /* util.h - Utility functions for GnuPG - * Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2004, 2009 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -183,6 +183,8 @@ gpg_error_t b64dec_finish (struct b64state *state); /*-- sexputil.c */ +gpg_error_t make_canon_sexp (gcry_sexp_t sexp, + unsigned char **r_buffer, size_t *r_buflen); gpg_error_t keygrip_from_canon_sexp (const unsigned char *key, size_t keylen, unsigned char *grip); int cmp_simple_canon_sexp (const unsigned char *a, const unsigned char *b); |