Skip to content

Commit

Permalink
Update example_sig_stfl.c
Browse files Browse the repository at this point in the history
Fixed compile error, unused function.
Added a negative test when stateful signature is disabled.
  • Loading branch information
ashman-p authored Jan 25, 2024
1 parent deff896 commit 7e23187
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions tests/example_sig_stfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


0 comments on commit 7e23187

Please sign in to comment.