aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2014-06-25 18:25:28 +0000
committerWerner Koch <[email protected]>2014-06-27 07:50:54 +0000
commit48d92bcc8870f5750fb66351f3623f9d874d08fa (patch)
tree83e1581cef8735137e43fea85429b17641c19aa8
parentagent: Let gpg-protect-tool pass envvars to pinentry. (diff)
downloadgnupg-48d92bcc8870f5750fb66351f3623f9d874d08fa.tar.gz
gnupg-48d92bcc8870f5750fb66351f3623f9d874d08fa.zip
gpg: 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 under GnuPG and Libgcrypt, with their 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.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/g10/keygen.c b/g10/keygen.c
index a786beb08..6d3dfa69b 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -1170,11 +1170,16 @@ gen_elg (int algo, unsigned int nbits,
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))
{
@@ -1281,7 +1286,7 @@ gen_dsa (unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
gcry_sexp_t misc_key_info;
unsigned int qbits;
- if ( nbits < 512)
+ if (nbits < 768)
{
nbits = 2048;
log_info(_("keysize invalid; using %u bits\n"), nbits );
@@ -1437,6 +1442,11 @@ 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))
{