Extend the test of BN_GF2m_mod_inv
authorMatt Caswell <matt@openssl.org>
Wed, 6 Dec 2023 11:19:24 +0000 (11:19 +0000)
committerMatt Caswell <matt@openssl.org>
Tue, 12 Dec 2023 16:08:59 +0000 (16:08 +0000)
Test that input value of 1 for p is treated as an error

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/22960)

test/bntest.c

index 2ffff10ef1c29f20c365df3bbd3a5ec86eea0939..20020cac42feea60972e466f8b71f56a16734d08 100644 (file)
@@ -910,6 +910,14 @@ static int test_gf2m_modinv(void)
             || !TEST_ptr(d = BN_new()))
         goto err;
 
+    /* Test that a non-sensical, too small value causes a failure */
+    if (!TEST_true(BN_one(b[0])))
+        goto err;
+    if (!TEST_true(BN_bntest_rand(a, 512, 0, 0)))
+        goto err;
+    if (!TEST_false(BN_GF2m_mod_inv(c, a, b[0], ctx)))
+        goto err;
+
     if (!(TEST_true(BN_GF2m_arr2poly(p0, b[0]))
             && TEST_true(BN_GF2m_arr2poly(p1, b[1]))))
         goto err;