mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
Code cleanup.
This commit is contained in:
parent
d68470d9b4
commit
c241d02e0d
@ -1,3 +1,9 @@
|
|||||||
|
2008-06-23 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* encrypt.c (encode_session_key): Replace xmalloc by xtrymalloc.
|
||||||
|
Use bin2hex instead of open coding the conversion.
|
||||||
|
(encrypt_dek): Init S_DATA.
|
||||||
|
|
||||||
2008-06-13 Marcus Brinkmann <marcus@ulysses.g10code.com>
|
2008-06-13 Marcus Brinkmann <marcus@ulysses.g10code.com>
|
||||||
|
|
||||||
* call-dirmngr.c (prepare_dirmngr): Fix error code to ignore.
|
* call-dirmngr.c (prepare_dirmngr): Fix error code to ignore.
|
||||||
|
26
sm/encrypt.c
26
sm/encrypt.c
@ -1,5 +1,5 @@
|
|||||||
/* encrypt.c - Encrypt a message
|
/* encrypt.c - Encrypt a message
|
||||||
* Copyright (C) 2001, 2003, 2004, 2007 Free Software Foundation, Inc.
|
* Copyright (C) 2001, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This file is part of GnuPG.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -144,17 +144,14 @@ static int
|
|||||||
encode_session_key (DEK dek, gcry_sexp_t * r_data)
|
encode_session_key (DEK dek, gcry_sexp_t * r_data)
|
||||||
{
|
{
|
||||||
gcry_sexp_t data;
|
gcry_sexp_t data;
|
||||||
char * p, tmp[3];
|
char *p;
|
||||||
int i;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
p = xmalloc (64 + 2 * dek->keylen);
|
p = xtrymalloc (64 + 2 * dek->keylen);
|
||||||
|
if (!p)
|
||||||
|
return gpg_error_from_syserror ();
|
||||||
strcpy (p, "(data\n (flags pkcs1)\n (value #");
|
strcpy (p, "(data\n (flags pkcs1)\n (value #");
|
||||||
for (i=0; i < dek->keylen; i++)
|
bin2hex (dek->key, dek->keylen, p + strlen (p));
|
||||||
{
|
|
||||||
sprintf (tmp, "%02x", (unsigned char) dek->key[i]);
|
|
||||||
strcat (p, tmp);
|
|
||||||
}
|
|
||||||
strcat (p, "#))\n");
|
strcat (p, "#))\n");
|
||||||
rc = gcry_sexp_sscan (&data, NULL, p, strlen (p));
|
rc = gcry_sexp_sscan (&data, NULL, p, strlen (p));
|
||||||
xfree (p);
|
xfree (p);
|
||||||
@ -196,13 +193,14 @@ encrypt_dek (const DEK dek, ksba_cert_t cert, unsigned char **encval)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* put the encoded cleartext into a simple list */
|
/* Put the encoded cleartext into a simple list. */
|
||||||
|
s_data = NULL; /* (avoid compiler warning) */
|
||||||
rc = encode_session_key (dek, &s_data);
|
rc = encode_session_key (dek, &s_data);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
log_error ("encode_session_key failed: %s\n", gpg_strerror (rc));
|
log_error ("encode_session_key failed: %s\n", gpg_strerror (rc));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pass it to libgcrypt */
|
/* pass it to libgcrypt */
|
||||||
rc = gcry_pk_encrypt (&s_ciph, s_data, s_pkey);
|
rc = gcry_pk_encrypt (&s_ciph, s_data, s_pkey);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user