From de46572102bc2615cbea3b4ebc210ed3688c025e Mon Sep 17 00:00:00 2001 From: Basil Hess Date: Mon, 4 Nov 2024 17:38:04 +0100 Subject: [PATCH] Adding _with_ctx_str APIs, templating Signed-off-by: Basil Hess --- .../copy_from_upstream/copy_from_upstream.yml | 3 +- .../patches/pqcrystals-ml_dsa.patch | 604 +++--------------- .../src/sig/family/sig_family.h | 9 + .../src/sig/family/sig_scheme.c | 87 +++ src/sig/cross/sig_cross_rsdp_128_balanced.c | 4 +- src/sig/cross/sig_cross_rsdp_128_fast.c | 4 +- src/sig/cross/sig_cross_rsdp_128_small.c | 4 +- src/sig/cross/sig_cross_rsdp_192_balanced.c | 4 +- src/sig/cross/sig_cross_rsdp_192_fast.c | 4 +- src/sig/cross/sig_cross_rsdp_192_small.c | 4 +- src/sig/cross/sig_cross_rsdp_256_balanced.c | 4 +- src/sig/cross/sig_cross_rsdp_256_fast.c | 4 +- src/sig/cross/sig_cross_rsdp_256_small.c | 4 +- src/sig/cross/sig_cross_rsdpg_128_balanced.c | 4 +- src/sig/cross/sig_cross_rsdpg_128_fast.c | 4 +- src/sig/cross/sig_cross_rsdpg_128_small.c | 4 +- src/sig/cross/sig_cross_rsdpg_192_balanced.c | 4 +- src/sig/cross/sig_cross_rsdpg_192_fast.c | 4 +- src/sig/cross/sig_cross_rsdpg_192_small.c | 4 +- src/sig/cross/sig_cross_rsdpg_256_balanced.c | 4 +- src/sig/cross/sig_cross_rsdpg_256_fast.c | 4 +- src/sig/cross/sig_cross_rsdpg_256_small.c | 4 +- src/sig/dilithium/sig_dilithium_2.c | 4 +- src/sig/dilithium/sig_dilithium_3.c | 4 +- src/sig/dilithium/sig_dilithium_5.c | 4 +- src/sig/falcon/sig_falcon_1024.c | 4 +- src/sig/falcon/sig_falcon_512.c | 4 +- src/sig/falcon/sig_falcon_padded_1024.c | 4 +- src/sig/falcon/sig_falcon_padded_512.c | 4 +- src/sig/mayo/sig_mayo_1.c | 4 +- src/sig/mayo/sig_mayo_2.c | 4 +- src/sig/mayo/sig_mayo_3.c | 4 +- src/sig/mayo/sig_mayo_5.c | 4 +- src/sig/ml_dsa/sig_ml_dsa.h | 6 + src/sig/ml_dsa/sig_ml_dsa_44.c | 33 +- src/sig/ml_dsa/sig_ml_dsa_65.c | 33 +- src/sig/ml_dsa/sig_ml_dsa_87.c | 33 +- src/sig/sig.c | 16 + src/sig/sig.h | 65 ++ .../sphincs/sig_sphincs_sha2_128f_simple.c | 4 +- .../sphincs/sig_sphincs_sha2_128s_simple.c | 4 +- .../sphincs/sig_sphincs_sha2_192f_simple.c | 4 +- .../sphincs/sig_sphincs_sha2_192s_simple.c | 4 +- .../sphincs/sig_sphincs_sha2_256f_simple.c | 4 +- .../sphincs/sig_sphincs_sha2_256s_simple.c | 4 +- .../sphincs/sig_sphincs_shake_128f_simple.c | 4 +- .../sphincs/sig_sphincs_shake_128s_simple.c | 4 +- .../sphincs/sig_sphincs_shake_192f_simple.c | 4 +- .../sphincs/sig_sphincs_shake_192s_simple.c | 4 +- .../sphincs/sig_sphincs_shake_256f_simple.c | 4 +- .../sphincs/sig_sphincs_shake_256s_simple.c | 4 +- 51 files changed, 458 insertions(+), 595 deletions(-) diff --git a/scripts/copy_from_upstream/copy_from_upstream.yml b/scripts/copy_from_upstream/copy_from_upstream.yml index 200165d97a..230f7052df 100644 --- a/scripts/copy_from_upstream/copy_from_upstream.yml +++ b/scripts/copy_from_upstream/copy_from_upstream.yml @@ -52,8 +52,7 @@ upstreams: git_commit: 444cdcc84eb36b66fe27b3a2529ee48f6d8150c2 sig_meta_path: '{pretty_name_full}_META.yml' sig_scheme_path: '.' - patches: [pqcrystals-ml_dsa-internal4.patch] - #patches: [pqcrystals-ml_dsa.patch] + patches: [pqcrystals-ml_dsa.patch] - name: pqmayo git_url: https://github.com/PQCMayo/MAYO-C.git diff --git a/scripts/copy_from_upstream/patches/pqcrystals-ml_dsa.patch b/scripts/copy_from_upstream/patches/pqcrystals-ml_dsa.patch index 00ff269ef8..5e17f66da2 100644 --- a/scripts/copy_from_upstream/patches/pqcrystals-ml_dsa.patch +++ b/scripts/copy_from_upstream/patches/pqcrystals-ml_dsa.patch @@ -1,20 +1,14 @@ -diff --git a/Dilithium2_META.yml b/ML-DSA-44_META.yml -index 425606f..23fa5af 100644 +diff --git a/Dilithium2_META.yml b/Dilithium2_META.yml +index 122b3ca..d9461b7 100644 --- a/Dilithium2_META.yml +++ b/ML-DSA-44_META.yml -@@ -1,9 +1,10 @@ +@@ -1,4 +1,4 @@ -name: Dilithium2 +name: ML-DSA-44 type: signature claimed-nist-level: 2 length-public-key: 1312 - length-secret-key: 2560 - length-signature: 2420 -+nistkat-sha256: 9a196e7fb32fbc93757dc2d8dc1924460eab66303c0c08aeb8b798fb8d8f8cf3 - testvectors-sha256: 5f0d135c0f7fd43f3fb9727265fcd6ec3651eb8c67c04ea5f3d8dfa1d99740d2 - principal-submitters: - - Vadim Lyubashevsky -@@ -19,20 +20,18 @@ implementations: +@@ -20,20 +20,20 @@ implementations: - name: ref version: https://github.com/pq-crystals/dilithium/tree/master folder_name: ref @@ -28,6 +22,7 @@ index 425606f..23fa5af 100644 + signature_keypair: pqcrystals_ml_dsa_44_ref_keypair + signature_signature: pqcrystals_ml_dsa_44_ref_signature + signature_verify: pqcrystals_ml_dsa_44_ref_verify ++ api-with-context-string: true + sources: ../LICENSE api.h config.h params.h sign.c sign.h packing.c packing.h polyvec.c polyvec.h poly.c poly.h ntt.c ntt.h reduce.c reduce.h rounding.c rounding.h symmetric.h symmetric-shake.c - name: avx2 version: https://github.com/pq-crystals/dilithium/tree/master @@ -41,27 +36,22 @@ index 425606f..23fa5af 100644 + signature_keypair: pqcrystals_ml_dsa_44_avx2_keypair + signature_signature: pqcrystals_ml_dsa_44_avx2_signature + signature_verify: pqcrystals_ml_dsa_44_avx2_verify ++ api-with-context-string: true + sources: ../LICENSE api.h config.h params.h align.h sign.c sign.h packing.c packing.h polyvec.c polyvec.h poly.c poly.h ntt.S invntt.S pointwise.S ntt.h shuffle.S shuffle.inc consts.c consts.h rejsample.c rejsample.h rounding.c rounding.h symmetric.h symmetric-shake.c supported_platforms: - architecture: x86_64 operating_systems: -diff --git a/Dilithium3_META.yml b/ML-DSA-65_META.yml -index 94b60c0..cc3e91c 100644 +diff --git a/Dilithium3_META.yml b/Dilithium3_META.yml +index b108b4f..cda907a 100644 --- a/Dilithium3_META.yml +++ b/ML-DSA-65_META.yml -@@ -1,9 +1,10 @@ +@@ -1,4 +1,4 @@ -name: Dilithium3 +name: ML-DSA-65 type: signature claimed-nist-level: 3 length-public-key: 1952 - length-secret-key: 4032 - length-signature: 3309 -+nistkat-sha256: 7cb96242eac9907a55b5c84c202f0ebd552419c50b2e986dc2e28f07ecebf072 - testvectors-sha256: 14bf84918ee90e7afbd580191d3eb890d4557e0900b1145e39a8399ef7dd3fba - principal-submitters: - - Vadim Lyubashevsky -@@ -19,20 +20,18 @@ implementations: +@@ -20,20 +20,20 @@ implementations: - name: ref version: https://github.com/pq-crystals/dilithium/tree/master folder_name: ref @@ -75,6 +65,7 @@ index 94b60c0..cc3e91c 100644 + signature_keypair: pqcrystals_ml_dsa_65_ref_keypair + signature_signature: pqcrystals_ml_dsa_65_ref_signature + signature_verify: pqcrystals_ml_dsa_65_ref_verify ++ api-with-context-string: true + sources: ../LICENSE api.h config.h params.h sign.c sign.h packing.c packing.h polyvec.c polyvec.h poly.c poly.h ntt.c ntt.h reduce.c reduce.h rounding.c rounding.h symmetric.h symmetric-shake.c - name: avx2 version: https://github.com/pq-crystals/dilithium/tree/master @@ -88,27 +79,22 @@ index 94b60c0..cc3e91c 100644 + signature_keypair: pqcrystals_ml_dsa_65_avx2_keypair + signature_signature: pqcrystals_ml_dsa_65_avx2_signature + signature_verify: pqcrystals_ml_dsa_65_avx2_verify ++ api-with-context-string: true + sources: ../LICENSE api.h config.h params.h align.h sign.c sign.h packing.c packing.h polyvec.c polyvec.h poly.c poly.h ntt.S invntt.S pointwise.S ntt.h shuffle.S shuffle.inc consts.c consts.h rejsample.c rejsample.h rounding.c rounding.h symmetric.h symmetric-shake.c supported_platforms: - architecture: x86_64 operating_systems: -diff --git a/Dilithium5_META.yml b/ML-DSA-87_META.yml -index 69e1c01..0c6b695 100644 +diff --git a/Dilithium5_META.yml b/Dilithium5_META.yml +index 5163526..12980de 100644 --- a/Dilithium5_META.yml +++ b/ML-DSA-87_META.yml -@@ -1,9 +1,10 @@ +@@ -1,4 +1,4 @@ -name: Dilithium5 +name: ML-DSA-87 type: signature claimed-nist-level: 5 length-public-key: 2592 - length-secret-key: 4896 - length-signature: 4627 -+nistkat-sha256: 4537905d2aabcf302fab2f242baed293459ecda7c230e6a67063b02c7e2840ed - testvectors-sha256: 759a3ba35210c7e27ff90a7ce5e399295533b82ef125e6ec98af158e00268e44 - principal-submitters: - - Vadim Lyubashevsky -@@ -19,20 +20,18 @@ implementations: +@@ -20,20 +20,20 @@ implementations: - name: ref version: https://github.com/pq-crystals/dilithium/tree/master folder_name: ref @@ -122,6 +108,7 @@ index 69e1c01..0c6b695 100644 + signature_keypair: pqcrystals_ml_dsa_87_ref_keypair + signature_signature: pqcrystals_ml_dsa_87_ref_signature + signature_verify: pqcrystals_ml_dsa_87_ref_verify ++ api-with-context-string: true + sources: ../LICENSE api.h config.h params.h sign.c sign.h packing.c packing.h polyvec.c polyvec.h poly.c poly.h ntt.c ntt.h reduce.c reduce.h rounding.c rounding.h symmetric.h symmetric-shake.c - name: avx2 version: https://github.com/pq-crystals/dilithium/tree/master @@ -135,6 +122,7 @@ index 69e1c01..0c6b695 100644 + signature_keypair: pqcrystals_ml_dsa_87_avx2_keypair + signature_signature: pqcrystals_ml_dsa_87_avx2_signature + signature_verify: pqcrystals_ml_dsa_87_avx2_verify ++ api-with-context-string: true + sources: ../LICENSE api.h config.h params.h align.h sign.c sign.h packing.c packing.h polyvec.c polyvec.h poly.c poly.h ntt.S invntt.S pointwise.S ntt.h shuffle.S shuffle.inc consts.c consts.h rejsample.c rejsample.h rounding.c rounding.h symmetric.h symmetric-shake.c supported_platforms: - architecture: x86_64 @@ -171,7 +159,7 @@ index a9facc0..3944cb4 100644 #endif diff --git a/avx2/poly.c b/avx2/poly.c -index 340e91d..7bae495 100644 +index 340e91d..0a4ecb6 100644 --- a/avx2/poly.c +++ b/avx2/poly.c @@ -401,6 +401,7 @@ void poly_uniform(poly *a, const uint8_t seed[SEEDBYTES], uint16_t nonce) @@ -295,51 +283,52 @@ index 340e91d..7bae495 100644 /************************************************* diff --git a/avx2/sign.c b/avx2/sign.c -index 7d70257..d1c747a 100644 +index efb6ea3..56bb897 100644 --- a/avx2/sign.c +++ b/avx2/sign.c -@@ -151,7 +151,7 @@ int crypto_sign_keypair(uint8_t *pk, uint8_t *sk) { - * - * Returns 0 (success) or -1 (context string too long) - **************************************************/ --int crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, -+static int crypto_sign_signature_ctx(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t mlen, - const uint8_t *ctx, size_t ctxlen, const uint8_t *sk) - { - unsigned int i, n, pos; -@@ -167,7 +167,7 @@ int crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t +@@ -168,7 +168,7 @@ int crypto_sign_signature_internal(uint8_t *sig, size_t *siglen, const uint8_t * polyvecl y; polyveck w0; } tmpv; - keccak_state state; + shake256incctx state; - if(ctxlen > 255) - return -1; -@@ -181,15 +181,15 @@ int crypto_sign_signature(uint8_t *sig, size_t *siglen, const uint8_t *m, size_t + rho = seedbuf; + tr = rho + SEEDBYTES; +@@ -178,20 +178,20 @@ int crypto_sign_signature_internal(uint8_t *sig, size_t *siglen, const uint8_t * unpack_sk(rho, tr, key, &t0, &s1, &s2, sk); - /* Compute CRH(tr, 0, ctxlen, ctx, msg) */ + /* Compute mu = CRH(tr, pre, msg) */ - shake256_init(&state); - shake256_absorb(&state, tr, TRBYTES); -+ shake256_inc_init(&state); -+ shake256_inc_absorb(&state, tr, TRBYTES); - mu[0] = 0; - mu[1] = ctxlen; -- shake256_absorb(&state, mu, 2); -- shake256_absorb(&state, ctx, ctxlen); +- shake256_absorb(&state, pre, prelen); - shake256_absorb(&state, m, mlen); - shake256_finalize(&state); - shake256_squeeze(mu, CRHBYTES, &state); -+ shake256_inc_absorb(&state, mu, 2); -+ shake256_inc_absorb(&state, ctx, ctxlen); ++ shake256_inc_init(&state); ++ shake256_inc_absorb(&state, tr, TRBYTES); ++ shake256_inc_absorb(&state, pre, prelen); + shake256_inc_absorb(&state, m, mlen); + shake256_inc_finalize(&state); + shake256_inc_squeeze(mu, CRHBYTES, &state); - #ifdef DILITHIUM_RANDOMIZED_SIGNING - randombytes(rnd, RNDBYTES); -@@ -236,11 +236,11 @@ rej: + /* Compute rhoprime = CRH(key, rnd, mu) */ +- shake256_init(&state); +- shake256_absorb(&state, key, SEEDBYTES); +- shake256_absorb(&state, rnd, RNDBYTES); +- shake256_absorb(&state, mu, CRHBYTES); +- shake256_finalize(&state); +- shake256_squeeze(rhoprime, CRHBYTES, &state); ++ shake256_inc_ctx_reset(&state); ++ shake256_inc_absorb(&state, key, SEEDBYTES); ++ shake256_inc_absorb(&state, rnd, RNDBYTES); ++ shake256_inc_absorb(&state, mu, CRHBYTES); ++ shake256_inc_finalize(&state); ++ shake256_inc_squeeze(rhoprime, CRHBYTES, &state); + + /* Expand matrix and transform vectors */ + polyvec_matrix_expand(mat, rho); +@@ -231,11 +231,11 @@ rej: polyveck_decompose(&w1, &tmpv.w0, &w1); polyveck_pack_w1(sig, &w1); @@ -356,7 +345,7 @@ index 7d70257..d1c747a 100644 poly_challenge(&c, sig); poly_ntt(&c); -@@ -285,6 +285,7 @@ rej: +@@ -280,6 +280,7 @@ rej: hint[OMEGA + i] = pos = pos + n; } @@ -364,129 +353,34 @@ index 7d70257..d1c747a 100644 /* Pack z into signature */ for(i = 0; i < L; i++) polyz_pack(sig + CTILDEBYTES + i*POLYZ_PACKEDBYTES, &z.vec[i]); -@@ -293,6 +294,30 @@ rej: - return 0; - } - -+/************************************************* -+* Name: crypto_sign_signature -+* -+* Description: Computes signature. Default with empty ctx. -+* -+* Arguments: - uint8_t *sig: pointer to output signature (of length CRYPTO_BYTES) -+* - size_t *siglen: pointer to output length of signature -+* - uint8_t *m: pointer to message to be signed -+* - size_t mlen: length of message -+* - uint8_t *sk: pointer to bit-packed secret key -+* -+* Returns 0 (success) or -1 (context string too long) -+**************************************************/ -+int crypto_sign_signature(uint8_t *sig, -+ size_t *siglen, -+ const uint8_t *m, -+ size_t mlen, -+ const uint8_t *sk) -+{ -+ return crypto_sign_signature_ctx(sig, siglen, m, mlen, NULL, 0, sk); -+} -+ -+ -+ - /************************************************* - * Name: crypto_sign - * -@@ -311,7 +336,7 @@ rej: - * - * Returns 0 (success) - **************************************************/ --int crypto_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen, const uint8_t *ctx, size_t ctxlen, -+static int crypto_sign_ctx(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen, const uint8_t *ctx, size_t ctxlen, - const uint8_t *sk) - { - size_t i; -@@ -319,13 +344,38 @@ int crypto_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen, const - - for(i = 0; i < mlen; ++i) - sm[CRYPTO_BYTES + mlen - 1 - i] = m[mlen - 1 - i]; -- ret = crypto_sign_signature(sm, smlen, sm + CRYPTO_BYTES, mlen, ctx, ctxlen, sk); -+ ret = crypto_sign_signature_ctx(sm, smlen, sm + CRYPTO_BYTES, mlen, ctx, ctxlen, sk); - *smlen += mlen; - return ret; - } - - /************************************************* --* Name: crypto_sign_verify -+* Name: crypto_sign -+* -+* Description: Compute signed message. Default with empty ctx. -+* -+* Arguments: - uint8_t *sm: pointer to output signed message (allocated -+* array with CRYPTO_BYTES + mlen bytes), -+* can be equal to m -+* - size_t *smlen: pointer to output length of signed -+* message -+* - const uint8_t *m: pointer to message to be signed -+* - size_t mlen: length of message -+* - const uint8_t *sk: pointer to bit-packed secret key -+* -+* Returns 0 (success) or -1 (context string too long) -+**************************************************/ -+int crypto_sign(uint8_t *sm, -+ size_t *smlen, -+ const uint8_t *m, -+ size_t mlen, -+ const uint8_t *sk) -+{ -+ return crypto_sign_ctx(sm, smlen, m, mlen, NULL, 0, sk); -+} -+ -+/************************************************* -+* Name: crypto_sign_verify_ctx - * - * Description: Verifies signature. - * -@@ -339,7 +389,7 @@ int crypto_sign(uint8_t *sm, size_t *smlen, const uint8_t *m, size_t mlen, const - * - * Returns 0 if signature could be verified correctly and -1 otherwise - **************************************************/ --int crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, -+static int crypto_sign_verify_ctx(const uint8_t *sig, size_t siglen, const uint8_t *m, size_t mlen, - const uint8_t *ctx, size_t ctxlen, const uint8_t *pk) { - unsigned int i, j, pos = 0; - /* polyw1_pack writes additional 14 bytes */ -@@ -350,22 +400,23 @@ int crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size +@@ -384,19 +385,19 @@ int crypto_sign_verify_internal(const uint8_t *sig, size_t siglen, const uint8_t polyvecl *row = rowbuf; polyvecl z; poly c, w1, h; - keccak_state state; + shake256incctx state; - if(ctxlen > 255 || siglen != CRYPTO_BYTES) + if(siglen != CRYPTO_BYTES) return -1; - /* Compute CRH(H(rho, t1), msg) */ + /* Compute CRH(H(rho, t1), pre, msg) */ shake256(mu, TRBYTES, pk, CRYPTO_PUBLICKEYBYTES); - shake256_init(&state); - shake256_absorb(&state, mu, CRHBYTES); -+ shake256_inc_init(&state); -+ shake256_inc_absorb(&state, mu, CRHBYTES); - mu[0] = 0; - mu[1] = ctxlen; -- shake256_absorb(&state, mu, 2); -- shake256_absorb(&state, ctx, ctxlen); +- shake256_absorb(&state, pre, prelen); - shake256_absorb(&state, m, mlen); - shake256_finalize(&state); - shake256_squeeze(mu, CRHBYTES, &state); -+ shake256_inc_absorb(&state, mu, 2); -+ shake256_inc_absorb(&state, ctx, ctxlen); ++ shake256_inc_init(&state); ++ shake256_inc_absorb(&state, mu, CRHBYTES); ++ shake256_inc_absorb(&state, pre, prelen); + shake256_inc_absorb(&state, m, mlen); + shake256_inc_finalize(&state); + shake256_inc_squeeze(mu, CRHBYTES, &state); -+ shake256_inc_ctx_release(&state); /* Expand challenge */ poly_challenge(&c, sig); -@@ -415,11 +466,12 @@ int crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size +@@ -446,11 +447,12 @@ int crypto_sign_verify_internal(const uint8_t *sig, size_t siglen, const uint8_t if(hint[j]) return -1; /* Call random oracle and verify challenge */ @@ -495,7 +389,7 @@ index 7d70257..d1c747a 100644 - shake256_absorb(&state, buf.coeffs, K*POLYW1_PACKEDBYTES); - shake256_finalize(&state); - shake256_squeeze(buf.coeffs, CTILDEBYTES, &state); -+ shake256_inc_init(&state); ++ shake256_inc_ctx_reset(&state); + shake256_inc_absorb(&state, mu, CRHBYTES); + shake256_inc_absorb(&state, buf.coeffs, K*POLYW1_PACKEDBYTES); + shake256_inc_finalize(&state); @@ -504,82 +398,6 @@ index 7d70257..d1c747a 100644 for(i = 0; i < CTILDEBYTES; ++i) if(buf.coeffs[i] != sig[i]) return -1; -@@ -428,7 +480,29 @@ int crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size - } - - /************************************************* --* Name: crypto_sign_open -+* Name: crypto_sign_verify -+* -+* Description: Verifies signature. With default context. -+* -+* Arguments: - uint8_t *m: pointer to input signature -+* - size_t siglen: length of signature -+* - const uint8_t *m: pointer to message -+* - size_t mlen: length of message -+* - const uint8_t *pk: pointer to bit-packed public key -+* -+* Returns 0 if signature could be verified correctly and -1 otherwise -+**************************************************/ -+int crypto_sign_verify(const uint8_t *sig, -+ size_t siglen, -+ const uint8_t *m, -+ size_t mlen, -+ const uint8_t *pk) -+{ -+ return crypto_sign_verify_ctx(sig, siglen, m, mlen, NULL, 0, pk); -+} -+ -+/************************************************* -+* Name: crypto_sign_open_ctx - * - * Description: Verify signed message. - * -@@ -443,7 +517,7 @@ int crypto_sign_verify(const uint8_t *sig, size_t siglen, const uint8_t *m, size - * - * Returns 0 if signed message could be verified correctly and -1 otherwise - **************************************************/ --int crypto_sign_open(uint8_t *m, size_t *mlen, const uint8_t *sm, size_t smlen, -+static int crypto_sign_open_ctx(uint8_t *m, size_t *mlen, const uint8_t *sm, size_t smlen, - const uint8_t *ctx, size_t ctxlen, const uint8_t *pk) { - size_t i; - -@@ -451,7 +525,7 @@ int crypto_sign_open(uint8_t *m, size_t *mlen, const uint8_t *sm, size_t smlen, - goto badsig; - - *mlen = smlen - CRYPTO_BYTES; -- if(crypto_sign_verify(sm, CRYPTO_BYTES, sm + CRYPTO_BYTES, *mlen, ctx, ctxlen, pk)) -+ if(crypto_sign_verify_ctx(sm, CRYPTO_BYTES, sm + CRYPTO_BYTES, *mlen, ctx, ctxlen, pk)) - goto badsig; - else { - /* All good, copy msg, return 0 */ -@@ -468,3 +542,26 @@ badsig: - - return -1; - } -+ -+/************************************************* -+* Name: crypto_sign_open -+* -+* Description: Verify signed message. Default with empty ctx. -+* -+* Arguments: - uint8_t *m: pointer to output message (allocated -+* array with smlen bytes), can be equal to sm -+* - size_t *mlen: pointer to output length of message -+* - const uint8_t *sm: pointer to signed message -+* - size_t smlen: length of signed message -+* - const uint8_t *pk: pointer to bit-packed public key -+* -+* Returns 0 if signed message could be verified correctly and -1 otherwise -+**************************************************/ -+int crypto_sign_open(uint8_t *m, -+ size_t *mlen, -+ const uint8_t *sm, -+ size_t smlen, -+ const uint8_t *pk) -+{ -+ return crypto_sign_open_ctx(m, mlen, sm, smlen, NULL, 0, pk); -+} diff --git a/avx2/symmetric.h b/avx2/symmetric.h index 8f3c3c5..fa49963 100644 --- a/avx2/symmetric.h @@ -644,7 +462,7 @@ index 98b8ccb..8008e11 100644 #endif diff --git a/ref/poly.c b/ref/poly.c -index 0db4f42..99405fa 100644 +index 0db4f42..691b5e8 100644 --- a/ref/poly.c +++ b/ref/poly.c @@ -365,6 +365,7 @@ void poly_uniform(poly *a, @@ -696,70 +514,52 @@ index 0db4f42..99405fa 100644 /************************************************* diff --git a/ref/sign.c b/ref/sign.c -index b130da9..59df461 100644 +index 7d3f882..abb033c 100644 --- a/ref/sign.c +++ b/ref/sign.c -@@ -67,7 +67,7 @@ int crypto_sign_keypair(uint8_t *pk, uint8_t *sk) { - } - - /************************************************* --* Name: crypto_sign_signature -+* Name: crypto_sign_signatur_ctx - * - * Description: Computes signature. - * -@@ -81,13 +81,13 @@ int crypto_sign_keypair(uint8_t *pk, uint8_t *sk) { - * - * Returns 0 (success) or -1 (context string too long) - **************************************************/ --int crypto_sign_signature(uint8_t *sig, -- size_t *siglen, -- const uint8_t *m, -- size_t mlen, -- const uint8_t *ctx, -- size_t ctxlen, -- const uint8_t *sk) -+static int crypto_sign_signature_ctx(uint8_t *sig, -+ size_t *siglen, -+ const uint8_t *m, -+ size_t mlen, -+ const uint8_t *ctx, -+ size_t ctxlen, -+ const uint8_t *sk) - { - unsigned int n; - uint8_t seedbuf[2*SEEDBYTES + TRBYTES + RNDBYTES + 2*CRHBYTES]; -@@ -96,7 +96,7 @@ int crypto_sign_signature(uint8_t *sig, +@@ -98,7 +98,7 @@ int crypto_sign_signature_internal(uint8_t *sig, polyvecl mat[K], s1, y, z; polyveck t0, s2, w1, w0, h; poly cp; - keccak_state state; + shake256incctx state; - if(ctxlen > 255) - return -1; -@@ -112,13 +112,13 @@ int crypto_sign_signature(uint8_t *sig, - /* Compute mu = CRH(tr, 0, ctxlen, ctx, msg) */ - mu[0] = 0; - mu[1] = ctxlen; + rho = seedbuf; + tr = rho + SEEDBYTES; +@@ -108,20 +108,20 @@ int crypto_sign_signature_internal(uint8_t *sig, + unpack_sk(rho, tr, key, &t0, &s1, &s2, sk); + + /* Compute mu = CRH(tr, pre, msg) */ - shake256_init(&state); - shake256_absorb(&state, tr, TRBYTES); -- shake256_absorb(&state, mu, 2); -- shake256_absorb(&state, ctx, ctxlen); +- shake256_absorb(&state, pre, prelen); - shake256_absorb(&state, m, mlen); - shake256_finalize(&state); - shake256_squeeze(mu, CRHBYTES, &state); + shake256_inc_init(&state); + shake256_inc_absorb(&state, tr, TRBYTES); -+ shake256_inc_absorb(&state, mu, 2); -+ shake256_inc_absorb(&state, ctx, ctxlen); ++ shake256_inc_absorb(&state, pre, prelen); + shake256_inc_absorb(&state, m, mlen); + shake256_inc_finalize(&state); + shake256_inc_squeeze(mu, CRHBYTES, &state); - #ifdef DILITHIUM_RANDOMIZED_SIGNING - randombytes(rnd, RNDBYTES); -@@ -150,11 +150,11 @@ rej: + /* Compute rhoprime = CRH(key, rnd, mu) */ +- shake256_init(&state); +- shake256_absorb(&state, key, SEEDBYTES); +- shake256_absorb(&state, rnd, RNDBYTES); +- shake256_absorb(&state, mu, CRHBYTES); +- shake256_finalize(&state); +- shake256_squeeze(rhoprime, CRHBYTES, &state); ++ shake256_inc_ctx_reset(&state); ++ shake256_inc_absorb(&state, key, SEEDBYTES); ++ shake256_inc_absorb(&state, rnd, RNDBYTES); ++ shake256_inc_absorb(&state, mu, CRHBYTES); ++ shake256_inc_finalize(&state); ++ shake256_inc_squeeze(rhoprime, CRHBYTES, &state); + + /* Expand matrix and transform vectors */ + polyvec_matrix_expand(mat, rho); +@@ -145,11 +145,11 @@ rej: polyveck_decompose(&w1, &w0, &w1); polyveck_pack_w1(sig, &w1); @@ -776,7 +576,7 @@ index b130da9..59df461 100644 poly_challenge(&cp, sig); poly_ntt(&cp); -@@ -187,6 +187,8 @@ rej: +@@ -182,6 +182,8 @@ rej: if(n > OMEGA) goto rej; @@ -785,140 +585,35 @@ index b130da9..59df461 100644 /* Write signature */ pack_sig(sig, sig, &z, &h); *siglen = CRYPTO_BYTES; -@@ -194,7 +196,29 @@ rej: - } - - /************************************************* --* Name: crypto_sign -+* Name: crypto_sign_signature -+* -+* Description: Computes signature. Default with empty ctx. -+* -+* Arguments: - uint8_t *sig: pointer to output signature (of length CRYPTO_BYTES) -+* - size_t *siglen: pointer to output length of signature -+* - uint8_t *m: pointer to message to be signed -+* - size_t mlen: length of message -+* - uint8_t *sk: pointer to bit-packed secret key -+* -+* Returns 0 (success) or -1 (context string too long) -+**************************************************/ -+int crypto_sign_signature(uint8_t *sig, -+ size_t *siglen, -+ const uint8_t *m, -+ size_t mlen, -+ const uint8_t *sk) -+{ -+ return crypto_sign_signature_ctx(sig, siglen, m, mlen, NULL, 0, sk); -+} -+ -+/************************************************* -+* Name: crypto_sign_ctx - * - * Description: Compute signed message. - * -@@ -211,26 +235,51 @@ rej: - * - * Returns 0 (success) or -1 (context string too long) - **************************************************/ --int crypto_sign(uint8_t *sm, -- size_t *smlen, -- const uint8_t *m, -- size_t mlen, -- const uint8_t *ctx, -- size_t ctxlen, -- const uint8_t *sk) -+static int crypto_sign_ctx(uint8_t *sm, -+ size_t *smlen, -+ const uint8_t *m, -+ size_t mlen, -+ const uint8_t *ctx, -+ size_t ctxlen, -+ const uint8_t *sk) - { - int ret; - size_t i; - - for(i = 0; i < mlen; ++i) - sm[CRYPTO_BYTES + mlen - 1 - i] = m[mlen - 1 - i]; -- ret = crypto_sign_signature(sm, smlen, sm + CRYPTO_BYTES, mlen, ctx, ctxlen, sk); -+ ret = crypto_sign_signature_ctx(sm, smlen, sm + CRYPTO_BYTES, mlen, ctx, ctxlen, sk); - *smlen += mlen; - return ret; - } - - /************************************************* --* Name: crypto_sign_verify -+* Name: crypto_sign -+* -+* Description: Compute signed message. Default with empty ctx. -+* -+* Arguments: - uint8_t *sm: pointer to output signed message (allocated -+* array with CRYPTO_BYTES + mlen bytes), -+* can be equal to m -+* - size_t *smlen: pointer to output length of signed -+* message -+* - const uint8_t *m: pointer to message to be signed -+* - size_t mlen: length of message -+* - const uint8_t *sk: pointer to bit-packed secret key -+* -+* Returns 0 (success) or -1 (context string too long) -+**************************************************/ -+int crypto_sign(uint8_t *sm, -+ size_t *smlen, -+ const uint8_t *m, -+ size_t mlen, -+ const uint8_t *sk) -+{ -+ return crypto_sign_ctx(sm, smlen, m, mlen, NULL, 0, sk); -+} -+ -+/************************************************* -+* Name: crypto_sign_verify_ctx - * - * Description: Verifies signature. - * -@@ -244,7 +293,7 @@ int crypto_sign(uint8_t *sm, - * - * Returns 0 if signature could be verified correctly and -1 otherwise - **************************************************/ --int crypto_sign_verify(const uint8_t *sig, -+static int crypto_sign_verify_ctx(const uint8_t *sig, - size_t siglen, - const uint8_t *m, - size_t mlen, -@@ -261,7 +310,7 @@ int crypto_sign_verify(const uint8_t *sig, +@@ -303,7 +305,7 @@ int crypto_sign_verify_internal(const uint8_t *sig, poly cp; polyvecl mat[K], z; polyveck t1, w1, h; - keccak_state state; + shake256incctx state; - if(ctxlen > 255 || siglen != CRYPTO_BYTES) + if(siglen != CRYPTO_BYTES) return -1; -@@ -274,15 +323,15 @@ int crypto_sign_verify(const uint8_t *sig, +@@ -316,12 +318,12 @@ int crypto_sign_verify_internal(const uint8_t *sig, - /* Compute CRH(H(rho, t1), msg) */ + /* Compute CRH(H(rho, t1), pre, msg) */ shake256(mu, TRBYTES, pk, CRYPTO_PUBLICKEYBYTES); - shake256_init(&state); - shake256_absorb(&state, mu, TRBYTES); -+ shake256_inc_init(&state); -+ shake256_inc_absorb(&state, mu, TRBYTES); - mu[0] = 0; - mu[1] = ctxlen; -- shake256_absorb(&state, mu, 2); -- shake256_absorb(&state, ctx, ctxlen); +- shake256_absorb(&state, pre, prelen); - shake256_absorb(&state, m, mlen); - shake256_finalize(&state); - shake256_squeeze(mu, CRHBYTES, &state); -+ shake256_inc_absorb(&state, mu, 2); -+ shake256_inc_absorb(&state, ctx, ctxlen); ++ shake256_inc_init(&state); ++ shake256_inc_absorb(&state, mu, TRBYTES); ++ shake256_inc_absorb(&state, pre, prelen); + shake256_inc_absorb(&state, m, mlen); + shake256_inc_finalize(&state); + shake256_inc_squeeze(mu, CRHBYTES, &state); /* Matrix-vector multiplication; compute Az - c2^dt1 */ poly_challenge(&cp, c); -@@ -306,11 +355,12 @@ int crypto_sign_verify(const uint8_t *sig, +@@ -345,11 +347,12 @@ int crypto_sign_verify_internal(const uint8_t *sig, polyveck_pack_w1(buf, &w1); /* Call random oracle and verify challenge */ @@ -936,112 +631,6 @@ index b130da9..59df461 100644 for(i = 0; i < CTILDEBYTES; ++i) if(c[i] != c2[i]) return -1; -@@ -319,7 +369,29 @@ int crypto_sign_verify(const uint8_t *sig, - } - - /************************************************* --* Name: crypto_sign_open -+* Name: crypto_sign_verify -+* -+* Description: Verifies signature. With default context. -+* -+* Arguments: - uint8_t *m: pointer to input signature -+* - size_t siglen: length of signature -+* - const uint8_t *m: pointer to message -+* - size_t mlen: length of message -+* - const uint8_t *pk: pointer to bit-packed public key -+* -+* Returns 0 if signature could be verified correctly and -1 otherwise -+**************************************************/ -+int crypto_sign_verify(const uint8_t *sig, -+ size_t siglen, -+ const uint8_t *m, -+ size_t mlen, -+ const uint8_t *pk) -+{ -+ return crypto_sign_verify_ctx(sig, siglen, m, mlen, NULL, 0, pk); -+} -+ -+/************************************************* -+* Name: crypto_sign_open_ctx - * - * Description: Verify signed message. - * -@@ -334,7 +406,7 @@ int crypto_sign_verify(const uint8_t *sig, - * - * Returns 0 if signed message could be verified correctly and -1 otherwise - **************************************************/ --int crypto_sign_open(uint8_t *m, -+static int crypto_sign_open_ctx(uint8_t *m, - size_t *mlen, - const uint8_t *sm, - size_t smlen, -@@ -348,7 +420,7 @@ int crypto_sign_open(uint8_t *m, - goto badsig; - - *mlen = smlen - CRYPTO_BYTES; -- if(crypto_sign_verify(sm, CRYPTO_BYTES, sm + CRYPTO_BYTES, *mlen, ctx, ctxlen, pk)) -+ if(crypto_sign_verify_ctx(sm, CRYPTO_BYTES, sm + CRYPTO_BYTES, *mlen, ctx, ctxlen, pk)) - goto badsig; - else { - /* All good, copy msg, return 0 */ -@@ -365,3 +437,26 @@ badsig: - - return -1; - } -+ -+/************************************************* -+* Name: crypto_sign_open -+* -+* Description: Verify signed message. Default with empty ctx. -+* -+* Arguments: - uint8_t *m: pointer to output message (allocated -+* array with smlen bytes), can be equal to sm -+* - size_t *mlen: pointer to output length of message -+* - const uint8_t *sm: pointer to signed message -+* - size_t smlen: length of signed message -+* - const uint8_t *pk: pointer to bit-packed public key -+* -+* Returns 0 if signed message could be verified correctly and -1 otherwise -+**************************************************/ -+int crypto_sign_open(uint8_t *m, -+ size_t *mlen, -+ const uint8_t *sm, -+ size_t smlen, -+ const uint8_t *pk) -+{ -+ return crypto_sign_open_ctx(m, mlen, sm, smlen, NULL, 0, pk); -+} -diff --git a/ref/sign.h b/ref/sign.h -index 91d2001..7f80213 100644 ---- a/ref/sign.h -+++ b/ref/sign.h -@@ -13,25 +13,21 @@ int crypto_sign_keypair(uint8_t *pk, uint8_t *sk); - #define crypto_sign_signature DILITHIUM_NAMESPACE(signature) - int crypto_sign_signature(uint8_t *sig, size_t *siglen, - const uint8_t *m, size_t mlen, -- const uint8_t *ctx, size_t ctxlen, - const uint8_t *sk); - - #define crypto_sign DILITHIUM_NAMESPACETOP - int crypto_sign(uint8_t *sm, size_t *smlen, - const uint8_t *m, size_t mlen, -- const uint8_t *ctx, size_t ctxlen, - const uint8_t *sk); - - #define crypto_sign_verify DILITHIUM_NAMESPACE(verify) - int crypto_sign_verify(const uint8_t *sig, size_t siglen, - const uint8_t *m, size_t mlen, -- const uint8_t *ctx, size_t ctxlen, - const uint8_t *pk); - - #define crypto_sign_open DILITHIUM_NAMESPACE(open) - int crypto_sign_open(uint8_t *m, size_t *mlen, - const uint8_t *sm, size_t smlen, -- const uint8_t *ctx, size_t ctxlen, - const uint8_t *pk); - - #endif diff --git a/ref/symmetric-shake.c b/ref/symmetric-shake.c index 11ec09c..963f649 100644 --- a/ref/symmetric-shake.c @@ -1084,7 +673,7 @@ index 11ec09c..963f649 100644 + shake256_inc_finalize(state); } diff --git a/ref/symmetric.h b/ref/symmetric.h -index cba12d1..b6c74b7 100644 +index cba12d1..211de3b 100644 --- a/ref/symmetric.h +++ b/ref/symmetric.h @@ -6,16 +6,16 @@ @@ -1108,7 +697,7 @@ index cba12d1..b6c74b7 100644 const uint8_t seed[CRHBYTES], uint16_t nonce); -@@ -26,9 +26,12 @@ void dilithium_shake256_stream_init(keccak_state *state, +@@ -26,9 +26,11 @@ void dilithium_shake256_stream_init(keccak_state *state, dilithium_shake128_stream_init(STATE, SEED, NONCE) #define stream128_squeezeblocks(OUT, OUTBLOCKS, STATE) \ shake128_squeezeblocks(OUT, OUTBLOCKS, STATE) @@ -1118,6 +707,5 @@ index cba12d1..b6c74b7 100644 #define stream256_squeezeblocks(OUT, OUTBLOCKS, STATE) \ shake256_squeezeblocks(OUT, OUTBLOCKS, STATE) +#define stream256_release(STATE) shake256_inc_ctx_release(STATE) -+ #endif diff --git a/scripts/copy_from_upstream/src/sig/family/sig_family.h b/scripts/copy_from_upstream/src/sig/family/sig_family.h index 94d3a78c15..443f73ebe7 100644 --- a/scripts/copy_from_upstream/src/sig/family/sig_family.h +++ b/scripts/copy_from_upstream/src/sig/family/sig_family.h @@ -6,6 +6,7 @@ #include {% for scheme in schemes -%} +{%- set default_impl = scheme['metadata']['implementations'] | selectattr("name", "equalto", scheme['default_implementation']) | first -%} #if defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['scheme'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['alias_scheme'] }}){%- endif %} #define OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_length_public_key {{ scheme['metadata']['length-public-key'] }} #define OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_length_secret_key {{ scheme['metadata']['length-secret-key'] }} @@ -15,6 +16,10 @@ OQS_SIG *OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_new(void); OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_keypair(uint8_t *public_key, uint8_t *secret_key); OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +{%- if 'api-with-context-string' in default_impl and default_impl['api-with-context-string'] %} +OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); +{%- endif %} {% if 'alias_scheme' in scheme %} #define OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_length_public_key OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_length_public_key #define OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_length_secret_key OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_length_secret_key @@ -23,6 +28,10 @@ OQS_SIG *OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_new(void); #define OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_keypair OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_keypair #define OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_sign OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign #define OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_verify OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify +{%- if 'api-with-context-string' in default_impl and default_impl['api-with-context-string'] %} +#define OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_sign_with_ctx_str OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign +#define OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_verify_with_ctx_str OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify +{%- endif %} {% endif -%} #endif diff --git a/scripts/copy_from_upstream/src/sig/family/sig_scheme.c b/scripts/copy_from_upstream/src/sig/family/sig_scheme.c index 9c0a3bf29a..93aedde83f 100644 --- a/scripts/copy_from_upstream/src/sig/family/sig_scheme.c +++ b/scripts/copy_from_upstream/src/sig/family/sig_scheme.c @@ -9,6 +9,7 @@ {% if 'alias_scheme' in scheme %} #if defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['scheme'] }}) {% endif %} +{%- set default_impl = scheme['metadata']['implementations'] | selectattr("name", "equalto", scheme['default_implementation']) | first -%} OQS_SIG *OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -28,6 +29,13 @@ OQS_SIG *OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_new(void) { sig->keypair = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_keypair; sig->sign = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign; sig->verify = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify; + {%- if 'api-with-context-string' in default_impl and default_impl['api-with-context-string'] %} + sig->sign_with_ctx_str = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify_with_ctx_str; + {%- else %} + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; + {%- endif %} return sig; } @@ -58,6 +66,13 @@ OQS_SIG *OQS_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_new(void) { sig->keypair = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_keypair; sig->sign = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign; sig->verify = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify; + {%- if 'api-with-context-string' in default_impl and default_impl['api-with-context-string'] %} + sig->sign_with_ctx_str = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify_with_ctx_str; + {%- else %} + sig->sign_with_ctx_str = NULL + sig->verify_with_ctx_str = NULL; + {%- endif %} return sig; } @@ -257,5 +272,77 @@ OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify(const uint {%- endif %} } +{%- set default_impl = scheme['metadata']['implementations'] | selectattr("name", "equalto", scheme['default_implementation']) | first %} +{%- if 'api-with-context-string' in default_impl and default_impl['api-with-context-string'] %} +OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + {%- for impl in scheme['metadata']['implementations'] if impl['name'] != scheme['default_implementation'] %} + {%- if loop.first %} +#if defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}){%- endif %} + {%- else %} +#elif defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}){%- endif %} + {%- endif %} + {%- if 'required_flags' in impl and impl['required_flags'] %} +#if defined(OQS_DIST_BUILD) + if ({%- for flag in impl['required_flags'] -%}OQS_CPU_has_extension(OQS_CPU_EXT_{{ flag|upper }}){%- if not loop.last %} && {% endif -%}{%- endfor -%}) { +#endif /* OQS_DIST_BUILD */ + {%- endif %} + {%- if impl['signature_signature'] %} + return (OQS_STATUS) {{ impl['signature_signature'] }}(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); + {%- else %} + return (OQS_STATUS) PQCLEAN_{{ scheme['pqclean_scheme_c']|upper }}_{{ impl['name']|upper }}_crypto_sign_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); + {%- endif %} + {%- if 'required_flags' in impl and impl['required_flags'] %} +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) {{ scheme['metadata']['default_signature_signature'] }}(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ + {%- endif %} + {%- endfor %} + {%- if scheme['metadata']['implementations']|rejectattr('name', 'equalto', scheme['default_implementation'])|list %} +#else + {%- endif %} + {%- set default_impl = scheme['metadata']['implementations'] | selectattr("name", "equalto", scheme['default_implementation']) | first %} + return (OQS_STATUS) {{ scheme['metadata']['default_signature_signature'] }}(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); + {%- if scheme['metadata']['implementations']|rejectattr('name', 'equalto', scheme['default_implementation'])|list %} +#endif + {%- endif %} +} + +OQS_API OQS_STATUS OQS_SIG_{{ family }}_{{ scheme['scheme'] }}_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + {%- for impl in scheme['metadata']['implementations'] if impl['name'] != scheme['default_implementation'] %} + {%- if loop.first %} +#if defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}){%- endif %} + {%- else %} +#elif defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['scheme'] }}_{{ impl['name'] }}) {%- if 'alias_scheme' in scheme %} || defined(OQS_ENABLE_SIG_{{ family }}_{{ scheme['alias_scheme'] }}_{{ impl['name'] }}){%- endif %} + {%- endif %} + {%- if 'required_flags' in impl and impl['required_flags'] %} +#if defined(OQS_DIST_BUILD) + if ({%- for flag in impl['required_flags'] -%}OQS_CPU_has_extension(OQS_CPU_EXT_{{ flag|upper }}){%- if not loop.last %} && {% endif -%}{%- endfor -%}) { +#endif /* OQS_DIST_BUILD */ + {%- endif %} + {%- if impl['signature_verify'] %} + return (OQS_STATUS) {{ impl['signature_verify'] }}(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); + {%- else %} + return (OQS_STATUS) PQCLEAN_{{ scheme['pqclean_scheme_c']|upper }}_{{ impl['name']|upper }}_crypto_sign_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); + {%- endif %} + {%- if 'required_flags' in impl and impl['required_flags'] %} +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) {{ scheme['metadata']['default_verify_signature'] }}(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); + } +#endif /* OQS_DIST_BUILD */ + {%- endif %} + {%- endfor %} + {%- if scheme['metadata']['implementations']|rejectattr('name', 'equalto', scheme['default_implementation'])|list %} +#else + {%- endif %} + {%- set default_impl = scheme['metadata']['implementations'] | selectattr("name", "equalto", scheme['default_implementation']) | first %} + return (OQS_STATUS) {{ scheme['metadata']['default_verify_signature'] }}(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); + {%- if scheme['metadata']['implementations']|rejectattr('name', 'equalto', scheme['default_implementation'])|list %} +#endif + {%- endif %} +} +{%- endif %} #endif {% endfor -%} diff --git a/src/sig/cross/sig_cross_rsdp_128_balanced.c b/src/sig/cross/sig_cross_rsdp_128_balanced.c index 0460004239..f086ff9ff9 100644 --- a/src/sig/cross/sig_cross_rsdp_128_balanced.c +++ b/src/sig/cross/sig_cross_rsdp_128_balanced.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_128_balanced) - OQS_SIG *OQS_SIG_cross_rsdp_128_balanced_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_128_balanced_new(void) { sig->keypair = OQS_SIG_cross_rsdp_128_balanced_keypair; sig->sign = OQS_SIG_cross_rsdp_128_balanced_sign; sig->verify = OQS_SIG_cross_rsdp_128_balanced_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_balanced_verify(const uint8_t *message return (OQS_STATUS) PQCLEAN_CROSSRSDP128BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdp_128_fast.c b/src/sig/cross/sig_cross_rsdp_128_fast.c index 5ad9f0ae31..86c72a1860 100644 --- a/src/sig/cross/sig_cross_rsdp_128_fast.c +++ b/src/sig/cross/sig_cross_rsdp_128_fast.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_128_fast) - OQS_SIG *OQS_SIG_cross_rsdp_128_fast_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_128_fast_new(void) { sig->keypair = OQS_SIG_cross_rsdp_128_fast_keypair; sig->sign = OQS_SIG_cross_rsdp_128_fast_sign; sig->verify = OQS_SIG_cross_rsdp_128_fast_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_fast_verify(const uint8_t *message, si return (OQS_STATUS) PQCLEAN_CROSSRSDP128FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdp_128_small.c b/src/sig/cross/sig_cross_rsdp_128_small.c index 24fb6f6cb7..25b40e1bef 100644 --- a/src/sig/cross/sig_cross_rsdp_128_small.c +++ b/src/sig/cross/sig_cross_rsdp_128_small.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_128_small) - OQS_SIG *OQS_SIG_cross_rsdp_128_small_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_128_small_new(void) { sig->keypair = OQS_SIG_cross_rsdp_128_small_keypair; sig->sign = OQS_SIG_cross_rsdp_128_small_sign; sig->verify = OQS_SIG_cross_rsdp_128_small_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_128_small_verify(const uint8_t *message, s return (OQS_STATUS) PQCLEAN_CROSSRSDP128SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdp_192_balanced.c b/src/sig/cross/sig_cross_rsdp_192_balanced.c index f4cc950cb9..e9b39612ce 100644 --- a/src/sig/cross/sig_cross_rsdp_192_balanced.c +++ b/src/sig/cross/sig_cross_rsdp_192_balanced.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_192_balanced) - OQS_SIG *OQS_SIG_cross_rsdp_192_balanced_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_192_balanced_new(void) { sig->keypair = OQS_SIG_cross_rsdp_192_balanced_keypair; sig->sign = OQS_SIG_cross_rsdp_192_balanced_sign; sig->verify = OQS_SIG_cross_rsdp_192_balanced_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_balanced_verify(const uint8_t *message return (OQS_STATUS) PQCLEAN_CROSSRSDP192BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdp_192_fast.c b/src/sig/cross/sig_cross_rsdp_192_fast.c index 8bed778f65..9fe59d421a 100644 --- a/src/sig/cross/sig_cross_rsdp_192_fast.c +++ b/src/sig/cross/sig_cross_rsdp_192_fast.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_192_fast) - OQS_SIG *OQS_SIG_cross_rsdp_192_fast_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_192_fast_new(void) { sig->keypair = OQS_SIG_cross_rsdp_192_fast_keypair; sig->sign = OQS_SIG_cross_rsdp_192_fast_sign; sig->verify = OQS_SIG_cross_rsdp_192_fast_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_fast_verify(const uint8_t *message, si return (OQS_STATUS) PQCLEAN_CROSSRSDP192FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdp_192_small.c b/src/sig/cross/sig_cross_rsdp_192_small.c index 53864a8661..f78832ec00 100644 --- a/src/sig/cross/sig_cross_rsdp_192_small.c +++ b/src/sig/cross/sig_cross_rsdp_192_small.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_192_small) - OQS_SIG *OQS_SIG_cross_rsdp_192_small_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_192_small_new(void) { sig->keypair = OQS_SIG_cross_rsdp_192_small_keypair; sig->sign = OQS_SIG_cross_rsdp_192_small_sign; sig->verify = OQS_SIG_cross_rsdp_192_small_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_192_small_verify(const uint8_t *message, s return (OQS_STATUS) PQCLEAN_CROSSRSDP192SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdp_256_balanced.c b/src/sig/cross/sig_cross_rsdp_256_balanced.c index 3cd07a60bb..b8b8af1c40 100644 --- a/src/sig/cross/sig_cross_rsdp_256_balanced.c +++ b/src/sig/cross/sig_cross_rsdp_256_balanced.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_256_balanced) - OQS_SIG *OQS_SIG_cross_rsdp_256_balanced_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_256_balanced_new(void) { sig->keypair = OQS_SIG_cross_rsdp_256_balanced_keypair; sig->sign = OQS_SIG_cross_rsdp_256_balanced_sign; sig->verify = OQS_SIG_cross_rsdp_256_balanced_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_balanced_verify(const uint8_t *message return (OQS_STATUS) PQCLEAN_CROSSRSDP256BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdp_256_fast.c b/src/sig/cross/sig_cross_rsdp_256_fast.c index 3c954f9a28..76fcd382c7 100644 --- a/src/sig/cross/sig_cross_rsdp_256_fast.c +++ b/src/sig/cross/sig_cross_rsdp_256_fast.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_256_fast) - OQS_SIG *OQS_SIG_cross_rsdp_256_fast_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_256_fast_new(void) { sig->keypair = OQS_SIG_cross_rsdp_256_fast_keypair; sig->sign = OQS_SIG_cross_rsdp_256_fast_sign; sig->verify = OQS_SIG_cross_rsdp_256_fast_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_fast_verify(const uint8_t *message, si return (OQS_STATUS) PQCLEAN_CROSSRSDP256FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdp_256_small.c b/src/sig/cross/sig_cross_rsdp_256_small.c index f20039a911..206da024b5 100644 --- a/src/sig/cross/sig_cross_rsdp_256_small.c +++ b/src/sig/cross/sig_cross_rsdp_256_small.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdp_256_small) - OQS_SIG *OQS_SIG_cross_rsdp_256_small_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdp_256_small_new(void) { sig->keypair = OQS_SIG_cross_rsdp_256_small_keypair; sig->sign = OQS_SIG_cross_rsdp_256_small_sign; sig->verify = OQS_SIG_cross_rsdp_256_small_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdp_256_small_verify(const uint8_t *message, s return (OQS_STATUS) PQCLEAN_CROSSRSDP256SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_128_balanced.c b/src/sig/cross/sig_cross_rsdpg_128_balanced.c index 2877847715..7e82ac536c 100644 --- a/src/sig/cross/sig_cross_rsdpg_128_balanced.c +++ b/src/sig/cross/sig_cross_rsdpg_128_balanced.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_128_balanced) - OQS_SIG *OQS_SIG_cross_rsdpg_128_balanced_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_128_balanced_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_128_balanced_keypair; sig->sign = OQS_SIG_cross_rsdpg_128_balanced_sign; sig->verify = OQS_SIG_cross_rsdpg_128_balanced_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_128_balanced_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_CROSSRSDPG128BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_128_fast.c b/src/sig/cross/sig_cross_rsdpg_128_fast.c index cf10d6298d..fc4b9a4d18 100644 --- a/src/sig/cross/sig_cross_rsdpg_128_fast.c +++ b/src/sig/cross/sig_cross_rsdpg_128_fast.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_128_fast) - OQS_SIG *OQS_SIG_cross_rsdpg_128_fast_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_128_fast_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_128_fast_keypair; sig->sign = OQS_SIG_cross_rsdpg_128_fast_sign; sig->verify = OQS_SIG_cross_rsdpg_128_fast_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_128_fast_verify(const uint8_t *message, s return (OQS_STATUS) PQCLEAN_CROSSRSDPG128FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_128_small.c b/src/sig/cross/sig_cross_rsdpg_128_small.c index e2cab5d433..388e3fe849 100644 --- a/src/sig/cross/sig_cross_rsdpg_128_small.c +++ b/src/sig/cross/sig_cross_rsdpg_128_small.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_128_small) - OQS_SIG *OQS_SIG_cross_rsdpg_128_small_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_128_small_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_128_small_keypair; sig->sign = OQS_SIG_cross_rsdpg_128_small_sign; sig->verify = OQS_SIG_cross_rsdpg_128_small_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_128_small_verify(const uint8_t *message, return (OQS_STATUS) PQCLEAN_CROSSRSDPG128SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_192_balanced.c b/src/sig/cross/sig_cross_rsdpg_192_balanced.c index e85be184be..930635d5ad 100644 --- a/src/sig/cross/sig_cross_rsdpg_192_balanced.c +++ b/src/sig/cross/sig_cross_rsdpg_192_balanced.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_192_balanced) - OQS_SIG *OQS_SIG_cross_rsdpg_192_balanced_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_192_balanced_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_192_balanced_keypair; sig->sign = OQS_SIG_cross_rsdpg_192_balanced_sign; sig->verify = OQS_SIG_cross_rsdpg_192_balanced_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_192_balanced_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_CROSSRSDPG192BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_192_fast.c b/src/sig/cross/sig_cross_rsdpg_192_fast.c index 4c600ae14f..9d1383390a 100644 --- a/src/sig/cross/sig_cross_rsdpg_192_fast.c +++ b/src/sig/cross/sig_cross_rsdpg_192_fast.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_192_fast) - OQS_SIG *OQS_SIG_cross_rsdpg_192_fast_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_192_fast_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_192_fast_keypair; sig->sign = OQS_SIG_cross_rsdpg_192_fast_sign; sig->verify = OQS_SIG_cross_rsdpg_192_fast_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_192_fast_verify(const uint8_t *message, s return (OQS_STATUS) PQCLEAN_CROSSRSDPG192FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_192_small.c b/src/sig/cross/sig_cross_rsdpg_192_small.c index 624f02e458..ab6a56e37a 100644 --- a/src/sig/cross/sig_cross_rsdpg_192_small.c +++ b/src/sig/cross/sig_cross_rsdpg_192_small.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_192_small) - OQS_SIG *OQS_SIG_cross_rsdpg_192_small_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_192_small_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_192_small_keypair; sig->sign = OQS_SIG_cross_rsdpg_192_small_sign; sig->verify = OQS_SIG_cross_rsdpg_192_small_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_192_small_verify(const uint8_t *message, return (OQS_STATUS) PQCLEAN_CROSSRSDPG192SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_256_balanced.c b/src/sig/cross/sig_cross_rsdpg_256_balanced.c index 73f12fafbf..ecfdf76f02 100644 --- a/src/sig/cross/sig_cross_rsdpg_256_balanced.c +++ b/src/sig/cross/sig_cross_rsdpg_256_balanced.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_256_balanced) - OQS_SIG *OQS_SIG_cross_rsdpg_256_balanced_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_256_balanced_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_256_balanced_keypair; sig->sign = OQS_SIG_cross_rsdpg_256_balanced_sign; sig->verify = OQS_SIG_cross_rsdpg_256_balanced_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_256_balanced_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_CROSSRSDPG256BALANCED_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_256_fast.c b/src/sig/cross/sig_cross_rsdpg_256_fast.c index 1ebfa2c224..41013e5a53 100644 --- a/src/sig/cross/sig_cross_rsdpg_256_fast.c +++ b/src/sig/cross/sig_cross_rsdpg_256_fast.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_256_fast) - OQS_SIG *OQS_SIG_cross_rsdpg_256_fast_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_256_fast_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_256_fast_keypair; sig->sign = OQS_SIG_cross_rsdpg_256_fast_sign; sig->verify = OQS_SIG_cross_rsdpg_256_fast_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_256_fast_verify(const uint8_t *message, s return (OQS_STATUS) PQCLEAN_CROSSRSDPG256FAST_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/cross/sig_cross_rsdpg_256_small.c b/src/sig/cross/sig_cross_rsdpg_256_small.c index 6f105167e2..87f92b37fc 100644 --- a/src/sig/cross/sig_cross_rsdpg_256_small.c +++ b/src/sig/cross/sig_cross_rsdpg_256_small.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_cross_rsdpg_256_small) - OQS_SIG *OQS_SIG_cross_rsdpg_256_small_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_cross_rsdpg_256_small_new(void) { sig->keypair = OQS_SIG_cross_rsdpg_256_small_keypair; sig->sign = OQS_SIG_cross_rsdpg_256_small_sign; sig->verify = OQS_SIG_cross_rsdpg_256_small_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_cross_rsdpg_256_small_verify(const uint8_t *message, return (OQS_STATUS) PQCLEAN_CROSSRSDPG256SMALL_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/dilithium/sig_dilithium_2.c b/src/sig/dilithium/sig_dilithium_2.c index de1b2ad1fa..f29749abac 100644 --- a/src/sig/dilithium/sig_dilithium_2.c +++ b/src/sig/dilithium/sig_dilithium_2.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_dilithium_2) - OQS_SIG *OQS_SIG_dilithium_2_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_dilithium_2_new(void) { sig->keypair = OQS_SIG_dilithium_2_keypair; sig->sign = OQS_SIG_dilithium_2_sign; sig->verify = OQS_SIG_dilithium_2_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -122,5 +123,4 @@ OQS_API OQS_STATUS OQS_SIG_dilithium_2_verify(const uint8_t *message, size_t mes return (OQS_STATUS) pqcrystals_dilithium2_ref_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/dilithium/sig_dilithium_3.c b/src/sig/dilithium/sig_dilithium_3.c index f1a8311a20..b77ef78a25 100644 --- a/src/sig/dilithium/sig_dilithium_3.c +++ b/src/sig/dilithium/sig_dilithium_3.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_dilithium_3) - OQS_SIG *OQS_SIG_dilithium_3_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_dilithium_3_new(void) { sig->keypair = OQS_SIG_dilithium_3_keypair; sig->sign = OQS_SIG_dilithium_3_sign; sig->verify = OQS_SIG_dilithium_3_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -122,5 +123,4 @@ OQS_API OQS_STATUS OQS_SIG_dilithium_3_verify(const uint8_t *message, size_t mes return (OQS_STATUS) pqcrystals_dilithium3_ref_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/dilithium/sig_dilithium_5.c b/src/sig/dilithium/sig_dilithium_5.c index 06871be6e6..169e931581 100644 --- a/src/sig/dilithium/sig_dilithium_5.c +++ b/src/sig/dilithium/sig_dilithium_5.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_dilithium_5) - OQS_SIG *OQS_SIG_dilithium_5_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_dilithium_5_new(void) { sig->keypair = OQS_SIG_dilithium_5_keypair; sig->sign = OQS_SIG_dilithium_5_sign; sig->verify = OQS_SIG_dilithium_5_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -122,5 +123,4 @@ OQS_API OQS_STATUS OQS_SIG_dilithium_5_verify(const uint8_t *message, size_t mes return (OQS_STATUS) pqcrystals_dilithium5_ref_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/falcon/sig_falcon_1024.c b/src/sig/falcon/sig_falcon_1024.c index 06562cdea7..5bc485f5d8 100644 --- a/src/sig/falcon/sig_falcon_1024.c +++ b/src/sig/falcon/sig_falcon_1024.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_falcon_1024) - OQS_SIG *OQS_SIG_falcon_1024_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_falcon_1024_new(void) { sig->keypair = OQS_SIG_falcon_1024_keypair; sig->sign = OQS_SIG_falcon_1024_sign; sig->verify = OQS_SIG_falcon_1024_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -122,5 +123,4 @@ OQS_API OQS_STATUS OQS_SIG_falcon_1024_verify(const uint8_t *message, size_t mes return (OQS_STATUS) PQCLEAN_FALCON1024_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/falcon/sig_falcon_512.c b/src/sig/falcon/sig_falcon_512.c index d77e3eb735..6a883dde62 100644 --- a/src/sig/falcon/sig_falcon_512.c +++ b/src/sig/falcon/sig_falcon_512.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_falcon_512) - OQS_SIG *OQS_SIG_falcon_512_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_falcon_512_new(void) { sig->keypair = OQS_SIG_falcon_512_keypair; sig->sign = OQS_SIG_falcon_512_sign; sig->verify = OQS_SIG_falcon_512_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -122,5 +123,4 @@ OQS_API OQS_STATUS OQS_SIG_falcon_512_verify(const uint8_t *message, size_t mess return (OQS_STATUS) PQCLEAN_FALCON512_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/falcon/sig_falcon_padded_1024.c b/src/sig/falcon/sig_falcon_padded_1024.c index 53b8c3926d..c658bcf18a 100644 --- a/src/sig/falcon/sig_falcon_padded_1024.c +++ b/src/sig/falcon/sig_falcon_padded_1024.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_falcon_padded_1024) - OQS_SIG *OQS_SIG_falcon_padded_1024_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_falcon_padded_1024_new(void) { sig->keypair = OQS_SIG_falcon_padded_1024_keypair; sig->sign = OQS_SIG_falcon_padded_1024_sign; sig->verify = OQS_SIG_falcon_padded_1024_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -122,5 +123,4 @@ OQS_API OQS_STATUS OQS_SIG_falcon_padded_1024_verify(const uint8_t *message, siz return (OQS_STATUS) PQCLEAN_FALCONPADDED1024_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/falcon/sig_falcon_padded_512.c b/src/sig/falcon/sig_falcon_padded_512.c index 9521187b80..9e26828724 100644 --- a/src/sig/falcon/sig_falcon_padded_512.c +++ b/src/sig/falcon/sig_falcon_padded_512.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_falcon_padded_512) - OQS_SIG *OQS_SIG_falcon_padded_512_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_falcon_padded_512_new(void) { sig->keypair = OQS_SIG_falcon_padded_512_keypair; sig->sign = OQS_SIG_falcon_padded_512_sign; sig->verify = OQS_SIG_falcon_padded_512_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -122,5 +123,4 @@ OQS_API OQS_STATUS OQS_SIG_falcon_padded_512_verify(const uint8_t *message, size return (OQS_STATUS) PQCLEAN_FALCONPADDED512_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/mayo/sig_mayo_1.c b/src/sig/mayo/sig_mayo_1.c index 93034eb5ef..82a2c6ceb7 100644 --- a/src/sig/mayo/sig_mayo_1.c +++ b/src/sig/mayo/sig_mayo_1.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_mayo_1) - OQS_SIG *OQS_SIG_mayo_1_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_mayo_1_new(void) { sig->keypair = OQS_SIG_mayo_1_keypair; sig->sign = OQS_SIG_mayo_1_sign; sig->verify = OQS_SIG_mayo_1_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_mayo_1_verify(const uint8_t *message, size_t message_ return (OQS_STATUS) pqmayo_MAYO_1_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/mayo/sig_mayo_2.c b/src/sig/mayo/sig_mayo_2.c index 25719f0aee..145389c252 100644 --- a/src/sig/mayo/sig_mayo_2.c +++ b/src/sig/mayo/sig_mayo_2.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_mayo_2) - OQS_SIG *OQS_SIG_mayo_2_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_mayo_2_new(void) { sig->keypair = OQS_SIG_mayo_2_keypair; sig->sign = OQS_SIG_mayo_2_sign; sig->verify = OQS_SIG_mayo_2_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_mayo_2_verify(const uint8_t *message, size_t message_ return (OQS_STATUS) pqmayo_MAYO_2_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/mayo/sig_mayo_3.c b/src/sig/mayo/sig_mayo_3.c index 7a68024880..352c22ea0a 100644 --- a/src/sig/mayo/sig_mayo_3.c +++ b/src/sig/mayo/sig_mayo_3.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_mayo_3) - OQS_SIG *OQS_SIG_mayo_3_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_mayo_3_new(void) { sig->keypair = OQS_SIG_mayo_3_keypair; sig->sign = OQS_SIG_mayo_3_sign; sig->verify = OQS_SIG_mayo_3_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_mayo_3_verify(const uint8_t *message, size_t message_ return (OQS_STATUS) pqmayo_MAYO_3_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/mayo/sig_mayo_5.c b/src/sig/mayo/sig_mayo_5.c index ca19cfbf91..92fa41facb 100644 --- a/src/sig/mayo/sig_mayo_5.c +++ b/src/sig/mayo/sig_mayo_5.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_mayo_5) - OQS_SIG *OQS_SIG_mayo_5_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_mayo_5_new(void) { sig->keypair = OQS_SIG_mayo_5_keypair; sig->sign = OQS_SIG_mayo_5_sign; sig->verify = OQS_SIG_mayo_5_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_mayo_5_verify(const uint8_t *message, size_t message_ return (OQS_STATUS) pqmayo_MAYO_5_opt_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/ml_dsa/sig_ml_dsa.h b/src/sig/ml_dsa/sig_ml_dsa.h index 1c6b02369b..e5f00f4387 100644 --- a/src/sig/ml_dsa/sig_ml_dsa.h +++ b/src/sig/ml_dsa/sig_ml_dsa.h @@ -14,6 +14,8 @@ OQS_SIG *OQS_SIG_ml_dsa_44_new(void); OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_keypair(uint8_t *public_key, uint8_t *secret_key); OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); #endif #if defined(OQS_ENABLE_SIG_ml_dsa_65) @@ -25,6 +27,8 @@ OQS_SIG *OQS_SIG_ml_dsa_65_new(void); OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_keypair(uint8_t *public_key, uint8_t *secret_key); OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); #endif #if defined(OQS_ENABLE_SIG_ml_dsa_87) @@ -36,6 +40,8 @@ OQS_SIG *OQS_SIG_ml_dsa_87_new(void); OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_keypair(uint8_t *public_key, uint8_t *secret_key); OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_sign(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_verify(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *secret_key); +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx, size_t ctxlen, const uint8_t *public_key); #endif #endif diff --git a/src/sig/ml_dsa/sig_ml_dsa_44.c b/src/sig/ml_dsa/sig_ml_dsa_44.c index 3a24623f6e..0efdfa0c91 100644 --- a/src/sig/ml_dsa/sig_ml_dsa_44.c +++ b/src/sig/ml_dsa/sig_ml_dsa_44.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_ml_dsa_44) - OQS_SIG *OQS_SIG_ml_dsa_44_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_ml_dsa_44_new(void) { sig->keypair = OQS_SIG_ml_dsa_44_keypair; sig->sign = OQS_SIG_ml_dsa_44_sign; sig->verify = OQS_SIG_ml_dsa_44_verify; + sig->sign_with_ctx_str = OQS_SIG_ml_dsa_44_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_ml_dsa_44_verify_with_ctx_str; return sig; } @@ -86,5 +87,35 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_verify(const uint8_t *message, size_t messa return (OQS_STATUS) pqcrystals_ml_dsa_44_ref_verify(signature, signature_len, message, message_len, NULL, 0, public_key); #endif } +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_44_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) pqcrystals_ml_dsa_44_avx2_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) pqcrystals_ml_dsa_44_ref_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) pqcrystals_ml_dsa_44_ref_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); +#endif +} +OQS_API OQS_STATUS OQS_SIG_ml_dsa_44_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_44_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) pqcrystals_ml_dsa_44_avx2_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) pqcrystals_ml_dsa_44_ref_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) pqcrystals_ml_dsa_44_ref_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); +#endif +} #endif diff --git a/src/sig/ml_dsa/sig_ml_dsa_65.c b/src/sig/ml_dsa/sig_ml_dsa_65.c index 0f01b1d991..3bc4d5c95e 100644 --- a/src/sig/ml_dsa/sig_ml_dsa_65.c +++ b/src/sig/ml_dsa/sig_ml_dsa_65.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_ml_dsa_65) - OQS_SIG *OQS_SIG_ml_dsa_65_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_ml_dsa_65_new(void) { sig->keypair = OQS_SIG_ml_dsa_65_keypair; sig->sign = OQS_SIG_ml_dsa_65_sign; sig->verify = OQS_SIG_ml_dsa_65_verify; + sig->sign_with_ctx_str = OQS_SIG_ml_dsa_65_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_ml_dsa_65_verify_with_ctx_str; return sig; } @@ -86,5 +87,35 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_verify(const uint8_t *message, size_t messa return (OQS_STATUS) pqcrystals_ml_dsa_65_ref_verify(signature, signature_len, message, message_len, NULL, 0, public_key); #endif } +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_65_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) pqcrystals_ml_dsa_65_avx2_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) pqcrystals_ml_dsa_65_ref_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) pqcrystals_ml_dsa_65_ref_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); +#endif +} +OQS_API OQS_STATUS OQS_SIG_ml_dsa_65_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_65_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) pqcrystals_ml_dsa_65_avx2_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) pqcrystals_ml_dsa_65_ref_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) pqcrystals_ml_dsa_65_ref_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); +#endif +} #endif diff --git a/src/sig/ml_dsa/sig_ml_dsa_87.c b/src/sig/ml_dsa/sig_ml_dsa_87.c index 4f80c387fe..4422693baa 100644 --- a/src/sig/ml_dsa/sig_ml_dsa_87.c +++ b/src/sig/ml_dsa/sig_ml_dsa_87.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_ml_dsa_87) - OQS_SIG *OQS_SIG_ml_dsa_87_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_ml_dsa_87_new(void) { sig->keypair = OQS_SIG_ml_dsa_87_keypair; sig->sign = OQS_SIG_ml_dsa_87_sign; sig->verify = OQS_SIG_ml_dsa_87_verify; + sig->sign_with_ctx_str = OQS_SIG_ml_dsa_87_sign_with_ctx_str; + sig->verify_with_ctx_str = OQS_SIG_ml_dsa_87_verify_with_ctx_str; return sig; } @@ -86,5 +87,35 @@ OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_verify(const uint8_t *message, size_t messa return (OQS_STATUS) pqcrystals_ml_dsa_87_ref_verify(signature, signature_len, message, message_len, NULL, 0, public_key); #endif } +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_sign_with_ctx_str(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_87_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) pqcrystals_ml_dsa_87_avx2_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) pqcrystals_ml_dsa_87_ref_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) pqcrystals_ml_dsa_87_ref_signature(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key); +#endif +} +OQS_API OQS_STATUS OQS_SIG_ml_dsa_87_verify_with_ctx_str(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { +#if defined(OQS_ENABLE_SIG_ml_dsa_87_avx2) +#if defined(OQS_DIST_BUILD) + if (OQS_CPU_has_extension(OQS_CPU_EXT_AVX2) && OQS_CPU_has_extension(OQS_CPU_EXT_POPCNT)) { +#endif /* OQS_DIST_BUILD */ + return (OQS_STATUS) pqcrystals_ml_dsa_87_avx2_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); +#if defined(OQS_DIST_BUILD) + } else { + return (OQS_STATUS) pqcrystals_ml_dsa_87_ref_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); + } +#endif /* OQS_DIST_BUILD */ +#else + return (OQS_STATUS) pqcrystals_ml_dsa_87_ref_verify(signature, signature_len, message, message_len, ctx_str, ctx_str_len, public_key); +#endif +} #endif diff --git a/src/sig/sig.c b/src/sig/sig.c index 6778960afe..e8cfc9d14f 100644 --- a/src/sig/sig.c +++ b/src/sig/sig.c @@ -726,6 +726,14 @@ OQS_API OQS_STATUS OQS_SIG_sign(const OQS_SIG *sig, uint8_t *signature, size_t * } } +OQS_API OQS_STATUS OQS_SIG_sign_with_ctx_str(const OQS_SIG *sig, uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key) { + if (sig == NULL || sig->sign_with_ctx_str == NULL || sig->sign_with_ctx_str(signature, signature_len, message, message_len, ctx_str, ctx_str_len, secret_key) != OQS_SUCCESS) { + return OQS_ERROR; + } else { + return OQS_SUCCESS; + } +} + OQS_API OQS_STATUS OQS_SIG_verify(const OQS_SIG *sig, const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key) { if (sig == NULL || sig->verify(message, message_len, signature, signature_len, public_key) != OQS_SUCCESS) { return OQS_ERROR; @@ -734,6 +742,14 @@ OQS_API OQS_STATUS OQS_SIG_verify(const OQS_SIG *sig, const uint8_t *message, si } } +OQS_API OQS_STATUS OQS_SIG_verify_with_ctx_str(const OQS_SIG *sig, const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key) { + if (sig == NULL || sig->verify_with_ctx_str == NULL || sig->verify_with_ctx_str(message, message_len, signature, signature_len, ctx_str, ctx_str_len, public_key) != OQS_SUCCESS) { + return OQS_ERROR; + } else { + return OQS_SUCCESS; + } +} + OQS_API void OQS_SIG_free(OQS_SIG *sig) { OQS_MEM_insecure_free(sig); } diff --git a/src/sig/sig.h b/src/sig/sig.h index 45bd2da762..5ed672273c 100644 --- a/src/sig/sig.h +++ b/src/sig/sig.h @@ -215,6 +215,24 @@ typedef struct OQS_SIG { */ OQS_STATUS (*sign)(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); + /** + * Signature generation algorithm, with custom context string. + * + * Caller is responsible for allocating sufficient memory for `signature`, + * based on the `length_*` members in this object or the per-scheme + * compile-time macros `OQS_SIG_*_length_*`. + * + * @param[out] signature The signature on the message represented as a byte string. + * @param[out] signature_len The actual length of the signature. May be smaller than `length_signature` for some algorithms since some algorithms have variable length signatures. + * @param[in] message The message to sign represented as a byte string. + * @param[in] message_len The length of the message to sign. + * @param[in] ctx_str The context string for the signature. + * @param[in] ctx_str_len The length of the context string. + * @param[in] secret_key The secret key represented as a byte string. + * @return OQS_SUCCESS or OQS_ERROR + */ + OQS_STATUS (*sign_with_ctx_str)(uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key); + /** * Signature verification algorithm. * @@ -227,6 +245,21 @@ typedef struct OQS_SIG { */ OQS_STATUS (*verify)(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); + /** + * Signature verification algorithm, with custom context string. + * + * @param[in] message The message represented as a byte string. + * @param[in] message_len The length of the message. + * @param[in] signature The signature on the message represented as a byte string. + * @param[in] signature_len The length of the signature. + * @param[in] ctx_str The context string for the signature. + * @param[in] ctx_str_len The length of the context string. + * @param[in] public_key The public key represented as a byte string. + * @return OQS_SUCCESS or OQS_ERROR + */ + OQS_STATUS (*verify_with_ctx_str)(const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key); + + } OQS_SIG; /** @@ -271,6 +304,24 @@ OQS_API OQS_STATUS OQS_SIG_keypair(const OQS_SIG *sig, uint8_t *public_key, uint */ OQS_API OQS_STATUS OQS_SIG_sign(const OQS_SIG *sig, uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *secret_key); +/** + * Signature generation algorithm, with custom context string. + * + * Caller is responsible for allocating sufficient memory for `signature`, + * based on the `length_*` members in this object or the per-scheme + * compile-time macros `OQS_SIG_*_length_*`. + * + * @param[out] signature The signature on the message represented as a byte string. + * @param[out] signature_len The actual length of the signature. May be smaller than `length_signature` for some algorithms since some algorithms have variable length signatures. + * @param[in] message The message to sign represented as a byte string. + * @param[in] message_len The length of the message to sign. + * @param[in] ctx_str The context string for the signature. + * @param[in] ctx_str_len The length of the context string. + * @param[in] secret_key The secret key represented as a byte string. + * @return OQS_SUCCESS or OQS_ERROR + */ +OQS_API OQS_STATUS OQS_SIG_sign_with_ctx_str(const OQS_SIG *sig, uint8_t *signature, size_t *signature_len, const uint8_t *message, size_t message_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *secret_key); + /** * Signature verification algorithm. * @@ -284,6 +335,20 @@ OQS_API OQS_STATUS OQS_SIG_sign(const OQS_SIG *sig, uint8_t *signature, size_t * */ OQS_API OQS_STATUS OQS_SIG_verify(const OQS_SIG *sig, const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *public_key); +/** + * Signature verification algorithm, with custom context string. + * + * @param[in] message The message represented as a byte string. + * @param[in] message_len The length of the message. + * @param[in] signature The signature on the message represented as a byte string. + * @param[in] signature_len The length of the signature. + * @param[in] ctx_str The context string for the signature. + * @param[in] ctx_str_len The length of the context string. + * @param[in] public_key The public key represented as a byte string. + * @return OQS_SUCCESS or OQS_ERROR + */ +OQS_API OQS_STATUS OQS_SIG_verify_with_ctx_str(const OQS_SIG *sig, const uint8_t *message, size_t message_len, const uint8_t *signature, size_t signature_len, const uint8_t *ctx_str, size_t ctx_str_len, const uint8_t *public_key); + /** * Frees an OQS_SIG object that was constructed by OQS_SIG_new. * diff --git a/src/sig/sphincs/sig_sphincs_sha2_128f_simple.c b/src/sig/sphincs/sig_sphincs_sha2_128f_simple.c index d3872e9c3c..148101560f 100644 --- a/src/sig/sphincs/sig_sphincs_sha2_128f_simple.c +++ b/src/sig/sphincs/sig_sphincs_sha2_128f_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_sha2_128f_simple) - OQS_SIG *OQS_SIG_sphincs_sha2_128f_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_sha2_128f_simple_new(void) { sig->keypair = OQS_SIG_sphincs_sha2_128f_simple_keypair; sig->sign = OQS_SIG_sphincs_sha2_128f_simple_sign; sig->verify = OQS_SIG_sphincs_sha2_128f_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_sha2_128f_simple_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_SPHINCSSHA2128FSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_sha2_128s_simple.c b/src/sig/sphincs/sig_sphincs_sha2_128s_simple.c index d9dab73c1e..fb6bd067c1 100644 --- a/src/sig/sphincs/sig_sphincs_sha2_128s_simple.c +++ b/src/sig/sphincs/sig_sphincs_sha2_128s_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_sha2_128s_simple) - OQS_SIG *OQS_SIG_sphincs_sha2_128s_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_sha2_128s_simple_new(void) { sig->keypair = OQS_SIG_sphincs_sha2_128s_simple_keypair; sig->sign = OQS_SIG_sphincs_sha2_128s_simple_sign; sig->verify = OQS_SIG_sphincs_sha2_128s_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_sha2_128s_simple_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_SPHINCSSHA2128SSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_sha2_192f_simple.c b/src/sig/sphincs/sig_sphincs_sha2_192f_simple.c index b7e2cf4372..8ba31aa0b4 100644 --- a/src/sig/sphincs/sig_sphincs_sha2_192f_simple.c +++ b/src/sig/sphincs/sig_sphincs_sha2_192f_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_sha2_192f_simple) - OQS_SIG *OQS_SIG_sphincs_sha2_192f_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_sha2_192f_simple_new(void) { sig->keypair = OQS_SIG_sphincs_sha2_192f_simple_keypair; sig->sign = OQS_SIG_sphincs_sha2_192f_simple_sign; sig->verify = OQS_SIG_sphincs_sha2_192f_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_sha2_192f_simple_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_SPHINCSSHA2192FSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_sha2_192s_simple.c b/src/sig/sphincs/sig_sphincs_sha2_192s_simple.c index 5104a7e5be..2a017d9a1b 100644 --- a/src/sig/sphincs/sig_sphincs_sha2_192s_simple.c +++ b/src/sig/sphincs/sig_sphincs_sha2_192s_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_sha2_192s_simple) - OQS_SIG *OQS_SIG_sphincs_sha2_192s_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_sha2_192s_simple_new(void) { sig->keypair = OQS_SIG_sphincs_sha2_192s_simple_keypair; sig->sign = OQS_SIG_sphincs_sha2_192s_simple_sign; sig->verify = OQS_SIG_sphincs_sha2_192s_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_sha2_192s_simple_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_SPHINCSSHA2192SSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_sha2_256f_simple.c b/src/sig/sphincs/sig_sphincs_sha2_256f_simple.c index 3e372e359d..83c9c90465 100644 --- a/src/sig/sphincs/sig_sphincs_sha2_256f_simple.c +++ b/src/sig/sphincs/sig_sphincs_sha2_256f_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_sha2_256f_simple) - OQS_SIG *OQS_SIG_sphincs_sha2_256f_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_sha2_256f_simple_new(void) { sig->keypair = OQS_SIG_sphincs_sha2_256f_simple_keypair; sig->sign = OQS_SIG_sphincs_sha2_256f_simple_sign; sig->verify = OQS_SIG_sphincs_sha2_256f_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_sha2_256f_simple_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_SPHINCSSHA2256FSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_sha2_256s_simple.c b/src/sig/sphincs/sig_sphincs_sha2_256s_simple.c index c2e468ccde..a4712a7b92 100644 --- a/src/sig/sphincs/sig_sphincs_sha2_256s_simple.c +++ b/src/sig/sphincs/sig_sphincs_sha2_256s_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_sha2_256s_simple) - OQS_SIG *OQS_SIG_sphincs_sha2_256s_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_sha2_256s_simple_new(void) { sig->keypair = OQS_SIG_sphincs_sha2_256s_simple_keypair; sig->sign = OQS_SIG_sphincs_sha2_256s_simple_sign; sig->verify = OQS_SIG_sphincs_sha2_256s_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_sha2_256s_simple_verify(const uint8_t *messag return (OQS_STATUS) PQCLEAN_SPHINCSSHA2256SSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_shake_128f_simple.c b/src/sig/sphincs/sig_sphincs_shake_128f_simple.c index f3539ddb74..eaa9ad61c4 100644 --- a/src/sig/sphincs/sig_sphincs_shake_128f_simple.c +++ b/src/sig/sphincs/sig_sphincs_shake_128f_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_shake_128f_simple) - OQS_SIG *OQS_SIG_sphincs_shake_128f_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_shake_128f_simple_new(void) { sig->keypair = OQS_SIG_sphincs_shake_128f_simple_keypair; sig->sign = OQS_SIG_sphincs_shake_128f_simple_sign; sig->verify = OQS_SIG_sphincs_shake_128f_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_shake_128f_simple_verify(const uint8_t *messa return (OQS_STATUS) PQCLEAN_SPHINCSSHAKE128FSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_shake_128s_simple.c b/src/sig/sphincs/sig_sphincs_shake_128s_simple.c index c46327547a..e88824693d 100644 --- a/src/sig/sphincs/sig_sphincs_shake_128s_simple.c +++ b/src/sig/sphincs/sig_sphincs_shake_128s_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_shake_128s_simple) - OQS_SIG *OQS_SIG_sphincs_shake_128s_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_shake_128s_simple_new(void) { sig->keypair = OQS_SIG_sphincs_shake_128s_simple_keypair; sig->sign = OQS_SIG_sphincs_shake_128s_simple_sign; sig->verify = OQS_SIG_sphincs_shake_128s_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_shake_128s_simple_verify(const uint8_t *messa return (OQS_STATUS) PQCLEAN_SPHINCSSHAKE128SSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_shake_192f_simple.c b/src/sig/sphincs/sig_sphincs_shake_192f_simple.c index 9d48934cfb..76ead84587 100644 --- a/src/sig/sphincs/sig_sphincs_shake_192f_simple.c +++ b/src/sig/sphincs/sig_sphincs_shake_192f_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_shake_192f_simple) - OQS_SIG *OQS_SIG_sphincs_shake_192f_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_shake_192f_simple_new(void) { sig->keypair = OQS_SIG_sphincs_shake_192f_simple_keypair; sig->sign = OQS_SIG_sphincs_shake_192f_simple_sign; sig->verify = OQS_SIG_sphincs_shake_192f_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_shake_192f_simple_verify(const uint8_t *messa return (OQS_STATUS) PQCLEAN_SPHINCSSHAKE192FSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_shake_192s_simple.c b/src/sig/sphincs/sig_sphincs_shake_192s_simple.c index add522d162..2fe5ffba57 100644 --- a/src/sig/sphincs/sig_sphincs_shake_192s_simple.c +++ b/src/sig/sphincs/sig_sphincs_shake_192s_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_shake_192s_simple) - OQS_SIG *OQS_SIG_sphincs_shake_192s_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_shake_192s_simple_new(void) { sig->keypair = OQS_SIG_sphincs_shake_192s_simple_keypair; sig->sign = OQS_SIG_sphincs_shake_192s_simple_sign; sig->verify = OQS_SIG_sphincs_shake_192s_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_shake_192s_simple_verify(const uint8_t *messa return (OQS_STATUS) PQCLEAN_SPHINCSSHAKE192SSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_shake_256f_simple.c b/src/sig/sphincs/sig_sphincs_shake_256f_simple.c index 73143d77d0..cf6613de82 100644 --- a/src/sig/sphincs/sig_sphincs_shake_256f_simple.c +++ b/src/sig/sphincs/sig_sphincs_shake_256f_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_shake_256f_simple) - OQS_SIG *OQS_SIG_sphincs_shake_256f_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_shake_256f_simple_new(void) { sig->keypair = OQS_SIG_sphincs_shake_256f_simple_keypair; sig->sign = OQS_SIG_sphincs_shake_256f_simple_sign; sig->verify = OQS_SIG_sphincs_shake_256f_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_shake_256f_simple_verify(const uint8_t *messa return (OQS_STATUS) PQCLEAN_SPHINCSSHAKE256FSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif diff --git a/src/sig/sphincs/sig_sphincs_shake_256s_simple.c b/src/sig/sphincs/sig_sphincs_shake_256s_simple.c index 832292dc3d..81e01a96e7 100644 --- a/src/sig/sphincs/sig_sphincs_shake_256s_simple.c +++ b/src/sig/sphincs/sig_sphincs_shake_256s_simple.c @@ -5,7 +5,6 @@ #include #if defined(OQS_ENABLE_SIG_sphincs_shake_256s_simple) - OQS_SIG *OQS_SIG_sphincs_shake_256s_simple_new(void) { OQS_SIG *sig = malloc(sizeof(OQS_SIG)); @@ -25,6 +24,8 @@ OQS_SIG *OQS_SIG_sphincs_shake_256s_simple_new(void) { sig->keypair = OQS_SIG_sphincs_shake_256s_simple_keypair; sig->sign = OQS_SIG_sphincs_shake_256s_simple_sign; sig->verify = OQS_SIG_sphincs_shake_256s_simple_verify; + sig->sign_with_ctx_str = NULL; + sig->verify_with_ctx_str = NULL; return sig; } @@ -86,5 +87,4 @@ OQS_API OQS_STATUS OQS_SIG_sphincs_shake_256s_simple_verify(const uint8_t *messa return (OQS_STATUS) PQCLEAN_SPHINCSSHAKE256SSIMPLE_CLEAN_crypto_sign_verify(signature, signature_len, message, message_len, public_key); #endif } - #endif