Skip to content

Commit 2e0cbd8

Browse files
Explain why MBEDTLS_SHA3_WANT_SHAKEnnn ≠ MBEDTLS_PSA_BUILTIN_SHAKEnnn
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
1 parent 239a07d commit 2e0cbd8

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/builtin/include/mbedtls/private/crypto_adjust_config_tweak_builtins.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@
3838
#define MBEDTLS_PSA_BUILTIN_ALG_SHA3_SOME_HASH
3939
#endif
4040

41+
/* If a SHAKE variant is enabled in psa_crypto_xof.c, tell sha3.c that we
42+
* want it.
43+
*
44+
* Note that the PSA API (following NIST standards) defines hash algorithms
45+
* that are SHAKE128 or SHAKE256 with a specific output lengths. From the
46+
* perspective of sha3.c, these are just users of SHAKE128/SHAKE256, but
47+
* from the perspective of psa_crypto_hash.c and psa_crypto_xof.c,
48+
* they are hashes and not XOF. So, for example, if the SHAKE256/512 hash
49+
* algorithm is enabled in the PSA API (for Ed448ph) but the SHAKE256 XOF
50+
* algorithm is disabled, then MBEDTLS_PSA_BUILTIN_ALG_SHAKE256 will be
51+
* disabled but we'll still need to enable MBEDTLS_SHA3_WANT_SHAKE256.
52+
*/
4153
#if defined(MBEDTLS_PSA_BUILTIN_ALG_SHAKE128)
4254
#define MBEDTLS_SHA3_WANT_SHAKE128
4355
#endif

0 commit comments

Comments
 (0)