mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
PSA operation structures: move less-used fields to the end
Move fields around to have fewer accesses outside the 128-element Thumb direct access window. In psa_hkdf_key_derivation_t, move the large fields (output_block, prk, hmac) after the state bit-fields. Experimentally, it's slightly better to put hmac last. Other operations structures don't go outside the window, at least when not considering nested structures. Results (arm-none-eabi-gcc 7.3.1, build_arm_none_eabi_gcc_m0plus build): library/psa_crypto.o: 16510 -> 16434 (diff: 76) Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@ -186,9 +186,6 @@ typedef struct
|
||||
{
|
||||
uint8_t *MBEDTLS_PRIVATE(info);
|
||||
size_t MBEDTLS_PRIVATE(info_length);
|
||||
struct psa_mac_operation_s MBEDTLS_PRIVATE(hmac);
|
||||
uint8_t MBEDTLS_PRIVATE(prk)[PSA_HASH_MAX_SIZE];
|
||||
uint8_t MBEDTLS_PRIVATE(output_block)[PSA_HASH_MAX_SIZE];
|
||||
#if PSA_HASH_MAX_SIZE > 0xff
|
||||
#error "PSA_HASH_MAX_SIZE does not fit in uint8_t"
|
||||
#endif
|
||||
@ -196,6 +193,9 @@ typedef struct
|
||||
uint8_t MBEDTLS_PRIVATE(block_number);
|
||||
unsigned int MBEDTLS_PRIVATE(state) : 2;
|
||||
unsigned int MBEDTLS_PRIVATE(info_set) : 1;
|
||||
uint8_t MBEDTLS_PRIVATE(output_block)[PSA_HASH_MAX_SIZE];
|
||||
uint8_t MBEDTLS_PRIVATE(prk)[PSA_HASH_MAX_SIZE];
|
||||
struct psa_mac_operation_s MBEDTLS_PRIVATE(hmac);
|
||||
} psa_hkdf_key_derivation_t;
|
||||
#endif /* MBEDTLS_PSA_BUILTIN_ALG_HKDF */
|
||||
|
||||
|
Reference in New Issue
Block a user