mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
gpg: Fix algo string parsing of --quick-addkey.
* g10/keygen.c (parse_key_parameter_string): Fix handling of PART==1. (parse_key_parameter_part): Use default key size if only "rsa", "dsa", or "elg" is given. -- The first change is the actual fix. The second change avoids the error "Invalid Curve" when only "rsa" instead of RSA2048 is given. Fixes-commit: ce29272e24e7b718b8fca9b84bc728e65f3dea24 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
d568a15616
commit
522e6f798d
21
g10/keygen.c
21
g10/keygen.c
@ -2871,7 +2871,7 @@ parse_key_parameter_part (char *string, int for_subkey,
|
|||||||
char const **r_curve)
|
char const **r_curve)
|
||||||
{
|
{
|
||||||
char *flags;
|
char *flags;
|
||||||
int algo = 0;
|
int algo;
|
||||||
char *endp;
|
char *endp;
|
||||||
const char *curve = NULL;
|
const char *curve = NULL;
|
||||||
int ecdh_or_ecdsa = 0;
|
int ecdh_or_ecdsa = 0;
|
||||||
@ -2887,7 +2887,8 @@ parse_key_parameter_part (char *string, int for_subkey,
|
|||||||
if (flags)
|
if (flags)
|
||||||
*flags++ = 0;
|
*flags++ = 0;
|
||||||
|
|
||||||
if (strlen (string) > 3 && digitp (string+3))
|
algo = 0;
|
||||||
|
if (strlen (string) >= 3 && (digitp (string+3) || !string[3]))
|
||||||
{
|
{
|
||||||
if (!ascii_memcasecmp (string, "rsa", 3))
|
if (!ascii_memcasecmp (string, "rsa", 3))
|
||||||
algo = PUBKEY_ALGO_RSA;
|
algo = PUBKEY_ALGO_RSA;
|
||||||
@ -2897,11 +2898,16 @@ parse_key_parameter_part (char *string, int for_subkey,
|
|||||||
algo = PUBKEY_ALGO_ELGAMAL_E;
|
algo = PUBKEY_ALGO_ELGAMAL_E;
|
||||||
}
|
}
|
||||||
if (algo)
|
if (algo)
|
||||||
|
{
|
||||||
|
if (!string[3])
|
||||||
|
size = get_keysize_range (algo, NULL, NULL);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
size = strtoul (string+3, &endp, 10);
|
size = strtoul (string+3, &endp, 10);
|
||||||
if (size < 512 || size > 16384 || *endp)
|
if (size < 512 || size > 16384 || *endp)
|
||||||
return gpg_error (GPG_ERR_INV_VALUE);
|
return gpg_error (GPG_ERR_INV_VALUE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if ((curve = openpgp_is_curve_supported (string, &algo, &size)))
|
else if ((curve = openpgp_is_curve_supported (string, &algo, &size)))
|
||||||
{
|
{
|
||||||
if (!algo)
|
if (!algo)
|
||||||
@ -3080,8 +3086,9 @@ parse_key_parameter_part (char *string, int for_subkey,
|
|||||||
* used:
|
* used:
|
||||||
* -1 := Both parts
|
* -1 := Both parts
|
||||||
* 0 := Only the part of the primary key
|
* 0 := Only the part of the primary key
|
||||||
* 1 := Only the part of the secondary key is parsed but returned
|
* 1 := If there is one part parse that one, if there are
|
||||||
* in the args for the primary key (R_ALGO,....)
|
* two parts parse the second part. Always return
|
||||||
|
* in the args for the primary key (R_ALGO,....).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
gpg_error_t
|
gpg_error_t
|
||||||
@ -3133,8 +3140,10 @@ parse_key_parameter_string (const char *string, int part,
|
|||||||
}
|
}
|
||||||
else if (part == 1)
|
else if (part == 1)
|
||||||
{
|
{
|
||||||
err = parse_key_parameter_part (secondary, 1, r_algo, r_size,
|
/* If we have SECONDARY, use that part. If there is only one
|
||||||
r_keyuse, r_curve);
|
* part consider this to be the subkey algo. */
|
||||||
|
err = parse_key_parameter_part (secondary? secondary : primary, 1,
|
||||||
|
r_algo, r_size, r_keyuse, r_curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree (primary);
|
xfree (primary);
|
||||||
|
@ -3050,7 +3050,7 @@ parse_mdc (IOBUF inp, int pkttype, unsigned long pktlen,
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This packet is internally generated by us (ibn armor.c) to transfer
|
* This packet is internally generated by us (in armor.c) to transfer
|
||||||
* some information to the lower layer. To make sure that this packet
|
* some information to the lower layer. To make sure that this packet
|
||||||
* is really a GPG faked one and not one coming from outside, we
|
* is really a GPG faked one and not one coming from outside, we
|
||||||
* first check that there is a unique tag in it.
|
* first check that there is a unique tag in it.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user