Commit graph

235 commits

Author SHA1 Message Date
Dave Rodgman
9fd1b526c3 Use MBEDTLS_ARCH_IS_ARMV8_A not MBEDTLS_ARCH_IS_ARMV8
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-10-25 09:06:24 +01:00
Dave Rodgman
27e3c87fc1 Suppport AESCE on A32 and T32
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-10-25 09:06:22 +01:00
Dave Rodgman
4b779bef9e
Merge branch 'development' into more-aes-checks
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-10-12 16:17:10 +01:00
Dave Rodgman
54bb76e106
Merge pull request #8348 from kasjer/kasjer/aes-rcon-rename
Rename local variable in aes.c
2023-10-12 12:30:35 +00:00
Jerzy Kasenberg
ee62fceade Rename local variable in aes.c
This changes local variable name RCON to round_constants.

RCON being definition in xc32 compiler headers for some PIC32 register.
Without this change, mynewt project for PIC32 platform fails to build due to
macro redefinition.

This does not changes behavior of library in any way.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-10-11 16:36:24 +02:00
Dave Rodgman
18ddf61a75 Use MBEDTLS_MAYBE_UNUSED to simplify aes.c and let compiler remove unused variables
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-10-04 14:03:12 +01:00
Dave Rodgman
a06d45ec4a Code style
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-29 18:59:34 +01:00
Dave Rodgman
450c1ff353 Fix some more incorrect guards in aes.c
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-29 16:23:37 +01:00
Dave Rodgman
e81a632257 Restore missing #if
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-29 13:54:27 +01:00
Dave Rodgman
782df03553 Improve AES hardware-only check
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-29 13:04:36 +01:00
Jerry Yu
d6e312dde4 replace aesni target detection macros
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-23 17:15:34 +08:00
Jerry Yu
72fd0bdc71 replace arm64 macro and aesce enable flag
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-23 17:15:34 +08:00
Dave Rodgman
f2249ec905 Rename mbedtls_aesce_has_support macro to satisfy case rules
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-20 20:20:12 +01:00
Dave Rodgman
1fdc884ed8
Merge pull request #7384 from yuhaoth/pr/add-aes-accelerator-only-mode
AES: Add accelerator only mode
2023-08-18 20:55:44 +00:00
Jerry Yu
61fc5ed5f3 improve readability of error message
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-18 17:28:48 +08:00
Jerry Yu
372f7a04d0 Add missing check
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-18 17:26:25 +08:00
Jerry Yu
9608447545 replace padlock_c with padlock_have_code
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 18:10:45 +08:00
Jerry Yu
3a0f044bde improve readability
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 17:06:21 +08:00
Jerry Yu
e9c6b53e74 remove return-type when runtime detection enabled without plain c
This case does not exist

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 13:53:38 +08:00
Jerry Yu
1b4c7eda80 add hardware only check for padlock
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 11:25:17 +08:00
Jerry Yu
9e628621b4 Add via padlock detection macro
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 11:20:09 +08:00
Jerry Yu
2319af0d64 Change the order of runtime detection
If aesni is available, we will use it.

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 10:38:57 +08:00
Antonio de Angelis
1ee4d1228c Fix error strings without quotes
Some of the error strings that should be printed with the
error preprocessor directive are missing quotes

Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-16 12:48:33 +01:00
Jerry Yu
516cf27d45 fix msvc build fail on i386 target
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-16 17:33:32 +08:00
Jerry Yu
cc068ae631 fix -Werror=return-type when runtime detection enabled and plain c disabled
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-16 16:14:01 +08:00
Jerry Yu
e62ff09569 Restore aesni for i386
intrinsic code can be work on i386 also

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-16 14:33:16 +08:00
Paul Elliott
2ad93674dc Fix potential corruption of IV for AES CBC
If passed a zero length, AES CBC could potentially corrupt the passed
in IV by memcpying it over itself. Although this might be ok with
more recent compilers, its not for every compiler we support. Found
by coverity.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-08-11 17:04:06 +01:00
Jerry Yu
8189f32945 improve aesni check for x86_64
`MBEDTLS_AESNI_C` does not depends on `MBEDTLS_HAVE_ASM`
when intrinsic is available.

And compiler relative checks only work on x86_64, it should
be only checked on x86_64.

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-10 15:17:45 +08:00
Jerry Yu
13696bb07b improve check config option for i386
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-10 13:36:32 +08:00
Jerry Yu
ba42b076f9 Remove asm check for aarch64 aesce
we implement it with aesce intrinsic. No asm needed.

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-10 12:53:26 +08:00
Jerry Yu
c4508c07f6 improve error message and config check for padlock
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-08 12:57:06 +08:00
Jerry Yu
5fcdd6a28a remove unnecessary definition
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-07 15:32:58 +08:00
Tom Cosgrove
ce37c5e1ce Update links to Rijndael paper and NIST SP 800-90 DRBGs
The link to the DRBG paper points to the March 2007 version, the same as the
original link (rather than the latest version).

The amended Rijndael paper has a two-page "Note on naming" prefix.

Fixes #7193

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-08-04 13:55:03 +01:00
Jerry Yu
fce351def8 improve platform relative check
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-04 17:13:36 +08:00
Jerry Yu
29c91ba42d fix unreachable code warnings
It is detected by clang with bellow patch
```
diff --git a/library/Makefile b/library/Makefile
index fdab4f4ba0..967f9e2e65 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -306,8 +306,8 @@ libmbedcrypto.dll: $(OBJS_CRYPTO)

 .c.o:
        echo "  CC    $<"
-       $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
-
+       $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $(@:%.o=%.i) -E $<
+       $(CC) $(LOCAL_CFLAGS) -Wunreachable-code -Werror -Wno-unused-command-line-argument $(CFLAGS) -o $@ -c $(@:%.o=%.i)
 .PHONY: generated_files
 GENERATED_FILES = \
        error.c version_features.c \
```

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-04 16:29:06 +08:00
Jerry Yu
6943681820 Improve error message and documents
- fix grammar error
- Add more information for AES_USE_HARDWARE_ONLY
- Improve error message

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-02 17:44:03 +08:00
Jerry Yu
02b1519ab6 move accelerator checks to aes.c
Origin position is always validate due to conflict
between the guards in `aes.c` and module undef check

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-02 17:44:02 +08:00
Yanray Wang
5adfdbdaed AES: fix mismatch comment in #endif
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
2023-07-06 17:10:44 +08:00
Dave Rodgman
c8d81ad54d
Merge pull request #7784 from daverodgman/aesce-unroll 2023-07-04 18:41:13 +01:00
Tom Cosgrove
9b20c6fcc1
Merge pull request #7840 from yanrayw/7381_aes_gen_table
AES: use uint8_t for array of pow and log to save RAM usage
2023-07-04 08:34:12 +01:00
Dave Rodgman
9cf17dad9d
Merge pull request #7851 from daverodgman/fix-unused-aes
Fix AES dependencies - build TF-M config cleanly
2023-07-03 16:49:00 +01:00
Dave Rodgman
afe85db42b Improve #endif comments
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:07:11 +01:00
Dave Rodgman
1be2463d76 Correct #endif comments
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:01:24 +01:00
Dave Rodgman
710e3c650f Correct comments on #endif's
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-29 12:00:14 +01:00
Dave Rodgman
2fd8c2c708 code style
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 21:03:31 +01:00
Dave Rodgman
160088d769 Fix comment
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 20:41:51 +01:00
Dave Rodgman
ad4e76be57 More dependency fixes
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:23:14 +01:00
Dave Rodgman
34152a48d4 Fix unused variable
Fix when MBEDTLS_AES_SETKEY_ENC_ALT, MBEDTLS_AES_DECRYPT_ALT and
MBEDTLS_AES_ROM_TABLE set.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:23:09 +01:00
Dave Rodgman
15cd28a264 Fix unused variable if MBEDTLS_AES_SETKEY_ENC_ALT and MBEDTLS_AES_DECRYPT_ALT set
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:23:06 +01:00
Dave Rodgman
28a539a549 Fix unused fn when MBEDTLS_AES_SETKEY_DEC_ALT and MBEDTLS_AES_SETKEY_ENC_ALT set
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 19:23:01 +01:00