Skip to content

Commit 799bd17

Browse files
authored
Merge pull request wolfSSL#11654 from dgarske/mldsa_small_mem
Fix two problems with ML-DSA small-memory builds
2 parents ddb5b32 + 8639f52 commit 799bd17

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎.github/configs/pq-all.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@
186186
"configure": ["--enable-mlkem", "--enable-mldsa",
187187
"--enable-tls-mlkem-standalone", "--enable-session-ticket",
188188
"--disable-rsa", "--disable-ecc", "--disable-dh"]},
189+
{"name": "mldsa-verify-only-smallest-mem-no-asn1", "minutes": 2.0,
190+
"comment": "The combination an embedded verifier actually ships: verify only, the smallest-memory verify path, and no ASN.1. Only this config reaches benchmark.c's no-sign branch, which verifies the baked bench_mldsa_NN_sig arrays rather than a signature it just made, so the signature and the imported public key have to be the same key pair. The existing no-ASN.1 rows build signing too, so they never take that branch. The benchmark exits 0 whether or not verification succeeded, and a level whose key import fails prints and moves on to the next one, so the run asserts a verify row for each of the three levels rather than just one. Built with -Werror=unused-function, as a verify-only build is where a helper loses its last caller.",
191+
"check": false,
192+
"extra_cflags": "-Werror=unused-function",
193+
"configure": ["--disable-intelasm", "--enable-experimental",
194+
"--enable-dilithium=yes,small,verify-only",
195+
"CPPFLAGS=-pedantic -Wdeclaration-after-statement -Wnull-dereference -DWOLFSSL_MLDSA_VERIFY_SMALLEST_MEM -DWOLFSSL_MLDSA_NO_ASN1 -DWOLFSSL_MLDSA_NO_LARGE_CODE"],
196+
"run": [["sh", "-c", "out=$(./wolfcrypt/benchmark/benchmark -ml-dsa 2>&1) || exit 1; printf '%s\\n' \"$out\"; if printf '%s\\n' \"$out\" | grep -qE 'VerifyCtx failed|Failed to load (public|private) key'; then echo 'ML-DSA verify or key load failed' >&2; exit 1; fi; for lvl in 44 65 87; do printf '%s\\n' \"$out\" | grep -qE \"^ML-DSA +$lvl +verify\" || { echo \"no ML-DSA-$lvl verify row reported\" >&2; exit 1; }; done"]]},
189197
{"name": "mldsa-dynamic-keys", "minutes": 1.8,
190198
"configure": ["--enable-intelasm", "--enable-sp-asm",
191199
"--enable-dilithium=yes", "CPPFLAGS=-DWOLFSSL_MLDSA_DYNAMIC_KEYS"]},

‎wolfcrypt/benchmark/benchmark.c‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18323,6 +18323,15 @@ void bench_mldsaKeySign(byte level)
1832318323
#ifndef WOLFSSL_MLDSA_NO_ASN1
1832418324
ret = wc_MlDsaKey_PublicKeyDecode(key, mldsa44_pub_spki,
1832518325
sizeof_mldsa44_pub_spki, &idx);
18326+
#elif defined(WOLFSSL_MLDSA_NO_SIGN)
18327+
/* The baked signature above was made with
18328+
* certs/mldsa/mldsa44_priv-only.der and verifies only under that
18329+
* key. Take its raw encoding from the SPKI payload;
18330+
* bench_mldsa_44_pubkey is an unrelated key pair. */
18331+
ret = wc_MlDsaKey_ImportPubRaw(key,
18332+
mldsa44_pub_spki + sizeof_mldsa44_pub_spki -
18333+
WC_MLDSA_44_PUB_KEY_SIZE,
18334+
WC_MLDSA_44_PUB_KEY_SIZE);
1832618335
#else
1832718336
ret = wc_MlDsaKey_ImportPubRaw(key, bench_mldsa_44_pubkey,
1832818337
sizeof_bench_mldsa_44_pubkey);
@@ -18338,6 +18347,15 @@ void bench_mldsaKeySign(byte level)
1833818347
#ifndef WOLFSSL_MLDSA_NO_ASN1
1833918348
ret = wc_MlDsaKey_PublicKeyDecode(key, mldsa65_pub_spki,
1834018349
sizeof_mldsa65_pub_spki, &idx);
18350+
#elif defined(WOLFSSL_MLDSA_NO_SIGN)
18351+
/* The baked signature above was made with
18352+
* certs/mldsa/mldsa65_priv-only.der and verifies only under that
18353+
* key. Take its raw encoding from the SPKI payload;
18354+
* bench_mldsa_65_pubkey is an unrelated key pair. */
18355+
ret = wc_MlDsaKey_ImportPubRaw(key,
18356+
mldsa65_pub_spki + sizeof_mldsa65_pub_spki -
18357+
WC_MLDSA_65_PUB_KEY_SIZE,
18358+
WC_MLDSA_65_PUB_KEY_SIZE);
1834118359
#else
1834218360
ret = wc_MlDsaKey_ImportPubRaw(key, bench_mldsa_65_pubkey,
1834318361
sizeof_bench_mldsa_65_pubkey);
@@ -18353,6 +18371,15 @@ void bench_mldsaKeySign(byte level)
1835318371
#ifndef WOLFSSL_MLDSA_NO_ASN1
1835418372
ret = wc_MlDsaKey_PublicKeyDecode(key, mldsa87_pub_spki,
1835518373
sizeof_mldsa87_pub_spki, &idx);
18374+
#elif defined(WOLFSSL_MLDSA_NO_SIGN)
18375+
/* The baked signature above was made with
18376+
* certs/mldsa/mldsa87_priv-only.der and verifies only under that
18377+
* key. Take its raw encoding from the SPKI payload;
18378+
* bench_mldsa_87_pubkey is an unrelated key pair. */
18379+
ret = wc_MlDsaKey_ImportPubRaw(key,
18380+
mldsa87_pub_spki + sizeof_mldsa87_pub_spki -
18381+
WC_MLDSA_87_PUB_KEY_SIZE,
18382+
WC_MLDSA_87_PUB_KEY_SIZE);
1835618383
#else
1835718384
ret = wc_MlDsaKey_ImportPubRaw(key, bench_mldsa_87_pubkey,
1835818385
sizeof_bench_mldsa_87_pubkey);

0 commit comments

Comments
 (0)