diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2021-11-12 07:09:05 +0100 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2021-11-12 07:39:30 +0100 |
commit | b124bca592e15dcf41b621be517bc4af9e1e9d4d (patch) | |
tree | 778fd51d77fc30dc198328d4733813687be95d0f /g10/ecdh.c | |
parent | kbx: Avoid use of uninitialized value. (diff) | |
download | gnupg2-b124bca592e15dcf41b621be517bc4af9e1e9d4d.tar.xz gnupg2-b124bca592e15dcf41b621be517bc4af9e1e9d4d.zip |
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>
Diffstat (limited to 'g10/ecdh.c')
-rw-r--r-- | g10/ecdh.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/g10/ecdh.c b/g10/ecdh.c index d048951d7..c3337d1dc 100644 --- a/g10/ecdh.c +++ b/g10/ecdh.c @@ -52,15 +52,12 @@ static const struct gcry_mpi_t 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; - 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 possible choices. Performance is not an issue here, only interoperability. */ @@ -78,7 +75,7 @@ pk_ecdh_default_params (unsigned int qbits) if (DBG_CRYPTO) 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); } |