diff --git a/src/sig_stfl/lms/sig_stfl_lms.c b/src/sig_stfl/lms/sig_stfl_lms.c index 9e65a5e442..7e5e99ea45 100644 --- a/src/sig_stfl/lms/sig_stfl_lms.c +++ b/src/sig_stfl/lms/sig_stfl_lms.c @@ -7,6 +7,50 @@ #include "sig_stfl_lms_wrap.h" #include "sig_stfl_lms.h" +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h25_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h25_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h25_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h25_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + + +// 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_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w1_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +// 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_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w8_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w4_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w8_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w2_h10_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w4_h10_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w8_h10_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_h10_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_h15_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_h10_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_h15_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); +OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_h20_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); + /* Convert LMS secret key object to byte string */ static OQS_STATUS OQS_SECRET_KEY_LMS_serialize_key(uint8_t **sk_buf_ptr, size_t *sk_len, const OQS_SIG_STFL_SECRET_KEY *sk); @@ -15,2858 +59,212 @@ static OQS_STATUS OQS_SECRET_KEY_LMS_deserialize_key(OQS_SIG_STFL_SECRET_KEY *sk static void OQS_SECRET_KEY_LMS_set_store_cb(OQS_SIG_STFL_SECRET_KEY *sk, secure_store_sk store_cb, void *context); -// ======================== LMS-SHA256 H5/W1 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_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_h5_w1) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_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_h5_w1; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h5_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_h5_w1_length_pk; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h5_w1_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h5_w1_length_sk; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h5_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; +// ======================== LMS Maccros ======================== // +// macro to en/disable OQS_SIG_STFL-only structs used only in sig&gen case: +#ifdef OQS_ALLOW_LMS_KEY_AND_SIG_GEN +#define LMS_SIGGEN(lms_variant, LMS_VARIANT) \ + sig->oid = OQS_LMS_ID_##lms_variant; \ + sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; \ + sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; \ + sig->keypair = OQS_SIG_STFL_alg_lms_##lms_variant##_keypair; \ + sig->sign = OQS_SIG_STFL_alg_lms_sign; +#else +#define LMS_SIGGEN(lms_variant, LMS_VARIANT) +#endif +// generator for all alg-specific functions: +#define LMS_ALG(lms_variant, LMS_VARIANT) \ +OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_##lms_variant##_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)); \ +\ + LMS_SIGGEN(lms_variant, ) \ + sig->method_name = OQS_SIG_STFL_alg_lms_##lms_variant; \ + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; \ + sig->euf_cma = true; \ +\ + sig->length_public_key = OQS_SIG_STFL_alg_lms_length_public_key; \ + sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; \ + sig->length_signature = OQS_SIG_STFL_alg_lms_##lms_variant##_length_signature; \ +\ + sig->verify = OQS_SIG_STFL_alg_lms_verify; \ +\ + return sig;\ +} \ +\ +OQS_STATUS OQS_SIG_STFL_alg_lms_##lms_variant##_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_##lms_variant) != 0) {\ + return OQS_ERROR;\ + }\ + return OQS_SUCCESS;\ +}\ +\ +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_##LMS_VARIANT##_new(void) {\ +\ + 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));\ +\ + sk->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key;\ +\ + sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key;\ +\ + sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key;\ +\ + sk->lock_key = NULL;\ +\ + sk->unlock_key = NULL;\ +\ + sk->secure_store_scrt_key = NULL;\ +\ + sk->free_key = OQS_SECRET_KEY_LMS_free;\ +\ + sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb;\ +\ + return sk;\ } -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_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_h5_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 H5/W1 ======================== // +LMS_ALG(sha256_h5_w1, SHA256_H5_W1) // ======================== 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_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_h5_w2; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_ALG(sha256_h5_w2, SHA256_H5_W2) // ======================== 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_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_h5_w4; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_ALG(sha256_h5_w4, SHA256_H5_W4) // ======================== 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_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_h5_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_ALG(sha256_h5_w8, SHA256_H5_W8) // ======================== 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_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_h10_w1; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_ALG(sha256_h10_w1, SHA256_H10_W1) // ======================== 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_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_h10_w2; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_ALG(sha256_h10_w2, SHA256_H10_W2) // ======================== 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_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_h10_w4; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_ALG(sha256_h10_w4, SHA256_H10_W4) // ======================== 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_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_h10_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_ALG(sha256_h10_w8, SHA256_H10_W8) // ======================== 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_h15_w1) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} +LMS_ALG(sha256_h15_w1, SHA256_H15_W1) -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w1_new(void) { +// ======================== LMS-SHA256 H15/W2 ======================== // - OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); - if (sig == NULL) { - return NULL; - } - memset(sig, 0, sizeof(OQS_SIG_STFL)); +LMS_ALG(sha256_h15_w2, SHA256_H15_W2) - sig->oid = OQS_LMS_ID_sha256_h15_w1; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h15_w1; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; - sig->euf_cma = true; +// ======================== LMS-SHA256 H15/W4 ======================== // - 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; +LMS_ALG(sha256_h15_w4, SHA256_H15_W4) - 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; +// ======================== LMS-SHA256 H15/W8 ======================== // - sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; - sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; +LMS_ALG(sha256_h15_w8, SHA256_H15_W8) - return sig; -} +// ======================== LMS-SHA256 H20/W1 ======================== // -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W1_new(void) { +LMS_ALG(sha256_h20_w1, SHA256_H20_W1) - // 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)); +// // ======================== LMS-SHA256 H20/W2 ======================== // - // Initialize the key with length_secret_key amount of bytes. - sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w1_length_sk; +LMS_ALG(sha256_h20_w2, SHA256_H20_W2) - /* - * Secret Key retrieval Function - */ - sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; +// ======================== LMS-SHA256 H20/W4 ======================== // - /* - * set Secret Key to internal structure Function - */ - sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; +LMS_ALG(sha256_h20_w4, SHA256_H20_W4) - /* - * Set Secret Key Locking Function - */ - sk->lock_key = NULL; +// ======================== LMS-SHA256 H20/W8 ======================== // - /* - * Set Secret Key Unlocking / Releasing Function - */ - sk->unlock_key = NULL; +LMS_ALG(sha256_h20_w8, SHA256_H20_W8) - /* - * Set Secret Key Saving Function - */ - sk->secure_store_scrt_key = NULL; +// ======================== LMS-SHA256 H25/W1 ======================== // - /* - * Set Secret Key free function - */ - sk->free_key = OQS_SECRET_KEY_LMS_free; +LMS_ALG(sha256_h25_w1, SHA256_H25_W1) - sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; +// ======================== LMS-SHA256 H25/W2 ======================== // - return sk; -} +LMS_ALG(sha256_h25_w2, SHA256_H25_W2) -// ======================== LMS-SHA256 H15/W2 ======================== // +// ======================== LMS-SHA256 H25/W4 ======================== // -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; - } +LMS_ALG(sha256_h25_w4, SHA256_H25_W4) - if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_h15_w2) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} +// ======================== LMS-SHA256 H25/W8 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w2_new(void) { +LMS_ALG(sha256_h25_w8, SHA256_H25_W8) - OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); - if (sig == NULL) { - return NULL; - } - memset(sig, 0, sizeof(OQS_SIG_STFL)); +// +//2-Level LMS +// ======================== LMS-SHA256 H5/W8, H5/W8 ======================== // - sig->oid = OQS_LMS_ID_sha256_h15_w2; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h15_w2; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; - sig->euf_cma = true; +LMS_ALG(sha256_h5_w8_h5_w8, SHA256_H5_W8_H5_W8) - 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; +// ======================== LMS-SHA256 H10/W2, H10/W2 ======================== // - 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; +LMS_ALG(sha256_h10_w2_h10_w2, SHA256_H10_W2_H10_W2) - sig->sigs_remaining = OQS_SIG_STFL_lms_sigs_left; - sig->sigs_total = OQS_SIG_STFL_lms_sigs_total; +// ======================== LMS-SHA256 H10/W4, H5/W8 ======================== // - return sig; -} +LMS_ALG(sha256_h10_w4_h5_w8, SHA256_H10_W4_H5_W8) -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W2_new(void) { +// ======================== LMS-SHA256 H10/W4, H10/W4 ======================== // - // 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)); +LMS_ALG(sha256_h10_w4_h10_w4, SHA256_H10_W4_H10_W4) - // Initialize the key with length_secret_key amount of bytes. - sk->length_secret_key = OQS_SIG_STFL_alg_lms_sha256_h15_w2_length_sk; +// ======================== LMS-SHA256 H10/W8, H5/W8 ======================== // - /* - * Secret Key retrieval Function - */ - sk->serialize_key = OQS_SECRET_KEY_LMS_serialize_key; +LMS_ALG(sha256_h10_w8_h5_w8, SHA256_H10_W8_H5_W8) - /* - * set Secret Key to internal structure Function - */ - sk->deserialize_key = OQS_SECRET_KEY_LMS_deserialize_key; +// ======================== LMS-SHA256 H10/W8, H10/W8 ======================== // - /* - * Set Secret Key Locking Function - */ - sk->lock_key = NULL; +LMS_ALG(sha256_h10_w8_h10_w8, SHA256_H10_W8_H10_W8) - /* - * Set Secret Key Unlocking / Releasing Function - */ - sk->unlock_key = NULL; +// ======================== LMS-SHA256 H15/W8, H5/W8 ======================== // - /* - * Set Secret Key Saving Function - */ - sk->secure_store_scrt_key = NULL; +LMS_ALG(sha256_h15_w8_h5_w8, SHA256_H15_W8_H5_W8) - /* - * Set Secret Key free function - */ - sk->free_key = OQS_SECRET_KEY_LMS_free; +// ======================== LMS-SHA256 H15/W8, H10/W8 ======================== // - sk->set_scrt_key_store_cb = OQS_SECRET_KEY_LMS_set_store_cb; +LMS_ALG(sha256_h15_w8_h10_w8, SHA256_H15_W8_H10_W8) - return sk; -} +// ======================== LMS-SHA256 H15/W8, H15/W8 ======================== // -// ======================== LMS-SHA256 H15/W4 ======================== // +LMS_ALG(sha256_h15_w8_h15_w8, SHA256_H15_W8_H15_W8) -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; - } +// ======================== LMS-SHA256 H20/W8, H5/W8 ======================== // - if (oqs_sig_stfl_lms_keypair(public_key, secret_key, (const uint32_t)OQS_LMS_ID_sha256_h15_w4) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} +LMS_ALG(sha256_h20_w8_h5_w8, SHA256_H20_W8_H5_W8) -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w4_new(void) { +// ======================== LMS-SHA256 H20/W8, H10/W8 ======================== // - OQS_SIG_STFL *sig = (OQS_SIG_STFL *)malloc(sizeof(OQS_SIG_STFL)); - if (sig == NULL) { - return NULL; - } - memset(sig, 0, sizeof(OQS_SIG_STFL)); +LMS_ALG(sha256_h20_w8_h10_w8, SHA256_H20_W8_H10_W8) - sig->oid = OQS_LMS_ID_sha256_h15_w4; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h15_w4; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8554"; - sig->euf_cma = true; +// ======================== LMS-SHA256 H20/W8, H15/W8 ======================== // - 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; +LMS_ALG(sha256_h20_w8_h15_w8, SHA256_H20_W8_H15_W8) - 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; +// ======================== LMS-SHA256 H20/W8, H20/W8 ======================== // - 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_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_h15_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_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_h20_w1; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_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_h20_w2; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_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_h20_w4; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_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_h20_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_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_h25_w1; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_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_h25_w2; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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_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_h25_w4; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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 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_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_h25_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_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 - */ - 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; -} - -// -//2-Level LMS -// ======================== LMS-SHA256 H5/W8, H5/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w8_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_h5_w8_h5_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w8_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_h5_w8_h5_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h5_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h5_w8_h5_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h5_w8_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_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_length_private_key; - - /* - * 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 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, H10/W2 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w2_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_h10_w2_h10_w2) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w2_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_h10_w2_h10_w2; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h10_w2_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w2_h10_w2_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w2_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_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_length_private_key; - - /* - * 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 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, H5/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w4_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_h10_w4_h5_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w4_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_h10_w4_h5_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h10_w4_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w4_h5_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w4_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_H10_W4_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_length_private_key; - - /* - * 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 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, H10/W4 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w4_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_h10_w4_h10_w4) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w4_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_h10_w4_h10_w4; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h10_w4_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w4_h10_w4_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w4_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_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_length_private_key; - - /* - * 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 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, H5/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w8_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_h10_w8_h5_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w8_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_h10_w8_h5_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h10_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w8_h5_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w8_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_H10_W8_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_length_private_key; - - /* - * 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, H10/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w8_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_h10_w8_h10_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w8_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_h15_w4; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h10_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h10_w8_h10_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h10_w8_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_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_length_private_key; - - /* - * 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, H5/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_h15_w8_h5_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_h15_w8_h5_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h15_w8_h5_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_H15_W8_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_length_private_key; - - /* - * 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, H10/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_h15_w8_h10_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_h15_w8_h10_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h15_w8_h10_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_H15_W8_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_length_private_key; - - /* - * 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, H15/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_h15_w8_h15_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_h15_w8_h15_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h15_w8_h15_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h15_w8_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_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_length_private_key; - - /* - * 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, H5/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_h20_w8_h5_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_h20_w8_h5_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h20_w8_h5_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_H20_W8_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_length_private_key; - - /* - * 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, H10/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_h20_w8_h10_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_h20_w8_h10_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h20_w8_h10_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_H20_W8_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_length_private_key; - - /* - * 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, H15/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_h20_w8_h15_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_h20_w8_h15_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h20_w8_h15_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_H20_W8_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_length_private_key; - - /* - * 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, H20/W8 ======================== // - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_h20_w8_h20_w8) != 0) { - return OQS_ERROR; - } - return OQS_SUCCESS; -} - -OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_h20_w8_h20_w8; - sig->method_name = OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_length_public_key; - sig->length_signature = OQS_SIG_STFL_alg_lms_sha256_h20_w8_h20_w8_length_signature; - sig->length_secret_key = OQS_SIG_STFL_alg_lms_length_private_key; - - sig->keypair = OQS_SIG_STFL_alg_lms_sha256_h20_w8_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_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_length_private_key; - - /* - * 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_ALG(sha256_h20_w8_h20_w8, SHA256_H20_W8_H20_W8) //2-Level LMS diff --git a/src/sig_stfl/lms/sig_stfl_lms.h b/src/sig_stfl/lms/sig_stfl_lms.h index 4405e60c1c..c5deed2f40 100644 --- a/src/sig_stfl/lms/sig_stfl_lms.h +++ b/src/sig_stfl/lms/sig_stfl_lms.h @@ -96,28 +96,24 @@ #define OQS_SIG_STFL_alg_lms_sha256_h5_w1_length_sk 64 OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w1_new(void); OQS_API 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); #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_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w2_new(void); OQS_API 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_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w4_new(void); OQS_API 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_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w8_new(void); OQS_API 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 @@ -279,55 +275,42 @@ void OQS_SECRET_KEY_LMS_free(OQS_SIG_STFL_SECRET_KEY *sk); #define OQS_SIG_STFL_alg_lms_sha256_h20_w8_h15_w8_length_signature 3444 #define OQS_SIG_STFL_alg_lms_sha256_h20_w8_h20_w8_length_signature 3604 -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h5_w8_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H5_W8_H5_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h5_w8_h5_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w4_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W4_H5_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w4_h5_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w8_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W8_H5_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w8_h5_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w2_h10_w2_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W2_H10_W2_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w2_h10_w2_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w4_h10_w4_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W4_H10_W4_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w4_h10_w4_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h10_w8_h10_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H10_W8_H10_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h10_w8_h10_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W8_H5_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w8_h5_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_h10_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W8_H10_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w8_h10_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h15_w8_h15_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H15_W8_H15_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h15_w8_h15_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_h5_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W8_H5_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_h5_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_h10_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W8_H10_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_h10_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_h15_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W8_H15_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_h15_w8_new(void); -OQS_API OQS_STATUS OQS_SIG_STFL_alg_lms_sha256_h20_w8_h20_w8_keypair(uint8_t *public_key, OQS_SIG_STFL_SECRET_KEY *secret_key); OQS_API OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_LMS_SHA256_H20_W8_H20_W8_new(void); OQS_API OQS_SIG_STFL *OQS_SIG_STFL_alg_lms_sha256_h20_w8_h20_w8_new(void); diff --git a/src/sig_stfl/sig_stfl.c b/src/sig_stfl/sig_stfl.c index 0f6ebff7af..69fdbc352c 100644 --- a/src/sig_stfl/sig_stfl.c +++ b/src/sig_stfl/sig_stfl.c @@ -912,6 +912,7 @@ OQS_API OQS_STATUS OQS_SIG_STFL_sign(const OQS_SIG_STFL *sig, uint8_t *signature #endif } + OQS_API OQS_STATUS OQS_SIG_STFL_verify(const OQS_SIG_STFL *sig, const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { if (sig == NULL || sig->verify == NULL || sig->verify(message, message_len, signature, signature_len, public_key) != 0) { return OQS_ERROR; @@ -920,20 +921,36 @@ OQS_API OQS_STATUS OQS_SIG_STFL_verify(const OQS_SIG_STFL *sig, const uint8_t *m } } + OQS_API OQS_STATUS OQS_SIG_STFL_sigs_remaining(const OQS_SIG_STFL *sig, unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { +#ifndef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN + (void)sig; + (void)remain; + (void)secret_key; + return OQS_ERROR; +#else if (sig == NULL || sig->sigs_remaining == NULL || sig->sigs_remaining(remain, secret_key) != 0) { return OQS_ERROR; } else { return OQS_SUCCESS; } +#endif //OQS_ALLOW_SFTL_KEY_AND_SIG_GEN } + OQS_API OQS_STATUS OQS_SIG_STFL_sigs_total(const OQS_SIG_STFL *sig, unsigned long long *max, const OQS_SIG_STFL_SECRET_KEY *secret_key) { +#ifndef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN + (void)sig; + (void)max; + (void)secret_key; + return OQS_ERROR; +#else if (sig == NULL || sig->sigs_total == NULL || sig->sigs_total(max, secret_key) != 0) { return OQS_ERROR; } else { return OQS_SUCCESS; } +#endif //OQS_ALLOW_SFTL_KEY_AND_SIG_GEN } OQS_API void OQS_SIG_STFL_free(OQS_SIG_STFL *sig) { diff --git a/src/sig_stfl/sig_stfl.h b/src/sig_stfl/sig_stfl.h index ac95842400..b0cb69b843 100644 --- a/src/sig_stfl/sig_stfl.h +++ b/src/sig_stfl/sig_stfl.h @@ -178,6 +178,9 @@ OQS_API int OQS_SIG_STFL_alg_count(void); */ OQS_API int OQS_SIG_STFL_alg_is_enabled(const char *method_name); +#ifndef OQS_ALLOW_SFTL_KEY_AND_SIG_GEN +#define OQS_SIG_STFL OQS_SIG +#else /** * Stateful signature scheme object */ @@ -281,6 +284,7 @@ typedef struct OQS_SIG_STFL { OQS_STATUS (*sigs_total)(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key); } OQS_SIG_STFL; +#endif //OQS_ALLOW_SFTL_KEY_AND_SIG_GEN /** * @brief OQS_SIG_STFL_SECRET_KEY object for stateful signature schemes 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 ebcf4f7608..7b9bcff39b 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h10.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h10.c @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHA2_10_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h10_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_SIG_STFL_alg_xmss_sha256_h10_oid; - sig->method_name = "XMSS-SHA2_10_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_sha256_h10_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_sha256_h10_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_sha256_h10_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_sha256_h10_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_sha256_h10_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_sha256_h10_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha256_h10_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha256_h10_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA256_H10_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_sha256_h10_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h10_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_sha256_h10_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h10_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h10_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h10_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h10_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _sha256_h10, _SHA256_H10) 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 d401b2aa75..c883e21e0e 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h16.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h16.c @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHA2_16_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h16_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_SIG_STFL_alg_xmss_sha256_h16_oid; - sig->method_name = "XMSS-SHA2_16_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_sha256_h16_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_sha256_h16_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_sha256_h16_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_sha256_h16_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_sha256_h16_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_sha256_h16_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha256_h16_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha256_h16_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA256_H16_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_sha256_h16_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h16_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_sha256_h16_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h16_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h16_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h16_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h16_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _sha256_h16, _SHA256_H16) 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 5cc2804754..a190255f2c 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h20.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha256_h20.c @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHA2_16_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha256_h20_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_SIG_STFL_alg_xmss_sha256_h20_oid; - sig->method_name = "XMSS-SHA2_20_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_sha256_h20_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_sha256_h20_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_sha256_h20_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_sha256_h20_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_sha256_h20_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_sha256_h20_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha256_h20_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha256_h20_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA256_H20_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_sha256_h20_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h20_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_sha256_h20_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h20_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h20_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h20_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha256_h20_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _sha256_h20, _SHA256_H20) 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 b77a8c8436..1ff4cd891a 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h10.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h10.c @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHA2_10_512 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h10_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_SIG_STFL_alg_xmss_sha512_h10_oid; - sig->method_name = "XMSS-SHA2_10_512"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_sha512_h10_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_sha512_h10_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_sha512_h10_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_sha512_h10_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_sha512_h10_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_sha512_h10_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha512_h10_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha512_h10_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA512_H10_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_sha512_h10_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h10_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_sha512_h10_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h10_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h10_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h10_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h10_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _sha512_h10, _SHA512_H10) 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 695d5de288..c1b5ed9150 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h16.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h16.c @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHA2_16_512 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h16_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_SIG_STFL_alg_xmss_sha512_h16_oid; - sig->method_name = "XMSS-SHA2_16_512"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_sha512_h16_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_sha512_h16_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_sha512_h16_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_sha512_h16_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_sha512_h16_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_sha512_h16_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha512_h16_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha512_h16_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA512_H16_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_sha512_h16_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h16_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_sha512_h16_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h16_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h16_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h16_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h16_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _sha512_h16, _SHA512_H16) 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 f4b579deec..bf0a5b8d12 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h20.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_sha512_h20.c @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHA2_20_512 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_sha512_h20_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_SIG_STFL_alg_xmss_sha512_h20_oid; - sig->method_name = "XMSS-SHA2_20_512"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_sha512_h20_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_sha512_h20_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_sha512_h20_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_sha512_h20_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_sha512_h20_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_sha512_h20_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_sha512_h20_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_sha512_h20_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHA512_H20_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_sha512_h20_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h20_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_sha512_h20_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h20_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h20_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h20_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_sha512_h20_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _sha512_h20, _SHA512_H20) 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 d216a02a15..8c01394663 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h10.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h10.c @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHAKE_10_256 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h10_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_SIG_STFL_alg_xmss_shake128_h10_oid; - sig->method_name = "XMSS-SHAKE_10_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_shake128_h10_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_shake128_h10_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_shake128_h10_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_shake128_h10_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_shake128_h10_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_shake128_h10_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake128_h10_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake128_h10_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE128_H10_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_shake128_h10_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h10_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_shake128_h10_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h10_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h10_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h10_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h10_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _shake128_h10, _SHAKE128_H10) 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 bb0bd4684b..ff45fc0f5f 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h16.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h16.c @@ -1,77 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHAKE_10_256 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h16_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_SIG_STFL_alg_xmss_shake128_h16_oid; - sig->method_name = "XMSS-SHAKE_16_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_shake128_h16_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_shake128_h16_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_shake128_h16_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_shake128_h16_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_shake128_h16_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_shake128_h16_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake128_h16_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake128_h16_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE128_H16_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_shake128_h16_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h16_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_shake128_h16_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h16_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h16_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h16_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h16_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} - +XMSS_ALG(, _shake128_h16, _SHAKE128_H16) 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 b601e09a4e..d566069a82 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h20.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake128_h20.c @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHAKE_10_256 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake128_h20_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_SIG_STFL_alg_xmss_shake128_h20_oid; - sig->method_name = "XMSS-SHAKE_20_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_shake128_h20_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_shake128_h20_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_shake128_h20_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_shake128_h20_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_shake128_h20_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_shake128_h20_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake128_h20_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake128_h20_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE128_H20_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_shake128_h20_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h20_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_shake128_h20_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h20_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h20_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h20_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake128_h20_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _shake128_h20, _SHAKE128_H20) 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 33b685c20b..aea7ef0204 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h10.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h10.c @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHAKE_10_512 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h10_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_SIG_STFL_alg_xmss_shake256_h10_oid; - sig->method_name = "XMSS-SHAKE_10_512"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_shake256_h10_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_shake256_h10_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_shake256_h10_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_shake256_h10_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_shake256_h10_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_shake256_h10_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake256_h10_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake256_h10_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H10_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_shake256_h10_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_shake256_h10_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h10_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _shake256_h10, _SHAKE256_H10) 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 02781a8600..d96e7644b3 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h16.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h16.c @@ -1,77 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHAKE_16_512 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h16_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_SIG_STFL_alg_xmss_shake256_h16_oid; - sig->method_name = "XMSS-SHAKE_16_512"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_shake256_h16_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_shake256_h16_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_shake256_h16_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_shake256_h16_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_shake256_h16_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_shake256_h16_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake256_h16_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake256_h16_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H16_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_shake256_h16_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_shake256_h16_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h16_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} - +XMSS_ALG(, _shake256_h16, _SHAKE256_H16) 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 f4d856c34a..5bf41b07f9 100644 --- a/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h20.c +++ b/src/sig_stfl/xmss/sig_stfl_xmss_shake256_h20.c @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSS-SHAKE_20_512 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss_shake256_h20_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_SIG_STFL_alg_xmss_shake256_h20_oid; - sig->method_name = "XMSS-SHAKE_20_512"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmss_shake256_h20_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmss_shake256_h20_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmss_shake256_h20_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmss_shake256_h20_keypair; - sig->sign = OQS_SIG_STFL_alg_xmss_shake256_h20_sign; - sig->verify = OQS_SIG_STFL_alg_xmss_shake256_h20_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmss_shake256_h20_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmss_shake256_h20_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS_SHAKE256_H20_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss_shake256_h20_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmss_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss_shake256_h20_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmss_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss_shake256_h20_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmss_sigs_total(total, secret_key); -} +XMSS_ALG(, _shake256_h20, _SHAKE256_H20) diff --git a/src/sig_stfl/xmss/sig_stfl_xmss_xmssmt.c b/src/sig_stfl/xmss/sig_stfl_xmss_xmssmt.c new file mode 100644 index 0000000000..1b81bec309 --- /dev/null +++ b/src/sig_stfl/xmss/sig_stfl_xmss_xmssmt.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: Apache-2.0 AND MIT + +#include +#include + +#include +#include "sig_stfl_xmss.h" + +#include "external/xmss.h" + +#if defined(__GNUC__) || defined(__clang__) +#define XMSS_UNUSED_ATT __attribute__((unused)) +#else +#define XMSS_UNUSED_ATT +#endif + + +// macro to en/disable OQS_SIG_STFL-only structs used only in sig&gen case: +#ifdef OQS_ALLOW_XMSS_KEY_AND_SIG_GEN +#define XMSS_SIGGEN(xmss_v, XMSS_V) \ + sig->oid = OQS_SIG_STFL_alg_xmss##xmss_v##_oid; \ + sig->sigs_remaining = OQS_SIG_STFL_alg_xmss##xmss_v##_sigs_remaining;\ + sig->sigs_total = OQS_SIG_STFL_alg_xmss##xmss_v##_sigs_total;\ + sig->keypair = OQS_SIG_STFL_alg_xmss##xmss_v##_keypair;\ + sig->sign = OQS_SIG_STFL_alg_xmss##xmss_v##_sign; +#else +#define XMSS_SIGGEN(xmss_v, XMSS_V) +#endif + +// generator for all alg-specific functions: +#define XMSS_ALG(mt, xmss_v, XMSS_V) \ +OQS_SIG_STFL *OQS_SIG_STFL_alg_xmss##xmss_v##_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)); \ +\ + XMSS_SIGGEN(xmss_v, XMSS_V) \ + sig->method_name = OQS_SIG_STFL_alg_xmss##xmss_v; \ + sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; \ + sig->euf_cma = true; \ +\ + sig->length_public_key = OQS_SIG_STFL_alg_xmss##xmss_v##_length_pk; \ + sig->length_secret_key = OQS_SIG_STFL_alg_xmss##xmss_v##_length_sk; \ + sig->length_signature = OQS_SIG_STFL_alg_xmss##xmss_v##_length_signature; \ +\ + sig->verify = OQS_SIG_STFL_alg_xmss##xmss_v##_verify;\ +\ + return sig;\ +} \ +\ +OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSS##XMSS_V##_new(void) {\ + return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmss##xmss_v##_length_sk);\ +}\ +\ +OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss##xmss_v##_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) {\ +\ + if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) {\ + return OQS_ERROR;\ + }\ +\ + if (xmss##mt##_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmss##xmss_v##_oid)) {\ + return OQS_ERROR;\ + }\ +\ + return OQS_SUCCESS;\ +}\ +\ +OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss##xmss_v##_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) {\ + return OQS_SIG_STFL_alg_xmss##mt##_sign(signature, signature_len, message, message_len, secret_key);\ +}\ +\ +OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss##xmss_v##_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) {\ + return OQS_SIG_STFL_alg_xmss##mt##_verify(message, message_len, signature, signature_len, public_key);\ +}\ +\ +OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss##xmss_v##_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) {\ + return OQS_SIG_STFL_alg_xmss##mt##_sigs_remaining(remain, secret_key);\ +}\ +\ +OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmss##xmss_v##_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) {\ + return OQS_SIG_STFL_alg_xmss##mt##_sigs_total(total, secret_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 3d90674459..0c6057eef9 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 @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHA2_20/2_256 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_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_SIG_STFL_alg_xmssmt_sha256_h20_2_oid; - sig->method_name = "XMSSMT-SHA2_20/2_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H20_2_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_2_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_sha256_h20_2, MT_SHA256_H20_2) 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 0305764855..867e0928b1 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 @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHA2_20/4_256 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_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_SIG_STFL_alg_xmssmt_sha256_h20_4_oid; - sig->method_name = "XMSSMT-SHA2_20/4_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H20_4_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h20_4_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_sha256_h20_4, MT_SHA256_H20_4) 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 19db158709..e972df04ee 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 @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHA2_40/2_256 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_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_SIG_STFL_alg_xmssmt_sha256_h40_2_oid; - sig->method_name = "XMSSMT-SHA2_40/2_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H40_2_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_2_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_sha256_h40_2, MT_SHA256_H40_2) 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 0f17088d4b..63c9af0bc8 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 @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHA2_40/4_256 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_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_SIG_STFL_alg_xmssmt_sha256_h40_4_oid; - sig->method_name = "XMSSMT-SHA2_40/4_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H40_4_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_4_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_sha256_h40_4, MT_SHA256_H40_4) 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 b985951514..156c2e3fd6 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHA2_40/8_256 ======================== // +XMSS_ALG(mt, mt_sha256_h40_8, MT_SHA256_H40_8) -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_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_SIG_STFL_alg_xmssmt_sha256_h40_8_oid; - sig->method_name = "XMSSMT-SHA2_40/8_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H40_8_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h40_8_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_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 60e3cae071..64f6576f82 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 @@ -1,76 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include +#include "sig_stfl_xmss_xmssmt.c" -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif // ======================== XMSSMT-SHA2_60/12_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_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_SIG_STFL_alg_xmssmt_sha256_h60_12_oid; - sig->method_name = "XMSSMT-SHA2_60/12_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H60_12_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_12_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_sha256_h60_12, MT_SHA256_H60_12) 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 fc5cf35c23..d37e1244ae 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 @@ -1,76 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHA2_60/3_256 ======================== // - -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_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_SIG_STFL_alg_xmssmt_sha256_h60_3_oid; - sig->method_name = "XMSSMT-SHA2_60/3_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H60_3_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_3_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_sha256_h60_3, MT_SHA256_H60_3) 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 6f055e949b..d5992617c0 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHA2_60/6_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_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_SIG_STFL_alg_xmssmt_sha256_h60_6_oid; - sig->method_name = "XMSSMT-SHA2_60/6_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHA256_H60_6_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_sha256_h60_6_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_sha256_h60_6, MT_SHA256_H60_6) 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 98a085ce22..76c8523a80 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHAKE_20/2_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_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_SIG_STFL_alg_xmssmt_shake128_h20_2_oid; - sig->method_name = "XMSSMT-SHAKE_20/2_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H20_2_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_2_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_shake128_h20_2, MT_SHAKE128_H20_2) 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 37ee00a20b..0dec4743e6 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHAKE_20/4_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_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_SIG_STFL_alg_xmssmt_shake128_h20_4_oid; - sig->method_name = "XMSSMT-SHAKE_20/4_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H20_4_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h20_4_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_shake128_h20_4, MT_SHAKE128_H20_4) 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 a4175423a7..765694287d 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHAKE_40/2_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_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_SIG_STFL_alg_xmssmt_shake128_h40_2_oid; - sig->method_name = "XMSSMT-SHAKE_40/2_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H40_2_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_2_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_shake128_h40_2, MT_SHAKE128_H40_2) 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 bbadceea0f..7ce156c659 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHAKE_40/4_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_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_SIG_STFL_alg_xmssmt_shake128_h40_4_oid; - sig->method_name = "XMSSMT-SHAKE_40/4_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H40_4_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_4_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_shake128_h40_4, MT_SHAKE128_H40_4) 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 14b3b50ffb..1c3f9671c0 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHAKE_40/8_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_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_SIG_STFL_alg_xmssmt_shake128_h40_8_oid; - sig->method_name = "XMSSMT-SHAKE_40/8_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H40_8_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h40_8_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_shake128_h40_8, MT_SHAKE128_H40_8) 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 74c378ac7e..793393eaf3 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 @@ -1,77 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHAKE_60/12_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_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_SIG_STFL_alg_xmssmt_shake128_h60_12_oid; - sig->method_name = "XMSSMT-SHAKE_60/12_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H60_12_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_12_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} - +XMSS_ALG(mt, mt_shake128_h60_12, MT_SHAKE128_H60_12) 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 f7bae2956c..09edd7ebd7 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHAKE_60/3_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_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_SIG_STFL_alg_xmssmt_shake128_h60_3_oid; - sig->method_name = "XMSSMT-SHAKE_60/3_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H60_3_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_3_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_shake128_h60_3, MT_SHAKE128_H60_3) 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 33f714d702..aae4ca20a6 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 @@ -1,76 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 AND MIT -#include -#include - -#include -#include "sig_stfl_xmss.h" - -#include "external/xmss.h" - -#if defined(__GNUC__) || defined(__clang__) -#define XMSS_UNUSED_ATT __attribute__((unused)) -#else -#define XMSS_UNUSED_ATT -#endif +#include "sig_stfl_xmss_xmssmt.c" // ======================== XMSSMT-SHAKE_60/6_256 ======================== // -OQS_SIG_STFL *OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_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_SIG_STFL_alg_xmssmt_shake128_h60_6_oid; - sig->method_name = "XMSSMT-SHAKE_60/6_256"; - sig->alg_version = "https://datatracker.ietf.org/doc/html/rfc8391"; - sig->euf_cma = true; - - sig->length_public_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_length_pk; - sig->length_secret_key = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_length_sk; - sig->length_signature = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_length_signature; - - sig->keypair = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_keypair; - sig->sign = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_sign; - sig->verify = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_verify; - sig->sigs_remaining = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_sigs_remaining; - sig->sigs_total = OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_sigs_total; - - return sig; -} - -OQS_SIG_STFL_SECRET_KEY *OQS_SECRET_KEY_XMSSMT_SHAKE128_H60_6_new(void) { - return OQS_SECRET_KEY_XMSS_new(OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_length_sk); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_keypair(XMSS_UNUSED_ATT uint8_t *public_key, XMSS_UNUSED_ATT OQS_SIG_STFL_SECRET_KEY *secret_key) { - - if (public_key == NULL || secret_key == NULL || secret_key->secret_key_data == NULL) { - return OQS_ERROR; - } - - if (xmssmt_keypair(public_key, secret_key->secret_key_data, OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_oid)) { - return OQS_ERROR; - } - - return OQS_SUCCESS; -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sign(signature, signature_len, message, message_len, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { - return OQS_SIG_STFL_alg_xmssmt_verify(message, message_len, signature, signature_len, public_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_sigs_remaining(unsigned long long *remain, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_remaining(remain, secret_key); -} - -OQS_API OQS_STATUS OQS_SIG_STFL_alg_xmssmt_shake128_h60_6_sigs_total(unsigned long long *total, const OQS_SIG_STFL_SECRET_KEY *secret_key) { - return OQS_SIG_STFL_alg_xmssmt_sigs_total(total, secret_key); -} +XMSS_ALG(mt, mt_shake128_h60_6, MT_SHAKE128_H60_6) diff --git a/tests/test_sig_stfl.c b/tests/test_sig_stfl.c index f0a51aac74..5626eee5b3 100644 --- a/tests/test_sig_stfl.c +++ b/tests/test_sig_stfl.c @@ -263,8 +263,8 @@ OQS_STATUS sig_stfl_KATs_keygen(OQS_SIG_STFL *sig, uint8_t *public_key, OQS_SIG_ return OQS_ERROR; } +#ifdef OQS_ENABLE_SIG_STFL_XMSS if (0) { - #ifdef OQS_ENABLE_SIG_STFL_xmss_sha256_h16 } else if (strcmp(sig->method_name, OQS_SIG_STFL_alg_xmss_sha256_h16) == 0) { goto from_kats; @@ -321,12 +321,11 @@ OQS_STATUS sig_stfl_KATs_keygen(OQS_SIG_STFL *sig, uint8_t *public_key, OQS_SIG_ } else { goto from_keygen; } -#ifdef OQS_ENABLE_SIG_STFL_XMSS from_kats: return sig_stfl_keypair_from_KATs(sig, public_key, secret_key, katfile); -#endif from_keygen: +#endif //OQS_ENABLE_SIG_STFL_XMSS (void)(katfile); return sig_stfl_keypair_from_keygen(sig, public_key, secret_key); }