mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
gpg: Move S2K encoding function to a shared file.
* g10/passphrase.c (encode_s2k_iterations): Move function to ... * common/openpgp-s2k.c: new file. Remove default intialization code. * common/openpgpdefs.h (S2K_DECODE_COUNT): New to keep only one copy. * g10/call-agent.c (agent_get_s2k_count): Change to return the count and print an error. * agent/protect.c: Include openpgpdefs.h * g10/card-util.c (gen_kdf_data): Adjust for changes * g10/gpgcompose.c: Include call-agent.h. (sk_esk): Adjust for changes. * g10/passphrase (passphrase_to_dek): Adjust for changes. * g10/main.h (S2K_DECODE_COUNT): Remove macro. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
0415b80227
commit
ec13b1c562
12 changed files with 111 additions and 71 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "keydb.h"
|
||||
#include "main.h"
|
||||
#include "options.h"
|
||||
#include "call-agent.h"
|
||||
|
||||
static int do_debug;
|
||||
#define debug(fmt, ...) \
|
||||
|
@ -2248,9 +2249,12 @@ sk_esk (const char *option, int argc, char *argv[], void *cookie)
|
|||
log_assert (sizeof (si.salt) == sizeof (ske->s2k.salt));
|
||||
memcpy (ske->s2k.salt, si.salt, sizeof (ske->s2k.salt));
|
||||
if (! si.s2k_is_session_key)
|
||||
/* 0 means get the default. */
|
||||
ske->s2k.count = encode_s2k_iterations (si.iterations);
|
||||
|
||||
{
|
||||
if (!si.iterations)
|
||||
ske->s2k.count = encode_s2k_iterations (agent_get_s2k_count ());
|
||||
else
|
||||
ske->s2k.count = encode_s2k_iterations (si.iterations);
|
||||
}
|
||||
|
||||
/* Derive the symmetric key that is either the session key or the
|
||||
key used to encrypt the session key. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue