mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-25 22:19:59 +01:00
gpg: Fix export of ecc secret keys by adjusting check ordering.
* g10/export.c (transfer_format_to_openpgp): Move the check against PUBKEY_MAX_NSKEY to after the ECC code adjusts the number of parameters.
This commit is contained in:
parent
c913e09ebd
commit
4054d86abc
@ -462,7 +462,7 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk)
|
||||
xfree (string); string = NULL;
|
||||
if (gcry_pk_algo_info (pk_algo, GCRYCTL_GET_ALGO_NPKEY, NULL, &npkey)
|
||||
|| gcry_pk_algo_info (pk_algo, GCRYCTL_GET_ALGO_NSKEY, NULL, &nskey)
|
||||
|| !npkey || npkey >= nskey || nskey > PUBKEY_MAX_NSKEY)
|
||||
|| !npkey || npkey >= nskey)
|
||||
goto bad_seckey;
|
||||
|
||||
/* Check that the pubkey algo matches the one from the public key. */
|
||||
@ -503,6 +503,10 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk)
|
||||
goto leave;
|
||||
}
|
||||
|
||||
/* This check has to go after the ecc adjustments. */
|
||||
if (nskey > PUBKEY_MAX_NSKEY)
|
||||
goto bad_seckey;
|
||||
|
||||
/* Parse the key parameters. */
|
||||
gcry_sexp_release (list);
|
||||
list = gcry_sexp_find_token (top_list, "skey", 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user