Add linux runtime detection
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
parent
49231319fd
commit
b95c776c43
2 changed files with 30 additions and 2 deletions
|
@ -45,6 +45,26 @@
|
|||
|
||||
#include <arm_neon.h>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <asm/hwcap.h>
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* AES instruction support detection routine
|
||||
*/
|
||||
int mbedtls_aesce_has_support(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
unsigned long auxval = getauxval(AT_HWCAP);
|
||||
return (auxval & (HWCAP_ASIMD | HWCAP_AES)) ==
|
||||
(HWCAP_ASIMD | HWCAP_AES);
|
||||
#else
|
||||
/* Suppose aes instructions are supported. */
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_HAVE_ARM64 */
|
||||
|
||||
#endif /* MBEDTLS_AESCE_C */
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include "mbedtls/aes.h"
|
||||
|
||||
|
||||
#if !defined(MBEDTLS_HAVE_ARM64) && \
|
||||
(defined(__aarch64__) || defined(_M_ARM64))
|
||||
#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && \
|
||||
defined(__aarch64__) && !defined(MBEDTLS_HAVE_ARM64)
|
||||
#define MBEDTLS_HAVE_ARM64
|
||||
#endif
|
||||
|
||||
|
@ -41,6 +41,14 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Internal function to detect the crypto engine in CPUs.
|
||||
*
|
||||
* \return 1 if CPU has support for the feature, 0 otherwise
|
||||
*/
|
||||
int mbedtls_aesce_has_support(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue