From: Pauli Date: Thu, 26 Jun 2025 08:36:37 +0000 (+1000) Subject: lms: add signing negative test X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dff36957a42593f51a1af2be8be4fcb5126c7060;p=thirdparty%2Fopenssl.git lms: add signing negative test Reviewed-by: Viktor Dukhovni Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/27885) --- diff --git a/test/lms_test.c b/test/lms_test.c index 430363c4ec6..6294f71d5f4 100644 --- a/test/lms_test.c +++ b/test/lms_test.c @@ -296,6 +296,28 @@ static int lms_digest_verify_fail_test(void) return ret; } +static int lms_signing_fail_test(void) +{ + int ret = 0; + LMS_ACVP_TEST_DATA *td = &lms_testdata[0]; + EVP_PKEY *pub = NULL; + EVP_MD_CTX *vctx = NULL; + + if (!TEST_ptr(pub = lms_pubkey_from_data(td->pub, td->publen))) + return 0; + if (!TEST_ptr(vctx = EVP_MD_CTX_new())) + goto err; + /* Only one shot mode is supported, streaming fails to initialise */ + if (!TEST_int_eq(EVP_DigestSignInit_ex(vctx, NULL, NULL, libctx, NULL, + pub, NULL), 0)) + goto err; + ret = 1; + err: + EVP_PKEY_free(pub); + EVP_MD_CTX_free(vctx); + return ret; +} + static int lms_verify_fail_test(void) { int ret = 0; @@ -519,6 +541,7 @@ int setup_tests(void) ADD_ALL_TESTS(lms_verify_test, OSSL_NELEM(lms_testdata)); ADD_TEST(lms_verify_fail_test); ADD_TEST(lms_digest_verify_fail_test); + ADD_TEST(lms_signing_fail_test); ADD_TEST(lms_verify_bad_sig_test); ADD_TEST(lms_verify_bad_sig_len_test); ADD_TEST(lms_verify_bad_pub_sig_test);