@@ -1031,6 +1031,12 @@ static int test_KDF(void)
10311031}
10321032
10331033
1034+ /* Checks the internal.h derivation directly, independent of any API. */
1035+ #if defined(WOLFSSH_NO_MLDSA44) && defined(WOLFSSH_NO_MLDSA65) && \
1036+ defined(WOLFSSH_NO_MLDSA87) && !defined(WOLFSSH_NO_MLDSA)
1037+ #error "WOLFSSH_NO_MLDSA must follow from all three levels being off"
1038+ #endif
1039+
10341040/* Key Generation Unit Test */
10351041
10361042#ifdef WOLFSSH_KEYGEN
@@ -1369,6 +1375,24 @@ static int test_MlDsaCompositesDisabled(void)
13691375
13701376#endif /* WOLFSSH_NO_MLDSA */
13711377
1378+ /* API behaviour with ML-DSA off; the #error above covers the derivation. */
1379+ #ifdef WOLFSSH_NO_MLDSA
1380+ static int test_MlDsaLevelsDisabled(void)
1381+ {
1382+ byte dummy[1];
1383+ int result = 0;
1384+ int sz;
1385+
1386+ sz = wolfSSH_MakeMlDsaKey(dummy, sizeof(dummy), WOLFSSH_MLDSAKEY_44);
1387+ if (sz != WS_NOT_COMPILED) {
1388+ printf("MlDsaLevelsDisabled: MakeMlDsaKey wrong result %d\n", sz);
1389+ result = -133;
1390+ }
1391+
1392+ return result;
1393+ }
1394+ #endif
1395+
13721396#endif /* WOLFSSH_KEYGEN */
13731397
13741398/* Exercises the malformed-input error paths of the WOLFSSH_FORMAT_OPENSSH
@@ -13229,7 +13253,7 @@ static int test_KEY_clean_osshCert(void)
1322913253}
1323013254#endif /* WOLFSSH_OSSH_CERTS */
1323113255
13232- #if !defined(WOLFSSH_NO_MLDSA)
13256+ #if !defined(WOLFSSH_NO_MLDSA) && !defined(WOLFSSH_NO_MLDSA44)
1323313257/* keys/server-key-mldsa44.der - MlDsa44 OneAsymmetricKey */
1323413258static const byte unitTestMlDsaPrivKey[] = {
1323513259 0x30, 0x82, 0x0a, 0x3e, 0x02, 0x01, 0x00, 0x30,
@@ -13562,7 +13586,7 @@ static const byte unitTestMlDsaPrivKey[] = {
1356213586 0x27, 0xfe, 0x32, 0x26, 0x3c, 0x33, 0x83, 0xda,
1356313587 0x18, 0xc9
1356413588};
13565- #endif /* !WOLFSSH_NO_MLDSA */
13589+ #endif /* !WOLFSSH_NO_MLDSA && !WOLFSSH_NO_MLDSA44 */
1356613590
1356713591#ifndef WOLFSSH_NO_ECDSA
1356813592/* P-256 DER with the OID last byte changed 0x07 -> 0x01 (secp192r1).
@@ -23761,6 +23785,12 @@ int wolfSSH_UnitTest(int argc, char** argv)
2376123785 testResult = testResult || unitResult;
2376223786#endif /* WOLFSSH_NO_MLDSA_COMPOSITES */
2376323787#endif
23788+ #ifdef WOLFSSH_NO_MLDSA
23789+ unitResult = test_MlDsaLevelsDisabled();
23790+ printf("MlDsaLevelsDisabled: %s\n",
23791+ (unitResult == 0 ? "SUCCESS" : "FAILED"));
23792+ testResult = testResult || unitResult;
23793+ #endif
2376423794#endif /* WOLFSSH_KEYGEN */
2376523795 unitResult = test_OpenSshPemNegative();
2376623796 printf("OpenSshPemNegative: %s\n",
0 commit comments