]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add mfail test for ossl_ffc_params_copy
authorJakub Zelenka <jakub.zelenka@openssl.foundation>
Wed, 6 May 2026 16:25:20 +0000 (18:25 +0200)
committerEugene Syromiatnikov <esyr@openssl.org>
Mon, 11 May 2026 07:21:44 +0000 (09:21 +0200)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Mon May 11 07:21:47 2026
(Merged from https://github.com/openssl/openssl/pull/31098)

test/ffc_internal_test.c

index 4743279e4c4e09773366717c97b6337c9069e71b..499a889978c3b6d391681cefeeaffa48db444987 100644 (file)
@@ -690,6 +690,47 @@ err:
     DH_free(dh);
     return ret;
 }
+
+static int ffc_params_copy_mfail(void)
+{
+    int ret = 0;
+    FFC_PARAMS params, copy;
+    BIGNUM *p = NULL, *q = NULL, *g = NULL;
+
+    ossl_ffc_params_init(&params);
+    ossl_ffc_params_init(&copy);
+
+    if (!TEST_ptr(p = BN_bin2bn(dsa_2048_224_sha256_p,
+                      sizeof(dsa_2048_224_sha256_p), NULL))
+        || !TEST_ptr(q = BN_bin2bn(dsa_2048_224_sha256_q,
+                         sizeof(dsa_2048_224_sha256_q), NULL))
+        || !TEST_ptr(g = BN_bin2bn(dsa_2048_224_sha256_g,
+                         sizeof(dsa_2048_224_sha256_g), NULL)))
+        goto err;
+
+    ossl_ffc_params_set0_pqg(&params, p, q, g);
+    p = q = g = NULL;
+    if (!TEST_true(ossl_ffc_params_set_seed(&params, dsa_2048_224_sha224_seed,
+            sizeof(dsa_2048_224_sha224_seed))))
+        goto err;
+
+    MFAIL_start();
+    ret = ossl_ffc_params_copy(&copy, &params);
+    MFAIL_end();
+
+    if (!ret)
+        goto err;
+
+    ret = 1;
+err:
+    ossl_ffc_params_cleanup(&params);
+    if (ret)
+        ossl_ffc_params_cleanup(&copy);
+    BN_free(p);
+    BN_free(q);
+    BN_free(g);
+    return ret;
+}
 #endif /* OPENSSL_NO_DH */
 
 int setup_tests(void)
@@ -706,6 +747,7 @@ int setup_tests(void)
     ADD_TEST(ffc_private_validate_test);
     ADD_ALL_TESTS(ffc_private_gen_test, 10);
     ADD_TEST(ffc_params_copy_test);
+    ADD_MFAIL_TEST(ffc_params_copy_mfail);
 #endif /* OPENSSL_NO_DH */
     return 1;
 }