Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/api/test_mldsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -24565,6 +24565,7 @@ int test_wc_dilithium_sign_mu_kats(void)
* convention, so passing zeroSeed reproduces them byte-for-byte. */
static const byte zeroSeed[DILITHIUM_RND_SZ] = { 0 };

#ifndef WOLFSSL_NO_ML_DSA_44
/* ML-DSA-44 externalMu: deterministic, tcId 91
* Source: kh-fork-fips/wolfACVP/v7.0.0-known/
* ML-DSA-sigGen-request.json. Deterministic mode
Expand Down Expand Up @@ -25206,7 +25207,9 @@ int test_wc_dilithium_sign_mu_kats(void)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x12, 0x1f, 0x28, 0x39
};
#endif

#ifndef WOLFSSL_NO_ML_DSA_65
/* ML-DSA-65 externalMu: deterministic, tcId 121
* Source: kh-fork-fips/wolfACVP/v7.0.0-known/
* ML-DSA-sigGen-request.json. Deterministic mode
Expand Down Expand Up @@ -26143,7 +26146,9 @@ int test_wc_dilithium_sign_mu_kats(void)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x0c, 0x10, 0x18, 0x1c, 0x1f
};
#endif

#ifndef WOLFSSL_NO_ML_DSA_87
/* ML-DSA-87 externalMu: deterministic, tcId 151
* Source: kh-fork-fips/wolfACVP/v7.0.0-known/
* ML-DSA-sigGen-request.json. Deterministic mode
Expand Down Expand Up @@ -27353,6 +27358,7 @@ int test_wc_dilithium_sign_mu_kats(void)
0x00, 0x00, 0x00, 0x01, 0x08, 0x0e, 0x16, 0x1e,
0x22, 0x2a, 0x30
};
#endif


ExpectNotNull(key = (dilithium_key*)XMALLOC(sizeof(*key), NULL,
Expand Down Expand Up @@ -27423,6 +27429,7 @@ int test_wc_dilithium_verify_mu_kats(void)
byte muBuf[DILITHIUM_MU_SZ];
int res;

#ifndef WOLFSSL_NO_ML_DSA_44
/* ML-DSA-44 externalMu: deterministic, tcId 91
* Source: kh-fork-fips/wolfACVP/v7.0.0-known/
* ML-DSA-sigGen-request.json. Deterministic mode
Expand Down Expand Up @@ -27908,7 +27915,9 @@ int test_wc_dilithium_verify_mu_kats(void)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x12, 0x1f, 0x28, 0x39
};
#endif

#ifndef WOLFSSL_NO_ML_DSA_65
/* ML-DSA-65 externalMu: deterministic, tcId 121
* Source: kh-fork-fips/wolfACVP/v7.0.0-known/
* ML-DSA-sigGen-request.json. Deterministic mode
Expand Down Expand Up @@ -28585,7 +28594,9 @@ int test_wc_dilithium_verify_mu_kats(void)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,
0x0c, 0x10, 0x18, 0x1c, 0x1f
};
#endif

#ifndef WOLFSSL_NO_ML_DSA_87
/* ML-DSA-87 externalMu: deterministic, tcId 151
* Source: kh-fork-fips/wolfACVP/v7.0.0-known/
* ML-DSA-sigGen-request.json. Deterministic mode
Expand Down Expand Up @@ -29507,7 +29518,7 @@ int test_wc_dilithium_verify_mu_kats(void)
0x00, 0x00, 0x00, 0x01, 0x08, 0x0e, 0x16, 0x1e,
0x22, 0x2a, 0x30
};

#endif

ExpectNotNull(key = (dilithium_key*)XMALLOC(sizeof(*key), NULL,
DYNAMIC_TYPE_TMP_BUFFER));
Expand Down
17 changes: 14 additions & 3 deletions wolfcrypt/src/sha3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,8 @@ static int wc_InitSha3(wc_Sha3* sha3, void* heap, int devId)
return ret;
}

#if !(defined(WOLFSSL_NOSHA3_224) && defined(WOLFSSL_NOSHA3_256) && \
defined(WOLFSSL_NOSHA3_384) && defined(WOLFSSL_NOSHA3_512))
/* Update the SHA-3 hash state with message data.
*
* sha3 wc_Sha3 object holding state.
Expand Down Expand Up @@ -1243,6 +1245,7 @@ static int wc_Sha3Final(wc_Sha3* sha3, byte* hash, byte p, byte len)
return InitSha3(sha3); /* reset state */
}
#endif
#endif

/* Dispose of any dynamically allocated data from the SHA3-384 operation.
* (Required for async ops.)
Expand Down Expand Up @@ -1342,6 +1345,8 @@ static int wc_Sha3Copy(wc_Sha3* src, wc_Sha3* dst)
return ret;
}

#if !(defined(WOLFSSL_NOSHA3_224) && defined(WOLFSSL_NOSHA3_256) && \
defined(WOLFSSL_NOSHA3_384) && defined(WOLFSSL_NOSHA3_512))
/* Calculate the SHA3-224 hash based on all the message data so far.
* More message data can be added, after this operation, using the current
* state.
Expand Down Expand Up @@ -1372,7 +1377,9 @@ static int wc_Sha3GetHash(wc_Sha3* sha3, byte* hash, byte p, byte len)
WC_FREE_VAR_EX(tmpSha3, sha3->heap, DYNAMIC_TYPE_TMP_BUFFER);
return ret;
}
#endif

#ifndef WOLFSSL_NOSHA3_224
/* Initialize the state for a SHA3-224 hash operation.
*
* sha3 wc_Sha3 object holding state.
Expand Down Expand Up @@ -1443,8 +1450,9 @@ int wc_Sha3_224_Copy(wc_Sha3* src, wc_Sha3* dst)
{
return wc_Sha3Copy(src, dst);
}
#endif


#ifndef WOLFSSL_NOSHA3_256
/* Initialize the state for a SHA3-256 hash operation.
*
* sha3 wc_Sha3 object holding state.
Expand Down Expand Up @@ -1515,8 +1523,9 @@ int wc_Sha3_256_Copy(wc_Sha3* src, wc_Sha3* dst)
{
return wc_Sha3Copy(src, dst);
}
#endif


#ifndef WOLFSSL_NOSHA3_384
/* Initialize the state for a SHA3-384 hash operation.
*
* sha3 wc_Sha3 object holding state.
Expand Down Expand Up @@ -1587,8 +1596,9 @@ int wc_Sha3_384_Copy(wc_Sha3* src, wc_Sha3* dst)
{
return wc_Sha3Copy(src, dst);
}
#endif


#ifndef WOLFSSL_NOSHA3_512
/* Initialize the state for a SHA3-512 hash operation.
*
* sha3 wc_Sha3 object holding state.
Expand Down Expand Up @@ -1659,6 +1669,7 @@ int wc_Sha3_512_Copy(wc_Sha3* src, wc_Sha3* dst)
{
return wc_Sha3Copy(src, dst);
}
#endif

#ifdef WOLFSSL_HASH_FLAGS
int wc_Sha3_SetFlags(wc_Sha3* sha3, word32 flags)
Expand Down
4 changes: 4 additions & 0 deletions wolfssl/wolfcrypt/dilithium.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,15 @@ struct dilithium_key {
#elif !defined(WOLFSSL_DILITHIUM_ASSIGN_KEY)
#ifdef USE_INTEL_SPEEDUP
byte p[DILITHIUM_MAX_PUB_KEY_SIZE+8];
#if !defined(WOLFSSL_DILITHIUM_VERIFY_ONLY)
byte k[DILITHIUM_MAX_KEY_SIZE+8];
#endif
#else
byte p[DILITHIUM_MAX_PUB_KEY_SIZE];
#if !defined(WOLFSSL_DILITHIUM_VERIFY_ONLY)
byte k[DILITHIUM_MAX_KEY_SIZE];
#endif
#endif
#else
const byte* p;
const byte* k;
Expand Down
Loading