Skip to content

Commit

Permalink
[nrf fromtree] crypto: Fix PSA max hash size without configuration he…
Browse files Browse the repository at this point in the history
…ader included

The PSA header only includes the configuration header when
MBEDTLS_PSA_CRYPTO_CONFIG_FILE is given on the command line.
If the configuration file has not been included assume that the
maximum hash size is the maximum possible instead of the minimal
possible.
This is consistent with how PSA_VENDOR_ECC_MAX_CURVE_BITS is defined.

Change-Id: I4c137a947ca0dbdbddf7eaac74e6ce59ae988224
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
(cherry picked from commit 779cfe0)
  • Loading branch information
joerchan authored and nordicjm committed Jul 6, 2023
1 parent 86fdfb9 commit ccab64f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions interface/include/psa/crypto_sizes.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,19 @@
/* Note: for HMAC-SHA-3, the block size is 144 bytes for HMAC-SHA3-226,
* 136 bytes for HMAC-SHA3-256, 104 bytes for SHA3-384, 72 bytes for
* HMAC-SHA3-512. */
#if defined(MBEDTLS_PSA_CRYPTO_CONFIG)
#if defined(PSA_WANT_ALG_SHA_512) || defined(PSA_WANT_ALG_SHA_384)
#define PSA_HASH_MAX_SIZE 64
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128
#else
#define PSA_HASH_MAX_SIZE 32
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 64
#endif
#else
/* Without any PSA configuration we must assume the maximum size possible. */
#define PSA_HASH_MAX_SIZE 64
#define PSA_HMAC_MAX_HASH_BLOCK_SIZE 128
#endif

/** \def PSA_MAC_MAX_SIZE
*
Expand Down Expand Up @@ -209,6 +215,7 @@
#define PSA_VENDOR_ECC_MAX_CURVE_BITS 0
#endif
#else /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */
/* Without any PSA configuration we must assume the maximum size possible. */
#define PSA_VENDOR_ECC_MAX_CURVE_BITS 521
#endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */

Expand Down

0 comments on commit ccab64f

Please sign in to comment.