Skip to content

Commit bceac6c

Browse files
valeriosettitomi-font
authored andcommitted
mbedtls: align crypto_sizes.h to the Mbed TLS one
crypto_sizes.h is no more aligned to the Mbed TLS version and it misses some #define that make some test to fail at build time in Zephyr. This commit fixes this disparities. Note: this commit can be ignored in future TF-M repo updates assuming that this fix will be already included in the upstream version of TF-M. Signed-off-by: Valerio Setti <vsetti@baylibre.com>
1 parent 8134106 commit bceac6c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

interface/include/psa/crypto_sizes.h

+25
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,10 @@
10381038
PSA_KEY_EXPORT_FFDH_PUBLIC_KEY_MAX_SIZE(PSA_VENDOR_FFDH_MAX_KEY_BITS)
10391039
#endif
10401040

1041+
#define PSA_EXPORT_KEY_PAIR_OR_PUBLIC_MAX_SIZE \
1042+
((PSA_EXPORT_KEY_PAIR_MAX_SIZE > PSA_EXPORT_PUBLIC_KEY_MAX_SIZE) ? \
1043+
PSA_EXPORT_KEY_PAIR_MAX_SIZE : PSA_EXPORT_PUBLIC_KEY_MAX_SIZE)
1044+
10411045
/** Sufficient output buffer size for psa_raw_key_agreement().
10421046
*
10431047
* This macro returns a compile-time constant if its arguments are
@@ -1085,6 +1089,27 @@
10851089
#define PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE PSA_BITS_TO_BYTES(PSA_VENDOR_FFDH_MAX_KEY_BITS)
10861090
#endif
10871091

1092+
/** Maximum key length for ciphers.
1093+
*
1094+
* Since there is no additional PSA_WANT_xxx symbol to specifiy the size of
1095+
* the key once a cipher is enabled (as it happens for asymmetric keys for
1096+
* example), the maximum key length is taken into account for each cipher.
1097+
* The resulting value will be the maximum cipher's key length given depending
1098+
* on which ciphers are enabled.
1099+
*
1100+
* Note: max value for AES used below would be doubled if XTS were enabled, but
1101+
* this mode is currently not supported in Mbed TLS implementation of PSA
1102+
* APIs.
1103+
*/
1104+
#if (defined(PSA_WANT_KEY_TYPE_AES) || defined(PSA_WANT_KEY_TYPE_ARIA) || \
1105+
defined(PSA_WANT_KEY_TYPE_CAMELLIA) || defined(PSA_WANT_KEY_TYPE_CHACHA20))
1106+
#define PSA_CIPHER_MAX_KEY_LENGTH 32u
1107+
#elif defined(PSA_WANT_KEY_TYPE_DES)
1108+
#define PSA_CIPHER_MAX_KEY_LENGTH 24u
1109+
#else
1110+
#define PSA_CIPHER_MAX_KEY_LENGTH 0u
1111+
#endif
1112+
10881113
/** The default IV size for a cipher algorithm, in bytes.
10891114
*
10901115
* The IV that is generated as part of a call to #psa_cipher_encrypt() is always

0 commit comments

Comments
 (0)