summaryrefslogtreecommitdiffstats
path: root/test/bntest.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2022-02-28 18:26:35 +0100
committerMatt Caswell <matt@openssl.org>2022-03-15 13:15:12 +0000
commit3469282ed2faee747868150089e07a187891b5ee (patch)
tree25a481aa40776ed87f986fe1c34970f831ef0725 /test/bntest.c
parent03eccd2663e36f8b95ba3ae8c30a63313a38ec0a (diff)
Add a negative testcase for BN_mod_sqrt
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'test/bntest.c')
-rw-r--r--test/bntest.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/bntest.c b/test/bntest.c
index f129c71ab8..62ca2838c7 100644
--- a/test/bntest.c
+++ b/test/bntest.c
@@ -1732,8 +1732,17 @@ static int file_modsqrt(STANZA *s)
|| !TEST_ptr(ret2 = BN_new()))
goto err;
+ if (BN_is_negative(mod_sqrt)) {
+ /* A negative testcase */
+ if (!TEST_ptr_null(BN_mod_sqrt(ret, a, p, ctx)))
+ goto err;
+
+ st = 1;
+ goto err;
+ }
+
/* There are two possible answers. */
- if (!TEST_true(BN_mod_sqrt(ret, a, p, ctx))
+ if (!TEST_ptr(BN_mod_sqrt(ret, a, p, ctx))
|| !TEST_true(BN_sub(ret2, p, ret)))
goto err;