Commit graph

116 commits

Author SHA1 Message Date
Dave Rodgman
59059ec503 Merge remote-tracking branch 'origin/development' into msft-aarch64
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-30 09:34:41 +00:00
Dave Rodgman
16799db69a update headers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-02 19:47:20 +00:00
Dave Rodgman
0a48717b83 Simplify Windows-on-Arm macros
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-10-16 09:25:59 +01:00
Dave Rodgman
a0f10da9d2 Use MBEDTLS_HAVE_NEON_INTRINSICS instead of __ARM_NEON
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-10-16 09:25:59 +01:00
Dave Rodgman
ad71b6a834 Support ARM64EC in the same way as ARM64 in sha256 and sha512
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-10-16 09:25:59 +01:00
Dave Rodgman
90330a4a2d Fix IAR control bypasses initialisation warning
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-28 18:13:46 +01:00
Dave Rodgman
aafd1e0924 Ensure all md_<hash>_finish functions perform zeroization
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-11 12:59:36 +01:00
Jerry Yu
b1d06bb29e Add error message for old armclang
when armclang<6.10, cpu modifiers MUST be
specified on command line.

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-07-13 10:40:29 +08:00
Jerry Yu
8e96e78dbe update document and error message
Chang the spell of armclang

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-07-13 10:40:28 +08:00
Jerry Yu
6b00f5a135 Add guards for arm_neon.h
See: https://arm-software.github.io/acle/main/acle.html#arm_neonh



Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-07-13 10:40:28 +08:00
Jerry Yu
22a4d3e2b4 fix armclang build fail for sha512.
`sha3` support is start from armclang6.10

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-07-13 10:40:28 +08:00
Jerry Yu
08933d3dbb fix compile fail for armclang
when target flags are not set at command line, armclang
will reports required feature not set error.

This is found and verified at 6.20.1. And it does not work
for 6.6

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-07-13 10:40:08 +08:00
Andrzej Kurek
b22b9778c7 Move the ARRAY_LENGTH definition to common.h
Reuse it in the library and tests.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
2023-06-13 05:46:47 -04:00
Tom Cosgrove
ef2aa0ecad Fix "unterminated '#pragma clang attribute push'" in sha256/sha512.c
If we're built with MBEDTLS_SHAxxx_USE_A64_CRYPTO_IF_PRESENT but don't have a
way to detect the crypto extensions required, the code turns off _IF_PRESENT
and falls back to C only (with a warning). This was done after the attributes
are pushed, and the pop is done only #if defined(xxx_IF_PRESENT), so this
commit fixes that.

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-06-09 11:29:50 +01:00
Dave Rodgman
db6ab247fc Improve macro naming
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-14 16:03:57 +00:00
Jerry Yu
b28d55b242 fix wrong typo and indent issue
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-03-14 10:36:47 +08:00
Jerry Yu
6f86c19d62 Improve readability for compiler version check
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-03-13 11:03:40 +08:00
Jerry Yu
02487a2123 Rename target option flag macro
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-03-13 10:19:35 +08:00
Jerry Yu
77a010e3b3 Remove the max version limitation for clang workaround
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-03-13 10:19:35 +08:00
Jerry Yu
490bf08dd9 fix comment issues
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-03-13 10:19:34 +08:00
Jerry Yu
7b4d9da08c fix wrong clang version check.
Both inline assembly and intrinsic need pragma

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-03-13 10:19:34 +08:00
Jerry Yu
fc2e128fc9 Fix grammar issues and remove useless code
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-02-27 11:16:56 +08:00
Jerry Yu
4d786a732b Fix regression issue for clang workaround.
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-02-22 11:01:07 +08:00
Jerry Yu
ba4ec24c79 fix code style failure
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-02-21 15:59:18 +08:00
Jerry Yu
a135deeece Move clang bug workaround to the head of file
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-02-16 17:56:33 +08:00
Jerry Yu
2f2c04956d Add GCC options pop
Reduce the scope of target pragma to meet
behavior of clang.

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-02-16 14:24:46 +08:00
Jerry Yu
92fc538a22 Add attribute popup
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-02-16 11:17:11 +08:00
Jerry Yu
64e5d4a2cd Replace error output with target pragma if possible
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-02-15 11:58:48 +08:00
Jerry Yu
35f2b26fd8 move cpu modifier flags check to source file
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-02-15 11:58:48 +08:00
Dave Rodgman
cb0f2c4491 Tidy-up - move asm #define into build_info.h
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-01-20 14:04:48 +00:00
Gilles Peskine
449bd8303e Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:50:10 +01:00
David Horstmann
e3d8f31ba1 Workaround Uncrustify parsing of "asm"
The following code:

 #ifndef asm
 #define asm __asm
 #endif

causes Uncrustify to stop correcting the rest of the file. This may be
due to parsing the "asm" keyword in the definition.

Work around this by wrapping the idiom in an *INDENT-OFF* comment
wherever it appears.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-03 11:07:09 +00:00
Valerio Setti
326cf46764 test: improved readability in sha self tests
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-12-23 14:57:18 +01:00
Valerio Setti
898e7a3afe test: sha: test SHA384 and SHA512 separately
This is meant to adapt to the new library design in which
SHA384 and SHA512 can be built independently from each other.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-12-14 10:50:54 +01:00
Valerio Setti
43363f5962 sha: make SHA-384 independent from SHA-512
Using proper configuration options (i.e. MBEDTLS_SHA384_C and
MBEDTLS_SHA512_C) it is now possible to build SHA384 and SHA512
independently from each other.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2022-12-14 08:53:23 +01:00
Gilles Peskine
744fd37d23
Merge pull request #6467 from davidhorstmann-arm/fix-unusual-macros-0
Fix unusual macros
2022-10-25 19:55:29 +02:00
Gilles Peskine
0fe6631486
Merge pull request #6291 from gilles-peskine-arm/platform.h-unconditional-3.2
Include platform.h unconditionally
2022-10-13 10:19:22 +02:00
David Horstmann
2788f6b668 Refactor macro-spanning if in sha512.c
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-10-07 14:08:42 +01:00
Gilles Peskine
a7aa80c058 Include platform.h unconditionally: second automatic part
Some source files included platform.h in a nested conditional. The previous
commit "Include platform.h unconditionally: automatic part" only removed
the outer conditional. This commit removes the inner conditional.

This commit once again replaces most occurrences of conditional inclusion of
platform.h, using the following code:

```
perl -i -0777 -pe 's!#if.*\n#include "mbedtls/platform.h"\n(#else.*\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*)?#endif.*!#include "mbedtls/platform.h"!mg' $(git grep -l '#include "mbedtls/platform.h"')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-15 20:34:10 +02:00
Gilles Peskine
945b23c46f Include platform.h unconditionally: automatic part
We used to include platform.h only when MBEDTLS_PLATFORM_C was enabled, and
to define ad hoc replacements for mbedtls_xxx functions on a case-by-case
basis when MBEDTLS_PLATFORM_C was disabled. The only reason for this
complication was to allow building individual source modules without copying
platform.h. This is not something we support or recommend anymore, so get
rid of the complication: include platform.h unconditionally.

There should be no change in behavior since just including the header should
not change the behavior of a program.

This commit replaces most occurrences of conditional inclusion of
platform.h, using the following code:

```
perl -i -0777 -pe 's!#if.*\n#include "mbedtls/platform.h"\n(#else.*\n(#define (mbedtls|MBEDTLS)_.*\n|#include <(stdarg|stddef|stdio|stdlib|string|time)\.h>\n)*)?#endif.*!#include "mbedtls/platform.h"!mg' $(git grep -l '#include "mbedtls/platform.h"')
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-09-15 20:33:07 +02:00
Tuvshinzaya Erdenekhuu
5893ab02b6 Re-introduce ENUM validation in sha512.c
Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
2022-08-31 10:15:25 +01:00
Tuvshinzaya Erdenekhuu
3446c2603a Remove NULL pointer validation in sha512.c
Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
2022-08-31 10:15:25 +01:00
Tom Cosgrove
c144ca6473 Hide unnecessarily public functions in SHA-256 and SHA-512 A64 acceleration
Fixes #5752

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-04-19 13:52:24 +01:00
Tom Cosgrove
87fbfb5d82 SECLIB-667: Accelerate SHA-512 with A64 crypto extensions
Provide an additional pair of #defines, MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT
and MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY. At most one of them may be
specified. If used, it is necessary to compile with -march=armv8.2-a+sha3.

The MBEDTLS_SHA512_PROCESS_ALT and MBEDTLS_SHA512_ALT mechanisms
continue to work, and are mutually exclusive with SHA512_USE_A64_CRYPTO.

There should be minimal code size impact if no A64_CRYPTO option is set.

The SHA-512 implementation was originally written by Simon Tatham for PuTTY,
under the MIT licence; dual-licensed as Apache 2 with his kind permission.

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-03-23 21:40:53 +00:00
Joe Subbiani
99edd6c810 Add UINT64 GET and PUT macros
Copy over the GET/PUT_UINT64_LE/BE macros from aes.c and sha512.c
Add the MBEDTLS_ prefix to all 4 macros.
Modify the GET_UINT64 macros to no longer take a target variable
as a parameter, so when the macro function is called it must be
assigned to a variable in the same statement.

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
2021-08-19 09:56:47 +01:00
TRodziewicz
26371e4793 Rename the _ret() functions
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-06-08 16:45:41 +02:00
Mateusz Starzyk
17011a3185 Merge branch 'development' into convert_NO_SHA384_to_positive
Conflicts:
	library/version_features.c
	programs/test/query_config.c

Files were removed in development branch and modified by current branch.
Conflicts fixes by removing them.
2021-05-20 14:18:12 +02:00
Gilles Peskine
e02e02f203 Change sha512 output type from an array to a pointer
The output parameter of mbedtls_sha512_finish_ret and mbedtls_sha512_ret
now has a pointer type rather than array type. This removes spurious
warnings in some compilers when outputting a SHA-384 hash into a
48-byte buffer.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-05-13 00:32:45 +02:00
Mateusz Starzyk
3352a53475 Modify config option for SHA384.
Although SHA512 is currently required to enable SHA384, this
is expected to change in the future. This commit is an
intermediate step towards fully separating SHA384 and SHA512.

check_config is the only module which enforces that SHA512 is
enabled together with SHA384.

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-04-28 14:38:37 +02:00
TRodziewicz
136b3989cb Remove deprecated things from hashing modules
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-04-15 12:34:09 +02:00