mirror of
git://git.gnupg.org/gnupg.git
synced 2024-06-04 22:57:47 +02:00
gpg: Don't use malloc for kek_params.
* g10/ecdh.c (pk_ecdh_default_params): Use stack for kek_params. -- GnuPG-bug-id: 5393 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
fae1d2e2cc
commit
b124bca592
13
g10/ecdh.c
13
g10/ecdh.c
|
@ -52,15 +52,12 @@ static const struct
|
||||||
gcry_mpi_t
|
gcry_mpi_t
|
||||||
pk_ecdh_default_params (unsigned int qbits)
|
pk_ecdh_default_params (unsigned int qbits)
|
||||||
{
|
{
|
||||||
byte *kek_params;
|
byte kek_params[4] = {
|
||||||
|
3, /* Number of bytes to follow. */
|
||||||
|
1 /* Version for KDF+AESWRAP. */
|
||||||
|
};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
kek_params = xtrymalloc (4);
|
|
||||||
if (!kek_params)
|
|
||||||
return NULL;
|
|
||||||
kek_params[0] = 3; /* Number of bytes to follow. */
|
|
||||||
kek_params[1] = 1; /* Version for KDF+AESWRAP. */
|
|
||||||
|
|
||||||
/* Search for matching KEK parameter. Defaults to the strongest
|
/* Search for matching KEK parameter. Defaults to the strongest
|
||||||
possible choices. Performance is not an issue here, only
|
possible choices. Performance is not an issue here, only
|
||||||
interoperability. */
|
interoperability. */
|
||||||
|
@ -78,7 +75,7 @@ pk_ecdh_default_params (unsigned int qbits)
|
||||||
if (DBG_CRYPTO)
|
if (DBG_CRYPTO)
|
||||||
log_printhex (kek_params, sizeof(kek_params), "ECDH KEK params are");
|
log_printhex (kek_params, sizeof(kek_params), "ECDH KEK params are");
|
||||||
|
|
||||||
return gcry_mpi_set_opaque (NULL, kek_params, 4 * 8);
|
return gcry_mpi_set_opaque_copy (NULL, kek_params, 4 * 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user