diff --git a/library/aes.c b/library/aes.c index 977b3de2d8..b446265b25 100644 --- a/library/aes.c +++ b/library/aes.c @@ -1128,7 +1128,7 @@ typedef unsigned char mbedtls_be128[16]; * for machine endianness and hence works correctly on both big and little * endian machines. */ -MBEDTLS_OPTIMIZE_ALWAYS +MBEDTLS_OPTIMIZE_FOR_PERFORMANCE static inline void mbedtls_gf128mul_x_ble(unsigned char r[16], const unsigned char x[16]) { @@ -1147,10 +1147,10 @@ static inline void mbedtls_gf128mul_x_ble(unsigned char r[16], /* * AES-XTS buffer encryption/decryption * - * Use of MBEDTLS_OPTIMIZE_ALWAYS here and for mbedtls_gf128mul_x_ble() + * Use of MBEDTLS_OPTIMIZE_FOR_PERFORMANCE here and for mbedtls_gf128mul_x_ble() * is a 3x performance improvement for gcc -Os! */ -MBEDTLS_OPTIMIZE_ALWAYS +MBEDTLS_OPTIMIZE_FOR_PERFORMANCE int mbedtls_aes_crypt_xts(mbedtls_aes_xts_context *ctx, int mode, size_t length, diff --git a/library/aesce.c b/library/aesce.c index 600326a08a..ecfadcd9df 100644 --- a/library/aesce.c +++ b/library/aesce.c @@ -109,7 +109,7 @@ int mbedtls_aesce_has_support(void) /* Two rounds of AESCE encryption */ #define AESCE_ENCRYPT_ROUND_X2 AESCE_ENCRYPT_ROUND; AESCE_ENCRYPT_ROUND -MBEDTLS_OPTIMIZE_ALWAYS +MBEDTLS_OPTIMIZE_FOR_PERFORMANCE static uint8x16_t aesce_encrypt_block(uint8x16_t block, unsigned char *keys, int rounds) @@ -173,7 +173,7 @@ rounds_10: /* Two rounds of AESCE decryption */ #define AESCE_DECRYPT_ROUND_X2 AESCE_DECRYPT_ROUND; AESCE_DECRYPT_ROUND -MBEDTLS_OPTIMIZE_ALWAYS +MBEDTLS_OPTIMIZE_FOR_PERFORMANCE static uint8x16_t aesce_decrypt_block(uint8x16_t block, unsigned char *keys, int rounds) @@ -210,7 +210,7 @@ rounds_10: /* * AES-ECB block en(de)cryption */ -MBEDTLS_OPTIMIZE_ALWAYS +MBEDTLS_OPTIMIZE_FOR_PERFORMANCE int mbedtls_aesce_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], diff --git a/library/ccm.c b/library/ccm.c index 1e644dc172..81bdfe7cc4 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -326,7 +326,7 @@ int mbedtls_ccm_update_ad(mbedtls_ccm_context *ctx, return 0; } -MBEDTLS_OPTIMIZE_ALWAYS +MBEDTLS_OPTIMIZE_FOR_PERFORMANCE int mbedtls_ccm_update(mbedtls_ccm_context *ctx, const unsigned char *input, size_t input_len, unsigned char *output, size_t output_size, diff --git a/library/common.h b/library/common.h index c477e1d373..497886f4d5 100644 --- a/library/common.h +++ b/library/common.h @@ -240,11 +240,14 @@ static inline void mbedtls_xor_no_simd(unsigned char *r, #define MBEDTLS_COMPILER_IS_GCC #endif -/* If -Os is specified, override with -O2 for a given function */ +/* For gcc -Os, override with -O2 for a given function. + * + * This will not affect behaviour for other optimisation settings, e.g. -O0. + */ #if defined(MBEDTLS_COMPILER_IS_GCC) && defined(__OPTIMIZE_SIZE__) -#define MBEDTLS_OPTIMIZE_ALWAYS __attribute__((optimize("-O2"))) +#define MBEDTLS_OPTIMIZE_FOR_PERFORMANCE __attribute__((optimize("-O2"))) #else -#define MBEDTLS_OPTIMIZE_ALWAYS +#define MBEDTLS_OPTIMIZE_FOR_PERFORMANCE #endif #endif /* MBEDTLS_LIBRARY_COMMON_H */ diff --git a/library/gcm.c b/library/gcm.c index 02f8cbfcaa..6d7ef21c41 100644 --- a/library/gcm.c +++ b/library/gcm.c @@ -417,7 +417,7 @@ static int gcm_mask(mbedtls_gcm_context *ctx, return 0; } -MBEDTLS_OPTIMIZE_ALWAYS +MBEDTLS_OPTIMIZE_FOR_PERFORMANCE int mbedtls_gcm_update(mbedtls_gcm_context *ctx, const unsigned char *input, size_t input_length, unsigned char *output, size_t output_size,