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:39:27 +0000
commit3ef5c3034e5c545f34d6929568f3f2b10ac4bdf0 (patch)
tree3241bf49066f16e34aa57d31237c702d51c0d6b4 /test/bntest.c
parentb5fcb7e133725b8b2eb66f63f5142710ed63a6d1 (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 390dd80073..1cab660bca 100644
--- a/test/bntest.c
+++ b/test/bntest.c
@@ -1729,8 +1729,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;