7316 Commits

Author SHA1 Message Date
Pengyu Lv
41bb446d12 Update TEST_CA_CRT_EC_PEM and TEST_CA_CRT_EC_DER
To retain the ABI compatibility, we need the DER
data to be in the exact size of 520 bytes. So,
these data are regenerated by unsetting the
'critical' flag of 'basic_constraints' extension,
though the extension should be critical for this
CA according to RFC5280 section 4.2.1.9.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-06-15 15:41:30 +08:00
Pengyu Lv
04da85f0f4 Update TEST_SRV_CRT_EC_PEM and TEST_SRV_CRT_EC_DER
Regenerate server5.crt[.der] until we got the
DER data in the size of 547 bytes to maintain
the ABI compatibility.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-06-15 13:01:35 +08:00
Pengyu Lv
14f59bfca8 Update cert macros in library/certs.c
This commit manually updates:
  - TEST_CA_CRT_EC_PEM
  - TEST_CA_CRT_EC_DER
  - TEST_SRV_CRT_EC_PEM
  - TEST_SRV_CRT_EC_DER

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-06-14 09:55:41 +08:00
Dave Rodgman
247e6f088d
Merge pull request #7608 from daverodgman/pr6511-2.28
Fix: no newline when debug msg over DEBUG_BUF_SIZE - backport 2.28
2023-05-17 17:59:54 +01:00
Gilles Peskine
2710fe2d5e
Merge pull request #7571 from bharsaklemukesh975/update-pkparse-tests-to-use-AES-2.28
Backport 2.28: Updating test-ca.key to use AES instead of DES
2023-05-16 19:15:11 +02:00
Dave Rodgman
bd77182063 Make use of MBEDTLS_STATIC_ASSERT
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-16 16:47:09 +01:00
Dave Rodgman
001917898f Document minimum size for DEBUG_BUF_SIZE
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-16 16:47:09 +01:00
valord577
0d87d90cea simplify code
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
valord577
de6ea9847d code style
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
valord577
06b0bb55e3 make code readable and change var name
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
valord577
e3623920cf send debug msg if contains '\n'
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
Dave Rodgman
40fe1cd364 Update library/debug.c
Fix trailing white-space

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-16 16:47:09 +01:00
valord577
afbaac29e8 Fix: no newline when debug msg over DEBUG_BUF_SIZE
Signed-off-by: valord577 <valord577@gmail.com>
2023-05-16 16:47:09 +01:00
Gilles Peskine
e32e447407 Ignore *.o everywhere
We don't commit *.o files anywhere, not even as test data. So ignore them
everywhere.

Also remove a redundant ignore of *.exe in a subdirectory.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-05-12 13:57:39 +02:00
Mukesh Bharsakle
2599a71c74 updating test-ca.key to use AES instead of DES 2023-05-10 12:12:40 +01:00
Dave Rodgman
2e4541f96f
Merge pull request #7545 from tom-cosgrove-arm/use-mbedtls_ct_uint_if-rather-than-mbedtls_ct_cond_select_sign-2.28
Backport 2.28: Use mbedtls_ct_uint_if() rather than mbedtls_ct_cond_select_sign()
2023-05-04 12:23:36 +01:00
Tom Cosgrove
735d2c99e7 Backport 2.28: Use mbedtls_ct_uint_if() rather than mbedtls_ct_cond_select_sign()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-05-03 09:50:10 +01:00
Valerio Setti
0eace4128b pk: fixing backport issues
Note: RSA is not supported in mbedtls-2.28 for opaque wrapping
so it was removed from test_suite_pkwrite.data.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:38:57 +02:00
Valerio Setti
5e7494ea75 pk: fix position for mbedtls_platform_zeroize
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:06:34 +02:00
Valerio Setti
aae96c9060 pk: fix: clear buffer holding raw EC private key on exit
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-05-02 16:00:45 +02:00
Tom Cosgrove
503f487cbe
Merge pull request #7469 from xkqian/2.28/bignumber_update_comments
Backport 2.28: Update links of references in bignum code
2023-04-26 16:22:09 +01:00
Xiaokang Qian
8738bc46e3 Update gen_prvkey_mx paras to align with comments and c code
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-04-21 10:29:17 +00:00
Xiaokang Qian
0e5a27b640 Update links of references in bignum code
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
2023-04-21 09:58:07 +00:00
Dave Rodgman
6ab5d5c536 Fix trailing whitespace
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 17:24:10 +01:00
Dave Rodgman
8f109fc249 Fix use of uninitialised variable
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 17:07:04 +01:00
Dave Rodgman
b2e3c7af2d Tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:43:40 +01:00
Dave Rodgman
8dde24eb08 Tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:24:04 +01:00
Dave Rodgman
42a5bb16c6 Fix failure to write back when reset != 0; tidy-up
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:20:32 +01:00
Dave Rodgman
0feecbd6f3 Copy the struct to align it, avoiding an ABI break
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-31 16:10:18 +01:00
Dave Rodgman
e4f1aac0fd Bump version to 2.28.3
Command used: ./scripts/bump_version.sh --version 2.28.3

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-03-23 18:06:54 +00:00
Paul Elliott
a183e1d53d Merge branch 'mbedtls-2.28-restricted' into mbedtls-2.28.3rc0-pr
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-03-21 15:34:35 +00:00
Tom Cosgrove
410594c002 Have MBEDTLS_STATIC_ASSERT() match current development more closely
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-20 15:10:11 +00:00
Tom Cosgrove
bdd01a74ef Implement and use MBEDTLS_STATIC_ASSERT()
Fixes #3693

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-20 15:08:21 +00:00
Tom Cosgrove
640b761e49 Print out AESNI mechanism used by GCM in self-test
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-19 15:07:06 +00:00
Tom Cosgrove
2c942a35ff Fix code style nit
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-19 14:04:04 +00:00
Tom Cosgrove
20458c0963 Have selftest print more information about the AESNI build
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-18 14:48:49 +00:00
Tom Cosgrove
3b53caed9f Remove references to MBEDTLS_AESCE_C and MBEDTLS_HAVE_ARM64
that aren't needed in this backport

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-17 18:25:36 +00:00
Tom Cosgrove
58550acba0 Fix merge errors in backporting
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-17 16:54:59 +00:00
Gilles Peskine
6dec541e68 AESNI: Overhaul implementation selection
Have clearly separated code to:
* determine whether the assembly-based implementation is available;
* determine whether the intrinsics-based implementation is available;
* select one of the available implementations if any.

Now MBEDTLS_AESNI_HAVE_CODE can be the single interface for aes.c and
aesni.c to determine which AESNI is built.

Change the implementation selection: now, if both implementations are
available, always prefer assembly. Before, the intrinsics were used if
available. This preference is to minimize disruption, and will likely
be revised in a later minor release.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:59 +00:00
Gilles Peskine
b71d40228d Clean up AES context alignment code
Use a single auxiliary function to determine rk_offset, covering both
setkey_enc and setkey_dec, covering both AESNI and PADLOCK. For AESNI, only
build this when using the intrinsics-based implementation, since the
assembly implementation supports unaligned access.

Simplify "do we need to realign?" to "is the desired offset now equal to
the current offset?".

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:58 +00:00
Gilles Peskine
30c356c540 Use consistent guards for padlock code
The padlock feature is enabled if
```
defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86)
```
with the second macro coming from `padlock.h`. The availability of the
macro `MBEDTLS_PADLOCK_ALIGN16` is coincidentally equivalent to
`MBEDTLS_HAVE_X86` but this is not meaningful.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:38 +00:00
Gilles Peskine
6978e73939 Fix unaligned access if the context is moved during operation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:34 +00:00
Gilles Peskine
5f1677f582 Fix typo in comment
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:31 +00:00
Gilles Peskine
de34578353 Fix code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:28 +00:00
Gilles Peskine
2e8d8d1fd6 Fix MSVC portability
MSVC doesn't have _mm_storeu_si64. Fortunately it isn't really needed here.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:23 +00:00
Gilles Peskine
d4a239310b Improve variable names
To some extent anyway.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:21 +00:00
Tom Cosgrove
790756d439 Get aesni.c compiling with Visual Studio
Clang is nice enough to support bitwise operators on __m128i, but MSVC
isn't.

Also, __cpuid() in MSVC comes from <intrin.h> (which is included via
<emmintrin.h>), not <cpuid.h>.

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-03-17 16:31:18 +00:00
Gilles Peskine
e7dc21fabb AESNI: add implementation with intrinsics
As of this commit, to use the intrinsics for MBEDTLS_AESNI_C:

* With MSVC, this should be the default.
* With Clang, build with `clang -maes -mpclmul` or equivalent.
* With GCC, build with `gcc -mpclmul -msse2` or equivalent.

In particular, for now, with a GCC-like compiler, when building specifically
for a target that supports both the AES and GCM instructions, the old
implementation using assembly is selected.

This method for platform selection will likely be improved in the future.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:16 +00:00
Gilles Peskine
2c8ad9400b AES, GCM selftest: indicate which implementation is used
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:14 +00:00
Gilles Peskine
5511a34566 New preprocessor symbol indicating that AESNI support is present
The configuration symbol MBEDTLS_AESNI_C requests AESNI support, but it is
ignored if the platform doesn't have AESNI. This allows keeping
MBEDTLS_AESNI_C enabled (as it is in the default build) when building for
platforms other than x86_64, or when MBEDTLS_HAVE_ASM is disabled.

To facilitate maintenance, always use the symbol MBEDTLS_AESNI_HAVE_CODE to
answer the question "can I call mbedtls_aesni_xxx functions?", rather than
repeating the check `defined(MBEDTLS_AESNI_C) && ...`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-03-17 16:31:12 +00:00