diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-03-29 11:27:29 +0200 |
---|---|---|
committer | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-03-31 16:31:37 +0200 |
commit | f91e026e38321d0c154f535ecd5af09e424e7f1b (patch) | |
tree | ed584cd2e045eb272f1ffba120c22eaab993dc52 /test/bntest.c | |
parent | Revert commit 4a56d9a2 (diff) | |
download | openssl-f91e026e38321d0c154f535ecd5af09e424e7f1b.tar.xz openssl-f91e026e38321d0c154f535ecd5af09e424e7f1b.zip |
Fix a possible crash in BN_from_montgomery_word
Thanks to Darovskikh Andrei for for reporting this issue.
Fixes: #5785
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5793)
Diffstat (limited to 'test/bntest.c')
-rw-r--r-- | test/bntest.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/bntest.c b/test/bntest.c index d6696e672e..d5b5e0494e 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -408,9 +408,21 @@ static int test_modexp_mont5(void) BN_free(b); b = BN_dup(a); BN_MONT_CTX_set(mont, n, ctx); - BN_mod_mul_montgomery(c, a, a, mont, ctx); - BN_mod_mul_montgomery(d, a, b, mont, ctx); - if (!TEST_BN_eq(c, d)) + if (!TEST_true(BN_mod_mul_montgomery(c, a, a, mont, ctx)) + || !TEST_true(BN_mod_mul_montgomery(d, a, b, mont, ctx)) + || !TEST_BN_eq(c, d)) + goto err; + + /* Regression test for bug in BN_from_montgomery_word */ + BN_hex2bn(&a, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); + BN_hex2bn(&n, + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); + BN_MONT_CTX_set(mont, n, ctx); + if (!TEST_false(BN_mod_mul_montgomery(d, a, a, mont, ctx))) goto err; /* Regression test for bug in rsaz_1024_mul_avx2 */ |