diff options
author | Werner Koch <[email protected]> | 2014-06-25 18:25:28 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2014-06-30 17:40:58 +0000 |
commit | aae7ec516b79e20938c56fd48fc0bc9d2116426c (patch) | |
tree | 77b1d8049c07c1f66c43653d363efc4d0ba62028 | |
parent | Make screening of keyserver result work with multi-key commands. (diff) | |
download | gnupg-aae7ec516b79e20938c56fd48fc0bc9d2116426c.tar.gz gnupg-aae7ec516b79e20938c56fd48fc0bc9d2116426c.zip |
Limit keysize for unattended key generation to useful values.
* g10/keygen.c (gen_elg): Enforce keysize 1024 to 4096.
(gen_rsa): Enforce keysize 1024 to 4096.
(gen_dsa): Enforce keysize 768 to 3072.
--
It was possible to create 16k RSA keys in batch mode. In addition to
the silliness of such keys, they have the major drawback that GnuPG,
with its limited amount of specially secured memory areas, the use of
such keys may lead to an "out of secure memory" condition.
-rw-r--r-- | g10/keygen.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/g10/keygen.c b/g10/keygen.c index b84dd0b30..84f852f3f 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -1039,10 +1039,14 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, assert( is_ELGAMAL(algo) ); - if( nbits < 512 ) { + if (nbits < 1024) { nbits = 2048; log_info(_("keysize invalid; using %u bits\n"), nbits ); } + else if (nbits > 4096) { + nbits = 4096; + log_info(_("keysize invalid; using %u bits\n"), nbits ); + } if( (nbits % 32) ) { nbits = ((nbits + 31) / 32) * 32; @@ -1121,7 +1125,7 @@ gen_dsa(unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, MPI *factors; unsigned int qbits; - if( nbits < 512) + if( nbits < 768) { nbits = 2048; log_info(_("keysize invalid; using %u bits\n"), nbits ); @@ -1256,6 +1260,10 @@ 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; + log_info(_("keysize invalid; using %u bits\n"), nbits ); + } if( (nbits % 32) ) { nbits = ((nbits + 31) / 32) * 32; |