diff options
author | Werner Koch <wk@gnupg.org> | 2010-06-17 17:44:44 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2010-06-17 17:44:44 +0200 |
commit | 006fd75aea5cc766bc223e435e5a07b543d658d3 (patch) | |
tree | 2f4365e73bf0a8b5272426fcf1fde9b75be4002e /common/sexputil.c | |
parent | Add makefiles to build a w32 development package. (diff) | |
download | gnupg2-006fd75aea5cc766bc223e435e5a07b543d658d3.tar.xz gnupg2-006fd75aea5cc766bc223e435e5a07b543d658d3.zip |
Avoid using the protect-tool to import pkcs#12.
Diffstat (limited to 'common/sexputil.c')
-rw-r--r-- | common/sexputil.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/common/sexputil.c b/common/sexputil.c index 736caded3..b336145c4 100644 --- a/common/sexputil.c +++ b/common/sexputil.c @@ -36,7 +36,7 @@ #include "sexp-parse.h" -/* Helper function to create a a canonical encoded S-expression from a +/* Helper function to create 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 @@ -71,6 +71,36 @@ make_canon_sexp (gcry_sexp_t sexp, unsigned char **r_buffer, size_t *r_buflen) } +/* Same as make_canon_sexp but pad the buffer to multiple of 64 + bits. */ +gpg_error_t +make_canon_sexp_pad (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); + len += (8 - len % 8) % 8; + buf = xtrycalloc (1, len); + if (!buf) + return gpg_error_from_syserror (); + if (!gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, buf, 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. |