mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Add build and runtime support for larger RSA keys
* configure.ac: Added --enable-large-secmem option. * g10/options.h: Add opt.flags.large_rsa. * g10/gpg.c: Contingent on configure option: adjust secmem size, add gpg --enable-large-rsa, bound to opt.flags.large_rsa. * g10/keygen.c: Adjust max RSA size based on opt.flags.large_rsa * doc/gpg.texi: Document --enable-large-rsa. -- Some older implementations built and used RSA keys up to 16Kib, but the larger secret keys now fail when used by more recent GnuPG, due to secure memory limitations. Building with ./configure --enable-large-secmem will make gpg capable of working with those secret keys, as well as permitting the use of a new gpg option --enable-large-rsa, which let gpg generate RSA keys up to 8Kib when used with --batch --gen-key. Debian-bug-id: 739424 Minor edits by wk. GnuPG-bug-id: 1732
This commit is contained in:
parent
2889a70c10
commit
534e2876ac
5 changed files with 50 additions and 3 deletions
22
g10/gpg.c
22
g10/gpg.c
|
@ -372,6 +372,8 @@ enum cmd_and_opt_values
|
|||
oAutoKeyLocate,
|
||||
oNoAutoKeyLocate,
|
||||
oAllowMultisigVerification,
|
||||
oEnableLargeRSA,
|
||||
oDisableLargeRSA,
|
||||
oEnableDSA2,
|
||||
oDisableDSA2,
|
||||
oAllowMultipleMessages,
|
||||
|
@ -719,6 +721,8 @@ static ARGPARSE_OPTS opts[] = {
|
|||
{ oDebugCCIDDriver, "debug-ccid-driver", 0, "@"},
|
||||
#endif
|
||||
{ oAllowMultisigVerification, "allow-multisig-verification", 0, "@"},
|
||||
{ oEnableLargeRSA, "enable-large-rsa", 0, "@"},
|
||||
{ oDisableLargeRSA, "disable-large-rsa", 0, "@"},
|
||||
{ oEnableDSA2, "enable-dsa2", 0, "@"},
|
||||
{ oDisableDSA2, "disable-dsa2", 0, "@"},
|
||||
{ oAllowMultipleMessages, "allow-multiple-messages", 0, "@"},
|
||||
|
@ -1995,7 +1999,7 @@ main (int argc, char **argv )
|
|||
}
|
||||
#endif
|
||||
/* initialize the secure memory. */
|
||||
got_secmem=secmem_init( 32768 );
|
||||
got_secmem=secmem_init( SECMEM_BUFFER_SIZE );
|
||||
maybe_setuid = 0;
|
||||
/* Okay, we are now working under our real uid */
|
||||
|
||||
|
@ -2851,6 +2855,22 @@ main (int argc, char **argv )
|
|||
release_akl();
|
||||
break;
|
||||
|
||||
case oEnableLargeRSA:
|
||||
#if SECMEM_BUFFER_SIZE >= 65536
|
||||
opt.flags.large_rsa=1;
|
||||
#else
|
||||
if (configname)
|
||||
log_info("%s:%d: WARNING: gpg not built with large secure "
|
||||
"memory buffer. Ignoring enable-large-rsa\n",
|
||||
configname,configlineno);
|
||||
else
|
||||
log_info("WARNING: gpg not built with large secure "
|
||||
"memory buffer. Ignoring --enable-large-rsa\n");
|
||||
#endif /* SECMEM_BUFFER_SIZE >= 65536 */
|
||||
break;
|
||||
case oDisableLargeRSA: opt.flags.large_rsa=0;
|
||||
break;
|
||||
|
||||
case oEnableDSA2: opt.flags.dsa2=1; break;
|
||||
case oDisableDSA2: opt.flags.dsa2=0; break;
|
||||
|
||||
|
|
|
@ -1253,6 +1253,7 @@ gen_rsa(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
|||
PKT_public_key *pk;
|
||||
MPI skey[6];
|
||||
MPI *factors;
|
||||
const unsigned maxsize = (opt.flags.large_rsa ? 8192 : 4096);
|
||||
|
||||
assert( is_RSA(algo) );
|
||||
|
||||
|
@ -1260,8 +1261,8 @@ gen_rsa(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
|
|||
nbits = 2048;
|
||||
log_info(_("keysize invalid; using %u bits\n"), nbits );
|
||||
}
|
||||
else if (nbits > 4096) {
|
||||
nbits = 4096;
|
||||
else if (nbits > maxsize) {
|
||||
nbits = maxsize;
|
||||
log_info(_("keysize invalid; using %u bits\n"), nbits );
|
||||
}
|
||||
|
||||
|
|
|
@ -231,6 +231,7 @@ struct
|
|||
unsigned int utf8_filename:1;
|
||||
unsigned int dsa2:1;
|
||||
unsigned int allow_multiple_messages:1;
|
||||
unsigned int large_rsa:1;
|
||||
} flags;
|
||||
|
||||
/* Linked list of ways to find a key if the key isn't on the local
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue