Add mfail test for ossl_ffc_params_copy

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)
This commit is contained in:
Jakub Zelenka 2026-05-06 18:25:20 +02:00 committed by Eugene Syromiatnikov
parent a887f93cc7
commit df53ee4fa0

View 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;
}