1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

gpg: Refactor function encrypt_seskey.

* g10/encrypt.c (encrypt_seskey): Allocate the buffer for the
encrypted key and returns that buffer and its length.
(encrypt_simple): Adjust for above change.
(write_symkey_enc): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-01-22 15:50:24 +01:00
parent 7356d6ec50
commit 0131d4369a
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
3 changed files with 112 additions and 53 deletions

View file

@ -2283,9 +2283,11 @@ sk_esk (const char *option, int argc, char *argv[], void *cookie)
DEK *sesdekp = &sesdek;
/* Now encrypt the session key (or rather, the algorithm used to
encrypt the SED plus the session key) using ENCKEY. */
ske->seskeylen = 1 + sesdek.keylen;
encrypt_seskey (&s2kdek, &sesdekp, ske->seskey);
encrypt the SKESK plus the session key) using ENCKEY. */
err = encrypt_seskey (&s2kdek, &sesdekp,
(void**)&ske->seskey, (size_t *)&ske->seskeylen);
if (err)
log_fatal ("encrypt_seskey failed: %s\n", gpg_strerror (err));
/* Save the session key for later. */
session_key = sesdek;