Skip to content

Commit 3fd13b8

Browse files
committed
Guard old non-ctx ML-DSA API by default
1 parent 4b8c524 commit 3fd13b8

10 files changed

Lines changed: 7872 additions & 28 deletions

File tree

.github/workflows/pq-all.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-mlkem=make,enc,dec,1024 --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
3535
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-mlkem=make,enc,dec,1024 --enable-tls-mlkem-standalone --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
3636
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-mlkem=make,enc,dec,1024 --enable-tls-mlkem-standalone --disable-pqc-hybrids --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
37+
'--enable-intelasm --enable-sp-asm --enable-all --enable-testcert --enable-acert --enable-dtls13 --enable-dtls-mtu --enable-dtls-frag-ch --enable-dtlscid --enable-quic --with-sys-crypto-policy --enable-experimental --enable-mlkem=yes,kyber,ml-kem --enable-lms --enable-xmss --enable-slhdsa --enable-dilithium=yes,no-ctx --enable-dual-alg-certs --disable-qt CPPFLAGS="-pedantic -Wdeclaration-after-statement -DWOLFCRYPT_TEST_LINT -DNO_WOLFSSL_CIPHER_SUITE_TEST -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE"',
3738
]
3839
name: make check
3940
if: github.repository_owner == 'wolfssl'

configure.ac

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1819,8 +1819,11 @@ do
18191819
draft|fips204-draft)
18201820
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DILITHIUM_FIPS204_DRAFT"
18211821
;;
1822+
no-ctx)
1823+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DILITHIUM_NO_CTX"
1824+
;;
18221825
*)
1823-
AC_MSG_ERROR([Invalid choice for DILITHIUM [all,make,sign,verify,verify-only,small,44,65,87]: $ENABLED_DILITHIUM.])
1826+
AC_MSG_ERROR([Invalid choice for DILITHIUM [all,make,sign,verify,verify-only,small,44,65,87,no-ctx]: $ENABLED_DILITHIUM.])
18241827
break;;
18251828
esac
18261829
done

tests/api/test_mldsa.c

Lines changed: 7791 additions & 5 deletions
Large diffs are not rendered by default.

tests/api/test_mldsa.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ int test_wc_dilithium_public_der_decode(void);
3434
int test_wc_dilithium_der(void);
3535
int test_wc_dilithium_make_key_from_seed(void);
3636
int test_wc_dilithium_sig_kats(void);
37+
int test_wc_dilithium_sign_ctx_kats(void);
38+
int test_wc_dilithium_verify_ctx_kats(void);
3739
int test_wc_dilithium_verify_kats(void);
3840
int test_wc_Dilithium_PrivateKeyDecode_OpenSSL_form(void);
3941
int test_mldsa_pkcs8_import_OpenSSL_form(void);
@@ -51,6 +53,8 @@ int test_mldsa_pkcs12(void);
5153
TEST_DECL_GROUP("mldsa", test_wc_dilithium_der), \
5254
TEST_DECL_GROUP("mldsa", test_wc_dilithium_make_key_from_seed), \
5355
TEST_DECL_GROUP("mldsa", test_wc_dilithium_sig_kats), \
56+
TEST_DECL_GROUP("mldsa", test_wc_dilithium_sign_ctx_kats), \
57+
TEST_DECL_GROUP("mldsa", test_wc_dilithium_verify_ctx_kats), \
5458
TEST_DECL_GROUP("mldsa", test_wc_dilithium_verify_kats), \
5559
TEST_DECL_GROUP("mldsa", test_wc_Dilithium_PrivateKeyDecode_OpenSSL_form), \
5660
TEST_DECL_GROUP("mldsa", test_mldsa_pkcs8_import_OpenSSL_form), \

wolfcrypt/benchmark/benchmark.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15557,10 +15557,10 @@ void bench_dilithiumKeySign(byte level)
1555715557
do {
1555815558
for (i = 0; i < agreeTimes; i++) {
1555915559
if (ret == 0) {
15560-
ret = wc_dilithium_sign_msg(msg, DILITHIUM_BENCH_MSG_SIZE, sig, &x, key,
15561-
GLOBAL_RNG);
15560+
ret = wc_dilithium_sign_ctx_msg(NULL, 0, msg,
15561+
DILITHIUM_BENCH_MSG_SIZE, sig, &x, key, GLOBAL_RNG);
1556215562
if (ret != 0) {
15563-
printf("wc_dilithium_sign_msg failed\n");
15563+
printf("wc_dilithium_sign_ctx_msg failed\n");
1556415564
}
1556515565
}
1556615566
RECORD_MULTI_VALUE_STATS();
@@ -15631,11 +15631,11 @@ void bench_dilithiumKeySign(byte level)
1563115631
for (i = 0; i < agreeTimes; i++) {
1563215632
if (ret == 0) {
1563315633
int verify = 0;
15634-
ret = wc_dilithium_verify_msg(sig, x, msg, DILITHIUM_BENCH_MSG_SIZE,
15635-
&verify, key);
15634+
ret = wc_dilithium_verify_ctx_msg(sig, x, NULL, 0, msg,
15635+
DILITHIUM_BENCH_MSG_SIZE, &verify, key);
1563615636

1563715637
if (ret != 0 || verify != 1) {
15638-
printf("wc_dilithium_verify_msg failed %d, verify %d\n",
15638+
printf("wc_dilithium_verify_ctx_msg failed %d, verify %d\n",
1563915639
ret, verify);
1564015640
ret = -1;
1564115641
}

wolfcrypt/src/dilithium.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9038,6 +9038,7 @@ static int dilithium_sign_ctx_msg_with_seed(dilithium_key* key,
90389038
* @return MEMORY_E when memory allocation fails.
90399039
* @return Other negative when an error occurs.
90409040
*/
9041+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
90419042
static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed,
90429043
const byte* msg, word32 msgLen, byte* sig, word32 *sigLen)
90439044
{
@@ -9058,6 +9059,7 @@ static int dilithium_sign_msg_with_seed(dilithium_key* key, const byte* seed,
90589059

90599060
return ret;
90609061
}
9062+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
90619063

90629064
/* Sign a message with the key and a random number generator.
90639065
*
@@ -9153,6 +9155,7 @@ static int dilithium_sign_ctx_msg(dilithium_key* key, WC_RNG* rng,
91539155
* @return MEMORY_E when memory allocation fails.
91549156
* @return Other negative when an error occurs.
91559157
*/
9158+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
91569159
static int dilithium_sign_msg(dilithium_key* key, WC_RNG* rng,
91579160
const byte* msg, word32 msgLen, byte* sig, word32 *sigLen)
91589161
{
@@ -9183,6 +9186,7 @@ static int dilithium_sign_msg(dilithium_key* key, WC_RNG* rng,
91839186

91849187
return ret;
91859188
}
9189+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
91869190

91879191
/* Sign a pre-hashed message with the key and a seed.
91889192
*
@@ -9825,6 +9829,7 @@ static int dilithium_verify_ctx_msg(dilithium_key* key, const byte* ctx,
98259829
return ret;
98269830
}
98279831

9832+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
98289833
/* Verify signature of message using public key.
98299834
*
98309835
* @param [in, out] key Dilithium key.
@@ -9867,6 +9872,7 @@ static int dilithium_verify_msg(dilithium_key* key, const byte* msg,
98679872

98689873
return ret;
98699874
}
9875+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
98709876

98719877
/* Verify signature of message using public key.
98729878
*
@@ -10084,7 +10090,7 @@ static int oqs_dilithium_verify_msg(const byte* sig, word32 sigLen,
1008410090
}
1008510091
return ret;
1008610092
}
10087-
#endif /* WOLFSSL_DILITHIUM_NO_VERIFY */
10093+
#endif /* !WOLFSSL_DILITHIUM_NO_VERIFY */
1008810094

1008910095
#else
1009010096
#error "No dilithium implementation chosen."
@@ -10222,6 +10228,7 @@ int wc_dilithium_sign_ctx_msg(const byte* ctx, byte ctxLen, const byte* msg,
1022210228
return ret;
1022310229
}
1022410230

10231+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
1022510232
/* Sign the message using the dilithium private key.
1022610233
*
1022710234
* msg [in] Message to sign.
@@ -10233,6 +10240,8 @@ int wc_dilithium_sign_ctx_msg(const byte* ctx, byte ctxLen, const byte* msg,
1023310240
* returns BAD_FUNC_ARG when a parameter is NULL or public key not set,
1023410241
* BUFFER_E when outLen is less than DILITHIUM_LEVEL2_SIG_SIZE,
1023510242
* 0 otherwise.
10243+
* NOTE: This is a pre-FIPS 204 API without context support. New code should
10244+
* use wc_dilithium_sign_ctx_msg() with ctx=NULL/ctxLen=0 instead.
1023610245
*/
1023710246
int wc_dilithium_sign_msg(const byte* msg, word32 msgLen, byte* sig,
1023810247
word32 *sigLen, dilithium_key* key, WC_RNG* rng)
@@ -10271,6 +10280,7 @@ int wc_dilithium_sign_msg(const byte* msg, word32 msgLen, byte* sig,
1027110280

1027210281
return ret;
1027310282
}
10283+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
1027410284

1027510285
/* Sign the message hash using the dilithium private key.
1027610286
*
@@ -10379,6 +10389,7 @@ int wc_dilithium_sign_ctx_msg_with_seed(const byte* ctx, byte ctxLen,
1037910389
return ret;
1038010390
}
1038110391

10392+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
1038210393
/* Sign the message using the dilithium private key.
1038310394
*
1038410395
* msg [in] Message to sign.
@@ -10390,6 +10401,8 @@ int wc_dilithium_sign_ctx_msg_with_seed(const byte* ctx, byte ctxLen,
1039010401
* returns BAD_FUNC_ARG when a parameter is NULL or public key not set,
1039110402
* BUFFER_E when outLen is less than DILITHIUM_LEVEL2_SIG_SIZE,
1039210403
* 0 otherwise.
10404+
* NOTE: This is a pre-FIPS 204 API without context support. New code should
10405+
* use wc_dilithium_sign_ctx_msg_with_seed() instead.
1039310406
*/
1039410407
int wc_dilithium_sign_msg_with_seed(const byte* msg, word32 msgLen, byte* sig,
1039510408
word32 *sigLen, dilithium_key* key, const byte* seed)
@@ -10414,6 +10427,7 @@ int wc_dilithium_sign_msg_with_seed(const byte* msg, word32 msgLen, byte* sig,
1041410427

1041510428
return ret;
1041610429
}
10430+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
1041710431

1041810432
/* Sign the message using the dilithium private key.
1041910433
*
@@ -10514,16 +10528,14 @@ int wc_dilithium_verify_ctx_msg(const byte* sig, word32 sigLen, const byte* ctx,
1051410528
ret = dilithium_verify_ctx_msg(key, ctx, ctxLen, msg, msgLen, sig,
1051510529
sigLen, res);
1051610530
#elif defined(HAVE_LIBOQS)
10517-
ret = NOT_COMPILED_IN;
10518-
(void)sigLen;
10519-
(void)msgLen;
10520-
(void)res;
10531+
ret = oqs_dilithium_verify_msg(sig, sigLen, msg, msgLen, res, key);
1052110532
#endif
1052210533
}
1052310534

1052410535
return ret;
1052510536
}
1052610537

10538+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
1052710539
/* Verify the message using the dilithium public key.
1052810540
*
1052910541
* sig [in] Signature to verify.
@@ -10535,6 +10547,8 @@ int wc_dilithium_verify_ctx_msg(const byte* sig, word32 sigLen, const byte* ctx,
1053510547
* returns BAD_FUNC_ARG when a parameter is NULL or contextLen is zero when and
1053610548
* BUFFER_E when sigLen is less than DILITHIUM_LEVEL2_SIG_SIZE,
1053710549
* 0 otherwise.
10550+
* NOTE: This is a pre-FIPS 204 API without context support. New code should
10551+
* use wc_dilithium_verify_ctx_msg() with ctx=NULL/ctxLen=0 instead.
1053810552
*/
1053910553
int wc_dilithium_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
1054010554
word32 msgLen, int* res, dilithium_key* key)
@@ -10573,6 +10587,7 @@ int wc_dilithium_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
1057310587

1057410588
return ret;
1057510589
}
10590+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
1057610591

1057710592
/* Verify the message using the dilithium public key.
1057810593
*

wolfcrypt/test/test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50246,14 +50246,14 @@ static wc_test_ret_t dilithium_param_test(int param, WC_RNG* rng)
5024650246
if (sigLen <= 0)
5024750247
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
5024850248

50249-
ret = wc_dilithium_sign_msg(msg, (word32)sizeof(msg), sig, &sigLen, key,
50250-
rng);
50249+
ret = wc_dilithium_sign_ctx_msg(NULL, 0, msg, (word32)sizeof(msg), sig,
50250+
&sigLen, key, rng);
5025150251
if (ret != 0)
5025250252
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
5025350253

5025450254
#ifndef WOLFSSL_DILITHIUM_NO_VERIFY
50255-
ret = wc_dilithium_verify_msg(sig, sigLen, msg, (word32)sizeof(msg), &res,
50256-
key);
50255+
ret = wc_dilithium_verify_ctx_msg(sig, sigLen, NULL, 0, msg,
50256+
(word32)sizeof(msg), &res, key);
5025750257
if (ret != 0)
5025850258
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
5025950259
if (res != 1)

wolfssl/wolfcrypt/dilithium.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,13 @@ struct dilithium_key {
803803
#define WC_DILITHIUMKEY_TYPE_DEFINED
804804
#endif
805805

806+
/* When WOLFSSL_DILITHIUM_FIPS204_DRAFT is enabled the legacy (pre-FIPS 204)
807+
* no-context sign/verify API is required to handle draft-format signatures. */
808+
#if defined(WOLFSSL_DILITHIUM_FIPS204_DRAFT) && \
809+
!defined(WOLFSSL_DILITHIUM_NO_CTX)
810+
#define WOLFSSL_DILITHIUM_NO_CTX
811+
#endif
812+
806813
/* Functions */
807814

808815
#ifndef WOLFSSL_DILITHIUM_VERIFY_ONLY
@@ -811,19 +818,30 @@ int wc_dilithium_make_key(dilithium_key* key, WC_RNG* rng);
811818
WOLFSSL_API
812819
int wc_dilithium_make_key_from_seed(dilithium_key* key, const byte* seed);
813820

821+
/* Legacy sign API without context parameter (pre-FIPS 204).
822+
* Only available when WOLFSSL_DILITHIUM_NO_CTX is defined.
823+
* New code should use wc_dilithium_sign_ctx_msg() with ctx=NULL/ctxLen=0
824+
* for FIPS 204 compliant signing with an empty context. */
825+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
814826
WOLFSSL_API
815827
int wc_dilithium_sign_msg(const byte* msg, word32 msgLen, byte* sig,
816828
word32* sigLen, dilithium_key* key, WC_RNG* rng);
829+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
817830
WOLFSSL_API
818831
int wc_dilithium_sign_ctx_msg(const byte* ctx, byte ctxLen, const byte* msg,
819832
word32 msgLen, byte* sig, word32* sigLen, dilithium_key* key, WC_RNG* rng);
820833
WOLFSSL_API
821834
int wc_dilithium_sign_ctx_hash(const byte* ctx, byte ctxLen, int hashAlg,
822835
const byte* hash, word32 hashLen, byte* sig, word32* sigLen,
823836
dilithium_key* key, WC_RNG* rng);
837+
/* Legacy seed-based sign API without context parameter (pre-FIPS 204).
838+
* Only available when WOLFSSL_DILITHIUM_NO_CTX is defined.
839+
* New code should use wc_dilithium_sign_ctx_msg_with_seed() instead. */
840+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
824841
WOLFSSL_API
825842
int wc_dilithium_sign_msg_with_seed(const byte* msg, word32 msgLen, byte* sig,
826843
word32 *sigLen, dilithium_key* key, const byte* seed);
844+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
827845
WOLFSSL_API
828846
int wc_dilithium_sign_ctx_msg_with_seed(const byte* ctx, byte ctxLen,
829847
const byte* msg, word32 msgLen, byte* sig, word32 *sigLen,
@@ -832,10 +850,16 @@ WOLFSSL_API
832850
int wc_dilithium_sign_ctx_hash_with_seed(const byte* ctx, byte ctxLen,
833851
int hashAlg, const byte* hash, word32 hashLen, byte* sig, word32 *sigLen,
834852
dilithium_key* key, const byte* seed);
835-
#endif
853+
#endif /* !WOLFSSL_DILITHIUM_VERIFY_ONLY */
854+
/* Legacy verify API without context parameter (pre-FIPS 204).
855+
* Only available when WOLFSSL_DILITHIUM_NO_CTX is defined.
856+
* New code should use wc_dilithium_verify_ctx_msg() with ctx=NULL/ctxLen=0
857+
* for FIPS 204 compliant verification with an empty context. */
858+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
836859
WOLFSSL_API
837860
int wc_dilithium_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
838861
word32 msgLen, int* res, dilithium_key* key);
862+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
839863
WOLFSSL_API
840864
int wc_dilithium_verify_ctx_msg(const byte* sig, word32 sigLen, const byte* ctx,
841865
byte ctxLen, const byte* msg, word32 msgLen, int* res,
@@ -1074,8 +1098,12 @@ WOLFSSL_LOCAL void wc_mldsa_poly_make_pos_avx2(sword32* a);
10741098
wc_dilithium_export_private_only(key, out, outLen)
10751099
#define wc_MlDsaKey_ImportPrivRaw(key, in, inLen) \
10761100
wc_dilithium_import_private_only(in, inLen, key)
1101+
/* Legacy no-context sign alias: only available with WOLFSSL_DILITHIUM_NO_CTX.
1102+
* Prefer wc_MlDsaKey_SignCtx() with empty context for FIPS 204 compliance. */
1103+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
10771104
#define wc_MlDsaKey_Sign(key, sig, sigSz, msg, msgSz, rng) \
10781105
wc_dilithium_sign_msg(msg, msgSz, sig, sigSz, key, rng)
1106+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
10791107
#define wc_MlDsaKey_SignCtx(key, ctx, ctxSz, sig, sigSz, msg, msgSz, rng) \
10801108
wc_dilithium_sign_ctx_msg(ctx, ctxSz, msg, msgSz, sig, sigSz, key, rng)
10811109
#define wc_MlDsaKey_SignCtxHash(key, ctx, ctxSz, sig, sigSz, hash, hashSz, \
@@ -1088,8 +1116,12 @@ WOLFSSL_LOCAL void wc_mldsa_poly_make_pos_avx2(sword32* a);
10881116
wc_dilithium_export_public(key, out, outLen)
10891117
#define wc_MlDsaKey_ImportPubRaw(key, in, inLen) \
10901118
wc_dilithium_import_public(in, inLen, key)
1119+
/* Legacy no-context verify alias: only available with WOLFSSL_DILITHIUM_NO_CTX.
1120+
* Prefer wc_MlDsaKey_VerifyCtx() with empty context for FIPS 204 compliance. */
1121+
#ifdef WOLFSSL_DILITHIUM_NO_CTX
10911122
#define wc_MlDsaKey_Verify(key, sig, sigSz, msg, msgSz, res) \
10921123
wc_dilithium_verify_msg(sig, sigSz, msg, msgSz, res, key)
1124+
#endif /* WOLFSSL_DILITHIUM_NO_CTX */
10931125
#define wc_MlDsaKey_VerifyCtx(key, sig, sigSz, ctx, ctxSz, msg, msgSz, res) \
10941126
wc_dilithium_verify_ctx_msg(sig, sigSz, ctx, ctxSz, msg, msgSz, res, key)
10951127
#define wc_MlDsaKey_VerifyCtxHash(key, sig, sigSz, ctx, ctxSz, hash, hashSz, \

wrapper/rust/wolfssl-wolfcrypt/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ fn scan_cfg() -> Result<()> {
316316
check_cfg(&binding, "wc_dilithium_init", "dilithium");
317317
check_cfg(&binding, "wc_dilithium_make_key", "dilithium_make_key");
318318
check_cfg(&binding, "wc_dilithium_make_key_from_seed", "dilithium_make_key_from_seed");
319-
check_cfg(&binding, "wc_dilithium_sign_msg", "dilithium_sign");
320-
check_cfg(&binding, "wc_dilithium_sign_msg_with_seed", "dilithium_sign_with_seed");
321-
check_cfg(&binding, "wc_dilithium_verify_msg", "dilithium_verify");
319+
check_cfg(&binding, "wc_dilithium_sign_ctx_msg", "dilithium_sign");
320+
check_cfg(&binding, "wc_dilithium_sign_ctx_msg_with_seed", "dilithium_sign_with_seed");
321+
check_cfg(&binding, "wc_dilithium_verify_ctx_msg", "dilithium_verify");
322322
check_cfg(&binding, "wc_dilithium_import_public", "dilithium_import");
323323
check_cfg(&binding, "wc_dilithium_export_public", "dilithium_export");
324324
check_cfg(&binding, "wc_dilithium_check_key", "dilithium_check_key");

wrapper/rust/wolfssl-wolfcrypt/src/dilithium.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,8 @@ impl Dilithium {
867867
let msg_len = msg.len() as u32;
868868
let mut sig_len = sig.len() as u32;
869869
let rc = unsafe {
870-
sys::wc_dilithium_sign_msg(
870+
sys::wc_dilithium_sign_ctx_msg(
871+
core::ptr::null(), 0,
871872
msg.as_ptr(), msg_len,
872873
sig.as_mut_ptr(), &mut sig_len,
873874
&mut self.ws_key,
@@ -1038,7 +1039,8 @@ impl Dilithium {
10381039
let msg_len = msg.len() as u32;
10391040
let mut sig_len = sig.len() as u32;
10401041
let rc = unsafe {
1041-
sys::wc_dilithium_sign_msg_with_seed(
1042+
sys::wc_dilithium_sign_ctx_msg_with_seed(
1043+
core::ptr::null(), 0,
10421044
msg.as_ptr(), msg_len,
10431045
sig.as_mut_ptr(), &mut sig_len,
10441046
&mut self.ws_key,
@@ -1184,8 +1186,9 @@ impl Dilithium {
11841186
let msg_len = msg.len() as u32;
11851187
let mut res = 0i32;
11861188
let rc = unsafe {
1187-
sys::wc_dilithium_verify_msg(
1189+
sys::wc_dilithium_verify_ctx_msg(
11881190
sig.as_ptr(), sig_len,
1191+
core::ptr::null(), 0,
11891192
msg.as_ptr(), msg_len,
11901193
&mut res,
11911194
&mut self.ws_key,

0 commit comments

Comments
 (0)