Skip to content

Commit e224037

Browse files
committed
[zep fromtree] psa: crypto_extra: update documentation of MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
Signed-off-by: Valerio Setti <[email protected]> (cherry picked from commit 5306324015b9db29969dff1ba592f6675a6dedf5)
1 parent dd7b0e7 commit e224037

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

include/psa/crypto_extra.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ extern "C" {
3333
#endif
3434

3535
/* If the size of static key slots is not explicitly defined by the user, then
36-
* set it to the maximum between PSA_EXPORT_KEY_PAIR_OR_PUBLIC_MAX_SIZE,
37-
* PSA_CIPHER_MAX_KEY_LENGTH and PSA_MAC_MAX_SIZE.
38-
* See mbedtls_config.h for the definition. */
36+
* try to guess it based on some of the most common the key types enabled in the build.
37+
* See mbedtls_config.h for the definition of MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE. */
3938
#if !defined(MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE)
4039

4140
#define MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE 1
@@ -45,27 +44,21 @@ extern "C" {
4544
#define MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE PSA_EXPORT_KEY_PAIR_OR_PUBLIC_MAX_SIZE
4645
#endif
4746

47+
/* This covers ciphers, AEADs and CMAC. */
4848
#if PSA_CIPHER_MAX_KEY_LENGTH > MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
4949
#undef MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
5050
#define MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE PSA_CIPHER_MAX_KEY_LENGTH
5151
#endif
5252

5353
/* For HMAC, it's typical but not mandatory to use a key size that is equal to
5454
* the hash size. */
55-
#if PSA_WANT_ALG_HMAC
55+
#if defined(PSA_WANT_ALG_HMAC)
5656
#if PSA_HASH_MAX_SIZE > MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
5757
#undef MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
5858
#define MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE PSA_HASH_MAX_SIZE
5959
#endif
6060
#endif /* PSA_WANT_ALG_HMAC */
6161

62-
#if PSA_WANT_ALG_CMAC
63-
#if PSA_CIPHER_MAX_KEY_LENGTH > MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
64-
#undef MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
65-
#define MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE PSA_CIPHER_MAX_KEY_LENGTH
66-
#endif
67-
#endif /* PSA_WANT_ALG_CMAC */
68-
6962
#endif /* !MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE*/
7063

7164
/** \addtogroup attributes

0 commit comments

Comments
 (0)