summaryrefslogtreecommitdiffstats
path: root/test/recipes/15-test_genrsa.t
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2021-05-25 13:31:44 +1000
committerPauli <pauli@openssl.org>2021-05-26 17:57:37 +1000
commit1ee04b791b396385cce2a0c46c112158b2005293 (patch)
tree2e3fd6cd9122d3a96c2971e7ad05b17de5d3891f /test/recipes/15-test_genrsa.t
parent0221b080cefa7358c0a0737d089caeec2979f930 (diff)
Fix buffer overflow when generating large RSA keys in FIPS mode.
A pairwise test runs only in FIPS mode. An assumption about the size of the 'to' buffer passed to RSA_private_decrypt() was incorrect. It needs to be up to RSA_size() bytes long - so a fixed buffer of 256 bytes was not large enough. An exiting malloc has increased in size to allocate buffer space for both the encrypt and decrypt buffer. The existing test used 2080 bits which was not quite large enough to trigger the issue. A test using 3072 bits has been added. Reported by Mark Powers from Acumen. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15447)
Diffstat (limited to 'test/recipes/15-test_genrsa.t')
-rw-r--r--test/recipes/15-test_genrsa.t8
1 files changed, 7 insertions, 1 deletions
diff --git a/test/recipes/15-test_genrsa.t b/test/recipes/15-test_genrsa.t
index 95390c5ff4..501d3a100f 100644
--- a/test/recipes/15-test_genrsa.t
+++ b/test/recipes/15-test_genrsa.t
@@ -24,7 +24,7 @@ use lib bldtop_dir('.');
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
plan tests =>
- ($no_fips ? 0 : 1) # Extra FIPS related test
+ ($no_fips ? 0 : 2) # Extra FIPS related test
+ 13;
# We want to know that an absurdly small number of bits isn't support
@@ -131,4 +131,10 @@ unless ($no_fips) {
'-pkeyopt', 'bits:2080',
'-out', 'genrsatest2080.pem'])),
"Generating RSA key with > 2048 bits and < 3072 bits");
+ ok(run(app(['openssl', 'genpkey',
+ @prov,
+ '-algorithm', 'RSA',
+ '-pkeyopt', 'bits:3072',
+ '-out', 'genrsatest3072.pem'])),
+ "Generating RSA key with 3072 bits");
}