Skip to content

Commit

Permalink
replace arm64 macro and aesce enable flag
Browse files Browse the repository at this point in the history
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
  • Loading branch information
yuhaoth committed Aug 23, 2023
1 parent 926221a commit 72fd0bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
10 changes: 5 additions & 5 deletions library/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "mbedtls/platform_util.h"
#include "mbedtls/error.h"

#if defined(__aarch64__)
#if defined(MBEDTLS_ARCH_IS_ARM64)
#if !defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
#error "MBEDTLS_AES_USE_HARDWARE_ONLY defined, but not all prerequisites"
#endif
Expand Down Expand Up @@ -652,7 +652,7 @@ int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key,
}
#endif

#if defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_HAVE_ARM64)
#if defined(MBEDTLS_AESCE_HAVE_CODE)
if (MBEDTLS_AESCE_HAS_SUPPORT()) {
return mbedtls_aesce_setkey_enc((unsigned char *) RK, key, keybits);
}
Expand Down Expand Up @@ -764,7 +764,7 @@ int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key,
}
#endif

#if defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_HAVE_ARM64)
#if defined(MBEDTLS_AESCE_HAVE_CODE)
if (MBEDTLS_AESCE_HAS_SUPPORT()) {
mbedtls_aesce_inverse_key(
(unsigned char *) RK,
Expand Down Expand Up @@ -1091,7 +1091,7 @@ int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx,
}
#endif

#if defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_HAVE_ARM64)
#if defined(MBEDTLS_AESCE_HAVE_CODE)
if (MBEDTLS_AESCE_HAS_SUPPORT()) {
return mbedtls_aesce_crypt_ecb(ctx, mode, input, output);
}
Expand Down Expand Up @@ -1910,7 +1910,7 @@ int mbedtls_aes_self_test(int verbose)
mbedtls_printf(" AES note: using VIA Padlock.\n");
} else
#endif
#if defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_HAVE_ARM64)
#if defined(MBEDTLS_AESCE_HAVE_CODE)
if (MBEDTLS_AESCE_HAS_SUPPORT()) {
mbedtls_printf(" AES note: using AESCE.\n");
} else
Expand Down
4 changes: 2 additions & 2 deletions library/aesce.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include "aesce.h"

#if defined(MBEDTLS_HAVE_ARM64)
#if defined(MBEDTLS_ARCH_IS_ARM64)

/* Compiler version checks. */
#if defined(__clang__)
Expand Down Expand Up @@ -510,6 +510,6 @@ void mbedtls_aesce_gcm_mult(unsigned char c[16],
#undef MBEDTLS_POP_TARGET_PRAGMA
#endif

#endif /* MBEDTLS_HAVE_ARM64 */
#endif /* MBEDTLS_ARCH_IS_ARM64 */

#endif /* MBEDTLS_AESCE_C */
12 changes: 5 additions & 7 deletions library/aesce.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@

#include "mbedtls/aes.h"

#if !defined(MBEDTLS_HAVE_ARM64)
#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define MBEDTLS_HAVE_ARM64
#endif
#endif
#include "common.h"

#if defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_ARCH_IS_ARM64)

#if defined(MBEDTLS_HAVE_ARM64)
#define MBEDTLS_AESCE_HAVE_CODE

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -131,6 +129,6 @@ int mbedtls_aesce_setkey_enc(unsigned char *rk,
}
#endif

#endif /* MBEDTLS_HAVE_ARM64 */
#endif /* MBEDTLS_AESCE_C && MBEDTLS_ARCH_IS_ARM64 */

#endif /* MBEDTLS_AESCE_H */
6 changes: 3 additions & 3 deletions library/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static int gcm_gen_table(mbedtls_gcm_context *ctx)
}
#endif

#if defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_HAVE_ARM64)
#if defined(MBEDTLS_AESCE_HAVE_CODE)
if (MBEDTLS_AESCE_HAS_SUPPORT()) {
return 0;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ static void gcm_mult(mbedtls_gcm_context *ctx, const unsigned char x[16],
}
#endif /* MBEDTLS_AESNI_HAVE_CODE */

#if defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_HAVE_ARM64)
#if defined(MBEDTLS_AESCE_HAVE_CODE)
if (MBEDTLS_AESCE_HAS_SUPPORT()) {
unsigned char h[16];

Expand Down Expand Up @@ -885,7 +885,7 @@ int mbedtls_gcm_self_test(int verbose)
} else
#endif

#if defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_HAVE_ARM64)
#if defined(MBEDTLS_AESCE_HAVE_CODE)
if (MBEDTLS_AESCE_HAS_SUPPORT()) {
mbedtls_printf(" GCM note: using AESCE.\n");
} else
Expand Down

0 comments on commit 72fd0bd

Please sign in to comment.