33511 Commits

Author SHA1 Message Date
Gabor Mezei
2649800f7c
Do not disable PSA_WANT_SHA3 macros when driver accel is used
The SW implementation is guarded with the `MBEDTLS_PSA_BUILTIN_ALG_SHA3`
macros and not enabled when driver accelaration is set. So disabling
the `PSA_WANT` macros is not needed.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-05 14:01:30 +02:00
Gabor Mezei
c45f3d6a1d
Update PSA repo
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-05 14:01:25 +02:00
Ben Taylor
83e5a7bf75 update framework submodule to pull in everest changes
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-06-05 11:26:51 +01:00
Ben Taylor
de864e7a1c Remove ChangeLog as it is not required
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-06-05 11:26:51 +01:00
Ben Taylor
40bc348963 corrected ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-06-05 11:26:51 +01:00
Ben Taylor
142347383f Add ChangeLog for removal of everest headers
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-06-05 11:26:51 +01:00
Ben Taylor
243b54f386 update further everest paths
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-06-05 11:26:51 +01:00
Ben Taylor
2d6374a0f9 adjust everest header paths in generate_visualc_files.pl
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-06-05 11:26:51 +01:00
Gilles Peskine
b4cbc156ef
Merge pull request #10192 from valeriosetti/fixes-for-ecp-restartable-part2
[development] Some pre-requisites for psa#299
2025-06-05 07:50:53 +00:00
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
Gabor Mezei
72cc7bb706
Start the generation at the beginning of the line
The markers for the generated code need to indented due to the code style check.
During the replacement remove the spaces along with the markers.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-03 17:49:23 +02:00
Gabor Mezei
588769cc65
Update error generation
Adapt the `generate_errors.pl` to handle `PSA_WANT` macros and
update to handle SHA3 macros.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-03 17:49:23 +02:00
Gabor Mezei
4aa974f7c7
Remove MBEDTLS_SHA3_C config option
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-03 17:49:23 +02:00
Gilles Peskine
7e7dc6fdda Align endif comments with auxiliary macros
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
9e147f264c Exclude crypto's oid.h now that it is in mbedtls
Otherwise Doxygen complains about two `\file` with the same name.

This is a temporary exclusion which can be removed once crypto no longer has
an oid.h.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
53e11cb5d5 Changelog entry for the OID module in Mbed TLS 4.0
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
dcd43fcc45 Move oid_xxx_numeric_string back to oid.h
The header `mbedtls/oid.h` now belongs to the X.509 library. Move the
declarations of `mbedtls_oid_get_numeric_string()` and
`mbedtls_oid_from_numeric_string()` back to this header, which is where they
were in all previous releases of Mbed TLS. This avoids gratuitously breaking
backward compatibility.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02: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
6354411670 Remove unused function
mbedtls_oid_get_md_alg() is used in X.509, but
mbedtls_oid_get_oid_by_md() is only used in crypto.

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
f9ca8ed9dd Create a public header file for OID values
This will be a subset of the former `<mbedtls/oid.h>`, with only macro
definitions, no function declarations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
71ccc723cd Remove macros for crypto OID
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
d2fe51cfc4 Add the x509_oid module to the build
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
86e45ba0ba Rename OID functions and types to mbedtls_x509_oid_xxx in x509_oid
Avoid clashes with the functions and the type that are still defined in
TF-PSA-Crypto. They are now internal names, so it doesn't really matter, but
having the same name as the ones declared in TF-PSA-Crypto's `oid.h` would
cause problems during the transition.

Remove the unused name for `struct mbedtls_oid_descriptor_t`, and rename the
rest:

```
perl -i -pe 's/mbedtls_oid_/mbedtls_x509_oid_/g' library/x509_oid.[hc]
./framework/scripts/code_style.py --fix library/x509_oid.[hc]
```

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
Gilles Peskine
b825dcfe2d Update file names in comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
86b9d3f299 documentation of mbedtls_ssl_async_sign_t with RSA: update to PSA
Stop referring to low-level APIs that are becoming private.

Also drop the requirement on supporting what is now
PSA_ALG_RSA_PKCS1V15_SIGN_RAW. That was needed for TLS 1.0/1.1 which signs
MD5||SHA1, but is no longer needed since Mbed TLS 3.0 dropped support for
these protocol versions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Bence Szépkúti
591d854b1a
Merge pull request #10201 from gabor-mezei-arm/9144_SHA3_testing
Add temporary test component for SHA3 testing
2025-06-02 17:52:07 +00: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
6edb76cba4 mbedtls_test_ssl_endpoint_init: split configuration and setup
Split `mbedtls_test_ssl_endpoint_init()` into two separate stages:
constructing the SSL configuration, and setting up an SSL session context
with that configuration.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-01 21:53:52 +02:00
Gilles Peskine
00eb072846 mbedtls_test_ssl_endpoint_init: store user_data_n in the endpoint object
This will allow splitting the configuration and setup stages of
`mbedtls_test_ssl_endpoint_init()`, while still checking that the value is
carried over from the configuration to the session context.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-01 21:52:30 +02:00
Gilles Peskine
a6e71f95fb Don't change the configuration after mbedtls_ssl_setup
In `mbedtls_test_ssl_endpoint_init()`, don't change the SSL configuration
object (`mbedtls_ssl_config`) after setting up an SSL context by calling
`mbedtls_ssl_setup()`. This works in practice, but is officially forbidden.

No intended behavior change. The test code calls the library slightly
differently, but this shouldn't make any difference in practice. If it does
make a difference, it fixes a bug in the test code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-01 21:34:28 +02:00
Gilles Peskine
6e4d245b00 Move certificate and key parsing to auxiliary functions
No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 21:36:28 +02:00
Gilles Peskine
fb2ce055a3 SSL tests: make client authentication more uniform, defaulting on
There was a discrepancy between how `mbedtls_test_ssl_endpoint_init()` and
`mbedtls_test_ssl_perform_handshake()` handled client authentication:
`mbedtls_test_ssl_endpoint_init()` defaulted to
`MBEDTLS_SSL_VERIFY_REQUIRED` on both sides, whereas
`mbedtls_test_ssl_perform_handshake()` obeyed `options->srv_auth_mode` which
defaulted to no verification of the client certificate.

Make this more uniform. Now `mbedtls_test_ssl_endpoint_init()` obeys
`options->srv_auth_mode` on servers (still forcing verification on clients,
which is the library default anyway). Also, `options->srv_auth_mode` is now
enabled by default. Thus:

* Tests that call `mbedtls_test_ssl_perform_handshake()` now perform client
  certificate verification, unless they disable it explicitly.
* Tests that call `mbedtls_test_ssl_endpoint_init()` on a server are
  unchanged. (They would change if they were setting
  `options->srv_auth_mode` explicitly, which previously was ignored, but
  no test function did this.)

This means that a few test functions now perform client certificate
verification whereas they previously don't. This is harmless except in
`handshake_ciphersuite_select`, where one test case
`Handshake, select ECDH-RSA-WITH-AES-256-CBC-SHA384, opaque` fails with
client authentication because the test code doesn't deal with the weirdness
of static ECDH correctly with respect to client authentication. So keep
the previous behavior in `handshake_ciphersuite_select`, by explicitly
turning off client authentication.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 21:36:28 +02:00
Gilles Peskine
27586d83f0 Move more endpoint configuration into the setup function
Applying SSL configuration settings recorded in the
`mbedtls_test_handshake_test_options` structure to an
`mbedtls_test_ssl_endpoint` object was split between
`mbedtls_test_ssl_endpoint_init()` and `mbedtls_test_ssl_perform_handshake()`.
This was surprising, and made it harder to use
`mbedtls_test_ssl_endpoint_init()` for custom behavior. It also meant some
code duplication in `mbedtls_test_ssl_perform_handshake()`.

Move most configuration setup from `mbedtls_test_ssl_perform_handshake()` to
`mbedtls_test_ssl_endpoint_init()`. This changes the behavior in two ways:

* `mbedtls_test_ssl_endpoint_init()` now takes some options into account
  that it previously ignored. This is ok because we don't set these options
  in any of the existing tests.
* When calling `mbedtls_test_ssl_perform_handshake()`, some SSL configuration
  settings are now set (calls to `mbedtls_ssl_conf_xxx()`) before the call
  to `mbedtls_ssl_setup()` instead of after. This should be ok since it is
  forbidden to change the configuration after `mbedtls_ssl_setup()`,
  although the previous test code was getting away with it. This commit does
  not move all configuration before `mbedtls_ssl_setup()`, that would be out
  of scope of the current series of patches.

Thus there are some internal behavior changes, but they should not affect
any relevant aspect of the tests' behavior.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 21:36:26 +02:00
Gilles Peskine
7a8fd46392 Separate test function to perform an SSL connection
Split mbedtls_test_ssl_perform_connection() out of
mbedtls_test_ssl_perform_handshake().

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 20:23:22 +02:00
Gilles Peskine
bd95340070 Unify SSL version checks between client and server
Stop calling mbedtls_test_set_step() in
mbedtls_test_ssl_perform_handshake(). This leaves the caller free to use the
test step as they wish.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 20:23:22 +02:00
Gilles Peskine
e23a6d12fc Move serialization testing into its own function
No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 20:23:22 +02:00
Gilles Peskine
78df6aebbc Move renegotiation testing into its own function
No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 20:23:22 +02:00
Gilles Peskine
e30b5c73f3 mbedtls_test_ssl_perform_handshake: make client, server pointers
This will facilitate future refactoring that breaks out code into auxiliary
functions.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 20:23:22 +02:00
Gilles Peskine
07432b9d0c Unify identical code
This is made possible by the endpoint init simplification.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 20:23:22 +02:00
Gilles Peskine
ca8a9ac4af Remove unused parameters to endpoint init/free
The DTLS context and the queues now conveyed inside the endpoint object.
Remove the unused parameters.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 20:23:22 +02:00
Gilles Peskine
6c154e7d51 Move queue management into mbedtls_test_ssl_dtls_join_endpoints
This allows mbedtls_test_ssl_endpoint_init() to no longer interact with the
other endpoint.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-28 20:23:22 +02:00