diff --git a/oqsprov/oqs_decode_der2key.c b/oqsprov/oqs_decode_der2key.c index 07308b25..127918fe 100644 --- a/oqsprov/oqs_decode_der2key.c +++ b/oqsprov/oqs_decode_der2key.c @@ -26,19 +26,19 @@ int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb); // TBD: OK to use? #include "oqs_endecoder_local.h" #ifdef NDEBUG -#define OQS_DEC_PRINTF(a) -#define OQS_DEC_PRINTF2(a, b) -#define OQS_DEC_PRINTF3(a, b, c) +# define OQS_DEC_PRINTF(a) +# define OQS_DEC_PRINTF2(a, b) +# define OQS_DEC_PRINTF3(a, b, c) #else -#define OQS_DEC_PRINTF(a) \ - if (getenv("OQSDEC")) \ - printf(a) -#define OQS_DEC_PRINTF2(a, b) \ - if (getenv("OQSDEC")) \ - printf(a, b) -#define OQS_DEC_PRINTF3(a, b, c) \ - if (getenv("OQSDEC")) \ - printf(a, b, c) +# define OQS_DEC_PRINTF(a) \ + if (getenv("OQSDEC")) \ + printf(a) +# define OQS_DEC_PRINTF2(a, b) \ + if (getenv("OQSDEC")) \ + printf(a, b) +# define OQS_DEC_PRINTF3(a, b, c) \ + if (getenv("OQSDEC")) \ + printf(a, b, c) #endif // NDEBUG struct der2key_ctx_st; /* Forward declaration */ @@ -108,16 +108,17 @@ struct X509_pubkey_st { unsigned int flag_force_legacy : 1; }; -ASN1_SEQUENCE(X509_PUBKEY_INTERNAL) = - {ASN1_SIMPLE(X509_PUBKEY, algor, X509_ALGOR), - ASN1_SIMPLE( - X509_PUBKEY, public_key, - ASN1_BIT_STRING)} static_ASN1_SEQUENCE_END_name(X509_PUBKEY, - X509_PUBKEY_INTERNAL) - - X509_PUBKEY - * oqsx_d2i_X509_PUBKEY_INTERNAL(const unsigned char **pp, long len, - OSSL_LIB_CTX *libctx) { +ASN1_SEQUENCE(X509_PUBKEY_INTERNAL) + = {ASN1_SIMPLE(X509_PUBKEY, algor, X509_ALGOR), + ASN1_SIMPLE( + X509_PUBKEY, public_key, + ASN1_BIT_STRING)} static_ASN1_SEQUENCE_END_name(X509_PUBKEY, + X509_PUBKEY_INTERNAL) + + X509_PUBKEY + * oqsx_d2i_X509_PUBKEY_INTERNAL(const unsigned char **pp, long len, + OSSL_LIB_CTX *libctx) +{ X509_PUBKEY *xpub = OPENSSL_zalloc(sizeof(*xpub)); if (xpub == NULL) @@ -141,7 +142,8 @@ struct der2key_ctx_st { }; int oqs_read_der(PROV_OQS_CTX *provctx, OSSL_CORE_BIO *cin, - unsigned char **data, long *len) { + unsigned char **data, long *len) +{ OQS_DEC_PRINTF("OQS DEC provider: oqs_read_der called.\n"); BUF_MEM *mem = NULL; @@ -162,7 +164,8 @@ typedef void *key_from_pkcs8_t(const PKCS8_PRIV_KEY_INFO *p8inf, static void *oqs_der2key_decode_p8(const unsigned char **input_der, long input_der_len, struct der2key_ctx_st *ctx, - key_from_pkcs8_t *key_from_pkcs8) { + key_from_pkcs8_t *key_from_pkcs8) +{ PKCS8_PRIV_KEY_INFO *p8inf = NULL; const X509_ALGOR *alg = NULL; void *key = NULL; @@ -171,17 +174,18 @@ static void *oqs_der2key_decode_p8(const unsigned char **input_der, "OQS DEC provider: oqs_der2key_decode_p8 called. Keytype: %d.\n", ctx->desc->evp_type); - if ((p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, input_der, input_der_len)) != - NULL && - PKCS8_pkey_get0(NULL, NULL, NULL, &alg, p8inf) && - OBJ_obj2nid(alg->algorithm) == ctx->desc->evp_type) + if ((p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, input_der, input_der_len)) + != NULL + && PKCS8_pkey_get0(NULL, NULL, NULL, &alg, p8inf) + && OBJ_obj2nid(alg->algorithm) == ctx->desc->evp_type) key = key_from_pkcs8(p8inf, PROV_OQS_LIBCTX_OF(ctx->provctx), NULL); PKCS8_PRIV_KEY_INFO_free(p8inf); return key; } -OQSX_KEY *oqsx_d2i_PUBKEY(OQSX_KEY **a, const unsigned char **pp, long length) { +OQSX_KEY *oqsx_d2i_PUBKEY(OQSX_KEY **a, const unsigned char **pp, long length) +{ OQSX_KEY *key = NULL; // taken from internal code for d2i_PUBKEY_int: X509_PUBKEY *xpk; @@ -213,7 +217,8 @@ static OSSL_FUNC_decoder_export_object_fn der2key_export_object; static struct der2key_ctx_st *der2key_newctx(void *provctx, struct keytype_desc_st *desc, - const char *tls_name) { + const char *tls_name) +{ struct der2key_ctx_st *ctx = OPENSSL_zalloc(sizeof(*ctx)); OQS_DEC_PRINTF3("OQS DEC provider: der2key_newctx called with tls_name %s. " @@ -233,21 +238,23 @@ static struct der2key_ctx_st *der2key_newctx(void *provctx, return ctx; } -static void der2key_freectx(void *vctx) { +static void der2key_freectx(void *vctx) +{ struct der2key_ctx_st *ctx = vctx; OPENSSL_free(ctx); } static int der2key_check_selection(int selection, - const struct keytype_desc_st *desc) { + const struct keytype_desc_st *desc) +{ /* * The selections are kinda sorta "levels", i.e. each selection given * here is assumed to include those following. */ - int checks[] = {OSSL_KEYMGMT_SELECT_PRIVATE_KEY, - OSSL_KEYMGMT_SELECT_PUBLIC_KEY, - OSSL_KEYMGMT_SELECT_ALL_PARAMETERS}; + int checks[] + = {OSSL_KEYMGMT_SELECT_PRIVATE_KEY, OSSL_KEYMGMT_SELECT_PUBLIC_KEY, + OSSL_KEYMGMT_SELECT_ALL_PARAMETERS}; size_t i; OQS_DEC_PRINTF3("OQS DEC provider: der2key_check_selection called with " @@ -280,7 +287,8 @@ static int der2key_check_selection(int selection, static int oqs_der2key_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, OSSL_CALLBACK *data_cb, void *data_cbarg, - OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg) { + OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg) +{ struct der2key_ctx_st *ctx = vctx; unsigned char *der = NULL; const unsigned char *derp; @@ -348,8 +356,8 @@ static int oqs_der2key_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, * classes of key types that have subtle variants, like RSA-PSS keys as * opposed to plain RSA keys. */ - if (key != NULL && ctx->desc->check_key != NULL && - !ctx->desc->check_key(key, ctx)) { + if (key != NULL && ctx->desc->check_key != NULL + && !ctx->desc->check_key(key, ctx)) { ctx->desc->free_key(key); key = NULL; } @@ -376,8 +384,8 @@ static int oqs_der2key_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, OSSL_PARAM params[4]; int object_type = OSSL_OBJECT_PKEY; - params[0] = - OSSL_PARAM_construct_int(OSSL_OBJECT_PARAM_TYPE, &object_type); + params[0] + = OSSL_PARAM_construct_int(OSSL_OBJECT_PARAM_TYPE, &object_type); params[1] = OSSL_PARAM_construct_utf8_string( OSSL_OBJECT_PARAM_DATA_TYPE, (char *)ctx->desc->keytype_name, 0); /* The address of the key becomes the octet string */ @@ -397,10 +405,11 @@ static int oqs_der2key_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, static int der2key_export_object(void *vctx, const void *reference, size_t reference_sz, OSSL_CALLBACK *export_cb, - void *export_cbarg) { + void *export_cbarg) +{ struct der2key_ctx_st *ctx = vctx; - OSSL_FUNC_keymgmt_export_fn *export = - oqs_prov_get_keymgmt_export(ctx->desc->fns); + OSSL_FUNC_keymgmt_export_fn *export + = oqs_prov_get_keymgmt_export(ctx->desc->fns); void *keydata; OQS_DEC_PRINTF("OQS DEC provider: der2key_export_object called.\n"); @@ -417,14 +426,16 @@ static int der2key_export_object(void *vctx, const void *reference, /* ---------------------------------------------------------------------- */ static void *oqsx_d2i_PKCS8(void **key, const unsigned char **der, long der_len, - struct der2key_ctx_st *ctx) { + struct der2key_ctx_st *ctx) +{ OQS_DEC_PRINTF("OQS DEC provider: oqsx_d2i_PKCS8 called.\n"); return oqs_der2key_decode_p8(der, der_len, ctx, (key_from_pkcs8_t *)oqsx_key_from_pkcs8); } -static void oqsx_key_adjust(void *key, struct der2key_ctx_st *ctx) { +static void oqsx_key_adjust(void *key, struct der2key_ctx_st *ctx) +{ OQS_DEC_PRINTF("OQS DEC provider: oqsx_key_adjust called.\n"); oqsx_key_set0_libctx(key, PROV_OQS_LIBCTX_OF(ctx->provctx)); @@ -443,37 +454,37 @@ static void oqsx_key_adjust(void *key, struct der2key_ctx_st *ctx) { "type-specific", 0, (OSSL_KEYMGMT_SELECT_KEYPAIR), NULL, NULL, NULL, NULL, \ NULL, NULL, oqsx_key_adjust, (free_key_fn *)oqsx_key_free -#define DO_type_specific_pub(keytype) \ - "type-specific", 0, (OSSL_KEYMGMT_SELECT_PUBLIC_KEY), NULL, NULL, NULL, \ +#define DO_type_specific_pub(keytype) \ + "type-specific", 0, (OSSL_KEYMGMT_SELECT_PUBLIC_KEY), NULL, NULL, NULL, \ NULL, NULL, NULL, oqsx_key_adjust, (free_key_fn *)oqsx_key_free -#define DO_type_specific_priv(keytype) \ - "type-specific", 0, (OSSL_KEYMGMT_SELECT_PRIVATE_KEY), NULL, NULL, NULL, \ +#define DO_type_specific_priv(keytype) \ + "type-specific", 0, (OSSL_KEYMGMT_SELECT_PRIVATE_KEY), NULL, NULL, NULL, \ NULL, NULL, NULL, oqsx_key_adjust, (free_key_fn *)oqsx_key_free -#define DO_type_specific_params(keytype) \ - "type-specific", 0, (OSSL_KEYMGMT_SELECT_ALL_PARAMETERS), NULL, NULL, \ +#define DO_type_specific_params(keytype) \ + "type-specific", 0, (OSSL_KEYMGMT_SELECT_ALL_PARAMETERS), NULL, NULL, \ NULL, NULL, NULL, NULL, oqsx_key_adjust, (free_key_fn *)oqsx_key_free -#define DO_type_specific(keytype) \ - "type-specific", 0, (OSSL_KEYMGMT_SELECT_ALL), NULL, NULL, NULL, NULL, \ +#define DO_type_specific(keytype) \ + "type-specific", 0, (OSSL_KEYMGMT_SELECT_ALL), NULL, NULL, NULL, NULL, \ NULL, NULL, oqsx_key_adjust, (free_key_fn *)oqsx_key_free -#define DO_type_specific_no_pub(keytype) \ - "type-specific", 0, \ - (OSSL_KEYMGMT_SELECT_PRIVATE_KEY | \ - OSSL_KEYMGMT_SELECT_ALL_PARAMETERS), \ - NULL, NULL, NULL, NULL, NULL, NULL, oqsx_key_adjust, \ +#define DO_type_specific_no_pub(keytype) \ + "type-specific", 0, \ + (OSSL_KEYMGMT_SELECT_PRIVATE_KEY \ + | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS), \ + NULL, NULL, NULL, NULL, NULL, NULL, oqsx_key_adjust, \ (free_key_fn *)oqsx_key_free -#define DO_PrivateKeyInfo(keytype) \ - "PrivateKeyInfo", 0, (OSSL_KEYMGMT_SELECT_PRIVATE_KEY), NULL, NULL, NULL, \ - oqsx_d2i_PKCS8, NULL, NULL, oqsx_key_adjust, \ +#define DO_PrivateKeyInfo(keytype) \ + "PrivateKeyInfo", 0, (OSSL_KEYMGMT_SELECT_PRIVATE_KEY), NULL, NULL, NULL, \ + oqsx_d2i_PKCS8, NULL, NULL, oqsx_key_adjust, \ (free_key_fn *)oqsx_key_free -#define DO_SubjectPublicKeyInfo(keytype) \ - "SubjectPublicKeyInfo", 0, (OSSL_KEYMGMT_SELECT_PUBLIC_KEY), NULL, NULL, \ - NULL, NULL, (d2i_of_void *)oqsx_d2i_PUBKEY, NULL, oqsx_key_adjust, \ +#define DO_SubjectPublicKeyInfo(keytype) \ + "SubjectPublicKeyInfo", 0, (OSSL_KEYMGMT_SELECT_PUBLIC_KEY), NULL, NULL, \ + NULL, NULL, (d2i_of_void *)oqsx_d2i_PUBKEY, NULL, oqsx_key_adjust, \ (free_key_fn *)oqsx_key_free /* @@ -495,33 +506,35 @@ static void oqsx_key_adjust(void *key, struct der2key_ctx_st *ctx) { * structure. */ // reverted const to be able to change NID/evp_type after assignment -#define MAKE_DECODER(oqskemhyb, keytype_name, keytype, type, kind) \ - static struct keytype_desc_st kind##_##keytype##_desc = { \ - keytype_name, oqs##oqskemhyb##_##keytype##_keymgmt_functions, \ - DO_##kind(keytype)}; \ - \ - static OSSL_FUNC_decoder_newctx_fn kind##_der2##keytype##_newctx; \ - \ - static void *kind##_der2##keytype##_newctx(void *provctx) { \ - OQS_DEC_PRINTF("OQS DEC provider: _newctx called.\n"); \ - return der2key_newctx(provctx, &kind##_##keytype##_desc, \ - keytype_name); \ - } \ - static int kind##_der2##keytype##_does_selection(void *provctx, \ - int selection) { \ - OQS_DEC_PRINTF("OQS DEC provider: _does_selection called.\n"); \ - return der2key_check_selection(selection, &kind##_##keytype##_desc); \ - } \ - const OSSL_DISPATCH oqs_##kind##_der_to_##keytype##_decoder_functions[] = \ - {{OSSL_FUNC_DECODER_NEWCTX, \ - (void (*)(void))kind##_der2##keytype##_newctx}, \ - {OSSL_FUNC_DECODER_FREECTX, (void (*)(void))der2key_freectx}, \ - {OSSL_FUNC_DECODER_DOES_SELECTION, \ - (void (*)(void))kind##_der2##keytype##_does_selection}, \ - {OSSL_FUNC_DECODER_DECODE, (void (*)(void))oqs_der2key_decode}, \ - {OSSL_FUNC_DECODER_EXPORT_OBJECT, \ - (void (*)(void))der2key_export_object}, \ - {0, NULL}} +#define MAKE_DECODER(oqskemhyb, keytype_name, keytype, type, kind) \ + static struct keytype_desc_st kind##_##keytype##_desc \ + = {keytype_name, oqs##oqskemhyb##_##keytype##_keymgmt_functions, \ + DO_##kind(keytype)}; \ + \ + static OSSL_FUNC_decoder_newctx_fn kind##_der2##keytype##_newctx; \ + \ + static void *kind##_der2##keytype##_newctx(void *provctx) \ + { \ + OQS_DEC_PRINTF("OQS DEC provider: _newctx called.\n"); \ + return der2key_newctx(provctx, &kind##_##keytype##_desc, \ + keytype_name); \ + } \ + static int kind##_der2##keytype##_does_selection(void *provctx, \ + int selection) \ + { \ + OQS_DEC_PRINTF("OQS DEC provider: _does_selection called.\n"); \ + return der2key_check_selection(selection, &kind##_##keytype##_desc); \ + } \ + const OSSL_DISPATCH oqs_##kind##_der_to_##keytype##_decoder_functions[] \ + = {{OSSL_FUNC_DECODER_NEWCTX, \ + (void (*)(void))kind##_der2##keytype##_newctx}, \ + {OSSL_FUNC_DECODER_FREECTX, (void (*)(void))der2key_freectx}, \ + {OSSL_FUNC_DECODER_DOES_SELECTION, \ + (void (*)(void))kind##_der2##keytype##_does_selection}, \ + {OSSL_FUNC_DECODER_DECODE, (void (*)(void))oqs_der2key_decode}, \ + {OSSL_FUNC_DECODER_EXPORT_OBJECT, \ + (void (*)(void))der2key_export_object}, \ + {0, NULL}} ///// OQS_TEMPLATE_FRAGMENT_DECODER_MAKE_START #ifdef OQS_KEM_ENCODERS diff --git a/oqsprov/oqs_encode_key2any.c b/oqsprov/oqs_encode_key2any.c index 55ffbfc8..72061eb3 100644 --- a/oqsprov/oqs_encode_key2any.c +++ b/oqsprov/oqs_encode_key2any.c @@ -27,19 +27,19 @@ #include "oqs_prov.h" #ifdef NDEBUG -#define OQS_ENC_PRINTF(a) -#define OQS_ENC_PRINTF2(a, b) -#define OQS_ENC_PRINTF3(a, b, c) +# define OQS_ENC_PRINTF(a) +# define OQS_ENC_PRINTF2(a, b) +# define OQS_ENC_PRINTF3(a, b, c) #else -#define OQS_ENC_PRINTF(a) \ - if (getenv("OQSENC")) \ - printf(a) -#define OQS_ENC_PRINTF2(a, b) \ - if (getenv("OQSENC")) \ - printf(a, b) -#define OQS_ENC_PRINTF3(a, b, c) \ - if (getenv("OQSENC")) \ - printf(a, b, c) +# define OQS_ENC_PRINTF(a) \ + if (getenv("OQSENC")) \ + printf(a) +# define OQS_ENC_PRINTF2(a, b) \ + if (getenv("OQSENC")) \ + printf(a, b) +# define OQS_ENC_PRINTF3(a, b, c) \ + if (getenv("OQSENC")) \ + printf(a, b, c) #endif // NDEBUG struct key2any_ctx_st { @@ -66,7 +66,8 @@ typedef int key_to_der_fn(BIO *out, const void *key, int key_nid, typedef int write_bio_of_void_fn(BIO *bp, const void *x); /* Free the blob allocated during key_to_paramstring_fn */ -static void free_asn1_data(int type, void *data) { +static void free_asn1_data(int type, void *data) +{ switch (type) { case V_ASN1_OBJECT: ASN1_OBJECT_free(data); @@ -79,7 +80,8 @@ static void free_asn1_data(int type, void *data) { static PKCS8_PRIV_KEY_INFO *key_to_p8info(const void *key, int key_nid, void *params, int params_type, - i2d_of_void *k2d) { + i2d_of_void *k2d) +{ /* der, derlen store the key DER output and its length */ unsigned char *der = NULL; int derlen; @@ -88,13 +90,13 @@ static PKCS8_PRIV_KEY_INFO *key_to_p8info(const void *key, int key_nid, OQS_ENC_PRINTF("OQS ENC provider: key_to_p8info called\n"); - if ((p8info = PKCS8_PRIV_KEY_INFO_new()) == NULL || - (derlen = k2d(key, &der)) <= 0 || - !PKCS8_pkey_set0(p8info, OBJ_nid2obj(key_nid), 0, - // doesn't work with oqs-openssl: - // params_type, params, - // does work/interop: - V_ASN1_UNDEF, NULL, der, derlen)) { + if ((p8info = PKCS8_PRIV_KEY_INFO_new()) == NULL + || (derlen = k2d(key, &der)) <= 0 + || !PKCS8_pkey_set0(p8info, OBJ_nid2obj(key_nid), 0, + // doesn't work with oqs-openssl: + // params_type, params, + // does work/interop: + V_ASN1_UNDEF, NULL, der, derlen)) { ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE); PKCS8_PRIV_KEY_INFO_free(p8info); OPENSSL_free(der); @@ -105,7 +107,8 @@ static PKCS8_PRIV_KEY_INFO *key_to_p8info(const void *key, int key_nid, } static X509_SIG *p8info_to_encp8(PKCS8_PRIV_KEY_INFO *p8info, - struct key2any_ctx_st *ctx) { + struct key2any_ctx_st *ctx) +{ X509_SIG *p8 = NULL; char kstr[PEM_BUFSIZE]; size_t klen = 0; @@ -129,9 +132,10 @@ static X509_SIG *p8info_to_encp8(PKCS8_PRIV_KEY_INFO *p8info, static X509_SIG *key_to_encp8(const void *key, int key_nid, void *params, int params_type, i2d_of_void *k2d, - struct key2any_ctx_st *ctx) { - PKCS8_PRIV_KEY_INFO *p8info = - key_to_p8info(key, key_nid, params, params_type, k2d); + struct key2any_ctx_st *ctx) +{ + PKCS8_PRIV_KEY_INFO *p8info + = key_to_p8info(key, key_nid, params, params_type, k2d); X509_SIG *p8 = NULL; OQS_ENC_PRINTF("OQS ENC provider: key_to_encp8 called\n"); @@ -147,7 +151,8 @@ static X509_SIG *key_to_encp8(const void *key, int key_nid, void *params, static X509_PUBKEY *oqsx_key_to_pubkey(const void *key, int key_nid, void *params, int params_type, - i2d_of_void k2d) { + i2d_of_void k2d) +{ /* der, derlen store the key DER output and its length */ unsigned char *der = NULL; int derlen; @@ -157,8 +162,8 @@ static X509_PUBKEY *oqsx_key_to_pubkey(const void *key, int key_nid, OQS_ENC_PRINTF2("OQS ENC provider: oqsx_key_to_pubkey called for NID %d\n", key_nid); - if ((xpk = X509_PUBKEY_new()) == NULL || (derlen = k2d(key, &der)) <= 0 || - !X509_PUBKEY_set0_param( + if ((xpk = X509_PUBKEY_new()) == NULL || (derlen = k2d(key, &der)) <= 0 + || !X509_PUBKEY_set0_param( xpk, OBJ_nid2obj(key_nid), V_ASN1_UNDEF, NULL, // as per logic in oqs_meth.c in oqs-openssl der, derlen)) { @@ -194,7 +199,8 @@ static int key_to_epki_der_priv_bio(BIO *out, const void *key, int key_nid, ossl_unused const char *pemname, key_to_paramstring_fn *p2s, i2d_of_void *k2d, - struct key2any_ctx_st *ctx) { + struct key2any_ctx_st *ctx) +{ int ret = 0; void *str = NULL; int strtype = V_ASN1_UNDEF; @@ -221,7 +227,8 @@ static int key_to_epki_pem_priv_bio(BIO *out, const void *key, int key_nid, ossl_unused const char *pemname, key_to_paramstring_fn *p2s, i2d_of_void *k2d, - struct key2any_ctx_st *ctx) { + struct key2any_ctx_st *ctx) +{ int ret = 0; void *str = NULL; int strtype = V_ASN1_UNDEF; @@ -247,7 +254,8 @@ static int key_to_epki_pem_priv_bio(BIO *out, const void *key, int key_nid, static int key_to_pki_der_priv_bio(BIO *out, const void *key, int key_nid, ossl_unused const char *pemname, key_to_paramstring_fn *p2s, i2d_of_void *k2d, - struct key2any_ctx_st *ctx) { + struct key2any_ctx_st *ctx) +{ int ret = 0; void *str = NULL; int strtype = V_ASN1_UNDEF; @@ -277,7 +285,8 @@ static int key_to_pki_der_priv_bio(BIO *out, const void *key, int key_nid, static int key_to_pki_pem_priv_bio(BIO *out, const void *key, int key_nid, ossl_unused const char *pemname, key_to_paramstring_fn *p2s, i2d_of_void *k2d, - struct key2any_ctx_st *ctx) { + struct key2any_ctx_st *ctx) +{ int ret = 0, cmp_len = 0; void *str = NULL; int strtype = V_ASN1_UNDEF; @@ -306,7 +315,8 @@ static int key_to_pki_pem_priv_bio(BIO *out, const void *key, int key_nid, static int key_to_spki_der_pub_bio(BIO *out, const void *key, int key_nid, ossl_unused const char *pemname, key_to_paramstring_fn *p2s, i2d_of_void *k2d, - struct key2any_ctx_st *ctx) { + struct key2any_ctx_st *ctx) +{ int ret = 0; OQSX_KEY *okey = (OQSX_KEY *)key; X509_PUBKEY *xpk = NULL; @@ -330,7 +340,8 @@ static int key_to_spki_der_pub_bio(BIO *out, const void *key, int key_nid, static int key_to_spki_pem_pub_bio(BIO *out, const void *key, int key_nid, ossl_unused const char *pemname, key_to_paramstring_fn *p2s, i2d_of_void *k2d, - struct key2any_ctx_st *ctx) { + struct key2any_ctx_st *ctx) +{ int ret = 0; X509_PUBKEY *xpk = NULL; void *str = NULL; @@ -451,7 +462,8 @@ called\n"); /* ---------------------------------------------------------------------- */ static int prepare_oqsx_params(const void *oqsxkey, int nid, int save, - void **pstr, int *pstrtype) { + void **pstr, int *pstrtype) +{ ASN1_OBJECT *params = NULL; OQSX_KEY *k = (OQSX_KEY *)oqsxkey; @@ -484,7 +496,8 @@ static int prepare_oqsx_params(const void *oqsxkey, int nid, int save, return 1; } -static int oqsx_spki_pub_to_der(const void *vxkey, unsigned char **pder) { +static int oqsx_spki_pub_to_der(const void *vxkey, unsigned char **pder) +{ const OQSX_KEY *oqsxkey = vxkey; unsigned char *keyblob, *buf; int keybloblen, nid, buflen = 0; @@ -509,12 +522,12 @@ static int oqsx_spki_pub_to_der(const void *vxkey, unsigned char **pder) { } else { if ((sk = sk_ASN1_TYPE_new_null()) == NULL) return -1; - ASN1_TYPE **aType = - OPENSSL_malloc(oqsxkey->numkeys * sizeof(ASN1_TYPE *)); - ASN1_BIT_STRING **aString = - OPENSSL_malloc(oqsxkey->numkeys * sizeof(ASN1_BIT_STRING *)); - unsigned char **temp = - OPENSSL_malloc(oqsxkey->numkeys * sizeof(unsigned char *)); + ASN1_TYPE **aType + = OPENSSL_malloc(oqsxkey->numkeys * sizeof(ASN1_TYPE *)); + ASN1_BIT_STRING **aString + = OPENSSL_malloc(oqsxkey->numkeys * sizeof(ASN1_BIT_STRING *)); + unsigned char **temp + = OPENSSL_malloc(oqsxkey->numkeys * sizeof(unsigned char *)); size_t *templen = OPENSSL_malloc(oqsxkey->numkeys * sizeof(size_t)); int i; @@ -573,7 +586,8 @@ static int oqsx_spki_pub_to_der(const void *vxkey, unsigned char **pder) { } } -static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { +static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) +{ OQSX_KEY *oqsxkey = (OQSX_KEY *)vxkey; unsigned char *buf = NULL; uint32_t buflen = 0, privkeylen = 0; @@ -603,18 +617,18 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { privkeylen = oqsxkey->privkeylen; if (oqsxkey->numkeys > 1) { // hybrid uint32_t actualprivkeylen = 0; - size_t fixed_pq_privkeylen = - oqsxkey->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key; - size_t space_for_classical_privkey = - privkeylen - SIZE_OF_UINT32 - fixed_pq_privkeylen; + size_t fixed_pq_privkeylen + = oqsxkey->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key; + size_t space_for_classical_privkey + = privkeylen - SIZE_OF_UINT32 - fixed_pq_privkeylen; DECODE_UINT32(actualprivkeylen, oqsxkey->privkey); - if ((actualprivkeylen > oqsxkey->evp_info->length_private_key) || - (actualprivkeylen > space_for_classical_privkey)) { + if ((actualprivkeylen > oqsxkey->evp_info->length_private_key) + || (actualprivkeylen > space_for_classical_privkey)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); return 0; } - privkeylen -= - (oqsxkey->evp_info->length_private_key - actualprivkeylen); + privkeylen + -= (oqsxkey->evp_info->length_private_key - actualprivkeylen); } #ifdef NOPUBKEY_IN_PRIVKEY buflen = privkeylen; @@ -659,12 +673,12 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { } OPENSSL_secure_clear_free(buf, buflen); } else { - ASN1_TYPE **aType = - OPENSSL_malloc(oqsxkey->numkeys * sizeof(ASN1_TYPE *)); - ASN1_OCTET_STRING **aString = - OPENSSL_malloc(oqsxkey->numkeys * sizeof(ASN1_OCTET_STRING *)); - unsigned char **temp = - OPENSSL_malloc(oqsxkey->numkeys * sizeof(unsigned char *)); + ASN1_TYPE **aType + = OPENSSL_malloc(oqsxkey->numkeys * sizeof(ASN1_TYPE *)); + ASN1_OCTET_STRING **aString + = OPENSSL_malloc(oqsxkey->numkeys * sizeof(ASN1_OCTET_STRING *)); + unsigned char **temp + = OPENSSL_malloc(oqsxkey->numkeys * sizeof(unsigned char *)); size_t *templen = OPENSSL_malloc(oqsxkey->numkeys * sizeof(size_t)); PKCS8_PRIV_KEY_INFO *p8inf_internal = NULL; sk = sk_ASN1_TYPE_new_null(); @@ -689,8 +703,8 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { int nid, version; void *pval; - if ((name = get_cmpname(OBJ_sn2nid(oqsxkey->tls_name), i)) == - NULL) { + if ((name = get_cmpname(OBJ_sn2nid(oqsxkey->tls_name), i)) + == NULL) { for (int j = 0; j <= i; j++) { OPENSSL_cleanse(aString[j]->data, aString[j]->length); ASN1_OCTET_STRING_free(aString[j]); @@ -714,8 +728,8 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { } if (get_oqsname_fromtls(name) == 0) { - nid = - oqsxkey->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->keytype; + nid = oqsxkey->oqsx_provider_ctx.oqsx_evp_ctx->evp_info + ->keytype; if (nid == EVP_PKEY_RSA) { // get the RSA real key size unsigned char *enc_len = (unsigned char *)OPENSSL_strndup( oqsxkey->comp_privkey[i], 4); @@ -779,8 +793,8 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE); return -1; } - if (get_oqsname_fromtls(name) != - 0) { // include pubkey in privkey for PQC + if (get_oqsname_fromtls(name) + != 0) { // include pubkey in privkey for PQC memcpy(buf, oqsxkey->comp_privkey[i], oqsxkey->privkeylen_cmp[i]); memcpy(buf + oqsxkey->privkeylen_cmp[i], @@ -824,10 +838,10 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { return -1; } - templen[i] = - i2d_PKCS8_PRIV_KEY_INFO(p8inf_internal, - &temp[i]); // create the privkey info - // for each individual key + templen[i] + = i2d_PKCS8_PRIV_KEY_INFO(p8inf_internal, + &temp[i]); // create the privkey info + // for each individual key ASN1_STRING_set(aString[i], temp[i], templen[i]); // add privkey info as ASN1_STRING ASN1_TYPE_set1(aType[i], V_ASN1_SEQUENCE, @@ -893,356 +907,356 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { // OQS provider uses NIDs generated at load time as EVP_type identifiers // so initially this must be 0 and set to a real value by OBJ_sn2nid later ///// OQS_TEMPLATE_FRAGMENT_ENCODER_DEFINES_START -#define frodo640aes_evp_type 0 +#define frodo640aes_evp_type 0 #define frodo640aes_input_type "frodo640aes" -#define frodo640aes_pem_type "frodo640aes" +#define frodo640aes_pem_type "frodo640aes" -#define p256_frodo640aes_evp_type 0 -#define p256_frodo640aes_input_type "p256_frodo640aes" -#define p256_frodo640aes_pem_type "p256_frodo640aes" -#define x25519_frodo640aes_evp_type 0 +#define p256_frodo640aes_evp_type 0 +#define p256_frodo640aes_input_type "p256_frodo640aes" +#define p256_frodo640aes_pem_type "p256_frodo640aes" +#define x25519_frodo640aes_evp_type 0 #define x25519_frodo640aes_input_type "x25519_frodo640aes" -#define x25519_frodo640aes_pem_type "x25519_frodo640aes" -#define frodo640shake_evp_type 0 -#define frodo640shake_input_type "frodo640shake" -#define frodo640shake_pem_type "frodo640shake" - -#define p256_frodo640shake_evp_type 0 -#define p256_frodo640shake_input_type "p256_frodo640shake" -#define p256_frodo640shake_pem_type "p256_frodo640shake" -#define x25519_frodo640shake_evp_type 0 +#define x25519_frodo640aes_pem_type "x25519_frodo640aes" +#define frodo640shake_evp_type 0 +#define frodo640shake_input_type "frodo640shake" +#define frodo640shake_pem_type "frodo640shake" + +#define p256_frodo640shake_evp_type 0 +#define p256_frodo640shake_input_type "p256_frodo640shake" +#define p256_frodo640shake_pem_type "p256_frodo640shake" +#define x25519_frodo640shake_evp_type 0 #define x25519_frodo640shake_input_type "x25519_frodo640shake" -#define x25519_frodo640shake_pem_type "x25519_frodo640shake" -#define frodo976aes_evp_type 0 -#define frodo976aes_input_type "frodo976aes" -#define frodo976aes_pem_type "frodo976aes" +#define x25519_frodo640shake_pem_type "x25519_frodo640shake" +#define frodo976aes_evp_type 0 +#define frodo976aes_input_type "frodo976aes" +#define frodo976aes_pem_type "frodo976aes" -#define p384_frodo976aes_evp_type 0 +#define p384_frodo976aes_evp_type 0 #define p384_frodo976aes_input_type "p384_frodo976aes" -#define p384_frodo976aes_pem_type "p384_frodo976aes" -#define x448_frodo976aes_evp_type 0 +#define p384_frodo976aes_pem_type "p384_frodo976aes" +#define x448_frodo976aes_evp_type 0 #define x448_frodo976aes_input_type "x448_frodo976aes" -#define x448_frodo976aes_pem_type "x448_frodo976aes" -#define frodo976shake_evp_type 0 -#define frodo976shake_input_type "frodo976shake" -#define frodo976shake_pem_type "frodo976shake" +#define x448_frodo976aes_pem_type "x448_frodo976aes" +#define frodo976shake_evp_type 0 +#define frodo976shake_input_type "frodo976shake" +#define frodo976shake_pem_type "frodo976shake" -#define p384_frodo976shake_evp_type 0 +#define p384_frodo976shake_evp_type 0 #define p384_frodo976shake_input_type "p384_frodo976shake" -#define p384_frodo976shake_pem_type "p384_frodo976shake" -#define x448_frodo976shake_evp_type 0 +#define p384_frodo976shake_pem_type "p384_frodo976shake" +#define x448_frodo976shake_evp_type 0 #define x448_frodo976shake_input_type "x448_frodo976shake" -#define x448_frodo976shake_pem_type "x448_frodo976shake" -#define frodo1344aes_evp_type 0 -#define frodo1344aes_input_type "frodo1344aes" -#define frodo1344aes_pem_type "frodo1344aes" +#define x448_frodo976shake_pem_type "x448_frodo976shake" +#define frodo1344aes_evp_type 0 +#define frodo1344aes_input_type "frodo1344aes" +#define frodo1344aes_pem_type "frodo1344aes" -#define p521_frodo1344aes_evp_type 0 +#define p521_frodo1344aes_evp_type 0 #define p521_frodo1344aes_input_type "p521_frodo1344aes" -#define p521_frodo1344aes_pem_type "p521_frodo1344aes" -#define frodo1344shake_evp_type 0 -#define frodo1344shake_input_type "frodo1344shake" -#define frodo1344shake_pem_type "frodo1344shake" +#define p521_frodo1344aes_pem_type "p521_frodo1344aes" +#define frodo1344shake_evp_type 0 +#define frodo1344shake_input_type "frodo1344shake" +#define frodo1344shake_pem_type "frodo1344shake" -#define p521_frodo1344shake_evp_type 0 +#define p521_frodo1344shake_evp_type 0 #define p521_frodo1344shake_input_type "p521_frodo1344shake" -#define p521_frodo1344shake_pem_type "p521_frodo1344shake" -#define kyber512_evp_type 0 -#define kyber512_input_type "kyber512" -#define kyber512_pem_type "kyber512" - -#define p256_kyber512_evp_type 0 -#define p256_kyber512_input_type "p256_kyber512" -#define p256_kyber512_pem_type "p256_kyber512" -#define x25519_kyber512_evp_type 0 +#define p521_frodo1344shake_pem_type "p521_frodo1344shake" +#define kyber512_evp_type 0 +#define kyber512_input_type "kyber512" +#define kyber512_pem_type "kyber512" + +#define p256_kyber512_evp_type 0 +#define p256_kyber512_input_type "p256_kyber512" +#define p256_kyber512_pem_type "p256_kyber512" +#define x25519_kyber512_evp_type 0 #define x25519_kyber512_input_type "x25519_kyber512" -#define x25519_kyber512_pem_type "x25519_kyber512" -#define kyber768_evp_type 0 -#define kyber768_input_type "kyber768" -#define kyber768_pem_type "kyber768" - -#define p384_kyber768_evp_type 0 -#define p384_kyber768_input_type "p384_kyber768" -#define p384_kyber768_pem_type "p384_kyber768" -#define x448_kyber768_evp_type 0 -#define x448_kyber768_input_type "x448_kyber768" -#define x448_kyber768_pem_type "x448_kyber768" -#define x25519_kyber768_evp_type 0 +#define x25519_kyber512_pem_type "x25519_kyber512" +#define kyber768_evp_type 0 +#define kyber768_input_type "kyber768" +#define kyber768_pem_type "kyber768" + +#define p384_kyber768_evp_type 0 +#define p384_kyber768_input_type "p384_kyber768" +#define p384_kyber768_pem_type "p384_kyber768" +#define x448_kyber768_evp_type 0 +#define x448_kyber768_input_type "x448_kyber768" +#define x448_kyber768_pem_type "x448_kyber768" +#define x25519_kyber768_evp_type 0 #define x25519_kyber768_input_type "x25519_kyber768" -#define x25519_kyber768_pem_type "x25519_kyber768" -#define p256_kyber768_evp_type 0 -#define p256_kyber768_input_type "p256_kyber768" -#define p256_kyber768_pem_type "p256_kyber768" -#define kyber1024_evp_type 0 -#define kyber1024_input_type "kyber1024" -#define kyber1024_pem_type "kyber1024" - -#define p521_kyber1024_evp_type 0 +#define x25519_kyber768_pem_type "x25519_kyber768" +#define p256_kyber768_evp_type 0 +#define p256_kyber768_input_type "p256_kyber768" +#define p256_kyber768_pem_type "p256_kyber768" +#define kyber1024_evp_type 0 +#define kyber1024_input_type "kyber1024" +#define kyber1024_pem_type "kyber1024" + +#define p521_kyber1024_evp_type 0 #define p521_kyber1024_input_type "p521_kyber1024" -#define p521_kyber1024_pem_type "p521_kyber1024" -#define mlkem512_evp_type 0 -#define mlkem512_input_type "mlkem512" -#define mlkem512_pem_type "mlkem512" - -#define p256_mlkem512_evp_type 0 -#define p256_mlkem512_input_type "p256_mlkem512" -#define p256_mlkem512_pem_type "p256_mlkem512" -#define x25519_mlkem512_evp_type 0 +#define p521_kyber1024_pem_type "p521_kyber1024" +#define mlkem512_evp_type 0 +#define mlkem512_input_type "mlkem512" +#define mlkem512_pem_type "mlkem512" + +#define p256_mlkem512_evp_type 0 +#define p256_mlkem512_input_type "p256_mlkem512" +#define p256_mlkem512_pem_type "p256_mlkem512" +#define x25519_mlkem512_evp_type 0 #define x25519_mlkem512_input_type "x25519_mlkem512" -#define x25519_mlkem512_pem_type "x25519_mlkem512" -#define mlkem768_evp_type 0 -#define mlkem768_input_type "mlkem768" -#define mlkem768_pem_type "mlkem768" - -#define p384_mlkem768_evp_type 0 -#define p384_mlkem768_input_type "p384_mlkem768" -#define p384_mlkem768_pem_type "p384_mlkem768" -#define x448_mlkem768_evp_type 0 -#define x448_mlkem768_input_type "x448_mlkem768" -#define x448_mlkem768_pem_type "x448_mlkem768" -#define X25519MLKEM768_evp_type 0 -#define X25519MLKEM768_input_type "X25519MLKEM768" -#define X25519MLKEM768_pem_type "X25519MLKEM768" -#define SecP256r1MLKEM768_evp_type 0 +#define x25519_mlkem512_pem_type "x25519_mlkem512" +#define mlkem768_evp_type 0 +#define mlkem768_input_type "mlkem768" +#define mlkem768_pem_type "mlkem768" + +#define p384_mlkem768_evp_type 0 +#define p384_mlkem768_input_type "p384_mlkem768" +#define p384_mlkem768_pem_type "p384_mlkem768" +#define x448_mlkem768_evp_type 0 +#define x448_mlkem768_input_type "x448_mlkem768" +#define x448_mlkem768_pem_type "x448_mlkem768" +#define X25519MLKEM768_evp_type 0 +#define X25519MLKEM768_input_type "X25519MLKEM768" +#define X25519MLKEM768_pem_type "X25519MLKEM768" +#define SecP256r1MLKEM768_evp_type 0 #define SecP256r1MLKEM768_input_type "SecP256r1MLKEM768" -#define SecP256r1MLKEM768_pem_type "SecP256r1MLKEM768" -#define mlkem1024_evp_type 0 -#define mlkem1024_input_type "mlkem1024" -#define mlkem1024_pem_type "mlkem1024" +#define SecP256r1MLKEM768_pem_type "SecP256r1MLKEM768" +#define mlkem1024_evp_type 0 +#define mlkem1024_input_type "mlkem1024" +#define mlkem1024_pem_type "mlkem1024" -#define p521_mlkem1024_evp_type 0 +#define p521_mlkem1024_evp_type 0 #define p521_mlkem1024_input_type "p521_mlkem1024" -#define p521_mlkem1024_pem_type "p521_mlkem1024" -#define p384_mlkem1024_evp_type 0 +#define p521_mlkem1024_pem_type "p521_mlkem1024" +#define p384_mlkem1024_evp_type 0 #define p384_mlkem1024_input_type "p384_mlkem1024" -#define p384_mlkem1024_pem_type "p384_mlkem1024" -#define bikel1_evp_type 0 -#define bikel1_input_type "bikel1" -#define bikel1_pem_type "bikel1" - -#define p256_bikel1_evp_type 0 -#define p256_bikel1_input_type "p256_bikel1" -#define p256_bikel1_pem_type "p256_bikel1" -#define x25519_bikel1_evp_type 0 +#define p384_mlkem1024_pem_type "p384_mlkem1024" +#define bikel1_evp_type 0 +#define bikel1_input_type "bikel1" +#define bikel1_pem_type "bikel1" + +#define p256_bikel1_evp_type 0 +#define p256_bikel1_input_type "p256_bikel1" +#define p256_bikel1_pem_type "p256_bikel1" +#define x25519_bikel1_evp_type 0 #define x25519_bikel1_input_type "x25519_bikel1" -#define x25519_bikel1_pem_type "x25519_bikel1" -#define bikel3_evp_type 0 -#define bikel3_input_type "bikel3" -#define bikel3_pem_type "bikel3" +#define x25519_bikel1_pem_type "x25519_bikel1" +#define bikel3_evp_type 0 +#define bikel3_input_type "bikel3" +#define bikel3_pem_type "bikel3" -#define p384_bikel3_evp_type 0 +#define p384_bikel3_evp_type 0 #define p384_bikel3_input_type "p384_bikel3" -#define p384_bikel3_pem_type "p384_bikel3" -#define x448_bikel3_evp_type 0 +#define p384_bikel3_pem_type "p384_bikel3" +#define x448_bikel3_evp_type 0 #define x448_bikel3_input_type "x448_bikel3" -#define x448_bikel3_pem_type "x448_bikel3" -#define bikel5_evp_type 0 -#define bikel5_input_type "bikel5" -#define bikel5_pem_type "bikel5" +#define x448_bikel3_pem_type "x448_bikel3" +#define bikel5_evp_type 0 +#define bikel5_input_type "bikel5" +#define bikel5_pem_type "bikel5" -#define p521_bikel5_evp_type 0 +#define p521_bikel5_evp_type 0 #define p521_bikel5_input_type "p521_bikel5" -#define p521_bikel5_pem_type "p521_bikel5" -#define hqc128_evp_type 0 -#define hqc128_input_type "hqc128" -#define hqc128_pem_type "hqc128" - -#define p256_hqc128_evp_type 0 -#define p256_hqc128_input_type "p256_hqc128" -#define p256_hqc128_pem_type "p256_hqc128" -#define x25519_hqc128_evp_type 0 +#define p521_bikel5_pem_type "p521_bikel5" +#define hqc128_evp_type 0 +#define hqc128_input_type "hqc128" +#define hqc128_pem_type "hqc128" + +#define p256_hqc128_evp_type 0 +#define p256_hqc128_input_type "p256_hqc128" +#define p256_hqc128_pem_type "p256_hqc128" +#define x25519_hqc128_evp_type 0 #define x25519_hqc128_input_type "x25519_hqc128" -#define x25519_hqc128_pem_type "x25519_hqc128" -#define hqc192_evp_type 0 -#define hqc192_input_type "hqc192" -#define hqc192_pem_type "hqc192" +#define x25519_hqc128_pem_type "x25519_hqc128" +#define hqc192_evp_type 0 +#define hqc192_input_type "hqc192" +#define hqc192_pem_type "hqc192" -#define p384_hqc192_evp_type 0 +#define p384_hqc192_evp_type 0 #define p384_hqc192_input_type "p384_hqc192" -#define p384_hqc192_pem_type "p384_hqc192" -#define x448_hqc192_evp_type 0 +#define p384_hqc192_pem_type "p384_hqc192" +#define x448_hqc192_evp_type 0 #define x448_hqc192_input_type "x448_hqc192" -#define x448_hqc192_pem_type "x448_hqc192" -#define hqc256_evp_type 0 -#define hqc256_input_type "hqc256" -#define hqc256_pem_type "hqc256" +#define x448_hqc192_pem_type "x448_hqc192" +#define hqc256_evp_type 0 +#define hqc256_input_type "hqc256" +#define hqc256_pem_type "hqc256" -#define p521_hqc256_evp_type 0 +#define p521_hqc256_evp_type 0 #define p521_hqc256_input_type "p521_hqc256" -#define p521_hqc256_pem_type "p521_hqc256" - -#define dilithium2_evp_type 0 -#define dilithium2_input_type "dilithium2" -#define dilithium2_pem_type "dilithium2" -#define p256_dilithium2_evp_type 0 -#define p256_dilithium2_input_type "p256_dilithium2" -#define p256_dilithium2_pem_type "p256_dilithium2" -#define rsa3072_dilithium2_evp_type 0 -#define rsa3072_dilithium2_input_type "rsa3072_dilithium2" -#define rsa3072_dilithium2_pem_type "rsa3072_dilithium2" -#define dilithium3_evp_type 0 -#define dilithium3_input_type "dilithium3" -#define dilithium3_pem_type "dilithium3" -#define p384_dilithium3_evp_type 0 -#define p384_dilithium3_input_type "p384_dilithium3" -#define p384_dilithium3_pem_type "p384_dilithium3" -#define dilithium5_evp_type 0 -#define dilithium5_input_type "dilithium5" -#define dilithium5_pem_type "dilithium5" -#define p521_dilithium5_evp_type 0 -#define p521_dilithium5_input_type "p521_dilithium5" -#define p521_dilithium5_pem_type "p521_dilithium5" -#define mldsa44_evp_type 0 -#define mldsa44_input_type "mldsa44" -#define mldsa44_pem_type "mldsa44" -#define p256_mldsa44_evp_type 0 -#define p256_mldsa44_input_type "p256_mldsa44" -#define p256_mldsa44_pem_type "p256_mldsa44" -#define rsa3072_mldsa44_evp_type 0 -#define rsa3072_mldsa44_input_type "rsa3072_mldsa44" -#define rsa3072_mldsa44_pem_type "rsa3072_mldsa44" -#define mldsa44_pss2048_evp_type 0 -#define mldsa44_pss2048_input_type "mldsa44_pss2048" -#define mldsa44_pss2048_pem_type "mldsa44_pss2048" -#define mldsa44_rsa2048_evp_type 0 -#define mldsa44_rsa2048_input_type "mldsa44_rsa2048" -#define mldsa44_rsa2048_pem_type "mldsa44_rsa2048" -#define mldsa44_ed25519_evp_type 0 -#define mldsa44_ed25519_input_type "mldsa44_ed25519" -#define mldsa44_ed25519_pem_type "mldsa44_ed25519" -#define mldsa44_p256_evp_type 0 -#define mldsa44_p256_input_type "mldsa44_p256" -#define mldsa44_p256_pem_type "mldsa44_p256" -#define mldsa44_bp256_evp_type 0 -#define mldsa44_bp256_input_type "mldsa44_bp256" -#define mldsa44_bp256_pem_type "mldsa44_bp256" -#define mldsa65_evp_type 0 -#define mldsa65_input_type "mldsa65" -#define mldsa65_pem_type "mldsa65" -#define p384_mldsa65_evp_type 0 -#define p384_mldsa65_input_type "p384_mldsa65" -#define p384_mldsa65_pem_type "p384_mldsa65" -#define mldsa65_pss3072_evp_type 0 -#define mldsa65_pss3072_input_type "mldsa65_pss3072" -#define mldsa65_pss3072_pem_type "mldsa65_pss3072" -#define mldsa65_rsa3072_evp_type 0 -#define mldsa65_rsa3072_input_type "mldsa65_rsa3072" -#define mldsa65_rsa3072_pem_type "mldsa65_rsa3072" -#define mldsa65_p256_evp_type 0 -#define mldsa65_p256_input_type "mldsa65_p256" -#define mldsa65_p256_pem_type "mldsa65_p256" -#define mldsa65_bp256_evp_type 0 -#define mldsa65_bp256_input_type "mldsa65_bp256" -#define mldsa65_bp256_pem_type "mldsa65_bp256" -#define mldsa65_ed25519_evp_type 0 -#define mldsa65_ed25519_input_type "mldsa65_ed25519" -#define mldsa65_ed25519_pem_type "mldsa65_ed25519" -#define mldsa87_evp_type 0 -#define mldsa87_input_type "mldsa87" -#define mldsa87_pem_type "mldsa87" -#define p521_mldsa87_evp_type 0 -#define p521_mldsa87_input_type "p521_mldsa87" -#define p521_mldsa87_pem_type "p521_mldsa87" -#define mldsa87_p384_evp_type 0 -#define mldsa87_p384_input_type "mldsa87_p384" -#define mldsa87_p384_pem_type "mldsa87_p384" -#define mldsa87_bp384_evp_type 0 -#define mldsa87_bp384_input_type "mldsa87_bp384" -#define mldsa87_bp384_pem_type "mldsa87_bp384" -#define mldsa87_ed448_evp_type 0 -#define mldsa87_ed448_input_type "mldsa87_ed448" -#define mldsa87_ed448_pem_type "mldsa87_ed448" -#define falcon512_evp_type 0 -#define falcon512_input_type "falcon512" -#define falcon512_pem_type "falcon512" -#define p256_falcon512_evp_type 0 -#define p256_falcon512_input_type "p256_falcon512" -#define p256_falcon512_pem_type "p256_falcon512" -#define rsa3072_falcon512_evp_type 0 -#define rsa3072_falcon512_input_type "rsa3072_falcon512" -#define rsa3072_falcon512_pem_type "rsa3072_falcon512" -#define falconpadded512_evp_type 0 -#define falconpadded512_input_type "falconpadded512" -#define falconpadded512_pem_type "falconpadded512" -#define p256_falconpadded512_evp_type 0 -#define p256_falconpadded512_input_type "p256_falconpadded512" -#define p256_falconpadded512_pem_type "p256_falconpadded512" -#define rsa3072_falconpadded512_evp_type 0 -#define rsa3072_falconpadded512_input_type "rsa3072_falconpadded512" -#define rsa3072_falconpadded512_pem_type "rsa3072_falconpadded512" -#define falcon1024_evp_type 0 -#define falcon1024_input_type "falcon1024" -#define falcon1024_pem_type "falcon1024" -#define p521_falcon1024_evp_type 0 -#define p521_falcon1024_input_type "p521_falcon1024" -#define p521_falcon1024_pem_type "p521_falcon1024" -#define falconpadded1024_evp_type 0 -#define falconpadded1024_input_type "falconpadded1024" -#define falconpadded1024_pem_type "falconpadded1024" -#define p521_falconpadded1024_evp_type 0 -#define p521_falconpadded1024_input_type "p521_falconpadded1024" -#define p521_falconpadded1024_pem_type "p521_falconpadded1024" -#define sphincssha2128fsimple_evp_type 0 -#define sphincssha2128fsimple_input_type "sphincssha2128fsimple" -#define sphincssha2128fsimple_pem_type "sphincssha2128fsimple" -#define p256_sphincssha2128fsimple_evp_type 0 -#define p256_sphincssha2128fsimple_input_type "p256_sphincssha2128fsimple" -#define p256_sphincssha2128fsimple_pem_type "p256_sphincssha2128fsimple" -#define rsa3072_sphincssha2128fsimple_evp_type 0 +#define p521_hqc256_pem_type "p521_hqc256" + +#define dilithium2_evp_type 0 +#define dilithium2_input_type "dilithium2" +#define dilithium2_pem_type "dilithium2" +#define p256_dilithium2_evp_type 0 +#define p256_dilithium2_input_type "p256_dilithium2" +#define p256_dilithium2_pem_type "p256_dilithium2" +#define rsa3072_dilithium2_evp_type 0 +#define rsa3072_dilithium2_input_type "rsa3072_dilithium2" +#define rsa3072_dilithium2_pem_type "rsa3072_dilithium2" +#define dilithium3_evp_type 0 +#define dilithium3_input_type "dilithium3" +#define dilithium3_pem_type "dilithium3" +#define p384_dilithium3_evp_type 0 +#define p384_dilithium3_input_type "p384_dilithium3" +#define p384_dilithium3_pem_type "p384_dilithium3" +#define dilithium5_evp_type 0 +#define dilithium5_input_type "dilithium5" +#define dilithium5_pem_type "dilithium5" +#define p521_dilithium5_evp_type 0 +#define p521_dilithium5_input_type "p521_dilithium5" +#define p521_dilithium5_pem_type "p521_dilithium5" +#define mldsa44_evp_type 0 +#define mldsa44_input_type "mldsa44" +#define mldsa44_pem_type "mldsa44" +#define p256_mldsa44_evp_type 0 +#define p256_mldsa44_input_type "p256_mldsa44" +#define p256_mldsa44_pem_type "p256_mldsa44" +#define rsa3072_mldsa44_evp_type 0 +#define rsa3072_mldsa44_input_type "rsa3072_mldsa44" +#define rsa3072_mldsa44_pem_type "rsa3072_mldsa44" +#define mldsa44_pss2048_evp_type 0 +#define mldsa44_pss2048_input_type "mldsa44_pss2048" +#define mldsa44_pss2048_pem_type "mldsa44_pss2048" +#define mldsa44_rsa2048_evp_type 0 +#define mldsa44_rsa2048_input_type "mldsa44_rsa2048" +#define mldsa44_rsa2048_pem_type "mldsa44_rsa2048" +#define mldsa44_ed25519_evp_type 0 +#define mldsa44_ed25519_input_type "mldsa44_ed25519" +#define mldsa44_ed25519_pem_type "mldsa44_ed25519" +#define mldsa44_p256_evp_type 0 +#define mldsa44_p256_input_type "mldsa44_p256" +#define mldsa44_p256_pem_type "mldsa44_p256" +#define mldsa44_bp256_evp_type 0 +#define mldsa44_bp256_input_type "mldsa44_bp256" +#define mldsa44_bp256_pem_type "mldsa44_bp256" +#define mldsa65_evp_type 0 +#define mldsa65_input_type "mldsa65" +#define mldsa65_pem_type "mldsa65" +#define p384_mldsa65_evp_type 0 +#define p384_mldsa65_input_type "p384_mldsa65" +#define p384_mldsa65_pem_type "p384_mldsa65" +#define mldsa65_pss3072_evp_type 0 +#define mldsa65_pss3072_input_type "mldsa65_pss3072" +#define mldsa65_pss3072_pem_type "mldsa65_pss3072" +#define mldsa65_rsa3072_evp_type 0 +#define mldsa65_rsa3072_input_type "mldsa65_rsa3072" +#define mldsa65_rsa3072_pem_type "mldsa65_rsa3072" +#define mldsa65_p256_evp_type 0 +#define mldsa65_p256_input_type "mldsa65_p256" +#define mldsa65_p256_pem_type "mldsa65_p256" +#define mldsa65_bp256_evp_type 0 +#define mldsa65_bp256_input_type "mldsa65_bp256" +#define mldsa65_bp256_pem_type "mldsa65_bp256" +#define mldsa65_ed25519_evp_type 0 +#define mldsa65_ed25519_input_type "mldsa65_ed25519" +#define mldsa65_ed25519_pem_type "mldsa65_ed25519" +#define mldsa87_evp_type 0 +#define mldsa87_input_type "mldsa87" +#define mldsa87_pem_type "mldsa87" +#define p521_mldsa87_evp_type 0 +#define p521_mldsa87_input_type "p521_mldsa87" +#define p521_mldsa87_pem_type "p521_mldsa87" +#define mldsa87_p384_evp_type 0 +#define mldsa87_p384_input_type "mldsa87_p384" +#define mldsa87_p384_pem_type "mldsa87_p384" +#define mldsa87_bp384_evp_type 0 +#define mldsa87_bp384_input_type "mldsa87_bp384" +#define mldsa87_bp384_pem_type "mldsa87_bp384" +#define mldsa87_ed448_evp_type 0 +#define mldsa87_ed448_input_type "mldsa87_ed448" +#define mldsa87_ed448_pem_type "mldsa87_ed448" +#define falcon512_evp_type 0 +#define falcon512_input_type "falcon512" +#define falcon512_pem_type "falcon512" +#define p256_falcon512_evp_type 0 +#define p256_falcon512_input_type "p256_falcon512" +#define p256_falcon512_pem_type "p256_falcon512" +#define rsa3072_falcon512_evp_type 0 +#define rsa3072_falcon512_input_type "rsa3072_falcon512" +#define rsa3072_falcon512_pem_type "rsa3072_falcon512" +#define falconpadded512_evp_type 0 +#define falconpadded512_input_type "falconpadded512" +#define falconpadded512_pem_type "falconpadded512" +#define p256_falconpadded512_evp_type 0 +#define p256_falconpadded512_input_type "p256_falconpadded512" +#define p256_falconpadded512_pem_type "p256_falconpadded512" +#define rsa3072_falconpadded512_evp_type 0 +#define rsa3072_falconpadded512_input_type "rsa3072_falconpadded512" +#define rsa3072_falconpadded512_pem_type "rsa3072_falconpadded512" +#define falcon1024_evp_type 0 +#define falcon1024_input_type "falcon1024" +#define falcon1024_pem_type "falcon1024" +#define p521_falcon1024_evp_type 0 +#define p521_falcon1024_input_type "p521_falcon1024" +#define p521_falcon1024_pem_type "p521_falcon1024" +#define falconpadded1024_evp_type 0 +#define falconpadded1024_input_type "falconpadded1024" +#define falconpadded1024_pem_type "falconpadded1024" +#define p521_falconpadded1024_evp_type 0 +#define p521_falconpadded1024_input_type "p521_falconpadded1024" +#define p521_falconpadded1024_pem_type "p521_falconpadded1024" +#define sphincssha2128fsimple_evp_type 0 +#define sphincssha2128fsimple_input_type "sphincssha2128fsimple" +#define sphincssha2128fsimple_pem_type "sphincssha2128fsimple" +#define p256_sphincssha2128fsimple_evp_type 0 +#define p256_sphincssha2128fsimple_input_type "p256_sphincssha2128fsimple" +#define p256_sphincssha2128fsimple_pem_type "p256_sphincssha2128fsimple" +#define rsa3072_sphincssha2128fsimple_evp_type 0 #define rsa3072_sphincssha2128fsimple_input_type "rsa3072_sphincssha2128fsimple" -#define rsa3072_sphincssha2128fsimple_pem_type "rsa3072_sphincssha2128fsimple" -#define sphincssha2128ssimple_evp_type 0 -#define sphincssha2128ssimple_input_type "sphincssha2128ssimple" -#define sphincssha2128ssimple_pem_type "sphincssha2128ssimple" -#define p256_sphincssha2128ssimple_evp_type 0 -#define p256_sphincssha2128ssimple_input_type "p256_sphincssha2128ssimple" -#define p256_sphincssha2128ssimple_pem_type "p256_sphincssha2128ssimple" -#define rsa3072_sphincssha2128ssimple_evp_type 0 +#define rsa3072_sphincssha2128fsimple_pem_type "rsa3072_sphincssha2128fsimple" +#define sphincssha2128ssimple_evp_type 0 +#define sphincssha2128ssimple_input_type "sphincssha2128ssimple" +#define sphincssha2128ssimple_pem_type "sphincssha2128ssimple" +#define p256_sphincssha2128ssimple_evp_type 0 +#define p256_sphincssha2128ssimple_input_type "p256_sphincssha2128ssimple" +#define p256_sphincssha2128ssimple_pem_type "p256_sphincssha2128ssimple" +#define rsa3072_sphincssha2128ssimple_evp_type 0 #define rsa3072_sphincssha2128ssimple_input_type "rsa3072_sphincssha2128ssimple" -#define rsa3072_sphincssha2128ssimple_pem_type "rsa3072_sphincssha2128ssimple" -#define sphincssha2192fsimple_evp_type 0 -#define sphincssha2192fsimple_input_type "sphincssha2192fsimple" -#define sphincssha2192fsimple_pem_type "sphincssha2192fsimple" -#define p384_sphincssha2192fsimple_evp_type 0 -#define p384_sphincssha2192fsimple_input_type "p384_sphincssha2192fsimple" -#define p384_sphincssha2192fsimple_pem_type "p384_sphincssha2192fsimple" -#define sphincsshake128fsimple_evp_type 0 -#define sphincsshake128fsimple_input_type "sphincsshake128fsimple" -#define sphincsshake128fsimple_pem_type "sphincsshake128fsimple" -#define p256_sphincsshake128fsimple_evp_type 0 -#define p256_sphincsshake128fsimple_input_type "p256_sphincsshake128fsimple" -#define p256_sphincsshake128fsimple_pem_type "p256_sphincsshake128fsimple" -#define rsa3072_sphincsshake128fsimple_evp_type 0 -#define rsa3072_sphincsshake128fsimple_input_type \ +#define rsa3072_sphincssha2128ssimple_pem_type "rsa3072_sphincssha2128ssimple" +#define sphincssha2192fsimple_evp_type 0 +#define sphincssha2192fsimple_input_type "sphincssha2192fsimple" +#define sphincssha2192fsimple_pem_type "sphincssha2192fsimple" +#define p384_sphincssha2192fsimple_evp_type 0 +#define p384_sphincssha2192fsimple_input_type "p384_sphincssha2192fsimple" +#define p384_sphincssha2192fsimple_pem_type "p384_sphincssha2192fsimple" +#define sphincsshake128fsimple_evp_type 0 +#define sphincsshake128fsimple_input_type "sphincsshake128fsimple" +#define sphincsshake128fsimple_pem_type "sphincsshake128fsimple" +#define p256_sphincsshake128fsimple_evp_type 0 +#define p256_sphincsshake128fsimple_input_type "p256_sphincsshake128fsimple" +#define p256_sphincsshake128fsimple_pem_type "p256_sphincsshake128fsimple" +#define rsa3072_sphincsshake128fsimple_evp_type 0 +#define rsa3072_sphincsshake128fsimple_input_type \ "rsa3072_sphincsshake128fsimple" #define rsa3072_sphincsshake128fsimple_pem_type "rsa3072_sphincsshake128fsimple" -#define mayo1_evp_type 0 -#define mayo1_input_type "mayo1" -#define mayo1_pem_type "mayo1" -#define p256_mayo1_evp_type 0 -#define p256_mayo1_input_type "p256_mayo1" -#define p256_mayo1_pem_type "p256_mayo1" -#define mayo2_evp_type 0 -#define mayo2_input_type "mayo2" -#define mayo2_pem_type "mayo2" -#define p256_mayo2_evp_type 0 -#define p256_mayo2_input_type "p256_mayo2" -#define p256_mayo2_pem_type "p256_mayo2" -#define mayo3_evp_type 0 -#define mayo3_input_type "mayo3" -#define mayo3_pem_type "mayo3" -#define p384_mayo3_evp_type 0 -#define p384_mayo3_input_type "p384_mayo3" -#define p384_mayo3_pem_type "p384_mayo3" -#define mayo5_evp_type 0 -#define mayo5_input_type "mayo5" -#define mayo5_pem_type "mayo5" -#define p521_mayo5_evp_type 0 -#define p521_mayo5_input_type "p521_mayo5" -#define p521_mayo5_pem_type "p521_mayo5" -#define CROSSrsdp128balanced_evp_type 0 -#define CROSSrsdp128balanced_input_type "CROSSrsdp128balanced" -#define CROSSrsdp128balanced_pem_type "CROSSrsdp128balanced" +#define mayo1_evp_type 0 +#define mayo1_input_type "mayo1" +#define mayo1_pem_type "mayo1" +#define p256_mayo1_evp_type 0 +#define p256_mayo1_input_type "p256_mayo1" +#define p256_mayo1_pem_type "p256_mayo1" +#define mayo2_evp_type 0 +#define mayo2_input_type "mayo2" +#define mayo2_pem_type "mayo2" +#define p256_mayo2_evp_type 0 +#define p256_mayo2_input_type "p256_mayo2" +#define p256_mayo2_pem_type "p256_mayo2" +#define mayo3_evp_type 0 +#define mayo3_input_type "mayo3" +#define mayo3_pem_type "mayo3" +#define p384_mayo3_evp_type 0 +#define p384_mayo3_input_type "p384_mayo3" +#define p384_mayo3_pem_type "p384_mayo3" +#define mayo5_evp_type 0 +#define mayo5_input_type "mayo5" +#define mayo5_pem_type "mayo5" +#define p521_mayo5_evp_type 0 +#define p521_mayo5_input_type "p521_mayo5" +#define p521_mayo5_pem_type "p521_mayo5" +#define CROSSrsdp128balanced_evp_type 0 +#define CROSSrsdp128balanced_input_type "CROSSrsdp128balanced" +#define CROSSrsdp128balanced_pem_type "CROSSrsdp128balanced" ///// OQS_TEMPLATE_FRAGMENT_ENCODER_DEFINES_END /* ---------------------------------------------------------------------- */ @@ -1250,7 +1264,8 @@ static int oqsx_pki_priv_to_der(const void *vxkey, unsigned char **pder) { static OSSL_FUNC_decoder_newctx_fn key2any_newctx; static OSSL_FUNC_decoder_freectx_fn key2any_freectx; -static void *key2any_newctx(void *provctx) { +static void *key2any_newctx(void *provctx) +{ struct key2any_ctx_st *ctx = OPENSSL_zalloc(sizeof(*ctx)); OQS_ENC_PRINTF("OQS ENC provider: key2any_newctx called\n"); @@ -1263,7 +1278,8 @@ static void *key2any_newctx(void *provctx) { return ctx; } -static void key2any_freectx(void *vctx) { +static void key2any_freectx(void *vctx) +{ struct key2any_ctx_st *ctx = vctx; OQS_ENC_PRINTF("OQS ENC provider: key2any_freectx called\n"); @@ -1272,8 +1288,8 @@ static void key2any_freectx(void *vctx) { OPENSSL_free(ctx); } -static const OSSL_PARAM * -key2any_settable_ctx_params(ossl_unused void *provctx) { +static const OSSL_PARAM *key2any_settable_ctx_params(ossl_unused void *provctx) +{ static const OSSL_PARAM settables[] = { OSSL_PARAM_utf8_string(OSSL_ENCODER_PARAM_CIPHER, NULL, 0), OSSL_PARAM_utf8_string(OSSL_ENCODER_PARAM_PROPERTIES, NULL, 0), @@ -1285,15 +1301,16 @@ key2any_settable_ctx_params(ossl_unused void *provctx) { return settables; } -static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[]) { +static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[]) +{ struct key2any_ctx_st *ctx = vctx; OSSL_LIB_CTX *libctx = ctx->provctx->libctx; - const OSSL_PARAM *cipherp = - OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_CIPHER); - const OSSL_PARAM *propsp = - OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_PROPERTIES); - const OSSL_PARAM *save_paramsp = - OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_SAVE_PARAMETERS); + const OSSL_PARAM *cipherp + = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_CIPHER); + const OSSL_PARAM *propsp + = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_PROPERTIES); + const OSSL_PARAM *save_paramsp + = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_SAVE_PARAMETERS); OQS_ENC_PRINTF("OQS ENC provider: key2any_set_ctx_params called\n"); @@ -1310,8 +1327,9 @@ static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[]) { EVP_CIPHER_free(ctx->cipher); ctx->cipher = NULL; ctx->cipher_intent = ciphername != NULL; - if (ciphername != NULL && ((ctx->cipher = EVP_CIPHER_fetch( - libctx, ciphername, props)) == NULL)) { + if (ciphername != NULL + && ((ctx->cipher = EVP_CIPHER_fetch(libctx, ciphername, props)) + == NULL)) { return 0; } } @@ -1326,14 +1344,15 @@ static int key2any_set_ctx_params(void *vctx, const OSSL_PARAM params[]) { return 1; } -static int key2any_check_selection(int selection, int selection_mask) { +static int key2any_check_selection(int selection, int selection_mask) +{ /* * The selections are kinda sorta "levels", i.e. each selection given * here is assumed to include those following. */ - int checks[] = {OSSL_KEYMGMT_SELECT_PRIVATE_KEY, - OSSL_KEYMGMT_SELECT_PUBLIC_KEY, - OSSL_KEYMGMT_SELECT_ALL_PARAMETERS}; + int checks[] + = {OSSL_KEYMGMT_SELECT_PRIVATE_KEY, OSSL_KEYMGMT_SELECT_PUBLIC_KEY, + OSSL_KEYMGMT_SELECT_ALL_PARAMETERS}; size_t i; OQS_ENC_PRINTF3("OQS ENC provider: key2any_check_selection called with " @@ -1369,7 +1388,8 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, const char *pemname, key_to_der_fn *writer, OSSL_PASSPHRASE_CALLBACK *pwcb, void *pwcbarg, key_to_paramstring_fn *key2paramstring, - i2d_of_void *key2der) { + i2d_of_void *key2der) +{ int ret = 0; int type = OBJ_sn2nid(typestr); OQSX_KEY *oqsk = (OQSX_KEY *)key; @@ -1391,8 +1411,8 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, ctx->pwcb = pwcb; ctx->pwcbarg = pwcbarg; - ret = - writer(out, key, type, pemname, key2paramstring, key2der, ctx); + ret = writer(out, key, type, pemname, key2paramstring, key2der, + ctx); } BIO_free(out); @@ -1404,27 +1424,27 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, } #define DO_PRIVATE_KEY_selection_mask OSSL_KEYMGMT_SELECT_PRIVATE_KEY -#define DO_PRIVATE_KEY(impl, type, kind, output) \ - if ((selection & DO_PRIVATE_KEY_selection_mask) != 0) \ - return key2any_encode( \ - ctx, cout, key, impl##_pem_type, impl##_pem_type " PRIVATE KEY", \ - key_to_##kind##_##output##_priv_bio, cb, cbarg, \ +#define DO_PRIVATE_KEY(impl, type, kind, output) \ + if ((selection & DO_PRIVATE_KEY_selection_mask) != 0) \ + return key2any_encode( \ + ctx, cout, key, impl##_pem_type, impl##_pem_type " PRIVATE KEY", \ + key_to_##kind##_##output##_priv_bio, cb, cbarg, \ prepare_##type##_params, type##_##kind##_priv_to_der); #define DO_PUBLIC_KEY_selection_mask OSSL_KEYMGMT_SELECT_PUBLIC_KEY -#define DO_PUBLIC_KEY(impl, type, kind, output) \ - if ((selection & DO_PUBLIC_KEY_selection_mask) != 0) \ - return key2any_encode( \ - ctx, cout, key, impl##_pem_type, impl##_pem_type " PUBLIC KEY", \ - key_to_##kind##_##output##_pub_bio, cb, cbarg, \ +#define DO_PUBLIC_KEY(impl, type, kind, output) \ + if ((selection & DO_PUBLIC_KEY_selection_mask) != 0) \ + return key2any_encode( \ + ctx, cout, key, impl##_pem_type, impl##_pem_type " PUBLIC KEY", \ + key_to_##kind##_##output##_pub_bio, cb, cbarg, \ prepare_##type##_params, type##_##kind##_pub_to_der); #define DO_PARAMETERS_selection_mask OSSL_KEYMGMT_SELECT_ALL_PARAMETERS -#define DO_PARAMETERS(impl, type, kind, output) \ - if ((selection & DO_PARAMETERS_selection_mask) != 0) \ - return key2any_encode(ctx, cout, key, impl##_pem_type, \ - impl##_pem_type " PARAMETERS", \ - key_to_##kind##_##output##_param_bio, NULL, \ +#define DO_PARAMETERS(impl, type, kind, output) \ + if ((selection & DO_PARAMETERS_selection_mask) != 0) \ + return key2any_encode(ctx, cout, key, impl##_pem_type, \ + impl##_pem_type " PARAMETERS", \ + key_to_##kind##_##output##_param_bio, NULL, \ NULL, NULL, type##_##kind##_params_to_der); /*- @@ -1461,16 +1481,16 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, * passphrase callback has been passed to them. */ #define DO_PrivateKeyInfo_selection_mask DO_PRIVATE_KEY_selection_mask -#define DO_PrivateKeyInfo(impl, type, output) \ +#define DO_PrivateKeyInfo(impl, type, output) \ DO_PRIVATE_KEY(impl, type, pki, output) #define DO_EncryptedPrivateKeyInfo_selection_mask DO_PRIVATE_KEY_selection_mask -#define DO_EncryptedPrivateKeyInfo(impl, type, output) \ +#define DO_EncryptedPrivateKeyInfo(impl, type, output) \ DO_PRIVATE_KEY(impl, type, epki, output) /* SubjectPublicKeyInfo is a structure for public keys only */ #define DO_SubjectPublicKeyInfo_selection_mask DO_PUBLIC_KEY_selection_mask -#define DO_SubjectPublicKeyInfo(impl, type, output) \ +#define DO_SubjectPublicKeyInfo(impl, type, output) \ DO_PUBLIC_KEY(impl, type, spki, output) /* @@ -1489,23 +1509,23 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, * except public key */ #define DO_type_specific_params_selection_mask DO_PARAMETERS_selection_mask -#define DO_type_specific_params(impl, type, output) \ +#define DO_type_specific_params(impl, type, output) \ DO_PARAMETERS(impl, type, type_specific, output) -#define DO_type_specific_keypair_selection_mask \ +#define DO_type_specific_keypair_selection_mask \ (DO_PRIVATE_KEY_selection_mask | DO_PUBLIC_KEY_selection_mask) -#define DO_type_specific_keypair(impl, type, output) \ - DO_PRIVATE_KEY(impl, type, type_specific, output) \ +#define DO_type_specific_keypair(impl, type, output) \ + DO_PRIVATE_KEY(impl, type, type_specific, output) \ DO_PUBLIC_KEY(impl, type, type_specific, output) -#define DO_type_specific_selection_mask \ - (DO_type_specific_keypair_selection_mask | \ - DO_type_specific_params_selection_mask) -#define DO_type_specific(impl, type, output) \ - DO_type_specific_keypair(impl, type, output) \ +#define DO_type_specific_selection_mask \ + (DO_type_specific_keypair_selection_mask \ + | DO_type_specific_params_selection_mask) +#define DO_type_specific(impl, type, output) \ + DO_type_specific_keypair(impl, type, output) \ DO_type_specific_params(impl, type, output) -#define DO_type_specific_no_pub_selection_mask \ +#define DO_type_specific_no_pub_selection_mask \ (DO_PRIVATE_KEY_selection_mask | DO_PARAMETERS_selection_mask) -#define DO_type_specific_no_pub(impl, type, output) \ - DO_PRIVATE_KEY(impl, type, type_specific, output) \ +#define DO_type_specific_no_pub(impl, type, output) \ + DO_PRIVATE_KEY(impl, type, type_specific, output) \ DO_type_specific_params(impl, type, output) /* @@ -1534,7 +1554,8 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, static OSSL_FUNC_encoder_encode_fn impl##_to_##kind##_##output##_encode; \ \ static void *impl##_to_##kind##_##output##_import_object( \ - void *vctx, int selection, const OSSL_PARAM params[]) { \ + void *vctx, int selection, const OSSL_PARAM params[]) \ + { \ struct key2any_ctx_st *ctx = vctx; \ \ OQS_ENC_PRINTF("OQS ENC provider: _import_object called\n"); \ @@ -1542,19 +1563,22 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, oqs##oqskemhyb##_##impl##_keymgmt_functions, ctx->provctx, \ selection, params); \ } \ - static void impl##_to_##kind##_##output##_free_object(void *key) { \ + static void impl##_to_##kind##_##output##_free_object(void *key) \ + { \ OQS_ENC_PRINTF("OQS ENC provider: _free_object called\n"); \ oqs_prov_free_key(oqs##oqskemhyb##_##impl##_keymgmt_functions, key); \ } \ static int impl##_to_##kind##_##output##_does_selection(void *ctx, \ - int selection) { \ + int selection) \ + { \ OQS_ENC_PRINTF("OQS ENC provider: _does_selection called\n"); \ return key2any_check_selection(selection, DO_##kind##_selection_mask); \ } \ static int impl##_to_##kind##_##output##_encode( \ void *ctx, OSSL_CORE_BIO *cout, const void *key, \ const OSSL_PARAM key_abstract[], int selection, \ - OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { \ + OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) \ + { \ /* We don't deal with abstract objects */ \ OQS_ENC_PRINTF("OQS ENC provider: _encode called\n"); \ if (key_abstract != NULL) { \ @@ -1567,22 +1591,22 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, return 0; \ } \ const OSSL_DISPATCH \ - oqs_##impl##_to_##kind##_##output##_encoder_functions[] = { \ - {OSSL_FUNC_ENCODER_NEWCTX, (void (*)(void))key2any_newctx}, \ - {OSSL_FUNC_ENCODER_FREECTX, (void (*)(void))key2any_freectx}, \ - {OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS, \ - (void (*)(void))key2any_settable_ctx_params}, \ - {OSSL_FUNC_ENCODER_SET_CTX_PARAMS, \ - (void (*)(void))key2any_set_ctx_params}, \ - {OSSL_FUNC_ENCODER_DOES_SELECTION, \ - (void (*)(void))impl##_to_##kind##_##output##_does_selection}, \ - {OSSL_FUNC_ENCODER_IMPORT_OBJECT, \ - (void (*)(void))impl##_to_##kind##_##output##_import_object}, \ - {OSSL_FUNC_ENCODER_FREE_OBJECT, \ - (void (*)(void))impl##_to_##kind##_##output##_free_object}, \ - {OSSL_FUNC_ENCODER_ENCODE, \ - (void (*)(void))impl##_to_##kind##_##output##_encode}, \ - {0, NULL}} + oqs_##impl##_to_##kind##_##output##_encoder_functions[] \ + = {{OSSL_FUNC_ENCODER_NEWCTX, (void (*)(void))key2any_newctx}, \ + {OSSL_FUNC_ENCODER_FREECTX, (void (*)(void))key2any_freectx}, \ + {OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS, \ + (void (*)(void))key2any_settable_ctx_params}, \ + {OSSL_FUNC_ENCODER_SET_CTX_PARAMS, \ + (void (*)(void))key2any_set_ctx_params}, \ + {OSSL_FUNC_ENCODER_DOES_SELECTION, \ + (void (*)(void))impl##_to_##kind##_##output##_does_selection}, \ + {OSSL_FUNC_ENCODER_IMPORT_OBJECT, \ + (void (*)(void))impl##_to_##kind##_##output##_import_object}, \ + {OSSL_FUNC_ENCODER_FREE_OBJECT, \ + (void (*)(void))impl##_to_##kind##_##output##_free_object}, \ + {OSSL_FUNC_ENCODER_ENCODE, \ + (void (*)(void))impl##_to_##kind##_##output##_encode}, \ + {0, NULL}} /* ---------------------------------------------------------------------- */ @@ -1592,7 +1616,8 @@ static int key2any_encode(struct key2any_ctx_st *ctx, OSSL_CORE_BIO *cout, #define LABELED_BUF_PRINT_WIDTH 15 static int print_labeled_buf(BIO *out, const char *label, - const unsigned char *buf, size_t buflen) { + const unsigned char *buf, size_t buflen) +{ size_t i; if (BIO_printf(out, "%s\n", label) <= 0) @@ -1606,8 +1631,8 @@ static int print_labeled_buf(BIO *out, const char *label, return 0; } - if (BIO_printf(out, "%02x%s", buf[i], (i == buflen - 1) ? "" : ":") <= - 0) + if (BIO_printf(out, "%02x%s", buf[i], (i == buflen - 1) ? "" : ":") + <= 0) return 0; } if (BIO_printf(out, "\n") <= 0) @@ -1616,7 +1641,8 @@ static int print_labeled_buf(BIO *out, const char *label, return 1; } -static int oqsx_to_text(BIO *out, const void *key, int selection) { +static int oqsx_to_text(BIO *out, const void *key, int selection) +{ OQSX_KEY *okey = (OQSX_KEY *)key; if (out == NULL || okey == NULL) { @@ -1639,13 +1665,13 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { case KEY_TYPE_ECP_HYB_KEM: case KEY_TYPE_ECX_HYB_KEM: case KEY_TYPE_HYB_SIG: - if (BIO_printf(out, "%s hybrid private key:\n", okey->tls_name) <= - 0) + if (BIO_printf(out, "%s hybrid private key:\n", okey->tls_name) + <= 0) return 0; break; case KEY_TYPE_CMP_SIG: - if (BIO_printf(out, "%s composite private key:\n", - okey->tls_name) <= 0) + if (BIO_printf(out, "%s composite private key:\n", okey->tls_name) + <= 0) return 0; break; default: @@ -1671,8 +1697,8 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { return 0; break; case KEY_TYPE_CMP_SIG: - if (BIO_printf(out, "%s composite public key:\n", okey->tls_name) <= - 0) + if (BIO_printf(out, "%s composite public key:\n", okey->tls_name) + <= 0) return 0; break; default: @@ -1689,8 +1715,8 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { int i; uint32_t privlen = 0; for (i = 0; i < okey->numkeys; i++) { - if ((name = get_cmpname(OBJ_sn2nid(okey->tls_name), i)) == - NULL) { + if ((name = get_cmpname(OBJ_sn2nid(okey->tls_name), i)) + == NULL) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_KEY); return 0; } @@ -1698,10 +1724,10 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { if (get_oqsname_fromtls(name) == 0 // classical key && okey->oqsx_provider_ctx.oqsx_evp_ctx->evp_info - ->keytype == - EVP_PKEY_RSA) { // get the RSA real key size - unsigned char *enc_len = - (unsigned char *)OPENSSL_strndup( + ->keytype + == EVP_PKEY_RSA) { // get the RSA real key size + unsigned char *enc_len + = (unsigned char *)OPENSSL_strndup( okey->comp_privkey[i], 4); OPENSSL_cleanse(enc_len, 2); DECODE_UINT32(privlen, enc_len); @@ -1724,12 +1750,12 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { if (okey->numkeys > 1) { // hybrid key char classic_label[200]; uint32_t classic_key_len = 0; - size_t fixed_pq_privkey_len = - okey->oqsx_provider_ctx.oqsx_qs_ctx.kem - ->length_secret_key; - size_t space_for_classical_privkey = okey->privkeylen - - SIZE_OF_UINT32 - - fixed_pq_privkey_len; + size_t fixed_pq_privkey_len + = okey->oqsx_provider_ctx.oqsx_qs_ctx.kem + ->length_secret_key; + size_t space_for_classical_privkey = okey->privkeylen + - SIZE_OF_UINT32 + - fixed_pq_privkey_len; sprintf(classic_label, "%s key material:", OBJ_nid2sn(okey->evp_info->nid)); DECODE_UINT32(classic_key_len, okey->privkey); @@ -1745,8 +1771,8 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { if (!print_labeled_buf( out, "PQ key material:", okey->comp_privkey[okey->numkeys - 1], - okey->privkeylen - classic_key_len - - SIZE_OF_UINT32)) + okey->privkeylen - classic_key_len + - SIZE_OF_UINT32)) return 0; } else { // plain PQ key if (!print_labeled_buf( @@ -1765,8 +1791,8 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { char label[200]; int i; for (i = 0; i < okey->numkeys; i++) { - if ((name = get_cmpname(OBJ_sn2nid(okey->tls_name), i)) == - NULL) { + if ((name = get_cmpname(OBJ_sn2nid(okey->tls_name), i)) + == NULL) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_KEY); return 0; } @@ -1782,11 +1808,12 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { if (okey->numkeys > 1) { // hybrid key char classic_label[200]; uint32_t classic_key_len = 0; - size_t fixed_pq_pubkey_len = - okey->oqsx_provider_ctx.oqsx_qs_ctx.kem - ->length_public_key; - size_t space_for_classical_pubkey = - okey->pubkeylen - SIZE_OF_UINT32 - fixed_pq_pubkey_len; + size_t fixed_pq_pubkey_len + = okey->oqsx_provider_ctx.oqsx_qs_ctx.kem + ->length_public_key; + size_t space_for_classical_pubkey = okey->pubkeylen + - SIZE_OF_UINT32 + - fixed_pq_pubkey_len; DECODE_UINT32(classic_key_len, okey->pubkey); if (classic_key_len > space_for_classical_pubkey) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); @@ -1801,8 +1828,8 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { /* finally print pure PQ key */ if (!print_labeled_buf(out, "PQ key material:", okey->comp_pubkey[okey->numkeys - 1], - okey->pubkeylen - classic_key_len - - SIZE_OF_UINT32)) + okey->pubkeylen - classic_key_len + - SIZE_OF_UINT32)) return 0; } else { // PQ key only if (!print_labeled_buf(out, "PQ key material:", @@ -1817,14 +1844,20 @@ static int oqsx_to_text(BIO *out, const void *key, int selection) { return 1; } -static void *key2text_newctx(void *provctx) { return provctx; } +static void *key2text_newctx(void *provctx) +{ + return provctx; +} -static void key2text_freectx(ossl_unused void *vctx) {} +static void key2text_freectx(ossl_unused void *vctx) +{ +} static int key2text_encode(void *vctx, const void *key, int selection, OSSL_CORE_BIO *cout, int (*key2text)(BIO *out, const void *key, int selection), - OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { + OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) +{ BIO *out = oqs_bio_new_from_core_bio(vctx, cout); int ret; @@ -1837,41 +1870,44 @@ key2text_encode(void *vctx, const void *key, int selection, OSSL_CORE_BIO *cout, return ret; } -#define MAKE_TEXT_ENCODER(oqskemhyb, impl) \ - static OSSL_FUNC_encoder_import_object_fn impl##2text_import_object; \ - static OSSL_FUNC_encoder_free_object_fn impl##2text_free_object; \ - static OSSL_FUNC_encoder_encode_fn impl##2text_encode; \ - \ - static void *impl##2text_import_object(void *ctx, int selection, \ - const OSSL_PARAM params[]) { \ - return oqs_prov_import_key( \ - oqs##oqskemhyb##_##impl##_keymgmt_functions, ctx, selection, \ - params); \ - } \ - static void impl##2text_free_object(void *key) { \ - oqs_prov_free_key(oqs##oqskemhyb##_##impl##_keymgmt_functions, key); \ - } \ - static int impl##2text_encode( \ - void *vctx, OSSL_CORE_BIO *cout, const void *key, \ - const OSSL_PARAM key_abstract[], int selection, \ - OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) { \ - /* We don't deal with abstract objects */ \ - if (key_abstract != NULL) { \ - ERR_raise(ERR_LIB_USER, ERR_R_PASSED_INVALID_ARGUMENT); \ - return 0; \ - } \ - return key2text_encode(vctx, key, selection, cout, oqsx_to_text, cb, \ - cbarg); \ - } \ - const OSSL_DISPATCH oqs_##impl##_to_text_encoder_functions[] = { \ - {OSSL_FUNC_ENCODER_NEWCTX, (void (*)(void))key2text_newctx}, \ - {OSSL_FUNC_ENCODER_FREECTX, (void (*)(void))key2text_freectx}, \ - {OSSL_FUNC_ENCODER_IMPORT_OBJECT, \ - (void (*)(void))impl##2text_import_object}, \ - {OSSL_FUNC_ENCODER_FREE_OBJECT, \ - (void (*)(void))impl##2text_free_object}, \ - {OSSL_FUNC_ENCODER_ENCODE, (void (*)(void))impl##2text_encode}, \ - {0, NULL}} +#define MAKE_TEXT_ENCODER(oqskemhyb, impl) \ + static OSSL_FUNC_encoder_import_object_fn impl##2text_import_object; \ + static OSSL_FUNC_encoder_free_object_fn impl##2text_free_object; \ + static OSSL_FUNC_encoder_encode_fn impl##2text_encode; \ + \ + static void *impl##2text_import_object(void *ctx, int selection, \ + const OSSL_PARAM params[]) \ + { \ + return oqs_prov_import_key( \ + oqs##oqskemhyb##_##impl##_keymgmt_functions, ctx, selection, \ + params); \ + } \ + static void impl##2text_free_object(void *key) \ + { \ + oqs_prov_free_key(oqs##oqskemhyb##_##impl##_keymgmt_functions, key); \ + } \ + static int impl##2text_encode( \ + void *vctx, OSSL_CORE_BIO *cout, const void *key, \ + const OSSL_PARAM key_abstract[], int selection, \ + OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg) \ + { \ + /* We don't deal with abstract objects */ \ + if (key_abstract != NULL) { \ + ERR_raise(ERR_LIB_USER, ERR_R_PASSED_INVALID_ARGUMENT); \ + return 0; \ + } \ + return key2text_encode(vctx, key, selection, cout, oqsx_to_text, cb, \ + cbarg); \ + } \ + const OSSL_DISPATCH oqs_##impl##_to_text_encoder_functions[] \ + = {{OSSL_FUNC_ENCODER_NEWCTX, (void (*)(void))key2text_newctx}, \ + {OSSL_FUNC_ENCODER_FREECTX, (void (*)(void))key2text_freectx}, \ + {OSSL_FUNC_ENCODER_IMPORT_OBJECT, \ + (void (*)(void))impl##2text_import_object}, \ + {OSSL_FUNC_ENCODER_FREE_OBJECT, \ + (void (*)(void))impl##2text_free_object}, \ + {OSSL_FUNC_ENCODER_ENCODE, (void (*)(void))impl##2text_encode}, \ + {0, NULL}} /* * Replacements for i2d_{TYPE}PrivateKey, i2d_{TYPE}PublicKey, diff --git a/oqsprov/oqs_endecoder_common.c b/oqsprov/oqs_endecoder_common.c index 512f360b..5c96fc43 100644 --- a/oqsprov/oqs_endecoder_common.c +++ b/oqsprov/oqs_endecoder_common.c @@ -14,7 +14,8 @@ #include "oqs_endecoder_local.h" -OSSL_FUNC_keymgmt_new_fn *oqs_prov_get_keymgmt_new(const OSSL_DISPATCH *fns) { +OSSL_FUNC_keymgmt_new_fn *oqs_prov_get_keymgmt_new(const OSSL_DISPATCH *fns) +{ /* Pilfer the keymgmt dispatch table */ for (; fns->function_id != 0; fns++) if (fns->function_id == OSSL_FUNC_KEYMGMT_NEW) @@ -23,7 +24,8 @@ OSSL_FUNC_keymgmt_new_fn *oqs_prov_get_keymgmt_new(const OSSL_DISPATCH *fns) { return NULL; } -OSSL_FUNC_keymgmt_free_fn *oqs_prov_get_keymgmt_free(const OSSL_DISPATCH *fns) { +OSSL_FUNC_keymgmt_free_fn *oqs_prov_get_keymgmt_free(const OSSL_DISPATCH *fns) +{ /* Pilfer the keymgmt dispatch table */ for (; fns->function_id != 0; fns++) if (fns->function_id == OSSL_FUNC_KEYMGMT_FREE) @@ -33,7 +35,8 @@ OSSL_FUNC_keymgmt_free_fn *oqs_prov_get_keymgmt_free(const OSSL_DISPATCH *fns) { } OSSL_FUNC_keymgmt_import_fn * -oqs_prov_get_keymgmt_import(const OSSL_DISPATCH *fns) { +oqs_prov_get_keymgmt_import(const OSSL_DISPATCH *fns) +{ /* Pilfer the keymgmt dispatch table */ for (; fns->function_id != 0; fns++) if (fns->function_id == OSSL_FUNC_KEYMGMT_IMPORT) @@ -43,7 +46,8 @@ oqs_prov_get_keymgmt_import(const OSSL_DISPATCH *fns) { } OSSL_FUNC_keymgmt_export_fn * -oqs_prov_get_keymgmt_export(const OSSL_DISPATCH *fns) { +oqs_prov_get_keymgmt_export(const OSSL_DISPATCH *fns) +{ /* Pilfer the keymgmt dispatch table */ for (; fns->function_id != 0; fns++) if (fns->function_id == OSSL_FUNC_KEYMGMT_EXPORT) @@ -53,16 +57,17 @@ oqs_prov_get_keymgmt_export(const OSSL_DISPATCH *fns) { } void *oqs_prov_import_key(const OSSL_DISPATCH *fns, void *provctx, - int selection, const OSSL_PARAM params[]) { + int selection, const OSSL_PARAM params[]) +{ OSSL_FUNC_keymgmt_new_fn *kmgmt_new = oqs_prov_get_keymgmt_new(fns); OSSL_FUNC_keymgmt_free_fn *kmgmt_free = oqs_prov_get_keymgmt_free(fns); - OSSL_FUNC_keymgmt_import_fn *kmgmt_import = - oqs_prov_get_keymgmt_import(fns); + OSSL_FUNC_keymgmt_import_fn *kmgmt_import + = oqs_prov_get_keymgmt_import(fns); void *key = NULL; if (kmgmt_new != NULL && kmgmt_import != NULL && kmgmt_free != NULL) { - if ((key = kmgmt_new(provctx)) == NULL || - !kmgmt_import(key, selection, params)) { + if ((key = kmgmt_new(provctx)) == NULL + || !kmgmt_import(key, selection, params)) { kmgmt_free(key); key = NULL; } @@ -70,7 +75,8 @@ void *oqs_prov_import_key(const OSSL_DISPATCH *fns, void *provctx, return key; } -void oqs_prov_free_key(const OSSL_DISPATCH *fns, void *key) { +void oqs_prov_free_key(const OSSL_DISPATCH *fns, void *key) +{ OSSL_FUNC_keymgmt_free_fn *kmgmt_free = oqs_prov_get_keymgmt_free(fns); if (kmgmt_free != NULL) diff --git a/oqsprov/oqs_hyb_kem.c b/oqsprov/oqs_hyb_kem.c index 6f9c9d94..81a74d6d 100644 --- a/oqsprov/oqs_hyb_kem.c +++ b/oqsprov/oqs_hyb_kem.c @@ -14,7 +14,8 @@ static OSSL_FUNC_kem_decapsulate_fn oqs_hyb_kem_decaps; static int oqs_evp_kem_encaps_keyslot(void *vpkemctx, unsigned char *ct, size_t *ctlen, unsigned char *secret, - size_t *secretlen, int keyslot) { + size_t *secretlen, int keyslot) +{ int ret = OQS_SUCCESS, ret2 = 0; const PROV_OQSKEM_CTX *pkemctx = (PROV_OQSKEM_CTX *)vpkemctx; @@ -90,7 +91,8 @@ static int oqs_evp_kem_encaps_keyslot(void *vpkemctx, unsigned char *ct, static int oqs_evp_kem_decaps_keyslot(void *vpkemctx, unsigned char *secret, size_t *secretlen, const unsigned char *ct, size_t ctlen, - int keyslot) { + int keyslot) +{ OQS_KEM_PRINTF("OQS KEM provider called: oqs_hyb_kem_decaps\n"); int ret = OQS_SUCCESS, ret2 = 0; @@ -150,7 +152,8 @@ static int oqs_evp_kem_decaps_keyslot(void *vpkemctx, unsigned char *secret, /// Hybrid KEM functions static int oqs_hyb_kem_encaps(void *vpkemctx, unsigned char *ct, size_t *ctlen, - unsigned char *secret, size_t *secretlen) { + unsigned char *secret, size_t *secretlen) +{ int ret = OQS_SUCCESS; const PROV_OQSKEM_CTX *pkemctx = (PROV_OQSKEM_CTX *)vpkemctx; const OQSX_KEY *oqsx_key = pkemctx->kem; @@ -162,9 +165,9 @@ static int oqs_hyb_kem_encaps(void *vpkemctx, unsigned char *ct, size_t *ctlen, &secretLenClassical, oqsx_key->reverse_share ? 1 : 0); ON_ERR_SET_GOTO(ret <= 0, ret, OQS_ERROR, err); - ret = - oqs_qs_kem_encaps_keyslot(vpkemctx, NULL, &ctLenPQ, NULL, &secretLenPQ, - oqsx_key->reverse_share ? 0 : 1); + ret = oqs_qs_kem_encaps_keyslot(vpkemctx, NULL, &ctLenPQ, NULL, + &secretLenPQ, + oqsx_key->reverse_share ? 0 : 1); ON_ERR_SET_GOTO(ret <= 0, ret, OQS_ERROR, err); *ctlen = ctLenClassical + ctLenPQ; @@ -208,7 +211,8 @@ static int oqs_hyb_kem_encaps(void *vpkemctx, unsigned char *ct, size_t *ctlen, static int oqs_hyb_kem_decaps(void *vpkemctx, unsigned char *secret, size_t *secretlen, const unsigned char *ct, - size_t ctlen) { + size_t ctlen) +{ int ret = OQS_SUCCESS; const PROV_OQSKEM_CTX *pkemctx = (PROV_OQSKEM_CTX *)vpkemctx; const OQSX_KEY *oqsx_key = pkemctx->kem; diff --git a/oqsprov/oqs_kem.c b/oqsprov/oqs_kem.c index 0ed3fbe4..1acd2270 100644 --- a/oqsprov/oqs_kem.c +++ b/oqsprov/oqs_kem.c @@ -20,19 +20,19 @@ #include "oqs_prov.h" #ifdef NDEBUG -#define OQS_KEM_PRINTF(a) -#define OQS_KEM_PRINTF2(a, b) -#define OQS_KEM_PRINTF3(a, b, c) +# define OQS_KEM_PRINTF(a) +# define OQS_KEM_PRINTF2(a, b) +# define OQS_KEM_PRINTF3(a, b, c) #else -#define OQS_KEM_PRINTF(a) \ - if (getenv("OQSKEM")) \ - printf(a) -#define OQS_KEM_PRINTF2(a, b) \ - if (getenv("OQSKEM")) \ - printf(a, b) -#define OQS_KEM_PRINTF3(a, b, c) \ - if (getenv("OQSKEM")) \ - printf(a, b, c) +# define OQS_KEM_PRINTF(a) \ + if (getenv("OQSKEM")) \ + printf(a) +# define OQS_KEM_PRINTF2(a, b) \ + if (getenv("OQSKEM")) \ + printf(a, b) +# define OQS_KEM_PRINTF3(a, b, c) \ + if (getenv("OQSKEM")) \ + printf(a, b, c) #endif // NDEBUG static OSSL_FUNC_kem_newctx_fn oqs_kem_newctx; @@ -51,7 +51,8 @@ typedef struct { /// Common KEM functions -static void *oqs_kem_newctx(void *provctx) { +static void *oqs_kem_newctx(void *provctx) +{ PROV_OQSKEM_CTX *pkemctx = OPENSSL_zalloc(sizeof(PROV_OQSKEM_CTX)); OQS_KEM_PRINTF("OQS KEM provider called: newctx\n"); @@ -63,7 +64,8 @@ static void *oqs_kem_newctx(void *provctx) { return pkemctx; } -static void oqs_kem_freectx(void *vpkemctx) { +static void oqs_kem_freectx(void *vpkemctx) +{ PROV_OQSKEM_CTX *pkemctx = (PROV_OQSKEM_CTX *)vpkemctx; OQS_KEM_PRINTF("OQS KEM provider called: freectx\n"); @@ -71,8 +73,8 @@ static void oqs_kem_freectx(void *vpkemctx) { OPENSSL_free(pkemctx); } -static int oqs_kem_decapsencaps_init(void *vpkemctx, void *vkem, - int operation) { +static int oqs_kem_decapsencaps_init(void *vpkemctx, void *vkem, int operation) +{ PROV_OQSKEM_CTX *pkemctx = (PROV_OQSKEM_CTX *)vpkemctx; OQS_KEM_PRINTF3("OQS KEM provider called: _init : New: %p; old: %p \n", @@ -86,13 +88,15 @@ static int oqs_kem_decapsencaps_init(void *vpkemctx, void *vkem, } static int oqs_kem_encaps_init(void *vpkemctx, void *vkem, - const OSSL_PARAM params[]) { + const OSSL_PARAM params[]) +{ OQS_KEM_PRINTF("OQS KEM provider called: encaps_init\n"); return oqs_kem_decapsencaps_init(vpkemctx, vkem, EVP_PKEY_OP_ENCAPSULATE); } static int oqs_kem_decaps_init(void *vpkemctx, void *vkem, - const OSSL_PARAM params[]) { + const OSSL_PARAM params[]) +{ OQS_KEM_PRINTF("OQS KEM provider called: decaps_init\n"); return oqs_kem_decapsencaps_init(vpkemctx, vkem, EVP_PKEY_OP_DECAPSULATE); } @@ -101,7 +105,8 @@ static int oqs_kem_decaps_init(void *vpkemctx, void *vkem, static int oqs_qs_kem_encaps_keyslot(void *vpkemctx, unsigned char *out, size_t *outlen, unsigned char *secret, - size_t *secretlen, int keyslot) { + size_t *secretlen, int keyslot) +{ const PROV_OQSKEM_CTX *pkemctx = (PROV_OQSKEM_CTX *)vpkemctx; const OQS_KEM *kem_ctx = NULL; @@ -112,8 +117,8 @@ static int oqs_qs_kem_encaps_keyslot(void *vpkemctx, unsigned char *out, } kem_ctx = pkemctx->kem->oqsx_provider_ctx.oqsx_qs_ctx.kem; - if (pkemctx->kem->comp_pubkey == NULL || - pkemctx->kem->comp_pubkey[keyslot] == NULL) { + if (pkemctx->kem->comp_pubkey == NULL + || pkemctx->kem->comp_pubkey[keyslot] == NULL) { OQS_KEM_PRINTF("OQS Warning: public key is NULL\n"); return -1; } @@ -145,13 +150,15 @@ static int oqs_qs_kem_encaps_keyslot(void *vpkemctx, unsigned char *out, *outlen = kem_ctx->length_ciphertext; *secretlen = kem_ctx->length_shared_secret; - return OQS_SUCCESS == OQS_KEM_encaps(kem_ctx, out, secret, - pkemctx->kem->comp_pubkey[keyslot]); + return OQS_SUCCESS + == OQS_KEM_encaps(kem_ctx, out, secret, + pkemctx->kem->comp_pubkey[keyslot]); } static int oqs_qs_kem_decaps_keyslot(void *vpkemctx, unsigned char *out, size_t *outlen, const unsigned char *in, - size_t inlen, int keyslot) { + size_t inlen, int keyslot) +{ const PROV_OQSKEM_CTX *pkemctx = (PROV_OQSKEM_CTX *)vpkemctx; const OQS_KEM *kem_ctx = NULL; @@ -161,8 +168,8 @@ static int oqs_qs_kem_decaps_keyslot(void *vpkemctx, unsigned char *out, return -1; } kem_ctx = pkemctx->kem->oqsx_provider_ctx.oqsx_qs_ctx.kem; - if (pkemctx->kem->comp_privkey == NULL || - pkemctx->kem->comp_privkey[keyslot] == NULL) { + if (pkemctx->kem->comp_privkey == NULL + || pkemctx->kem->comp_privkey[keyslot] == NULL) { OQS_KEM_PRINTF("OQS Warning: private key is NULL\n"); return -1; } @@ -192,18 +199,21 @@ static int oqs_qs_kem_decaps_keyslot(void *vpkemctx, unsigned char *out, } *outlen = kem_ctx->length_shared_secret; - return OQS_SUCCESS == OQS_KEM_decaps(kem_ctx, out, in, - pkemctx->kem->comp_privkey[keyslot]); + return OQS_SUCCESS + == OQS_KEM_decaps(kem_ctx, out, in, + pkemctx->kem->comp_privkey[keyslot]); } static int oqs_qs_kem_encaps(void *vpkemctx, unsigned char *out, size_t *outlen, - unsigned char *secret, size_t *secretlen) { + unsigned char *secret, size_t *secretlen) +{ return oqs_qs_kem_encaps_keyslot(vpkemctx, out, outlen, secret, secretlen, 0); } static int oqs_qs_kem_decaps(void *vpkemctx, unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen) { + const unsigned char *in, size_t inlen) +{ return oqs_qs_kem_decaps_keyslot(vpkemctx, out, outlen, in, inlen, 0); } diff --git a/oqsprov/oqs_kmgmt.c b/oqsprov/oqs_kmgmt.c index 1603dbc4..285c12c3 100644 --- a/oqsprov/oqs_kmgmt.c +++ b/oqsprov/oqs_kmgmt.c @@ -26,7 +26,8 @@ int oqsx_param_build_set_octet_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, const char *key, const unsigned char *data, - size_t data_len) { + size_t data_len) +{ if (bld != NULL) return OSSL_PARAM_BLD_push_octet_string(bld, key, data, data_len); @@ -37,19 +38,19 @@ int oqsx_param_build_set_octet_string(OSSL_PARAM_BLD *bld, OSSL_PARAM *p, } #ifdef NDEBUG -#define OQS_KM_PRINTF(a) -#define OQS_KM_PRINTF2(a, b) -#define OQS_KM_PRINTF3(a, b, c) +# define OQS_KM_PRINTF(a) +# define OQS_KM_PRINTF2(a, b) +# define OQS_KM_PRINTF3(a, b, c) #else -#define OQS_KM_PRINTF(a) \ - if (getenv("OQSKM")) \ - printf(a) -#define OQS_KM_PRINTF2(a, b) \ - if (getenv("OQSKM")) \ - printf(a, b) -#define OQS_KM_PRINTF3(a, b, c) \ - if (getenv("OQSKM")) \ - printf(a, b, c) +# define OQS_KM_PRINTF(a) \ + if (getenv("OQSKM")) \ + printf(a) +# define OQS_KM_PRINTF2(a, b) \ + if (getenv("OQSKM")) \ + printf(a, b) +# define OQS_KM_PRINTF3(a, b, c) \ + if (getenv("OQSKM")) \ + printf(a, b, c) #endif // NDEBUG // our own error codes: @@ -81,7 +82,8 @@ struct oqsx_gen_ctx { int reverse_share; }; -static int oqsx_has(const void *keydata, int selection) { +static int oqsx_has(const void *keydata, int selection) +{ const OQSX_KEY *key = keydata; int ok = 0; @@ -108,10 +110,11 @@ static int oqsx_has(const void *keydata, int selection) { /* Sets the index of the key components in a comp_privkey or comp_pubkey array */ static void oqsx_comp_set_idx(const OQSX_KEY *key, int *idx_classic, - int *idx_pq) { - int reverse_share = (key->keytype == KEY_TYPE_ECP_HYB_KEM || - key->keytype == KEY_TYPE_ECX_HYB_KEM) && - key->reverse_share; + int *idx_pq) +{ + int reverse_share = (key->keytype == KEY_TYPE_ECP_HYB_KEM + || key->keytype == KEY_TYPE_ECX_HYB_KEM) + && key->reverse_share; if (reverse_share) { if (idx_classic) @@ -145,8 +148,8 @@ static void oqsx_comp_set_idx(const OQSX_KEY *key, int *idx_classic, * key matching. */ -static int oqsx_match(const void *keydata1, const void *keydata2, - int selection) { +static int oqsx_match(const void *keydata1, const void *keydata2, int selection) +{ const OQSX_KEY *key1 = keydata1; const OQSX_KEY *key2 = keydata2; int ok = 1; @@ -168,49 +171,53 @@ static int oqsx_match(const void *keydata1, const void *keydata2, * at least the key type name matches. Potential actual key mismatches will * only be discovered later. */ - if (((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) && - ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)) { - if ((key1->privkey == NULL && key2->pubkey == NULL) || - (key1->pubkey == NULL && key2->privkey == NULL) || - ((key1->tls_name != NULL && key2->tls_name != NULL) && - !strcmp(key1->tls_name, key2->tls_name))) { + if (((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) + && ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)) { + if ((key1->privkey == NULL && key2->pubkey == NULL) + || (key1->pubkey == NULL && key2->privkey == NULL) + || ((key1->tls_name != NULL && key2->tls_name != NULL) + && !strcmp(key1->tls_name, key2->tls_name))) { OQS_KM_PRINTF("OQSKEYMGMT: leap-of-faith match\n"); return 1; } } #endif - if (((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) && - ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) == 0)) { - if ((key1->privkey == NULL && key2->privkey != NULL) || - (key1->privkey != NULL && key2->privkey == NULL) || - ((key1->tls_name != NULL && key2->tls_name != NULL) && - strcmp(key1->tls_name, key2->tls_name))) { + if (((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) + && ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) == 0)) { + if ((key1->privkey == NULL && key2->privkey != NULL) + || (key1->privkey != NULL && key2->privkey == NULL) + || ((key1->tls_name != NULL && key2->tls_name != NULL) + && strcmp(key1->tls_name, key2->tls_name))) { ok = 0; } else { - ok = ((key1->privkey == NULL && key2->privkey == NULL) || - ((key1->privkey != NULL) && - CRYPTO_memcmp(key1->privkey, key2->privkey, - key1->privkeylen) == 0)); + ok = ((key1->privkey == NULL && key2->privkey == NULL) + || ((key1->privkey != NULL) + && CRYPTO_memcmp(key1->privkey, key2->privkey, + key1->privkeylen) + == 0)); } } if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) { - if ((key1->pubkey == NULL && key2->pubkey != NULL) || - (key1->pubkey != NULL && key2->pubkey == NULL) || - ((key1->tls_name != NULL && key2->tls_name != NULL) && - strcmp(key1->tls_name, key2->tls_name))) { + if ((key1->pubkey == NULL && key2->pubkey != NULL) + || (key1->pubkey != NULL && key2->pubkey == NULL) + || ((key1->tls_name != NULL && key2->tls_name != NULL) + && strcmp(key1->tls_name, key2->tls_name))) { // special case now: If domain parameter matching // requested, consider private key match sufficient: - ok = ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) && - (key1->privkey != NULL && key2->privkey != NULL) && - (CRYPTO_memcmp(key1->privkey, key2->privkey, - key1->privkeylen) == 0); + ok = ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) + && (key1->privkey != NULL && key2->privkey != NULL) + && (CRYPTO_memcmp(key1->privkey, key2->privkey, + key1->privkeylen) + == 0); } else { - ok = ok && ((key1->pubkey == NULL && key2->pubkey == NULL) || - ((key1->pubkey != NULL) && - CRYPTO_memcmp(key1->pubkey, key2->pubkey, - key1->pubkeylen) == 0)); + ok = ok + && ((key1->pubkey == NULL && key2->pubkey == NULL) + || ((key1->pubkey != NULL) + && CRYPTO_memcmp(key1->pubkey, key2->pubkey, + key1->pubkeylen) + == 0)); } } if (!ok) @@ -218,8 +225,8 @@ static int oqsx_match(const void *keydata1, const void *keydata2, return ok; } -static int oqsx_import(void *keydata, int selection, - const OSSL_PARAM params[]) { +static int oqsx_import(void *keydata, int selection, const OSSL_PARAM params[]) +{ OQSX_KEY *key = keydata; int ok = 0; @@ -229,14 +236,15 @@ static int oqsx_import(void *keydata, int selection, return ok; } - if (((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0) && - (oqsx_key_fromdata(key, params, 1))) + if (((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0) + && (oqsx_key_fromdata(key, params, 1))) ok = 1; return ok; } int oqsx_key_to_params(const OQSX_KEY *key, OSSL_PARAM_BLD *tmpl, - OSSL_PARAM params[], int include_private) { + OSSL_PARAM params[], int include_private) +{ int ret = 0; if (key == NULL) @@ -250,9 +258,10 @@ int oqsx_key_to_params(const OQSX_KEY *key, OSSL_PARAM_BLD *tmpl, } if (p != NULL || tmpl != NULL) { - if (key->pubkeylen == 0 || !oqsx_param_build_set_octet_string( - tmpl, p, OSSL_PKEY_PARAM_PUB_KEY, - key->pubkey, key->pubkeylen)) + if (key->pubkeylen == 0 + || !oqsx_param_build_set_octet_string( + tmpl, p, OSSL_PKEY_PARAM_PUB_KEY, key->pubkey, + key->pubkeylen)) goto err; } } @@ -271,9 +280,10 @@ int oqsx_key_to_params(const OQSX_KEY *key, OSSL_PARAM_BLD *tmpl, } if (p != NULL || tmpl != NULL) { - if (key->privkeylen == 0 || !oqsx_param_build_set_octet_string( - tmpl, p, OSSL_PKEY_PARAM_PRIV_KEY, - key->privkey, key->privkeylen)) + if (key->privkeylen == 0 + || !oqsx_param_build_set_octet_string( + tmpl, p, OSSL_PKEY_PARAM_PRIV_KEY, key->privkey, + key->privkeylen)) goto err; } } @@ -284,7 +294,8 @@ int oqsx_key_to_params(const OQSX_KEY *key, OSSL_PARAM_BLD *tmpl, } static int oqsx_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, - void *cbarg) { + void *cbarg) +{ OQSX_KEY *key = keydata; OSSL_PARAM_BLD *tmpl; OSSL_PARAM *params = NULL; @@ -309,8 +320,8 @@ static int oqsx_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, } if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) { - int include_private = - selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY ? 1 : 0; + int include_private + = selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY ? 1 : 0; ok = ok && oqsx_key_to_params(key, tmpl, NULL, include_private); } @@ -335,13 +346,14 @@ static int oqsx_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, OSSL_PARAM_octet_string(OQS_HYBRID_PKEY_PARAM_PQ_PUB_KEY, NULL, 0), \ OSSL_PARAM_octet_string(OQS_HYBRID_PKEY_PARAM_PQ_PRIV_KEY, NULL, 0) -#define OQS_KEY_TYPES() \ - OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0), \ - OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), \ +#define OQS_KEY_TYPES() \ + OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0), \ + OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0), \ OQS_HYBRID_KEY_TYPES() static const OSSL_PARAM oqsx_key_types[] = {OQS_KEY_TYPES(), OSSL_PARAM_END}; -static const OSSL_PARAM *oqs_imexport_types(int selection) { +static const OSSL_PARAM *oqs_imexport_types(int selection) +{ OQS_KM_PRINTF("OQSKEYMGMT: imexport called\n"); if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) return oqsx_key_types; @@ -352,11 +364,12 @@ static const OSSL_PARAM *oqs_imexport_types(int selection) { // hybrid algorithm. // // Returns 1 if hybrid, else 0. -static int oqsx_key_is_hybrid(const OQSX_KEY *oqsxk) { - if ((oqsxk->keytype == KEY_TYPE_ECP_HYB_KEM || - oqsxk->keytype == KEY_TYPE_ECX_HYB_KEM || - oqsxk->keytype == KEY_TYPE_HYB_SIG) && - oqsxk->numkeys == 2 && oqsxk->classical_pkey != NULL) { +static int oqsx_key_is_hybrid(const OQSX_KEY *oqsxk) +{ + if ((oqsxk->keytype == KEY_TYPE_ECP_HYB_KEM + || oqsxk->keytype == KEY_TYPE_ECX_HYB_KEM + || oqsxk->keytype == KEY_TYPE_HYB_SIG) + && oqsxk->numkeys == 2 && oqsxk->classical_pkey != NULL) { OQS_KM_PRINTF("OQSKEYMGMT: key is hybrid\n"); return 1; } @@ -368,7 +381,8 @@ static int oqsx_key_is_hybrid(const OQSX_KEY *oqsxk) { // Gets hybrid params. // // Returns 0 on success. -static int oqsx_get_hybrid_params(OQSX_KEY *key, OSSL_PARAM params[]) { +static int oqsx_get_hybrid_params(OQSX_KEY *key, OSSL_PARAM params[]) +{ OSSL_PARAM *p; const void *classical_pubkey = NULL; const void *classical_privkey = NULL; @@ -392,13 +406,13 @@ static int oqsx_get_hybrid_params(OQSX_KEY *key, OSSL_PARAM params[]) { oqsx_comp_set_idx(key, &idx_classic, &idx_pq); - if (key->comp_pubkey != NULL && key->pubkey != NULL && - key->comp_pubkey[idx_classic] != NULL) { + if (key->comp_pubkey != NULL && key->pubkey != NULL + && key->comp_pubkey[idx_classic] != NULL) { classical_pubkey = key->comp_pubkey[idx_classic]; DECODE_UINT32(classical_pubkey_len, key->pubkey); } - if (key->comp_privkey != NULL && key->privkey != NULL && - key->comp_privkey[idx_classic] != NULL) { + if (key->comp_privkey != NULL && key->privkey != NULL + && key->comp_privkey[idx_classic] != NULL) { classical_privkey = key->comp_privkey[idx_classic]; DECODE_UINT32(classical_privkey_len, key->privkey); } @@ -409,33 +423,36 @@ static int oqsx_get_hybrid_params(OQSX_KEY *key, OSSL_PARAM params[]) { } if (key->comp_privkey != NULL && key->comp_privkey != NULL) { pq_privkey = key->comp_privkey[idx_pq]; - pq_privkey_len = - key->privkeylen - classical_privkey_len - SIZE_OF_UINT32; + pq_privkey_len + = key->privkeylen - classical_privkey_len - SIZE_OF_UINT32; } - if ((p = OSSL_PARAM_locate( - params, OQS_HYBRID_PKEY_PARAM_CLASSICAL_PUB_KEY)) != NULL && - !OSSL_PARAM_set_octet_string(p, classical_pubkey, classical_pubkey_len)) + if ((p = OSSL_PARAM_locate(params, OQS_HYBRID_PKEY_PARAM_CLASSICAL_PUB_KEY)) + != NULL + && !OSSL_PARAM_set_octet_string(p, classical_pubkey, + classical_pubkey_len)) return -1; - if ((p = OSSL_PARAM_locate( - params, OQS_HYBRID_PKEY_PARAM_CLASSICAL_PRIV_KEY)) != NULL && - !OSSL_PARAM_set_octet_string(p, classical_privkey, - classical_privkey_len)) + if ((p + = OSSL_PARAM_locate(params, OQS_HYBRID_PKEY_PARAM_CLASSICAL_PRIV_KEY)) + != NULL + && !OSSL_PARAM_set_octet_string(p, classical_privkey, + classical_privkey_len)) return -1; - if ((p = OSSL_PARAM_locate(params, OQS_HYBRID_PKEY_PARAM_PQ_PUB_KEY)) != - NULL && - !OSSL_PARAM_set_octet_string(p, pq_pubkey, pq_pubkey_len)) + if ((p = OSSL_PARAM_locate(params, OQS_HYBRID_PKEY_PARAM_PQ_PUB_KEY)) + != NULL + && !OSSL_PARAM_set_octet_string(p, pq_pubkey, pq_pubkey_len)) return -1; - if ((p = OSSL_PARAM_locate(params, OQS_HYBRID_PKEY_PARAM_PQ_PRIV_KEY)) != - NULL && - !OSSL_PARAM_set_octet_string(p, pq_privkey, pq_privkey_len)) + if ((p = OSSL_PARAM_locate(params, OQS_HYBRID_PKEY_PARAM_PQ_PRIV_KEY)) + != NULL + && !OSSL_PARAM_set_octet_string(p, pq_privkey, pq_privkey_len)) return -1; return 0; } // must handle param requests for KEM and SIG keys... -static int oqsx_get_params(void *key, OSSL_PARAM params[]) { +static int oqsx_get_params(void *key, OSSL_PARAM params[]) +{ OQSX_KEY *oqsxk = key; OSSL_PARAM *p; @@ -445,34 +462,32 @@ static int oqsx_get_params(void *key, OSSL_PARAM params[]) { } OQS_KM_PRINTF2("OQSKEYMGMT: get_params called for %s\n", params[0].key); - if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL && - !OSSL_PARAM_set_int(p, oqsx_key_secbits(oqsxk))) + if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL + && !OSSL_PARAM_set_int(p, oqsx_key_secbits(oqsxk))) return 0; - if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_BITS)) != - NULL && - !OSSL_PARAM_set_int(p, oqsx_key_secbits(oqsxk))) + if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_BITS)) != NULL + && !OSSL_PARAM_set_int(p, oqsx_key_secbits(oqsxk))) return 0; - if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL && - !OSSL_PARAM_set_int(p, oqsx_key_maxsize(oqsxk))) + if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL + && !OSSL_PARAM_set_int(p, oqsx_key_maxsize(oqsxk))) return 0; /* add as temporary workaround TBC */ - if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != - NULL && - !OSSL_PARAM_set_utf8_string(p, SN_undef)) + if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL + && !OSSL_PARAM_set_utf8_string(p, SN_undef)) return 0; - if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MANDATORY_DIGEST)) != - NULL && - !OSSL_PARAM_set_utf8_string(p, SN_undef)) + if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MANDATORY_DIGEST)) + != NULL + && !OSSL_PARAM_set_utf8_string(p, SN_undef)) return 0; /* end workaround */ - if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY)) != - NULL) { + if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY)) + != NULL) { // hybrid KEMs are special in that the classic length information // shall not be passed out: - if (oqsxk->keytype == KEY_TYPE_ECP_HYB_KEM || - oqsxk->keytype == KEY_TYPE_ECX_HYB_KEM) { + if (oqsxk->keytype == KEY_TYPE_ECP_HYB_KEM + || oqsxk->keytype == KEY_TYPE_ECX_HYB_KEM) { if (!OSSL_PARAM_set_octet_string( p, (char *)oqsxk->pubkey + SIZE_OF_UINT32, oqsxk->pubkeylen - SIZE_OF_UINT32)) @@ -499,20 +514,22 @@ static int oqsx_get_params(void *key, OSSL_PARAM params[]) { return 1; } -static const OSSL_PARAM oqsx_gettable_params[] = { - OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL), - OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL), - OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL), - OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, NULL, 0), - OQS_KEY_TYPES(), - OSSL_PARAM_END}; +static const OSSL_PARAM oqsx_gettable_params[] + = {OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL), + OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL), + OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL), + OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, NULL, 0), + OQS_KEY_TYPES(), + OSSL_PARAM_END}; -static const OSSL_PARAM *oqs_gettable_params(void *provctx) { +static const OSSL_PARAM *oqs_gettable_params(void *provctx) +{ OQS_KM_PRINTF("OQSKEYMGMT: gettable_params called\n"); return oqsx_gettable_params; } -static int set_property_query(OQSX_KEY *oqsxkey, const char *propq) { +static int set_property_query(OQSX_KEY *oqsxkey, const char *propq) +{ OPENSSL_free(oqsxkey->propq); oqsxkey->propq = NULL; OQS_KM_PRINTF("OQSKEYMGMT: property_query called\n"); @@ -526,7 +543,8 @@ static int set_property_query(OQSX_KEY *oqsxkey, const char *propq) { return 1; } -static int oqsx_set_params(void *key, const OSSL_PARAM params[]) { +static int oqsx_set_params(void *key, const OSSL_PARAM params[]) +{ OQSX_KEY *oqsxkey = key; const OSSL_PARAM *p; @@ -539,20 +557,20 @@ static int oqsx_set_params(void *key, const OSSL_PARAM params[]) { if (p != NULL) { size_t used_len; int classic_pubkey_len; - if (oqsxkey->keytype == KEY_TYPE_ECP_HYB_KEM || - oqsxkey->keytype == KEY_TYPE_ECX_HYB_KEM) { + if (oqsxkey->keytype == KEY_TYPE_ECP_HYB_KEM + || oqsxkey->keytype == KEY_TYPE_ECX_HYB_KEM) { // classic key len already stored by key setup; only data // needs to be filled in - if (p->data_size != oqsxkey->pubkeylen - SIZE_OF_UINT32 || - !OSSL_PARAM_get_octet_string( + if (p->data_size != oqsxkey->pubkeylen - SIZE_OF_UINT32 + || !OSSL_PARAM_get_octet_string( p, &oqsxkey->comp_pubkey[0], oqsxkey->pubkeylen - SIZE_OF_UINT32, &used_len)) { return 0; } } else { - if (p->data_size != oqsxkey->pubkeylen || - !OSSL_PARAM_get_octet_string(p, &oqsxkey->pubkey, - oqsxkey->pubkeylen, &used_len)) { + if (p->data_size != oqsxkey->pubkeylen + || !OSSL_PARAM_get_octet_string( + p, &oqsxkey->pubkey, oqsxkey->pubkeylen, &used_len)) { return 0; } } @@ -561,8 +579,8 @@ static int oqsx_set_params(void *key, const OSSL_PARAM params[]) { } p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PROPERTIES); if (p != NULL) { - if (p->data_type != OSSL_PARAM_UTF8_STRING || - !set_property_query(oqsxkey, p->data)) { + if (p->data_type != OSSL_PARAM_UTF8_STRING + || !set_property_query(oqsxkey, p->data)) { return 0; } } @@ -571,19 +589,21 @@ static int oqsx_set_params(void *key, const OSSL_PARAM params[]) { return 1; } -static const OSSL_PARAM oqs_settable_params[] = { - OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, NULL, 0), - OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0), - OSSL_PARAM_END}; +static const OSSL_PARAM oqs_settable_params[] + = {OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, NULL, 0), + OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_PROPERTIES, NULL, 0), + OSSL_PARAM_END}; -static const OSSL_PARAM *oqsx_settable_params(void *provctx) { +static const OSSL_PARAM *oqsx_settable_params(void *provctx) +{ OQS_KM_PRINTF("OQSKEYMGMT: settable_params called\n"); return oqs_settable_params; } static void *oqsx_gen_init(void *provctx, int selection, char *oqs_name, char *tls_name, int primitive, int bit_security, - int alg_idx, int reverse_share) { + int alg_idx, int reverse_share) +{ OSSL_LIB_CTX *libctx = PROV_OQS_LIBCTX_OF(provctx); struct oqsx_gen_ctx *gctx = NULL; @@ -603,7 +623,8 @@ static void *oqsx_gen_init(void *provctx, int selection, char *oqs_name, return gctx; } -static void *oqsx_genkey(struct oqsx_gen_ctx *gctx) { +static void *oqsx_genkey(struct oqsx_gen_ctx *gctx) +{ OQSX_KEY *key; if (gctx == NULL) @@ -612,7 +633,8 @@ static void *oqsx_genkey(struct oqsx_gen_ctx *gctx) { gctx->tls_name); if ((key = oqsx_key_new(gctx->libctx, gctx->oqs_name, gctx->tls_name, gctx->primitive, gctx->propq, gctx->bit_security, - gctx->alg_idx, gctx->reverse_share)) == NULL) { + gctx->alg_idx, gctx->reverse_share)) + == NULL) { OQS_KM_PRINTF2("OQSKM: Error generating key for %s\n", gctx->tls_name); ERR_raise(ERR_LIB_USER, ERR_R_MALLOC_FAILURE); return NULL; @@ -625,7 +647,8 @@ static void *oqsx_genkey(struct oqsx_gen_ctx *gctx) { return key; } -static void *oqsx_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg) { +static void *oqsx_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg) +{ struct oqsx_gen_ctx *gctx = genctx; OQS_KM_PRINTF("OQSKEYMGMT: gen called\n"); @@ -633,7 +656,8 @@ static void *oqsx_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg) { return oqsx_genkey(gctx); } -static void oqsx_gen_cleanup(void *genctx) { +static void oqsx_gen_cleanup(void *genctx) +{ struct oqsx_gen_ctx *gctx = genctx; OQS_KM_PRINTF("OQSKEYMGMT: gen_cleanup called\n"); @@ -643,7 +667,8 @@ static void oqsx_gen_cleanup(void *genctx) { OPENSSL_free(gctx); } -void *oqsx_load(const void *reference, size_t reference_sz) { +void *oqsx_load(const void *reference, size_t reference_sz) +{ OQSX_KEY *key = NULL; OQS_KM_PRINTF("OQSKEYMGMT: load called\n"); @@ -657,15 +682,17 @@ void *oqsx_load(const void *reference, size_t reference_sz) { return NULL; } -static const OSSL_PARAM *oqsx_gen_settable_params(void *provctx) { - static OSSL_PARAM settable[] = { - OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, NULL, 0), - OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_PROPERTIES, NULL, 0), - OSSL_PARAM_END}; +static const OSSL_PARAM *oqsx_gen_settable_params(void *provctx) +{ + static OSSL_PARAM settable[] + = {OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_GROUP_NAME, NULL, 0), + OSSL_PARAM_utf8_string(OSSL_KDF_PARAM_PROPERTIES, NULL, 0), + OSSL_PARAM_END}; return settable; } -static int oqsx_gen_set_params(void *genctx, const OSSL_PARAM params[]) { +static int oqsx_gen_set_params(void *genctx, const OSSL_PARAM params[]) +{ struct oqsx_gen_ctx *gctx = genctx; const OSSL_PARAM *p; @@ -695,638 +722,755 @@ static int oqsx_gen_set_params(void *genctx, const OSSL_PARAM params[]) { } ///// OQS_TEMPLATE_FRAGMENT_KEYMGMT_CONSTRUCTORS_START -static void *dilithium2_new_key(void *provctx) { +static void *dilithium2_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_dilithium_2, "dilithium2", KEY_TYPE_SIG, NULL, 128, 0, 0); } -static void *dilithium2_gen_init(void *provctx, int selection) { +static void *dilithium2_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_dilithium_2, "dilithium2", 0, 128, 0, 0); } -static void *p256_dilithium2_new_key(void *provctx) { +static void *p256_dilithium2_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_dilithium_2, "p256_dilithium2", KEY_TYPE_HYB_SIG, NULL, 128, 1, 0); } -static void *p256_dilithium2_gen_init(void *provctx, int selection) { +static void *p256_dilithium2_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_dilithium_2, "p256_dilithium2", KEY_TYPE_HYB_SIG, 128, 1, 0); } -static void *rsa3072_dilithium2_new_key(void *provctx) { +static void *rsa3072_dilithium2_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_dilithium_2, "rsa3072_dilithium2", KEY_TYPE_HYB_SIG, NULL, 128, 2, 0); } -static void *rsa3072_dilithium2_gen_init(void *provctx, int selection) { +static void *rsa3072_dilithium2_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_dilithium_2, "rsa3072_dilithium2", KEY_TYPE_HYB_SIG, 128, 2, 0); } -static void *dilithium3_new_key(void *provctx) { +static void *dilithium3_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_dilithium_3, "dilithium3", KEY_TYPE_SIG, NULL, 192, 3, 0); } -static void *dilithium3_gen_init(void *provctx, int selection) { +static void *dilithium3_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_dilithium_3, "dilithium3", 0, 192, 3, 0); } -static void *p384_dilithium3_new_key(void *provctx) { +static void *p384_dilithium3_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_dilithium_3, "p384_dilithium3", KEY_TYPE_HYB_SIG, NULL, 192, 4, 0); } -static void *p384_dilithium3_gen_init(void *provctx, int selection) { +static void *p384_dilithium3_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_dilithium_3, "p384_dilithium3", KEY_TYPE_HYB_SIG, 192, 4, 0); } -static void *dilithium5_new_key(void *provctx) { +static void *dilithium5_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_dilithium_5, "dilithium5", KEY_TYPE_SIG, NULL, 256, 5, 0); } -static void *dilithium5_gen_init(void *provctx, int selection) { +static void *dilithium5_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_dilithium_5, "dilithium5", 0, 256, 5, 0); } -static void *p521_dilithium5_new_key(void *provctx) { +static void *p521_dilithium5_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_dilithium_5, "p521_dilithium5", KEY_TYPE_HYB_SIG, NULL, 256, 6, 0); } -static void *p521_dilithium5_gen_init(void *provctx, int selection) { +static void *p521_dilithium5_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_dilithium_5, "p521_dilithium5", KEY_TYPE_HYB_SIG, 256, 6, 0); } -static void *mldsa44_new_key(void *provctx) { +static void *mldsa44_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_44, "mldsa44", KEY_TYPE_SIG, NULL, 128, 7, 0); } -static void *mldsa44_gen_init(void *provctx, int selection) { +static void *mldsa44_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_44, "mldsa44", 0, 128, 7, 0); } -static void *p256_mldsa44_new_key(void *provctx) { +static void *p256_mldsa44_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_44, "p256_mldsa44", KEY_TYPE_HYB_SIG, NULL, 128, 8, 0); } -static void *p256_mldsa44_gen_init(void *provctx, int selection) { +static void *p256_mldsa44_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_44, "p256_mldsa44", KEY_TYPE_HYB_SIG, 128, 8, 0); } -static void *rsa3072_mldsa44_new_key(void *provctx) { +static void *rsa3072_mldsa44_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_44, "rsa3072_mldsa44", KEY_TYPE_HYB_SIG, NULL, 128, 9, 0); } -static void *rsa3072_mldsa44_gen_init(void *provctx, int selection) { +static void *rsa3072_mldsa44_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_44, "rsa3072_mldsa44", KEY_TYPE_HYB_SIG, 128, 9, 0); } -static void *mldsa44_pss2048_new_key(void *provctx) { +static void *mldsa44_pss2048_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_44, "mldsa44_pss2048", KEY_TYPE_CMP_SIG, NULL, 112, 10, 0); } -static void *mldsa44_pss2048_gen_init(void *provctx, int selection) { +static void *mldsa44_pss2048_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_44, "mldsa44_pss2048", KEY_TYPE_CMP_SIG, 112, 10, 0); } -static void *mldsa44_rsa2048_new_key(void *provctx) { +static void *mldsa44_rsa2048_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_44, "mldsa44_rsa2048", KEY_TYPE_CMP_SIG, NULL, 112, 11, 0); } -static void *mldsa44_rsa2048_gen_init(void *provctx, int selection) { +static void *mldsa44_rsa2048_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_44, "mldsa44_rsa2048", KEY_TYPE_CMP_SIG, 112, 11, 0); } -static void *mldsa44_ed25519_new_key(void *provctx) { +static void *mldsa44_ed25519_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_44, "mldsa44_ed25519", KEY_TYPE_CMP_SIG, NULL, 128, 12, 0); } -static void *mldsa44_ed25519_gen_init(void *provctx, int selection) { +static void *mldsa44_ed25519_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_44, "mldsa44_ed25519", KEY_TYPE_CMP_SIG, 128, 12, 0); } -static void *mldsa44_p256_new_key(void *provctx) { +static void *mldsa44_p256_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_44, "mldsa44_p256", KEY_TYPE_CMP_SIG, NULL, 128, 13, 0); } -static void *mldsa44_p256_gen_init(void *provctx, int selection) { +static void *mldsa44_p256_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_44, "mldsa44_p256", KEY_TYPE_CMP_SIG, 128, 13, 0); } -static void *mldsa44_bp256_new_key(void *provctx) { +static void *mldsa44_bp256_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_44, "mldsa44_bp256", KEY_TYPE_CMP_SIG, NULL, 256, 14, 0); } -static void *mldsa44_bp256_gen_init(void *provctx, int selection) { +static void *mldsa44_bp256_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_44, "mldsa44_bp256", KEY_TYPE_CMP_SIG, 256, 14, 0); } -static void *mldsa65_new_key(void *provctx) { +static void *mldsa65_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_65, "mldsa65", KEY_TYPE_SIG, NULL, 192, 15, 0); } -static void *mldsa65_gen_init(void *provctx, int selection) { +static void *mldsa65_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_65, "mldsa65", 0, 192, 15, 0); } -static void *p384_mldsa65_new_key(void *provctx) { +static void *p384_mldsa65_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_65, "p384_mldsa65", KEY_TYPE_HYB_SIG, NULL, 192, 16, 0); } -static void *p384_mldsa65_gen_init(void *provctx, int selection) { +static void *p384_mldsa65_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_65, "p384_mldsa65", KEY_TYPE_HYB_SIG, 192, 16, 0); } -static void *mldsa65_pss3072_new_key(void *provctx) { +static void *mldsa65_pss3072_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_65, "mldsa65_pss3072", KEY_TYPE_CMP_SIG, NULL, 128, 17, 0); } -static void *mldsa65_pss3072_gen_init(void *provctx, int selection) { +static void *mldsa65_pss3072_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_65, "mldsa65_pss3072", KEY_TYPE_CMP_SIG, 128, 17, 0); } -static void *mldsa65_rsa3072_new_key(void *provctx) { +static void *mldsa65_rsa3072_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_65, "mldsa65_rsa3072", KEY_TYPE_CMP_SIG, NULL, 128, 18, 0); } -static void *mldsa65_rsa3072_gen_init(void *provctx, int selection) { +static void *mldsa65_rsa3072_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_65, "mldsa65_rsa3072", KEY_TYPE_CMP_SIG, 128, 18, 0); } -static void *mldsa65_p256_new_key(void *provctx) { +static void *mldsa65_p256_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_65, "mldsa65_p256", KEY_TYPE_CMP_SIG, NULL, 128, 19, 0); } -static void *mldsa65_p256_gen_init(void *provctx, int selection) { +static void *mldsa65_p256_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_65, "mldsa65_p256", KEY_TYPE_CMP_SIG, 128, 19, 0); } -static void *mldsa65_bp256_new_key(void *provctx) { +static void *mldsa65_bp256_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_65, "mldsa65_bp256", KEY_TYPE_CMP_SIG, NULL, 256, 20, 0); } -static void *mldsa65_bp256_gen_init(void *provctx, int selection) { +static void *mldsa65_bp256_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_65, "mldsa65_bp256", KEY_TYPE_CMP_SIG, 256, 20, 0); } -static void *mldsa65_ed25519_new_key(void *provctx) { +static void *mldsa65_ed25519_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_65, "mldsa65_ed25519", KEY_TYPE_CMP_SIG, NULL, 128, 21, 0); } -static void *mldsa65_ed25519_gen_init(void *provctx, int selection) { +static void *mldsa65_ed25519_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_65, "mldsa65_ed25519", KEY_TYPE_CMP_SIG, 128, 21, 0); } -static void *mldsa87_new_key(void *provctx) { +static void *mldsa87_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_87, "mldsa87", KEY_TYPE_SIG, NULL, 256, 22, 0); } -static void *mldsa87_gen_init(void *provctx, int selection) { +static void *mldsa87_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_87, "mldsa87", 0, 256, 22, 0); } -static void *p521_mldsa87_new_key(void *provctx) { +static void *p521_mldsa87_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_87, "p521_mldsa87", KEY_TYPE_HYB_SIG, NULL, 256, 23, 0); } -static void *p521_mldsa87_gen_init(void *provctx, int selection) { +static void *p521_mldsa87_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_87, "p521_mldsa87", KEY_TYPE_HYB_SIG, 256, 23, 0); } -static void *mldsa87_p384_new_key(void *provctx) { +static void *mldsa87_p384_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_87, "mldsa87_p384", KEY_TYPE_CMP_SIG, NULL, 192, 24, 0); } -static void *mldsa87_p384_gen_init(void *provctx, int selection) { +static void *mldsa87_p384_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_87, "mldsa87_p384", KEY_TYPE_CMP_SIG, 192, 24, 0); } -static void *mldsa87_bp384_new_key(void *provctx) { +static void *mldsa87_bp384_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_87, "mldsa87_bp384", KEY_TYPE_CMP_SIG, NULL, 384, 25, 0); } -static void *mldsa87_bp384_gen_init(void *provctx, int selection) { +static void *mldsa87_bp384_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_87, "mldsa87_bp384", KEY_TYPE_CMP_SIG, 384, 25, 0); } -static void *mldsa87_ed448_new_key(void *provctx) { +static void *mldsa87_ed448_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_ml_dsa_87, "mldsa87_ed448", KEY_TYPE_CMP_SIG, NULL, 192, 26, 0); } -static void *mldsa87_ed448_gen_init(void *provctx, int selection) { +static void *mldsa87_ed448_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_ml_dsa_87, "mldsa87_ed448", KEY_TYPE_CMP_SIG, 192, 26, 0); } -static void *falcon512_new_key(void *provctx) { +static void *falcon512_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_512, "falcon512", KEY_TYPE_SIG, NULL, 128, 27, 0); } -static void *falcon512_gen_init(void *provctx, int selection) { +static void *falcon512_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_512, "falcon512", 0, 128, 27, 0); } -static void *p256_falcon512_new_key(void *provctx) { +static void *p256_falcon512_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_512, "p256_falcon512", KEY_TYPE_HYB_SIG, NULL, 128, 28, 0); } -static void *p256_falcon512_gen_init(void *provctx, int selection) { +static void *p256_falcon512_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_512, "p256_falcon512", KEY_TYPE_HYB_SIG, 128, 28, 0); } -static void *rsa3072_falcon512_new_key(void *provctx) { +static void *rsa3072_falcon512_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_512, "rsa3072_falcon512", KEY_TYPE_HYB_SIG, NULL, 128, 29, 0); } -static void *rsa3072_falcon512_gen_init(void *provctx, int selection) { +static void *rsa3072_falcon512_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_512, "rsa3072_falcon512", KEY_TYPE_HYB_SIG, 128, 29, 0); } -static void *falconpadded512_new_key(void *provctx) { +static void *falconpadded512_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_padded_512, "falconpadded512", KEY_TYPE_SIG, NULL, 128, 30, 0); } -static void *falconpadded512_gen_init(void *provctx, int selection) { +static void *falconpadded512_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_padded_512, "falconpadded512", 0, 128, 30, 0); } -static void *p256_falconpadded512_new_key(void *provctx) { +static void *p256_falconpadded512_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_padded_512, "p256_falconpadded512", KEY_TYPE_HYB_SIG, NULL, 128, 31, 0); } -static void *p256_falconpadded512_gen_init(void *provctx, int selection) { +static void *p256_falconpadded512_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_padded_512, "p256_falconpadded512", KEY_TYPE_HYB_SIG, 128, 31, 0); } -static void *rsa3072_falconpadded512_new_key(void *provctx) { +static void *rsa3072_falconpadded512_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_padded_512, "rsa3072_falconpadded512", KEY_TYPE_HYB_SIG, NULL, 128, 32, 0); } -static void *rsa3072_falconpadded512_gen_init(void *provctx, int selection) { +static void *rsa3072_falconpadded512_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_padded_512, "rsa3072_falconpadded512", KEY_TYPE_HYB_SIG, 128, 32, 0); } -static void *falcon1024_new_key(void *provctx) { +static void *falcon1024_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_1024, "falcon1024", KEY_TYPE_SIG, NULL, 256, 33, 0); } -static void *falcon1024_gen_init(void *provctx, int selection) { +static void *falcon1024_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_1024, "falcon1024", 0, 256, 33, 0); } -static void *p521_falcon1024_new_key(void *provctx) { +static void *p521_falcon1024_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_1024, "p521_falcon1024", KEY_TYPE_HYB_SIG, NULL, 256, 34, 0); } -static void *p521_falcon1024_gen_init(void *provctx, int selection) { +static void *p521_falcon1024_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_1024, "p521_falcon1024", KEY_TYPE_HYB_SIG, 256, 34, 0); } -static void *falconpadded1024_new_key(void *provctx) { +static void *falconpadded1024_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_padded_1024, "falconpadded1024", KEY_TYPE_SIG, NULL, 256, 35, 0); } -static void *falconpadded1024_gen_init(void *provctx, int selection) { +static void *falconpadded1024_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_padded_1024, "falconpadded1024", 0, 256, 35, 0); } -static void *p521_falconpadded1024_new_key(void *provctx) { +static void *p521_falconpadded1024_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_falcon_padded_1024, "p521_falconpadded1024", KEY_TYPE_HYB_SIG, NULL, 256, 36, 0); } -static void *p521_falconpadded1024_gen_init(void *provctx, int selection) { +static void *p521_falconpadded1024_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_falcon_padded_1024, "p521_falconpadded1024", KEY_TYPE_HYB_SIG, 256, 36, 0); } -static void *sphincssha2128fsimple_new_key(void *provctx) { +static void *sphincssha2128fsimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_sha2_128f_simple, "sphincssha2128fsimple", KEY_TYPE_SIG, NULL, 128, 37, 0); } -static void *sphincssha2128fsimple_gen_init(void *provctx, int selection) { +static void *sphincssha2128fsimple_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_sphincs_sha2_128f_simple, "sphincssha2128fsimple", 0, 128, 37, 0); } -static void *p256_sphincssha2128fsimple_new_key(void *provctx) { +static void *p256_sphincssha2128fsimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_sha2_128f_simple, "p256_sphincssha2128fsimple", KEY_TYPE_HYB_SIG, NULL, 128, 38, 0); } -static void *p256_sphincssha2128fsimple_gen_init(void *provctx, int selection) { +static void *p256_sphincssha2128fsimple_gen_init(void *provctx, int selection) +{ return oqsx_gen_init( provctx, selection, OQS_SIG_alg_sphincs_sha2_128f_simple, "p256_sphincssha2128fsimple", KEY_TYPE_HYB_SIG, 128, 38, 0); } -static void *rsa3072_sphincssha2128fsimple_new_key(void *provctx) { +static void *rsa3072_sphincssha2128fsimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_sha2_128f_simple, "rsa3072_sphincssha2128fsimple", KEY_TYPE_HYB_SIG, NULL, 128, 39, 0); } static void *rsa3072_sphincssha2128fsimple_gen_init(void *provctx, - int selection) { + int selection) +{ return oqsx_gen_init( provctx, selection, OQS_SIG_alg_sphincs_sha2_128f_simple, "rsa3072_sphincssha2128fsimple", KEY_TYPE_HYB_SIG, 128, 39, 0); } -static void *sphincssha2128ssimple_new_key(void *provctx) { +static void *sphincssha2128ssimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_sha2_128s_simple, "sphincssha2128ssimple", KEY_TYPE_SIG, NULL, 128, 40, 0); } -static void *sphincssha2128ssimple_gen_init(void *provctx, int selection) { +static void *sphincssha2128ssimple_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_sphincs_sha2_128s_simple, "sphincssha2128ssimple", 0, 128, 40, 0); } -static void *p256_sphincssha2128ssimple_new_key(void *provctx) { +static void *p256_sphincssha2128ssimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_sha2_128s_simple, "p256_sphincssha2128ssimple", KEY_TYPE_HYB_SIG, NULL, 128, 41, 0); } -static void *p256_sphincssha2128ssimple_gen_init(void *provctx, int selection) { +static void *p256_sphincssha2128ssimple_gen_init(void *provctx, int selection) +{ return oqsx_gen_init( provctx, selection, OQS_SIG_alg_sphincs_sha2_128s_simple, "p256_sphincssha2128ssimple", KEY_TYPE_HYB_SIG, 128, 41, 0); } -static void *rsa3072_sphincssha2128ssimple_new_key(void *provctx) { +static void *rsa3072_sphincssha2128ssimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_sha2_128s_simple, "rsa3072_sphincssha2128ssimple", KEY_TYPE_HYB_SIG, NULL, 128, 42, 0); } static void *rsa3072_sphincssha2128ssimple_gen_init(void *provctx, - int selection) { + int selection) +{ return oqsx_gen_init( provctx, selection, OQS_SIG_alg_sphincs_sha2_128s_simple, "rsa3072_sphincssha2128ssimple", KEY_TYPE_HYB_SIG, 128, 42, 0); } -static void *sphincssha2192fsimple_new_key(void *provctx) { +static void *sphincssha2192fsimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_sha2_192f_simple, "sphincssha2192fsimple", KEY_TYPE_SIG, NULL, 192, 43, 0); } -static void *sphincssha2192fsimple_gen_init(void *provctx, int selection) { +static void *sphincssha2192fsimple_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_sphincs_sha2_192f_simple, "sphincssha2192fsimple", 0, 192, 43, 0); } -static void *p384_sphincssha2192fsimple_new_key(void *provctx) { +static void *p384_sphincssha2192fsimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_sha2_192f_simple, "p384_sphincssha2192fsimple", KEY_TYPE_HYB_SIG, NULL, 192, 44, 0); } -static void *p384_sphincssha2192fsimple_gen_init(void *provctx, int selection) { +static void *p384_sphincssha2192fsimple_gen_init(void *provctx, int selection) +{ return oqsx_gen_init( provctx, selection, OQS_SIG_alg_sphincs_sha2_192f_simple, "p384_sphincssha2192fsimple", KEY_TYPE_HYB_SIG, 192, 44, 0); } -static void *sphincsshake128fsimple_new_key(void *provctx) { +static void *sphincsshake128fsimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_shake_128f_simple, "sphincsshake128fsimple", KEY_TYPE_SIG, NULL, 128, 45, 0); } -static void *sphincsshake128fsimple_gen_init(void *provctx, int selection) { +static void *sphincsshake128fsimple_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_sphincs_shake_128f_simple, "sphincsshake128fsimple", 0, 128, 45, 0); } -static void *p256_sphincsshake128fsimple_new_key(void *provctx) { +static void *p256_sphincsshake128fsimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_shake_128f_simple, "p256_sphincsshake128fsimple", KEY_TYPE_HYB_SIG, NULL, 128, 46, 0); } -static void *p256_sphincsshake128fsimple_gen_init(void *provctx, - int selection) { +static void *p256_sphincsshake128fsimple_gen_init(void *provctx, int selection) +{ return oqsx_gen_init( provctx, selection, OQS_SIG_alg_sphincs_shake_128f_simple, "p256_sphincsshake128fsimple", KEY_TYPE_HYB_SIG, 128, 46, 0); } -static void *rsa3072_sphincsshake128fsimple_new_key(void *provctx) { +static void *rsa3072_sphincsshake128fsimple_new_key(void *provctx) +{ return oqsx_key_new( PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_sphincs_shake_128f_simple, "rsa3072_sphincsshake128fsimple", KEY_TYPE_HYB_SIG, NULL, 128, 47, 0); } static void *rsa3072_sphincsshake128fsimple_gen_init(void *provctx, - int selection) { + int selection) +{ return oqsx_gen_init( provctx, selection, OQS_SIG_alg_sphincs_shake_128f_simple, "rsa3072_sphincsshake128fsimple", KEY_TYPE_HYB_SIG, 128, 47, 0); } -static void *mayo1_new_key(void *provctx) { +static void *mayo1_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_mayo_1, "mayo1", KEY_TYPE_SIG, NULL, 128, 48, 0); } -static void *mayo1_gen_init(void *provctx, int selection) { +static void *mayo1_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_mayo_1, "mayo1", 0, 128, 48, 0); } -static void *p256_mayo1_new_key(void *provctx) { +static void *p256_mayo1_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_mayo_1, "p256_mayo1", KEY_TYPE_HYB_SIG, NULL, 128, 49, 0); } -static void *p256_mayo1_gen_init(void *provctx, int selection) { +static void *p256_mayo1_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_mayo_1, "p256_mayo1", KEY_TYPE_HYB_SIG, 128, 49, 0); } -static void *mayo2_new_key(void *provctx) { +static void *mayo2_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_mayo_2, "mayo2", KEY_TYPE_SIG, NULL, 128, 50, 0); } -static void *mayo2_gen_init(void *provctx, int selection) { +static void *mayo2_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_mayo_2, "mayo2", 0, 128, 50, 0); } -static void *p256_mayo2_new_key(void *provctx) { +static void *p256_mayo2_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_mayo_2, "p256_mayo2", KEY_TYPE_HYB_SIG, NULL, 128, 51, 0); } -static void *p256_mayo2_gen_init(void *provctx, int selection) { +static void *p256_mayo2_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_mayo_2, "p256_mayo2", KEY_TYPE_HYB_SIG, 128, 51, 0); } -static void *mayo3_new_key(void *provctx) { +static void *mayo3_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_mayo_3, "mayo3", KEY_TYPE_SIG, NULL, 192, 52, 0); } -static void *mayo3_gen_init(void *provctx, int selection) { +static void *mayo3_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_mayo_3, "mayo3", 0, 192, 52, 0); } -static void *p384_mayo3_new_key(void *provctx) { +static void *p384_mayo3_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_mayo_3, "p384_mayo3", KEY_TYPE_HYB_SIG, NULL, 192, 53, 0); } -static void *p384_mayo3_gen_init(void *provctx, int selection) { +static void *p384_mayo3_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_mayo_3, "p384_mayo3", KEY_TYPE_HYB_SIG, 192, 53, 0); } -static void *mayo5_new_key(void *provctx) { +static void *mayo5_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_mayo_5, "mayo5", KEY_TYPE_SIG, NULL, 256, 54, 0); } -static void *mayo5_gen_init(void *provctx, int selection) { +static void *mayo5_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_mayo_5, "mayo5", 0, 256, 54, 0); } -static void *p521_mayo5_new_key(void *provctx) { +static void *p521_mayo5_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_mayo_5, "p521_mayo5", KEY_TYPE_HYB_SIG, NULL, 256, 55, 0); } -static void *p521_mayo5_gen_init(void *provctx, int selection) { +static void *p521_mayo5_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_mayo_5, "p521_mayo5", KEY_TYPE_HYB_SIG, 256, 55, 0); } -static void *CROSSrsdp128balanced_new_key(void *provctx) { +static void *CROSSrsdp128balanced_new_key(void *provctx) +{ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), OQS_SIG_alg_cross_rsdp_128_balanced, - "CROSSrsdp128balanced", KEY_TYPE_SIG, NULL, 128, 56); + "CROSSrsdp128balanced", KEY_TYPE_SIG, NULL, 128, 56, 0); } -static void *CROSSrsdp128balanced_gen_init(void *provctx, int selection) { +static void *CROSSrsdp128balanced_gen_init(void *provctx, int selection) +{ return oqsx_gen_init(provctx, selection, OQS_SIG_alg_cross_rsdp_128_balanced, - "CROSSrsdp128balanced", 0, 128, 56); + "CROSSrsdp128balanced", 0, 128, 56, 0); } ///// OQS_TEMPLATE_FRAGMENT_KEYMGMT_CONSTRUCTORS_END -#define MAKE_SIG_KEYMGMT_FUNCTIONS(alg) \ - \ - const OSSL_DISPATCH oqs_##alg##_keymgmt_functions[] = { \ - {OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))alg##_new_key}, \ - {OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))oqsx_key_free}, \ - {OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*)(void))oqsx_get_params}, \ - {OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, \ - (void (*)(void))oqsx_settable_params}, \ - {OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, \ - (void (*)(void))oqs_gettable_params}, \ - {OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*)(void))oqsx_set_params}, \ - {OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))oqsx_has}, \ - {OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))oqsx_match}, \ - {OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))oqsx_import}, \ - {OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))oqs_imexport_types}, \ - {OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))oqsx_export}, \ - {OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))oqs_imexport_types}, \ - {OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))alg##_gen_init}, \ - {OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))oqsx_gen}, \ - {OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))oqsx_gen_cleanup}, \ - {OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, \ - (void (*)(void))oqsx_gen_set_params}, \ - {OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, \ - (void (*)(void))oqsx_gen_settable_params}, \ - {OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))oqsx_load}, \ +#define MAKE_SIG_KEYMGMT_FUNCTIONS(alg) \ + \ + const OSSL_DISPATCH oqs_##alg##_keymgmt_functions[] = { \ + {OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))alg##_new_key}, \ + {OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))oqsx_key_free}, \ + {OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*)(void))oqsx_get_params}, \ + {OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, \ + (void (*)(void))oqsx_settable_params}, \ + {OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, \ + (void (*)(void))oqs_gettable_params}, \ + {OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*)(void))oqsx_set_params}, \ + {OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))oqsx_has}, \ + {OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))oqsx_match}, \ + {OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))oqsx_import}, \ + {OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))oqs_imexport_types}, \ + {OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))oqsx_export}, \ + {OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))oqs_imexport_types}, \ + {OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))alg##_gen_init}, \ + {OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))oqsx_gen}, \ + {OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))oqsx_gen_cleanup}, \ + {OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, \ + (void (*)(void))oqsx_gen_set_params}, \ + {OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, \ + (void (*)(void))oqsx_gen_settable_params}, \ + {OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))oqsx_load}, \ {0, NULL}}; -#define MAKE_KEM_KEYMGMT_FUNCTIONS(tokalg, tokoqsalg, bit_security) \ - \ - static void *tokalg##_new_key(void *provctx) { \ - return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), tokoqsalg, \ - "" #tokalg "", KEY_TYPE_KEM, NULL, bit_security, \ - -1, 0); \ - } \ - \ - static void *tokalg##_gen_init(void *provctx, int selection) { \ - return oqsx_gen_init(provctx, selection, tokoqsalg, "" #tokalg "", \ - KEY_TYPE_KEM, bit_security, -1, 0); \ - } \ - \ - const OSSL_DISPATCH oqs_##tokalg##_keymgmt_functions[] = { \ - {OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))tokalg##_new_key}, \ - {OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))oqsx_key_free}, \ - {OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*)(void))oqsx_get_params}, \ - {OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, \ - (void (*)(void))oqsx_settable_params}, \ - {OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, \ - (void (*)(void))oqs_gettable_params}, \ - {OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*)(void))oqsx_set_params}, \ - {OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))oqsx_has}, \ - {OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))oqsx_match}, \ - {OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))oqsx_import}, \ - {OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))oqs_imexport_types}, \ - {OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))oqsx_export}, \ - {OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))oqs_imexport_types}, \ - {OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))tokalg##_gen_init}, \ - {OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))oqsx_gen}, \ - {OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))oqsx_gen_cleanup}, \ - {OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, \ - (void (*)(void))oqsx_gen_set_params}, \ - {OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, \ - (void (*)(void))oqsx_gen_settable_params}, \ - {OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))oqsx_load}, \ +#define MAKE_KEM_KEYMGMT_FUNCTIONS(tokalg, tokoqsalg, bit_security) \ + \ + static void *tokalg##_new_key(void *provctx) \ + { \ + return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), tokoqsalg, \ + "" #tokalg "", KEY_TYPE_KEM, NULL, bit_security, \ + -1, 0); \ + } \ + \ + static void *tokalg##_gen_init(void *provctx, int selection) \ + { \ + return oqsx_gen_init(provctx, selection, tokoqsalg, "" #tokalg "", \ + KEY_TYPE_KEM, bit_security, -1, 0); \ + } \ + \ + const OSSL_DISPATCH oqs_##tokalg##_keymgmt_functions[] = { \ + {OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))tokalg##_new_key}, \ + {OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))oqsx_key_free}, \ + {OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*)(void))oqsx_get_params}, \ + {OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS, \ + (void (*)(void))oqsx_settable_params}, \ + {OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, \ + (void (*)(void))oqs_gettable_params}, \ + {OSSL_FUNC_KEYMGMT_SET_PARAMS, (void (*)(void))oqsx_set_params}, \ + {OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))oqsx_has}, \ + {OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))oqsx_match}, \ + {OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))oqsx_import}, \ + {OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))oqs_imexport_types}, \ + {OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))oqsx_export}, \ + {OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))oqs_imexport_types}, \ + {OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))tokalg##_gen_init}, \ + {OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))oqsx_gen}, \ + {OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))oqsx_gen_cleanup}, \ + {OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, \ + (void (*)(void))oqsx_gen_set_params}, \ + {OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, \ + (void (*)(void))oqsx_gen_settable_params}, \ + {OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))oqsx_load}, \ {0, NULL}}; #define MAKE_KEM_ECP_KEYMGMT_FUNCTIONS(tokalg, tokoqsalg, bit_security) \ \ - static void *ecp_##tokalg##_new_key(void *provctx) { \ + static void *ecp_##tokalg##_new_key(void *provctx) \ + { \ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), tokoqsalg, \ "" #tokalg "", KEY_TYPE_ECP_HYB_KEM, NULL, \ bit_security, -1, 0); \ } \ \ - static void *ecp_##tokalg##_gen_init(void *provctx, int selection) { \ + static void *ecp_##tokalg##_gen_init(void *provctx, int selection) \ + { \ return oqsx_gen_init(provctx, selection, tokoqsalg, "" #tokalg "", \ KEY_TYPE_ECP_HYB_KEM, bit_security, -1, 0); \ } \ @@ -1358,13 +1502,15 @@ static void *CROSSrsdp128balanced_gen_init(void *provctx, int selection) { #define MAKE_KEM_ECX_KEYMGMT_FUNCTIONS(tokalg, tokoqsalg, bit_security, \ pqfips) \ - static void *ecx_##tokalg##_new_key(void *provctx) { \ + static void *ecx_##tokalg##_new_key(void *provctx) \ + { \ return oqsx_key_new(PROV_OQS_LIBCTX_OF(provctx), tokoqsalg, \ "" #tokalg "", KEY_TYPE_ECX_HYB_KEM, NULL, \ bit_security, -1, pqfips); \ } \ \ - static void *ecx_##tokalg##_gen_init(void *provctx, int selection) { \ + static void *ecx_##tokalg##_gen_init(void *provctx, int selection) \ + { \ return oqsx_gen_init(provctx, selection, tokoqsalg, "" #tokalg "", \ KEY_TYPE_ECX_HYB_KEM, bit_security, -1, pqfips); \ } \ diff --git a/oqsprov/oqs_prov.h b/oqsprov/oqs_prov.h index bb8ed1a9..ecf79d98 100644 --- a/oqsprov/oqs_prov.h +++ b/oqsprov/oqs_prov.h @@ -12,7 +12,7 @@ #define OQSX_H #ifndef OQS_PROVIDER_NOATOMIC -#include +# include #endif #include @@ -27,34 +27,34 @@ #define OSSL_NELEM(x) (sizeof(x) / sizeof((x)[0])) #ifdef _MSC_VER -#define strncasecmp _strnicmp -#define strcasecmp _stricmp +# define strncasecmp _strnicmp +# define strcasecmp _stricmp #endif /* oqsprovider error codes */ -#define OQSPROV_R_INVALID_DIGEST 1 -#define OQSPROV_R_INVALID_SIZE 2 -#define OQSPROV_R_INVALID_KEY 3 -#define OQSPROV_R_UNSUPPORTED 4 -#define OQSPROV_R_MISSING_OID 5 -#define OQSPROV_R_OBJ_CREATE_ERR 6 -#define OQSPROV_R_INVALID_ENCODING 7 -#define OQSPROV_R_SIGN_ERROR 8 -#define OQSPROV_R_LIB_CREATE_ERR 9 -#define OQSPROV_R_NO_PRIVATE_KEY 10 +#define OQSPROV_R_INVALID_DIGEST 1 +#define OQSPROV_R_INVALID_SIZE 2 +#define OQSPROV_R_INVALID_KEY 3 +#define OQSPROV_R_UNSUPPORTED 4 +#define OQSPROV_R_MISSING_OID 5 +#define OQSPROV_R_OBJ_CREATE_ERR 6 +#define OQSPROV_R_INVALID_ENCODING 7 +#define OQSPROV_R_SIGN_ERROR 8 +#define OQSPROV_R_LIB_CREATE_ERR 9 +#define OQSPROV_R_NO_PRIVATE_KEY 10 #define OQSPROV_R_BUFFER_LENGTH_WRONG 11 -#define OQSPROV_R_SIGNING_FAILED 12 -#define OQSPROV_R_WRONG_PARAMETERS 13 -#define OQSPROV_R_VERIFY_ERROR 14 -#define OQSPROV_R_EVPINFO_MISSING 15 -#define OQSPROV_R_INTERNAL_ERROR 16 +#define OQSPROV_R_SIGNING_FAILED 12 +#define OQSPROV_R_WRONG_PARAMETERS 13 +#define OQSPROV_R_VERIFY_ERROR 14 +#define OQSPROV_R_EVPINFO_MISSING 15 +#define OQSPROV_R_INTERNAL_ERROR 16 /* Extra OpenSSL parameters for hybrid EVP_PKEY. */ -#define OQS_HYBRID_PKEY_PARAM_CLASSICAL_PUB_KEY \ +#define OQS_HYBRID_PKEY_PARAM_CLASSICAL_PUB_KEY \ "hybrid_classical_" OSSL_PKEY_PARAM_PUB_KEY -#define OQS_HYBRID_PKEY_PARAM_CLASSICAL_PRIV_KEY \ +#define OQS_HYBRID_PKEY_PARAM_CLASSICAL_PRIV_KEY \ "hybrid_classical_" OSSL_PKEY_PARAM_PRIV_KEY -#define OQS_HYBRID_PKEY_PARAM_PQ_PUB_KEY "hybrid_pq_" OSSL_PKEY_PARAM_PUB_KEY +#define OQS_HYBRID_PKEY_PARAM_PQ_PUB_KEY "hybrid_pq_" OSSL_PKEY_PARAM_PUB_KEY #define OQS_HYBRID_PKEY_PARAM_PQ_PRIV_KEY "hybrid_pq_" OSSL_PKEY_PARAM_PRIV_KEY /* Extras for OQS extension */ @@ -74,15 +74,15 @@ i |= ((uint32_t)((unsigned char *)pbuf)[3]) // clang-format on -#define ON_ERR_SET_GOTO(condition, ret, code, gt) \ - if ((condition)) { \ - (ret) = (code); \ - goto gt; \ +#define ON_ERR_SET_GOTO(condition, ret, code, gt) \ + if ((condition)) { \ + (ret) = (code); \ + goto gt; \ } -#define ON_ERR_GOTO(condition, gt) \ - if ((condition)) { \ - goto gt; \ +#define ON_ERR_GOTO(condition, gt) \ + if ((condition)) { \ + goto gt; \ } typedef struct prov_oqs_ctx_st { @@ -94,7 +94,7 @@ typedef struct prov_oqs_ctx_st { PROV_OQS_CTX *oqsx_newprovctx(OSSL_LIB_CTX *libctx, const OSSL_CORE_HANDLE *handle, BIO_METHOD *bm); void oqsx_freeprovctx(PROV_OQS_CTX *ctx); -#define PROV_OQS_LIBCTX_OF(provctx) \ +#define PROV_OQS_LIBCTX_OF(provctx) \ provctx ? (((PROV_OQS_CTX *)provctx)->libctx) : NULL #include "oqs/oqs.h" diff --git a/oqsprov/oqs_sig.c b/oqsprov/oqs_sig.c index 83305bb2..17b208ce 100644 --- a/oqsprov/oqs_sig.c +++ b/oqsprov/oqs_sig.c @@ -24,24 +24,24 @@ #include "oqs_prov.h" // TBD: Review what we really need/want: For now go with OSSL settings: -#define OSSL_MAX_NAME_SIZE 50 -#define OSSL_MAX_PROPQUERY_SIZE 256 /* Property query strings */ +#define OSSL_MAX_NAME_SIZE 50 +#define OSSL_MAX_PROPQUERY_SIZE 256 /* Property query strings */ #define COMPOSITE_OID_PREFIX_LEN 26 #ifdef NDEBUG -#define OQS_SIG_PRINTF(a) -#define OQS_SIG_PRINTF2(a, b) -#define OQS_SIG_PRINTF3(a, b, c) +# define OQS_SIG_PRINTF(a) +# define OQS_SIG_PRINTF2(a, b) +# define OQS_SIG_PRINTF3(a, b, c) #else -#define OQS_SIG_PRINTF(a) \ - if (getenv("OQSSIG")) \ - printf(a) -#define OQS_SIG_PRINTF2(a, b) \ - if (getenv("OQSSIG")) \ - printf(a, b) -#define OQS_SIG_PRINTF3(a, b, c) \ - if (getenv("OQSSIG")) \ - printf(a, b, c) +# define OQS_SIG_PRINTF(a) \ + if (getenv("OQSSIG")) \ + printf(a) +# define OQS_SIG_PRINTF2(a, b) \ + if (getenv("OQSSIG")) \ + printf(a, b) +# define OQS_SIG_PRINTF3(a, b, c) \ + if (getenv("OQSSIG")) \ + printf(a, b, c) #endif // NDEBUG static OSSL_FUNC_signature_newctx_fn oqs_sig_newctx; @@ -71,7 +71,8 @@ static OSSL_FUNC_signature_settable_ctx_md_params_fn oqs_sig_settable_ctx_md_params; // OIDS: -static int get_aid(unsigned char **oidbuf, const char *tls_name) { +static int get_aid(unsigned char **oidbuf, const char *tls_name) +{ X509_ALGOR *algor = X509_ALGOR_new(); int aidlen = 0; @@ -124,7 +125,8 @@ ASN1_NDEF_SEQUENCE(CompositeSignature) = int operation; } PROV_OQSSIG_CTX; -static void *oqs_sig_newctx(void *provctx, const char *propq) { +static void *oqs_sig_newctx(void *provctx, const char *propq) +{ PROV_OQSSIG_CTX *poqs_sigctx; OQS_SIG_PRINTF2("OQS SIG provider: newctx called with propq %s\n", propq); @@ -143,7 +145,8 @@ static void *oqs_sig_newctx(void *provctx, const char *propq) { } static int oqs_sig_setup_md(PROV_OQSSIG_CTX *ctx, const char *mdname, - const char *mdprops) { + const char *mdprops) +{ OQS_SIG_PRINTF3("OQS SIG provider: setup_md called for MD %s (alg %s)\n", mdname, ctx->sig->tls_name); if (mdprops == NULL) @@ -177,7 +180,8 @@ static int oqs_sig_setup_md(PROV_OQSSIG_CTX *ctx, const char *mdname, } static int oqs_sig_signverify_init(void *vpoqs_sigctx, void *voqssig, - int operation) { + int operation) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQS_SIG_PRINTF("OQS SIG provider: signverify_init called\n"); @@ -187,8 +191,8 @@ static int oqs_sig_signverify_init(void *vpoqs_sigctx, void *voqssig, poqs_sigctx->sig = voqssig; poqs_sigctx->operation = operation; poqs_sigctx->flag_allow_md = 1; /* change permitted until first use */ - if ((operation == EVP_PKEY_OP_SIGN && !poqs_sigctx->sig->privkey) || - (operation == EVP_PKEY_OP_VERIFY && !poqs_sigctx->sig->pubkey)) { + if ((operation == EVP_PKEY_OP_SIGN && !poqs_sigctx->sig->privkey) + || (operation == EVP_PKEY_OP_VERIFY && !poqs_sigctx->sig->pubkey)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_KEY); return 0; } @@ -196,13 +200,15 @@ static int oqs_sig_signverify_init(void *vpoqs_sigctx, void *voqssig, } static int oqs_sig_sign_init(void *vpoqs_sigctx, void *voqssig, - const OSSL_PARAM params[]) { + const OSSL_PARAM params[]) +{ OQS_SIG_PRINTF("OQS SIG provider: sign_init called\n"); return oqs_sig_signverify_init(vpoqs_sigctx, voqssig, EVP_PKEY_OP_SIGN); } static int oqs_sig_verify_init(void *vpoqs_sigctx, void *voqssig, - const OSSL_PARAM params[]) { + const OSSL_PARAM params[]) +{ OQS_SIG_PRINTF("OQS SIG provider: verify_init called\n"); return oqs_sig_signverify_init(vpoqs_sigctx, voqssig, EVP_PKEY_OP_VERIFY); } @@ -308,7 +314,8 @@ static const unsigned char *composite_OID_prefix[] = { }; /*put the chars on in into memory on out*/ -void composite_prefix_conversion(char *out, const unsigned char *in) { +void composite_prefix_conversion(char *out, const unsigned char *in) +{ int temp; for (int i = 0; i < COMPOSITE_OID_PREFIX_LEN / 2; i++) { temp = OPENSSL_hexchar2int(in[2 * i]); @@ -323,8 +330,8 @@ void composite_prefix_conversion(char *out, const unsigned char *in) { * NULL, we have to hash in case of hybrid signatures */ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, - size_t sigsize, const unsigned char *tbs, - size_t tbslen) { + size_t sigsize, const unsigned char *tbs, size_t tbslen) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQSX_KEY *oqsxkey = poqs_sigctx->sig; OQS_SIG *oqs_key = poqs_sigctx->sig->oqsx_provider_ctx.oqsx_qs_ctx.sig; @@ -371,14 +378,15 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, } if (is_hybrid) { - if ((classical_ctx_sign = EVP_PKEY_CTX_new(evpkey, NULL)) == NULL || - EVP_PKEY_sign_init(classical_ctx_sign) <= 0) { + if ((classical_ctx_sign = EVP_PKEY_CTX_new(evpkey, NULL)) == NULL + || EVP_PKEY_sign_init(classical_ctx_sign) <= 0) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); goto endsign; } if (oqsxkey->evp_info->keytype == EVP_PKEY_RSA) { if (EVP_PKEY_CTX_set_rsa_padding(classical_ctx_sign, - RSA_PKCS1_PADDING) <= 0) { + RSA_PKCS1_PADDING) + <= 0) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); goto endsign; } @@ -415,11 +423,11 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, SHA512(tbs, tbslen, (unsigned char *)&digest); break; } - if ((EVP_PKEY_CTX_set_signature_md(classical_ctx_sign, classical_md) <= - 0) || - (EVP_PKEY_sign(classical_ctx_sign, sig + SIZE_OF_UINT32, - &actual_classical_sig_len, digest, - digest_len) <= 0)) { + if ((EVP_PKEY_CTX_set_signature_md(classical_ctx_sign, classical_md) + <= 0) + || (EVP_PKEY_sign(classical_ctx_sign, sig + SIZE_OF_UINT32, + &actual_classical_sig_len, digest, digest_len) + <= 0)) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); goto endsign; } @@ -453,10 +461,11 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, const unsigned char *oid_prefix = composite_OID_prefix[comp_idx - 1]; char *final_tbs; CompositeSignature *compsig = CompositeSignature_new(); - size_t final_tbslen = COMPOSITE_OID_PREFIX_LEN / - 2; // COMPOSITE_OID_PREFIX_LEN stores the size of - // the *char, but the prefix will be on memory, - // so each 2 chars will translate into one byte + size_t final_tbslen + = COMPOSITE_OID_PREFIX_LEN + / 2; // COMPOSITE_OID_PREFIX_LEN stores the size of + // the *char, but the prefix will be on memory, + // so each 2 chars will translate into one byte int aux = 0; unsigned char *tbs_hash; @@ -471,10 +480,10 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, } upcase_name = get_oqsname_fromtls(name); - if ((upcase_name != 0) && - ((!strcmp(upcase_name, OQS_SIG_alg_ml_dsa_65)) || - (!strcmp(upcase_name, OQS_SIG_alg_ml_dsa_87))) || - (name[0] == 'e')) { + if ((upcase_name != 0) + && ((!strcmp(upcase_name, OQS_SIG_alg_ml_dsa_65)) + || (!strcmp(upcase_name, OQS_SIG_alg_ml_dsa_87))) + || (name[0] == 'e')) { aux = 1; OPENSSL_free(name); break; @@ -519,7 +528,8 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, buf = OPENSSL_malloc(oqs_sig_len); if (OQS_SIG_sign(oqs_key, buf, &oqs_sig_len, (const unsigned char *)final_tbs, final_tbslen, - oqsxkey->comp_privkey[i]) != OQS_SUCCESS) { + oqsxkey->comp_privkey[i]) + != OQS_SUCCESS) { ERR_raise(ERR_LIB_USER, OQSPROV_R_SIGNING_FAILED); CompositeSignature_free(compsig); OPENSSL_free(final_tbs); @@ -540,10 +550,12 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, if (name[0] == 'e') { // ed25519 or ed448 EVP_MD_CTX *evp_ctx = EVP_MD_CTX_new(); if ((EVP_DigestSignInit(evp_ctx, NULL, NULL, NULL, - oqs_key_classic) <= 0) || - (EVP_DigestSign(evp_ctx, buf, &oqs_sig_len, - (const unsigned char *)final_tbs, - final_tbslen) <= 0)) { + oqs_key_classic) + <= 0) + || (EVP_DigestSign(evp_ctx, buf, &oqs_sig_len, + (const unsigned char *)final_tbs, + final_tbslen) + <= 0)) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); CompositeSignature_free(compsig); OPENSSL_free(final_tbs); @@ -554,9 +566,10 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, } EVP_MD_CTX_free(evp_ctx); } else { - if ((classical_ctx_sign = - EVP_PKEY_CTX_new(oqs_key_classic, NULL)) == NULL || - (EVP_PKEY_sign_init(classical_ctx_sign) <= 0)) { + if ((classical_ctx_sign + = EVP_PKEY_CTX_new(oqs_key_classic, NULL)) + == NULL + || (EVP_PKEY_sign_init(classical_ctx_sign) <= 0)) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); CompositeSignature_free(compsig); OPENSSL_free(final_tbs); @@ -584,13 +597,15 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, goto endsign; } } - if ((EVP_PKEY_CTX_set_rsa_padding( - classical_ctx_sign, RSA_PKCS1_PSS_PADDING) <= - 0) || - (EVP_PKEY_CTX_set_rsa_pss_saltlen( - classical_ctx_sign, salt) <= 0) || - (EVP_PKEY_CTX_set_rsa_mgf1_md(classical_ctx_sign, - pss_mgf1) <= 0)) { + if ((EVP_PKEY_CTX_set_rsa_padding(classical_ctx_sign, + RSA_PKCS1_PSS_PADDING) + <= 0) + || (EVP_PKEY_CTX_set_rsa_pss_saltlen( + classical_ctx_sign, salt) + <= 0) + || (EVP_PKEY_CTX_set_rsa_mgf1_md(classical_ctx_sign, + pss_mgf1) + <= 0)) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); CompositeSignature_free(compsig); OPENSSL_free(final_tbs); @@ -599,9 +614,11 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, goto endsign; } } else if (oqsxkey->oqsx_provider_ctx.oqsx_evp_ctx->evp_info - ->keytype == EVP_PKEY_RSA) { - if (EVP_PKEY_CTX_set_rsa_padding( - classical_ctx_sign, RSA_PKCS1_PADDING) <= 0) { + ->keytype + == EVP_PKEY_RSA) { + if (EVP_PKEY_CTX_set_rsa_padding(classical_ctx_sign, + RSA_PKCS1_PADDING) + <= 0) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); CompositeSignature_free(compsig); OPENSSL_free(final_tbs); @@ -623,9 +640,11 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, } if ((EVP_PKEY_CTX_set_signature_md(classical_ctx_sign, - classical_md) <= 0) || - (EVP_PKEY_sign(classical_ctx_sign, buf, &oqs_sig_len, - digest, digest_len) <= 0)) { + classical_md) + <= 0) + || (EVP_PKEY_sign(classical_ctx_sign, buf, &oqs_sig_len, + digest, digest_len) + <= 0)) { ERR_raise(ERR_LIB_USER, ERR_R_FATAL); CompositeSignature_free(compsig); OPENSSL_free(final_tbs); @@ -650,13 +669,13 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, if (i == 0) { compsig->sig1->data = OPENSSL_memdup(buf, oqs_sig_len); compsig->sig1->length = oqs_sig_len; - compsig->sig1->flags = - 8; // set as 8 to not check for unused bits + compsig->sig1->flags + = 8; // set as 8 to not check for unused bits } else { compsig->sig2->data = OPENSSL_memdup(buf, oqs_sig_len); compsig->sig2->length = oqs_sig_len; - compsig->sig2->flags = - 8; // set as 8 to not check for unused bits + compsig->sig2->flags + = 8; // set as 8 to not check for unused bits } OPENSSL_free(buf); @@ -667,8 +686,8 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, CompositeSignature_free(compsig); OPENSSL_free(final_tbs); } else if (OQS_SIG_sign(oqs_key, sig + index, &oqs_sig_len, tbs, tbslen, - oqsxkey->comp_privkey[oqsxkey->numkeys - 1]) != - OQS_SUCCESS) { + oqsxkey->comp_privkey[oqsxkey->numkeys - 1]) + != OQS_SUCCESS) { ERR_raise(ERR_LIB_USER, OQSPROV_R_SIGNING_FAILED); goto endsign; } @@ -687,7 +706,8 @@ static int oqs_sig_sign(void *vpoqs_sigctx, unsigned char *sig, size_t *siglen, static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, - size_t tbslen) { + size_t tbslen) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQSX_KEY *oqsxkey = poqs_sigctx->sig; OQS_SIG *oqs_key = poqs_sigctx->sig->oqsx_provider_ctx.oqsx_qs_ctx.sig; @@ -705,8 +725,8 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, "tbslen %ld\n", siglen, tbslen); - if (!oqsxkey || !oqs_key || !oqsxkey->pubkey || sig == NULL || - (tbs == NULL && tbslen > 0)) { + if (!oqsxkey || !oqs_key || !oqsxkey->pubkey || sig == NULL + || (tbs == NULL && tbslen > 0)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS); goto endverify; } @@ -716,20 +736,20 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, uint32_t actual_classical_sig_len = 0; int digest_len; unsigned char digest[SHA512_DIGEST_LENGTH]; /* init with max length */ - size_t max_pq_sig_len = - oqsxkey->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_signature; - size_t max_classical_sig_len = - oqsxkey->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->length_signature; - - if ((ctx_verify = EVP_PKEY_CTX_new(oqsxkey->classical_pkey, NULL)) == - NULL || - EVP_PKEY_verify_init(ctx_verify) <= 0) { + size_t max_pq_sig_len + = oqsxkey->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_signature; + size_t max_classical_sig_len = oqsxkey->oqsx_provider_ctx.oqsx_evp_ctx + ->evp_info->length_signature; + + if ((ctx_verify = EVP_PKEY_CTX_new(oqsxkey->classical_pkey, NULL)) + == NULL + || EVP_PKEY_verify_init(ctx_verify) <= 0) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); goto endverify; } if (oqsxkey->evp_info->keytype == EVP_PKEY_RSA) { - if (EVP_PKEY_CTX_set_rsa_padding(ctx_verify, RSA_PKCS1_PADDING) <= - 0) { + if (EVP_PKEY_CTX_set_rsa_padding(ctx_verify, RSA_PKCS1_PADDING) + <= 0) { ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS); goto endverify; } @@ -737,11 +757,11 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, if (siglen > SIZE_OF_UINT32) { size_t actual_pq_sig_len = 0; DECODE_UINT32(actual_classical_sig_len, sig); - actual_pq_sig_len = - siglen - SIZE_OF_UINT32 - actual_classical_sig_len; - if (siglen <= (SIZE_OF_UINT32 + actual_classical_sig_len) || - actual_classical_sig_len > max_classical_sig_len || - actual_pq_sig_len > max_pq_sig_len) { + actual_pq_sig_len + = siglen - SIZE_OF_UINT32 - actual_classical_sig_len; + if (siglen <= (SIZE_OF_UINT32 + actual_classical_sig_len) + || actual_classical_sig_len > max_classical_sig_len + || actual_pq_sig_len > max_pq_sig_len) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto endverify; } @@ -773,10 +793,10 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, SHA512(tbs, tbslen, (unsigned char *)&digest); break; } - if ((EVP_PKEY_CTX_set_signature_md(ctx_verify, classical_md) <= 0) || - (EVP_PKEY_verify(ctx_verify, sig + SIZE_OF_UINT32, - actual_classical_sig_len, digest, - digest_len) <= 0)) { + if ((EVP_PKEY_CTX_set_signature_md(ctx_verify, classical_md) <= 0) + || (EVP_PKEY_verify(ctx_verify, sig + SIZE_OF_UINT32, + actual_classical_sig_len, digest, digest_len) + <= 0)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); goto endverify; } else { @@ -827,10 +847,10 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, } upcase_name = get_oqsname_fromtls(name); - if ((upcase_name != 0) && - ((!strcmp(upcase_name, OQS_SIG_alg_ml_dsa_65)) || - (!strcmp(upcase_name, OQS_SIG_alg_ml_dsa_87))) || - (name[0] == 'e')) { + if ((upcase_name != 0) + && ((!strcmp(upcase_name, OQS_SIG_alg_ml_dsa_65)) + || (!strcmp(upcase_name, OQS_SIG_alg_ml_dsa_87))) + || (name[0] == 'e')) { aux = 1; OPENSSL_free(name); break; @@ -880,7 +900,8 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, if (get_oqsname_fromtls(name)) { if (OQS_SIG_verify(oqs_key, (const unsigned char *)final_tbs, final_tbslen, buf, buf_len, - oqsxkey->comp_pubkey[i]) != OQS_SUCCESS) { + oqsxkey->comp_pubkey[i]) + != OQS_SUCCESS) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); OPENSSL_free(name); CompositeSignature_free(compsig); @@ -897,10 +918,12 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, if (name[0] == 'e') { // ed25519 or ed448 EVP_MD_CTX *evp_ctx = EVP_MD_CTX_new(); if ((EVP_DigestVerifyInit(evp_ctx, NULL, NULL, NULL, - oqsxkey->classical_pkey) <= 0) || - (EVP_DigestVerify(evp_ctx, buf, buf_len, - (const unsigned char *)final_tbs, - final_tbslen) <= 0)) { + oqsxkey->classical_pkey) + <= 0) + || (EVP_DigestVerify(evp_ctx, buf, buf_len, + (const unsigned char *)final_tbs, + final_tbslen) + <= 0)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); OPENSSL_free(name); EVP_MD_CTX_free(evp_ctx); @@ -910,9 +933,10 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, } EVP_MD_CTX_free(evp_ctx); } else { - if (((ctx_verify = EVP_PKEY_CTX_new(oqsxkey->classical_pkey, - NULL)) == NULL) || - (EVP_PKEY_verify_init(ctx_verify) <= 0)) { + if (((ctx_verify + = EVP_PKEY_CTX_new(oqsxkey->classical_pkey, NULL)) + == NULL) + || (EVP_PKEY_verify_init(ctx_verify) <= 0)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); OPENSSL_free(name); CompositeSignature_free(compsig); @@ -937,12 +961,15 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, goto endverify; } } - if ((EVP_PKEY_CTX_set_rsa_padding( - ctx_verify, RSA_PKCS1_PSS_PADDING) <= 0) || - (EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx_verify, - salt) <= 0) || - (EVP_PKEY_CTX_set_rsa_mgf1_md(ctx_verify, - pss_mgf1) <= 0)) { + if ((EVP_PKEY_CTX_set_rsa_padding(ctx_verify, + RSA_PKCS1_PSS_PADDING) + <= 0) + || (EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx_verify, + salt) + <= 0) + || (EVP_PKEY_CTX_set_rsa_mgf1_md(ctx_verify, + pss_mgf1) + <= 0)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS); OPENSSL_free(name); CompositeSignature_free(compsig); @@ -950,9 +977,11 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, goto endverify; } } else if (oqsxkey->oqsx_provider_ctx.oqsx_evp_ctx->evp_info - ->keytype == EVP_PKEY_RSA) { - if (EVP_PKEY_CTX_set_rsa_padding( - ctx_verify, RSA_PKCS1_PADDING) <= 0) { + ->keytype + == EVP_PKEY_RSA) { + if (EVP_PKEY_CTX_set_rsa_padding(ctx_verify, + RSA_PKCS1_PADDING) + <= 0) { ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS); OPENSSL_free(name); CompositeSignature_free(compsig); @@ -972,10 +1001,11 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, (unsigned char *)&digest); } - if ((EVP_PKEY_CTX_set_signature_md(ctx_verify, - classical_md) <= 0) || - (EVP_PKEY_verify(ctx_verify, buf, buf_len, digest, - digest_len) <= 0)) { + if ((EVP_PKEY_CTX_set_signature_md(ctx_verify, classical_md) + <= 0) + || (EVP_PKEY_verify(ctx_verify, buf, buf_len, digest, + digest_len) + <= 0)) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); OPENSSL_free(name); CompositeSignature_free(compsig); @@ -994,9 +1024,10 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, ERR_raise(ERR_LIB_USER, OQSPROV_R_WRONG_PARAMETERS); goto endverify; } - if (OQS_SIG_verify( - oqs_key, tbs, tbslen, sig + index, siglen - classical_sig_len, - oqsxkey->comp_pubkey[oqsxkey->numkeys - 1]) != OQS_SUCCESS) { + if (OQS_SIG_verify(oqs_key, tbs, tbslen, sig + index, + siglen - classical_sig_len, + oqsxkey->comp_pubkey[oqsxkey->numkeys - 1]) + != OQS_SUCCESS) { ERR_raise(ERR_LIB_USER, OQSPROV_R_VERIFY_ERROR); goto endverify; } @@ -1013,7 +1044,8 @@ static int oqs_sig_verify(void *vpoqs_sigctx, const unsigned char *sig, static int oqs_sig_digest_signverify_init(void *vpoqs_sigctx, const char *mdname, void *voqssig, - int operation) { + int operation) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQS_SIG_PRINTF2( @@ -1048,23 +1080,24 @@ static int oqs_sig_digest_signverify_init(void *vpoqs_sigctx, } static int oqs_sig_digest_sign_init(void *vpoqs_sigctx, const char *mdname, - void *voqssig, const OSSL_PARAM params[]) { + void *voqssig, const OSSL_PARAM params[]) +{ OQS_SIG_PRINTF("OQS SIG provider: digest_sign_init called\n"); return oqs_sig_digest_signverify_init(vpoqs_sigctx, mdname, voqssig, EVP_PKEY_OP_SIGN); } static int oqs_sig_digest_verify_init(void *vpoqs_sigctx, const char *mdname, - void *voqssig, - const OSSL_PARAM params[]) { + void *voqssig, const OSSL_PARAM params[]) +{ OQS_SIG_PRINTF("OQS SIG provider: sig_digest_verify called\n"); return oqs_sig_digest_signverify_init(vpoqs_sigctx, mdname, voqssig, EVP_PKEY_OP_VERIFY); } int oqs_sig_digest_signverify_update(void *vpoqs_sigctx, - const unsigned char *data, - size_t datalen) { + const unsigned char *data, size_t datalen) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQS_SIG_PRINTF("OQS SIG provider: digest_signverify_update called\n"); @@ -1101,7 +1134,8 @@ int oqs_sig_digest_signverify_update(void *vpoqs_sigctx, } int oqs_sig_digest_sign_final(void *vpoqs_sigctx, unsigned char *sig, - size_t *siglen, size_t sigsize) { + size_t *siglen, size_t sigsize) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; unsigned char digest[EVP_MAX_MD_SIZE]; unsigned int dlen = 0; @@ -1137,7 +1171,8 @@ int oqs_sig_digest_sign_final(void *vpoqs_sigctx, unsigned char *sig, } int oqs_sig_digest_verify_final(void *vpoqs_sigctx, const unsigned char *sig, - size_t siglen) { + size_t siglen) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; unsigned char digest[EVP_MAX_MD_SIZE]; unsigned int dlen = 0; @@ -1159,7 +1194,8 @@ int oqs_sig_digest_verify_final(void *vpoqs_sigctx, const unsigned char *sig, poqs_sigctx->mdsize); } -static void oqs_sig_freectx(void *vpoqs_sigctx) { +static void oqs_sig_freectx(void *vpoqs_sigctx) +{ PROV_OQSSIG_CTX *ctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQS_SIG_PRINTF("OQS SIG provider: freectx called\n"); @@ -1179,7 +1215,8 @@ static void oqs_sig_freectx(void *vpoqs_sigctx) { OPENSSL_free(ctx); } -static void *oqs_sig_dupctx(void *vpoqs_sigctx) { +static void *oqs_sig_dupctx(void *vpoqs_sigctx) +{ PROV_OQSSIG_CTX *srcctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; PROV_OQSSIG_CTX *dstctx; @@ -1204,8 +1241,8 @@ static void *oqs_sig_dupctx(void *vpoqs_sigctx) { if (srcctx->mdctx != NULL) { dstctx->mdctx = EVP_MD_CTX_new(); - if (dstctx->mdctx == NULL || - !EVP_MD_CTX_copy_ex(dstctx->mdctx, srcctx->mdctx)) + if (dstctx->mdctx == NULL + || !EVP_MD_CTX_copy_ex(dstctx->mdctx, srcctx->mdctx)) goto err; } @@ -1235,7 +1272,8 @@ static void *oqs_sig_dupctx(void *vpoqs_sigctx) { return NULL; } -static int oqs_sig_get_ctx_params(void *vpoqs_sigctx, OSSL_PARAM *params) { +static int oqs_sig_get_ctx_params(void *vpoqs_sigctx, OSSL_PARAM *params) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OSSL_PARAM *p; @@ -1246,12 +1284,13 @@ static int oqs_sig_get_ctx_params(void *vpoqs_sigctx, OSSL_PARAM *params) { p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID); if (poqs_sigctx->aid == NULL) { - poqs_sigctx->aid_len = - get_aid(&(poqs_sigctx->aid), poqs_sigctx->sig->tls_name); + poqs_sigctx->aid_len + = get_aid(&(poqs_sigctx->aid), poqs_sigctx->sig->tls_name); } - if (p != NULL && - !OSSL_PARAM_set_octet_string(p, poqs_sigctx->aid, poqs_sigctx->aid_len)) + if (p != NULL + && !OSSL_PARAM_set_octet_string(p, poqs_sigctx->aid, + poqs_sigctx->aid_len)) return 0; p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST); @@ -1261,19 +1300,20 @@ static int oqs_sig_get_ctx_params(void *vpoqs_sigctx, OSSL_PARAM *params) { return 1; } -static const OSSL_PARAM known_gettable_ctx_params[] = { - OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0), - OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0), - OSSL_PARAM_END}; +static const OSSL_PARAM known_gettable_ctx_params[] + = {OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0), + OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0), + OSSL_PARAM_END}; static const OSSL_PARAM * oqs_sig_gettable_ctx_params(ossl_unused void *vpoqs_sigctx, - ossl_unused void *vctx) { + ossl_unused void *vctx) +{ OQS_SIG_PRINTF("OQS SIG provider: gettable_ctx_params called\n"); return known_gettable_ctx_params; } -static int oqs_sig_set_ctx_params(void *vpoqs_sigctx, - const OSSL_PARAM params[]) { +static int oqs_sig_set_ctx_params(void *vpoqs_sigctx, const OSSL_PARAM params[]) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; const OSSL_PARAM *p; @@ -1288,13 +1328,13 @@ static int oqs_sig_set_ctx_params(void *vpoqs_sigctx, if (p != NULL) { char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname; char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops; - const OSSL_PARAM *propsp = - OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_PROPERTIES); + const OSSL_PARAM *propsp + = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_PROPERTIES); if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname))) return 0; - if (propsp != NULL && - !OSSL_PARAM_get_utf8_string(propsp, &pmdprops, sizeof(mdprops))) + if (propsp != NULL + && !OSSL_PARAM_get_utf8_string(propsp, &pmdprops, sizeof(mdprops))) return 0; if (!oqs_sig_setup_md(poqs_sigctx, mdname, mdprops)) return 0; @@ -1304,14 +1344,14 @@ static int oqs_sig_set_ctx_params(void *vpoqs_sigctx, return 1; } -static const OSSL_PARAM known_settable_ctx_params[] = { - OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0), - OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PROPERTIES, NULL, 0), - OSSL_PARAM_END}; +static const OSSL_PARAM known_settable_ctx_params[] + = {OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0), + OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PROPERTIES, NULL, 0), + OSSL_PARAM_END}; -static const OSSL_PARAM * -oqs_sig_settable_ctx_params(ossl_unused void *vpsm2ctx, - ossl_unused void *provctx) { +static const OSSL_PARAM *oqs_sig_settable_ctx_params(ossl_unused void *vpsm2ctx, + ossl_unused void *provctx) +{ /* * TODO(3.0): Should this function return a different set of settable ctx * params if the ctx is being used for a DigestSign/DigestVerify? In that @@ -1328,7 +1368,8 @@ oqs_sig_settable_ctx_params(ossl_unused void *vpsm2ctx, return known_settable_ctx_params; } -static int oqs_sig_get_ctx_md_params(void *vpoqs_sigctx, OSSL_PARAM *params) { +static int oqs_sig_get_ctx_md_params(void *vpoqs_sigctx, OSSL_PARAM *params) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQS_SIG_PRINTF("OQS SIG provider: get_ctx_md_params called\n"); @@ -1338,7 +1379,8 @@ static int oqs_sig_get_ctx_md_params(void *vpoqs_sigctx, OSSL_PARAM *params) { return EVP_MD_CTX_get_params(poqs_sigctx->mdctx, params); } -static const OSSL_PARAM *oqs_sig_gettable_ctx_md_params(void *vpoqs_sigctx) { +static const OSSL_PARAM *oqs_sig_gettable_ctx_md_params(void *vpoqs_sigctx) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQS_SIG_PRINTF("OQS SIG provider: gettable_ctx_md_params called\n"); @@ -1349,7 +1391,8 @@ static const OSSL_PARAM *oqs_sig_gettable_ctx_md_params(void *vpoqs_sigctx) { } static int oqs_sig_set_ctx_md_params(void *vpoqs_sigctx, - const OSSL_PARAM params[]) { + const OSSL_PARAM params[]) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; OQS_SIG_PRINTF("OQS SIG provider: set_ctx_md_params called\n"); @@ -1359,7 +1402,8 @@ static int oqs_sig_set_ctx_md_params(void *vpoqs_sigctx, return EVP_MD_CTX_set_params(poqs_sigctx->mdctx, params); } -static const OSSL_PARAM *oqs_sig_settable_ctx_md_params(void *vpoqs_sigctx) { +static const OSSL_PARAM *oqs_sig_settable_ctx_md_params(void *vpoqs_sigctx) +{ PROV_OQSSIG_CTX *poqs_sigctx = (PROV_OQSSIG_CTX *)vpoqs_sigctx; if (poqs_sigctx->md == NULL) @@ -1369,40 +1413,40 @@ static const OSSL_PARAM *oqs_sig_settable_ctx_md_params(void *vpoqs_sigctx) { return EVP_MD_settable_ctx_params(poqs_sigctx->md); } -const OSSL_DISPATCH oqs_signature_functions[] = { - {OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))oqs_sig_newctx}, - {OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))oqs_sig_sign_init}, - {OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))oqs_sig_sign}, - {OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))oqs_sig_verify_init}, - {OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))oqs_sig_verify}, - {OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT, - (void (*)(void))oqs_sig_digest_sign_init}, - {OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE, - (void (*)(void))oqs_sig_digest_signverify_update}, - {OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL, - (void (*)(void))oqs_sig_digest_sign_final}, - {OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT, - (void (*)(void))oqs_sig_digest_verify_init}, - {OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE, - (void (*)(void))oqs_sig_digest_signverify_update}, - {OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL, - (void (*)(void))oqs_sig_digest_verify_final}, - {OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))oqs_sig_freectx}, - {OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))oqs_sig_dupctx}, - {OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, - (void (*)(void))oqs_sig_get_ctx_params}, - {OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS, - (void (*)(void))oqs_sig_gettable_ctx_params}, - {OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, - (void (*)(void))oqs_sig_set_ctx_params}, - {OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS, - (void (*)(void))oqs_sig_settable_ctx_params}, - {OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS, - (void (*)(void))oqs_sig_get_ctx_md_params}, - {OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS, - (void (*)(void))oqs_sig_gettable_ctx_md_params}, - {OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS, - (void (*)(void))oqs_sig_set_ctx_md_params}, - {OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS, - (void (*)(void))oqs_sig_settable_ctx_md_params}, - {0, NULL}}; +const OSSL_DISPATCH oqs_signature_functions[] + = {{OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))oqs_sig_newctx}, + {OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))oqs_sig_sign_init}, + {OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))oqs_sig_sign}, + {OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))oqs_sig_verify_init}, + {OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))oqs_sig_verify}, + {OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT, + (void (*)(void))oqs_sig_digest_sign_init}, + {OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE, + (void (*)(void))oqs_sig_digest_signverify_update}, + {OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL, + (void (*)(void))oqs_sig_digest_sign_final}, + {OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT, + (void (*)(void))oqs_sig_digest_verify_init}, + {OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE, + (void (*)(void))oqs_sig_digest_signverify_update}, + {OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL, + (void (*)(void))oqs_sig_digest_verify_final}, + {OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))oqs_sig_freectx}, + {OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))oqs_sig_dupctx}, + {OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, + (void (*)(void))oqs_sig_get_ctx_params}, + {OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS, + (void (*)(void))oqs_sig_gettable_ctx_params}, + {OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, + (void (*)(void))oqs_sig_set_ctx_params}, + {OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS, + (void (*)(void))oqs_sig_settable_ctx_params}, + {OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS, + (void (*)(void))oqs_sig_get_ctx_md_params}, + {OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS, + (void (*)(void))oqs_sig_gettable_ctx_md_params}, + {OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS, + (void (*)(void))oqs_sig_set_ctx_md_params}, + {OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS, + (void (*)(void))oqs_sig_settable_ctx_md_params}, + {0, NULL}}; diff --git a/oqsprov/oqsdecoders.inc b/oqsprov/oqsdecoders.inc index cd0403de..e94a0e51 100644 --- a/oqsprov/oqsdecoders.inc +++ b/oqsprov/oqsdecoders.inc @@ -36,247 +36,417 @@ ///// OQS_TEMPLATE_FRAGMENT_MAKE_START #ifdef OQS_KEM_ENCODERS -#ifdef OQS_ENABLE_KEM_frodokem_640_aes +# ifdef OQS_ENABLE_KEM_frodokem_640_aes DECODER_w_structure("frodo640aes", der, PrivateKeyInfo, frodo640aes), -DECODER_w_structure("frodo640aes", der, SubjectPublicKeyInfo, frodo640aes), -DECODER_w_structure("p256_frodo640aes", der, PrivateKeyInfo, p256_frodo640aes), -DECODER_w_structure("p256_frodo640aes", der, SubjectPublicKeyInfo, p256_frodo640aes),DECODER_w_structure("x25519_frodo640aes", der, PrivateKeyInfo, x25519_frodo640aes), -DECODER_w_structure("x25519_frodo640aes", der, SubjectPublicKeyInfo, x25519_frodo640aes), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_640_shake -DECODER_w_structure("frodo640shake", der, PrivateKeyInfo, frodo640shake), -DECODER_w_structure("frodo640shake", der, SubjectPublicKeyInfo, frodo640shake), -DECODER_w_structure("p256_frodo640shake", der, PrivateKeyInfo, p256_frodo640shake), -DECODER_w_structure("p256_frodo640shake", der, SubjectPublicKeyInfo, p256_frodo640shake),DECODER_w_structure("x25519_frodo640shake", der, PrivateKeyInfo, x25519_frodo640shake), -DECODER_w_structure("x25519_frodo640shake", der, SubjectPublicKeyInfo, x25519_frodo640shake), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_976_aes -DECODER_w_structure("frodo976aes", der, PrivateKeyInfo, frodo976aes), -DECODER_w_structure("frodo976aes", der, SubjectPublicKeyInfo, frodo976aes), -DECODER_w_structure("p384_frodo976aes", der, PrivateKeyInfo, p384_frodo976aes), -DECODER_w_structure("p384_frodo976aes", der, SubjectPublicKeyInfo, p384_frodo976aes),DECODER_w_structure("x448_frodo976aes", der, PrivateKeyInfo, x448_frodo976aes), -DECODER_w_structure("x448_frodo976aes", der, SubjectPublicKeyInfo, x448_frodo976aes), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_976_shake -DECODER_w_structure("frodo976shake", der, PrivateKeyInfo, frodo976shake), -DECODER_w_structure("frodo976shake", der, SubjectPublicKeyInfo, frodo976shake), -DECODER_w_structure("p384_frodo976shake", der, PrivateKeyInfo, p384_frodo976shake), -DECODER_w_structure("p384_frodo976shake", der, SubjectPublicKeyInfo, p384_frodo976shake),DECODER_w_structure("x448_frodo976shake", der, PrivateKeyInfo, x448_frodo976shake), -DECODER_w_structure("x448_frodo976shake", der, SubjectPublicKeyInfo, x448_frodo976shake), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_1344_aes -DECODER_w_structure("frodo1344aes", der, PrivateKeyInfo, frodo1344aes), -DECODER_w_structure("frodo1344aes", der, SubjectPublicKeyInfo, frodo1344aes), -DECODER_w_structure("p521_frodo1344aes", der, PrivateKeyInfo, p521_frodo1344aes), -DECODER_w_structure("p521_frodo1344aes", der, SubjectPublicKeyInfo, p521_frodo1344aes), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_1344_shake -DECODER_w_structure("frodo1344shake", der, PrivateKeyInfo, frodo1344shake), -DECODER_w_structure("frodo1344shake", der, SubjectPublicKeyInfo, frodo1344shake), -DECODER_w_structure("p521_frodo1344shake", der, PrivateKeyInfo, p521_frodo1344shake), -DECODER_w_structure("p521_frodo1344shake", der, SubjectPublicKeyInfo, p521_frodo1344shake), -#endif -#ifdef OQS_ENABLE_KEM_kyber_512 -DECODER_w_structure("kyber512", der, PrivateKeyInfo, kyber512), -DECODER_w_structure("kyber512", der, SubjectPublicKeyInfo, kyber512), -DECODER_w_structure("p256_kyber512", der, PrivateKeyInfo, p256_kyber512), -DECODER_w_structure("p256_kyber512", der, SubjectPublicKeyInfo, p256_kyber512),DECODER_w_structure("x25519_kyber512", der, PrivateKeyInfo, x25519_kyber512), -DECODER_w_structure("x25519_kyber512", der, SubjectPublicKeyInfo, x25519_kyber512), -#endif -#ifdef OQS_ENABLE_KEM_kyber_768 -DECODER_w_structure("kyber768", der, PrivateKeyInfo, kyber768), -DECODER_w_structure("kyber768", der, SubjectPublicKeyInfo, kyber768), -DECODER_w_structure("p384_kyber768", der, PrivateKeyInfo, p384_kyber768), -DECODER_w_structure("p384_kyber768", der, SubjectPublicKeyInfo, p384_kyber768),DECODER_w_structure("x448_kyber768", der, PrivateKeyInfo, x448_kyber768), -DECODER_w_structure("x448_kyber768", der, SubjectPublicKeyInfo, x448_kyber768),DECODER_w_structure("x25519_kyber768", der, PrivateKeyInfo, x25519_kyber768), -DECODER_w_structure("x25519_kyber768", der, SubjectPublicKeyInfo, x25519_kyber768),DECODER_w_structure("p256_kyber768", der, PrivateKeyInfo, p256_kyber768), -DECODER_w_structure("p256_kyber768", der, SubjectPublicKeyInfo, p256_kyber768), -#endif -#ifdef OQS_ENABLE_KEM_kyber_1024 -DECODER_w_structure("kyber1024", der, PrivateKeyInfo, kyber1024), -DECODER_w_structure("kyber1024", der, SubjectPublicKeyInfo, kyber1024), -DECODER_w_structure("p521_kyber1024", der, PrivateKeyInfo, p521_kyber1024), -DECODER_w_structure("p521_kyber1024", der, SubjectPublicKeyInfo, p521_kyber1024), -#endif -#ifdef OQS_ENABLE_KEM_ml_kem_512 -DECODER_w_structure("mlkem512", der, PrivateKeyInfo, mlkem512), -DECODER_w_structure("mlkem512", der, SubjectPublicKeyInfo, mlkem512), -DECODER_w_structure("p256_mlkem512", der, PrivateKeyInfo, p256_mlkem512), -DECODER_w_structure("p256_mlkem512", der, SubjectPublicKeyInfo, p256_mlkem512),DECODER_w_structure("x25519_mlkem512", der, PrivateKeyInfo, x25519_mlkem512), -DECODER_w_structure("x25519_mlkem512", der, SubjectPublicKeyInfo, x25519_mlkem512), -#endif -#ifdef OQS_ENABLE_KEM_ml_kem_768 -DECODER_w_structure("mlkem768", der, PrivateKeyInfo, mlkem768), -DECODER_w_structure("mlkem768", der, SubjectPublicKeyInfo, mlkem768), -DECODER_w_structure("p384_mlkem768", der, PrivateKeyInfo, p384_mlkem768), -DECODER_w_structure("p384_mlkem768", der, SubjectPublicKeyInfo, p384_mlkem768),DECODER_w_structure("x448_mlkem768", der, PrivateKeyInfo, x448_mlkem768), -DECODER_w_structure("x448_mlkem768", der, SubjectPublicKeyInfo, x448_mlkem768),DECODER_w_structure("X25519MLKEM768", der, PrivateKeyInfo, X25519MLKEM768), -DECODER_w_structure("X25519MLKEM768", der, SubjectPublicKeyInfo, X25519MLKEM768),DECODER_w_structure("SecP256r1MLKEM768", der, PrivateKeyInfo, SecP256r1MLKEM768), -DECODER_w_structure("SecP256r1MLKEM768", der, SubjectPublicKeyInfo, SecP256r1MLKEM768), -#endif -#ifdef OQS_ENABLE_KEM_ml_kem_1024 -DECODER_w_structure("mlkem1024", der, PrivateKeyInfo, mlkem1024), -DECODER_w_structure("mlkem1024", der, SubjectPublicKeyInfo, mlkem1024), -DECODER_w_structure("p521_mlkem1024", der, PrivateKeyInfo, p521_mlkem1024), -DECODER_w_structure("p521_mlkem1024", der, SubjectPublicKeyInfo, p521_mlkem1024),DECODER_w_structure("p384_mlkem1024", der, PrivateKeyInfo, p384_mlkem1024), -DECODER_w_structure("p384_mlkem1024", der, SubjectPublicKeyInfo, p384_mlkem1024), -#endif -#ifdef OQS_ENABLE_KEM_bike_l1 -DECODER_w_structure("bikel1", der, PrivateKeyInfo, bikel1), -DECODER_w_structure("bikel1", der, SubjectPublicKeyInfo, bikel1), -DECODER_w_structure("p256_bikel1", der, PrivateKeyInfo, p256_bikel1), -DECODER_w_structure("p256_bikel1", der, SubjectPublicKeyInfo, p256_bikel1),DECODER_w_structure("x25519_bikel1", der, PrivateKeyInfo, x25519_bikel1), -DECODER_w_structure("x25519_bikel1", der, SubjectPublicKeyInfo, x25519_bikel1), -#endif -#ifdef OQS_ENABLE_KEM_bike_l3 -DECODER_w_structure("bikel3", der, PrivateKeyInfo, bikel3), -DECODER_w_structure("bikel3", der, SubjectPublicKeyInfo, bikel3), -DECODER_w_structure("p384_bikel3", der, PrivateKeyInfo, p384_bikel3), -DECODER_w_structure("p384_bikel3", der, SubjectPublicKeyInfo, p384_bikel3),DECODER_w_structure("x448_bikel3", der, PrivateKeyInfo, x448_bikel3), -DECODER_w_structure("x448_bikel3", der, SubjectPublicKeyInfo, x448_bikel3), -#endif -#ifdef OQS_ENABLE_KEM_bike_l5 -DECODER_w_structure("bikel5", der, PrivateKeyInfo, bikel5), -DECODER_w_structure("bikel5", der, SubjectPublicKeyInfo, bikel5), -DECODER_w_structure("p521_bikel5", der, PrivateKeyInfo, p521_bikel5), -DECODER_w_structure("p521_bikel5", der, SubjectPublicKeyInfo, p521_bikel5), -#endif -#ifdef OQS_ENABLE_KEM_hqc_128 -DECODER_w_structure("hqc128", der, PrivateKeyInfo, hqc128), -DECODER_w_structure("hqc128", der, SubjectPublicKeyInfo, hqc128), -DECODER_w_structure("p256_hqc128", der, PrivateKeyInfo, p256_hqc128), -DECODER_w_structure("p256_hqc128", der, SubjectPublicKeyInfo, p256_hqc128),DECODER_w_structure("x25519_hqc128", der, PrivateKeyInfo, x25519_hqc128), -DECODER_w_structure("x25519_hqc128", der, SubjectPublicKeyInfo, x25519_hqc128), -#endif -#ifdef OQS_ENABLE_KEM_hqc_192 -DECODER_w_structure("hqc192", der, PrivateKeyInfo, hqc192), -DECODER_w_structure("hqc192", der, SubjectPublicKeyInfo, hqc192), -DECODER_w_structure("p384_hqc192", der, PrivateKeyInfo, p384_hqc192), -DECODER_w_structure("p384_hqc192", der, SubjectPublicKeyInfo, p384_hqc192),DECODER_w_structure("x448_hqc192", der, PrivateKeyInfo, x448_hqc192), -DECODER_w_structure("x448_hqc192", der, SubjectPublicKeyInfo, x448_hqc192), -#endif -#ifdef OQS_ENABLE_KEM_hqc_256 -DECODER_w_structure("hqc256", der, PrivateKeyInfo, hqc256), -DECODER_w_structure("hqc256", der, SubjectPublicKeyInfo, hqc256), -DECODER_w_structure("p521_hqc256", der, PrivateKeyInfo, p521_hqc256), -DECODER_w_structure("p521_hqc256", der, SubjectPublicKeyInfo, p521_hqc256), -#endif + DECODER_w_structure("frodo640aes", der, SubjectPublicKeyInfo, frodo640aes), + DECODER_w_structure("p256_frodo640aes", der, PrivateKeyInfo, + p256_frodo640aes), + DECODER_w_structure("p256_frodo640aes", der, SubjectPublicKeyInfo, + p256_frodo640aes), + DECODER_w_structure("x25519_frodo640aes", der, PrivateKeyInfo, + x25519_frodo640aes), + DECODER_w_structure("x25519_frodo640aes", der, SubjectPublicKeyInfo, + x25519_frodo640aes), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_640_shake + DECODER_w_structure("frodo640shake", der, PrivateKeyInfo, frodo640shake), + DECODER_w_structure("frodo640shake", der, SubjectPublicKeyInfo, + frodo640shake), + DECODER_w_structure("p256_frodo640shake", der, PrivateKeyInfo, + p256_frodo640shake), + DECODER_w_structure("p256_frodo640shake", der, SubjectPublicKeyInfo, + p256_frodo640shake), + DECODER_w_structure("x25519_frodo640shake", der, PrivateKeyInfo, + x25519_frodo640shake), + DECODER_w_structure("x25519_frodo640shake", der, SubjectPublicKeyInfo, + x25519_frodo640shake), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_976_aes + DECODER_w_structure("frodo976aes", der, PrivateKeyInfo, frodo976aes), + DECODER_w_structure("frodo976aes", der, SubjectPublicKeyInfo, frodo976aes), + DECODER_w_structure("p384_frodo976aes", der, PrivateKeyInfo, + p384_frodo976aes), + DECODER_w_structure("p384_frodo976aes", der, SubjectPublicKeyInfo, + p384_frodo976aes), + DECODER_w_structure("x448_frodo976aes", der, PrivateKeyInfo, + x448_frodo976aes), + DECODER_w_structure("x448_frodo976aes", der, SubjectPublicKeyInfo, + x448_frodo976aes), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_976_shake + DECODER_w_structure("frodo976shake", der, PrivateKeyInfo, frodo976shake), + DECODER_w_structure("frodo976shake", der, SubjectPublicKeyInfo, + frodo976shake), + DECODER_w_structure("p384_frodo976shake", der, PrivateKeyInfo, + p384_frodo976shake), + DECODER_w_structure("p384_frodo976shake", der, SubjectPublicKeyInfo, + p384_frodo976shake), + DECODER_w_structure("x448_frodo976shake", der, PrivateKeyInfo, + x448_frodo976shake), + DECODER_w_structure("x448_frodo976shake", der, SubjectPublicKeyInfo, + x448_frodo976shake), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_1344_aes + DECODER_w_structure("frodo1344aes", der, PrivateKeyInfo, frodo1344aes), + DECODER_w_structure("frodo1344aes", der, SubjectPublicKeyInfo, + frodo1344aes), + DECODER_w_structure("p521_frodo1344aes", der, PrivateKeyInfo, + p521_frodo1344aes), + DECODER_w_structure("p521_frodo1344aes", der, SubjectPublicKeyInfo, + p521_frodo1344aes), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_1344_shake + DECODER_w_structure("frodo1344shake", der, PrivateKeyInfo, frodo1344shake), + DECODER_w_structure("frodo1344shake", der, SubjectPublicKeyInfo, + frodo1344shake), + DECODER_w_structure("p521_frodo1344shake", der, PrivateKeyInfo, + p521_frodo1344shake), + DECODER_w_structure("p521_frodo1344shake", der, SubjectPublicKeyInfo, + p521_frodo1344shake), +# endif +# ifdef OQS_ENABLE_KEM_kyber_512 + DECODER_w_structure("kyber512", der, PrivateKeyInfo, kyber512), + DECODER_w_structure("kyber512", der, SubjectPublicKeyInfo, kyber512), + DECODER_w_structure("p256_kyber512", der, PrivateKeyInfo, p256_kyber512), + DECODER_w_structure("p256_kyber512", der, SubjectPublicKeyInfo, + p256_kyber512), + DECODER_w_structure("x25519_kyber512", der, PrivateKeyInfo, + x25519_kyber512), + DECODER_w_structure("x25519_kyber512", der, SubjectPublicKeyInfo, + x25519_kyber512), +# endif +# ifdef OQS_ENABLE_KEM_kyber_768 + DECODER_w_structure("kyber768", der, PrivateKeyInfo, kyber768), + DECODER_w_structure("kyber768", der, SubjectPublicKeyInfo, kyber768), + DECODER_w_structure("p384_kyber768", der, PrivateKeyInfo, p384_kyber768), + DECODER_w_structure("p384_kyber768", der, SubjectPublicKeyInfo, + p384_kyber768), + DECODER_w_structure("x448_kyber768", der, PrivateKeyInfo, x448_kyber768), + DECODER_w_structure("x448_kyber768", der, SubjectPublicKeyInfo, + x448_kyber768), + DECODER_w_structure("x25519_kyber768", der, PrivateKeyInfo, + x25519_kyber768), + DECODER_w_structure("x25519_kyber768", der, SubjectPublicKeyInfo, + x25519_kyber768), + DECODER_w_structure("p256_kyber768", der, PrivateKeyInfo, p256_kyber768), + DECODER_w_structure("p256_kyber768", der, SubjectPublicKeyInfo, + p256_kyber768), +# endif +# ifdef OQS_ENABLE_KEM_kyber_1024 + DECODER_w_structure("kyber1024", der, PrivateKeyInfo, kyber1024), + DECODER_w_structure("kyber1024", der, SubjectPublicKeyInfo, kyber1024), + DECODER_w_structure("p521_kyber1024", der, PrivateKeyInfo, p521_kyber1024), + DECODER_w_structure("p521_kyber1024", der, SubjectPublicKeyInfo, + p521_kyber1024), +# endif +# ifdef OQS_ENABLE_KEM_ml_kem_512 + DECODER_w_structure("mlkem512", der, PrivateKeyInfo, mlkem512), + DECODER_w_structure("mlkem512", der, SubjectPublicKeyInfo, mlkem512), + DECODER_w_structure("p256_mlkem512", der, PrivateKeyInfo, p256_mlkem512), + DECODER_w_structure("p256_mlkem512", der, SubjectPublicKeyInfo, + p256_mlkem512), + DECODER_w_structure("x25519_mlkem512", der, PrivateKeyInfo, + x25519_mlkem512), + DECODER_w_structure("x25519_mlkem512", der, SubjectPublicKeyInfo, + x25519_mlkem512), +# endif +# ifdef OQS_ENABLE_KEM_ml_kem_768 + DECODER_w_structure("mlkem768", der, PrivateKeyInfo, mlkem768), + DECODER_w_structure("mlkem768", der, SubjectPublicKeyInfo, mlkem768), + DECODER_w_structure("p384_mlkem768", der, PrivateKeyInfo, p384_mlkem768), + DECODER_w_structure("p384_mlkem768", der, SubjectPublicKeyInfo, + p384_mlkem768), + DECODER_w_structure("x448_mlkem768", der, PrivateKeyInfo, x448_mlkem768), + DECODER_w_structure("x448_mlkem768", der, SubjectPublicKeyInfo, + x448_mlkem768), + DECODER_w_structure("X25519MLKEM768", der, PrivateKeyInfo, X25519MLKEM768), + DECODER_w_structure("X25519MLKEM768", der, SubjectPublicKeyInfo, + X25519MLKEM768), + DECODER_w_structure("SecP256r1MLKEM768", der, PrivateKeyInfo, + SecP256r1MLKEM768), + DECODER_w_structure("SecP256r1MLKEM768", der, SubjectPublicKeyInfo, + SecP256r1MLKEM768), +# endif +# ifdef OQS_ENABLE_KEM_ml_kem_1024 + DECODER_w_structure("mlkem1024", der, PrivateKeyInfo, mlkem1024), + DECODER_w_structure("mlkem1024", der, SubjectPublicKeyInfo, mlkem1024), + DECODER_w_structure("p521_mlkem1024", der, PrivateKeyInfo, p521_mlkem1024), + DECODER_w_structure("p521_mlkem1024", der, SubjectPublicKeyInfo, + p521_mlkem1024), + DECODER_w_structure("p384_mlkem1024", der, PrivateKeyInfo, p384_mlkem1024), + DECODER_w_structure("p384_mlkem1024", der, SubjectPublicKeyInfo, + p384_mlkem1024), +# endif +# ifdef OQS_ENABLE_KEM_bike_l1 + DECODER_w_structure("bikel1", der, PrivateKeyInfo, bikel1), + DECODER_w_structure("bikel1", der, SubjectPublicKeyInfo, bikel1), + DECODER_w_structure("p256_bikel1", der, PrivateKeyInfo, p256_bikel1), + DECODER_w_structure("p256_bikel1", der, SubjectPublicKeyInfo, p256_bikel1), + DECODER_w_structure("x25519_bikel1", der, PrivateKeyInfo, x25519_bikel1), + DECODER_w_structure("x25519_bikel1", der, SubjectPublicKeyInfo, + x25519_bikel1), +# endif +# ifdef OQS_ENABLE_KEM_bike_l3 + DECODER_w_structure("bikel3", der, PrivateKeyInfo, bikel3), + DECODER_w_structure("bikel3", der, SubjectPublicKeyInfo, bikel3), + DECODER_w_structure("p384_bikel3", der, PrivateKeyInfo, p384_bikel3), + DECODER_w_structure("p384_bikel3", der, SubjectPublicKeyInfo, p384_bikel3), + DECODER_w_structure("x448_bikel3", der, PrivateKeyInfo, x448_bikel3), + DECODER_w_structure("x448_bikel3", der, SubjectPublicKeyInfo, x448_bikel3), +# endif +# ifdef OQS_ENABLE_KEM_bike_l5 + DECODER_w_structure("bikel5", der, PrivateKeyInfo, bikel5), + DECODER_w_structure("bikel5", der, SubjectPublicKeyInfo, bikel5), + DECODER_w_structure("p521_bikel5", der, PrivateKeyInfo, p521_bikel5), + DECODER_w_structure("p521_bikel5", der, SubjectPublicKeyInfo, p521_bikel5), +# endif +# ifdef OQS_ENABLE_KEM_hqc_128 + DECODER_w_structure("hqc128", der, PrivateKeyInfo, hqc128), + DECODER_w_structure("hqc128", der, SubjectPublicKeyInfo, hqc128), + DECODER_w_structure("p256_hqc128", der, PrivateKeyInfo, p256_hqc128), + DECODER_w_structure("p256_hqc128", der, SubjectPublicKeyInfo, p256_hqc128), + DECODER_w_structure("x25519_hqc128", der, PrivateKeyInfo, x25519_hqc128), + DECODER_w_structure("x25519_hqc128", der, SubjectPublicKeyInfo, + x25519_hqc128), +# endif +# ifdef OQS_ENABLE_KEM_hqc_192 + DECODER_w_structure("hqc192", der, PrivateKeyInfo, hqc192), + DECODER_w_structure("hqc192", der, SubjectPublicKeyInfo, hqc192), + DECODER_w_structure("p384_hqc192", der, PrivateKeyInfo, p384_hqc192), + DECODER_w_structure("p384_hqc192", der, SubjectPublicKeyInfo, p384_hqc192), + DECODER_w_structure("x448_hqc192", der, PrivateKeyInfo, x448_hqc192), + DECODER_w_structure("x448_hqc192", der, SubjectPublicKeyInfo, x448_hqc192), +# endif +# ifdef OQS_ENABLE_KEM_hqc_256 + DECODER_w_structure("hqc256", der, PrivateKeyInfo, hqc256), + DECODER_w_structure("hqc256", der, SubjectPublicKeyInfo, hqc256), + DECODER_w_structure("p521_hqc256", der, PrivateKeyInfo, p521_hqc256), + DECODER_w_structure("p521_hqc256", der, SubjectPublicKeyInfo, p521_hqc256), +# endif #endif /* OQS_KEM_ENCODERS */ - #ifdef OQS_ENABLE_SIG_dilithium_2 -DECODER_w_structure("dilithium2", der, PrivateKeyInfo, dilithium2), -DECODER_w_structure("dilithium2", der, SubjectPublicKeyInfo, dilithium2),DECODER_w_structure("p256_dilithium2", der, PrivateKeyInfo, p256_dilithium2), -DECODER_w_structure("p256_dilithium2", der, SubjectPublicKeyInfo, p256_dilithium2),DECODER_w_structure("rsa3072_dilithium2", der, PrivateKeyInfo, rsa3072_dilithium2), -DECODER_w_structure("rsa3072_dilithium2", der, SubjectPublicKeyInfo, rsa3072_dilithium2), + DECODER_w_structure("dilithium2", der, PrivateKeyInfo, dilithium2), + DECODER_w_structure("dilithium2", der, SubjectPublicKeyInfo, dilithium2), + DECODER_w_structure("p256_dilithium2", der, PrivateKeyInfo, + p256_dilithium2), + DECODER_w_structure("p256_dilithium2", der, SubjectPublicKeyInfo, + p256_dilithium2), + DECODER_w_structure("rsa3072_dilithium2", der, PrivateKeyInfo, + rsa3072_dilithium2), + DECODER_w_structure("rsa3072_dilithium2", der, SubjectPublicKeyInfo, + rsa3072_dilithium2), #endif #ifdef OQS_ENABLE_SIG_dilithium_3 -DECODER_w_structure("dilithium3", der, PrivateKeyInfo, dilithium3), -DECODER_w_structure("dilithium3", der, SubjectPublicKeyInfo, dilithium3),DECODER_w_structure("p384_dilithium3", der, PrivateKeyInfo, p384_dilithium3), -DECODER_w_structure("p384_dilithium3", der, SubjectPublicKeyInfo, p384_dilithium3), + DECODER_w_structure("dilithium3", der, PrivateKeyInfo, dilithium3), + DECODER_w_structure("dilithium3", der, SubjectPublicKeyInfo, dilithium3), + DECODER_w_structure("p384_dilithium3", der, PrivateKeyInfo, + p384_dilithium3), + DECODER_w_structure("p384_dilithium3", der, SubjectPublicKeyInfo, + p384_dilithium3), #endif #ifdef OQS_ENABLE_SIG_dilithium_5 -DECODER_w_structure("dilithium5", der, PrivateKeyInfo, dilithium5), -DECODER_w_structure("dilithium5", der, SubjectPublicKeyInfo, dilithium5),DECODER_w_structure("p521_dilithium5", der, PrivateKeyInfo, p521_dilithium5), -DECODER_w_structure("p521_dilithium5", der, SubjectPublicKeyInfo, p521_dilithium5), + DECODER_w_structure("dilithium5", der, PrivateKeyInfo, dilithium5), + DECODER_w_structure("dilithium5", der, SubjectPublicKeyInfo, dilithium5), + DECODER_w_structure("p521_dilithium5", der, PrivateKeyInfo, + p521_dilithium5), + DECODER_w_structure("p521_dilithium5", der, SubjectPublicKeyInfo, + p521_dilithium5), #endif #ifdef OQS_ENABLE_SIG_ml_dsa_44 -DECODER_w_structure("mldsa44", der, PrivateKeyInfo, mldsa44), -DECODER_w_structure("mldsa44", der, SubjectPublicKeyInfo, mldsa44),DECODER_w_structure("p256_mldsa44", der, PrivateKeyInfo, p256_mldsa44), -DECODER_w_structure("p256_mldsa44", der, SubjectPublicKeyInfo, p256_mldsa44),DECODER_w_structure("rsa3072_mldsa44", der, PrivateKeyInfo, rsa3072_mldsa44), -DECODER_w_structure("rsa3072_mldsa44", der, SubjectPublicKeyInfo, rsa3072_mldsa44),DECODER_w_structure("mldsa44_pss2048", der, PrivateKeyInfo, mldsa44_pss2048), -DECODER_w_structure("mldsa44_pss2048", der, SubjectPublicKeyInfo, mldsa44_pss2048),DECODER_w_structure("mldsa44_rsa2048", der, PrivateKeyInfo, mldsa44_rsa2048), -DECODER_w_structure("mldsa44_rsa2048", der, SubjectPublicKeyInfo, mldsa44_rsa2048),DECODER_w_structure("mldsa44_ed25519", der, PrivateKeyInfo, mldsa44_ed25519), -DECODER_w_structure("mldsa44_ed25519", der, SubjectPublicKeyInfo, mldsa44_ed25519),DECODER_w_structure("mldsa44_p256", der, PrivateKeyInfo, mldsa44_p256), -DECODER_w_structure("mldsa44_p256", der, SubjectPublicKeyInfo, mldsa44_p256),DECODER_w_structure("mldsa44_bp256", der, PrivateKeyInfo, mldsa44_bp256), -DECODER_w_structure("mldsa44_bp256", der, SubjectPublicKeyInfo, mldsa44_bp256), + DECODER_w_structure("mldsa44", der, PrivateKeyInfo, mldsa44), + DECODER_w_structure("mldsa44", der, SubjectPublicKeyInfo, mldsa44), + DECODER_w_structure("p256_mldsa44", der, PrivateKeyInfo, p256_mldsa44), + DECODER_w_structure("p256_mldsa44", der, SubjectPublicKeyInfo, + p256_mldsa44), + DECODER_w_structure("rsa3072_mldsa44", der, PrivateKeyInfo, + rsa3072_mldsa44), + DECODER_w_structure("rsa3072_mldsa44", der, SubjectPublicKeyInfo, + rsa3072_mldsa44), + DECODER_w_structure("mldsa44_pss2048", der, PrivateKeyInfo, + mldsa44_pss2048), + DECODER_w_structure("mldsa44_pss2048", der, SubjectPublicKeyInfo, + mldsa44_pss2048), + DECODER_w_structure("mldsa44_rsa2048", der, PrivateKeyInfo, + mldsa44_rsa2048), + DECODER_w_structure("mldsa44_rsa2048", der, SubjectPublicKeyInfo, + mldsa44_rsa2048), + DECODER_w_structure("mldsa44_ed25519", der, PrivateKeyInfo, + mldsa44_ed25519), + DECODER_w_structure("mldsa44_ed25519", der, SubjectPublicKeyInfo, + mldsa44_ed25519), + DECODER_w_structure("mldsa44_p256", der, PrivateKeyInfo, mldsa44_p256), + DECODER_w_structure("mldsa44_p256", der, SubjectPublicKeyInfo, + mldsa44_p256), + DECODER_w_structure("mldsa44_bp256", der, PrivateKeyInfo, mldsa44_bp256), + DECODER_w_structure("mldsa44_bp256", der, SubjectPublicKeyInfo, + mldsa44_bp256), #endif #ifdef OQS_ENABLE_SIG_ml_dsa_65 -DECODER_w_structure("mldsa65", der, PrivateKeyInfo, mldsa65), -DECODER_w_structure("mldsa65", der, SubjectPublicKeyInfo, mldsa65),DECODER_w_structure("p384_mldsa65", der, PrivateKeyInfo, p384_mldsa65), -DECODER_w_structure("p384_mldsa65", der, SubjectPublicKeyInfo, p384_mldsa65),DECODER_w_structure("mldsa65_pss3072", der, PrivateKeyInfo, mldsa65_pss3072), -DECODER_w_structure("mldsa65_pss3072", der, SubjectPublicKeyInfo, mldsa65_pss3072),DECODER_w_structure("mldsa65_rsa3072", der, PrivateKeyInfo, mldsa65_rsa3072), -DECODER_w_structure("mldsa65_rsa3072", der, SubjectPublicKeyInfo, mldsa65_rsa3072),DECODER_w_structure("mldsa65_p256", der, PrivateKeyInfo, mldsa65_p256), -DECODER_w_structure("mldsa65_p256", der, SubjectPublicKeyInfo, mldsa65_p256),DECODER_w_structure("mldsa65_bp256", der, PrivateKeyInfo, mldsa65_bp256), -DECODER_w_structure("mldsa65_bp256", der, SubjectPublicKeyInfo, mldsa65_bp256),DECODER_w_structure("mldsa65_ed25519", der, PrivateKeyInfo, mldsa65_ed25519), -DECODER_w_structure("mldsa65_ed25519", der, SubjectPublicKeyInfo, mldsa65_ed25519), + DECODER_w_structure("mldsa65", der, PrivateKeyInfo, mldsa65), + DECODER_w_structure("mldsa65", der, SubjectPublicKeyInfo, mldsa65), + DECODER_w_structure("p384_mldsa65", der, PrivateKeyInfo, p384_mldsa65), + DECODER_w_structure("p384_mldsa65", der, SubjectPublicKeyInfo, + p384_mldsa65), + DECODER_w_structure("mldsa65_pss3072", der, PrivateKeyInfo, + mldsa65_pss3072), + DECODER_w_structure("mldsa65_pss3072", der, SubjectPublicKeyInfo, + mldsa65_pss3072), + DECODER_w_structure("mldsa65_rsa3072", der, PrivateKeyInfo, + mldsa65_rsa3072), + DECODER_w_structure("mldsa65_rsa3072", der, SubjectPublicKeyInfo, + mldsa65_rsa3072), + DECODER_w_structure("mldsa65_p256", der, PrivateKeyInfo, mldsa65_p256), + DECODER_w_structure("mldsa65_p256", der, SubjectPublicKeyInfo, + mldsa65_p256), + DECODER_w_structure("mldsa65_bp256", der, PrivateKeyInfo, mldsa65_bp256), + DECODER_w_structure("mldsa65_bp256", der, SubjectPublicKeyInfo, + mldsa65_bp256), + DECODER_w_structure("mldsa65_ed25519", der, PrivateKeyInfo, + mldsa65_ed25519), + DECODER_w_structure("mldsa65_ed25519", der, SubjectPublicKeyInfo, + mldsa65_ed25519), #endif #ifdef OQS_ENABLE_SIG_ml_dsa_87 -DECODER_w_structure("mldsa87", der, PrivateKeyInfo, mldsa87), -DECODER_w_structure("mldsa87", der, SubjectPublicKeyInfo, mldsa87),DECODER_w_structure("p521_mldsa87", der, PrivateKeyInfo, p521_mldsa87), -DECODER_w_structure("p521_mldsa87", der, SubjectPublicKeyInfo, p521_mldsa87),DECODER_w_structure("mldsa87_p384", der, PrivateKeyInfo, mldsa87_p384), -DECODER_w_structure("mldsa87_p384", der, SubjectPublicKeyInfo, mldsa87_p384),DECODER_w_structure("mldsa87_bp384", der, PrivateKeyInfo, mldsa87_bp384), -DECODER_w_structure("mldsa87_bp384", der, SubjectPublicKeyInfo, mldsa87_bp384),DECODER_w_structure("mldsa87_ed448", der, PrivateKeyInfo, mldsa87_ed448), -DECODER_w_structure("mldsa87_ed448", der, SubjectPublicKeyInfo, mldsa87_ed448), + DECODER_w_structure("mldsa87", der, PrivateKeyInfo, mldsa87), + DECODER_w_structure("mldsa87", der, SubjectPublicKeyInfo, mldsa87), + DECODER_w_structure("p521_mldsa87", der, PrivateKeyInfo, p521_mldsa87), + DECODER_w_structure("p521_mldsa87", der, SubjectPublicKeyInfo, + p521_mldsa87), + DECODER_w_structure("mldsa87_p384", der, PrivateKeyInfo, mldsa87_p384), + DECODER_w_structure("mldsa87_p384", der, SubjectPublicKeyInfo, + mldsa87_p384), + DECODER_w_structure("mldsa87_bp384", der, PrivateKeyInfo, mldsa87_bp384), + DECODER_w_structure("mldsa87_bp384", der, SubjectPublicKeyInfo, + mldsa87_bp384), + DECODER_w_structure("mldsa87_ed448", der, PrivateKeyInfo, mldsa87_ed448), + DECODER_w_structure("mldsa87_ed448", der, SubjectPublicKeyInfo, + mldsa87_ed448), #endif #ifdef OQS_ENABLE_SIG_falcon_512 -DECODER_w_structure("falcon512", der, PrivateKeyInfo, falcon512), -DECODER_w_structure("falcon512", der, SubjectPublicKeyInfo, falcon512),DECODER_w_structure("p256_falcon512", der, PrivateKeyInfo, p256_falcon512), -DECODER_w_structure("p256_falcon512", der, SubjectPublicKeyInfo, p256_falcon512),DECODER_w_structure("rsa3072_falcon512", der, PrivateKeyInfo, rsa3072_falcon512), -DECODER_w_structure("rsa3072_falcon512", der, SubjectPublicKeyInfo, rsa3072_falcon512), + DECODER_w_structure("falcon512", der, PrivateKeyInfo, falcon512), + DECODER_w_structure("falcon512", der, SubjectPublicKeyInfo, falcon512), + DECODER_w_structure("p256_falcon512", der, PrivateKeyInfo, p256_falcon512), + DECODER_w_structure("p256_falcon512", der, SubjectPublicKeyInfo, + p256_falcon512), + DECODER_w_structure("rsa3072_falcon512", der, PrivateKeyInfo, + rsa3072_falcon512), + DECODER_w_structure("rsa3072_falcon512", der, SubjectPublicKeyInfo, + rsa3072_falcon512), #endif #ifdef OQS_ENABLE_SIG_falcon_padded_512 -DECODER_w_structure("falconpadded512", der, PrivateKeyInfo, falconpadded512), -DECODER_w_structure("falconpadded512", der, SubjectPublicKeyInfo, falconpadded512),DECODER_w_structure("p256_falconpadded512", der, PrivateKeyInfo, p256_falconpadded512), -DECODER_w_structure("p256_falconpadded512", der, SubjectPublicKeyInfo, p256_falconpadded512),DECODER_w_structure("rsa3072_falconpadded512", der, PrivateKeyInfo, rsa3072_falconpadded512), -DECODER_w_structure("rsa3072_falconpadded512", der, SubjectPublicKeyInfo, rsa3072_falconpadded512), + DECODER_w_structure("falconpadded512", der, PrivateKeyInfo, + falconpadded512), + DECODER_w_structure("falconpadded512", der, SubjectPublicKeyInfo, + falconpadded512), + DECODER_w_structure("p256_falconpadded512", der, PrivateKeyInfo, + p256_falconpadded512), + DECODER_w_structure("p256_falconpadded512", der, SubjectPublicKeyInfo, + p256_falconpadded512), + DECODER_w_structure("rsa3072_falconpadded512", der, PrivateKeyInfo, + rsa3072_falconpadded512), + DECODER_w_structure("rsa3072_falconpadded512", der, SubjectPublicKeyInfo, + rsa3072_falconpadded512), #endif #ifdef OQS_ENABLE_SIG_falcon_1024 -DECODER_w_structure("falcon1024", der, PrivateKeyInfo, falcon1024), -DECODER_w_structure("falcon1024", der, SubjectPublicKeyInfo, falcon1024),DECODER_w_structure("p521_falcon1024", der, PrivateKeyInfo, p521_falcon1024), -DECODER_w_structure("p521_falcon1024", der, SubjectPublicKeyInfo, p521_falcon1024), + DECODER_w_structure("falcon1024", der, PrivateKeyInfo, falcon1024), + DECODER_w_structure("falcon1024", der, SubjectPublicKeyInfo, falcon1024), + DECODER_w_structure("p521_falcon1024", der, PrivateKeyInfo, + p521_falcon1024), + DECODER_w_structure("p521_falcon1024", der, SubjectPublicKeyInfo, + p521_falcon1024), #endif #ifdef OQS_ENABLE_SIG_falcon_padded_1024 -DECODER_w_structure("falconpadded1024", der, PrivateKeyInfo, falconpadded1024), -DECODER_w_structure("falconpadded1024", der, SubjectPublicKeyInfo, falconpadded1024),DECODER_w_structure("p521_falconpadded1024", der, PrivateKeyInfo, p521_falconpadded1024), -DECODER_w_structure("p521_falconpadded1024", der, SubjectPublicKeyInfo, p521_falconpadded1024), + DECODER_w_structure("falconpadded1024", der, PrivateKeyInfo, + falconpadded1024), + DECODER_w_structure("falconpadded1024", der, SubjectPublicKeyInfo, + falconpadded1024), + DECODER_w_structure("p521_falconpadded1024", der, PrivateKeyInfo, + p521_falconpadded1024), + DECODER_w_structure("p521_falconpadded1024", der, SubjectPublicKeyInfo, + p521_falconpadded1024), #endif #ifdef OQS_ENABLE_SIG_sphincs_sha2_128f_simple -DECODER_w_structure("sphincssha2128fsimple", der, PrivateKeyInfo, sphincssha2128fsimple), -DECODER_w_structure("sphincssha2128fsimple", der, SubjectPublicKeyInfo, sphincssha2128fsimple),DECODER_w_structure("p256_sphincssha2128fsimple", der, PrivateKeyInfo, p256_sphincssha2128fsimple), -DECODER_w_structure("p256_sphincssha2128fsimple", der, SubjectPublicKeyInfo, p256_sphincssha2128fsimple),DECODER_w_structure("rsa3072_sphincssha2128fsimple", der, PrivateKeyInfo, rsa3072_sphincssha2128fsimple), -DECODER_w_structure("rsa3072_sphincssha2128fsimple", der, SubjectPublicKeyInfo, rsa3072_sphincssha2128fsimple), + DECODER_w_structure("sphincssha2128fsimple", der, PrivateKeyInfo, + sphincssha2128fsimple), + DECODER_w_structure("sphincssha2128fsimple", der, SubjectPublicKeyInfo, + sphincssha2128fsimple), + DECODER_w_structure("p256_sphincssha2128fsimple", der, PrivateKeyInfo, + p256_sphincssha2128fsimple), + DECODER_w_structure("p256_sphincssha2128fsimple", der, SubjectPublicKeyInfo, + p256_sphincssha2128fsimple), + DECODER_w_structure("rsa3072_sphincssha2128fsimple", der, PrivateKeyInfo, + rsa3072_sphincssha2128fsimple), + DECODER_w_structure("rsa3072_sphincssha2128fsimple", der, + SubjectPublicKeyInfo, rsa3072_sphincssha2128fsimple), #endif #ifdef OQS_ENABLE_SIG_sphincs_sha2_128s_simple -DECODER_w_structure("sphincssha2128ssimple", der, PrivateKeyInfo, sphincssha2128ssimple), -DECODER_w_structure("sphincssha2128ssimple", der, SubjectPublicKeyInfo, sphincssha2128ssimple),DECODER_w_structure("p256_sphincssha2128ssimple", der, PrivateKeyInfo, p256_sphincssha2128ssimple), -DECODER_w_structure("p256_sphincssha2128ssimple", der, SubjectPublicKeyInfo, p256_sphincssha2128ssimple),DECODER_w_structure("rsa3072_sphincssha2128ssimple", der, PrivateKeyInfo, rsa3072_sphincssha2128ssimple), -DECODER_w_structure("rsa3072_sphincssha2128ssimple", der, SubjectPublicKeyInfo, rsa3072_sphincssha2128ssimple), + DECODER_w_structure("sphincssha2128ssimple", der, PrivateKeyInfo, + sphincssha2128ssimple), + DECODER_w_structure("sphincssha2128ssimple", der, SubjectPublicKeyInfo, + sphincssha2128ssimple), + DECODER_w_structure("p256_sphincssha2128ssimple", der, PrivateKeyInfo, + p256_sphincssha2128ssimple), + DECODER_w_structure("p256_sphincssha2128ssimple", der, SubjectPublicKeyInfo, + p256_sphincssha2128ssimple), + DECODER_w_structure("rsa3072_sphincssha2128ssimple", der, PrivateKeyInfo, + rsa3072_sphincssha2128ssimple), + DECODER_w_structure("rsa3072_sphincssha2128ssimple", der, + SubjectPublicKeyInfo, rsa3072_sphincssha2128ssimple), #endif #ifdef OQS_ENABLE_SIG_sphincs_sha2_192f_simple -DECODER_w_structure("sphincssha2192fsimple", der, PrivateKeyInfo, sphincssha2192fsimple), -DECODER_w_structure("sphincssha2192fsimple", der, SubjectPublicKeyInfo, sphincssha2192fsimple),DECODER_w_structure("p384_sphincssha2192fsimple", der, PrivateKeyInfo, p384_sphincssha2192fsimple), -DECODER_w_structure("p384_sphincssha2192fsimple", der, SubjectPublicKeyInfo, p384_sphincssha2192fsimple), + DECODER_w_structure("sphincssha2192fsimple", der, PrivateKeyInfo, + sphincssha2192fsimple), + DECODER_w_structure("sphincssha2192fsimple", der, SubjectPublicKeyInfo, + sphincssha2192fsimple), + DECODER_w_structure("p384_sphincssha2192fsimple", der, PrivateKeyInfo, + p384_sphincssha2192fsimple), + DECODER_w_structure("p384_sphincssha2192fsimple", der, SubjectPublicKeyInfo, + p384_sphincssha2192fsimple), #endif #ifdef OQS_ENABLE_SIG_sphincs_shake_128f_simple -DECODER_w_structure("sphincsshake128fsimple", der, PrivateKeyInfo, sphincsshake128fsimple), -DECODER_w_structure("sphincsshake128fsimple", der, SubjectPublicKeyInfo, sphincsshake128fsimple),DECODER_w_structure("p256_sphincsshake128fsimple", der, PrivateKeyInfo, p256_sphincsshake128fsimple), -DECODER_w_structure("p256_sphincsshake128fsimple", der, SubjectPublicKeyInfo, p256_sphincsshake128fsimple),DECODER_w_structure("rsa3072_sphincsshake128fsimple", der, PrivateKeyInfo, rsa3072_sphincsshake128fsimple), -DECODER_w_structure("rsa3072_sphincsshake128fsimple", der, SubjectPublicKeyInfo, rsa3072_sphincsshake128fsimple), + DECODER_w_structure("sphincsshake128fsimple", der, PrivateKeyInfo, + sphincsshake128fsimple), + DECODER_w_structure("sphincsshake128fsimple", der, SubjectPublicKeyInfo, + sphincsshake128fsimple), + DECODER_w_structure("p256_sphincsshake128fsimple", der, PrivateKeyInfo, + p256_sphincsshake128fsimple), + DECODER_w_structure("p256_sphincsshake128fsimple", der, + SubjectPublicKeyInfo, p256_sphincsshake128fsimple), + DECODER_w_structure("rsa3072_sphincsshake128fsimple", der, PrivateKeyInfo, + rsa3072_sphincsshake128fsimple), + DECODER_w_structure("rsa3072_sphincsshake128fsimple", der, + SubjectPublicKeyInfo, rsa3072_sphincsshake128fsimple), #endif #ifdef OQS_ENABLE_SIG_mayo_1 -DECODER_w_structure("mayo1", der, PrivateKeyInfo, mayo1), -DECODER_w_structure("mayo1", der, SubjectPublicKeyInfo, mayo1),DECODER_w_structure("p256_mayo1", der, PrivateKeyInfo, p256_mayo1), -DECODER_w_structure("p256_mayo1", der, SubjectPublicKeyInfo, p256_mayo1), + DECODER_w_structure("mayo1", der, PrivateKeyInfo, mayo1), + DECODER_w_structure("mayo1", der, SubjectPublicKeyInfo, mayo1), + DECODER_w_structure("p256_mayo1", der, PrivateKeyInfo, p256_mayo1), + DECODER_w_structure("p256_mayo1", der, SubjectPublicKeyInfo, p256_mayo1), #endif #ifdef OQS_ENABLE_SIG_mayo_2 -DECODER_w_structure("mayo2", der, PrivateKeyInfo, mayo2), -DECODER_w_structure("mayo2", der, SubjectPublicKeyInfo, mayo2),DECODER_w_structure("p256_mayo2", der, PrivateKeyInfo, p256_mayo2), -DECODER_w_structure("p256_mayo2", der, SubjectPublicKeyInfo, p256_mayo2), + DECODER_w_structure("mayo2", der, PrivateKeyInfo, mayo2), + DECODER_w_structure("mayo2", der, SubjectPublicKeyInfo, mayo2), + DECODER_w_structure("p256_mayo2", der, PrivateKeyInfo, p256_mayo2), + DECODER_w_structure("p256_mayo2", der, SubjectPublicKeyInfo, p256_mayo2), #endif #ifdef OQS_ENABLE_SIG_mayo_3 -DECODER_w_structure("mayo3", der, PrivateKeyInfo, mayo3), -DECODER_w_structure("mayo3", der, SubjectPublicKeyInfo, mayo3),DECODER_w_structure("p384_mayo3", der, PrivateKeyInfo, p384_mayo3), -DECODER_w_structure("p384_mayo3", der, SubjectPublicKeyInfo, p384_mayo3), + DECODER_w_structure("mayo3", der, PrivateKeyInfo, mayo3), + DECODER_w_structure("mayo3", der, SubjectPublicKeyInfo, mayo3), + DECODER_w_structure("p384_mayo3", der, PrivateKeyInfo, p384_mayo3), + DECODER_w_structure("p384_mayo3", der, SubjectPublicKeyInfo, p384_mayo3), #endif #ifdef OQS_ENABLE_SIG_mayo_5 -DECODER_w_structure("mayo5", der, PrivateKeyInfo, mayo5), -DECODER_w_structure("mayo5", der, SubjectPublicKeyInfo, mayo5),DECODER_w_structure("p521_mayo5", der, PrivateKeyInfo, p521_mayo5), -DECODER_w_structure("p521_mayo5", der, SubjectPublicKeyInfo, p521_mayo5), + DECODER_w_structure("mayo5", der, PrivateKeyInfo, mayo5), + DECODER_w_structure("mayo5", der, SubjectPublicKeyInfo, mayo5), + DECODER_w_structure("p521_mayo5", der, PrivateKeyInfo, p521_mayo5), + DECODER_w_structure("p521_mayo5", der, SubjectPublicKeyInfo, p521_mayo5), #endif #ifdef OQS_ENABLE_SIG_cross_rsdp_128_balanced -DECODER_w_structure("CROSSrsdp128balanced", der, PrivateKeyInfo, CROSSrsdp128balanced), -DECODER_w_structure("CROSSrsdp128balanced", der, SubjectPublicKeyInfo, CROSSrsdp128balanced), + DECODER_w_structure("CROSSrsdp128balanced", der, PrivateKeyInfo, + CROSSrsdp128balanced), + DECODER_w_structure("CROSSrsdp128balanced", der, SubjectPublicKeyInfo, + CROSSrsdp128balanced), #endif -///// OQS_TEMPLATE_FRAGMENT_MAKE_END + ///// OQS_TEMPLATE_FRAGMENT_MAKE_END diff --git a/oqsprov/oqsencoders.inc b/oqsprov/oqsencoders.inc index 386ef8a0..ca9eeef3 100644 --- a/oqsprov/oqsencoders.inc +++ b/oqsprov/oqsencoders.inc @@ -81,853 +81,1270 @@ ///// OQS_TEMPLATE_FRAGMENT_MAKE_START #ifdef OQS_KEM_ENCODERS - -#ifdef OQS_ENABLE_KEM_frodokem_640_aes +# ifdef OQS_ENABLE_KEM_frodokem_640_aes ENCODER_w_structure("frodo640aes", frodo640aes, der, PrivateKeyInfo), -ENCODER_w_structure("frodo640aes", frodo640aes, pem, PrivateKeyInfo), -ENCODER_w_structure("frodo640aes", frodo640aes, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo640aes", frodo640aes, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo640aes", frodo640aes, der, SubjectPublicKeyInfo), -ENCODER_w_structure("frodo640aes", frodo640aes, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("frodo640aes", frodo640aes), -ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, der, PrivateKeyInfo), -ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_frodo640aes", p256_frodo640aes), -ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, der, PrivateKeyInfo), -ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, pem, PrivateKeyInfo), -ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x25519_frodo640aes", x25519_frodo640aes), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_640_shake -ENCODER_w_structure("frodo640shake", frodo640shake, der, PrivateKeyInfo), -ENCODER_w_structure("frodo640shake", frodo640shake, pem, PrivateKeyInfo), -ENCODER_w_structure("frodo640shake", frodo640shake, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo640shake", frodo640shake, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo640shake", frodo640shake, der, SubjectPublicKeyInfo), -ENCODER_w_structure("frodo640shake", frodo640shake, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("frodo640shake", frodo640shake), -ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, der, PrivateKeyInfo), -ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_frodo640shake", p256_frodo640shake), -ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, der, PrivateKeyInfo), -ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, pem, PrivateKeyInfo), -ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x25519_frodo640shake", x25519_frodo640shake), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_976_aes -ENCODER_w_structure("frodo976aes", frodo976aes, der, PrivateKeyInfo), -ENCODER_w_structure("frodo976aes", frodo976aes, pem, PrivateKeyInfo), -ENCODER_w_structure("frodo976aes", frodo976aes, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo976aes", frodo976aes, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo976aes", frodo976aes, der, SubjectPublicKeyInfo), -ENCODER_w_structure("frodo976aes", frodo976aes, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("frodo976aes", frodo976aes), -ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, der, PrivateKeyInfo), -ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_frodo976aes", p384_frodo976aes), -ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, der, PrivateKeyInfo), -ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, pem, PrivateKeyInfo), -ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x448_frodo976aes", x448_frodo976aes), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_976_shake -ENCODER_w_structure("frodo976shake", frodo976shake, der, PrivateKeyInfo), -ENCODER_w_structure("frodo976shake", frodo976shake, pem, PrivateKeyInfo), -ENCODER_w_structure("frodo976shake", frodo976shake, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo976shake", frodo976shake, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo976shake", frodo976shake, der, SubjectPublicKeyInfo), -ENCODER_w_structure("frodo976shake", frodo976shake, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("frodo976shake", frodo976shake), -ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, der, PrivateKeyInfo), -ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_frodo976shake", p384_frodo976shake), -ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, der, PrivateKeyInfo), -ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, pem, PrivateKeyInfo), -ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x448_frodo976shake", x448_frodo976shake), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_1344_aes -ENCODER_w_structure("frodo1344aes", frodo1344aes, der, PrivateKeyInfo), -ENCODER_w_structure("frodo1344aes", frodo1344aes, pem, PrivateKeyInfo), -ENCODER_w_structure("frodo1344aes", frodo1344aes, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo1344aes", frodo1344aes, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo1344aes", frodo1344aes, der, SubjectPublicKeyInfo), -ENCODER_w_structure("frodo1344aes", frodo1344aes, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("frodo1344aes", frodo1344aes), -ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, der, PrivateKeyInfo), -ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_frodo1344aes", p521_frodo1344aes), -#endif -#ifdef OQS_ENABLE_KEM_frodokem_1344_shake -ENCODER_w_structure("frodo1344shake", frodo1344shake, der, PrivateKeyInfo), -ENCODER_w_structure("frodo1344shake", frodo1344shake, pem, PrivateKeyInfo), -ENCODER_w_structure("frodo1344shake", frodo1344shake, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo1344shake", frodo1344shake, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("frodo1344shake", frodo1344shake, der, SubjectPublicKeyInfo), -ENCODER_w_structure("frodo1344shake", frodo1344shake, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("frodo1344shake", frodo1344shake), -ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, der, PrivateKeyInfo), -ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_frodo1344shake", p521_frodo1344shake), -#endif -#ifdef OQS_ENABLE_KEM_kyber_512 -ENCODER_w_structure("kyber512", kyber512, der, PrivateKeyInfo), -ENCODER_w_structure("kyber512", kyber512, pem, PrivateKeyInfo), -ENCODER_w_structure("kyber512", kyber512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("kyber512", kyber512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("kyber512", kyber512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("kyber512", kyber512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("kyber512", kyber512), -ENCODER_w_structure("p256_kyber512", p256_kyber512, der, PrivateKeyInfo), -ENCODER_w_structure("p256_kyber512", p256_kyber512, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_kyber512", p256_kyber512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_kyber512", p256_kyber512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_kyber512", p256_kyber512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_kyber512", p256_kyber512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_kyber512", p256_kyber512), -ENCODER_w_structure("x25519_kyber512", x25519_kyber512, der, PrivateKeyInfo), -ENCODER_w_structure("x25519_kyber512", x25519_kyber512, pem, PrivateKeyInfo), -ENCODER_w_structure("x25519_kyber512", x25519_kyber512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_kyber512", x25519_kyber512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_kyber512", x25519_kyber512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x25519_kyber512", x25519_kyber512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x25519_kyber512", x25519_kyber512), -#endif -#ifdef OQS_ENABLE_KEM_kyber_768 -ENCODER_w_structure("kyber768", kyber768, der, PrivateKeyInfo), -ENCODER_w_structure("kyber768", kyber768, pem, PrivateKeyInfo), -ENCODER_w_structure("kyber768", kyber768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("kyber768", kyber768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("kyber768", kyber768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("kyber768", kyber768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("kyber768", kyber768), -ENCODER_w_structure("p384_kyber768", p384_kyber768, der, PrivateKeyInfo), -ENCODER_w_structure("p384_kyber768", p384_kyber768, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_kyber768", p384_kyber768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_kyber768", p384_kyber768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_kyber768", p384_kyber768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_kyber768", p384_kyber768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_kyber768", p384_kyber768), -ENCODER_w_structure("x448_kyber768", x448_kyber768, der, PrivateKeyInfo), -ENCODER_w_structure("x448_kyber768", x448_kyber768, pem, PrivateKeyInfo), -ENCODER_w_structure("x448_kyber768", x448_kyber768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_kyber768", x448_kyber768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_kyber768", x448_kyber768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x448_kyber768", x448_kyber768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x448_kyber768", x448_kyber768), -ENCODER_w_structure("x25519_kyber768", x25519_kyber768, der, PrivateKeyInfo), -ENCODER_w_structure("x25519_kyber768", x25519_kyber768, pem, PrivateKeyInfo), -ENCODER_w_structure("x25519_kyber768", x25519_kyber768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_kyber768", x25519_kyber768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_kyber768", x25519_kyber768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x25519_kyber768", x25519_kyber768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x25519_kyber768", x25519_kyber768), -ENCODER_w_structure("p256_kyber768", p256_kyber768, der, PrivateKeyInfo), -ENCODER_w_structure("p256_kyber768", p256_kyber768, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_kyber768", p256_kyber768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_kyber768", p256_kyber768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_kyber768", p256_kyber768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_kyber768", p256_kyber768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_kyber768", p256_kyber768), -#endif -#ifdef OQS_ENABLE_KEM_kyber_1024 -ENCODER_w_structure("kyber1024", kyber1024, der, PrivateKeyInfo), -ENCODER_w_structure("kyber1024", kyber1024, pem, PrivateKeyInfo), -ENCODER_w_structure("kyber1024", kyber1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("kyber1024", kyber1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("kyber1024", kyber1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("kyber1024", kyber1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("kyber1024", kyber1024), -ENCODER_w_structure("p521_kyber1024", p521_kyber1024, der, PrivateKeyInfo), -ENCODER_w_structure("p521_kyber1024", p521_kyber1024, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_kyber1024", p521_kyber1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_kyber1024", p521_kyber1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_kyber1024", p521_kyber1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_kyber1024", p521_kyber1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_kyber1024", p521_kyber1024), -#endif -#ifdef OQS_ENABLE_KEM_ml_kem_512 -ENCODER_w_structure("mlkem512", mlkem512, der, PrivateKeyInfo), -ENCODER_w_structure("mlkem512", mlkem512, pem, PrivateKeyInfo), -ENCODER_w_structure("mlkem512", mlkem512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mlkem512", mlkem512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mlkem512", mlkem512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mlkem512", mlkem512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mlkem512", mlkem512), -ENCODER_w_structure("p256_mlkem512", p256_mlkem512, der, PrivateKeyInfo), -ENCODER_w_structure("p256_mlkem512", p256_mlkem512, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_mlkem512", p256_mlkem512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_mlkem512", p256_mlkem512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_mlkem512", p256_mlkem512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_mlkem512", p256_mlkem512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_mlkem512", p256_mlkem512), -ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, der, PrivateKeyInfo), -ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, pem, PrivateKeyInfo), -ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x25519_mlkem512", x25519_mlkem512), -#endif -#ifdef OQS_ENABLE_KEM_ml_kem_768 -ENCODER_w_structure("mlkem768", mlkem768, der, PrivateKeyInfo), -ENCODER_w_structure("mlkem768", mlkem768, pem, PrivateKeyInfo), -ENCODER_w_structure("mlkem768", mlkem768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mlkem768", mlkem768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mlkem768", mlkem768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mlkem768", mlkem768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mlkem768", mlkem768), -ENCODER_w_structure("p384_mlkem768", p384_mlkem768, der, PrivateKeyInfo), -ENCODER_w_structure("p384_mlkem768", p384_mlkem768, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_mlkem768", p384_mlkem768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_mlkem768", p384_mlkem768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_mlkem768", p384_mlkem768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_mlkem768", p384_mlkem768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_mlkem768", p384_mlkem768), -ENCODER_w_structure("x448_mlkem768", x448_mlkem768, der, PrivateKeyInfo), -ENCODER_w_structure("x448_mlkem768", x448_mlkem768, pem, PrivateKeyInfo), -ENCODER_w_structure("x448_mlkem768", x448_mlkem768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_mlkem768", x448_mlkem768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_mlkem768", x448_mlkem768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x448_mlkem768", x448_mlkem768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x448_mlkem768", x448_mlkem768), -ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, der, PrivateKeyInfo), -ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, pem, PrivateKeyInfo), -ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("X25519MLKEM768", X25519MLKEM768), -ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, der, PrivateKeyInfo), -ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, pem, PrivateKeyInfo), -ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, der, SubjectPublicKeyInfo), -ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("SecP256r1MLKEM768", SecP256r1MLKEM768), -#endif -#ifdef OQS_ENABLE_KEM_ml_kem_1024 -ENCODER_w_structure("mlkem1024", mlkem1024, der, PrivateKeyInfo), -ENCODER_w_structure("mlkem1024", mlkem1024, pem, PrivateKeyInfo), -ENCODER_w_structure("mlkem1024", mlkem1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mlkem1024", mlkem1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mlkem1024", mlkem1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mlkem1024", mlkem1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mlkem1024", mlkem1024), -ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, der, PrivateKeyInfo), -ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_mlkem1024", p521_mlkem1024), -ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, der, PrivateKeyInfo), -ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_mlkem1024", p384_mlkem1024), -#endif -#ifdef OQS_ENABLE_KEM_bike_l1 -ENCODER_w_structure("bikel1", bikel1, der, PrivateKeyInfo), -ENCODER_w_structure("bikel1", bikel1, pem, PrivateKeyInfo), -ENCODER_w_structure("bikel1", bikel1, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("bikel1", bikel1, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("bikel1", bikel1, der, SubjectPublicKeyInfo), -ENCODER_w_structure("bikel1", bikel1, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("bikel1", bikel1), -ENCODER_w_structure("p256_bikel1", p256_bikel1, der, PrivateKeyInfo), -ENCODER_w_structure("p256_bikel1", p256_bikel1, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_bikel1", p256_bikel1, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_bikel1", p256_bikel1, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_bikel1", p256_bikel1, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_bikel1", p256_bikel1, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_bikel1", p256_bikel1), -ENCODER_w_structure("x25519_bikel1", x25519_bikel1, der, PrivateKeyInfo), -ENCODER_w_structure("x25519_bikel1", x25519_bikel1, pem, PrivateKeyInfo), -ENCODER_w_structure("x25519_bikel1", x25519_bikel1, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_bikel1", x25519_bikel1, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_bikel1", x25519_bikel1, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x25519_bikel1", x25519_bikel1, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x25519_bikel1", x25519_bikel1), -#endif -#ifdef OQS_ENABLE_KEM_bike_l3 -ENCODER_w_structure("bikel3", bikel3, der, PrivateKeyInfo), -ENCODER_w_structure("bikel3", bikel3, pem, PrivateKeyInfo), -ENCODER_w_structure("bikel3", bikel3, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("bikel3", bikel3, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("bikel3", bikel3, der, SubjectPublicKeyInfo), -ENCODER_w_structure("bikel3", bikel3, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("bikel3", bikel3), -ENCODER_w_structure("p384_bikel3", p384_bikel3, der, PrivateKeyInfo), -ENCODER_w_structure("p384_bikel3", p384_bikel3, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_bikel3", p384_bikel3, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_bikel3", p384_bikel3, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_bikel3", p384_bikel3, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_bikel3", p384_bikel3, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_bikel3", p384_bikel3), -ENCODER_w_structure("x448_bikel3", x448_bikel3, der, PrivateKeyInfo), -ENCODER_w_structure("x448_bikel3", x448_bikel3, pem, PrivateKeyInfo), -ENCODER_w_structure("x448_bikel3", x448_bikel3, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_bikel3", x448_bikel3, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_bikel3", x448_bikel3, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x448_bikel3", x448_bikel3, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x448_bikel3", x448_bikel3), -#endif -#ifdef OQS_ENABLE_KEM_bike_l5 -ENCODER_w_structure("bikel5", bikel5, der, PrivateKeyInfo), -ENCODER_w_structure("bikel5", bikel5, pem, PrivateKeyInfo), -ENCODER_w_structure("bikel5", bikel5, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("bikel5", bikel5, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("bikel5", bikel5, der, SubjectPublicKeyInfo), -ENCODER_w_structure("bikel5", bikel5, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("bikel5", bikel5), -ENCODER_w_structure("p521_bikel5", p521_bikel5, der, PrivateKeyInfo), -ENCODER_w_structure("p521_bikel5", p521_bikel5, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_bikel5", p521_bikel5, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_bikel5", p521_bikel5, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_bikel5", p521_bikel5, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_bikel5", p521_bikel5, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_bikel5", p521_bikel5), -#endif -#ifdef OQS_ENABLE_KEM_hqc_128 -ENCODER_w_structure("hqc128", hqc128, der, PrivateKeyInfo), -ENCODER_w_structure("hqc128", hqc128, pem, PrivateKeyInfo), -ENCODER_w_structure("hqc128", hqc128, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("hqc128", hqc128, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("hqc128", hqc128, der, SubjectPublicKeyInfo), -ENCODER_w_structure("hqc128", hqc128, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("hqc128", hqc128), -ENCODER_w_structure("p256_hqc128", p256_hqc128, der, PrivateKeyInfo), -ENCODER_w_structure("p256_hqc128", p256_hqc128, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_hqc128", p256_hqc128, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_hqc128", p256_hqc128, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_hqc128", p256_hqc128, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_hqc128", p256_hqc128, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_hqc128", p256_hqc128), -ENCODER_w_structure("x25519_hqc128", x25519_hqc128, der, PrivateKeyInfo), -ENCODER_w_structure("x25519_hqc128", x25519_hqc128, pem, PrivateKeyInfo), -ENCODER_w_structure("x25519_hqc128", x25519_hqc128, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_hqc128", x25519_hqc128, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x25519_hqc128", x25519_hqc128, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x25519_hqc128", x25519_hqc128, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x25519_hqc128", x25519_hqc128), -#endif -#ifdef OQS_ENABLE_KEM_hqc_192 -ENCODER_w_structure("hqc192", hqc192, der, PrivateKeyInfo), -ENCODER_w_structure("hqc192", hqc192, pem, PrivateKeyInfo), -ENCODER_w_structure("hqc192", hqc192, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("hqc192", hqc192, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("hqc192", hqc192, der, SubjectPublicKeyInfo), -ENCODER_w_structure("hqc192", hqc192, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("hqc192", hqc192), -ENCODER_w_structure("p384_hqc192", p384_hqc192, der, PrivateKeyInfo), -ENCODER_w_structure("p384_hqc192", p384_hqc192, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_hqc192", p384_hqc192, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_hqc192", p384_hqc192, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_hqc192", p384_hqc192, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_hqc192", p384_hqc192, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_hqc192", p384_hqc192), -ENCODER_w_structure("x448_hqc192", x448_hqc192, der, PrivateKeyInfo), -ENCODER_w_structure("x448_hqc192", x448_hqc192, pem, PrivateKeyInfo), -ENCODER_w_structure("x448_hqc192", x448_hqc192, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_hqc192", x448_hqc192, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("x448_hqc192", x448_hqc192, der, SubjectPublicKeyInfo), -ENCODER_w_structure("x448_hqc192", x448_hqc192, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("x448_hqc192", x448_hqc192), -#endif -#ifdef OQS_ENABLE_KEM_hqc_256 -ENCODER_w_structure("hqc256", hqc256, der, PrivateKeyInfo), -ENCODER_w_structure("hqc256", hqc256, pem, PrivateKeyInfo), -ENCODER_w_structure("hqc256", hqc256, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("hqc256", hqc256, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("hqc256", hqc256, der, SubjectPublicKeyInfo), -ENCODER_w_structure("hqc256", hqc256, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("hqc256", hqc256), -ENCODER_w_structure("p521_hqc256", p521_hqc256, der, PrivateKeyInfo), -ENCODER_w_structure("p521_hqc256", p521_hqc256, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_hqc256", p521_hqc256, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_hqc256", p521_hqc256, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_hqc256", p521_hqc256, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_hqc256", p521_hqc256, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_hqc256", p521_hqc256), -#endif + ENCODER_w_structure("frodo640aes", frodo640aes, pem, PrivateKeyInfo), + ENCODER_w_structure("frodo640aes", frodo640aes, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo640aes", frodo640aes, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo640aes", frodo640aes, der, SubjectPublicKeyInfo), + ENCODER_w_structure("frodo640aes", frodo640aes, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("frodo640aes", frodo640aes), + ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, der, + PrivateKeyInfo), + ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, pem, + PrivateKeyInfo), + ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_frodo640aes", p256_frodo640aes, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_frodo640aes", p256_frodo640aes), + ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, der, + PrivateKeyInfo), + ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, pem, + PrivateKeyInfo), + ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x25519_frodo640aes", x25519_frodo640aes, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x25519_frodo640aes", x25519_frodo640aes), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_640_shake + ENCODER_w_structure("frodo640shake", frodo640shake, der, PrivateKeyInfo), + ENCODER_w_structure("frodo640shake", frodo640shake, pem, PrivateKeyInfo), + ENCODER_w_structure("frodo640shake", frodo640shake, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo640shake", frodo640shake, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo640shake", frodo640shake, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("frodo640shake", frodo640shake, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("frodo640shake", frodo640shake), + ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, der, + PrivateKeyInfo), + ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, pem, + PrivateKeyInfo), + ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_frodo640shake", p256_frodo640shake, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_frodo640shake", p256_frodo640shake), + ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, der, + PrivateKeyInfo), + ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, pem, + PrivateKeyInfo), + ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x25519_frodo640shake", x25519_frodo640shake, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x25519_frodo640shake", x25519_frodo640shake), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_976_aes + ENCODER_w_structure("frodo976aes", frodo976aes, der, PrivateKeyInfo), + ENCODER_w_structure("frodo976aes", frodo976aes, pem, PrivateKeyInfo), + ENCODER_w_structure("frodo976aes", frodo976aes, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo976aes", frodo976aes, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo976aes", frodo976aes, der, SubjectPublicKeyInfo), + ENCODER_w_structure("frodo976aes", frodo976aes, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("frodo976aes", frodo976aes), + ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, der, + PrivateKeyInfo), + ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, pem, + PrivateKeyInfo), + ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p384_frodo976aes", p384_frodo976aes, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p384_frodo976aes", p384_frodo976aes), + ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, der, + PrivateKeyInfo), + ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, pem, + PrivateKeyInfo), + ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x448_frodo976aes", x448_frodo976aes, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x448_frodo976aes", x448_frodo976aes), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_976_shake + ENCODER_w_structure("frodo976shake", frodo976shake, der, PrivateKeyInfo), + ENCODER_w_structure("frodo976shake", frodo976shake, pem, PrivateKeyInfo), + ENCODER_w_structure("frodo976shake", frodo976shake, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo976shake", frodo976shake, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo976shake", frodo976shake, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("frodo976shake", frodo976shake, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("frodo976shake", frodo976shake), + ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, der, + PrivateKeyInfo), + ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, pem, + PrivateKeyInfo), + ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p384_frodo976shake", p384_frodo976shake, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p384_frodo976shake", p384_frodo976shake), + ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, der, + PrivateKeyInfo), + ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, pem, + PrivateKeyInfo), + ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x448_frodo976shake", x448_frodo976shake, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x448_frodo976shake", x448_frodo976shake), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_1344_aes + ENCODER_w_structure("frodo1344aes", frodo1344aes, der, PrivateKeyInfo), + ENCODER_w_structure("frodo1344aes", frodo1344aes, pem, PrivateKeyInfo), + ENCODER_w_structure("frodo1344aes", frodo1344aes, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo1344aes", frodo1344aes, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo1344aes", frodo1344aes, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("frodo1344aes", frodo1344aes, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("frodo1344aes", frodo1344aes), + ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, der, + PrivateKeyInfo), + ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, pem, + PrivateKeyInfo), + ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p521_frodo1344aes", p521_frodo1344aes, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p521_frodo1344aes", p521_frodo1344aes), +# endif +# ifdef OQS_ENABLE_KEM_frodokem_1344_shake + ENCODER_w_structure("frodo1344shake", frodo1344shake, der, PrivateKeyInfo), + ENCODER_w_structure("frodo1344shake", frodo1344shake, pem, PrivateKeyInfo), + ENCODER_w_structure("frodo1344shake", frodo1344shake, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo1344shake", frodo1344shake, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("frodo1344shake", frodo1344shake, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("frodo1344shake", frodo1344shake, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("frodo1344shake", frodo1344shake), + ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, der, + PrivateKeyInfo), + ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, pem, + PrivateKeyInfo), + ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p521_frodo1344shake", p521_frodo1344shake, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p521_frodo1344shake", p521_frodo1344shake), +# endif +# ifdef OQS_ENABLE_KEM_kyber_512 + ENCODER_w_structure("kyber512", kyber512, der, PrivateKeyInfo), + ENCODER_w_structure("kyber512", kyber512, pem, PrivateKeyInfo), + ENCODER_w_structure("kyber512", kyber512, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("kyber512", kyber512, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("kyber512", kyber512, der, SubjectPublicKeyInfo), + ENCODER_w_structure("kyber512", kyber512, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("kyber512", kyber512), + ENCODER_w_structure("p256_kyber512", p256_kyber512, der, PrivateKeyInfo), + ENCODER_w_structure("p256_kyber512", p256_kyber512, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_kyber512", p256_kyber512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_kyber512", p256_kyber512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_kyber512", p256_kyber512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_kyber512", p256_kyber512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_kyber512", p256_kyber512), + ENCODER_w_structure("x25519_kyber512", x25519_kyber512, der, + PrivateKeyInfo), + ENCODER_w_structure("x25519_kyber512", x25519_kyber512, pem, + PrivateKeyInfo), + ENCODER_w_structure("x25519_kyber512", x25519_kyber512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_kyber512", x25519_kyber512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_kyber512", x25519_kyber512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x25519_kyber512", x25519_kyber512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x25519_kyber512", x25519_kyber512), +# endif +# ifdef OQS_ENABLE_KEM_kyber_768 + ENCODER_w_structure("kyber768", kyber768, der, PrivateKeyInfo), + ENCODER_w_structure("kyber768", kyber768, pem, PrivateKeyInfo), + ENCODER_w_structure("kyber768", kyber768, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("kyber768", kyber768, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("kyber768", kyber768, der, SubjectPublicKeyInfo), + ENCODER_w_structure("kyber768", kyber768, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("kyber768", kyber768), + ENCODER_w_structure("p384_kyber768", p384_kyber768, der, PrivateKeyInfo), + ENCODER_w_structure("p384_kyber768", p384_kyber768, pem, PrivateKeyInfo), + ENCODER_w_structure("p384_kyber768", p384_kyber768, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_kyber768", p384_kyber768, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_kyber768", p384_kyber768, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p384_kyber768", p384_kyber768, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p384_kyber768", p384_kyber768), + ENCODER_w_structure("x448_kyber768", x448_kyber768, der, PrivateKeyInfo), + ENCODER_w_structure("x448_kyber768", x448_kyber768, pem, PrivateKeyInfo), + ENCODER_w_structure("x448_kyber768", x448_kyber768, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_kyber768", x448_kyber768, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_kyber768", x448_kyber768, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x448_kyber768", x448_kyber768, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x448_kyber768", x448_kyber768), + ENCODER_w_structure("x25519_kyber768", x25519_kyber768, der, + PrivateKeyInfo), + ENCODER_w_structure("x25519_kyber768", x25519_kyber768, pem, + PrivateKeyInfo), + ENCODER_w_structure("x25519_kyber768", x25519_kyber768, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_kyber768", x25519_kyber768, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_kyber768", x25519_kyber768, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x25519_kyber768", x25519_kyber768, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x25519_kyber768", x25519_kyber768), + ENCODER_w_structure("p256_kyber768", p256_kyber768, der, PrivateKeyInfo), + ENCODER_w_structure("p256_kyber768", p256_kyber768, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_kyber768", p256_kyber768, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_kyber768", p256_kyber768, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_kyber768", p256_kyber768, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_kyber768", p256_kyber768, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_kyber768", p256_kyber768), +# endif +# ifdef OQS_ENABLE_KEM_kyber_1024 + ENCODER_w_structure("kyber1024", kyber1024, der, PrivateKeyInfo), + ENCODER_w_structure("kyber1024", kyber1024, pem, PrivateKeyInfo), + ENCODER_w_structure("kyber1024", kyber1024, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("kyber1024", kyber1024, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("kyber1024", kyber1024, der, SubjectPublicKeyInfo), + ENCODER_w_structure("kyber1024", kyber1024, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("kyber1024", kyber1024), + ENCODER_w_structure("p521_kyber1024", p521_kyber1024, der, PrivateKeyInfo), + ENCODER_w_structure("p521_kyber1024", p521_kyber1024, pem, PrivateKeyInfo), + ENCODER_w_structure("p521_kyber1024", p521_kyber1024, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_kyber1024", p521_kyber1024, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_kyber1024", p521_kyber1024, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p521_kyber1024", p521_kyber1024, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p521_kyber1024", p521_kyber1024), +# endif +# ifdef OQS_ENABLE_KEM_ml_kem_512 + ENCODER_w_structure("mlkem512", mlkem512, der, PrivateKeyInfo), + ENCODER_w_structure("mlkem512", mlkem512, pem, PrivateKeyInfo), + ENCODER_w_structure("mlkem512", mlkem512, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mlkem512", mlkem512, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mlkem512", mlkem512, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mlkem512", mlkem512, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mlkem512", mlkem512), + ENCODER_w_structure("p256_mlkem512", p256_mlkem512, der, PrivateKeyInfo), + ENCODER_w_structure("p256_mlkem512", p256_mlkem512, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_mlkem512", p256_mlkem512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_mlkem512", p256_mlkem512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_mlkem512", p256_mlkem512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_mlkem512", p256_mlkem512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_mlkem512", p256_mlkem512), + ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, der, + PrivateKeyInfo), + ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, pem, + PrivateKeyInfo), + ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x25519_mlkem512", x25519_mlkem512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x25519_mlkem512", x25519_mlkem512), +# endif +# ifdef OQS_ENABLE_KEM_ml_kem_768 + ENCODER_w_structure("mlkem768", mlkem768, der, PrivateKeyInfo), + ENCODER_w_structure("mlkem768", mlkem768, pem, PrivateKeyInfo), + ENCODER_w_structure("mlkem768", mlkem768, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mlkem768", mlkem768, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mlkem768", mlkem768, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mlkem768", mlkem768, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mlkem768", mlkem768), + ENCODER_w_structure("p384_mlkem768", p384_mlkem768, der, PrivateKeyInfo), + ENCODER_w_structure("p384_mlkem768", p384_mlkem768, pem, PrivateKeyInfo), + ENCODER_w_structure("p384_mlkem768", p384_mlkem768, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_mlkem768", p384_mlkem768, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_mlkem768", p384_mlkem768, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p384_mlkem768", p384_mlkem768, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p384_mlkem768", p384_mlkem768), + ENCODER_w_structure("x448_mlkem768", x448_mlkem768, der, PrivateKeyInfo), + ENCODER_w_structure("x448_mlkem768", x448_mlkem768, pem, PrivateKeyInfo), + ENCODER_w_structure("x448_mlkem768", x448_mlkem768, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_mlkem768", x448_mlkem768, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_mlkem768", x448_mlkem768, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x448_mlkem768", x448_mlkem768, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x448_mlkem768", x448_mlkem768), + ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, der, PrivateKeyInfo), + ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, pem, PrivateKeyInfo), + ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("X25519MLKEM768", X25519MLKEM768, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("X25519MLKEM768", X25519MLKEM768), + ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, der, + PrivateKeyInfo), + ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, pem, + PrivateKeyInfo), + ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("SecP256r1MLKEM768", SecP256r1MLKEM768, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("SecP256r1MLKEM768", SecP256r1MLKEM768), +# endif +# ifdef OQS_ENABLE_KEM_ml_kem_1024 + ENCODER_w_structure("mlkem1024", mlkem1024, der, PrivateKeyInfo), + ENCODER_w_structure("mlkem1024", mlkem1024, pem, PrivateKeyInfo), + ENCODER_w_structure("mlkem1024", mlkem1024, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mlkem1024", mlkem1024, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mlkem1024", mlkem1024, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mlkem1024", mlkem1024, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mlkem1024", mlkem1024), + ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, der, PrivateKeyInfo), + ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, pem, PrivateKeyInfo), + ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p521_mlkem1024", p521_mlkem1024, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p521_mlkem1024", p521_mlkem1024), + ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, der, PrivateKeyInfo), + ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, pem, PrivateKeyInfo), + ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p384_mlkem1024", p384_mlkem1024, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p384_mlkem1024", p384_mlkem1024), +# endif +# ifdef OQS_ENABLE_KEM_bike_l1 + ENCODER_w_structure("bikel1", bikel1, der, PrivateKeyInfo), + ENCODER_w_structure("bikel1", bikel1, pem, PrivateKeyInfo), + ENCODER_w_structure("bikel1", bikel1, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("bikel1", bikel1, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("bikel1", bikel1, der, SubjectPublicKeyInfo), + ENCODER_w_structure("bikel1", bikel1, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("bikel1", bikel1), + ENCODER_w_structure("p256_bikel1", p256_bikel1, der, PrivateKeyInfo), + ENCODER_w_structure("p256_bikel1", p256_bikel1, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_bikel1", p256_bikel1, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_bikel1", p256_bikel1, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_bikel1", p256_bikel1, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p256_bikel1", p256_bikel1, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p256_bikel1", p256_bikel1), + ENCODER_w_structure("x25519_bikel1", x25519_bikel1, der, PrivateKeyInfo), + ENCODER_w_structure("x25519_bikel1", x25519_bikel1, pem, PrivateKeyInfo), + ENCODER_w_structure("x25519_bikel1", x25519_bikel1, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_bikel1", x25519_bikel1, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_bikel1", x25519_bikel1, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x25519_bikel1", x25519_bikel1, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x25519_bikel1", x25519_bikel1), +# endif +# ifdef OQS_ENABLE_KEM_bike_l3 + ENCODER_w_structure("bikel3", bikel3, der, PrivateKeyInfo), + ENCODER_w_structure("bikel3", bikel3, pem, PrivateKeyInfo), + ENCODER_w_structure("bikel3", bikel3, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("bikel3", bikel3, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("bikel3", bikel3, der, SubjectPublicKeyInfo), + ENCODER_w_structure("bikel3", bikel3, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("bikel3", bikel3), + ENCODER_w_structure("p384_bikel3", p384_bikel3, der, PrivateKeyInfo), + ENCODER_w_structure("p384_bikel3", p384_bikel3, pem, PrivateKeyInfo), + ENCODER_w_structure("p384_bikel3", p384_bikel3, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_bikel3", p384_bikel3, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_bikel3", p384_bikel3, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p384_bikel3", p384_bikel3, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p384_bikel3", p384_bikel3), + ENCODER_w_structure("x448_bikel3", x448_bikel3, der, PrivateKeyInfo), + ENCODER_w_structure("x448_bikel3", x448_bikel3, pem, PrivateKeyInfo), + ENCODER_w_structure("x448_bikel3", x448_bikel3, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_bikel3", x448_bikel3, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_bikel3", x448_bikel3, der, SubjectPublicKeyInfo), + ENCODER_w_structure("x448_bikel3", x448_bikel3, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("x448_bikel3", x448_bikel3), +# endif +# ifdef OQS_ENABLE_KEM_bike_l5 + ENCODER_w_structure("bikel5", bikel5, der, PrivateKeyInfo), + ENCODER_w_structure("bikel5", bikel5, pem, PrivateKeyInfo), + ENCODER_w_structure("bikel5", bikel5, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("bikel5", bikel5, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("bikel5", bikel5, der, SubjectPublicKeyInfo), + ENCODER_w_structure("bikel5", bikel5, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("bikel5", bikel5), + ENCODER_w_structure("p521_bikel5", p521_bikel5, der, PrivateKeyInfo), + ENCODER_w_structure("p521_bikel5", p521_bikel5, pem, PrivateKeyInfo), + ENCODER_w_structure("p521_bikel5", p521_bikel5, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_bikel5", p521_bikel5, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_bikel5", p521_bikel5, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p521_bikel5", p521_bikel5, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p521_bikel5", p521_bikel5), +# endif +# ifdef OQS_ENABLE_KEM_hqc_128 + ENCODER_w_structure("hqc128", hqc128, der, PrivateKeyInfo), + ENCODER_w_structure("hqc128", hqc128, pem, PrivateKeyInfo), + ENCODER_w_structure("hqc128", hqc128, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("hqc128", hqc128, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("hqc128", hqc128, der, SubjectPublicKeyInfo), + ENCODER_w_structure("hqc128", hqc128, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("hqc128", hqc128), + ENCODER_w_structure("p256_hqc128", p256_hqc128, der, PrivateKeyInfo), + ENCODER_w_structure("p256_hqc128", p256_hqc128, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_hqc128", p256_hqc128, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_hqc128", p256_hqc128, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_hqc128", p256_hqc128, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p256_hqc128", p256_hqc128, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p256_hqc128", p256_hqc128), + ENCODER_w_structure("x25519_hqc128", x25519_hqc128, der, PrivateKeyInfo), + ENCODER_w_structure("x25519_hqc128", x25519_hqc128, pem, PrivateKeyInfo), + ENCODER_w_structure("x25519_hqc128", x25519_hqc128, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_hqc128", x25519_hqc128, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x25519_hqc128", x25519_hqc128, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("x25519_hqc128", x25519_hqc128, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("x25519_hqc128", x25519_hqc128), +# endif +# ifdef OQS_ENABLE_KEM_hqc_192 + ENCODER_w_structure("hqc192", hqc192, der, PrivateKeyInfo), + ENCODER_w_structure("hqc192", hqc192, pem, PrivateKeyInfo), + ENCODER_w_structure("hqc192", hqc192, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("hqc192", hqc192, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("hqc192", hqc192, der, SubjectPublicKeyInfo), + ENCODER_w_structure("hqc192", hqc192, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("hqc192", hqc192), + ENCODER_w_structure("p384_hqc192", p384_hqc192, der, PrivateKeyInfo), + ENCODER_w_structure("p384_hqc192", p384_hqc192, pem, PrivateKeyInfo), + ENCODER_w_structure("p384_hqc192", p384_hqc192, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_hqc192", p384_hqc192, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_hqc192", p384_hqc192, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p384_hqc192", p384_hqc192, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p384_hqc192", p384_hqc192), + ENCODER_w_structure("x448_hqc192", x448_hqc192, der, PrivateKeyInfo), + ENCODER_w_structure("x448_hqc192", x448_hqc192, pem, PrivateKeyInfo), + ENCODER_w_structure("x448_hqc192", x448_hqc192, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_hqc192", x448_hqc192, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("x448_hqc192", x448_hqc192, der, SubjectPublicKeyInfo), + ENCODER_w_structure("x448_hqc192", x448_hqc192, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("x448_hqc192", x448_hqc192), +# endif +# ifdef OQS_ENABLE_KEM_hqc_256 + ENCODER_w_structure("hqc256", hqc256, der, PrivateKeyInfo), + ENCODER_w_structure("hqc256", hqc256, pem, PrivateKeyInfo), + ENCODER_w_structure("hqc256", hqc256, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("hqc256", hqc256, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("hqc256", hqc256, der, SubjectPublicKeyInfo), + ENCODER_w_structure("hqc256", hqc256, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("hqc256", hqc256), + ENCODER_w_structure("p521_hqc256", p521_hqc256, der, PrivateKeyInfo), + ENCODER_w_structure("p521_hqc256", p521_hqc256, pem, PrivateKeyInfo), + ENCODER_w_structure("p521_hqc256", p521_hqc256, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_hqc256", p521_hqc256, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_hqc256", p521_hqc256, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p521_hqc256", p521_hqc256, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p521_hqc256", p521_hqc256), +# endif #endif /* OQS_KEM_ENCODERS */ - #ifdef OQS_ENABLE_SIG_dilithium_2 -ENCODER_w_structure("dilithium2", dilithium2, der, PrivateKeyInfo), -ENCODER_w_structure("dilithium2", dilithium2, pem, PrivateKeyInfo), -ENCODER_w_structure("dilithium2", dilithium2, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("dilithium2", dilithium2, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("dilithium2", dilithium2, der, SubjectPublicKeyInfo), -ENCODER_w_structure("dilithium2", dilithium2, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("dilithium2", dilithium2), -ENCODER_w_structure("p256_dilithium2", p256_dilithium2, der, PrivateKeyInfo), -ENCODER_w_structure("p256_dilithium2", p256_dilithium2, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_dilithium2", p256_dilithium2, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_dilithium2", p256_dilithium2, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_dilithium2", p256_dilithium2, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_dilithium2", p256_dilithium2, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_dilithium2", p256_dilithium2), -ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, der, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, pem, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, der, SubjectPublicKeyInfo), -ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("rsa3072_dilithium2", rsa3072_dilithium2), + ENCODER_w_structure("dilithium2", dilithium2, der, PrivateKeyInfo), + ENCODER_w_structure("dilithium2", dilithium2, pem, PrivateKeyInfo), + ENCODER_w_structure("dilithium2", dilithium2, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("dilithium2", dilithium2, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("dilithium2", dilithium2, der, SubjectPublicKeyInfo), + ENCODER_w_structure("dilithium2", dilithium2, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("dilithium2", dilithium2), + ENCODER_w_structure("p256_dilithium2", p256_dilithium2, der, + PrivateKeyInfo), + ENCODER_w_structure("p256_dilithium2", p256_dilithium2, pem, + PrivateKeyInfo), + ENCODER_w_structure("p256_dilithium2", p256_dilithium2, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_dilithium2", p256_dilithium2, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_dilithium2", p256_dilithium2, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_dilithium2", p256_dilithium2, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_dilithium2", p256_dilithium2), + ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, der, + PrivateKeyInfo), + ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, pem, + PrivateKeyInfo), + ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("rsa3072_dilithium2", rsa3072_dilithium2, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("rsa3072_dilithium2", rsa3072_dilithium2), #endif #ifdef OQS_ENABLE_SIG_dilithium_3 -ENCODER_w_structure("dilithium3", dilithium3, der, PrivateKeyInfo), -ENCODER_w_structure("dilithium3", dilithium3, pem, PrivateKeyInfo), -ENCODER_w_structure("dilithium3", dilithium3, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("dilithium3", dilithium3, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("dilithium3", dilithium3, der, SubjectPublicKeyInfo), -ENCODER_w_structure("dilithium3", dilithium3, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("dilithium3", dilithium3), -ENCODER_w_structure("p384_dilithium3", p384_dilithium3, der, PrivateKeyInfo), -ENCODER_w_structure("p384_dilithium3", p384_dilithium3, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_dilithium3", p384_dilithium3, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_dilithium3", p384_dilithium3, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_dilithium3", p384_dilithium3, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_dilithium3", p384_dilithium3, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_dilithium3", p384_dilithium3), + ENCODER_w_structure("dilithium3", dilithium3, der, PrivateKeyInfo), + ENCODER_w_structure("dilithium3", dilithium3, pem, PrivateKeyInfo), + ENCODER_w_structure("dilithium3", dilithium3, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("dilithium3", dilithium3, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("dilithium3", dilithium3, der, SubjectPublicKeyInfo), + ENCODER_w_structure("dilithium3", dilithium3, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("dilithium3", dilithium3), + ENCODER_w_structure("p384_dilithium3", p384_dilithium3, der, + PrivateKeyInfo), + ENCODER_w_structure("p384_dilithium3", p384_dilithium3, pem, + PrivateKeyInfo), + ENCODER_w_structure("p384_dilithium3", p384_dilithium3, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_dilithium3", p384_dilithium3, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_dilithium3", p384_dilithium3, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p384_dilithium3", p384_dilithium3, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p384_dilithium3", p384_dilithium3), #endif #ifdef OQS_ENABLE_SIG_dilithium_5 -ENCODER_w_structure("dilithium5", dilithium5, der, PrivateKeyInfo), -ENCODER_w_structure("dilithium5", dilithium5, pem, PrivateKeyInfo), -ENCODER_w_structure("dilithium5", dilithium5, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("dilithium5", dilithium5, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("dilithium5", dilithium5, der, SubjectPublicKeyInfo), -ENCODER_w_structure("dilithium5", dilithium5, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("dilithium5", dilithium5), -ENCODER_w_structure("p521_dilithium5", p521_dilithium5, der, PrivateKeyInfo), -ENCODER_w_structure("p521_dilithium5", p521_dilithium5, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_dilithium5", p521_dilithium5, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_dilithium5", p521_dilithium5, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_dilithium5", p521_dilithium5, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_dilithium5", p521_dilithium5, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_dilithium5", p521_dilithium5), + ENCODER_w_structure("dilithium5", dilithium5, der, PrivateKeyInfo), + ENCODER_w_structure("dilithium5", dilithium5, pem, PrivateKeyInfo), + ENCODER_w_structure("dilithium5", dilithium5, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("dilithium5", dilithium5, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("dilithium5", dilithium5, der, SubjectPublicKeyInfo), + ENCODER_w_structure("dilithium5", dilithium5, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("dilithium5", dilithium5), + ENCODER_w_structure("p521_dilithium5", p521_dilithium5, der, + PrivateKeyInfo), + ENCODER_w_structure("p521_dilithium5", p521_dilithium5, pem, + PrivateKeyInfo), + ENCODER_w_structure("p521_dilithium5", p521_dilithium5, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_dilithium5", p521_dilithium5, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_dilithium5", p521_dilithium5, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p521_dilithium5", p521_dilithium5, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p521_dilithium5", p521_dilithium5), #endif #ifdef OQS_ENABLE_SIG_ml_dsa_44 -ENCODER_w_structure("mldsa44", mldsa44, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa44", mldsa44, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa44", mldsa44, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44", mldsa44, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44", mldsa44, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa44", mldsa44, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa44", mldsa44), -ENCODER_w_structure("p256_mldsa44", p256_mldsa44, der, PrivateKeyInfo), -ENCODER_w_structure("p256_mldsa44", p256_mldsa44, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_mldsa44", p256_mldsa44, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_mldsa44", p256_mldsa44, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_mldsa44", p256_mldsa44, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_mldsa44", p256_mldsa44, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_mldsa44", p256_mldsa44), -ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, der, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, pem, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, der, SubjectPublicKeyInfo), -ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("rsa3072_mldsa44", rsa3072_mldsa44), -ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa44_pss2048", mldsa44_pss2048), -ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa44_rsa2048", mldsa44_rsa2048), -ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa44_ed25519", mldsa44_ed25519), -ENCODER_w_structure("mldsa44_p256", mldsa44_p256, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_p256", mldsa44_p256, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_p256", mldsa44_p256, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_p256", mldsa44_p256, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_p256", mldsa44_p256, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa44_p256", mldsa44_p256, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa44_p256", mldsa44_p256), -ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa44_bp256", mldsa44_bp256), + ENCODER_w_structure("mldsa44", mldsa44, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa44", mldsa44, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa44", mldsa44, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44", mldsa44, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44", mldsa44, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa44", mldsa44, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa44", mldsa44), + ENCODER_w_structure("p256_mldsa44", p256_mldsa44, der, PrivateKeyInfo), + ENCODER_w_structure("p256_mldsa44", p256_mldsa44, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_mldsa44", p256_mldsa44, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_mldsa44", p256_mldsa44, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_mldsa44", p256_mldsa44, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_mldsa44", p256_mldsa44, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_mldsa44", p256_mldsa44), + ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, der, + PrivateKeyInfo), + ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, pem, + PrivateKeyInfo), + ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("rsa3072_mldsa44", rsa3072_mldsa44, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("rsa3072_mldsa44", rsa3072_mldsa44), + ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, der, + PrivateKeyInfo), + ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, pem, + PrivateKeyInfo), + ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa44_pss2048", mldsa44_pss2048, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa44_pss2048", mldsa44_pss2048), + ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, der, + PrivateKeyInfo), + ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, pem, + PrivateKeyInfo), + ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa44_rsa2048", mldsa44_rsa2048, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa44_rsa2048", mldsa44_rsa2048), + ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, der, + PrivateKeyInfo), + ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, pem, + PrivateKeyInfo), + ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa44_ed25519", mldsa44_ed25519, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa44_ed25519", mldsa44_ed25519), + ENCODER_w_structure("mldsa44_p256", mldsa44_p256, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa44_p256", mldsa44_p256, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa44_p256", mldsa44_p256, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_p256", mldsa44_p256, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_p256", mldsa44_p256, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa44_p256", mldsa44_p256, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa44_p256", mldsa44_p256), + ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa44_bp256", mldsa44_bp256, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa44_bp256", mldsa44_bp256), #endif #ifdef OQS_ENABLE_SIG_ml_dsa_65 -ENCODER_w_structure("mldsa65", mldsa65, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa65", mldsa65, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa65", mldsa65, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65", mldsa65, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65", mldsa65, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa65", mldsa65, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa65", mldsa65), -ENCODER_w_structure("p384_mldsa65", p384_mldsa65, der, PrivateKeyInfo), -ENCODER_w_structure("p384_mldsa65", p384_mldsa65, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_mldsa65", p384_mldsa65, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_mldsa65", p384_mldsa65, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_mldsa65", p384_mldsa65, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_mldsa65", p384_mldsa65, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_mldsa65", p384_mldsa65), -ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa65_pss3072", mldsa65_pss3072), -ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa65_rsa3072", mldsa65_rsa3072), -ENCODER_w_structure("mldsa65_p256", mldsa65_p256, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_p256", mldsa65_p256, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_p256", mldsa65_p256, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_p256", mldsa65_p256, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_p256", mldsa65_p256, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa65_p256", mldsa65_p256, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa65_p256", mldsa65_p256), -ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa65_bp256", mldsa65_bp256), -ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa65_ed25519", mldsa65_ed25519), + ENCODER_w_structure("mldsa65", mldsa65, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa65", mldsa65, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa65", mldsa65, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65", mldsa65, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65", mldsa65, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa65", mldsa65, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa65", mldsa65), + ENCODER_w_structure("p384_mldsa65", p384_mldsa65, der, PrivateKeyInfo), + ENCODER_w_structure("p384_mldsa65", p384_mldsa65, pem, PrivateKeyInfo), + ENCODER_w_structure("p384_mldsa65", p384_mldsa65, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_mldsa65", p384_mldsa65, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_mldsa65", p384_mldsa65, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p384_mldsa65", p384_mldsa65, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p384_mldsa65", p384_mldsa65), + ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, der, + PrivateKeyInfo), + ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, pem, + PrivateKeyInfo), + ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa65_pss3072", mldsa65_pss3072, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa65_pss3072", mldsa65_pss3072), + ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, der, + PrivateKeyInfo), + ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, pem, + PrivateKeyInfo), + ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa65_rsa3072", mldsa65_rsa3072, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa65_rsa3072", mldsa65_rsa3072), + ENCODER_w_structure("mldsa65_p256", mldsa65_p256, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa65_p256", mldsa65_p256, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa65_p256", mldsa65_p256, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_p256", mldsa65_p256, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_p256", mldsa65_p256, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa65_p256", mldsa65_p256, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa65_p256", mldsa65_p256), + ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa65_bp256", mldsa65_bp256, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa65_bp256", mldsa65_bp256), + ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, der, + PrivateKeyInfo), + ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, pem, + PrivateKeyInfo), + ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa65_ed25519", mldsa65_ed25519, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa65_ed25519", mldsa65_ed25519), #endif #ifdef OQS_ENABLE_SIG_ml_dsa_87 -ENCODER_w_structure("mldsa87", mldsa87, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa87", mldsa87, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa87", mldsa87, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa87", mldsa87, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa87", mldsa87, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa87", mldsa87, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa87", mldsa87), -ENCODER_w_structure("p521_mldsa87", p521_mldsa87, der, PrivateKeyInfo), -ENCODER_w_structure("p521_mldsa87", p521_mldsa87, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_mldsa87", p521_mldsa87, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_mldsa87", p521_mldsa87, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_mldsa87", p521_mldsa87, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_mldsa87", p521_mldsa87, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_mldsa87", p521_mldsa87), -ENCODER_w_structure("mldsa87_p384", mldsa87_p384, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa87_p384", mldsa87_p384, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa87_p384", mldsa87_p384, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa87_p384", mldsa87_p384, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa87_p384", mldsa87_p384, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa87_p384", mldsa87_p384, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa87_p384", mldsa87_p384), -ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa87_bp384", mldsa87_bp384), -ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, der, PrivateKeyInfo), -ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, pem, PrivateKeyInfo), -ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mldsa87_ed448", mldsa87_ed448), + ENCODER_w_structure("mldsa87", mldsa87, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa87", mldsa87, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa87", mldsa87, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa87", mldsa87, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa87", mldsa87, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa87", mldsa87, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa87", mldsa87), + ENCODER_w_structure("p521_mldsa87", p521_mldsa87, der, PrivateKeyInfo), + ENCODER_w_structure("p521_mldsa87", p521_mldsa87, pem, PrivateKeyInfo), + ENCODER_w_structure("p521_mldsa87", p521_mldsa87, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_mldsa87", p521_mldsa87, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_mldsa87", p521_mldsa87, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p521_mldsa87", p521_mldsa87, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p521_mldsa87", p521_mldsa87), + ENCODER_w_structure("mldsa87_p384", mldsa87_p384, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa87_p384", mldsa87_p384, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa87_p384", mldsa87_p384, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa87_p384", mldsa87_p384, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa87_p384", mldsa87_p384, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa87_p384", mldsa87_p384, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa87_p384", mldsa87_p384), + ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa87_bp384", mldsa87_bp384, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa87_bp384", mldsa87_bp384), + ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, der, PrivateKeyInfo), + ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, pem, PrivateKeyInfo), + ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("mldsa87_ed448", mldsa87_ed448, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("mldsa87_ed448", mldsa87_ed448), #endif #ifdef OQS_ENABLE_SIG_falcon_512 -ENCODER_w_structure("falcon512", falcon512, der, PrivateKeyInfo), -ENCODER_w_structure("falcon512", falcon512, pem, PrivateKeyInfo), -ENCODER_w_structure("falcon512", falcon512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("falcon512", falcon512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("falcon512", falcon512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("falcon512", falcon512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("falcon512", falcon512), -ENCODER_w_structure("p256_falcon512", p256_falcon512, der, PrivateKeyInfo), -ENCODER_w_structure("p256_falcon512", p256_falcon512, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_falcon512", p256_falcon512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_falcon512", p256_falcon512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_falcon512", p256_falcon512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_falcon512", p256_falcon512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_falcon512", p256_falcon512), -ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, der, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, pem, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("rsa3072_falcon512", rsa3072_falcon512), + ENCODER_w_structure("falcon512", falcon512, der, PrivateKeyInfo), + ENCODER_w_structure("falcon512", falcon512, pem, PrivateKeyInfo), + ENCODER_w_structure("falcon512", falcon512, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("falcon512", falcon512, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("falcon512", falcon512, der, SubjectPublicKeyInfo), + ENCODER_w_structure("falcon512", falcon512, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("falcon512", falcon512), + ENCODER_w_structure("p256_falcon512", p256_falcon512, der, PrivateKeyInfo), + ENCODER_w_structure("p256_falcon512", p256_falcon512, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_falcon512", p256_falcon512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_falcon512", p256_falcon512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_falcon512", p256_falcon512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_falcon512", p256_falcon512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_falcon512", p256_falcon512), + ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, der, + PrivateKeyInfo), + ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, pem, + PrivateKeyInfo), + ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("rsa3072_falcon512", rsa3072_falcon512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("rsa3072_falcon512", rsa3072_falcon512), #endif #ifdef OQS_ENABLE_SIG_falcon_padded_512 -ENCODER_w_structure("falconpadded512", falconpadded512, der, PrivateKeyInfo), -ENCODER_w_structure("falconpadded512", falconpadded512, pem, PrivateKeyInfo), -ENCODER_w_structure("falconpadded512", falconpadded512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("falconpadded512", falconpadded512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("falconpadded512", falconpadded512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("falconpadded512", falconpadded512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("falconpadded512", falconpadded512), -ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, der, PrivateKeyInfo), -ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_falconpadded512", p256_falconpadded512), -ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, der, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, pem, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, der, SubjectPublicKeyInfo), -ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("rsa3072_falconpadded512", rsa3072_falconpadded512), + ENCODER_w_structure("falconpadded512", falconpadded512, der, + PrivateKeyInfo), + ENCODER_w_structure("falconpadded512", falconpadded512, pem, + PrivateKeyInfo), + ENCODER_w_structure("falconpadded512", falconpadded512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("falconpadded512", falconpadded512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("falconpadded512", falconpadded512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("falconpadded512", falconpadded512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("falconpadded512", falconpadded512), + ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, der, + PrivateKeyInfo), + ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, pem, + PrivateKeyInfo), + ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p256_falconpadded512", p256_falconpadded512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p256_falconpadded512", p256_falconpadded512), + ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, der, + PrivateKeyInfo), + ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, pem, + PrivateKeyInfo), + ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("rsa3072_falconpadded512", rsa3072_falconpadded512, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("rsa3072_falconpadded512", rsa3072_falconpadded512), #endif #ifdef OQS_ENABLE_SIG_falcon_1024 -ENCODER_w_structure("falcon1024", falcon1024, der, PrivateKeyInfo), -ENCODER_w_structure("falcon1024", falcon1024, pem, PrivateKeyInfo), -ENCODER_w_structure("falcon1024", falcon1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("falcon1024", falcon1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("falcon1024", falcon1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("falcon1024", falcon1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("falcon1024", falcon1024), -ENCODER_w_structure("p521_falcon1024", p521_falcon1024, der, PrivateKeyInfo), -ENCODER_w_structure("p521_falcon1024", p521_falcon1024, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_falcon1024", p521_falcon1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_falcon1024", p521_falcon1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_falcon1024", p521_falcon1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_falcon1024", p521_falcon1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_falcon1024", p521_falcon1024), + ENCODER_w_structure("falcon1024", falcon1024, der, PrivateKeyInfo), + ENCODER_w_structure("falcon1024", falcon1024, pem, PrivateKeyInfo), + ENCODER_w_structure("falcon1024", falcon1024, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("falcon1024", falcon1024, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("falcon1024", falcon1024, der, SubjectPublicKeyInfo), + ENCODER_w_structure("falcon1024", falcon1024, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("falcon1024", falcon1024), + ENCODER_w_structure("p521_falcon1024", p521_falcon1024, der, + PrivateKeyInfo), + ENCODER_w_structure("p521_falcon1024", p521_falcon1024, pem, + PrivateKeyInfo), + ENCODER_w_structure("p521_falcon1024", p521_falcon1024, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_falcon1024", p521_falcon1024, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_falcon1024", p521_falcon1024, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p521_falcon1024", p521_falcon1024, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p521_falcon1024", p521_falcon1024), #endif #ifdef OQS_ENABLE_SIG_falcon_padded_1024 -ENCODER_w_structure("falconpadded1024", falconpadded1024, der, PrivateKeyInfo), -ENCODER_w_structure("falconpadded1024", falconpadded1024, pem, PrivateKeyInfo), -ENCODER_w_structure("falconpadded1024", falconpadded1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("falconpadded1024", falconpadded1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("falconpadded1024", falconpadded1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("falconpadded1024", falconpadded1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("falconpadded1024", falconpadded1024), -ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, der, PrivateKeyInfo), -ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_falconpadded1024", p521_falconpadded1024), + ENCODER_w_structure("falconpadded1024", falconpadded1024, der, + PrivateKeyInfo), + ENCODER_w_structure("falconpadded1024", falconpadded1024, pem, + PrivateKeyInfo), + ENCODER_w_structure("falconpadded1024", falconpadded1024, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("falconpadded1024", falconpadded1024, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("falconpadded1024", falconpadded1024, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("falconpadded1024", falconpadded1024, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("falconpadded1024", falconpadded1024), + ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, der, + PrivateKeyInfo), + ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, pem, + PrivateKeyInfo), + ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("p521_falconpadded1024", p521_falconpadded1024, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("p521_falconpadded1024", p521_falconpadded1024), #endif #ifdef OQS_ENABLE_SIG_sphincs_sha2_128f_simple -ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, der, PrivateKeyInfo), -ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, pem, PrivateKeyInfo), -ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("sphincssha2128fsimple", sphincssha2128fsimple), -ENCODER_w_structure("p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, der, PrivateKeyInfo), -ENCODER_w_structure("p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_sphincssha2128fsimple", p256_sphincssha2128fsimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_sphincssha2128fsimple", p256_sphincssha2128fsimple), -ENCODER_w_structure("rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple, der, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple, pem, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("rsa3072_sphincssha2128fsimple", rsa3072_sphincssha2128fsimple), + ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, der, + PrivateKeyInfo), + ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, pem, + PrivateKeyInfo), + ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("sphincssha2128fsimple", sphincssha2128fsimple, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("sphincssha2128fsimple", sphincssha2128fsimple), + ENCODER_w_structure("p256_sphincssha2128fsimple", + p256_sphincssha2128fsimple, der, PrivateKeyInfo), + ENCODER_w_structure("p256_sphincssha2128fsimple", + p256_sphincssha2128fsimple, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_sphincssha2128fsimple", + p256_sphincssha2128fsimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_sphincssha2128fsimple", + p256_sphincssha2128fsimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_sphincssha2128fsimple", + p256_sphincssha2128fsimple, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p256_sphincssha2128fsimple", + p256_sphincssha2128fsimple, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p256_sphincssha2128fsimple", p256_sphincssha2128fsimple), + ENCODER_w_structure("rsa3072_sphincssha2128fsimple", + rsa3072_sphincssha2128fsimple, der, PrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128fsimple", + rsa3072_sphincssha2128fsimple, pem, PrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128fsimple", + rsa3072_sphincssha2128fsimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128fsimple", + rsa3072_sphincssha2128fsimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128fsimple", + rsa3072_sphincssha2128fsimple, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128fsimple", + rsa3072_sphincssha2128fsimple, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("rsa3072_sphincssha2128fsimple", + rsa3072_sphincssha2128fsimple), #endif #ifdef OQS_ENABLE_SIG_sphincs_sha2_128s_simple -ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, der, PrivateKeyInfo), -ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, pem, PrivateKeyInfo), -ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("sphincssha2128ssimple", sphincssha2128ssimple), -ENCODER_w_structure("p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, der, PrivateKeyInfo), -ENCODER_w_structure("p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_sphincssha2128ssimple", p256_sphincssha2128ssimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_sphincssha2128ssimple", p256_sphincssha2128ssimple), -ENCODER_w_structure("rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple, der, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple, pem, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("rsa3072_sphincssha2128ssimple", rsa3072_sphincssha2128ssimple), + ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, der, + PrivateKeyInfo), + ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, pem, + PrivateKeyInfo), + ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("sphincssha2128ssimple", sphincssha2128ssimple, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("sphincssha2128ssimple", sphincssha2128ssimple), + ENCODER_w_structure("p256_sphincssha2128ssimple", + p256_sphincssha2128ssimple, der, PrivateKeyInfo), + ENCODER_w_structure("p256_sphincssha2128ssimple", + p256_sphincssha2128ssimple, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_sphincssha2128ssimple", + p256_sphincssha2128ssimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_sphincssha2128ssimple", + p256_sphincssha2128ssimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_sphincssha2128ssimple", + p256_sphincssha2128ssimple, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p256_sphincssha2128ssimple", + p256_sphincssha2128ssimple, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p256_sphincssha2128ssimple", p256_sphincssha2128ssimple), + ENCODER_w_structure("rsa3072_sphincssha2128ssimple", + rsa3072_sphincssha2128ssimple, der, PrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128ssimple", + rsa3072_sphincssha2128ssimple, pem, PrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128ssimple", + rsa3072_sphincssha2128ssimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128ssimple", + rsa3072_sphincssha2128ssimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128ssimple", + rsa3072_sphincssha2128ssimple, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("rsa3072_sphincssha2128ssimple", + rsa3072_sphincssha2128ssimple, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("rsa3072_sphincssha2128ssimple", + rsa3072_sphincssha2128ssimple), #endif #ifdef OQS_ENABLE_SIG_sphincs_sha2_192f_simple -ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, der, PrivateKeyInfo), -ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, pem, PrivateKeyInfo), -ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("sphincssha2192fsimple", sphincssha2192fsimple), -ENCODER_w_structure("p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, der, PrivateKeyInfo), -ENCODER_w_structure("p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_sphincssha2192fsimple", p384_sphincssha2192fsimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_sphincssha2192fsimple", p384_sphincssha2192fsimple), + ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, der, + PrivateKeyInfo), + ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, pem, + PrivateKeyInfo), + ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("sphincssha2192fsimple", sphincssha2192fsimple, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("sphincssha2192fsimple", sphincssha2192fsimple), + ENCODER_w_structure("p384_sphincssha2192fsimple", + p384_sphincssha2192fsimple, der, PrivateKeyInfo), + ENCODER_w_structure("p384_sphincssha2192fsimple", + p384_sphincssha2192fsimple, pem, PrivateKeyInfo), + ENCODER_w_structure("p384_sphincssha2192fsimple", + p384_sphincssha2192fsimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_sphincssha2192fsimple", + p384_sphincssha2192fsimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_sphincssha2192fsimple", + p384_sphincssha2192fsimple, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p384_sphincssha2192fsimple", + p384_sphincssha2192fsimple, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p384_sphincssha2192fsimple", p384_sphincssha2192fsimple), #endif #ifdef OQS_ENABLE_SIG_sphincs_shake_128f_simple -ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, der, PrivateKeyInfo), -ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, pem, PrivateKeyInfo), -ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("sphincsshake128fsimple", sphincsshake128fsimple), -ENCODER_w_structure("p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, der, PrivateKeyInfo), -ENCODER_w_structure("p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_sphincsshake128fsimple", p256_sphincsshake128fsimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_sphincsshake128fsimple", p256_sphincsshake128fsimple), -ENCODER_w_structure("rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple, der, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple, pem, PrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple, der, SubjectPublicKeyInfo), -ENCODER_w_structure("rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("rsa3072_sphincsshake128fsimple", rsa3072_sphincsshake128fsimple), + ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, der, + PrivateKeyInfo), + ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, pem, + PrivateKeyInfo), + ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("sphincsshake128fsimple", sphincsshake128fsimple, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("sphincsshake128fsimple", sphincsshake128fsimple), + ENCODER_w_structure("p256_sphincsshake128fsimple", + p256_sphincsshake128fsimple, der, PrivateKeyInfo), + ENCODER_w_structure("p256_sphincsshake128fsimple", + p256_sphincsshake128fsimple, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_sphincsshake128fsimple", + p256_sphincsshake128fsimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_sphincsshake128fsimple", + p256_sphincsshake128fsimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_sphincsshake128fsimple", + p256_sphincsshake128fsimple, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p256_sphincsshake128fsimple", + p256_sphincsshake128fsimple, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p256_sphincsshake128fsimple", p256_sphincsshake128fsimple), + ENCODER_w_structure("rsa3072_sphincsshake128fsimple", + rsa3072_sphincsshake128fsimple, der, PrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincsshake128fsimple", + rsa3072_sphincsshake128fsimple, pem, PrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincsshake128fsimple", + rsa3072_sphincsshake128fsimple, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincsshake128fsimple", + rsa3072_sphincsshake128fsimple, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("rsa3072_sphincsshake128fsimple", + rsa3072_sphincsshake128fsimple, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("rsa3072_sphincsshake128fsimple", + rsa3072_sphincsshake128fsimple, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("rsa3072_sphincsshake128fsimple", + rsa3072_sphincsshake128fsimple), #endif #ifdef OQS_ENABLE_SIG_mayo_1 -ENCODER_w_structure("mayo1", mayo1, der, PrivateKeyInfo), -ENCODER_w_structure("mayo1", mayo1, pem, PrivateKeyInfo), -ENCODER_w_structure("mayo1", mayo1, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mayo1", mayo1, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mayo1", mayo1, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mayo1", mayo1, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mayo1", mayo1), -ENCODER_w_structure("p256_mayo1", p256_mayo1, der, PrivateKeyInfo), -ENCODER_w_structure("p256_mayo1", p256_mayo1, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_mayo1", p256_mayo1, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_mayo1", p256_mayo1, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_mayo1", p256_mayo1, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_mayo1", p256_mayo1, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_mayo1", p256_mayo1), + ENCODER_w_structure("mayo1", mayo1, der, PrivateKeyInfo), + ENCODER_w_structure("mayo1", mayo1, pem, PrivateKeyInfo), + ENCODER_w_structure("mayo1", mayo1, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mayo1", mayo1, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mayo1", mayo1, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mayo1", mayo1, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mayo1", mayo1), + ENCODER_w_structure("p256_mayo1", p256_mayo1, der, PrivateKeyInfo), + ENCODER_w_structure("p256_mayo1", p256_mayo1, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_mayo1", p256_mayo1, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_mayo1", p256_mayo1, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_mayo1", p256_mayo1, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p256_mayo1", p256_mayo1, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p256_mayo1", p256_mayo1), #endif #ifdef OQS_ENABLE_SIG_mayo_2 -ENCODER_w_structure("mayo2", mayo2, der, PrivateKeyInfo), -ENCODER_w_structure("mayo2", mayo2, pem, PrivateKeyInfo), -ENCODER_w_structure("mayo2", mayo2, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mayo2", mayo2, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mayo2", mayo2, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mayo2", mayo2, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mayo2", mayo2), -ENCODER_w_structure("p256_mayo2", p256_mayo2, der, PrivateKeyInfo), -ENCODER_w_structure("p256_mayo2", p256_mayo2, pem, PrivateKeyInfo), -ENCODER_w_structure("p256_mayo2", p256_mayo2, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_mayo2", p256_mayo2, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p256_mayo2", p256_mayo2, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p256_mayo2", p256_mayo2, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p256_mayo2", p256_mayo2), + ENCODER_w_structure("mayo2", mayo2, der, PrivateKeyInfo), + ENCODER_w_structure("mayo2", mayo2, pem, PrivateKeyInfo), + ENCODER_w_structure("mayo2", mayo2, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mayo2", mayo2, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mayo2", mayo2, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mayo2", mayo2, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mayo2", mayo2), + ENCODER_w_structure("p256_mayo2", p256_mayo2, der, PrivateKeyInfo), + ENCODER_w_structure("p256_mayo2", p256_mayo2, pem, PrivateKeyInfo), + ENCODER_w_structure("p256_mayo2", p256_mayo2, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_mayo2", p256_mayo2, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("p256_mayo2", p256_mayo2, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p256_mayo2", p256_mayo2, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p256_mayo2", p256_mayo2), #endif #ifdef OQS_ENABLE_SIG_mayo_3 -ENCODER_w_structure("mayo3", mayo3, der, PrivateKeyInfo), -ENCODER_w_structure("mayo3", mayo3, pem, PrivateKeyInfo), -ENCODER_w_structure("mayo3", mayo3, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mayo3", mayo3, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mayo3", mayo3, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mayo3", mayo3, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mayo3", mayo3), -ENCODER_w_structure("p384_mayo3", p384_mayo3, der, PrivateKeyInfo), -ENCODER_w_structure("p384_mayo3", p384_mayo3, pem, PrivateKeyInfo), -ENCODER_w_structure("p384_mayo3", p384_mayo3, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_mayo3", p384_mayo3, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p384_mayo3", p384_mayo3, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p384_mayo3", p384_mayo3, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p384_mayo3", p384_mayo3), + ENCODER_w_structure("mayo3", mayo3, der, PrivateKeyInfo), + ENCODER_w_structure("mayo3", mayo3, pem, PrivateKeyInfo), + ENCODER_w_structure("mayo3", mayo3, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mayo3", mayo3, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mayo3", mayo3, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mayo3", mayo3, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mayo3", mayo3), + ENCODER_w_structure("p384_mayo3", p384_mayo3, der, PrivateKeyInfo), + ENCODER_w_structure("p384_mayo3", p384_mayo3, pem, PrivateKeyInfo), + ENCODER_w_structure("p384_mayo3", p384_mayo3, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_mayo3", p384_mayo3, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("p384_mayo3", p384_mayo3, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p384_mayo3", p384_mayo3, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p384_mayo3", p384_mayo3), #endif #ifdef OQS_ENABLE_SIG_mayo_5 -ENCODER_w_structure("mayo5", mayo5, der, PrivateKeyInfo), -ENCODER_w_structure("mayo5", mayo5, pem, PrivateKeyInfo), -ENCODER_w_structure("mayo5", mayo5, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mayo5", mayo5, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("mayo5", mayo5, der, SubjectPublicKeyInfo), -ENCODER_w_structure("mayo5", mayo5, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("mayo5", mayo5), -ENCODER_w_structure("p521_mayo5", p521_mayo5, der, PrivateKeyInfo), -ENCODER_w_structure("p521_mayo5", p521_mayo5, pem, PrivateKeyInfo), -ENCODER_w_structure("p521_mayo5", p521_mayo5, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_mayo5", p521_mayo5, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("p521_mayo5", p521_mayo5, der, SubjectPublicKeyInfo), -ENCODER_w_structure("p521_mayo5", p521_mayo5, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("p521_mayo5", p521_mayo5), + ENCODER_w_structure("mayo5", mayo5, der, PrivateKeyInfo), + ENCODER_w_structure("mayo5", mayo5, pem, PrivateKeyInfo), + ENCODER_w_structure("mayo5", mayo5, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mayo5", mayo5, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("mayo5", mayo5, der, SubjectPublicKeyInfo), + ENCODER_w_structure("mayo5", mayo5, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("mayo5", mayo5), + ENCODER_w_structure("p521_mayo5", p521_mayo5, der, PrivateKeyInfo), + ENCODER_w_structure("p521_mayo5", p521_mayo5, pem, PrivateKeyInfo), + ENCODER_w_structure("p521_mayo5", p521_mayo5, der, EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_mayo5", p521_mayo5, pem, EncryptedPrivateKeyInfo), + ENCODER_w_structure("p521_mayo5", p521_mayo5, der, SubjectPublicKeyInfo), + ENCODER_w_structure("p521_mayo5", p521_mayo5, pem, SubjectPublicKeyInfo), + ENCODER_TEXT("p521_mayo5", p521_mayo5), #endif #ifdef OQS_ENABLE_SIG_cross_rsdp_128_balanced -ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, der, PrivateKeyInfo), -ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, pem, PrivateKeyInfo), -ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, der, EncryptedPrivateKeyInfo), -ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, pem, EncryptedPrivateKeyInfo), -ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, der, SubjectPublicKeyInfo), -ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, pem, SubjectPublicKeyInfo), -ENCODER_TEXT("CROSSrsdp128balanced", CROSSrsdp128balanced), + ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, der, + PrivateKeyInfo), + ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, pem, + PrivateKeyInfo), + ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, der, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, pem, + EncryptedPrivateKeyInfo), + ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, der, + SubjectPublicKeyInfo), + ENCODER_w_structure("CROSSrsdp128balanced", CROSSrsdp128balanced, pem, + SubjectPublicKeyInfo), + ENCODER_TEXT("CROSSrsdp128balanced", CROSSrsdp128balanced), #endif -///// OQS_TEMPLATE_FRAGMENT_MAKE_END + ///// OQS_TEMPLATE_FRAGMENT_MAKE_END diff --git a/oqsprov/oqsprov.c b/oqsprov/oqsprov.c index 39890ba3..202dc50b 100644 --- a/oqsprov/oqsprov.c +++ b/oqsprov/oqsprov.c @@ -21,19 +21,19 @@ #include "oqs_prov.h" #ifdef NDEBUG -#define OQS_PROV_PRINTF(a) -#define OQS_PROV_PRINTF2(a, b) -#define OQS_PROV_PRINTF3(a, b, c) +# define OQS_PROV_PRINTF(a) +# define OQS_PROV_PRINTF2(a, b) +# define OQS_PROV_PRINTF3(a, b, c) #else -#define OQS_PROV_PRINTF(a) \ - if (getenv("OQSPROV")) \ - printf(a) -#define OQS_PROV_PRINTF2(a, b) \ - if (getenv("OQSPROV")) \ - printf(a, b) -#define OQS_PROV_PRINTF3(a, b, c) \ - if (getenv("OQSPROV")) \ - printf(a, b, c) +# define OQS_PROV_PRINTF(a) \ + if (getenv("OQSPROV")) \ + printf(a) +# define OQS_PROV_PRINTF2(a, b) \ + if (getenv("OQSPROV")) \ + printf(a, b) +# define OQS_PROV_PRINTF3(a, b, c) \ + if (getenv("OQSPROV")) \ + printf(a, b, c) #endif // NDEBUG /* @@ -51,9 +51,9 @@ extern OSSL_FUNC_provider_get_capabilities_fn oqs_provider_get_capabilities; ///// OQS_TEMPLATE_FRAGMENT_ASSIGN_SIG_OIDS_START #ifdef OQS_KEM_ENCODERS -#define OQS_OID_CNT 220 +# define OQS_OID_CNT 220 #else -#define OQS_OID_CNT 114 +# define OQS_OID_CNT 114 #endif const char *oqs_oid_alg_list[OQS_OID_CNT] = { @@ -123,9 +123,9 @@ const char *oqs_oid_alg_list[OQS_OID_CNT] = { NULL, "x448_mlkem768", NULL, - "X25519MLKEM768", + "x25519_mlkem768", NULL, - "SecP256r1MLKEM768", + "p256_mlkem768", "2.16.840.1.101.3.4.4.3", "mlkem1024", NULL, @@ -284,7 +284,8 @@ const char *oqs_oid_alg_list[OQS_OID_CNT] = { ///// OQS_TEMPLATE_FRAGMENT_ASSIGN_SIG_OIDS_END }; -int oqs_patch_oids(void) { +int oqs_patch_oids(void) +{ ///// OQS_TEMPLATE_FRAGMENT_OID_PATCHING_START { const char *envval = NULL; @@ -416,9 +417,9 @@ int oqs_patch_oids(void) { if ((envval = getenv("OQS_OID_P521_HQC256"))) oqs_oid_alg_list[104] = envval; -#define OQS_KEMOID_CNT 104 + 2 +# define OQS_KEMOID_CNT 104 + 2 #else -#define OQS_KEMOID_CNT 0 +# define OQS_KEMOID_CNT 0 #endif /* OQS_KEM_ENCODERS */ if ((envval = getenv("OQS_OID_DILITHIUM2"))) oqs_oid_alg_list[0 + OQS_KEMOID_CNT] = envval; @@ -538,29 +539,29 @@ int oqs_patch_oids(void) { return 1; } -#define SIGALG(NAMES, SECBITS, FUNC) \ - { \ - NAMES, "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ - FUNC \ +#define SIGALG(NAMES, SECBITS, FUNC) \ + { \ + NAMES, "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ + FUNC \ } -#define KEMBASEALG(NAMES, SECBITS) \ - {"" #NAMES "", \ - "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ +#define KEMBASEALG(NAMES, SECBITS) \ + {"" #NAMES "", \ + "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ oqs_generic_kem_functions}, -#define KEMHYBALG(NAMES, SECBITS) \ - {"" #NAMES "", \ - "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ +#define KEMHYBALG(NAMES, SECBITS) \ + {"" #NAMES "", \ + "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ oqs_hybrid_kem_functions}, -#define KEMKMALG(NAMES, SECBITS) \ - {"" #NAMES "", \ - "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ +#define KEMKMALG(NAMES, SECBITS) \ + {"" #NAMES "", \ + "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ oqs_##NAMES##_keymgmt_functions}, -#define KEMKMHYBALG(NAMES, SECBITS, HYBTYPE) \ - {"" #NAMES "", \ - "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ +#define KEMKMHYBALG(NAMES, SECBITS, HYBTYPE) \ + {"" #NAMES "", \ + "provider=oqsprovider,oqsprovider.security_bits=" #SECBITS "", \ oqs_##HYBTYPE##_##NAMES##_keymgmt_functions}, /* Functions provided by the core */ @@ -568,12 +569,12 @@ static OSSL_FUNC_core_gettable_params_fn *c_gettable_params = NULL; static OSSL_FUNC_core_get_params_fn *c_get_params = NULL; /* Parameters we provide to the core */ -static const OSSL_PARAM oqsprovider_param_types[] = { - OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0), - OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0), - OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0), - OSSL_PARAM_DEFN(OSSL_PROV_PARAM_STATUS, OSSL_PARAM_INTEGER, NULL, 0), - OSSL_PARAM_END}; +static const OSSL_PARAM oqsprovider_param_types[] + = {OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0), + OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0), + OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0), + OSSL_PARAM_DEFN(OSSL_PROV_PARAM_STATUS, OSSL_PARAM_INTEGER, NULL, 0), + OSSL_PARAM_END}; static const OSSL_ALGORITHM oqsprovider_signatures[] = { ///// OQS_TEMPLATE_FRAGMENT_SIG_FUNCTIONS_START @@ -997,7 +998,8 @@ static const OSSL_ALGORITHM oqsprovider_decoder[] = { }; // get the last number on the composite OID -int get_composite_idx(int idx) { +int get_composite_idx(int idx) +{ char *s; int i, len, ret = -1, count = 0; @@ -1021,23 +1023,25 @@ int get_composite_idx(int idx) { return ret; } -static const OSSL_PARAM *oqsprovider_gettable_params(void *provctx) { +static const OSSL_PARAM *oqsprovider_gettable_params(void *provctx) +{ return oqsprovider_param_types; } -#define OQS_PROVIDER_BASE_BUILD_INFO_STR \ - "OQS Provider v." OQS_PROVIDER_VERSION_STR OQS_PROVIDER_COMMIT \ +#define OQS_PROVIDER_BASE_BUILD_INFO_STR \ + "OQS Provider v." OQS_PROVIDER_VERSION_STR OQS_PROVIDER_COMMIT \ " based on liboqs v." OQS_VERSION_TEXT #ifdef QSC_ENCODING_VERSION_STRING -#define OQS_PROVIDER_BUILD_INFO_STR \ - OQS_PROVIDER_BASE_BUILD_INFO_STR \ - " using qsc-key-encoder v." QSC_ENCODING_VERSION_STRING +# define OQS_PROVIDER_BUILD_INFO_STR \ + OQS_PROVIDER_BASE_BUILD_INFO_STR \ + " using qsc-key-encoder v." QSC_ENCODING_VERSION_STRING #else -#define OQS_PROVIDER_BUILD_INFO_STR OQS_PROVIDER_BASE_BUILD_INFO_STR +# define OQS_PROVIDER_BUILD_INFO_STR OQS_PROVIDER_BASE_BUILD_INFO_STR #endif -static int oqsprovider_get_params(void *provctx, OSSL_PARAM params[]) { +static int oqsprovider_get_params(void *provctx, OSSL_PARAM params[]) +{ OSSL_PARAM *p; p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME); @@ -1057,7 +1061,8 @@ static int oqsprovider_get_params(void *provctx, OSSL_PARAM params[]) { } static const OSSL_ALGORITHM *oqsprovider_query(void *provctx, int operation_id, - int *no_cache) { + int *no_cache) +{ *no_cache = 0; switch (operation_id) { @@ -1079,31 +1084,33 @@ static const OSSL_ALGORITHM *oqsprovider_query(void *provctx, int operation_id, return NULL; } -static void oqsprovider_teardown(void *provctx) { +static void oqsprovider_teardown(void *provctx) +{ oqsx_freeprovctx((PROV_OQS_CTX *)provctx); OQS_destroy(); } /* Functions we provide to the core */ -static const OSSL_DISPATCH oqsprovider_dispatch_table[] = { - {OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))oqsprovider_teardown}, - {OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, - (void (*)(void))oqsprovider_gettable_params}, - {OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))oqsprovider_get_params}, - {OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))oqsprovider_query}, - {OSSL_FUNC_PROVIDER_GET_CAPABILITIES, - (void (*)(void))oqs_provider_get_capabilities}, - {0, NULL}}; +static const OSSL_DISPATCH oqsprovider_dispatch_table[] + = {{OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))oqsprovider_teardown}, + {OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, + (void (*)(void))oqsprovider_gettable_params}, + {OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))oqsprovider_get_params}, + {OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))oqsprovider_query}, + {OSSL_FUNC_PROVIDER_GET_CAPABILITIES, + (void (*)(void))oqs_provider_get_capabilities}, + {0, NULL}}; #ifdef OQS_PROVIDER_STATIC -#define OQS_PROVIDER_ENTRYPOINT_NAME oqs_provider_init +# define OQS_PROVIDER_ENTRYPOINT_NAME oqs_provider_init #else -#define OQS_PROVIDER_ENTRYPOINT_NAME OSSL_provider_init +# define OQS_PROVIDER_ENTRYPOINT_NAME OSSL_provider_init #endif // ifdef OQS_PROVIDER_STATIC int OQS_PROVIDER_ENTRYPOINT_NAME(const OSSL_CORE_HANDLE *handle, const OSSL_DISPATCH *in, - const OSSL_DISPATCH **out, void **provctx) { + const OSSL_DISPATCH **out, void **provctx) +{ const OSSL_DISPATCH *orig_in = in; OSSL_FUNC_core_obj_create_fn *c_obj_create = NULL; @@ -1217,9 +1224,10 @@ int OQS_PROVIDER_ENTRYPOINT_NAME(const OSSL_CORE_HANDLE *handle, } // if libctx not yet existing, create a new one - if (((corebiometh = oqs_bio_prov_init_bio_method()) == NULL) || - ((libctx = OSSL_LIB_CTX_new_child(handle, orig_in)) == NULL) || - ((*provctx = oqsx_newprovctx(libctx, handle, corebiometh)) == NULL)) { + if (((corebiometh = oqs_bio_prov_init_bio_method()) == NULL) + || ((libctx = OSSL_LIB_CTX_new_child(handle, orig_in)) == NULL) + || ((*provctx = oqsx_newprovctx(libctx, handle, corebiometh)) + == NULL)) { OQS_PROV_PRINTF("OQS PROV: error creating new provider context\n"); ERR_raise(ERR_LIB_USER, OQSPROV_R_LIB_CREATE_ERR); goto end_init; @@ -1228,8 +1236,8 @@ int OQS_PROVIDER_ENTRYPOINT_NAME(const OSSL_CORE_HANDLE *handle, *out = oqsprovider_dispatch_table; // finally, warn if neither default nor fips provider are present: - if (!OSSL_PROVIDER_available(libctx, "default") && - !OSSL_PROVIDER_available(libctx, "fips")) { + if (!OSSL_PROVIDER_available(libctx, "default") + && !OSSL_PROVIDER_available(libctx, "fips")) { OQS_PROV_PRINTF( "OQS PROV: Default and FIPS provider not available. Errors " "may result.\n"); diff --git a/oqsprov/oqsprov_bio.c b/oqsprov/oqsprov_bio.c index eca0591a..596abd99 100644 --- a/oqsprov/oqsprov_bio.c +++ b/oqsprov/oqsprov_bio.c @@ -18,7 +18,8 @@ static OSSL_FUNC_BIO_up_ref_fn *c_bio_up_ref = NULL; static OSSL_FUNC_BIO_free_fn *c_bio_free = NULL; static OSSL_FUNC_BIO_vprintf_fn *c_bio_vprintf = NULL; -int oqs_prov_bio_from_dispatch(const OSSL_DISPATCH *fns) { +int oqs_prov_bio_from_dispatch(const OSSL_DISPATCH *fns) +{ for (; fns->function_id != 0; fns++) { switch (fns->function_id) { case OSSL_FUNC_BIO_NEW_FILE: @@ -67,69 +68,80 @@ int oqs_prov_bio_from_dispatch(const OSSL_DISPATCH *fns) { return 1; } -OSSL_CORE_BIO *oqs_prov_bio_new_file(const char *filename, const char *mode) { +OSSL_CORE_BIO *oqs_prov_bio_new_file(const char *filename, const char *mode) +{ if (c_bio_new_file == NULL) return NULL; return c_bio_new_file(filename, mode); } -OSSL_CORE_BIO *oqs_prov_bio_new_membuf(const char *filename, int len) { +OSSL_CORE_BIO *oqs_prov_bio_new_membuf(const char *filename, int len) +{ if (c_bio_new_membuf == NULL) return NULL; return c_bio_new_membuf(filename, len); } int oqs_prov_bio_read_ex(OSSL_CORE_BIO *bio, void *data, size_t data_len, - size_t *bytes_read) { + size_t *bytes_read) +{ if (c_bio_read_ex == NULL) return 0; return c_bio_read_ex(bio, data, data_len, bytes_read); } int oqs_prov_bio_write_ex(OSSL_CORE_BIO *bio, const void *data, size_t data_len, - size_t *written) { + size_t *written) +{ if (c_bio_write_ex == NULL) return 0; return c_bio_write_ex(bio, data, data_len, written); } -int oqs_prov_bio_gets(OSSL_CORE_BIO *bio, char *buf, int size) { +int oqs_prov_bio_gets(OSSL_CORE_BIO *bio, char *buf, int size) +{ if (c_bio_gets == NULL) return -1; return c_bio_gets(bio, buf, size); } -int oqs_prov_bio_puts(OSSL_CORE_BIO *bio, const char *str) { +int oqs_prov_bio_puts(OSSL_CORE_BIO *bio, const char *str) +{ if (c_bio_puts == NULL) return -1; return c_bio_puts(bio, str); } -int oqs_prov_bio_ctrl(OSSL_CORE_BIO *bio, int cmd, long num, void *ptr) { +int oqs_prov_bio_ctrl(OSSL_CORE_BIO *bio, int cmd, long num, void *ptr) +{ if (c_bio_ctrl == NULL) return -1; return c_bio_ctrl(bio, cmd, num, ptr); } -int oqs_prov_bio_up_ref(OSSL_CORE_BIO *bio) { +int oqs_prov_bio_up_ref(OSSL_CORE_BIO *bio) +{ if (c_bio_up_ref == NULL) return 0; return c_bio_up_ref(bio); } -int oqs_prov_bio_free(OSSL_CORE_BIO *bio) { +int oqs_prov_bio_free(OSSL_CORE_BIO *bio) +{ if (c_bio_free == NULL) return 0; return c_bio_free(bio); } -int oqs_prov_bio_vprintf(OSSL_CORE_BIO *bio, const char *format, va_list ap) { +int oqs_prov_bio_vprintf(OSSL_CORE_BIO *bio, const char *format, va_list ap) +{ if (c_bio_vprintf == NULL) return -1; return c_bio_vprintf(bio, format, ap); } -int oqs_prov_bio_printf(OSSL_CORE_BIO *bio, const char *format, ...) { +int oqs_prov_bio_printf(OSSL_CORE_BIO *bio, const char *format, ...) +{ va_list ap; int ret; @@ -145,52 +157,60 @@ int oqs_prov_bio_printf(OSSL_CORE_BIO *bio, const char *format, ...) { /* No direct BIO support in the FIPS module */ static int bio_core_read_ex(BIO *bio, char *data, size_t data_len, - size_t *bytes_read) { + size_t *bytes_read) +{ return oqs_prov_bio_read_ex(BIO_get_data(bio), data, data_len, bytes_read); } static int bio_core_write_ex(BIO *bio, const char *data, size_t data_len, - size_t *written) { + size_t *written) +{ return oqs_prov_bio_write_ex(BIO_get_data(bio), data, data_len, written); } -static long bio_core_ctrl(BIO *bio, int cmd, long num, void *ptr) { +static long bio_core_ctrl(BIO *bio, int cmd, long num, void *ptr) +{ return oqs_prov_bio_ctrl(BIO_get_data(bio), cmd, num, ptr); } -static int bio_core_gets(BIO *bio, char *buf, int size) { +static int bio_core_gets(BIO *bio, char *buf, int size) +{ return oqs_prov_bio_gets(BIO_get_data(bio), buf, size); } -static int bio_core_puts(BIO *bio, const char *str) { +static int bio_core_puts(BIO *bio, const char *str) +{ return oqs_prov_bio_puts(BIO_get_data(bio), str); } -static int bio_core_new(BIO *bio) { +static int bio_core_new(BIO *bio) +{ BIO_set_init(bio, 1); return 1; } -static int bio_core_free(BIO *bio) { +static int bio_core_free(BIO *bio) +{ BIO_set_init(bio, 0); oqs_prov_bio_free(BIO_get_data(bio)); return 1; } -BIO_METHOD *oqs_bio_prov_init_bio_method(void) { +BIO_METHOD *oqs_bio_prov_init_bio_method(void) +{ BIO_METHOD *corebiometh = NULL; corebiometh = BIO_meth_new(BIO_TYPE_CORE_TO_PROV, "BIO to Core filter"); - if (corebiometh == NULL || - !BIO_meth_set_write_ex(corebiometh, bio_core_write_ex) || - !BIO_meth_set_read_ex(corebiometh, bio_core_read_ex) || - !BIO_meth_set_puts(corebiometh, bio_core_puts) || - !BIO_meth_set_gets(corebiometh, bio_core_gets) || - !BIO_meth_set_ctrl(corebiometh, bio_core_ctrl) || - !BIO_meth_set_create(corebiometh, bio_core_new) || - !BIO_meth_set_destroy(corebiometh, bio_core_free)) { + if (corebiometh == NULL + || !BIO_meth_set_write_ex(corebiometh, bio_core_write_ex) + || !BIO_meth_set_read_ex(corebiometh, bio_core_read_ex) + || !BIO_meth_set_puts(corebiometh, bio_core_puts) + || !BIO_meth_set_gets(corebiometh, bio_core_gets) + || !BIO_meth_set_ctrl(corebiometh, bio_core_ctrl) + || !BIO_meth_set_create(corebiometh, bio_core_new) + || !BIO_meth_set_destroy(corebiometh, bio_core_free)) { BIO_meth_free(corebiometh); return NULL; } @@ -198,7 +218,8 @@ BIO_METHOD *oqs_bio_prov_init_bio_method(void) { return corebiometh; } -BIO *oqs_bio_new_from_core_bio(PROV_OQS_CTX *provctx, OSSL_CORE_BIO *corebio) { +BIO *oqs_bio_new_from_core_bio(PROV_OQS_CTX *provctx, OSSL_CORE_BIO *corebio) +{ BIO *outbio; BIO_METHOD *corebiometh = provctx->corebiometh; diff --git a/oqsprov/oqsprov_capabilities.c b/oqsprov/oqsprov_capabilities.c index bf8081e2..5797bd80 100644 --- a/oqsprov/oqsprov_capabilities.c +++ b/oqsprov/oqsprov_capabilities.c @@ -110,29 +110,29 @@ static OQS_GROUP_CONSTANTS oqs_group_list[] = { }; // Adds entries for tlsname, `ecx`_tlsname and `ecp`_tlsname -#define OQS_GROUP_ENTRY(tlsname, realname, algorithm, idx) \ - { \ - OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME, #tlsname, \ - sizeof(#tlsname)), \ - OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL, \ - #realname, sizeof(#realname)), \ - OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_ALG, #algorithm, \ - sizeof(#algorithm)), \ - OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_ID, \ - (unsigned int *)&oqs_group_list[idx].group_id), \ - OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS, \ - (unsigned int *)&oqs_group_list[idx].secbits), \ - OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_TLS, \ - (unsigned int *)&oqs_group_list[idx].mintls), \ - OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_TLS, \ - (unsigned int *)&oqs_group_list[idx].maxtls), \ - OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_DTLS, \ - (unsigned int *)&oqs_group_list[idx].mindtls), \ - OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_DTLS, \ - (unsigned int *)&oqs_group_list[idx].maxdtls), \ - OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_IS_KEM, \ - (unsigned int *)&oqs_group_list[idx].is_kem), \ - OSSL_PARAM_END \ +#define OQS_GROUP_ENTRY(tlsname, realname, algorithm, idx) \ + { \ + OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME, #tlsname, \ + sizeof(#tlsname)), \ + OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_NAME_INTERNAL, \ + #realname, sizeof(#realname)), \ + OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_GROUP_ALG, #algorithm, \ + sizeof(#algorithm)), \ + OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_ID, \ + (unsigned int *)&oqs_group_list[idx].group_id), \ + OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_GROUP_SECURITY_BITS, \ + (unsigned int *)&oqs_group_list[idx].secbits), \ + OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_TLS, \ + (unsigned int *)&oqs_group_list[idx].mintls), \ + OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_TLS, \ + (unsigned int *)&oqs_group_list[idx].maxtls), \ + OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MIN_DTLS, \ + (unsigned int *)&oqs_group_list[idx].mindtls), \ + OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_MAX_DTLS, \ + (unsigned int *)&oqs_group_list[idx].maxdtls), \ + OSSL_PARAM_int(OSSL_CAPABILITY_TLS_GROUP_IS_KEM, \ + (unsigned int *)&oqs_group_list[idx].is_kem), \ + OSSL_PARAM_END \ } static const OSSL_PARAM oqs_param_group_list[][11] = { @@ -298,118 +298,119 @@ static OQS_SIGALG_CONSTANTS oqs_sigalg_list[] = { ///// OQS_TEMPLATE_FRAGMENT_SIGALG_ASSIGNMENTS_END }; -int oqs_patch_codepoints() { +int oqs_patch_codepoints() +{ ///// OQS_TEMPLATE_FRAGMENT_CODEPOINT_PATCHING_START if (getenv("OQS_CODEPOINT_FRODO640AES")) oqs_group_list[0].group_id = atoi(getenv("OQS_CODEPOINT_FRODO640AES")); if (getenv("OQS_CODEPOINT_P256_FRODO640AES")) - oqs_group_list[1].group_id = - atoi(getenv("OQS_CODEPOINT_P256_FRODO640AES")); + oqs_group_list[1].group_id + = atoi(getenv("OQS_CODEPOINT_P256_FRODO640AES")); if (getenv("OQS_CODEPOINT_X25519_FRODO640AES")) - oqs_group_list[2].group_id = - atoi(getenv("OQS_CODEPOINT_X25519_FRODO640AES")); + oqs_group_list[2].group_id + = atoi(getenv("OQS_CODEPOINT_X25519_FRODO640AES")); if (getenv("OQS_CODEPOINT_FRODO640SHAKE")) - oqs_group_list[3].group_id = - atoi(getenv("OQS_CODEPOINT_FRODO640SHAKE")); + oqs_group_list[3].group_id + = atoi(getenv("OQS_CODEPOINT_FRODO640SHAKE")); if (getenv("OQS_CODEPOINT_P256_FRODO640SHAKE")) - oqs_group_list[4].group_id = - atoi(getenv("OQS_CODEPOINT_P256_FRODO640SHAKE")); + oqs_group_list[4].group_id + = atoi(getenv("OQS_CODEPOINT_P256_FRODO640SHAKE")); if (getenv("OQS_CODEPOINT_X25519_FRODO640SHAKE")) - oqs_group_list[5].group_id = - atoi(getenv("OQS_CODEPOINT_X25519_FRODO640SHAKE")); + oqs_group_list[5].group_id + = atoi(getenv("OQS_CODEPOINT_X25519_FRODO640SHAKE")); if (getenv("OQS_CODEPOINT_FRODO976AES")) oqs_group_list[6].group_id = atoi(getenv("OQS_CODEPOINT_FRODO976AES")); if (getenv("OQS_CODEPOINT_P384_FRODO976AES")) - oqs_group_list[7].group_id = - atoi(getenv("OQS_CODEPOINT_P384_FRODO976AES")); + oqs_group_list[7].group_id + = atoi(getenv("OQS_CODEPOINT_P384_FRODO976AES")); if (getenv("OQS_CODEPOINT_X448_FRODO976AES")) - oqs_group_list[8].group_id = - atoi(getenv("OQS_CODEPOINT_X448_FRODO976AES")); + oqs_group_list[8].group_id + = atoi(getenv("OQS_CODEPOINT_X448_FRODO976AES")); if (getenv("OQS_CODEPOINT_FRODO976SHAKE")) - oqs_group_list[9].group_id = - atoi(getenv("OQS_CODEPOINT_FRODO976SHAKE")); + oqs_group_list[9].group_id + = atoi(getenv("OQS_CODEPOINT_FRODO976SHAKE")); if (getenv("OQS_CODEPOINT_P384_FRODO976SHAKE")) - oqs_group_list[10].group_id = - atoi(getenv("OQS_CODEPOINT_P384_FRODO976SHAKE")); + oqs_group_list[10].group_id + = atoi(getenv("OQS_CODEPOINT_P384_FRODO976SHAKE")); if (getenv("OQS_CODEPOINT_X448_FRODO976SHAKE")) - oqs_group_list[11].group_id = - atoi(getenv("OQS_CODEPOINT_X448_FRODO976SHAKE")); + oqs_group_list[11].group_id + = atoi(getenv("OQS_CODEPOINT_X448_FRODO976SHAKE")); if (getenv("OQS_CODEPOINT_FRODO1344AES")) - oqs_group_list[12].group_id = - atoi(getenv("OQS_CODEPOINT_FRODO1344AES")); + oqs_group_list[12].group_id + = atoi(getenv("OQS_CODEPOINT_FRODO1344AES")); if (getenv("OQS_CODEPOINT_P521_FRODO1344AES")) - oqs_group_list[13].group_id = - atoi(getenv("OQS_CODEPOINT_P521_FRODO1344AES")); + oqs_group_list[13].group_id + = atoi(getenv("OQS_CODEPOINT_P521_FRODO1344AES")); if (getenv("OQS_CODEPOINT_FRODO1344SHAKE")) - oqs_group_list[14].group_id = - atoi(getenv("OQS_CODEPOINT_FRODO1344SHAKE")); + oqs_group_list[14].group_id + = atoi(getenv("OQS_CODEPOINT_FRODO1344SHAKE")); if (getenv("OQS_CODEPOINT_P521_FRODO1344SHAKE")) - oqs_group_list[15].group_id = - atoi(getenv("OQS_CODEPOINT_P521_FRODO1344SHAKE")); + oqs_group_list[15].group_id + = atoi(getenv("OQS_CODEPOINT_P521_FRODO1344SHAKE")); if (getenv("OQS_CODEPOINT_KYBER512")) oqs_group_list[16].group_id = atoi(getenv("OQS_CODEPOINT_KYBER512")); if (getenv("OQS_CODEPOINT_P256_KYBER512")) - oqs_group_list[17].group_id = - atoi(getenv("OQS_CODEPOINT_P256_KYBER512")); + oqs_group_list[17].group_id + = atoi(getenv("OQS_CODEPOINT_P256_KYBER512")); if (getenv("OQS_CODEPOINT_X25519_KYBER512")) - oqs_group_list[18].group_id = - atoi(getenv("OQS_CODEPOINT_X25519_KYBER512")); + oqs_group_list[18].group_id + = atoi(getenv("OQS_CODEPOINT_X25519_KYBER512")); if (getenv("OQS_CODEPOINT_KYBER768")) oqs_group_list[19].group_id = atoi(getenv("OQS_CODEPOINT_KYBER768")); if (getenv("OQS_CODEPOINT_P384_KYBER768")) - oqs_group_list[20].group_id = - atoi(getenv("OQS_CODEPOINT_P384_KYBER768")); + oqs_group_list[20].group_id + = atoi(getenv("OQS_CODEPOINT_P384_KYBER768")); if (getenv("OQS_CODEPOINT_X448_KYBER768")) - oqs_group_list[21].group_id = - atoi(getenv("OQS_CODEPOINT_X448_KYBER768")); + oqs_group_list[21].group_id + = atoi(getenv("OQS_CODEPOINT_X448_KYBER768")); if (getenv("OQS_CODEPOINT_X25519_KYBER768")) - oqs_group_list[22].group_id = - atoi(getenv("OQS_CODEPOINT_X25519_KYBER768")); + oqs_group_list[22].group_id + = atoi(getenv("OQS_CODEPOINT_X25519_KYBER768")); if (getenv("OQS_CODEPOINT_P256_KYBER768")) - oqs_group_list[23].group_id = - atoi(getenv("OQS_CODEPOINT_P256_KYBER768")); + oqs_group_list[23].group_id + = atoi(getenv("OQS_CODEPOINT_P256_KYBER768")); if (getenv("OQS_CODEPOINT_KYBER1024")) oqs_group_list[24].group_id = atoi(getenv("OQS_CODEPOINT_KYBER1024")); if (getenv("OQS_CODEPOINT_P521_KYBER1024")) - oqs_group_list[25].group_id = - atoi(getenv("OQS_CODEPOINT_P521_KYBER1024")); + oqs_group_list[25].group_id + = atoi(getenv("OQS_CODEPOINT_P521_KYBER1024")); if (getenv("OQS_CODEPOINT_MLKEM512")) oqs_group_list[26].group_id = atoi(getenv("OQS_CODEPOINT_MLKEM512")); if (getenv("OQS_CODEPOINT_P256_MLKEM512")) - oqs_group_list[27].group_id = - atoi(getenv("OQS_CODEPOINT_P256_MLKEM512")); + oqs_group_list[27].group_id + = atoi(getenv("OQS_CODEPOINT_P256_MLKEM512")); if (getenv("OQS_CODEPOINT_X25519_MLKEM512")) - oqs_group_list[28].group_id = - atoi(getenv("OQS_CODEPOINT_X25519_MLKEM512")); + oqs_group_list[28].group_id + = atoi(getenv("OQS_CODEPOINT_X25519_MLKEM512")); if (getenv("OQS_CODEPOINT_MLKEM768")) oqs_group_list[29].group_id = atoi(getenv("OQS_CODEPOINT_MLKEM768")); if (getenv("OQS_CODEPOINT_P384_MLKEM768")) - oqs_group_list[30].group_id = - atoi(getenv("OQS_CODEPOINT_P384_MLKEM768")); + oqs_group_list[30].group_id + = atoi(getenv("OQS_CODEPOINT_P384_MLKEM768")); if (getenv("OQS_CODEPOINT_X448_MLKEM768")) - oqs_group_list[31].group_id = - atoi(getenv("OQS_CODEPOINT_X448_MLKEM768")); + oqs_group_list[31].group_id + = atoi(getenv("OQS_CODEPOINT_X448_MLKEM768")); if (getenv("OQS_CODEPOINT_X25519MLKEM768")) - oqs_group_list[32].group_id = - atoi(getenv("OQS_CODEPOINT_X25519MLKEM768")); + oqs_group_list[32].group_id + = atoi(getenv("OQS_CODEPOINT_X25519MLKEM768")); if (getenv("OQS_CODEPOINT_SECP256R1MLKEM768")) - oqs_group_list[33].group_id = - atoi(getenv("OQS_CODEPOINT_SECP256R1MLKEM768")); + oqs_group_list[33].group_id + = atoi(getenv("OQS_CODEPOINT_SECP256R1MLKEM768")); if (getenv("OQS_CODEPOINT_MLKEM1024")) oqs_group_list[34].group_id = atoi(getenv("OQS_CODEPOINT_MLKEM1024")); if (getenv("OQS_CODEPOINT_P521_MLKEM1024")) - oqs_group_list[35].group_id = - atoi(getenv("OQS_CODEPOINT_P521_MLKEM1024")); + oqs_group_list[35].group_id + = atoi(getenv("OQS_CODEPOINT_P521_MLKEM1024")); if (getenv("OQS_CODEPOINT_P384_MLKEM1024")) - oqs_group_list[36].group_id = - atoi(getenv("OQS_CODEPOINT_P384_MLKEM1024")); + oqs_group_list[36].group_id + = atoi(getenv("OQS_CODEPOINT_P384_MLKEM1024")); if (getenv("OQS_CODEPOINT_BIKEL1")) oqs_group_list[37].group_id = atoi(getenv("OQS_CODEPOINT_BIKEL1")); if (getenv("OQS_CODEPOINT_P256_BIKEL1")) oqs_group_list[38].group_id = atoi(getenv("OQS_CODEPOINT_P256_BIKEL1")); if (getenv("OQS_CODEPOINT_X25519_BIKEL1")) - oqs_group_list[39].group_id = - atoi(getenv("OQS_CODEPOINT_X25519_BIKEL1")); + oqs_group_list[39].group_id + = atoi(getenv("OQS_CODEPOINT_X25519_BIKEL1")); if (getenv("OQS_CODEPOINT_BIKEL3")) oqs_group_list[40].group_id = atoi(getenv("OQS_CODEPOINT_BIKEL3")); if (getenv("OQS_CODEPOINT_P384_BIKEL3")) @@ -425,8 +426,8 @@ int oqs_patch_codepoints() { if (getenv("OQS_CODEPOINT_P256_HQC128")) oqs_group_list[46].group_id = atoi(getenv("OQS_CODEPOINT_P256_HQC128")); if (getenv("OQS_CODEPOINT_X25519_HQC128")) - oqs_group_list[47].group_id = - atoi(getenv("OQS_CODEPOINT_X25519_HQC128")); + oqs_group_list[47].group_id + = atoi(getenv("OQS_CODEPOINT_X25519_HQC128")); if (getenv("OQS_CODEPOINT_HQC192")) oqs_group_list[48].group_id = atoi(getenv("OQS_CODEPOINT_HQC192")); if (getenv("OQS_CODEPOINT_P384_HQC192")) @@ -439,174 +440,175 @@ int oqs_patch_codepoints() { oqs_group_list[52].group_id = atoi(getenv("OQS_CODEPOINT_P521_HQC256")); if (getenv("OQS_CODEPOINT_DILITHIUM2")) - oqs_sigalg_list[0].code_point = - atoi(getenv("OQS_CODEPOINT_DILITHIUM2")); + oqs_sigalg_list[0].code_point + = atoi(getenv("OQS_CODEPOINT_DILITHIUM2")); if (getenv("OQS_CODEPOINT_P256_DILITHIUM2")) - oqs_sigalg_list[1].code_point = - atoi(getenv("OQS_CODEPOINT_P256_DILITHIUM2")); + oqs_sigalg_list[1].code_point + = atoi(getenv("OQS_CODEPOINT_P256_DILITHIUM2")); if (getenv("OQS_CODEPOINT_RSA3072_DILITHIUM2")) - oqs_sigalg_list[2].code_point = - atoi(getenv("OQS_CODEPOINT_RSA3072_DILITHIUM2")); + oqs_sigalg_list[2].code_point + = atoi(getenv("OQS_CODEPOINT_RSA3072_DILITHIUM2")); if (getenv("OQS_CODEPOINT_DILITHIUM3")) - oqs_sigalg_list[3].code_point = - atoi(getenv("OQS_CODEPOINT_DILITHIUM3")); + oqs_sigalg_list[3].code_point + = atoi(getenv("OQS_CODEPOINT_DILITHIUM3")); if (getenv("OQS_CODEPOINT_P384_DILITHIUM3")) - oqs_sigalg_list[4].code_point = - atoi(getenv("OQS_CODEPOINT_P384_DILITHIUM3")); + oqs_sigalg_list[4].code_point + = atoi(getenv("OQS_CODEPOINT_P384_DILITHIUM3")); if (getenv("OQS_CODEPOINT_DILITHIUM5")) - oqs_sigalg_list[5].code_point = - atoi(getenv("OQS_CODEPOINT_DILITHIUM5")); + oqs_sigalg_list[5].code_point + = atoi(getenv("OQS_CODEPOINT_DILITHIUM5")); if (getenv("OQS_CODEPOINT_P521_DILITHIUM5")) - oqs_sigalg_list[6].code_point = - atoi(getenv("OQS_CODEPOINT_P521_DILITHIUM5")); + oqs_sigalg_list[6].code_point + = atoi(getenv("OQS_CODEPOINT_P521_DILITHIUM5")); if (getenv("OQS_CODEPOINT_MLDSA44")) oqs_sigalg_list[7].code_point = atoi(getenv("OQS_CODEPOINT_MLDSA44")); if (getenv("OQS_CODEPOINT_P256_MLDSA44")) - oqs_sigalg_list[8].code_point = - atoi(getenv("OQS_CODEPOINT_P256_MLDSA44")); + oqs_sigalg_list[8].code_point + = atoi(getenv("OQS_CODEPOINT_P256_MLDSA44")); if (getenv("OQS_CODEPOINT_RSA3072_MLDSA44")) - oqs_sigalg_list[9].code_point = - atoi(getenv("OQS_CODEPOINT_RSA3072_MLDSA44")); + oqs_sigalg_list[9].code_point + = atoi(getenv("OQS_CODEPOINT_RSA3072_MLDSA44")); if (getenv("OQS_CODEPOINT_MLDSA44_PSS2048")) - oqs_sigalg_list[10].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA44_PSS2048")); + oqs_sigalg_list[10].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA44_PSS2048")); if (getenv("OQS_CODEPOINT_MLDSA44_RSA2048")) - oqs_sigalg_list[11].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA44_RSA2048")); + oqs_sigalg_list[11].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA44_RSA2048")); if (getenv("OQS_CODEPOINT_MLDSA44_ED25519")) - oqs_sigalg_list[12].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA44_ED25519")); + oqs_sigalg_list[12].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA44_ED25519")); if (getenv("OQS_CODEPOINT_MLDSA44_P256")) - oqs_sigalg_list[13].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA44_P256")); + oqs_sigalg_list[13].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA44_P256")); if (getenv("OQS_CODEPOINT_MLDSA44_BP256")) - oqs_sigalg_list[14].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA44_BP256")); + oqs_sigalg_list[14].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA44_BP256")); if (getenv("OQS_CODEPOINT_MLDSA65")) oqs_sigalg_list[15].code_point = atoi(getenv("OQS_CODEPOINT_MLDSA65")); if (getenv("OQS_CODEPOINT_P384_MLDSA65")) - oqs_sigalg_list[16].code_point = - atoi(getenv("OQS_CODEPOINT_P384_MLDSA65")); + oqs_sigalg_list[16].code_point + = atoi(getenv("OQS_CODEPOINT_P384_MLDSA65")); if (getenv("OQS_CODEPOINT_MLDSA65_PSS3072")) - oqs_sigalg_list[17].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA65_PSS3072")); + oqs_sigalg_list[17].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA65_PSS3072")); if (getenv("OQS_CODEPOINT_MLDSA65_RSA3072")) - oqs_sigalg_list[18].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA65_RSA3072")); + oqs_sigalg_list[18].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA65_RSA3072")); if (getenv("OQS_CODEPOINT_MLDSA65_P256")) - oqs_sigalg_list[19].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA65_P256")); + oqs_sigalg_list[19].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA65_P256")); if (getenv("OQS_CODEPOINT_MLDSA65_BP256")) - oqs_sigalg_list[20].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA65_BP256")); + oqs_sigalg_list[20].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA65_BP256")); if (getenv("OQS_CODEPOINT_MLDSA65_ED25519")) - oqs_sigalg_list[21].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA65_ED25519")); + oqs_sigalg_list[21].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA65_ED25519")); if (getenv("OQS_CODEPOINT_MLDSA87")) oqs_sigalg_list[22].code_point = atoi(getenv("OQS_CODEPOINT_MLDSA87")); if (getenv("OQS_CODEPOINT_P521_MLDSA87")) - oqs_sigalg_list[23].code_point = - atoi(getenv("OQS_CODEPOINT_P521_MLDSA87")); + oqs_sigalg_list[23].code_point + = atoi(getenv("OQS_CODEPOINT_P521_MLDSA87")); if (getenv("OQS_CODEPOINT_MLDSA87_P384")) - oqs_sigalg_list[24].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA87_P384")); + oqs_sigalg_list[24].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA87_P384")); if (getenv("OQS_CODEPOINT_MLDSA87_BP384")) - oqs_sigalg_list[25].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA87_BP384")); + oqs_sigalg_list[25].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA87_BP384")); if (getenv("OQS_CODEPOINT_MLDSA87_ED448")) - oqs_sigalg_list[26].code_point = - atoi(getenv("OQS_CODEPOINT_MLDSA87_ED448")); + oqs_sigalg_list[26].code_point + = atoi(getenv("OQS_CODEPOINT_MLDSA87_ED448")); if (getenv("OQS_CODEPOINT_FALCON512")) - oqs_sigalg_list[27].code_point = - atoi(getenv("OQS_CODEPOINT_FALCON512")); + oqs_sigalg_list[27].code_point + = atoi(getenv("OQS_CODEPOINT_FALCON512")); if (getenv("OQS_CODEPOINT_P256_FALCON512")) - oqs_sigalg_list[28].code_point = - atoi(getenv("OQS_CODEPOINT_P256_FALCON512")); + oqs_sigalg_list[28].code_point + = atoi(getenv("OQS_CODEPOINT_P256_FALCON512")); if (getenv("OQS_CODEPOINT_RSA3072_FALCON512")) - oqs_sigalg_list[29].code_point = - atoi(getenv("OQS_CODEPOINT_RSA3072_FALCON512")); + oqs_sigalg_list[29].code_point + = atoi(getenv("OQS_CODEPOINT_RSA3072_FALCON512")); if (getenv("OQS_CODEPOINT_FALCONPADDED512")) - oqs_sigalg_list[30].code_point = - atoi(getenv("OQS_CODEPOINT_FALCONPADDED512")); + oqs_sigalg_list[30].code_point + = atoi(getenv("OQS_CODEPOINT_FALCONPADDED512")); if (getenv("OQS_CODEPOINT_P256_FALCONPADDED512")) - oqs_sigalg_list[31].code_point = - atoi(getenv("OQS_CODEPOINT_P256_FALCONPADDED512")); + oqs_sigalg_list[31].code_point + = atoi(getenv("OQS_CODEPOINT_P256_FALCONPADDED512")); if (getenv("OQS_CODEPOINT_RSA3072_FALCONPADDED512")) - oqs_sigalg_list[32].code_point = - atoi(getenv("OQS_CODEPOINT_RSA3072_FALCONPADDED512")); + oqs_sigalg_list[32].code_point + = atoi(getenv("OQS_CODEPOINT_RSA3072_FALCONPADDED512")); if (getenv("OQS_CODEPOINT_FALCON1024")) - oqs_sigalg_list[33].code_point = - atoi(getenv("OQS_CODEPOINT_FALCON1024")); + oqs_sigalg_list[33].code_point + = atoi(getenv("OQS_CODEPOINT_FALCON1024")); if (getenv("OQS_CODEPOINT_P521_FALCON1024")) - oqs_sigalg_list[34].code_point = - atoi(getenv("OQS_CODEPOINT_P521_FALCON1024")); + oqs_sigalg_list[34].code_point + = atoi(getenv("OQS_CODEPOINT_P521_FALCON1024")); if (getenv("OQS_CODEPOINT_FALCONPADDED1024")) - oqs_sigalg_list[35].code_point = - atoi(getenv("OQS_CODEPOINT_FALCONPADDED1024")); + oqs_sigalg_list[35].code_point + = atoi(getenv("OQS_CODEPOINT_FALCONPADDED1024")); if (getenv("OQS_CODEPOINT_P521_FALCONPADDED1024")) - oqs_sigalg_list[36].code_point = - atoi(getenv("OQS_CODEPOINT_P521_FALCONPADDED1024")); + oqs_sigalg_list[36].code_point + = atoi(getenv("OQS_CODEPOINT_P521_FALCONPADDED1024")); if (getenv("OQS_CODEPOINT_SPHINCSSHA2128FSIMPLE")) - oqs_sigalg_list[37].code_point = - atoi(getenv("OQS_CODEPOINT_SPHINCSSHA2128FSIMPLE")); + oqs_sigalg_list[37].code_point + = atoi(getenv("OQS_CODEPOINT_SPHINCSSHA2128FSIMPLE")); if (getenv("OQS_CODEPOINT_P256_SPHINCSSHA2128FSIMPLE")) - oqs_sigalg_list[38].code_point = - atoi(getenv("OQS_CODEPOINT_P256_SPHINCSSHA2128FSIMPLE")); + oqs_sigalg_list[38].code_point + = atoi(getenv("OQS_CODEPOINT_P256_SPHINCSSHA2128FSIMPLE")); if (getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHA2128FSIMPLE")) - oqs_sigalg_list[39].code_point = - atoi(getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHA2128FSIMPLE")); + oqs_sigalg_list[39].code_point + = atoi(getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHA2128FSIMPLE")); if (getenv("OQS_CODEPOINT_SPHINCSSHA2128SSIMPLE")) - oqs_sigalg_list[40].code_point = - atoi(getenv("OQS_CODEPOINT_SPHINCSSHA2128SSIMPLE")); + oqs_sigalg_list[40].code_point + = atoi(getenv("OQS_CODEPOINT_SPHINCSSHA2128SSIMPLE")); if (getenv("OQS_CODEPOINT_P256_SPHINCSSHA2128SSIMPLE")) - oqs_sigalg_list[41].code_point = - atoi(getenv("OQS_CODEPOINT_P256_SPHINCSSHA2128SSIMPLE")); + oqs_sigalg_list[41].code_point + = atoi(getenv("OQS_CODEPOINT_P256_SPHINCSSHA2128SSIMPLE")); if (getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHA2128SSIMPLE")) - oqs_sigalg_list[42].code_point = - atoi(getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHA2128SSIMPLE")); + oqs_sigalg_list[42].code_point + = atoi(getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHA2128SSIMPLE")); if (getenv("OQS_CODEPOINT_SPHINCSSHA2192FSIMPLE")) - oqs_sigalg_list[43].code_point = - atoi(getenv("OQS_CODEPOINT_SPHINCSSHA2192FSIMPLE")); + oqs_sigalg_list[43].code_point + = atoi(getenv("OQS_CODEPOINT_SPHINCSSHA2192FSIMPLE")); if (getenv("OQS_CODEPOINT_P384_SPHINCSSHA2192FSIMPLE")) - oqs_sigalg_list[44].code_point = - atoi(getenv("OQS_CODEPOINT_P384_SPHINCSSHA2192FSIMPLE")); + oqs_sigalg_list[44].code_point + = atoi(getenv("OQS_CODEPOINT_P384_SPHINCSSHA2192FSIMPLE")); if (getenv("OQS_CODEPOINT_SPHINCSSHAKE128FSIMPLE")) - oqs_sigalg_list[45].code_point = - atoi(getenv("OQS_CODEPOINT_SPHINCSSHAKE128FSIMPLE")); + oqs_sigalg_list[45].code_point + = atoi(getenv("OQS_CODEPOINT_SPHINCSSHAKE128FSIMPLE")); if (getenv("OQS_CODEPOINT_P256_SPHINCSSHAKE128FSIMPLE")) - oqs_sigalg_list[46].code_point = - atoi(getenv("OQS_CODEPOINT_P256_SPHINCSSHAKE128FSIMPLE")); + oqs_sigalg_list[46].code_point + = atoi(getenv("OQS_CODEPOINT_P256_SPHINCSSHAKE128FSIMPLE")); if (getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHAKE128FSIMPLE")) - oqs_sigalg_list[47].code_point = - atoi(getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHAKE128FSIMPLE")); + oqs_sigalg_list[47].code_point + = atoi(getenv("OQS_CODEPOINT_RSA3072_SPHINCSSHAKE128FSIMPLE")); if (getenv("OQS_CODEPOINT_MAYO1")) oqs_sigalg_list[48].code_point = atoi(getenv("OQS_CODEPOINT_MAYO1")); if (getenv("OQS_CODEPOINT_P256_MAYO1")) - oqs_sigalg_list[49].code_point = - atoi(getenv("OQS_CODEPOINT_P256_MAYO1")); + oqs_sigalg_list[49].code_point + = atoi(getenv("OQS_CODEPOINT_P256_MAYO1")); if (getenv("OQS_CODEPOINT_MAYO2")) oqs_sigalg_list[50].code_point = atoi(getenv("OQS_CODEPOINT_MAYO2")); if (getenv("OQS_CODEPOINT_P256_MAYO2")) - oqs_sigalg_list[51].code_point = - atoi(getenv("OQS_CODEPOINT_P256_MAYO2")); + oqs_sigalg_list[51].code_point + = atoi(getenv("OQS_CODEPOINT_P256_MAYO2")); if (getenv("OQS_CODEPOINT_MAYO3")) oqs_sigalg_list[52].code_point = atoi(getenv("OQS_CODEPOINT_MAYO3")); if (getenv("OQS_CODEPOINT_P384_MAYO3")) - oqs_sigalg_list[53].code_point = - atoi(getenv("OQS_CODEPOINT_P384_MAYO3")); + oqs_sigalg_list[53].code_point + = atoi(getenv("OQS_CODEPOINT_P384_MAYO3")); if (getenv("OQS_CODEPOINT_MAYO5")) oqs_sigalg_list[54].code_point = atoi(getenv("OQS_CODEPOINT_MAYO5")); if (getenv("OQS_CODEPOINT_P521_MAYO5")) - oqs_sigalg_list[55].code_point = - atoi(getenv("OQS_CODEPOINT_P521_MAYO5")); + oqs_sigalg_list[55].code_point + = atoi(getenv("OQS_CODEPOINT_P521_MAYO5")); if (getenv("OQS_CODEPOINT_CROSSRSDP128BALANCED")) - oqs_sigalg_list[56].code_point = - atoi(getenv("OQS_CODEPOINT_CROSSRSDP128BALANCED")); + oqs_sigalg_list[56].code_point + = atoi(getenv("OQS_CODEPOINT_CROSSRSDP128BALANCED")); ///// OQS_TEMPLATE_FRAGMENT_CODEPOINT_PATCHING_END return 1; } -static int oqs_group_capability(OSSL_CALLBACK *cb, void *arg) { +static int oqs_group_capability(OSSL_CALLBACK *cb, void *arg) +{ size_t i; for (i = 0; i < OSSL_NELEM(oqs_param_group_list); i++) { @@ -618,48 +620,50 @@ static int oqs_group_capability(OSSL_CALLBACK *cb, void *arg) { } #ifdef OSSL_CAPABILITY_TLS_SIGALG_NAME -#define OQS_SIGALG_ENTRY(tlsname, realname, algorithm, oid, idx) \ - { \ - OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_IANA_NAME, #tlsname, \ - sizeof(#tlsname)), \ - OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_NAME, #tlsname, \ - sizeof(#tlsname)), \ - OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_OID, #oid, \ - sizeof(#oid)), \ - OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_SIGALG_CODE_POINT, \ - (unsigned int *)&oqs_sigalg_list[idx].code_point), \ - OSSL_PARAM_uint(OSSL_CAPABILITY_TLS_SIGALG_SECURITY_BITS, \ - (unsigned int *)&oqs_sigalg_list[idx].secbits), \ - OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MIN_TLS, \ - (unsigned int *)&oqs_sigalg_list[idx].mintls), \ - OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MAX_TLS, \ - (unsigned int *)&oqs_sigalg_list[idx].maxtls), \ - OSSL_PARAM_END \ - } +# define OQS_SIGALG_ENTRY(tlsname, realname, algorithm, oid, idx) \ + { \ + OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_IANA_NAME, \ + #tlsname, sizeof(#tlsname)), \ + OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_NAME, \ + #tlsname, sizeof(#tlsname)), \ + OSSL_PARAM_utf8_string(OSSL_CAPABILITY_TLS_SIGALG_OID, #oid, \ + sizeof(#oid)), \ + OSSL_PARAM_uint( \ + OSSL_CAPABILITY_TLS_SIGALG_CODE_POINT, \ + (unsigned int *)&oqs_sigalg_list[idx].code_point), \ + OSSL_PARAM_uint( \ + OSSL_CAPABILITY_TLS_SIGALG_SECURITY_BITS, \ + (unsigned int *)&oqs_sigalg_list[idx].secbits), \ + OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MIN_TLS, \ + (unsigned int *)&oqs_sigalg_list[idx].mintls), \ + OSSL_PARAM_int(OSSL_CAPABILITY_TLS_SIGALG_MAX_TLS, \ + (unsigned int *)&oqs_sigalg_list[idx].maxtls), \ + OSSL_PARAM_END \ + } static const OSSL_PARAM oqs_param_sigalg_list[][12] = { ///// OQS_TEMPLATE_FRAGMENT_SIGALG_NAMES_START -#ifdef OQS_ENABLE_SIG_dilithium_2 +# ifdef OQS_ENABLE_SIG_dilithium_2 OQS_SIGALG_ENTRY(dilithium2, dilithium2, dilithium2, "1.3.6.1.4.1.2.267.7.4.4", 0), OQS_SIGALG_ENTRY(p256_dilithium2, p256_dilithium2, p256_dilithium2, "1.3.9999.2.7.1", 1), OQS_SIGALG_ENTRY(rsa3072_dilithium2, rsa3072_dilithium2, rsa3072_dilithium2, "1.3.9999.2.7.2", 2), -#endif -#ifdef OQS_ENABLE_SIG_dilithium_3 +# endif +# ifdef OQS_ENABLE_SIG_dilithium_3 OQS_SIGALG_ENTRY(dilithium3, dilithium3, dilithium3, "1.3.6.1.4.1.2.267.7.6.5", 3), OQS_SIGALG_ENTRY(p384_dilithium3, p384_dilithium3, p384_dilithium3, "1.3.9999.2.7.3", 4), -#endif -#ifdef OQS_ENABLE_SIG_dilithium_5 +# endif +# ifdef OQS_ENABLE_SIG_dilithium_5 OQS_SIGALG_ENTRY(dilithium5, dilithium5, dilithium5, "1.3.6.1.4.1.2.267.7.8.7", 5), OQS_SIGALG_ENTRY(p521_dilithium5, p521_dilithium5, p521_dilithium5, "1.3.9999.2.7.4", 6), -#endif -#ifdef OQS_ENABLE_SIG_ml_dsa_44 +# endif +# ifdef OQS_ENABLE_SIG_ml_dsa_44 OQS_SIGALG_ENTRY(mldsa44, mldsa44, mldsa44, "1.3.6.1.4.1.2.267.12.4.4", 7), OQS_SIGALG_ENTRY(p256_mldsa44, p256_mldsa44, p256_mldsa44, "1.3.9999.7.1", 8), @@ -675,8 +679,8 @@ static const OSSL_PARAM oqs_param_sigalg_list[][12] = { "2.16.840.1.114027.80.8.1.4", 13), OQS_SIGALG_ENTRY(mldsa44_bp256, mldsa44_bp256, mldsa44_bp256, "2.16.840.1.114027.80.8.1.5", 14), -#endif -#ifdef OQS_ENABLE_SIG_ml_dsa_65 +# endif +# ifdef OQS_ENABLE_SIG_ml_dsa_65 OQS_SIGALG_ENTRY(mldsa65, mldsa65, mldsa65, "1.3.6.1.4.1.2.267.12.6.5", 15), OQS_SIGALG_ENTRY(p384_mldsa65, p384_mldsa65, p384_mldsa65, "1.3.9999.7.3", 16), @@ -690,8 +694,8 @@ static const OSSL_PARAM oqs_param_sigalg_list[][12] = { "2.16.840.1.114027.80.8.1.9", 20), OQS_SIGALG_ENTRY(mldsa65_ed25519, mldsa65_ed25519, mldsa65_ed25519, "2.16.840.1.114027.80.8.1.10", 21), -#endif -#ifdef OQS_ENABLE_SIG_ml_dsa_87 +# endif +# ifdef OQS_ENABLE_SIG_ml_dsa_87 OQS_SIGALG_ENTRY(mldsa87, mldsa87, mldsa87, "1.3.6.1.4.1.2.267.12.8.7", 22), OQS_SIGALG_ENTRY(p521_mldsa87, p521_mldsa87, p521_mldsa87, "1.3.9999.7.4", 23), @@ -701,34 +705,34 @@ static const OSSL_PARAM oqs_param_sigalg_list[][12] = { "2.16.840.1.114027.80.8.1.12", 25), OQS_SIGALG_ENTRY(mldsa87_ed448, mldsa87_ed448, mldsa87_ed448, "2.16.840.1.114027.80.8.1.13", 26), -#endif -#ifdef OQS_ENABLE_SIG_falcon_512 +# endif +# ifdef OQS_ENABLE_SIG_falcon_512 OQS_SIGALG_ENTRY(falcon512, falcon512, falcon512, "1.3.9999.3.11", 27), OQS_SIGALG_ENTRY(p256_falcon512, p256_falcon512, p256_falcon512, "1.3.9999.3.12", 28), OQS_SIGALG_ENTRY(rsa3072_falcon512, rsa3072_falcon512, rsa3072_falcon512, "1.3.9999.3.13", 29), -#endif -#ifdef OQS_ENABLE_SIG_falcon_padded_512 +# endif +# ifdef OQS_ENABLE_SIG_falcon_padded_512 OQS_SIGALG_ENTRY(falconpadded512, falconpadded512, falconpadded512, "1.3.9999.3.16", 30), OQS_SIGALG_ENTRY(p256_falconpadded512, p256_falconpadded512, p256_falconpadded512, "1.3.9999.3.17", 31), OQS_SIGALG_ENTRY(rsa3072_falconpadded512, rsa3072_falconpadded512, rsa3072_falconpadded512, "1.3.9999.3.18", 32), -#endif -#ifdef OQS_ENABLE_SIG_falcon_1024 +# endif +# ifdef OQS_ENABLE_SIG_falcon_1024 OQS_SIGALG_ENTRY(falcon1024, falcon1024, falcon1024, "1.3.9999.3.14", 33), OQS_SIGALG_ENTRY(p521_falcon1024, p521_falcon1024, p521_falcon1024, "1.3.9999.3.15", 34), -#endif -#ifdef OQS_ENABLE_SIG_falcon_padded_1024 +# endif +# ifdef OQS_ENABLE_SIG_falcon_padded_1024 OQS_SIGALG_ENTRY(falconpadded1024, falconpadded1024, falconpadded1024, "1.3.9999.3.19", 35), OQS_SIGALG_ENTRY(p521_falconpadded1024, p521_falconpadded1024, p521_falconpadded1024, "1.3.9999.3.20", 36), -#endif -#ifdef OQS_ENABLE_SIG_sphincs_sha2_128f_simple +# endif +# ifdef OQS_ENABLE_SIG_sphincs_sha2_128f_simple OQS_SIGALG_ENTRY(sphincssha2128fsimple, sphincssha2128fsimple, sphincssha2128fsimple, "1.3.9999.6.4.13", 37), OQS_SIGALG_ENTRY(p256_sphincssha2128fsimple, p256_sphincssha2128fsimple, @@ -736,8 +740,8 @@ static const OSSL_PARAM oqs_param_sigalg_list[][12] = { OQS_SIGALG_ENTRY(rsa3072_sphincssha2128fsimple, rsa3072_sphincssha2128fsimple, rsa3072_sphincssha2128fsimple, "1.3.9999.6.4.15", 39), -#endif -#ifdef OQS_ENABLE_SIG_sphincs_sha2_128s_simple +# endif +# ifdef OQS_ENABLE_SIG_sphincs_sha2_128s_simple OQS_SIGALG_ENTRY(sphincssha2128ssimple, sphincssha2128ssimple, sphincssha2128ssimple, "1.3.9999.6.4.16", 40), OQS_SIGALG_ENTRY(p256_sphincssha2128ssimple, p256_sphincssha2128ssimple, @@ -745,14 +749,14 @@ static const OSSL_PARAM oqs_param_sigalg_list[][12] = { OQS_SIGALG_ENTRY(rsa3072_sphincssha2128ssimple, rsa3072_sphincssha2128ssimple, rsa3072_sphincssha2128ssimple, "1.3.9999.6.4.18", 42), -#endif -#ifdef OQS_ENABLE_SIG_sphincs_sha2_192f_simple +# endif +# ifdef OQS_ENABLE_SIG_sphincs_sha2_192f_simple OQS_SIGALG_ENTRY(sphincssha2192fsimple, sphincssha2192fsimple, sphincssha2192fsimple, "1.3.9999.6.5.10", 43), OQS_SIGALG_ENTRY(p384_sphincssha2192fsimple, p384_sphincssha2192fsimple, p384_sphincssha2192fsimple, "1.3.9999.6.5.11", 44), -#endif -#ifdef OQS_ENABLE_SIG_sphincs_shake_128f_simple +# endif +# ifdef OQS_ENABLE_SIG_sphincs_shake_128f_simple OQS_SIGALG_ENTRY(sphincsshake128fsimple, sphincsshake128fsimple, sphincsshake128fsimple, "1.3.9999.6.7.13", 45), OQS_SIGALG_ENTRY(p256_sphincsshake128fsimple, p256_sphincsshake128fsimple, @@ -760,31 +764,32 @@ static const OSSL_PARAM oqs_param_sigalg_list[][12] = { OQS_SIGALG_ENTRY(rsa3072_sphincsshake128fsimple, rsa3072_sphincsshake128fsimple, rsa3072_sphincsshake128fsimple, "1.3.9999.6.7.15", 47), -#endif -#ifdef OQS_ENABLE_SIG_mayo_1 +# endif +# ifdef OQS_ENABLE_SIG_mayo_1 OQS_SIGALG_ENTRY(mayo1, mayo1, mayo1, "1.3.9999.8.1.1", 48), OQS_SIGALG_ENTRY(p256_mayo1, p256_mayo1, p256_mayo1, "1.3.9999.8.1.2", 49), -#endif -#ifdef OQS_ENABLE_SIG_mayo_2 +# endif +# ifdef OQS_ENABLE_SIG_mayo_2 OQS_SIGALG_ENTRY(mayo2, mayo2, mayo2, "1.3.9999.8.2.1", 50), OQS_SIGALG_ENTRY(p256_mayo2, p256_mayo2, p256_mayo2, "1.3.9999.8.2.2", 51), -#endif -#ifdef OQS_ENABLE_SIG_mayo_3 +# endif +# ifdef OQS_ENABLE_SIG_mayo_3 OQS_SIGALG_ENTRY(mayo3, mayo3, mayo3, "1.3.9999.8.3.1", 52), OQS_SIGALG_ENTRY(p384_mayo3, p384_mayo3, p384_mayo3, "1.3.9999.8.3.2", 53), -#endif -#ifdef OQS_ENABLE_SIG_mayo_5 +# endif +# ifdef OQS_ENABLE_SIG_mayo_5 OQS_SIGALG_ENTRY(mayo5, mayo5, mayo5, "1.3.9999.8.5.1", 54), OQS_SIGALG_ENTRY(p521_mayo5, p521_mayo5, p521_mayo5, "1.3.9999.8.5.2", 55), -#endif -#ifdef OQS_ENABLE_SIG_cross_rsdp_128_balanced +# endif +# ifdef OQS_ENABLE_SIG_cross_rsdp_128_balanced OQS_SIGALG_ENTRY(CROSSrsdp128balanced, CROSSrsdp128balanced, CROSSrsdp128balanced, "1.3.6.1.4.1.62245.2.1.1", 56), -#endif +# endif ///// OQS_TEMPLATE_FRAGMENT_SIGALG_NAMES_END }; -static int oqs_sigalg_capability(OSSL_CALLBACK *cb, void *arg) { +static int oqs_sigalg_capability(OSSL_CALLBACK *cb, void *arg) +{ size_t i; // relaxed assertion for the case that not all algorithms are enabled in @@ -800,7 +805,8 @@ static int oqs_sigalg_capability(OSSL_CALLBACK *cb, void *arg) { #endif /* OSSL_CAPABILITY_TLS_SIGALG_NAME */ int oqs_provider_get_capabilities(void *provctx, const char *capability, - OSSL_CALLBACK *cb, void *arg) { + OSSL_CALLBACK *cb, void *arg) +{ if (strcasecmp(capability, "TLS-GROUP") == 0) return oqs_group_capability(cb, arg); @@ -808,13 +814,13 @@ int oqs_provider_get_capabilities(void *provctx, const char *capability, if (strcasecmp(capability, "TLS-SIGALG") == 0) return oqs_sigalg_capability(cb, arg); #else -#ifndef NDEBUG +# ifndef NDEBUG fprintf(stderr, "Warning: OSSL_CAPABILITY_TLS_SIGALG_NAME not defined: " "OpenSSL version used that does not support pluggable " "signature capabilities.\nUpgrading OpenSSL installation " "recommended to enable QSC TLS signature support.\n\n"); -#endif /* NDEBUG */ -#endif /* OSSL_CAPABILITY_TLS_SIGALG_NAME */ +# endif /* NDEBUG */ +#endif /* OSSL_CAPABILITY_TLS_SIGALG_NAME */ /* We don't support this capability */ return 0; diff --git a/oqsprov/oqsprov_keys.c b/oqsprov/oqsprov_keys.c index 6153b1de..a6209b1e 100644 --- a/oqsprov/oqsprov_keys.c +++ b/oqsprov/oqsprov_keys.c @@ -20,22 +20,26 @@ #include "oqs_prov.h" #ifdef NDEBUG -#define OQS_KEY_PRINTF(a) -#define OQS_KEY_PRINTF2(a, b) -#define OQS_KEY_PRINTF3(a, b, c) +# define OQS_KEY_PRINTF(a) +# define OQS_KEY_PRINTF2(a, b) +# define OQS_KEY_PRINTF3(a, b, c) #else -#define OQS_KEY_PRINTF(a) \ - if (getenv("OQSKEY")) \ - printf(a) -#define OQS_KEY_PRINTF2(a, b) \ - if (getenv("OQSKEY")) \ - printf(a, b) -#define OQS_KEY_PRINTF3(a, b, c) \ - if (getenv("OQSKEY")) \ - printf(a, b, c) +# define OQS_KEY_PRINTF(a) \ + if (getenv("OQSKEY")) \ + printf(a) +# define OQS_KEY_PRINTF2(a, b) \ + if (getenv("OQSKEY")) \ + printf(a, b) +# define OQS_KEY_PRINTF3(a, b, c) \ + if (getenv("OQSKEY")) \ + printf(a, b, c) #endif // NDEBUG -typedef enum { KEY_OP_PUBLIC, KEY_OP_PRIVATE, KEY_OP_KEYGEN } oqsx_key_op_t; +typedef enum { + KEY_OP_PUBLIC, + KEY_OP_PRIVATE, + KEY_OP_KEYGEN +} oqsx_key_op_t; /// NID/name table @@ -53,9 +57,9 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op); ///// OQS_TEMPLATE_FRAGMENT_OQSNAMES_START #ifdef OQS_KEM_ENCODERS -#define NID_TABLE_LEN 110 +# define NID_TABLE_LEN 110 #else -#define NID_TABLE_LEN 57 +# define NID_TABLE_LEN 57 #endif static oqs_nid_name_t nid_names[NID_TABLE_LEN] = { @@ -206,7 +210,8 @@ static oqs_nid_name_t nid_names[NID_TABLE_LEN] = { ///// OQS_TEMPLATE_FRAGMENT_OQSNAMES_END }; -int oqs_set_nid(char *tlsname, int nid) { +int oqs_set_nid(char *tlsname, int nid) +{ int i; for (i = 0; i < NID_TABLE_LEN; i++) { if (!strcmp(nid_names[i].tlsname, tlsname)) { @@ -217,7 +222,8 @@ int oqs_set_nid(char *tlsname, int nid) { return 0; } -static int get_secbits(int nid) { +static int get_secbits(int nid) +{ int i; for (i = 0; i < NID_TABLE_LEN; i++) { if (nid_names[i].nid == nid) @@ -226,7 +232,8 @@ static int get_secbits(int nid) { return 0; } -static int get_reverseshare(int nid) { +static int get_reverseshare(int nid) +{ int i; for (i = 0; i < NID_TABLE_LEN; i++) { if (nid_names[i].nid == nid) @@ -235,7 +242,8 @@ static int get_reverseshare(int nid) { return 0; } -static int get_keytype(int nid) { +static int get_keytype(int nid) +{ int i; for (i = 0; i < NID_TABLE_LEN; i++) { if (nid_names[i].nid == nid) @@ -244,19 +252,21 @@ static int get_keytype(int nid) { return 0; } -char *get_oqsname_fromtls(char *tlsname) { +char *get_oqsname_fromtls(char *tlsname) +{ int i; for (i = 0; i < NID_TABLE_LEN; i++) { if (nid_names[i].keytype == KEY_TYPE_SIG) { - if (!strcmp(nid_names[i].oqsname, tlsname) || - !strcmp(nid_names[i].tlsname, tlsname)) + if (!strcmp(nid_names[i].oqsname, tlsname) + || !strcmp(nid_names[i].tlsname, tlsname)) return nid_names[i].oqsname; } } return 0; // classical } -char *get_oqsname(int nid) { +char *get_oqsname(int nid) +{ int i; for (i = 0; i < NID_TABLE_LEN; i++) { if (nid_names[i].nid == nid) @@ -265,7 +275,8 @@ char *get_oqsname(int nid) { return 0; } -char *get_cmpname(int nid, int index) { +char *get_cmpname(int nid, int index) +{ int i, len; char *name, *s; if ((i = get_oqsalg_idx(nid)) == -1) @@ -292,7 +303,8 @@ char *get_cmpname(int nid, int index) { return name; } -int get_oqsalg_idx(int nid) { +int get_oqsalg_idx(int nid) +{ int i; for (i = 0; i < NID_TABLE_LEN; i++) { if (nid_names[i].nid == nid) @@ -304,10 +316,11 @@ int get_oqsalg_idx(int nid) { /* Sets the index of the key components in a comp_privkey or comp_pubkey array */ static void oqsx_comp_set_idx(const OQSX_KEY *key, int *idx_classic, - int *idx_pq) { - int reverse_share = (key->keytype == KEY_TYPE_ECP_HYB_KEM || - key->keytype == KEY_TYPE_ECX_HYB_KEM) && - key->reverse_share; + int *idx_pq) +{ + int reverse_share = (key->keytype == KEY_TYPE_ECP_HYB_KEM + || key->keytype == KEY_TYPE_ECX_HYB_KEM) + && key->reverse_share; if (reverse_share) { if (idx_classic) @@ -326,7 +339,8 @@ static void oqsx_comp_set_idx(const OQSX_KEY *key, int *idx_classic, */ static int oqsx_comp_set_offsets(const OQSX_KEY *key, int set_privkey_offsets, int set_pubkey_offsets, - int classic_lengths_fixed) { + int classic_lengths_fixed) +{ int ret = 1; uint32_t classic_pubkey_len = 0; uint32_t classic_privkey_len = 0; @@ -335,9 +349,9 @@ static int oqsx_comp_set_offsets(const OQSX_KEY *key, int set_privkey_offsets, // The only special case with reversed keys (so far) // is: x25519_mlkem* - int reverse_share = (key->keytype == KEY_TYPE_ECP_HYB_KEM || - key->keytype == KEY_TYPE_ECX_HYB_KEM) && - key->reverse_share; + int reverse_share = (key->keytype == KEY_TYPE_ECP_HYB_KEM + || key->keytype == KEY_TYPE_ECX_HYB_KEM) + && key->reverse_share; if (set_privkey_offsets) { key->comp_privkey[0] = privkey + SIZE_OF_UINT32; @@ -356,15 +370,15 @@ static int oqsx_comp_set_offsets(const OQSX_KEY *key, int set_privkey_offsets, if (reverse_share) { // structure is: // UINT32 (encoding classic key size) | PQ_KEY | CLASSIC_KEY - key->comp_privkey[1] = - privkey + - key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key + - SIZE_OF_UINT32; + key->comp_privkey[1] + = privkey + + key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key + + SIZE_OF_UINT32; } else { // structure is: // UINT32 (encoding classic key size) | CLASSIC_KEY | PQ_KEY - key->comp_privkey[1] = - privkey + classic_privkey_len + SIZE_OF_UINT32; + key->comp_privkey[1] + = privkey + classic_privkey_len + SIZE_OF_UINT32; } } @@ -385,10 +399,10 @@ static int oqsx_comp_set_offsets(const OQSX_KEY *key, int set_privkey_offsets, if (reverse_share) { // structure is: // UINT32 (encoding classic key size) | PQ_KEY | CLASSIC_KEY - key->comp_pubkey[1] = - pubkey + - key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_public_key + - SIZE_OF_UINT32; + key->comp_pubkey[1] + = pubkey + + key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_public_key + + SIZE_OF_UINT32; } else { // structure is: // UINT32 (encoding classic key size) | CLASSIC_KEY | PQ_KEY @@ -401,7 +415,8 @@ static int oqsx_comp_set_offsets(const OQSX_KEY *key, int set_privkey_offsets, } /* Prepare composite data structures. RetVal 0 is error. */ -static int oqsx_key_set_composites(OQSX_KEY *key, int classic_lengths_fixed) { +static int oqsx_key_set_composites(OQSX_KEY *key, int classic_lengths_fixed) +{ int ret = 1; OQS_KEY_PRINTF2("Setting composites with evp_info %p\n", key->evp_info); @@ -453,7 +468,8 @@ static int oqsx_key_set_composites(OQSX_KEY *key, int classic_lengths_fixed) { } PROV_OQS_CTX *oqsx_newprovctx(OSSL_LIB_CTX *libctx, - const OSSL_CORE_HANDLE *handle, BIO_METHOD *bm) { + const OSSL_CORE_HANDLE *handle, BIO_METHOD *bm) +{ PROV_OQS_CTX *ret = OPENSSL_zalloc(sizeof(PROV_OQS_CTX)); if (ret) { ret->libctx = libctx; @@ -463,19 +479,22 @@ PROV_OQS_CTX *oqsx_newprovctx(OSSL_LIB_CTX *libctx, return ret; } -void oqsx_freeprovctx(PROV_OQS_CTX *ctx) { +void oqsx_freeprovctx(PROV_OQS_CTX *ctx) +{ OSSL_LIB_CTX_free(ctx->libctx); BIO_meth_free(ctx->corebiometh); OPENSSL_free(ctx); } -void oqsx_key_set0_libctx(OQSX_KEY *key, OSSL_LIB_CTX *libctx) { +void oqsx_key_set0_libctx(OQSX_KEY *key, OSSL_LIB_CTX *libctx) +{ key->libctx = libctx; } /* convenience function creating OQSX keys from nids (only for sigs) */ static OQSX_KEY *oqsx_key_new_from_nid(OSSL_LIB_CTX *libctx, const char *propq, - int nid) { + int nid) +{ OQS_KEY_PRINTF2("Generating OQSX key for nid %d\n", nid); char *tls_algname = (char *)OBJ_nid2sn(nid); @@ -494,17 +513,18 @@ static OQSX_KEY *oqsx_key_new_from_nid(OSSL_LIB_CTX *libctx, const char *propq, /* Workaround for not functioning EC PARAM initialization * TBD, check https://github.com/openssl/openssl/issues/16989 */ -EVP_PKEY *setECParams(EVP_PKEY *eck, int nid) { - const unsigned char p256params[] = {0x06, 0x08, 0x2a, 0x86, 0x48, - 0xce, 0x3d, 0x03, 0x01, 0x07}; - const unsigned char p384params[] = {0x06, 0x05, 0x2b, 0x81, - 0x04, 0x00, 0x22}; - const unsigned char p521params[] = {0x06, 0x05, 0x2b, 0x81, - 0x04, 0x00, 0x23}; - const unsigned char bp256params[] = {0x06, 0x09, 0x2b, 0x24, 0x03, 0x03, - 0x02, 0x08, 0x01, 0x01, 0x07}; - const unsigned char bp384params[] = {0x06, 0x09, 0x2b, 0x24, 0x03, 0x03, - 0x02, 0x08, 0x01, 0x01, 0x0b}; +EVP_PKEY *setECParams(EVP_PKEY *eck, int nid) +{ + const unsigned char p256params[] + = {0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07}; + const unsigned char p384params[] + = {0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22}; + const unsigned char p521params[] + = {0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x23}; + const unsigned char bp256params[] + = {0x06, 0x09, 0x2b, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x07}; + const unsigned char bp384params[] + = {0x06, 0x09, 0x2b, 0x24, 0x03, 0x03, 0x02, 0x08, 0x01, 0x01, 0x0b}; const unsigned char *params; switch (nid) { @@ -544,8 +564,8 @@ static const OQSX_EVP_INFO nids_sig[] = { }; // These two array need to stay synced: // note only leading 4 chars of alg name are checked -static const char *OQSX_ECP_NAMES[] = { - "p256", "p384", "p521", "SecP256r1", "SecP384r1", "SecP521r1", 0}; +static const char *OQSX_ECP_NAMES[] + = {"p256", "p384", "p521", "SecP256r1", "SecP384r1", "SecP521r1", 0}; static const OQSX_EVP_INFO nids_ecp[] = { {EVP_PKEY_EC, NID_X9_62_prime256v1, 0, 65, 121, 32, 0}, // 128 bit {EVP_PKEY_EC, NID_secp384r1, 0, 97, 167, 48, 0}, // 192 bit @@ -568,7 +588,8 @@ static const OQSX_EVP_INFO nids_ecx[] = { }; static int oqsx_hybsig_init(int bit_security, OQSX_EVP_CTX *evp_ctx, - char *algname) { + char *algname) +{ int ret = 1; int idx = (bit_security - 128) / 64; ON_ERR_GOTO(idx < 0 || idx > 5, err_init); @@ -631,7 +652,8 @@ static int oqsx_hybsig_init(int bit_security, OQSX_EVP_CTX *evp_ctx, return ret; } -static const int oqshybkem_init_ecp(char *tls_name, OQSX_EVP_CTX *evp_ctx) { +static const int oqshybkem_init_ecp(char *tls_name, OQSX_EVP_CTX *evp_ctx) +{ int ret = 1; int idx = 0; @@ -661,7 +683,8 @@ static const int oqshybkem_init_ecp(char *tls_name, OQSX_EVP_CTX *evp_ctx) { return ret; } -static const int oqshybkem_init_ecx(char *tls_name, OQSX_EVP_CTX *evp_ctx) { +static const int oqshybkem_init_ecx(char *tls_name, OQSX_EVP_CTX *evp_ctx) +{ int ret = 1; int idx = 0; @@ -690,7 +713,8 @@ static const int oqshybkem_init_ecx(char *tls_name, OQSX_EVP_CTX *evp_ctx) { /* Re-create OQSX_KEY from encoding(s): Same end-state as after ken-gen */ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, int plen, oqsx_key_op_t op, OSSL_LIB_CTX *libctx, - const char *propq) { + const char *propq) +{ OQSX_KEY *key = NULL; void **privkey, **pubkey; int nid = NID_undef; @@ -751,8 +775,8 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, // check if key is the right size for (i = 0; i < key->numkeys; i++) { char *name; - if ((name = get_cmpname(OBJ_sn2nid(key->tls_name), i)) == - NULL) { + if ((name = get_cmpname(OBJ_sn2nid(key->tls_name), i)) + == NULL) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto err_key_op; } @@ -793,8 +817,8 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, for (i = 0; i < key->numkeys; i++) { size_t classic_publen = 0; char *name; - if ((name = get_cmpname(OBJ_sn2nid(key->tls_name), i)) == - NULL) { + if ((name = get_cmpname(OBJ_sn2nid(key->tls_name), i)) + == NULL) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); OPENSSL_secure_clear_free(temp_priv, temp_priv_len); OPENSSL_secure_clear_free(temp_pub, temp_pub_len); @@ -804,9 +828,8 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, publen = 0; // no pubkey encoded with privkey // on classical keys. will // recreate the pubkey later - if (key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info - ->keytype == - EVP_PKEY_RSA) { // get the RSA real key size + if (key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->keytype + == EVP_PKEY_RSA) { // get the RSA real key size if (previous_privlen + previous_publen + 4 > plen) { OPENSSL_free(name); OPENSSL_secure_clear_free(temp_priv, temp_priv_len); @@ -814,10 +837,10 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto err_key_op; } - unsigned char *enc_len = - (unsigned char *)OPENSSL_strndup( - (const char *)(p + previous_privlen + - previous_publen), + unsigned char *enc_len + = (unsigned char *)OPENSSL_strndup( + (const char *)(p + previous_privlen + + previous_publen), 4); OPENSSL_cleanse(enc_len, 2); DECODE_UINT32(privlen, enc_len); @@ -862,26 +885,26 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, OPENSSL_secure_clear_free(temp_pub, temp_pub_len); } else { if (key->numkeys == 2) { - size_t expected_pq_privkey_len = - key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key; + size_t expected_pq_privkey_len + = key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key; #ifndef NOPUBKEY_IN_PRIVKEY - expected_pq_privkey_len += - key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_public_key; + expected_pq_privkey_len += key->oqsx_provider_ctx.oqsx_qs_ctx + .kem->length_public_key; #endif if (plen > (SIZE_OF_UINT32 + expected_pq_privkey_len)) { - size_t max_classical_privkey_len = - key->evp_info->length_private_key; - size_t space_for_classical_privkey = - plen - expected_pq_privkey_len - SIZE_OF_UINT32; - if (space_for_classical_privkey > - max_classical_privkey_len) { + size_t max_classical_privkey_len + = key->evp_info->length_private_key; + size_t space_for_classical_privkey + = plen - expected_pq_privkey_len - SIZE_OF_UINT32; + if (space_for_classical_privkey + > max_classical_privkey_len) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto err_key_op; } DECODE_UINT32(classical_privatekey_len, p); // actual classic key len - if (classical_privatekey_len != - space_for_classical_privkey) { + if (classical_privatekey_len + != space_for_classical_privkey) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto err_key_op; } @@ -889,8 +912,8 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto err_key_op; } - actualprivkeylen -= (key->evp_info->length_private_key - - classical_privatekey_len); + actualprivkeylen -= (key->evp_info->length_private_key + - classical_privatekey_len); } #ifdef NOPUBKEY_IN_PRIVKEY if (actualprivkeylen != plen) { @@ -898,13 +921,13 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, "unexpected length %d vs %d\n", plen, (int)(actualprivkeylen)); #else - if (actualprivkeylen + oqsx_key_get_oqs_public_key_len(key) != - plen) { + if (actualprivkeylen + oqsx_key_get_oqs_public_key_len(key) + != plen) { OQS_KEY_PRINTF3("OQSX KEY: private key with unexpected length " "%d vs %d\n", plen, - (int)(actualprivkeylen + - oqsx_key_get_oqs_public_key_len(key))); + (int)(actualprivkeylen + + oqsx_key_get_oqs_public_key_len(key))); #endif ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto err_key_op; @@ -921,8 +944,8 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, memcpy(key->privkey, p, actualprivkeylen); #ifndef NOPUBKEY_IN_PRIVKEY // only enough data to fill public OQS key component - if (oqsx_key_get_oqs_public_key_len(key) != - plen - actualprivkeylen) { + if (oqsx_key_get_oqs_public_key_len(key) + != plen - actualprivkeylen) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto err_key_op; } @@ -934,8 +957,8 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, memcpy(pubkey + SIZE_OF_UINT32, p + actualprivkeylen, plen - actualprivkeylen); } else { - memcpy(pubkey + SIZE_OF_UINT32 + - key->evp_info->length_public_key, + memcpy(pubkey + SIZE_OF_UINT32 + + key->evp_info->length_public_key, p + actualprivkeylen, plen - actualprivkeylen); } } else @@ -945,9 +968,9 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, } } if (!oqsx_key_set_composites(key, - key->keytype == KEY_TYPE_ECP_HYB_KEM || - key->keytype == KEY_TYPE_ECX_HYB_KEM) || - !oqsx_key_recreate_classickey(key, op)) + key->keytype == KEY_TYPE_ECP_HYB_KEM + || key->keytype == KEY_TYPE_ECX_HYB_KEM) + || !oqsx_key_recreate_classickey(key, op)) goto err_key_op; return key; @@ -958,14 +981,15 @@ static OQSX_KEY *oqsx_key_op(const X509_ALGOR *palg, const unsigned char *p, } /* Recreate EVP data structure after import. RetVal 0 is error. */ -static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { +static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) +{ if (key->keytype == KEY_TYPE_CMP_SIG) { int i; if (op == KEY_OP_PUBLIC) { for (i = 0; i < key->numkeys; i++) { char *name; - if ((name = get_cmpname(OBJ_sn2nid(key->tls_name), i)) == - NULL) { + if ((name = get_cmpname(OBJ_sn2nid(key->tls_name), i)) + == NULL) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto rec_err; } @@ -976,7 +1000,8 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { ->raw_key_support) { EVP_PKEY *npk = EVP_PKEY_new(); if (key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info - ->keytype != EVP_PKEY_RSA) { + ->keytype + != EVP_PKEY_RSA) { npk = setECParams(npk, key->oqsx_provider_ctx .oqsx_evp_ctx->evp_info->nid); @@ -1003,8 +1028,8 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { if (op == KEY_OP_PRIVATE) { for (i = 0; i < key->numkeys; i++) { char *name; - if ((name = get_cmpname(OBJ_sn2nid(key->tls_name), i)) == - NULL) { + if ((name = get_cmpname(OBJ_sn2nid(key->tls_name), i)) + == NULL) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto rec_err; } @@ -1031,10 +1056,11 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { if (!key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info ->raw_key_support) { unsigned char *comp_pubkey = key->comp_pubkey[i]; - int pubkeylen = - i2d_PublicKey(key->classical_pkey, &comp_pubkey); - if (pubkeylen != key->oqsx_provider_ctx.oqsx_evp_ctx - ->evp_info->length_public_key) { + int pubkeylen + = i2d_PublicKey(key->classical_pkey, &comp_pubkey); + if (pubkeylen + != key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info + ->length_public_key) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); OPENSSL_free(name); goto rec_err; @@ -1085,9 +1111,9 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { if (key->evp_info->keytype != EVP_PKEY_RSA) { npk = setECParams(npk, key->evp_info->nid); } - key->classical_pkey = - d2i_PublicKey(key->evp_info->keytype, &npk, &enc_pubkey, - classical_pubkey_len); + key->classical_pkey + = d2i_PublicKey(key->evp_info->keytype, &npk, + &enc_pubkey, classical_pubkey_len); if (!key->classical_pkey) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); EVP_PKEY_free(npk); @@ -1101,8 +1127,8 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto rec_err; } - const unsigned char *enc_privkey = - key->comp_privkey[idx_classic]; + const unsigned char *enc_privkey + = key->comp_privkey[idx_classic]; unsigned char *enc_pubkey = key->comp_pubkey[idx_classic]; if (key->evp_info->raw_key_support) { key->classical_pkey = EVP_PKEY_new_raw_private_key( @@ -1119,17 +1145,18 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { EVP_PKEY_get_raw_public_key(key->classical_pkey, NULL, &pubkeylen); - if (pubkeylen != key->evp_info->length_public_key || - EVP_PKEY_get_raw_public_key( - key->classical_pkey, enc_pubkey, &pubkeylen) != 1) { + if (pubkeylen != key->evp_info->length_public_key + || EVP_PKEY_get_raw_public_key(key->classical_pkey, + enc_pubkey, &pubkeylen) + != 1) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto rec_err; } #endif } else { - key->classical_pkey = - d2i_PrivateKey(key->evp_info->keytype, NULL, - &enc_privkey, classical_privkey_len); + key->classical_pkey + = d2i_PrivateKey(key->evp_info->keytype, NULL, + &enc_privkey, classical_privkey_len); if (!key->classical_pkey) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto rec_err; @@ -1137,8 +1164,8 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { #ifndef NOPUBKEY_IN_PRIVKEY // re-create classic public key part from // private key: - int pubkeylen = - i2d_PublicKey(key->classical_pkey, &enc_pubkey); + int pubkeylen + = i2d_PublicKey(key->classical_pkey, &enc_pubkey); if (pubkeylen != key->evp_info->length_public_key) { ERR_raise(ERR_LIB_USER, OQSPROV_R_INVALID_ENCODING); goto rec_err; @@ -1156,7 +1183,8 @@ static int oqsx_key_recreate_classickey(OQSX_KEY *key, oqsx_key_op_t op) { } OQSX_KEY *oqsx_key_from_x509pubkey(const X509_PUBKEY *xpk, OSSL_LIB_CTX *libctx, - const char *propq) { + const char *propq) +{ const unsigned char *p; int plen; X509_ALGOR *palg; @@ -1179,15 +1207,15 @@ OQSX_KEY *oqsx_key_from_x509pubkey(const X509_PUBKEY *xpk, OSSL_LIB_CTX *libctx, return NULL; } else { count = sk_ASN1_TYPE_num(sk); - concat_key = - OPENSSL_zalloc(plen); // concat_key is allocated with plen, - // which is the max value for pubkey + concat_key + = OPENSSL_zalloc(plen); // concat_key is allocated with plen, + // which is the max value for pubkey aux = 0; for (i = 0; i < count; i++) { - aType = - sk_ASN1_TYPE_pop(sk); // this remove in FILO order, but we - // need this in the opposite order + aType + = sk_ASN1_TYPE_pop(sk); // this remove in FILO order, but we + // need this in the opposite order buf = aType->value.sequence->data; buflen = aType->value.sequence->length; aux += buflen; @@ -1210,7 +1238,8 @@ OQSX_KEY *oqsx_key_from_x509pubkey(const X509_PUBKEY *xpk, OSSL_LIB_CTX *libctx, } OQSX_KEY *oqsx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, - OSSL_LIB_CTX *libctx, const char *propq) { + OSSL_LIB_CTX *libctx, const char *propq) +{ OQSX_KEY *oqsx = NULL; const unsigned char *p; int plen; @@ -1250,14 +1279,15 @@ OQSX_KEY *oqsx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, aux = 0; for (i = 0; i < count; i++) { - aType = - sk_ASN1_TYPE_pop(sk); // this remove in FILO order, but we - // need this in the opposite order + aType + = sk_ASN1_TYPE_pop(sk); // this remove in FILO order, but we + // need this in the opposite order p8inf_internal = PKCS8_PRIV_KEY_INFO_new(); nid = 0; char *name; - if ((name = get_cmpname(OBJ_obj2nid(palg->algorithm), - count - 1 - i)) == NULL) { + if ((name + = get_cmpname(OBJ_obj2nid(palg->algorithm), count - 1 - i)) + == NULL) { ASN1_TYPE_free(aType); OPENSSL_clear_free(concat_key, plen); PKCS8_PRIV_KEY_INFO_free(p8inf_internal); @@ -1268,8 +1298,8 @@ OQSX_KEY *oqsx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, buflen = aType->value.sequence->length; const unsigned char *buf2 = aType->value.sequence->data; - p8inf_internal = - d2i_PKCS8_PRIV_KEY_INFO(&p8inf_internal, &buf2, buflen); + p8inf_internal + = d2i_PKCS8_PRIV_KEY_INFO(&p8inf_internal, &buf2, buflen); if (!PKCS8_pkey_get0(NULL, &buf, &buflen, &palg_internal, p8inf_internal)) { OPENSSL_free(name); @@ -1287,23 +1317,24 @@ OQSX_KEY *oqsx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, int j; nid = OBJ_obj2nid(palg_internal->parameter->value.object); for (j = 0; j < OSSL_NELEM(nids_sig); j++) { - if ((nids_sig[j].nid == nid) && - (nids_sig[j].length_private_key > - buflen)) { // check if the curve is the - // same and if the key len is - // smaller than the max key - // size + if ((nids_sig[j].nid == nid) + && (nids_sig[j].length_private_key + > buflen)) { // check if the curve is the + // same and if the key len is + // smaller than the max key + // size EVP_PKEY *ec_pkey; OSSL_PARAM params[3]; int include_pub = 1; - const unsigned char *buf3 = - aType->value.sequence->data; + const unsigned char *buf3 + = aType->value.sequence->data; unsigned char *buf4, *buf5; - if (buflen != nids_sig[j].kex_length_secret + - 7) { // no OPTIONAL - // ECParameter and no - // OPTIONAL Pubkey + if (buflen + != nids_sig[j].kex_length_secret + + 7) { // no OPTIONAL + // ECParameter and no + // OPTIONAL Pubkey OPENSSL_free(name); ASN1_TYPE_free(aType); PKCS8_PRIV_KEY_INFO_free(p8inf_internal); @@ -1339,8 +1370,8 @@ OQSX_KEY *oqsx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, params[2] = OSSL_PARAM_construct_end(); EVP_PKEY_set_params(ec_pkey, params); - buf4 = - OPENSSL_malloc(nids_sig[j].length_private_key); + buf4 = OPENSSL_malloc( + nids_sig[j].length_private_key); buf5 = buf4; buflen = i2d_PrivateKey(ec_pkey, &buf5); // encode priv @@ -1406,15 +1437,16 @@ OQSX_KEY *oqsx_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, return oqsx; } -static const int (*init_kex_fun[])(char *, OQSX_EVP_CTX *) = { - oqshybkem_init_ecp, oqshybkem_init_ecx}; +static const int (*init_kex_fun[])(char *, OQSX_EVP_CTX *) + = {oqshybkem_init_ecp, oqshybkem_init_ecx}; extern const char *oqs_oid_alg_list[]; OQSX_KEY *oqsx_key_new(OSSL_LIB_CTX *libctx, char *oqs_name, char *tls_name, int primitive, const char *propq, int bit_security, - int alg_idx, int reverse_share) { - OQSX_KEY *ret = - OPENSSL_zalloc(sizeof(*ret)); // ensure all component pointers are NULL + int alg_idx, int reverse_share) +{ + OQSX_KEY *ret = OPENSSL_zalloc( + sizeof(*ret)); // ensure all component pointers are NULL OQSX_EVP_CTX *evp_ctx = NULL; int ret2 = 0, i; @@ -1453,10 +1485,10 @@ OQSX_KEY *oqsx_key_new(OSSL_LIB_CTX *libctx, char *oqs_name, char *tls_name, goto err; } - ret->privkeylen = - ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_secret_key; - ret->pubkeylen = - ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_public_key; + ret->privkeylen + = ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_secret_key; + ret->pubkeylen + = ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_public_key; ret->keytype = KEY_TYPE_SIG; break; case KEY_TYPE_KEM: @@ -1473,10 +1505,10 @@ OQSX_KEY *oqsx_key_new(OSSL_LIB_CTX *libctx, char *oqs_name, char *tls_name, oqs_name); goto err; } - ret->privkeylen = - ret->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key; - ret->pubkeylen = - ret->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_public_key; + ret->privkeylen + = ret->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key; + ret->pubkeylen + = ret->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_public_key; ret->keytype = KEY_TYPE_KEM; break; case KEY_TYPE_ECX_HYB_KEM: @@ -1493,22 +1525,22 @@ OQSX_KEY *oqsx_key_new(OSSL_LIB_CTX *libctx, char *oqs_name, char *tls_name, evp_ctx = OPENSSL_zalloc(sizeof(OQSX_EVP_CTX)); ON_ERR_GOTO(!evp_ctx, err); - ret2 = - (init_kex_fun[primitive - KEY_TYPE_ECP_HYB_KEM])(tls_name, evp_ctx); + ret2 = (init_kex_fun[primitive - KEY_TYPE_ECP_HYB_KEM])(tls_name, + evp_ctx); ON_ERR_GOTO(ret2 <= 0 || !evp_ctx->keyParam || !evp_ctx->ctx, err); ret->numkeys = 2; ret->comp_privkey = OPENSSL_malloc(ret->numkeys * sizeof(void *)); ret->comp_pubkey = OPENSSL_malloc(ret->numkeys * sizeof(void *)); ON_ERR_GOTO(!ret->comp_privkey || !ret->comp_pubkey, err); - ret->privkeylen = - (ret->numkeys - 1) * SIZE_OF_UINT32 + - ret->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key + - evp_ctx->evp_info->length_private_key; - ret->pubkeylen = - (ret->numkeys - 1) * SIZE_OF_UINT32 + - ret->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_public_key + - evp_ctx->evp_info->length_public_key; + ret->privkeylen + = (ret->numkeys - 1) * SIZE_OF_UINT32 + + ret->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_secret_key + + evp_ctx->evp_info->length_private_key; + ret->pubkeylen + = (ret->numkeys - 1) * SIZE_OF_UINT32 + + ret->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_public_key + + evp_ctx->evp_info->length_public_key; ret->oqsx_provider_ctx.oqsx_evp_ctx = evp_ctx; ret->keytype = primitive; ret->evp_info = evp_ctx->evp_info; @@ -1533,14 +1565,14 @@ OQSX_KEY *oqsx_key_new(OSSL_LIB_CTX *libctx, char *oqs_name, char *tls_name, ret->comp_privkey = OPENSSL_malloc(ret->numkeys * sizeof(void *)); ret->comp_pubkey = OPENSSL_malloc(ret->numkeys * sizeof(void *)); ON_ERR_GOTO(!ret->comp_privkey || !ret->comp_pubkey, err); - ret->privkeylen = - (ret->numkeys - 1) * SIZE_OF_UINT32 + - ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_secret_key + - evp_ctx->evp_info->length_private_key; - ret->pubkeylen = - (ret->numkeys - 1) * SIZE_OF_UINT32 + - ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_public_key + - evp_ctx->evp_info->length_public_key; + ret->privkeylen + = (ret->numkeys - 1) * SIZE_OF_UINT32 + + ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_secret_key + + evp_ctx->evp_info->length_private_key; + ret->pubkeylen + = (ret->numkeys - 1) * SIZE_OF_UINT32 + + ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_public_key + + evp_ctx->evp_info->length_public_key; ret->oqsx_provider_ctx.oqsx_evp_ctx = evp_ctx; ret->keytype = primitive; ret->evp_info = evp_ctx->evp_info; @@ -1561,8 +1593,8 @@ OQSX_KEY *oqsx_key_new(OSSL_LIB_CTX *libctx, char *oqs_name, char *tls_name, goto err; } if (get_oqsname_fromtls(name) != 0) { - ret->oqsx_provider_ctx.oqsx_qs_ctx.sig = - OQS_SIG_new(get_oqsname_fromtls(name)); + ret->oqsx_provider_ctx.oqsx_qs_ctx.sig + = OQS_SIG_new(get_oqsname_fromtls(name)); if (!ret->oqsx_provider_ctx.oqsx_qs_ctx.sig) { fprintf(stderr, "Could not create OQS signature " @@ -1572,10 +1604,10 @@ OQSX_KEY *oqsx_key_new(OSSL_LIB_CTX *libctx, char *oqs_name, char *tls_name, name); goto err; } - ret->privkeylen_cmp[i] = - ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_secret_key; - ret->pubkeylen_cmp[i] = - ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_public_key; + ret->privkeylen_cmp[i] + = ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_secret_key; + ret->pubkeylen_cmp[i] + = ret->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_public_key; } else { evp_ctx = OPENSSL_zalloc(sizeof(OQSX_EVP_CTX)); ON_ERR_GOTO(!evp_ctx, err); @@ -1632,15 +1664,16 @@ OQSX_KEY *oqsx_key_new(OSSL_LIB_CTX *libctx, char *oqs_name, char *tls_name, return NULL; } -void oqsx_key_free(OQSX_KEY *key) { +void oqsx_key_free(OQSX_KEY *key) +{ int refcnt; if (key == NULL) return; #ifndef OQS_PROVIDER_NOATOMIC - refcnt = - atomic_fetch_sub_explicit(&key->references, 1, memory_order_relaxed) - - 1; + refcnt + = atomic_fetch_sub_explicit(&key->references, 1, memory_order_relaxed) + - 1; if (refcnt == 0) atomic_thread_fence(memory_order_acquire); #else @@ -1666,8 +1699,8 @@ void oqsx_key_free(OQSX_KEY *key) { } if (key->keytype == KEY_TYPE_KEM) OQS_KEM_free(key->oqsx_provider_ctx.oqsx_qs_ctx.kem); - else if (key->keytype == KEY_TYPE_ECP_HYB_KEM || - key->keytype == KEY_TYPE_ECX_HYB_KEM) { + else if (key->keytype == KEY_TYPE_ECP_HYB_KEM + || key->keytype == KEY_TYPE_ECX_HYB_KEM) { OQS_KEM_free(key->oqsx_provider_ctx.oqsx_qs_ctx.kem); } else OQS_SIG_free(key->oqsx_provider_ctx.oqsx_qs_ctx.sig); @@ -1684,13 +1717,14 @@ void oqsx_key_free(OQSX_KEY *key) { OPENSSL_free(key); } -int oqsx_key_up_ref(OQSX_KEY *key) { +int oqsx_key_up_ref(OQSX_KEY *key) +{ int refcnt; #ifndef OQS_PROVIDER_NOATOMIC - refcnt = - atomic_fetch_add_explicit(&key->references, 1, memory_order_relaxed) + - 1; + refcnt + = atomic_fetch_add_explicit(&key->references, 1, memory_order_relaxed) + + 1; #else CRYPTO_atomic_add(&key->references, 1, &refcnt, key->lock); #endif @@ -1702,7 +1736,8 @@ int oqsx_key_up_ref(OQSX_KEY *key) { return (refcnt > 1); } -int oqsx_key_allocate_keymaterial(OQSX_KEY *key, int include_private) { +int oqsx_key_allocate_keymaterial(OQSX_KEY *key, int include_private) +{ int ret = 0, aux = 0; if (key->keytype != KEY_TYPE_CMP_SIG) @@ -1721,11 +1756,12 @@ int oqsx_key_allocate_keymaterial(OQSX_KEY *key, int include_private) { } int oqsx_key_fromdata(OQSX_KEY *key, const OSSL_PARAM params[], - int include_private) { + int include_private) +{ const OSSL_PARAM *pp1, *pp2; - int classic_lengths_fixed = key->keytype == KEY_TYPE_ECP_HYB_KEM || - key->keytype == KEY_TYPE_ECX_HYB_KEM; + int classic_lengths_fixed = key->keytype == KEY_TYPE_ECP_HYB_KEM + || key->keytype == KEY_TYPE_ECX_HYB_KEM; OQS_KEY_PRINTF("OQSX Key from data called\n"); pp1 = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY); @@ -1769,15 +1805,16 @@ int oqsx_key_fromdata(OQSX_KEY *key, const OSSL_PARAM params[], } memcpy(key->pubkey, pp2->data, pp2->data_size); } - if (!oqsx_key_set_composites(key, classic_lengths_fixed) || - !oqsx_key_recreate_classickey( + if (!oqsx_key_set_composites(key, classic_lengths_fixed) + || !oqsx_key_recreate_classickey( key, key->privkey != NULL ? KEY_OP_PRIVATE : KEY_OP_PUBLIC)) return 0; return 1; } // OQS key always the last of the numkeys comp keys -static int oqsx_key_gen_oqs(OQSX_KEY *key, int gen_kem) { +static int oqsx_key_gen_oqs(OQSX_KEY *key, int gen_kem) +{ int idx_pq; oqsx_comp_set_idx(key, NULL, &idx_pq); @@ -1797,7 +1834,8 @@ static int oqsx_key_gen_oqs(OQSX_KEY *key, int gen_kem) { */ static EVP_PKEY *oqsx_key_gen_evp_key_sig(OQSX_EVP_CTX *ctx, unsigned char *pubkey, - unsigned char *privkey, int encode) { + unsigned char *privkey, int encode) +{ int ret = 0, ret2 = 0, aux = 0; // Free at errhyb: @@ -1833,38 +1871,38 @@ static EVP_PKEY *oqsx_key_gen_evp_key_sig(OQSX_EVP_CTX *ctx, if (ctx->evp_info->raw_key_support) { // TODO: If available, use preallocated memory - if (ctx->evp_info->nid != NID_ED25519 && - ctx->evp_info->nid != NID_ED448) { + if (ctx->evp_info->nid != NID_ED25519 + && ctx->evp_info->nid != NID_ED448) { pubkeylen = EVP_PKEY_get1_encoded_public_key(pkey, &pubkey_encoded); - ON_ERR_SET_GOTO(pubkeylen != ctx->evp_info->length_public_key || - !pubkey_encoded, + ON_ERR_SET_GOTO(pubkeylen != ctx->evp_info->length_public_key + || !pubkey_encoded, ret, -3, errhyb); memcpy(pubkey + aux, pubkey_encoded, pubkeylen); } else { pubkeylen = ctx->evp_info->length_public_key; ret2 = EVP_PKEY_get_raw_public_key(pkey, pubkey + aux, &pubkeylen); - ON_ERR_SET_GOTO(ret2 <= 0 || - pubkeylen != ctx->evp_info->length_public_key, - ret, -3, errhyb); + ON_ERR_SET_GOTO( + ret2 <= 0 || pubkeylen != ctx->evp_info->length_public_key, ret, + -3, errhyb); } privkeylen = ctx->evp_info->length_private_key; ret2 = EVP_PKEY_get_raw_private_key(pkey, privkey + aux, &privkeylen); - ON_ERR_SET_GOTO(ret2 <= 0 || - privkeylen != ctx->evp_info->length_private_key, + ON_ERR_SET_GOTO(ret2 <= 0 + || privkeylen != ctx->evp_info->length_private_key, ret, -4, errhyb); } else { unsigned char *pubkey_enc = pubkey + aux; const unsigned char *pubkey_enc2 = pubkey + aux; pubkeylen = i2d_PublicKey(pkey, &pubkey_enc); - ON_ERR_SET_GOTO(!pubkey_enc || - pubkeylen > (int)ctx->evp_info->length_public_key, - ret, -11, errhyb); + ON_ERR_SET_GOTO( + !pubkey_enc || pubkeylen > (int)ctx->evp_info->length_public_key, + ret, -11, errhyb); unsigned char *privkey_enc = privkey + aux; const unsigned char *privkey_enc2 = privkey + aux; privkeylen = i2d_PrivateKey(pkey, &privkey_enc); - ON_ERR_SET_GOTO(!privkey_enc || - privkeylen > (int)ctx->evp_info->length_private_key, - ret, -12, errhyb); + ON_ERR_SET_GOTO( + !privkey_enc || privkeylen > (int)ctx->evp_info->length_private_key, + ret, -12, errhyb); // selftest: EVP_PKEY *ck2 = d2i_PrivateKey(ctx->evp_info->keytype, NULL, &privkey_enc2, privkeylen); @@ -1894,7 +1932,8 @@ static EVP_PKEY *oqsx_key_gen_evp_key_sig(OQSX_EVP_CTX *ctx, * pubkey/privkey buffers; returned EVP_PKEY must be freed if not used */ static EVP_PKEY *oqsx_key_gen_evp_key_kem(OQSX_KEY *key, unsigned char *pubkey, - unsigned char *privkey, int encode) { + unsigned char *privkey, int encode) +{ int ret = 0, ret2 = 0, aux = 0; // Free at errhyb: @@ -1923,38 +1962,38 @@ static EVP_PKEY *oqsx_key_gen_evp_key_kem(OQSX_KEY *key, unsigned char *pubkey, if (ctx->evp_info->raw_key_support) { // TODO: If available, use preallocated memory - if (ctx->evp_info->nid != NID_ED25519 && - ctx->evp_info->nid != NID_ED448) { + if (ctx->evp_info->nid != NID_ED25519 + && ctx->evp_info->nid != NID_ED448) { pubkeylen = EVP_PKEY_get1_encoded_public_key(pkey, &pubkey_encoded); - ON_ERR_SET_GOTO(pubkeylen != ctx->evp_info->length_public_key || - !pubkey_encoded, + ON_ERR_SET_GOTO(pubkeylen != ctx->evp_info->length_public_key + || !pubkey_encoded, ret, -3, errhyb); memcpy(pubkey + aux, pubkey_encoded, pubkeylen); } else { pubkeylen = ctx->evp_info->length_public_key; ret2 = EVP_PKEY_get_raw_public_key(pkey, pubkey + aux, &pubkeylen); - ON_ERR_SET_GOTO(ret2 <= 0 || - pubkeylen != ctx->evp_info->length_public_key, - ret, -3, errhyb); + ON_ERR_SET_GOTO( + ret2 <= 0 || pubkeylen != ctx->evp_info->length_public_key, ret, + -3, errhyb); } privkeylen = ctx->evp_info->length_private_key; ret2 = EVP_PKEY_get_raw_private_key(pkey, privkey + aux, &privkeylen); - ON_ERR_SET_GOTO(ret2 <= 0 || - privkeylen != ctx->evp_info->length_private_key, + ON_ERR_SET_GOTO(ret2 <= 0 + || privkeylen != ctx->evp_info->length_private_key, ret, -4, errhyb); } else { unsigned char *pubkey_enc = pubkey + aux; const unsigned char *pubkey_enc2 = pubkey + aux; pubkeylen = i2d_PublicKey(pkey, &pubkey_enc); - ON_ERR_SET_GOTO(!pubkey_enc || - pubkeylen > (int)ctx->evp_info->length_public_key, - ret, -11, errhyb); + ON_ERR_SET_GOTO( + !pubkey_enc || pubkeylen > (int)ctx->evp_info->length_public_key, + ret, -11, errhyb); unsigned char *privkey_enc = privkey + aux; const unsigned char *privkey_enc2 = privkey + aux; privkeylen = i2d_PrivateKey(pkey, &privkey_enc); - ON_ERR_SET_GOTO(!privkey_enc || - privkeylen > (int)ctx->evp_info->length_private_key, - ret, -12, errhyb); + ON_ERR_SET_GOTO( + !privkey_enc || privkeylen > (int)ctx->evp_info->length_private_key, + ret, -12, errhyb); // selftest: EVP_PKEY *ck2 = d2i_PrivateKey(ctx->evp_info->keytype, NULL, &privkey_enc2, privkeylen); @@ -1981,13 +2020,14 @@ static EVP_PKEY *oqsx_key_gen_evp_key_kem(OQSX_KEY *key, unsigned char *pubkey, } /* allocates OQS and classical keys */ -int oqsx_key_gen(OQSX_KEY *key) { +int oqsx_key_gen(OQSX_KEY *key) +{ int ret = 0; EVP_PKEY *pkey = NULL; if (key->privkey == NULL || key->pubkey == NULL) { - ret = oqsx_key_allocate_keymaterial(key, 0) || - oqsx_key_allocate_keymaterial(key, 1); + ret = oqsx_key_allocate_keymaterial(key, 0) + || oqsx_key_allocate_keymaterial(key, 1); ON_ERR_GOTO(ret, err_gen); } @@ -2006,8 +2046,8 @@ int oqsx_key_gen(OQSX_KEY *key) { key->classical_pkey = pkey; ret = oqsx_key_gen_oqs(key, key->keytype != KEY_TYPE_HYB_SIG); - } else if (key->keytype == KEY_TYPE_ECP_HYB_KEM || - key->keytype == KEY_TYPE_ECX_HYB_KEM) { + } else if (key->keytype == KEY_TYPE_ECP_HYB_KEM + || key->keytype == KEY_TYPE_ECX_HYB_KEM) { int idx_classic; oqsx_comp_set_idx(key, &idx_classic, NULL); @@ -2039,9 +2079,9 @@ int oqsx_key_gen(OQSX_KEY *key) { ON_ERR_GOTO(pkey == NULL, err_gen); key->classical_pkey = pkey; } else { - ret = - OQS_SIG_keypair(key->oqsx_provider_ctx.oqsx_qs_ctx.sig, - key->comp_pubkey[i], key->comp_privkey[i]); + ret = OQS_SIG_keypair(key->oqsx_provider_ctx.oqsx_qs_ctx.sig, + key->comp_pubkey[i], + key->comp_privkey[i]); OPENSSL_free(name); ON_ERR_GOTO(ret, err_gen); } @@ -2061,27 +2101,30 @@ int oqsx_key_gen(OQSX_KEY *key) { return ret; } -int oqsx_key_secbits(OQSX_KEY *key) { return key->bit_security; } +int oqsx_key_secbits(OQSX_KEY *key) +{ + return key->bit_security; +} -int oqsx_key_maxsize(OQSX_KEY *key) { +int oqsx_key_maxsize(OQSX_KEY *key) +{ switch (key->keytype) { case KEY_TYPE_KEM: return key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_shared_secret; case KEY_TYPE_ECP_HYB_KEM: case KEY_TYPE_ECX_HYB_KEM: - return key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info - ->kex_length_secret + - key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_shared_secret; + return key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->kex_length_secret + + key->oqsx_provider_ctx.oqsx_qs_ctx.kem->length_shared_secret; case KEY_TYPE_SIG: return key->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_signature; case KEY_TYPE_HYB_SIG: - return key->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_signature + - key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->length_signature + - SIZE_OF_UINT32; + return key->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_signature + + key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->length_signature + + SIZE_OF_UINT32; case KEY_TYPE_CMP_SIG: - return sizeof(CompositeSignature) + - key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->length_signature + - key->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_signature; + return sizeof(CompositeSignature) + + key->oqsx_provider_ctx.oqsx_evp_ctx->evp_info->length_signature + + key->oqsx_provider_ctx.oqsx_qs_ctx.sig->length_signature; default: OQS_KEY_PRINTF("OQSX KEY: Wrong key type\n"); @@ -2089,7 +2132,8 @@ int oqsx_key_maxsize(OQSX_KEY *key) { } } -int oqsx_key_get_oqs_public_key_len(OQSX_KEY *k) { +int oqsx_key_get_oqs_public_key_len(OQSX_KEY *k) +{ switch (k->keytype) { case KEY_TYPE_SIG: case KEY_TYPE_KEM: diff --git a/test/oqs_test_endecode.c b/test/oqs_test_endecode.c index 0e498e37..999ba8d3 100644 --- a/test/oqs_test_endecode.c +++ b/test/oqs_test_endecode.c @@ -52,7 +52,8 @@ static ENDECODE_PARAMS test_params_list[] = { }; static EVP_PKEY *oqstest_make_key(const char *type, EVP_PKEY *template, - OSSL_PARAM *genparams) { + OSSL_PARAM *genparams) +{ EVP_PKEY *pkey = NULL; EVP_PKEY_CTX *ctx = NULL; @@ -69,24 +70,25 @@ static EVP_PKEY *oqstest_make_key(const char *type, EVP_PKEY *template, * No real need to check the errors other than for the cascade * effect. |pkey| will simply remain NULL if something goes wrong. */ - (void)(ctx != NULL && EVP_PKEY_keygen_init(ctx) > 0 && - (genparams == NULL || EVP_PKEY_CTX_set_params(ctx, genparams) > 0) && - EVP_PKEY_keygen(ctx, &pkey) > 0); + (void)(ctx != NULL && EVP_PKEY_keygen_init(ctx) > 0 + && (genparams == NULL || EVP_PKEY_CTX_set_params(ctx, genparams) > 0) + && EVP_PKEY_keygen(ctx, &pkey) > 0); EVP_PKEY_CTX_free(ctx); return pkey; } static int encode_EVP_PKEY_prov(const EVP_PKEY *pkey, const char *format, const char *structure, const char *pass, - const int selection, BUF_MEM **encoded) { + const int selection, BUF_MEM **encoded) +{ OSSL_ENCODER_CTX *ectx; BIO *mem_ser = NULL; BUF_MEM *mem_buf = NULL; const char *cipher = "AES-256-CBC"; int ok = 0; - ectx = - OSSL_ENCODER_CTX_new_for_pkey(pkey, selection, format, structure, NULL); + ectx = OSSL_ENCODER_CTX_new_for_pkey(pkey, selection, format, structure, + NULL); if (ectx == NULL) { printf("No suitable encoder found\n"); goto end; @@ -126,7 +128,8 @@ static int encode_EVP_PKEY_prov(const EVP_PKEY *pkey, const char *format, static int decode_EVP_PKEY_prov(const char *input_type, const char *structure, const char *pass, const char *keytype, const int selection, EVP_PKEY **object, - const void *encoded, const long encoded_len) { + const void *encoded, const long encoded_len) +{ EVP_PKEY *pkey = NULL; OSSL_DECODER_CTX *dctx = NULL; BIO *encoded_bio = NULL; @@ -163,7 +166,8 @@ static int decode_EVP_PKEY_prov(const char *input_type, const char *structure, return ok; } -static int test_oqs_encdec(const char *alg_name) { +static int test_oqs_encdec(const char *alg_name) +{ EVP_PKEY *pkey = NULL; EVP_PKEY *decoded_pkey = NULL; BUF_MEM *encoded = NULL; @@ -215,7 +219,8 @@ static int test_oqs_encdec(const char *alg_name) { return ok; } -static int test_algs(const OSSL_ALGORITHM *algs) { +static int test_algs(const OSSL_ALGORITHM *algs) +{ int errcnt = 0; for (; algs->algorithm_names != NULL; algs++) { if (test_oqs_encdec(algs->algorithm_names)) { @@ -233,7 +238,8 @@ static int test_algs(const OSSL_ALGORITHM *algs) { return errcnt; } -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ size_t i; int errcnt = 0, test = 0, query_nocache; OSSL_PROVIDER *oqsprov = NULL; diff --git a/test/oqs_test_evp_pkey_params.c b/test/oqs_test_evp_pkey_params.c index b00c05c2..8d335982 100644 --- a/test/oqs_test_evp_pkey_params.c +++ b/test/oqs_test_evp_pkey_params.c @@ -70,7 +70,8 @@ const char *kHybridKEMAlgorithms[] = { * \param s String to test. * * \return 1 if `s` is in `list`, else 0. */ -static int is_string_in_list(const char **list, const char *s) { +static int is_string_in_list(const char **list, const char *s) +{ for (; *list != NULL && strcmp(*list, s) != 0; ++list) ; if (*list != NULL) { @@ -84,7 +85,7 @@ static int is_string_in_list(const char **list, const char *s) { * \param alg Algorithm name. * * \returns 1 if hybrid, else 0. */ -#define is_signature_algorithm_hybrid(_alg_) \ +#define is_signature_algorithm_hybrid(_alg_) \ is_string_in_list(kHybridSignatureAlgorithms, (_alg_)) /** \brief Indicates if an kem algorithm is hybrid or not. @@ -92,7 +93,7 @@ static int is_string_in_list(const char **list, const char *s) { * \param alg Algorithm name. * * \returns 1 if hybrid, else 0. */ -#define is_kem_algorithm_hybrid(_alg_) \ +#define is_kem_algorithm_hybrid(_alg_) \ is_string_in_list(kHybridKEMAlgorithms, (_alg_)) /** \brief A pair of keys. */ @@ -117,7 +118,8 @@ struct KeyPair { /** \brief Frees the memory occupied by a KeyPair. * * \param kp Keypair to free. */ -static void keypair_free(struct KeyPair *kp) { +static void keypair_free(struct KeyPair *kp) +{ free(kp->pubkey); free(kp->privkey); } @@ -125,7 +127,8 @@ static void keypair_free(struct KeyPair *kp) { /** \brief Initializes an OpenSSL top-level context. * * \returns The top-level context, or `NULL` if an error occurred. */ -static OSSL_LIB_CTX *init_openssl(void) { +static OSSL_LIB_CTX *init_openssl(void) +{ OSSL_LIB_CTX *ctx; if (!(ctx = OSSL_LIB_CTX_new())) { @@ -142,7 +145,8 @@ static OSSL_LIB_CTX *init_openssl(void) { * \paran alg The algorithm to use. * * \returns The EVP_PKEY context, or `NULL` if an error occurred. */ -static EVP_PKEY_CTX *init_EVP_PKEY_CTX(OSSL_LIB_CTX *libctx, const char *alg) { +static EVP_PKEY_CTX *init_EVP_PKEY_CTX(OSSL_LIB_CTX *libctx, const char *alg) +{ EVP_PKEY_CTX *ctx; if (!(ctx = EVP_PKEY_CTX_new_from_name(libctx, alg, NULL))) { @@ -161,7 +165,8 @@ static EVP_PKEY_CTX *init_EVP_PKEY_CTX(OSSL_LIB_CTX *libctx, const char *alg) { * \param ctx EVP_PKEY context. * * \returns 0 on success. */ -static int init_keygen(EVP_PKEY_CTX *ctx) { +static int init_keygen(EVP_PKEY_CTX *ctx) +{ int err; if ((err = EVP_PKEY_keygen_init(ctx)) == -2) { @@ -185,7 +190,8 @@ static int init_keygen(EVP_PKEY_CTX *ctx) { * \param ctx EVP_PKEY context. * * \returns The private key, or `NULL` if an error occurred. */ -static EVP_PKEY *generate_private_key(EVP_PKEY_CTX *ctx) { +static EVP_PKEY *generate_private_key(EVP_PKEY_CTX *ctx) +{ EVP_PKEY *private_key = NULL; int err; @@ -211,13 +217,14 @@ static EVP_PKEY *generate_private_key(EVP_PKEY_CTX *ctx) { * * \returns 0 on success. */ static int get_param_octet_string(const EVP_PKEY *key, const char *param_name, - uint8_t **buf, size_t *buf_len) { + uint8_t **buf, size_t *buf_len) +{ *buf = NULL; *buf_len = 0; int ret = -1; - if (EVP_PKEY_get_octet_string_param(key, param_name, NULL, 0, buf_len) != - 1) { + if (EVP_PKEY_get_octet_string_param(key, param_name, NULL, 0, buf_len) + != 1) { fprintf(stderr, cRED "`EVP_PKEY_get_octet_string_param` failed with param `%s`: ", @@ -231,7 +238,8 @@ static int get_param_octet_string(const EVP_PKEY *key, const char *param_name, goto out; } if (EVP_PKEY_get_octet_string_param(key, param_name, *buf, *buf_len, - buf_len) != 1) { + buf_len) + != 1) { fprintf(stderr, cRED "`EVP_PKEY_get_octet_string_param` failed with param `%s`: ", @@ -255,7 +263,8 @@ static int get_param_octet_string(const EVP_PKEY *key, const char *param_name, * * \returns 0 on success. */ static int private_key_params_get_classical_keys(const EVP_PKEY *private_key, - struct KeyPair *out) { + struct KeyPair *out) +{ int ret = -1; if (get_param_octet_string(private_key, @@ -285,7 +294,8 @@ static int private_key_params_get_classical_keys(const EVP_PKEY *private_key, * * \returns 0 on success. */ static int private_key_params_get_pq_keys(const EVP_PKEY *private_key, - struct KeyPair *out) { + struct KeyPair *out) +{ int ret = -1; if (get_param_octet_string(private_key, OQS_HYBRID_PKEY_PARAM_PQ_PUB_KEY, @@ -314,7 +324,8 @@ static int private_key_params_get_pq_keys(const EVP_PKEY *private_key, * * \returns 0 on success. */ static int private_key_params_get_full_keys(const EVP_PKEY *private_key, - struct KeyPair *out) { + struct KeyPair *out) +{ int ret = -1; if (get_param_octet_string(private_key, OSSL_PKEY_PARAM_PUB_KEY, @@ -349,7 +360,8 @@ static int private_key_params_get_full_keys(const EVP_PKEY *private_key, * \returns 0 on success. */ static int reconstitute_keys(const uint8_t *classical, const size_t classical_n, const uint8_t *pq, const size_t pq_n, int reverse, - uint8_t **buf, size_t *buf_len) { + uint8_t **buf, size_t *buf_len) +{ uint32_t header; int ret = -1; @@ -387,7 +399,8 @@ static int reconstitute_keys(const uint8_t *classical, const size_t classical_n, * \returns 0 on success. */ static int keypairs_verify_consistency(const struct KeyPair *classical, const struct KeyPair *pq, - const struct KeyPair *comb) { + const struct KeyPair *comb) +{ uint8_t *reconstitution, *reconstitution_rev; size_t n; int ret = -1; @@ -407,8 +420,8 @@ static int keypairs_verify_consistency(const struct KeyPair *classical, comb->pubkey_len, n); goto free_reconstitute; } - if (memcmp(reconstitution, comb->pubkey, n) && - memcmp(reconstitution_rev, comb->pubkey, n)) { + if (memcmp(reconstitution, comb->pubkey, n) + && memcmp(reconstitution_rev, comb->pubkey, n)) { fputs(cRED "pubkey and comb->pubkey differ " cNORM "\n", stderr); fputs(cRED "pubkey: ", stderr); hexdump(reconstitution, n); @@ -437,8 +450,8 @@ static int keypairs_verify_consistency(const struct KeyPair *classical, comb->privkey_len, n); goto free_reconstitute; } - if (memcmp(reconstitution, comb->privkey, n) && - memcmp(reconstitution_rev, comb->privkey, n)) { + if (memcmp(reconstitution, comb->privkey, n) + && memcmp(reconstitution_rev, comb->privkey, n)) { fputs(cRED "privkey and comb->privkey differ" cNORM "\n", stderr); fputs(cRED "privkey: ", stderr); hexdump(reconstitution, n); @@ -463,7 +476,8 @@ static int keypairs_verify_consistency(const struct KeyPair *classical, * \param algname Algorithm name. * * \returns 0 on success. */ -static int test_algorithm(OSSL_LIB_CTX *libctx, const char *algname) { +static int test_algorithm(OSSL_LIB_CTX *libctx, const char *algname) +{ EVP_PKEY_CTX *evp_pkey_ctx; EVP_PKEY *private_key; struct KeyPair classical_keypair; @@ -519,7 +533,8 @@ static int test_algorithm(OSSL_LIB_CTX *libctx, const char *algname) { return ret; } -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ OSSL_LIB_CTX *libctx; OSSL_PROVIDER *default_provider; OSSL_PROVIDER *oqs_provider; diff --git a/test/oqs_test_groups.c b/test/oqs_test_groups.c index cb1485ab..5ed9fd13 100644 --- a/test/oqs_test_groups.c +++ b/test/oqs_test_groups.c @@ -15,7 +15,8 @@ static char *cert = NULL; static char *privkey = NULL; static char *certsdir = NULL; -char *test_mk_file_path(const char *dir, const char *file) { +char *test_mk_file_path(const char *dir, const char *file) +{ #ifndef OPENSSL_SYS_VMS const char *sep = "/"; #else @@ -33,7 +34,8 @@ char *test_mk_file_path(const char *dir, const char *file) { return full_file; } -static int test_oqs_groups(const char *group_name) { +static int test_oqs_groups(const char *group_name) +{ SSL_CTX *cctx = NULL, *sctx = NULL; SSL *clientssl = NULL, *serverssl = NULL; int ret = 1, testresult = 0; @@ -82,11 +84,12 @@ static int test_oqs_groups(const char *group_name) { return ret; } -static int test_group(const OSSL_PARAM params[], void *data) { +static int test_group(const OSSL_PARAM params[], void *data) +{ int ret = 1; int *errcnt = (int *)data; - const OSSL_PARAM *p = - OSSL_PARAM_locate_const(params, OSSL_CAPABILITY_TLS_GROUP_NAME); + const OSSL_PARAM *p + = OSSL_PARAM_locate_const(params, OSSL_CAPABILITY_TLS_GROUP_NAME); if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING) { ret = -1; goto err; @@ -115,7 +118,8 @@ static int test_group(const OSSL_PARAM params[], void *data) { return ret; } -static int test_provider_groups(OSSL_PROVIDER *provider, void *vctx) { +static int test_provider_groups(OSSL_PROVIDER *provider, void *vctx) +{ const char *provname = OSSL_PROVIDER_get0_name(provider); if (!strcmp(provname, PROVIDER_NAME_OQS)) @@ -125,7 +129,8 @@ static int test_provider_groups(OSSL_PROVIDER *provider, void *vctx) { return 1; } -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ size_t i; int errcnt = 0, test = 0; diff --git a/test/oqs_test_kems.c b/test/oqs_test_kems.c index 9797776e..00567be1 100644 --- a/test/oqs_test_kems.c +++ b/test/oqs_test_kems.c @@ -11,7 +11,8 @@ static OSSL_LIB_CTX *libctx = NULL; static char *modulename = NULL; static char *configfile = NULL; -static int test_oqs_kems(const char *kemalg_name) { +static int test_oqs_kems(const char *kemalg_name) +{ EVP_MD_CTX *mdctx = NULL; EVP_PKEY_CTX *ctx = NULL; EVP_PKEY *key = NULL; @@ -30,38 +31,39 @@ static int test_oqs_kems(const char *kemalg_name) { // TBD revisit when hybrids are activated: They always need default // provider if (OSSL_PROVIDER_available(libctx, "default")) { - testresult &= (ctx = EVP_PKEY_CTX_new_from_name(libctx, kemalg_name, - NULL)) != NULL && - EVP_PKEY_keygen_init(ctx) && EVP_PKEY_generate(ctx, &key); + testresult + &= (ctx = EVP_PKEY_CTX_new_from_name(libctx, kemalg_name, NULL)) + != NULL + && EVP_PKEY_keygen_init(ctx) && EVP_PKEY_generate(ctx, &key); if (!testresult) goto err; EVP_PKEY_CTX_free(ctx); ctx = NULL; - testresult &= - (ctx = EVP_PKEY_CTX_new_from_pkey(libctx, key, NULL)) != NULL && - EVP_PKEY_encapsulate_init(ctx, NULL) && - EVP_PKEY_encapsulate(ctx, NULL, &outlen, NULL, &seclen) && - (out = OPENSSL_malloc(outlen)) != NULL && - (secenc = OPENSSL_malloc(seclen)) != NULL && - memset(secenc, 0x11, seclen) != NULL && - (secdec = OPENSSL_malloc(seclen)) != NULL && - memset(secdec, 0xff, seclen) != NULL && - EVP_PKEY_encapsulate(ctx, out, &outlen, secenc, &seclen) && - EVP_PKEY_decapsulate_init(ctx, NULL) && - EVP_PKEY_decapsulate(ctx, secdec, &seclen, out, outlen) && - memcmp(secenc, secdec, seclen) == 0; + testresult + &= (ctx = EVP_PKEY_CTX_new_from_pkey(libctx, key, NULL)) != NULL + && EVP_PKEY_encapsulate_init(ctx, NULL) + && EVP_PKEY_encapsulate(ctx, NULL, &outlen, NULL, &seclen) + && (out = OPENSSL_malloc(outlen)) != NULL + && (secenc = OPENSSL_malloc(seclen)) != NULL + && memset(secenc, 0x11, seclen) != NULL + && (secdec = OPENSSL_malloc(seclen)) != NULL + && memset(secdec, 0xff, seclen) != NULL + && EVP_PKEY_encapsulate(ctx, out, &outlen, secenc, &seclen) + && EVP_PKEY_decapsulate_init(ctx, NULL) + && EVP_PKEY_decapsulate(ctx, secdec, &seclen, out, outlen) + && memcmp(secenc, secdec, seclen) == 0; if (!testresult) goto err; out[0] = ~out[0]; out[outlen - 1] = ~out[outlen - 1]; - testresult &= - memset(secdec, 0xff, seclen) != NULL && - EVP_PKEY_decapsulate_init(ctx, NULL) && - (EVP_PKEY_decapsulate(ctx, secdec, &seclen, out, outlen) || 1) && - memcmp(secenc, secdec, seclen) != 0; + testresult + &= memset(secdec, 0xff, seclen) != NULL + && EVP_PKEY_decapsulate_init(ctx, NULL) + && (EVP_PKEY_decapsulate(ctx, secdec, &seclen, out, outlen) || 1) + && memcmp(secenc, secdec, seclen) != 0; } err: @@ -75,7 +77,8 @@ static int test_oqs_kems(const char *kemalg_name) { #define nelem(a) (sizeof(a) / sizeof((a)[0])) -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ size_t i; int errcnt = 0, test = 0, query_nocache; OSSL_PROVIDER *oqsprov = NULL; @@ -90,8 +93,8 @@ int main(int argc, char *argv[]) { oqsprov = OSSL_PROVIDER_load(libctx, modulename); - kemalgs = - OSSL_PROVIDER_query_operation(oqsprov, OSSL_OP_KEM, &query_nocache); + kemalgs + = OSSL_PROVIDER_query_operation(oqsprov, OSSL_OP_KEM, &query_nocache); if (kemalgs) { for (; kemalgs->algorithm_names != NULL; kemalgs++) { if (test_oqs_kems(kemalgs->algorithm_names)) { diff --git a/test/oqs_test_signatures.c b/test/oqs_test_signatures.c index 47c8728e..71117790 100644 --- a/test/oqs_test_signatures.c +++ b/test/oqs_test_signatures.c @@ -16,7 +16,8 @@ static char *srpvfile = NULL; static char *tmpfilename = NULL; // sign-and-hash must work with and without providing a digest algorithm -static int test_oqs_signatures(const char *sigalg_name) { +static int test_oqs_signatures(const char *sigalg_name) +{ EVP_MD_CTX *mdctx = NULL; EVP_PKEY_CTX *ctx = NULL; EVP_PKEY *key = NULL; @@ -34,26 +35,26 @@ static int test_oqs_signatures(const char *sigalg_name) { // TBD revisit when hybrids are activated: They always need default // provider if (OSSL_PROVIDER_available(libctx, "default")) { - testresult &= - (ctx = EVP_PKEY_CTX_new_from_name(libctx, sigalg_name, NULL)) != - NULL && - EVP_PKEY_keygen_init(ctx) && EVP_PKEY_generate(ctx, &key) && - (mdctx = EVP_MD_CTX_new()) != NULL && - EVP_DigestSignInit_ex(mdctx, NULL, "SHA512", libctx, NULL, key, - NULL) && - EVP_DigestSignUpdate(mdctx, msg, sizeof(msg)) && - EVP_DigestSignFinal(mdctx, NULL, &siglen) && - (sig = OPENSSL_malloc(siglen)) != NULL && - EVP_DigestSignFinal(mdctx, sig, &siglen) && - EVP_DigestVerifyInit_ex(mdctx, NULL, "SHA512", libctx, NULL, key, - NULL) && - EVP_DigestVerifyUpdate(mdctx, msg, sizeof(msg)) && - EVP_DigestVerifyFinal(mdctx, sig, siglen); + testresult + &= (ctx = EVP_PKEY_CTX_new_from_name(libctx, sigalg_name, NULL)) + != NULL + && EVP_PKEY_keygen_init(ctx) && EVP_PKEY_generate(ctx, &key) + && (mdctx = EVP_MD_CTX_new()) != NULL + && EVP_DigestSignInit_ex(mdctx, NULL, "SHA512", libctx, NULL, + key, NULL) + && EVP_DigestSignUpdate(mdctx, msg, sizeof(msg)) + && EVP_DigestSignFinal(mdctx, NULL, &siglen) + && (sig = OPENSSL_malloc(siglen)) != NULL + && EVP_DigestSignFinal(mdctx, sig, &siglen) + && EVP_DigestVerifyInit_ex(mdctx, NULL, "SHA512", libctx, NULL, + key, NULL) + && EVP_DigestVerifyUpdate(mdctx, msg, sizeof(msg)) + && EVP_DigestVerifyFinal(mdctx, sig, siglen); sig[0] = ~sig[0]; testresult &= EVP_DigestVerifyInit_ex(mdctx, NULL, "SHA512", libctx, - NULL, key, NULL) && - EVP_DigestVerifyUpdate(mdctx, msg, sizeof(msg)) && - !EVP_DigestVerifyFinal(mdctx, sig, siglen); + NULL, key, NULL) + && EVP_DigestVerifyUpdate(mdctx, msg, sizeof(msg)) + && !EVP_DigestVerifyFinal(mdctx, sig, siglen); } EVP_MD_CTX_free(mdctx); @@ -64,23 +65,24 @@ static int test_oqs_signatures(const char *sigalg_name) { key = NULL; // this test must work also with default provider inactive: - testresult &= - (ctx = EVP_PKEY_CTX_new_from_name(libctx, sigalg_name, NULL)) != NULL && - EVP_PKEY_keygen_init(ctx) && EVP_PKEY_generate(ctx, &key) && - (mdctx = EVP_MD_CTX_new()) != NULL && - EVP_DigestSignInit_ex(mdctx, NULL, NULL, libctx, NULL, key, NULL) && - EVP_DigestSignUpdate(mdctx, msg, sizeof(msg)) && - EVP_DigestSignFinal(mdctx, NULL, &siglen) && - (sig = OPENSSL_malloc(siglen)) != NULL && - EVP_DigestSignFinal(mdctx, sig, &siglen) && - EVP_DigestVerifyInit_ex(mdctx, NULL, NULL, libctx, NULL, key, NULL) && - EVP_DigestVerifyUpdate(mdctx, msg, sizeof(msg)) && - EVP_DigestVerifyFinal(mdctx, sig, siglen); + testresult + &= (ctx = EVP_PKEY_CTX_new_from_name(libctx, sigalg_name, NULL)) != NULL + && EVP_PKEY_keygen_init(ctx) && EVP_PKEY_generate(ctx, &key) + && (mdctx = EVP_MD_CTX_new()) != NULL + && EVP_DigestSignInit_ex(mdctx, NULL, NULL, libctx, NULL, key, NULL) + && EVP_DigestSignUpdate(mdctx, msg, sizeof(msg)) + && EVP_DigestSignFinal(mdctx, NULL, &siglen) + && (sig = OPENSSL_malloc(siglen)) != NULL + && EVP_DigestSignFinal(mdctx, sig, &siglen) + && EVP_DigestVerifyInit_ex(mdctx, NULL, NULL, libctx, NULL, key, + NULL) + && EVP_DigestVerifyUpdate(mdctx, msg, sizeof(msg)) + && EVP_DigestVerifyFinal(mdctx, sig, siglen); sig[0] = ~sig[0]; - testresult &= - EVP_DigestVerifyInit_ex(mdctx, NULL, NULL, libctx, NULL, key, NULL) && - EVP_DigestVerifyUpdate(mdctx, msg, sizeof(msg)) && - !EVP_DigestVerifyFinal(mdctx, sig, siglen); + testresult + &= EVP_DigestVerifyInit_ex(mdctx, NULL, NULL, libctx, NULL, key, NULL) + && EVP_DigestVerifyUpdate(mdctx, msg, sizeof(msg)) + && !EVP_DigestVerifyFinal(mdctx, sig, siglen); EVP_MD_CTX_free(mdctx); EVP_PKEY_free(key); @@ -91,7 +93,8 @@ static int test_oqs_signatures(const char *sigalg_name) { #define nelem(a) (sizeof(a) / sizeof((a)[0])) -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ size_t i; int errcnt = 0, test = 0, query_nocache; OSSL_PROVIDER *oqsprov = NULL; diff --git a/test/oqs_test_tlssig.c b/test/oqs_test_tlssig.c index 5e653f56..60157f3e 100644 --- a/test/oqs_test_tlssig.c +++ b/test/oqs_test_tlssig.c @@ -18,17 +18,18 @@ static char *configfile = NULL; static char *certsdir = NULL; #ifdef OSSL_CAPABILITY_TLS_SIGALG_NAME -static int test_oqs_tlssig(const char *sig_name) { +static int test_oqs_tlssig(const char *sig_name) +{ SSL_CTX *cctx = NULL, *sctx = NULL; SSL *clientssl = NULL, *serverssl = NULL; int ret = 1, testresult = 0; char certpath[300]; char privkeypath[300]; -#ifndef OPENSSL_SYS_VMS +# ifndef OPENSSL_SYS_VMS const char *sep = "/"; -#else +# else const char *sep = ""; -#endif +# endif if (!alg_is_enabled(sig_name)) { printf("Not testing disabled algorithm %s.\n", sig_name); @@ -53,8 +54,8 @@ static int test_oqs_tlssig(const char *sig_name) { goto err; } - testresult = - create_tls1_3_ctx_pair(libctx, &sctx, &cctx, certpath, privkeypath); + testresult + = create_tls1_3_ctx_pair(libctx, &sctx, &cctx, certpath, privkeypath); if (!testresult) { ret = -1; @@ -93,11 +94,12 @@ EVP_SIGNATURE_get0_name(evpsig)); } */ -static int test_signature(const OSSL_PARAM params[], void *data) { +static int test_signature(const OSSL_PARAM params[], void *data) +{ int ret = 0; int *errcnt = (int *)data; - const OSSL_PARAM *p = - OSSL_PARAM_locate_const(params, OSSL_CAPABILITY_TLS_SIGALG_NAME); + const OSSL_PARAM *p + = OSSL_PARAM_locate_const(params, OSSL_CAPABILITY_TLS_SIGALG_NAME); if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING) { ret = -1; @@ -130,7 +132,8 @@ static int test_signature(const OSSL_PARAM params[], void *data) { return ret; } -static int test_provider_signatures(OSSL_PROVIDER *provider, void *vctx) { +static int test_provider_signatures(OSSL_PROVIDER *provider, void *vctx) +{ const char *provname = OSSL_PROVIDER_get0_name(provider); if (!strcmp(provname, PROVIDER_NAME_OQS)) @@ -141,7 +144,8 @@ static int test_provider_signatures(OSSL_PROVIDER *provider, void *vctx) { } #endif /* OSSL_CAPABILITY_TLS_SIGALG_NAME */ -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ size_t i; int errcnt = 0, test = 0; diff --git a/test/test_common.c b/test/test_common.c index 645b2839..23d46a7b 100644 --- a/test/test_common.c +++ b/test/test_common.c @@ -4,7 +4,8 @@ #include -void hexdump(const void *ptr, size_t len) { +void hexdump(const void *ptr, size_t len) +{ const unsigned char *p = ptr; size_t i, j; @@ -16,7 +17,8 @@ void hexdump(const void *ptr, size_t len) { } #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) -int alg_is_enabled(const char *algname) { +int alg_is_enabled(const char *algname) +{ char *alglist = getenv("OQS_SKIP_TESTS"); char *comma = NULL; char totest[200]; @@ -34,23 +36,25 @@ int alg_is_enabled(const char *algname) { return strstr(algname, alglist) == NULL; } -OSSL_PROVIDER *load_default_provider(OSSL_LIB_CTX *libctx) { +OSSL_PROVIDER *load_default_provider(OSSL_LIB_CTX *libctx) +{ OSSL_PROVIDER *provider; T((provider = OSSL_PROVIDER_load(libctx, "default"))); return provider; } #ifdef OQS_PROVIDER_STATIC -#define OQS_PROVIDER_ENTRYPOINT_NAME oqs_provider_init +# define OQS_PROVIDER_ENTRYPOINT_NAME oqs_provider_init #else -#define OQS_PROVIDER_ENTRYPOINT_NAME OSSL_provider_init +# define OQS_PROVIDER_ENTRYPOINT_NAME OSSL_provider_init #endif // ifdef OQS_PROVIDER_STATIC #ifndef OQS_PROVIDER_STATIC /* Loads the oqs-provider from a shared module (.so). */ void load_oqs_provider(OSSL_LIB_CTX *libctx, const char *modulename, - const char *configfile) { + const char *configfile) +{ T(OSSL_LIB_CTX_load_config(libctx, configfile)); T(OSSL_PROVIDER_available(libctx, modulename)); } @@ -61,7 +65,8 @@ extern OSSL_provider_init_fn OQS_PROVIDER_ENTRYPOINT_NAME; /* Loads the statically linked oqs-provider. */ void load_oqs_provider(OSSL_LIB_CTX *libctx, const char *modulename, - const char *configfile) { + const char *configfile) +{ (void)configfile; T(OSSL_PROVIDER_add_builtin(libctx, modulename, OQS_PROVIDER_ENTRYPOINT_NAME)); diff --git a/test/test_common.h b/test/test_common.h index b7aa76ff..5cb9161d 100644 --- a/test/test_common.h +++ b/test/test_common.h @@ -5,32 +5,32 @@ #include /* For controlled success */ -#define T(e) \ - if (!(e)) { \ - ERR_print_errors_fp(stderr); \ - OPENSSL_die(#e, __FILE__, __LINE__); \ +#define T(e) \ + if (!(e)) { \ + ERR_print_errors_fp(stderr); \ + OPENSSL_die(#e, __FILE__, __LINE__); \ } /* For controlled failure */ -#define TF(e) \ - if ((e)) { \ - ERR_print_errors_fp(stderr); \ - } else { \ - OPENSSL_die(#e, __FILE__, __LINE__); \ +#define TF(e) \ + if ((e)) { \ + ERR_print_errors_fp(stderr); \ + } else { \ + OPENSSL_die(#e, __FILE__, __LINE__); \ } -#define cRED "\033[1;31m" -#define cDRED "\033[0;31m" -#define cGREEN "\033[1;32m" -#define cDGREEN "\033[0;32m" -#define cBLUE "\033[1;34m" -#define cDBLUE "\033[0;34m" -#define cNORM "\033[m" +#define cRED "\033[1;31m" +#define cDRED "\033[0;31m" +#define cGREEN "\033[1;32m" +#define cDGREEN "\033[0;32m" +#define cBLUE "\033[1;34m" +#define cDBLUE "\033[0;34m" +#define cNORM "\033[m" #define PROVIDER_NAME_OQS "oqsprovider" -#define TEST_ASSERT(e) \ - { \ - if (!(test = (e))) \ - printf(cRED " Test FAILED" cNORM "\n"); \ - else \ - printf(cGREEN " Test passed" cNORM "\n"); \ +#define TEST_ASSERT(e) \ + { \ + if (!(test = (e))) \ + printf(cRED " Test FAILED" cNORM "\n"); \ + else \ + printf(cGREEN " Test passed" cNORM "\n"); \ } void hexdump(const void *ptr, size_t len); diff --git a/test/tlstest_helpers.c b/test/tlstest_helpers.c index 047d45f5..939fd893 100644 --- a/test/tlstest_helpers.c +++ b/test/tlstest_helpers.c @@ -6,7 +6,8 @@ /* Stolen from openssl/tests/sslapitest.c: */ int create_cert_key(OSSL_LIB_CTX *libctx, char *algname, char *certfilename, - char *privkeyfilename) { + char *privkeyfilename) +{ EVP_PKEY_CTX *evpctx = EVP_PKEY_CTX_new_from_name(libctx, algname, NULL); EVP_PKEY *pkey = NULL; X509 *x509 = X509_new(); @@ -14,24 +15,24 @@ int create_cert_key(OSSL_LIB_CTX *libctx, char *algname, char *certfilename, BIO *keybio = NULL, *certbio = NULL; int ret = 1; - if (!evpctx || !EVP_PKEY_keygen_init(evpctx) || - !EVP_PKEY_generate(evpctx, &pkey) || !pkey || !x509 || - !ASN1_INTEGER_set(X509_get_serialNumber(x509), 1) || - !X509_gmtime_adj(X509_getm_notBefore(x509), 0) || - !X509_gmtime_adj(X509_getm_notAfter(x509), 31536000L) || - !X509_set_pubkey(x509, pkey) || !(name = X509_get_subject_name(x509)) || - !X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, - (unsigned char *)"CH", -1, -1, 0) || - !X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, - (unsigned char *)"test.org", -1, -1, 0) || - !X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, - (unsigned char *)"localhost", -1, -1, 0) || - !X509_set_issuer_name(x509, name) || - !X509_sign(x509, pkey, EVP_sha1()) || - !(keybio = BIO_new_file(privkeyfilename, "wb")) || - !PEM_write_bio_PrivateKey(keybio, pkey, NULL, NULL, 0, NULL, NULL) || - !(certbio = BIO_new_file(certfilename, "wb")) || - !PEM_write_bio_X509(certbio, x509)) + if (!evpctx || !EVP_PKEY_keygen_init(evpctx) + || !EVP_PKEY_generate(evpctx, &pkey) || !pkey || !x509 + || !ASN1_INTEGER_set(X509_get_serialNumber(x509), 1) + || !X509_gmtime_adj(X509_getm_notBefore(x509), 0) + || !X509_gmtime_adj(X509_getm_notAfter(x509), 31536000L) + || !X509_set_pubkey(x509, pkey) || !(name = X509_get_subject_name(x509)) + || !X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, + (unsigned char *)"CH", -1, -1, 0) + || !X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, + (unsigned char *)"test.org", -1, -1, 0) + || !X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, + (unsigned char *)"localhost", -1, -1, 0) + || !X509_set_issuer_name(x509, name) + || !X509_sign(x509, pkey, EVP_sha1()) + || !(keybio = BIO_new_file(privkeyfilename, "wb")) + || !PEM_write_bio_PrivateKey(keybio, pkey, NULL, NULL, 0, NULL, NULL) + || !(certbio = BIO_new_file(certfilename, "wb")) + || !PEM_write_bio_X509(certbio, x509)) ret = 0; EVP_PKEY_free(pkey); @@ -43,7 +44,8 @@ int create_cert_key(OSSL_LIB_CTX *libctx, char *algname, char *certfilename, } /* end steal */ int create_tls1_3_ctx_pair(OSSL_LIB_CTX *libctx, SSL_CTX **sctx, SSL_CTX **cctx, - char *certfile, char *privkeyfile) { + char *certfile, char *privkeyfile) +{ SSL_CTX *serverctx = NULL, *clientctx = NULL; if (sctx == NULL || cctx == NULL) @@ -81,7 +83,8 @@ int create_tls1_3_ctx_pair(OSSL_LIB_CTX *libctx, SSL_CTX **sctx, SSL_CTX **cctx, } int create_tls_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl, - SSL **cssl) { + SSL **cssl) +{ SSL *serverssl = NULL, *clientssl = NULL; BIO *s_to_c_bio = NULL, *c_to_s_bio = NULL; @@ -131,7 +134,8 @@ int create_tls_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl, * attempt could be restarted by a subsequent call to this function. */ int create_bare_tls_connection(SSL *serverssl, SSL *clientssl, int want, - int read) { + int read) +{ int retc = -1, rets = -1, err, abortctr = 0; int clienterr = 0, servererr = 0; @@ -162,8 +166,8 @@ int create_bare_tls_connection(SSL *serverssl, SSL *clientssl, int want, err = SSL_get_error(serverssl, rets); } - if (!servererr && rets <= 0 && err != SSL_ERROR_WANT_READ && - err != SSL_ERROR_WANT_X509_LOOKUP) { + if (!servererr && rets <= 0 && err != SSL_ERROR_WANT_READ + && err != SSL_ERROR_WANT_X509_LOOKUP) { fprintf(stderr, "SSL_accept() failed returning %d, SSL error %d.\n", rets, err); ERR_print_errors_fp(stderr); @@ -189,7 +193,8 @@ int create_bare_tls_connection(SSL *serverssl, SSL *clientssl, int want, * Create an SSL connection including any post handshake NewSessionTicket * messages. */ -int create_tls_connection(SSL *serverssl, SSL *clientssl, int want) { +int create_tls_connection(SSL *serverssl, SSL *clientssl, int want) +{ int i; unsigned char buf; size_t readbytes;