diff options
author | Werner Koch <[email protected]> | 2014-04-15 14:40:48 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2014-04-15 17:44:42 +0000 |
commit | c4d983239a3f0a18c77f0a5aeba520a81a1b86e8 (patch) | |
tree | d7ae8c7eb42b0001f343039aa5f0f5515626482e /agent/cvt-openpgp.c | |
parent | gpg: Change pinentry prompt to talk about "secret key". (diff) | |
download | gnupg-c4d983239a3f0a18c77f0a5aeba520a81a1b86e8.tar.gz gnupg-c4d983239a3f0a18c77f0a5aeba520a81a1b86e8.zip |
gpg: Fix regression in secret key export.
* agent/cvt-openpgp.c (convert_to_openpgp): Fix use
gcry_sexp_extract_param.
* g10/export.c (do_export_stream): Provide a proper prompt to the
agent.
--
NB: The export needs more work, in particular the ECC algorithms.
Diffstat (limited to '')
-rw-r--r-- | agent/cvt-openpgp.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/agent/cvt-openpgp.c b/agent/cvt-openpgp.c index 5718bd904..4c34130bb 100644 --- a/agent/cvt-openpgp.c +++ b/agent/cvt-openpgp.c @@ -1,7 +1,7 @@ /* cvt-openpgp.c - Convert an OpenPGP key to our internal format. * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006, 2009, * 2010 Free Software Foundation, Inc. - * Copyright (C) 2013 Werner Koch + * Copyright (C) 2013, 2014 Werner Koch * * This file is part of GnuPG. * @@ -1134,7 +1134,6 @@ convert_to_openpgp (ctrl_t ctrl, gcry_sexp_t s_key, const char *passphrase, gcry_sexp_t list, l2; char *name; const char *algoname; - const char *elems; int npkey, nskey; gcry_mpi_t array[10]; char protect_iv[16]; @@ -1170,55 +1169,62 @@ convert_to_openpgp (ctrl_t ctrl, gcry_sexp_t s_key, const char *passphrase, { algoname = "rsa"; npkey = 2; - elems = "nedpqu"; + nskey = 6; + err = gcry_sexp_extract_param (list, NULL, "nedpqu", + array+0, array+1, array+2, array+3, + array+4, array+5, NULL); } else if (!strcmp (name, "elg")) { algoname = "elg"; npkey = 3; - elems = "pgyx"; + nskey = 4; + err = gcry_sexp_extract_param (list, NULL, "pgyx", + array+0, array+1, array+2, array+3, + NULL); } else if (!strcmp (name, "dsa")) { algoname = "dsa"; npkey = 4; - elems = "pqgyx"; + nskey = 5; + err = gcry_sexp_extract_param (list, NULL, "pqgyx", + array+0, array+1, array+2, array+3, + array+4, NULL); } else if (!strcmp (name, "ecc")) { + /* FIXME: We need to use the curve parameter. */ algoname = "?"; /* Decide later by checking the usage. */ npkey = 6; - elems = "pabgnqd"; + nskey = 7; + err = gcry_sexp_extract_param (list, NULL, "pabgnqd", + array+0, array+1, array+2, array+3, + array+4, array+5, array+6, NULL); } else if (!strcmp (name, "ecdsa")) { algoname = "ecdsa"; npkey = 6; - elems = "pabgnqd"; + nskey = 7; + err = gcry_sexp_extract_param (list, NULL, "pabgnqd", + array+0, array+1, array+2, array+3, + array+4, array+5, array+6, NULL); } else if (!strcmp (name, "ecdh")) { algoname = "ecdh"; npkey = 6; - elems = "pabgnqd"; + nskey= 7; + err = gcry_sexp_extract_param (list, NULL, "pabgnqd", + array+0, array+1, array+2, array+3, + array+4, array+5, array+6, NULL); } else { - algoname = ""; - npkey = 0; - elems = NULL; + err = gpg_error (GPG_ERR_PUBKEY_ALGO); } xfree (name); - assert (!elems || strlen (elems) < DIM (array) ); - nskey = elems? strlen (elems) : 0; - - /* Extract the parameters and put them into an array. */ - if (!elems) - err = gpg_error (GPG_ERR_PUBKEY_ALGO); - else - err = gcry_sexp_extract_param (list, NULL, elems, - array+0, array+1, array+2, array+3, array+4, - array+5, array+6, NULL); gcry_sexp_release (list); if (err) return err; |