diff --git a/src/sig_stfl/lms/sig_stfl_lms.c b/src/sig_stfl/lms/sig_stfl_lms.c index e6c30e66d5..3503c7447b 100644 --- a/src/sig_stfl/lms/sig_stfl_lms.c +++ b/src/sig_stfl/lms/sig_stfl_lms.c @@ -22,7 +22,7 @@ OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w1_keypair(uint8_t *public_key return OQS_ERROR; } - if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)0x00000001) != 0) { + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h5_w1) != 0) { return OQS_ERROR; } return OQS_SUCCESS; @@ -36,7 +36,7 @@ OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w1_new(void) { } memset(sig, 0, sizeof(OQS_SIG_STFL)); - sig->oid = 0x00000001; + sig->oid = OQS_LMS_ID_sha256_n32_h5_w1; sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1; sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; sig->euf_cma = true; @@ -67,11 +67,1658 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W1_new(void) { // Initialize the key with length_secret_key amount of bytes. sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h5_w1_length_sk; - /* Function that returns the total number of signatures for the secret key */ - sk->sigs_total = NULL; + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H5/W2 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h5_w2) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w2_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h5_w2; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h5_w2_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h5_w2_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h5_w2_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h5_w2_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W2_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h5_w2_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H5/W4 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h5_w4) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w4_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h5_w4; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h5_w4_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h5_w4_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h5_w4_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h5_w4_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W4_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h5_w4_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H5/W8 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h5_w8) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w8_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h5_w8; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h5_w8_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h5_w8_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h5_w8_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h5_w8_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W8_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h5_w8_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H10/W1 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h10_w1) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w1_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h10_w1; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h10_w1_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w1_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h10_w1_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w1_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W1_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h10_w1_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H10/W2 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h10_w2) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w2_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h10_w2; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h10_w2; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h10_w2_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w2_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h10_w2_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w2_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W2_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h10_w2_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H10/W4 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h10_w4) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w4_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h10_w4; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h10_w4; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h10_w4_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w4_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h10_w4_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w4_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W4_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h10_w4_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H10/W8 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h10_w8) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w8_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h10_w8; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h10_w8; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h10_w8_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w8_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h10_w8_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w8_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W8_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h10_w8_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H15/W1 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h15_w1) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w1_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h15_w1; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h15_w1_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h15_w1_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w1_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h15_w1_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W1_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w1_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H15/W2 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h15_w2) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w2_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h15_w2; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h15_w2; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h15_w2_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h15_w2_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w2_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h15_w2_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W2_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w2_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H15/W4 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h15_w4) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w4_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h15_w4; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h15_w4; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h15_w4_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h15_w4_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w4_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h15_w4_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W4_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w4_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H15/W8 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h15_w8) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w8_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h15_w8; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h15_w8; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h15_w8_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h15_w8_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w8_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h15_w8_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W8_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w8_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H20/W1 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h20_w1) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w1_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h20_w1; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h20_w1; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h20_w1_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h20_w1_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h20_w1_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h20_w1_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W1_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h20_w1_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H20/W2 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h20_w2) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w2_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h20_w2; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h20_w2; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h20_w2_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h20_w2_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h20_w2_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h20_w2_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W2_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h20_w2_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H20/W4 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h20_w4) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w4_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h20_w4; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h20_w4; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h20_w4_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h20_w4_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h20_w4_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h20_w4_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W4_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h20_w4_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H20/W8 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h20_w8) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h20_w8; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h20_w8; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h20_w8_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h20_w8_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h20_w8_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h20_w8_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W8_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h20_w8_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H25/W1 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h25_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h25_w1) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h25_w1_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h25_w1; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h25_w1; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h25_w1_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h25_w1_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h25_w1_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h25_w1_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H25_W1_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h25_w1_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H25/W2 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h25_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h25_w2) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h25_w2_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h25_w2; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h25_w2; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h25_w2_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h25_w2_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h25_w2_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h25_w2_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H25_W2_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h25_w2_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; + + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H25/W4 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h25_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h25_w4) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h25_w4_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h25_w4; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h25_w4; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h25_w4_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h25_w4_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h25_w4_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h25_w4_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H25_W4_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h25_w4_length_sk; + + /* + * Secret Key retrieval Function + */ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; + + /* + * set Secret Key to internal structure Function + */ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; - /* set Function to returns the number of signatures left for the secret key */ - sk->sigs_left = NULL; + /* + * Set Secret Key Locking Function + */ + sk->lock_key = NULL; + + /* + * Set Secret Key Unlocking / Releasing Function + */ + sk->unlock_key = NULL; + + /* + * Set Secret Key Saving Function + */ + sk->secure_store_scrt_key = NULL; + + /* + * Set Secret Key free function + */ + sk->free_key = OQS_SECRET_KEY_LMS_free; + + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; + + return sk; +} + +// ======================== LMS-SHA256 H25/W8 ======================== // + +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h25_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { + if (secret_key == NULL || public_key == NULL) { + return OQS_ERROR; + } + + if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_n32_h25_w8) != 0) { + return OQS_ERROR; + } + return OQS_SUCCESS; +} + +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h25_w8_new(void) { + + OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); + if (sig == NULL) { + return NULL; + } + memset(sig, 0, sizeof(OQS_SIG_STFL)); + + sig->oid = OQS_LMS_ID_sha256_n32_h25_w8; + sig->method_name = OQS_SIG_STFL_alg_lms_sha256_n32_h25_w8; + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; + sig->euf_cma = true; + + sig->length_public_key = OQS_SIG_STFL_alg_lms_sha256_h25_w8_length_pk; + sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h25_w8_length_signature; + sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h25_w8_length_sk; + + sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h25_w8_keypair; + sig->sign = OQS_SIG_STFL_alg_lms_sign; + sig->verify = OQS_SIG_STFL_alg_lms_verify; + + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; + + return sig; +} + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H25_W8_new(void) { + + // Initialize the secret key in the heap with adequate memory + OQS_SIG_STFL_SECRET_KEY *sk = malloc(sizeof(OQS_SIG_STFL_SECRET_KEY)); + if (sk == NULL) { + return NULL; + } + memset(sk, 0, sizeof(OQS_SIG_STFL_SECRET_KEY)); + + // Initialize the key with length_secret_key amount of bytes. + sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h25_w8_length_sk; /* * Secret Key retrieval Function diff --git a/src/sig_stfl/lms/sig_stfl_lms.h b/src/sig_stfl/lms/sig_stfl_lms.h index 75ce739238..e42450fd15 100644 --- a/src/sig_stfl/lms/sig_stfl_lms.h +++ b/src/sig_stfl/lms/sig_stfl_lms.h @@ -5,16 +5,193 @@ #include +//OQS LMS parameter identifiers +/* Defined LM parameter sets */ +#define OQS_LMS_ID_sha256_n32_h5_w1 0x1 //"5/1" +#define OQS_LMS_ID_sha256_n32_h5_w2 0x2 //"5/2" +#define OQS_LMS_ID_sha256_n32_h5_w4 0x3 //"5/4" +#define OQS_LMS_ID_sha256_n32_h5_w8 0x4 //"5/8" + +#define OQS_LMS_ID_sha256_n32_h10_w1 0x5 //"10/1" +#define OQS_LMS_ID_sha256_n32_h10_w2 0x7 //"10/2" +#define OQS_LMS_ID_sha256_n32_h10_w4 0x8 //"10/4" +#define OQS_LMS_ID_sha256_n32_h10_w8 0x9 //"10/8" + +#define OQS_LMS_ID_sha256_n32_h15_w1 0xa //"15/1" +#define OQS_LMS_ID_sha256_n32_h15_w2 0xb //"15/2" +#define OQS_LMS_ID_sha256_n32_h15_w4 0xc//"15/4" +#define OQS_LMS_ID_sha256_n32_h15_w8 0xd //"15/8" + +#define OQS_LMS_ID_sha256_n32_h20_w1 0xe //"20/1" +#define OQS_LMS_ID_sha256_n32_h20_w2 0xf //"20/2" +#define OQS_LMS_ID_sha256_n32_h20_w4 0x10 //"20/4" +#define OQS_LMS_ID_sha256_n32_h20_w8 0x11 //"20/8" + +#define OQS_LMS_ID_sha256_n32_h25_w1 0x12 //"25/1" +#define OQS_LMS_ID_sha256_n32_h25_w2 0x13 //"25/2" +#define OQS_LMS_ID_sha256_n32_h25_w4 0x14 //"25/4" +#define OQS_LMS_ID_sha256_n32_h25_w8 0x15 //"25/8" + //H5 #define OQS_SIG_STFL_alg_lms_sha256_h5_w1_length_signature 8688 #define OQS_SIG_STFL_alg_lms_sha256_h5_w1_length_pk 60 #define OQS_SIG_STFL_alg_lms_sha256_h5_w1_length_sk 64 - +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w1_new(void); +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W1_new(void); OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W1_new(void); +#define OQS_SIG_STFL_alg_lms_sha256_h5_w2_length_signature 4464 +#define OQS_SIG_STFL_alg_lms_sha256_h5_w2_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h5_w2_length_sk 64 +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w2_new(void); +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W2_new(void); +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + +#define OQS_SIG_STFL_alg_lms_sha256_h5_w4_length_signature 2352 +#define OQS_SIG_STFL_alg_lms_sha256_h5_w4_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h5_w4_length_sk 64 +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w4_new(void); +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W4_new(void); +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + +#define OQS_SIG_STFL_alg_lms_sha256_h5_w8_length_signature 1296 +#define OQS_SIG_STFL_alg_lms_sha256_h5_w8_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h5_w8_length_sk 64 +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w8_new(void); +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W8_new(void); +OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + +//H10 +// H10 W1 60 8848 64 +// H10 W2 60 4624 64 +// H10 W4 60 2512 64 +// H10 W8 60 1456 64 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w1_length_signature 8848 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w1_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w1_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W1_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w1_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h10_w2_length_signature 4624 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w2_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w2_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W2_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w2_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h10_w4_length_signature 2512 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w4_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w4_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W4_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w4_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h10_w8_length_signature 1456 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w8_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h10_w8_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W8_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w8_new(void); + +//H15 +// H15 W1 60 9008 64 +// H15 W2 60 4784 64 +// H15 W4 60 2672 64 +// H15 W8 60 1616 64 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w1_length_signature 9008 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w1_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w1_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W1_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w1_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h15_w2_length_signature 4784 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w2_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w2_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W2_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w2_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h15_w4_length_signature 2672 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w4_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w4_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W4_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w4_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h15_w8_length_signature 1616 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w8_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h15_w8_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W8_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w8_new(void); + +//H20 +// H20 W1 60 9168 64 +// H20 W2 60 4944 64 +// H20 W4 60 2832 64 +// H20 W8 60 1776 64 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w1_length_signature 9168 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w1_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w1_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W1_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w1_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h20_w2_length_signature 4944 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w2_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w2_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W2_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w2_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h20_w4_length_signature 2832 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w4_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w4_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W4_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w4_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h20_w8_length_signature 1776 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w8_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h20_w8_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W8_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_new(void); + +//H25 +// H25 W1 60 9328 64 +// H25 W2 60 5104 64 +// H25 W4 60 2992 64 +// H25 W8 60 1936 64 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w1_length_signature 9328 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w1_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w1_length_sk 64 -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w1_new(void); +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H25_W1_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h25_w1_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h25_w2_length_signature 5104 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w2_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w2_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H25_W2_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h25_w2_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h25_w4_length_signature 2992 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w4_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w4_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H25_W4_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h25_w4_new(void); + +#define OQS_SIG_STFL_alg_lms_sha256_h25_w8_length_signature 1936 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w8_length_pk 60 +#define OQS_SIG_STFL_alg_lms_sha256_h25_w8_length_sk 64 + +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H25_W8_new(void); +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h25_w8_new(void); OQS_API OQS_STATUS OQS_SIG_STFL_lms_sigs_left(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_STATUS OQS_SIG_STFL_lms_sigs_total(unsigned long long *totaln, const OQS_SIG_STFL_SECRET_KEY *secret_key); diff --git a/src/sig_stfl/lms/sig_stfl_lms_functions.c b/src/sig_stfl/lms/sig_stfl_lms_functions.c index 018b04b21e..f18d8c445b 100644 --- a/src/sig_stfl/lms/sig_stfl_lms_functions.c +++ b/src/sig_stfl/lms/sig_stfl_lms_functions.c @@ -183,7 +183,6 @@ OQS_API OQS_STATUS OQS_SIG_STFL_lms_sigs_total(unsigned long long *total, const oqs_lms_key_data *oqs_key_data = NULL; struct hss_working_key *working_key = NULL; - if (total == NULL || secret_key == NULL) { return OQS_ERROR; } @@ -207,8 +206,6 @@ OQS_API OQS_STATUS OQS_SIG_STFL_lms_sigs_total(unsigned long long *total, const return OQS_ERROR; } - - *total = (unsigned long long)working_key->max_count; OQS_MEM_secure_free(working_key, sizeof(struct hss_working_key)); return OQS_SUCCESS; @@ -280,11 +277,91 @@ int oqs_sig_stfl_lms_keypair(uint8_t *pk, OQS_SIG_STFL_SECRET_KEY *sk, const uin /* Set lms param set */ switch (oid) { - case 0x1: + case OQS_LMS_ID_sha256_n32_h5_w1: oqs_key_data->lm_type[0] = LMS_SHA256_N32_H5; oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W1; break; - default: + case OQS_LMS_ID_sha256_n32_h5_w2: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H5; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W2; + break; + case OQS_LMS_ID_sha256_n32_h5_w4: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H5; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W4; + break; + case OQS_LMS_ID_sha256_n32_h5_w8: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H5; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W8; + break; + + case OQS_LMS_ID_sha256_n32_h10_w1: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H10; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W1; + break; + case OQS_LMS_ID_sha256_n32_h10_w2: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H10; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W2; + break; + case OQS_LMS_ID_sha256_n32_h10_w4: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H10; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W4; + break; + case OQS_LMS_ID_sha256_n32_h10_w8: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H10; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W8; + break; + + case OQS_LMS_ID_sha256_n32_h15_w1: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H15; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W1; + break; + case OQS_LMS_ID_sha256_n32_h15_w2: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H15; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W2; + break; + case OQS_LMS_ID_sha256_n32_h15_w4: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H15; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W4; + break; + case OQS_LMS_ID_sha256_n32_h15_w8: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H15; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W8; + break; + + case OQS_LMS_ID_sha256_n32_h20_w1: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H20; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W1; + break; + case OQS_LMS_ID_sha256_n32_h20_w2: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H20; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W2; + break; + case OQS_LMS_ID_sha256_n32_h20_w4: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H20; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W4; + break; + case OQS_LMS_ID_sha256_n32_h20_w8: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H20; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W8; + break; + + case OQS_LMS_ID_sha256_n32_h25_w1: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H25; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W1; + break; + case OQS_LMS_ID_sha256_n32_h25_w2: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H25; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W2; + break; + case OQS_LMS_ID_sha256_n32_h25_w4: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H25; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W4; + break; + case OQS_LMS_ID_sha256_n32_h25_w8: + oqs_key_data->lm_type[0] = LMS_SHA256_N32_H25; + oqs_key_data->lm_ots_type[0] = LMOTS_SHA256_N32_W8; + break; + oqs_key_data->lm_type[0] = 0; oqs_key_data->lm_ots_type[0] = 0; parse_err = 1; diff --git a/src/sig_stfl/sig_stfl.c b/src/sig_stfl/sig_stfl.c index 023d4e1df3..b434f54715 100644 --- a/src/sig_stfl/sig_stfl.c +++ b/src/sig_stfl/sig_stfl.c @@ -43,6 +43,29 @@ OQS_API const char *OQS_SIG_STFL_alg_identifier(size_t i) { OQS_SIG_STFL_alg_xmssmt_shake128_h60_6, OQS_SIG_STFL_alg_xmssmt_shake128_h60_12, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1, + OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2, + OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4, + OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8, + + OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1, + OQS_SIG_STFL_alg_lms_sha256_n32_h10_w2, + OQS_SIG_STFL_alg_lms_sha256_n32_h10_w4, + OQS_SIG_STFL_alg_lms_sha256_n32_h10_w8, + + OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1, + OQS_SIG_STFL_alg_lms_sha256_n32_h15_w2, + OQS_SIG_STFL_alg_lms_sha256_n32_h15_w4, + OQS_SIG_STFL_alg_lms_sha256_n32_h15_w8, + + OQS_SIG_STFL_alg_lms_sha256_n32_h20_w1, + OQS_SIG_STFL_alg_lms_sha256_n32_h20_w2, + OQS_SIG_STFL_alg_lms_sha256_n32_h20_w4, + OQS_SIG_STFL_alg_lms_sha256_n32_h20_w8, + + OQS_SIG_STFL_alg_lms_sha256_n32_h25_w1, + OQS_SIG_STFL_alg_lms_sha256_n32_h25_w2, + OQS_SIG_STFL_alg_lms_sha256_n32_h25_w4, + OQS_SIG_STFL_alg_lms_sha256_n32_h25_w8, }; if (i >= OQS_SIG_STFL_algs_length) { @@ -52,12 +75,10 @@ OQS_API const char *OQS_SIG_STFL_alg_identifier(size_t i) { } } - OQS_API int OQS_SIG_STFL_alg_count(void) { return OQS_SIG_STFL_algs_length; } - OQS_API int OQS_SIG_STFL_alg_is_enabled(const char *method_name) { assert(method_name != NULL); @@ -231,18 +252,61 @@ OQS_API int OQS_SIG_STFL_alg_is_enabled(const char *method_name) { #else return 0; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1)) { + } #ifdef OQS_ENABLE_SIG_STFL_LMS + else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1)) { return 1; -#else - return 0; -#endif - } else { + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w2)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w4)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w8)) { + return 1; + } + + else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w2)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w4)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w8)) { + return 1; + } + + else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w1)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w2)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w4)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w8)) { + return 1; + } + + else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w1)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w2)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w4)) { + return 1; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w8)) { + return 1; + } +#endif //OQS_ENABLE_SIG_STFL_LMS + else { return 0; } } - OQS_API OQS_SIG_STFL *OQS_SIG_STFL_new(const char *method_name) { assert(method_name != NULL); @@ -416,18 +480,55 @@ OQS_API OQS_SIG_STFL *OQS_SIG_STFL_new(const char *method_name) { #else return NULL; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1)) { + } #ifdef OQS_ENABLE_SIG_STFL_LMS + else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1)) { return OQS_SIG_STFL_alg_lms_sha256_h5_w1_new(); -#else - return NULL; + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2)) { + return OQS_SIG_STFL_alg_lms_sha256_h5_w2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4)) { + return OQS_SIG_STFL_alg_lms_sha256_h5_w4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8)) { + return OQS_SIG_STFL_alg_lms_sha256_h5_w8_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1)) { + return OQS_SIG_STFL_alg_lms_sha256_h10_w1_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w2)) { + return OQS_SIG_STFL_alg_lms_sha256_h10_w2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w4)) { + return OQS_SIG_STFL_alg_lms_sha256_h10_w4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w8)) { + return OQS_SIG_STFL_alg_lms_sha256_h10_w8_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1)) { + return OQS_SIG_STFL_alg_lms_sha256_h15_w1_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w2)) { + return OQS_SIG_STFL_alg_lms_sha256_h15_w2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w4)) { + return OQS_SIG_STFL_alg_lms_sha256_h15_w4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w8)) { + return OQS_SIG_STFL_alg_lms_sha256_h15_w8_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w1)) { + return OQS_SIG_STFL_alg_lms_sha256_h20_w1_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w2)) { + return OQS_SIG_STFL_alg_lms_sha256_h20_w2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w4)) { + return OQS_SIG_STFL_alg_lms_sha256_h20_w4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w8)) { + return OQS_SIG_STFL_alg_lms_sha256_h20_w8_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w1)) { + return OQS_SIG_STFL_alg_lms_sha256_h25_w1_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w2)) { + return OQS_SIG_STFL_alg_lms_sha256_h25_w2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w4)) { + return OQS_SIG_STFL_alg_lms_sha256_h25_w4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w8)) { + return OQS_SIG_STFL_alg_lms_sha256_h25_w8_new(); + } #endif //OQS_ENABLE_SIG_STFL_LMS - } else { + else { return NULL; } } - OQS_API OQS_STATUS OQS_SIG_STFL_keypair(const OQS_SIG_STFL *sig, uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key) { if (sig == NULL || sig->keypair == NULL || sig->keypair(public_key, secret_key) != 0) { return OQS_ERROR; @@ -474,11 +575,8 @@ OQS_API void OQS_SIG_STFL_free(OQS_SIG_STFL *sig) { OQS_MEM_insecure_free(sig); } - - // ================================= OQS_SIG_STFL_SECRET_KEY FUNCTION =============================================== - OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SIG_STFL_SECRET_KEY_new(const char *method_name) { assert(method_name != NULL); @@ -652,13 +750,51 @@ OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SIG_STFL_SECRET_KEY_new(const char *method_ #else return NULL; #endif - } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1)) { + } #ifdef OQS_ENABLE_SIG_STFL_LMS + else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1)) { return OQS_SECRET_KEY_LMS_SHA256_H5_W1_new(); -#else - return NULL; -#endif - } else { + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2)) { + return OQS_SECRET_KEY_LMS_SHA256_H5_W2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4)) { + return OQS_SECRET_KEY_LMS_SHA256_H5_W4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8)) { + return OQS_SECRET_KEY_LMS_SHA256_H5_W8_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1)) { + return OQS_SECRET_KEY_LMS_SHA256_H10_W1_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w2)) { + return OQS_SECRET_KEY_LMS_SHA256_H10_W2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w4)) { + return OQS_SECRET_KEY_LMS_SHA256_H10_W4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w8)) { + return OQS_SECRET_KEY_LMS_SHA256_H10_W8_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1)) { + return OQS_SECRET_KEY_LMS_SHA256_H15_W1_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w2)) { + return OQS_SECRET_KEY_LMS_SHA256_H15_W2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w4)) { + return OQS_SECRET_KEY_LMS_SHA256_H15_W4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w8)) { + return OQS_SECRET_KEY_LMS_SHA256_H15_W8_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w1)) { + return OQS_SECRET_KEY_LMS_SHA256_H20_W1_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w2)) { + return OQS_SECRET_KEY_LMS_SHA256_H20_W2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w4)) { + return OQS_SECRET_KEY_LMS_SHA256_H20_W4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h20_w8)) { + return OQS_SECRET_KEY_LMS_SHA256_H20_W8_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w1)) { + return OQS_SECRET_KEY_LMS_SHA256_H25_W1_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w2)) { + return OQS_SECRET_KEY_LMS_SHA256_H25_W2_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w4)) { + return OQS_SECRET_KEY_LMS_SHA256_H25_W4_new(); + } else if (0 == strcasecmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h25_w8)) { + return OQS_SECRET_KEY_LMS_SHA256_H25_W8_new(); + } +#endif //OQS_ENABLE_SIG_STFL_LMS + else { return NULL; } } @@ -717,8 +853,6 @@ OQS_API OQS_STATUS OQS_SECRET_KEY_STFL_deserialize_key(OQS_SIG_STFL_SECRET_KEY * return sk->deserialize_key(sk, key_len, sk_buf, context); } - - /* OQS_SIG_STFL_SECRET_KEY_SET_lock callback function*/ OQS_API void OQS_SIG_STFL_SECRET_KEY_SET_lock(OQS_SIG_STFL_SECRET_KEY *sk, lock_key lock) { if (sk == NULL) { diff --git a/src/sig_stfl/sig_stfl.h b/src/sig_stfl/sig_stfl.h index a9bffdfdd8..33177e829e 100644 --- a/src/sig_stfl/sig_stfl.h +++ b/src/sig_stfl/sig_stfl.h @@ -38,7 +38,6 @@ * */ - #if defined(__cplusplus) extern "C" { #endif @@ -75,8 +74,31 @@ extern "C" { /* Defined LMS parameter identifiers */ #define OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1 "LMS_SHA256_H5_W1" //"5/1" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2 "LMS_SHA256_H5_W2" //"5/2" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4 "LMS_SHA256_H5_W4" //"5/4" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8 "LMS_SHA256_H5_W8" //"5/8" + +#define OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1 "LMS_SHA256_H10_W1" //"10/1" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h10_w2 "LMS_SHA256_H10_W2" //"10/2" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h10_w4 "LMS_SHA256_H10_W4" //"10/4" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h10_w8 "LMS_SHA256_H10_W8" //"10/8" + +#define OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1 "LMS_SHA256_H15_W1" //"15/1" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h15_w2 "LMS_SHA256_H15_W2" //"15/2" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h15_w4 "LMS_SHA256_H15_W4" //"15/4" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h15_w8 "LMS_SHA256_H15_W8" //"15/8" + +#define OQS_SIG_STFL_alg_lms_sha256_n32_h20_w1 "LMS_SHA256_H20_W1" //"20/1" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h20_w2 "LMS_SHA256_H20_W2" //"20/2" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h20_w4 "LMS_SHA256_H20_W4" //"20/4" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h20_w8 "LMS_SHA256_H20_W8" //"20/8" -#define OQS_SIG_STFL_algs_length 29 +#define OQS_SIG_STFL_alg_lms_sha256_n32_h25_w1 "LMS_SHA256_H25_W1" //"25/1" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h25_w2 "LMS_SHA256_H25_W2" //"25/2" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h25_w4 "LMS_SHA256_H25_W4" //"25/4" +#define OQS_SIG_STFL_alg_lms_sha256_n32_h25_w8 "LMS_SHA256_H25_W8" //"25/8" + +#define OQS_SIG_STFL_algs_length 48 /* Defined LM parameter identifiers */ /* Algorithm identifier for LMS-SHA256_N32_H5 */ @@ -167,7 +189,6 @@ typedef struct OQS_SIG_STFL { /** The (maximum) length, in bytes, of signatures for this signature scheme. */ size_t length_signature; - /** * Keypair generation algorithm. * @@ -247,12 +268,6 @@ typedef struct OQS_SIG_STFL_SECRET_KEY { /* mutual exclusion struct */ void *mutex; - /* Function that returns the total number of signatures for the secret key */ - uint64_t (*sigs_total)(const OQS_SIG_STFL_SECRET_KEY *secret_key); - - /* Function that returns the number of signatures left for the secret key */ - uint64_t (*sigs_left)(const OQS_SIG_STFL_SECRET_KEY *secret_key); - /** * Secret Key retrieval Function * diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h10.c b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h10.c index 83d3c4b275..20a8f87af0 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h10.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h10.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA256_H10_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_sha256_h10_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h16.c b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h16.c index b3f72ef038..d32ad7df05 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h16.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h16.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA256_H16_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_sha256_h16_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h20.c b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h20.c index 660f8c797c..9675fb1151 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h20.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h20.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA256_H20_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_sha256_h20_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h10.c b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h10.c index 735cd012f2..c4589175c6 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h10.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h10.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA512_H10_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_sha512_h10_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h16.c b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h16.c index de64237cb1..bab2bda1f2 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h16.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h16.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA512_H16_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_sha512_h16_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h20.c b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h20.c index 0917020588..5c931a35c4 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h20.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h20.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA512_H20_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_sha512_h20_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h10.c b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h10.c index 708981b3ac..fde4331e66 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h10.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h10.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE128_H10_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_shake128_h10_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h16.c b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h16.c index e6381f0209..d1587260f3 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h16.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h16.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE128_H16_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_shake128_h16_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h20.c b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h20.c index 4b80a0c938..c618ce8260 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h20.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h20.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE128_H20_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_shake128_h20_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h10.c b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h10.c index bdb3243bfc..84e5772280 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h10.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h10.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H10_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_shake256_h10_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h16.c b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h16.c index 7b6b352720..788eb8f1e7 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h16.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h16.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H16_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_shake256_h16_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h20.c b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h20.c index fa6c7cc060..7029f669f8 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h20.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h20.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H20_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmss_shake256_h20_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h20_2.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h20_2.c index 60cb3dd8ad..c4862f728e 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h20_2.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h20_2.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H20_2_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h20_4.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h20_4.c index cd698b3d44..efa097b262 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h20_4.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h20_4.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H20_4_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_2.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_2.c index 4b6d0a9021..04c8fd52fb 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_2.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_2.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H40_2_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_4.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_4.c index c42a6db25f..dfa69325e8 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_4.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_4.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H40_4_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_8.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_8.c index c29b43d2d1..7b4640ed40 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_8.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h40_8.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H40_8_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_12.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_12.c index 7e53563c2d..84f0f589d3 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_12.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_12.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H60_12_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_3.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_3.c index c1ed78f606..c9616932eb 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_3.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_3.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H60_3_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_6.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_6.c index bc644a4223..7ab46f56ad 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_6.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_sha256_h60_6.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H60_6_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h20_2.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h20_2.c index 807eae702d..19421bb2ae 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h20_2.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h20_2.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H20_2_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h20_4.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h20_4.c index 1082dcd999..1b51a87c76 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h20_4.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h20_4.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H20_4_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_2.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_2.c index 01d70f3a37..8e3617fbd0 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_2.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_2.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H40_2_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_4.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_4.c index d5935a5752..9a5f66ccef 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_4.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_4.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H40_4_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_8.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_8.c index 743ff4cb96..9b6fc160ed 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_8.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h40_8.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H40_8_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_12.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_12.c index c571bbe7ea..dfad288f23 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_12.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_12.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H60_12_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_3.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_3.c index 83ed6b0b63..acd7b70165 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_3.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_3.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H60_3_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_6.c b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_6.c index a8c3ed07af..889e831775 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_6.c +++ b/src/sig_stfl/xmss/sig_stfl_xmssmt_shake128_h60_6.c @@ -52,10 +52,6 @@ OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H60_6_new(void) { sk->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_length_sk; - // Assign the sigs_left and sigs_max functions - sk->sigs_left = NULL; - sk->sigs_total = NULL; - // Secret serialize/deserialize function sk->serialize_key = OQS_SECRET_KEY_XMSS_serialize_key; sk->deserialize_key = OQS_SECRET_KEY_XMSS_deserialize_key; diff --git a/tests/test_sig_stfl.c b/tests/test_sig_stfl.c index 2f2b176016..9abd8dbe73 100644 --- a/tests/test_sig_stfl.c +++ b/tests/test_sig_stfl.c @@ -573,10 +573,16 @@ static OQS_STATUS sig_stfl_test_secret_key(const char *method_name) { * Temporarily skip algs with long key generation times. */ - if (strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1) != 0) { - goto skip_test; - } else { + if (strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8) == 0 + + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1) == 0) { goto keep_going; + } else { + goto skip_test; } // if (0) { @@ -715,7 +721,6 @@ static OQS_STATUS sig_stfl_test_secret_key(const char *method_name) { sk->set_scrt_key_store_cb(sk, test_save_secret_key, (void *)context); } - /* read secret key from disk */ frm_file_sk_buf = malloc(to_file_sk_len); if (oqs_fload("sk", method_name, frm_file_sk_buf, to_file_sk_len, &frm_file_sk_len) != OQS_SUCCESS) { @@ -769,10 +774,16 @@ static OQS_STATUS sig_stfl_test_query_key(const char *method_name) { * Temporarily skip algs with long key generation times. */ - if (strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1) != 0) { - goto skip_test; - } else { + if (strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8) == 0 + + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1) == 0) { goto keep_going; + } else { + goto skip_test; } skip_test: @@ -790,7 +801,6 @@ static OQS_STATUS sig_stfl_test_query_key(const char *method_name) { return OQS_ERROR; } - printf("================================================================================\n"); printf("Sig Verify 1 %s\n", method_name); printf("================================================================================\n"); @@ -833,10 +843,16 @@ static OQS_STATUS sig_stfl_test_sig_gen(const char *method_name) { * Temporarily skip algs with long key generation times. */ - if (strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1) != 0) { - goto skip_test; + if (strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8) == 0 + + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1) == 0) { + goto keep_going; } else { - goto keep_going; + goto skip_test; } skip_test: @@ -853,7 +869,6 @@ static OQS_STATUS sig_stfl_test_sig_gen(const char *method_name) { return OQS_ERROR; } - /* * Get max num signature and the amount remaining */ @@ -872,7 +887,6 @@ static OQS_STATUS sig_stfl_test_sig_gen(const char *method_name) { } printf("%s Remaining number of sign operations = %llu\n", method_name, num_sig_left); - printf("================================================================================\n"); printf("Sig Gen 1 %s\n", method_name); printf("================================================================================\n"); @@ -947,7 +961,6 @@ static OQS_STATUS sig_stfl_test_sig_gen(const char *method_name) { return rc; } - static OQS_STATUS sig_stfl_test_secret_key_lock(const char *method_name) { OQS_STATUS rc = OQS_SUCCESS; @@ -955,10 +968,16 @@ static OQS_STATUS sig_stfl_test_secret_key_lock(const char *method_name) { * Temporarily skip algs with long key generation times. */ - if (strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1) != 0) { - goto skip_test; - } else { + if (strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w1) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w2) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w4) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h5_w8) == 0 + + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h10_w1) == 0 + || strcmp(method_name, OQS_SIG_STFL_alg_lms_sha256_n32_h15_w1) == 0) { goto keep_going; + } else { + goto skip_test; } skip_test: @@ -1020,8 +1039,6 @@ static OQS_STATUS sig_stfl_test_secret_key_lock(const char *method_name) { goto err; } - - if (!lock_test_sk->secret_key_data) { fprintf(stderr, "ERROR: OQS_SECRET_KEY_new incomplete.\n"); goto err; @@ -1158,7 +1175,6 @@ int main(int argc, char **argv) { td_sign.alg_name = alg_name; td_query.alg_name = alg_name; - int trc = pthread_create(&thread, NULL, test_wrapper, &td); if (trc) { fprintf(stderr, "ERROR: Creating pthread\n");