Rename plain c option and update comments

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2023-04-19 10:44:29 +08:00
parent 8840a8c574
commit 3660623e59
9 changed files with 23 additions and 17 deletions

View File

@ -147,7 +147,7 @@ jobs:
- scripts/config.py unset MBEDTLS_AESNI_C
- scripts/config.py unset MBEDTLS_PADLOCK_C
- scripts/config.py set MBEDTLS_AESCE_C
- scripts/config.py set MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO
- scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
- make generated_files
- make
- programs/test/selftest

View File

@ -4008,8 +4008,14 @@
/*
* Platform independent implementation for crypto algorithms.
* Disable plain c implementation for AES.
* Disable plain C implementation for AES.
*
* If the plain C implementation is enabled, and an implementation using a
* special CPU feature (such as MBEDTLS_AESCE_C) is also enabled, runtime
* detection will be used to select between them.
*
* If only one implementation is present, runtime detection will not be used.
*/
//#define MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO /* Uncomment to disable plain c implementation of AES */
//#define MBEDTLS_AES_USE_HARDWARE_ONLY
/** \} name SECTION: Module configuration options */

View File

@ -99,7 +99,7 @@
#include <sys/auxv.h>
#endif
#if !defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
/*
* AES instruction support detection routine
*/

View File

@ -33,7 +33,7 @@
#if !defined(MBEDTLS_HAVE_ARM64)
#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
#define MBEDTLS_HAVE_ARM64
#if !defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_AESCE_C) && defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
#error "MBEDTLS_AES_C defined, but not all prerequisites"
#endif
#endif
@ -50,7 +50,7 @@ extern "C" {
*
* \return 1 if CPU has support for the feature, 0 otherwise
*/
#if !defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
int mbedtls_aesce_has_support(void);
#else
#define /* no-check-names */ mbedtls_aesce_has_support() 1

View File

@ -39,7 +39,7 @@
#include <immintrin.h>
#endif
#if !defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
/*
* AES-NI support detection routine
*/
@ -69,7 +69,7 @@ int mbedtls_aesni_has_support(unsigned int what)
return (c & what) != 0;
}
#endif /* !MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO */
#endif /* !MBEDTLS_AES_USE_HARDWARE_ONLY */
#if MBEDTLS_AESNI_HAVE_CODE == 2

View File

@ -39,7 +39,7 @@
(defined(__amd64__) || defined(__x86_64__)) && \
!defined(MBEDTLS_HAVE_X86_64)
#define MBEDTLS_HAVE_X86_64
#if !defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
#error "MBEDTLS_AES_C defined, but not all prerequisites"
#endif
#endif
@ -91,7 +91,7 @@ extern "C" {
*
* \return 1 if CPU has support for the feature, 0 otherwise
*/
#if !defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
int mbedtls_aesni_has_support(unsigned int what);
#else
#define /* no-check-names */ mbedtls_aesni_has_support(what) 1

View File

@ -33,7 +33,7 @@
#if defined(MBEDTLS_HAVE_X86)
#if !defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
/*
* PadLock detection routine
*/

View File

@ -47,7 +47,7 @@
#include <stdint.h>
#if !defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
#error "MBEDTLS_AES_C defined, but not all prerequisites"
#endif
@ -72,7 +72,7 @@ extern "C" {
*
* \return non-zero if CPU has support for the feature, 0 otherwise
*/
#if !defined(MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO)
#if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
int mbedtls_padlock_has_support(int feature);
#else
#define /* no-check-names */ mbedtls_padlock_has_support(feature) 1

View File

@ -4941,12 +4941,12 @@ component_check_test_helpers () {
python3 -m unittest tests/scripts/translate_ciphers.py 2>&1
}
component_test_aes_builtin_only () {
component_test_aes_donot_use_hardware () {
msg "Test: AES builtin only"
scripts/config.py unset MBEDTLS_AESNI_C
scripts/config.py unset MBEDTLS_PADLOCK_C
scripts/config.py unset MBEDTLS_AESCE_C
scripts/config.py unset MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO
scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
msg "build: make, AES built-in only" # ~10s
make
@ -4959,7 +4959,7 @@ component_test_aes_aesni_only () {
scripts/config.py set MBEDTLS_AESNI_C
scripts/config.py unset MBEDTLS_PADLOCK_C
scripts/config.py unset MBEDTLS_AESCE_C
scripts/config.py set MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO
scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
msg "build: AESNI only" # ~10s
make
@ -4972,7 +4972,7 @@ component_test_aes_padlock_only () {
scripts/config.py unset MBEDTLS_AESNI_C
scripts/config.py set MBEDTLS_PADLOCK_C
scripts/config.py unset MBEDTLS_AESCE_C
scripts/config.py set MBEDTLS_AES_DONT_USE_SOFTWARE_CRYPTO
scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
msg "build: AES, VIA padlock only" # ~10s
make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"