1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-06 06:49:22 +08:00

12394 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
e8061342a2
Merge pull request #10173 from gilles-peskine-arm/oid-split-x509
OID: make X.509 independent from crypto
2025-06-04 08:26:59 +00:00
Gilles Peskine
b828820f7a Declare oid_xxx_numeric_string only when they are defined
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
02ec585518 Replace MBEDTLS_OID_C by function-specific dependencies
For each function in `x509_oid.c`, determine where it is used and only
include it in the build if it is needed by the X.509 code. Define the
corresponding internal tables only when they are consumed by a function.

This makes Mbed TLS completely independent of the compilation option
`MBEDTLS_OID_C`. This option remains present only in sample configs for
crypto, where it must stay until TF-PSA-Crypto no longer relies on this
option.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
cd4c0d7b00 Move OID string definitions back to mbedtls/oid.h
Some code that parses or writes X.509 needs to know OID values. We provide a
convenient list. Don't remove this list from the public interface of the
library.

For user convenience, expose these values in the same header as before and
with the same name as before: `MBEDTLS_OID_xxx` in `<mbedtls/oid.h>`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
4c83221320 Replace MBEDTLS_ERR_OID_NOT_FOUND with MBEDTLS_ERR_X509_UNKNOWN_OID
Replace the non-X.509-named error code `MBEDTLS_ERR_OID_NOT_FOUND` with
`MBEDTLS_ERR_X509_UNKNOWN_OID`, which already exists and is currently not
used for anything.

Public functions in X.509 propagate this error code, so it needs to have a
public name.

Remove the definition of `MBEDTLS_ERR_OID_NOT_FOUND` in `x509_oid.h`, then

```
git grep -l MBEDTLS_ERR_OID_NOT_FOUND | xargs perl -i -pe 's/\bMBEDTLS_ERR_OID_NOT_FOUND\b/MBEDTLS_ERR_X509_UNKNOWN_OID/g'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
47f1d7be95 Replace MBEDTLS_ERR_OID_BUF_TOO_SMALL with PSA_ERROR_BUFFER_TOO_SMALL
Remove the definition of `MBEDTLS_ERR_OID_BUF_TOO_SMALL` in `x509_oid.h`,
and use the corresponding PSA error instead.

```
git grep -l MBEDTLS_ERR_OID_BUF_TOO_SMALL | xargs perl -i -pe 's/\bMBEDTLS_ERR_OID_BUF_TOO_SMALL\b/PSA_ERROR_BUFFER_TOO_SMALL/p'
edit library/x509_oid.h
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
32a1112e88 Remove MBEDTLS_OID_X509_EXT_xxx constants
They're just aliases for the corresponding MBEDTLS_X509_EXT_xxx. We don't
need separate names.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
b7ef4df001 Remove OID tables that are not used in X.509
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
532e3ee104 Switch library and tests to the x509_oid module
```
git grep -l -P 'mbedtls_oid_get_(?!numeric_string\b)' | xargs perl -i -pe 's/\bmbedtls_oid_get_(?!numeric_string\b)/mbedtls_x509_oid_get_/'
./framework/scripts/code_style.py --since HEAD~1 --fix
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
86a47f85fa Switch to "x509_oid.h" in code that uses OID functions
Keep "mbedtls/oid.h" in code that only uses OID macros.

```
git grep -l mbedtls_oid_ '**/*.[hc]' tests/suites/*.function | xargs perl -i -pe 's!["<]mbedtls/oid\.h[">]!"x509_oid.h"!g'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gabor Mezei
b9d728467a
Fix calling config.py and update comment
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-02 17:22:53 +02:00
Gabor Mezei
8e5ee478e1
Add temporary component for SHA3 testing
With the removal of MBEDTLS_SHA3_C the test cases with disabled SHA3
dependency are never executed. Adding a temporary `all.sh` component
which disabling the `PSA_WANT_ALG_SHA3_*` macros to cover
these test cases.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-02 13:28:39 +02:00
Gilles Peskine
80b697d78a
Merge pull request #10183 from felixc-arm/fix-ssl-opt-error-codes
Change hardcoded error values in ssl-opt to take in the PSA error alias
2025-05-27 14:52:51 +00:00
Valerio Setti
4a2e7b9ed8 tests: suite_x509parse: set PSA max operations in x509_verify_restart()
Set also psa_interruptible_set_max_ops() when mbedtls_ecp_set_max_ops()
is set so that the same amount of operations will be used both if legacy
ECDSA_C or PSA is used under the hood to perform the operation.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-23 15:15:22 +02:00
Felix Conway
e0ce40bc8f Change hardcoded error values in ssl-opt to take in the PSA error alias
ssl-opt checks for specific error code values in the output, but as
MBEDTLS_ERR_ECP_IN_PROGRESS is becoming an alias of PSA_OPERATION_INCOMPLETE
then this hardcoded value will change.

Therefore allow the result to be either the old mbedtls error, or the new PSA
error, as not to break the CI.

Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-05-19 16:22:05 +01:00
Gilles Peskine
b9da11f289 Test with GCC 15 with sloppy union initialization
This is a non-regression test for
https://github.com/Mbed-TLS/mbedtls/issues/9814

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-19 16:51:19 +02:00
Gilles Peskine
d31a3c39b1
Merge pull request #10159 from gilles-peskine-arm/union-initialization-gcc15-preliminaries-dev
Test with GCC 15
2025-05-15 14:33:45 +00:00
Manuel Pégourié-Gonnard
7769c16512
Merge pull request #9654 from gabor-mezei-arm/9145_update_depends.py_pkalgs_domain
Update the `pkalgs` domain to use PSA macros in `depends.py`
2025-05-14 08:38:24 +00:00
Gilles Peskine
49b7ef635f
Merge pull request #10166 from gilles-peskine-arm/oid-split-restore-x509
Restore the OID module for use in X.509
2025-05-12 07:59:55 +00:00
Gabor Mezei
f13fd1e272
Use PSA macros for the pkalgs domain
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-05-09 14:51:54 +02:00
Gilles Peskine
d0e799ad8b Improve comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-07 17:15:37 +02:00
Gilles Peskine
d69bfb9044 Allow gcc-15 to be in $PATH
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-07 17:15:37 +02:00
Gilles Peskine
27f0713988 Enable drivers when testing with GCC 15
The goal of testing with GCC 15 is to validate fixes for
https://github.com/Mbed-TLS/mbedtls/issues/9814 . The bug is present in
multiple places, and some of them affect third-party drivers but not our
built-in implementation. (The bug is that driver contexts might not be
zero-initialized, but some of our built-in implementations happen not to
care about this.) Thus, enable the test drivers in the test component that
uses GCC 15, to gain the extra checks performed in the driver wrappers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-07 17:15:37 +02:00
Gilles Peskine
6e245040d4 GCC 15: Silence -Wunterminated-string-initialization
This is a new warning in GCC 15 that our code base triggers in many places.
Silence it for the time being.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-07 17:15:37 +02:00
Gilles Peskine
579475d5d3 Test with GCC 15
Non-regression for https://github.com/Mbed-TLS/mbedtls/issues/9814

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-07 17:15:37 +02:00
Gilles Peskine
1876efc157 Merge remote-tracking branch 'development' into HEAD 2025-05-07 14:41:13 +02:00
Gilles Peskine
47c8579ed0 Copy OID files that are getting moved to tf-psa-crypto
The OID module is used by both crypto and X.509. It has moved to the
`tf-psa-crypto` subdirectory, and the sibling commit
08d8cc57dbe7be54fe3f88ecbc2729300c48d450 removes this subdirectory from the
`mbedtls` repository in order to make `tf-psa-crypto` a submodule. We want
to access the relevant parts directly from X.509 rather than go through the
crypto repository, because OID functions are only accessible as private
interfaces, and crypto doesn't know when a particular OID function is needed
in the build since it depends on X.509 configuration options.

Make a copy of the OID module and its unit tests. In a follow-up, the X.509
module will switch to consuming this copy rather than the one that went into
TF-PSA-Crypto.

Rename the files from `*oid*` to `*x509_oid*` to follow the naming
convention that submodules of X.509 are prefixed with `x509`. This also
avoids file name clashes with TF-PSA-Crypto.

Since OID is not a public interface of Mbed TLS 4.x, move the header file
into `library`.

This commit only makes the files available. Subsequent commits will take
care of making these files used in the build.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-07 14:35:04 +02:00
Valerio Setti
b8d5649ab6 tests: test_suite_x509: adapt RSA-PSS tests
Parsing of CRT files with message's hash alg different from the MGF1 was
allowed in the past, but now it fails. So we need to move/adapt tests
relying on this feature, from a "verify" scope to a "parse" one.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-07 09:06:52 +02:00
Valerio Setti
7f6f4e6907 library: pass NULL options parameter to mbedtls_pk_verify_ext()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-07 09:06:52 +02:00
Valerio Setti
d24dfad7af library: x509: remove sig_opts from mbedtls_x509_sig_alg_gets()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-07 09:06:52 +02:00
Gilles Peskine
2439c4c14a
Merge pull request #10090 from valeriosetti/issue9618-development
[development] MBEDTLS_PLATFORM_GET_ENTROPY_ALT in 4.0
2025-05-06 22:35:03 +02:00
Valerio Setti
1afedacfea tests: scripts: add new component to configuration-platform.sh
Import component_test_platform_get_entropy_alt() from its counterpart
in TF-PSA-Crypto repo.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-06 06:28:35 +02:00
Gilles Peskine
5f6c6334f8
Merge pull request #10157 from diopoex/development
Remove use of mbedtls_md_get_name() from ssl_context_info.c
2025-04-30 07:00:01 +00:00
Paul Höhn
02c80e631f
Fix test and formatting in ssl_context_info
Signed-off-by: Paul Höhn <paul.hoehn@icloud.com>
2025-04-29 22:02:24 +02:00
Paul Höhn
e38041673f
fixed the tests
Signed-off-by: Paul Höhn <paul.hoehn@icloud.com>
2025-04-29 18:53:07 +02:00
Valerio Setti
0f0304d433 scripts: tests: fix component_test_full_cmake_clang
Use the proper Clang C++ compiler to build C++ code otherwise the C
compiler will fail because std::cout() is unknown in
"cpp_dummy_build.cpp".

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-29 11:01:46 +02:00
Valerio Setti
7fb7fdabd7 tests: scripts: fix component_test_no_platform()
Use alternative implementation of mbedtls_platform_get_entropy() since
the default one lives in "platform.c" and that one is excluded in
this test component.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-29 11:01:46 +02:00
Valerio Setti
b13d29ebb2 tests: scripts: fix test_cmake_out_of_source
By default C++ code would be compiled with GNU while C with Clang and
this can create problems at link time. In order to prevent this we
use Clang for both.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-29 11:01:46 +02:00
Valerio Setti
7ac11845d0 configs: add PLATFORM_C to configs using ENTROPY_C
This is necessary to let entropy being able to gather entropy data from
the native platform source.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-29 11:01:46 +02:00
Valerio Setti
73bd210a94 tests: remove usage of MBEDTLS_NO_PLATFORM_ENTROPY
Use MBEDTLS_PLATFORM_GET_ENTROPY_ALT instead.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-29 11:01:46 +02:00
Valerio Setti
405d4adff2 psasim: add timeout while waiting for psa_server to start
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-29 11:01:46 +02:00
Ben Taylor
1948c94385 added dependencies to test scripts
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-04-29 07:43:37 +01:00
David Horstmann
ad6953f788
Merge pull request #10114 from felixc-arm/switch-to-which-aes
Switch all.sh components from selftest to which_aes
2025-04-28 06:58:38 +00:00
Gilles Peskine
4156c49342
Merge pull request #10122 from felixc-arm/move-public-headers
Adjust build scripts to accommodate public header move
2025-04-24 17:47:17 +00:00
Gilles Peskine
97c45bb2e0
Merge pull request #10120 from gilles-peskine-arm/test_suite_ssl-fix-ret-20250408
Fix uncaught failure conditions in test_suite_ssl
2025-04-23 16:42:20 +00:00
Felix Conway
6908580131 Use aesni_crypt_ecb and internal_aes_encrypt to check conditional compilation
Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-04-22 10:45:28 +01:00
Felix Conway
ad7049407b Remove executable permissions and shebang from component-platforms.sh
Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-04-22 10:45:28 +01:00
Felix Conway
8e13c8f018 Add shebang to fix CI error
Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-04-22 10:35:52 +01:00
Felix Conway
5081d6544d Switch all.sh components from selftest to which_aes
Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-04-22 10:35:49 +01:00
David Horstmann
232da48471
Merge pull request #9421 from mfil/feature/implement_tls_exporter
Implement TLS-Exporter
2025-04-17 14:47:13 +00:00