From 7e231879d1f6704b1f8afc880bf71a9aa8b8b871 Mon Sep 17 00:00:00 2001 From: Norman Ashley Date: Thu, 25 Jan 2024 01:52:57 -0500 Subject: [PATCH] Update example_sig_stfl.c Fixed compile error, unused function. Added a negative test when stateful signature is disabled. --- tests/example_sig_stfl.c | 41 ++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/tests/example_sig_stfl.c b/tests/example_sig_stfl.c index 74ff1004c4..cdcd9f6472 100644 --- a/tests/example_sig_stfl.c +++ b/tests/example_sig_stfl.c @@ -122,26 +122,43 @@ static OQS_STATUS stfl_example(char *method_name) { int main(void) { #ifndef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN + OQS_init(); printf("Stateful signature algorithms key and signature generation is not enabled.\n"); - return EXIT_SUCCESS; + if (stfl_example((char *)"XMSS-SHA2_10_256") == OQS_ERROR && stfl_example((char *)"LMS_SHA256_H10_W4") == OQS_ERROR) { + OQS_destroy(); + return EXIT_SUCCESS; + } else { + OQS_destroy(); + return EXIT_FAILURE; + } #else + OQS_STATUS lms_status; + OQS_STATUS xmss_status; OQS_init(); -# if defined(OQS_ALLOW_XMSS_KEY_AND_SIG_GEN) && defined(OQS_ALLOW_LMS_KEY_AND_SIG_GEN) - if (stfl_example((char *)"XMSS-SHA2_10_256") == OQS_SUCCESS && stfl_example((char *)"LMS_SHA256_H10_W4") == OQS_SUCCESS) { -# elif defined(OQS_ALLOW_XMSS_KEY_AND_SIG_GEN) - OQS_init(); - if (stfl_example((char *)"XMSS-SHA2_10_256") == OQS_SUCCESS) { -# elif defined(OQS_ALLOW_LMS_KEY_AND_SIG_GEN) - if ( stfl_example((char *)"LMS_SHA256_H10_W4") == OQS_SUCCESS) { -# else - if ( stfl_example((char *)"") == OQS_SUCCESS) { + xmss_status = stfl_example((char *)"XMSS-SHA2_10_256"); + lms_status = stfl_example((char *)"LMS_SHA256_H10_W4"); + OQS_destroy(); + +#ifndef OQS_ALLOW_XMSS_KEY_AND_SIG_GEN + if (xmss_status == OQS_ERROR) { + xmss_status = OQS_SUCCESS; + } else { + xmss_status = OQS_ERROR; + } #endif - OQS_destroy(); +#ifndef OQS_ALLOW_LMS_KEY_AND_SIG_GEN + if (lms_status == OQS_ERROR) { + lms_status = OQS_SUCCESS; + } else { + lms_status = OQS_ERROR; + } +#endif + if ((xmss_status == OQS_SUCCESS) && (lms_status == OQS_SUCCESS)) { return EXIT_SUCCESS; } else { - OQS_destroy(); return EXIT_FAILURE; } #endif } +