1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

Avoid using the protect-tool to import pkcs#12.

This commit is contained in:
Werner Koch 2010-06-17 15:44:44 +00:00
parent 28b3b74cbb
commit 006fd75aea
24 changed files with 1167 additions and 414 deletions

View file

@ -1,3 +1,11 @@
2010-06-17 Werner Koch <wk@g10code.com>
* sexputil.c (make_canon_sexp_pad): New.
2010-06-14 Werner Koch <wk@g10code.com>
* membuf.c (put_membuf): Add shortcut for !LEN.
2010-06-11 Marcus Brinkmann <marcus@g10code.de>
* sysutils.c (translate_sys2libc_fd): Revert last change.

View file

@ -59,7 +59,7 @@ init_membuf_secure (membuf_t *mb, int initiallen)
void
put_membuf (membuf_t *mb, const void *buf, size_t len)
{
if (mb->out_of_core)
if (mb->out_of_core || !len)
return;
if (mb->len + len >= mb->size)

View file

@ -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.

View file

@ -146,6 +146,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 make_canon_sexp_pad (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);