1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-27 15:53:57 +08:00

12421 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
42c4bddc07
Merge pull request #10245 from felixc-arm/gcc-15-remove-wnoerror-dev
[Dev] Turn Wunterminated-string-initialization back into an error
2025-06-26 07:08:33 +00:00
Gilles Peskine
f68f45c827
Merge pull request #10213 from valeriosetti/issue298-development
[development] PK: try storing all private RSA keys in PSA (2/3)
2025-06-25 15:23:27 +00:00
Valerio Setti
27eb0141b9 tests: suite_x509parse: rename variable in x509parse_crt()
- rename result_ext to result_back_comp
- add a comment to describe its purpose

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-06-25 10:25:02 +02:00
Valerio Setti
210b61111b tests: suite_x509parse: fix indentation in x509parse_crt()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-06-25 10:25:02 +02:00
Valerio Setti
2747ac1e70 tests: x509parse: fix RSA key in DER certificates
The previous key was not correct so it could not be imported into PSA
for validation inside the PK module.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-06-25 10:25:02 +02:00
Valerio Setti
11345e9de3 tests: x509parse: fix return values for invalid RSA keys
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-06-25 10:25:02 +02:00
Gilles Peskine
760608d47b Properly initialize SSL endpoint objects
In some cases, we were calling `mbedtls_test_ssl_endpoint_free()` on an
uninitialized `mbedtls_test_ssl_endpoint` object if the test case failed
early, e.g. due to `psa_crypto_init()` failing. This was largely harmless,
but could have caused weird test results in case of failure, and was flagged
by Coverity.

Use a more systematic style for initializing the stack object as soon as
it's declared.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-24 18:42:04 +02:00
Gilles Peskine
b836d46870 Fix accidentally skipped test assertion
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-24 18:42:04 +02:00
David Horstmann
8e95ba94c6
Merge pull request #10214 from ariwo17/fix-typo
Fixed some minor typos in comments.
2025-06-23 16:33:45 +00:00
Felix Conway
95c48b3b44 Turn Wunterminated-string-initialization back into an error
Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-06-23 14:54:33 +01:00
Ari Weiler-Ofek
78b0521449 Remove trailing whitespace
Signed-off-by: Ari Weiler-Ofek <ariwei01@e134794.arm.com>
2025-06-20 11:48:50 +01:00
Ari Weiler-Ofek
69f5706431 Add explanatory comment above #include "../tf-psa-crypto/core/common.h"
Signed-off-by: Ari Weiler-Ofek <ariwei01@e134794.arm.com>
2025-06-20 11:48:50 +01:00
Felix Conway
cfbee27b45 Add include so psasim files can find new macro
Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-06-20 11:48:50 +01:00
Felix Conway
5b84ae14e9 Replace __attribute__((nonstring)) with macro MBEDTLS_ATTRIBUTE_UNTERMINATED_STRING
This macro applies __attribute__((nonstring)) when using a compiler that supports it

Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-06-20 11:48:16 +01:00
Felix Conway
79b513894a Add __attribute__ ((nonstring)) to remove unterminated-string-initialization warning
Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-06-20 11:48:16 +01:00
Manuel Pégourié-Gonnard
48552b620d
Merge pull request #10187 from valeriosetti/ecp-restartable-development
[development] Always enable MBEDTLS_PK_USE_PSA_EC_DATA + use PSA interruptible operations as backend for PK restartable ones
2025-06-16 07:24:50 +00:00
Ronald Cron
b1d3e2e4e0
Merge pull request #9634 from gabor-mezei-arm/9144_update_depends.py_hashes_domain
Update the `hashes` domain to use PSA macros in `depends.py`
2025-06-13 07:25:04 +00:00
Valerio Setti
a81d6dfb05 tests|programs: remove usage of mbedtls_ecp_set_max_ops()
PK restartable operations are now implemented using PSA interruptible
ones, so mbedtls_ecp_set_max_ops() can be removed in favor of
psa_interruptible_set_max_ops().

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-06-12 06:39:18 +02:00
Ari Weiler-Ofek
6ee4d9220e Fixed the same typo in ssl-opt.sh
Signed-off-by: Ari Weiler-Ofek <ari.weiler-ofek@arm.com>
2025-06-11 17:40:42 +01:00
Gabor Mezei
3795f8ab74
Remove temporary component created for SHA3 testing
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-10 15:40:53 +02:00
Gabor Mezei
ef013a6970
Use PSA macros for the hashes domain
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-06-10 15:40:41 +02:00
Felix Conway
43c891ae98 Remove requirement on MBEDTLS_PLATFORM_C from configs
Signed-off-by: Felix Conway <felix.conway@arm.com>
2025-06-10 13:45:34 +01:00
Manuel Pégourié-Gonnard
cdd91da1af
Merge pull request #10145 from gabor-mezei-arm/remove_sha3_config_option
Remove `MBEDTLS_SHA3_C` config option
2025-06-10 09:57:22 +00:00
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
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
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
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
Valerio Setti
03a86e783b test: suites: pkcs7/x509parse: add missing PSA_INIT and PSA_DONE
Both PKCS7 and X509 rely on PK module under the hood and the latter can
use PSA to store keys and perform operations. Therefore psa_crypto_init()
must be called before any operation can be done with PKCS7 and X509.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-28 15:47:42 +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