Commit graph

26723 commits

Author SHA1 Message Date
Agathiyan Bragadeesh
ddc720d209 Add mbedtls_x509_dn_gets hexstring output
If the data is a bitstring or an octet string, instead use the hexstring
of the BER encoding (RFC 4514 Section 2.4)

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
ef299d6735 Add more tests for RFC 4514
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
b73778d8f9 Implement parse_attribute_value_ber_encoded
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
e119f3c0ea Refactor mbedtls_x509_string_to_names
This refactor is to accomodate future support of numericoid/hexstring
attributetype value pairs.

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
404b4bb9ab Add x509 tests for upper and lowercase hexpairs
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
f0e1ac59d8 Rewrite nibble_to_hex_digit for readability
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
9d2507c81d Rename x509_int_to_hexdigit to nibble_to_hex_digit
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:56 +01:00
Agathiyan Bragadeesh
dba8a641fe Add and update tests for x509write and x509parse
Due to change in handling non-ascii characters, existing tests had to be
updated to handle the new implementation. New tests and certificates
are added to test the escaping functionality in edge cases.

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:39:52 +01:00
Agathiyan Bragadeesh
ef2decbe4a Escape hexpairs characters RFC 4514
Converts none ascii to escaped hexpairs in mbedtls_x509_dn_gets and
interprets hexpairs in mbedtls_x509_string_to_names.

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:38:16 +01:00
Agathiyan Bragadeesh
48513b8639 Escape special characters RFC 4514
This escapes special characters according to RFC 4514 in
mbedtls_x509_dn_gets and de-escapes in mbedtls_x509_string_to_names.
This commit does not handle hexpairs.

Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-08-22 10:38:16 +01:00
Tom Cosgrove
17d5081ffb
Merge pull request #8099 from gilles-peskine-arm/split-config_psa-prepare
Prepare to split config_psa.h
2023-08-22 07:30:46 +00:00
Gilles Peskine
d50562c33c
Merge pull request #7827 from davidhorstmann-arm/reword-net-free-description-2544
Reword the description of `mbedtls_net_free()`
2023-08-21 22:23:08 +00:00
Tom Cosgrove
31b2d7414d
Merge pull request #8053 from gilles-peskine-arm/mpi_exp_mod-remove_initial_copy
mbedtls_mpi_exp_mod: remove spurious copy of the output variable
2023-08-21 15:50:28 +00:00
Gilles Peskine
796bc2b8f9
Merge pull request #7486 from AndrzejKurek/calloc-also-zeroizes
Document mbedtls_calloc zeroization
2023-08-21 15:47:21 +00:00
Gilles Peskine
0addbe6dc7
Merge pull request #8069 from paul-elliott-arm/fix_ecjpake_deadcode
Fix logical dead code found by Coverity
2023-08-21 14:44:36 +00:00
Gilles Peskine
d686c2a822
Merge pull request #7971 from AgathiyanB/fix-data-files-makefile
Fix server1.crt.der in tests/data_files/Makefile
2023-08-21 14:43:07 +00:00
Dave Rodgman
65204f8fc8
Merge pull request #8035 from daverodgman/aesce-support-perf
Make mbedtls_aesce_has_support more efficient
2023-08-21 14:39:08 +00:00
Gilles Peskine
ea4fc97cd0 Restore a comment and fix it
aca31654e6 removed a sentence with copypasta
refering to PBKDF2 instead of XTS. Restore that comment but fix the
copypasta.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 16:16:24 +02:00
Gilles Peskine
9af413bcc5 Don't try to include mbedtls/config_*.h
They're included by build_info.h and must not be included directly.

Currently, this only concerns one file: config_psa.h. It's technically a bug
to include it, but a harmless one because that header has already been
included by build_info.h except in configurations where it
effectively had no effect (enabling PSA options with PSA turned off).

We plan to split config_psa.h into multiple headers that are less
independent, which could make the inclusion more problematic.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 16:12:36 +02:00
Gilles Peskine
44243e11ff Remove obsolete header inclusions
Since 3.0.0, mbedtls_config.h (formerly config.h) no longer needs to include
config_psa.h or check_config.h: build_info.h takes care of that.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 16:10:06 +02:00
Gilles Peskine
7b7ecf5e0d Fix condition to include MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE
Don't try to include MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE when
MBEDTLS_PSA_CRYPTO_CONFIG is disabled. This didn't make sense and was an
editorial mistake when adding it: it's meant as an addition to
MBEDTLS_PSA_CRYPTO_CONFIG_FILE, so it should be included under the same
conditions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 16:09:14 +02:00
Gilles Peskine
a458d48e7f Move the inclusion of the PSA config file(s) into build_info.h
They belong here, next to the inclusion of the mbedtls config file. We only
put them in config_psa.h in Mbed TLS 2.x because there was no build_info.h
we could use.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 16:06:12 +02:00
Gilles Peskine
8cd1da4b73 Remove spurious extern "C"
This header only contains preprocessor definitions. They are not affected by
extern "C".

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-08-21 16:03:41 +02:00
Tom Cosgrove
d29648026b
Merge pull request #8017 from ivq/unchecked_return
Fix a few unchecked return values
2023-08-21 13:02:53 +00:00
Janos Follath
e220d258fd
Merge pull request #8086 from yanesca/remove-new-bignum
Remove new bignum when not needed
2023-08-21 10:59:41 +00: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
b30adce7fd Use -1 as uninitialised marker
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-20 20:20:12 +01:00
Dave Rodgman
4566132163 Make mbedtls_aesce_has_support more efficient
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
0a6272d6c9 revert padlock from aesni module
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-18 17:35:59 +08: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
Bence Szépkúti
505dffd5e3
Merge pull request #7937 from yanrayw/code_size_compare_improvement
code_size_compare.py: preparation work to show code size changes in PR comment
2023-08-17 20:59:11 +00:00
Gilles Peskine
eeaad50cd6
Merge pull request #8079 from adeaarm/port_IAR_build_fix
Small fixes for IAR support
2023-08-17 19:10:51 +00:00
Gilles Peskine
dbd13c3689
Merge pull request #7662 from lpy4105/issue/renew_cert_2027-01-01
Updating crt/crl files due to expiry before 2027-01-01
2023-08-17 15:38:35 +00:00
Antonio de Angelis
8e9d6b927e Remove the workaround for psa_key_agreement_internal
Remove the workaround for psa_key_agreement_internal to
have a shared_secret array always non-zero. The spec is
recently updated so that PSA_RAW_KEY_AGREEMENT_OUTPUT_MAX_SIZE
is always non-zero

Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-17 15:27:56 +01:00
Janos Follath
f2334b7b39 Remove new bignum when not needed
New bignum modules are only needed when the new ecp_curves module is
present. Remove them when they are not needed to save code size.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2023-08-17 14:36:59 +01:00
Gilles Peskine
294be94922
Merge pull request #7818 from silabs-Kusumit/PBKDF2_cmac_implementation
PBKDF2 CMAC implementation
2023-08-17 11:15:16 +00: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
6c6b9f602c Change document to match real status
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 16:53:01 +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
f258d17acd remove aesni + padlock - plain c tests
This test is not valid for padlock depends
on plain c

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 12:39:00 +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
Jerry Yu
35b59d7805 exclude arm64ec mode for aesni
AESNI does not work correctly for msvc arm64ec

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-08-17 10:34:15 +08:00
Antonio de Angelis
f1adc2a7a1 Use asm instead of __asm in constant_time.c
The original IAR fix submitted to TF-M directly changed asm to __asm.
But mbed TLS now has a workaround for such cases hence just remove the
original change modification.

Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-16 12:48:48 +01: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
TTornblom
e4f6d79bbe BUILD: Update For IAR support
Applied the same change as in mbed-crypto for using this as a sub
project with the IAR toolchain. Use __asm generic ,and avoid empty
enum. Avoid declaration of array with null size. This is a porting
of the original patch contributed to trusted-firmware-m.

Signed-off-by: TTornblom <thomas.tornblom@iar.com>
Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
2023-08-16 12:36:21 +01:00