33255 Commits

Author SHA1 Message Date
David Horstmann
d177e3f5fc
Merge pull request #1356 from Mbed-TLS/bugfix_1351_1352_1353_lms_drivers
Bugfix: lms/lmots driver hardening.
2025-06-13 15:48:29 +01:00
Manuel Pégourié-Gonnard
3a21cdfa5c
Merge pull request #1354 from mpg/fix-asn1-store-named-data-null-deref-dev
Fix asn1 store named data null deref dev
2025-06-13 09:57:24 +02:00
Manuel Pégourié-Gonnard
f5a63d1456 Fix invalid test data by aligning with 3.6
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-06-12 09:42:03 +02:00
Manuel Pégourié-Gonnard
dc82fa67c5 Keep only the X.509 part from the Changelog
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-06-12 09:42:03 +02:00
Manuel Pégourié-Gonnard
5f6310b65f Add ChangeLog entry
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-06-12 09:42:03 +02:00
Manuel Pégourié-Gonnard
d2262f2304 Uncomment tests now that crypto is fixed
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-06-12 09:42:03 +02:00
Manuel Pégourié-Gonnard
d1090d70ff Update crypto submodule
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-06-12 09:42:03 +02:00
Minos Galanakis
67f63821a5 Updated tf-psa-crypto pointer
Signed-off-by: Minos Galanakis <minos.galaanakis@arm.com>
2025-06-11 10:38:44 +01:00
Manuel Pégourié-Gonnard
5989da22a9 Add tests for bug in mbedtls_x509_string_to_names()
The commented out tests cause crashes (in different ways) until the bug
is fixed; the first two test are passing already and are here mostly to
provide a reference point.

The bug report was using programs/x509/cert_write, but string_to_names()
is what it was really targetting, which is better for automated tests.
The strings used are a minor adapation of those from the report.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-28 13:01:28 +02:00
Manuel Pégourié-Gonnard
a4ffc4e4c6 Merge remote-tracking branch 'public/development' into development-restricted
* public/development: (23 commits)
  tests: suite_x509parse: set PSA max operations in x509_verify_restart()
  library: debug: remove mbedtls_debug_printf_ecdh()
  library: debug: make mbedtls_debug_print_psa_ec() static
  Remove call to pk_decrypt() in ssl_server2
  Change hardcoded error values in ssl-opt to take in the PSA error alias
  Test with GCC 15 with sloppy union initialization
  Update crypto with the union initialization fixes
  Mark ssl_tls12_preset_suiteb_sig_algs const
  Mark ssl_tls12_preset_default_sig_algs const
  Use PSA macros for the `pkalgs` domain
  reverted compat-2.x.h removal from psa-transition.md
  Correct ChangeLog file extension
  Add ChangeLog
  remove compat-2.x.h
  Remove trace of secp224k1
  Update submodules
  Improve comments
  Allow gcc-15 to be in $PATH
  Enable drivers when testing with GCC 15
  GCC 15: Silence -Wunterminated-string-initialization
  ...
2025-05-28 12:41:28 +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
Ronald Cron
36f424e240
Merge pull request #10190 from valeriosetti/prerequisites-for-ecp-restartable
[development] Some prerequisites for PR #10187
2025-05-26 15:15:23 +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
Valerio Setti
153a906a51 library: debug: remove mbedtls_debug_printf_ecdh()
The function is not used anywhere and can be removed.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-23 15:08:48 +02:00
Valerio Setti
28ef01a3c1 library: debug: make mbedtls_debug_print_psa_ec() static
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-23 15:03:26 +02:00
Gilles Peskine
127c78e589
Merge pull request #10133 from bjwtaylor/remove-compat-2
remove compat-2.x.h
2025-05-23 09:57:49 +00:00
Manuel Pégourié-Gonnard
235143090b
Merge pull request #1343 from mpg/fix-string-to-names-uaf-dev
[dev] Fix string to names memory management
2025-05-21 14:48:37 +02:00
Manuel Pégourié-Gonnard
768f90f3c3
Merge pull request #10186 from mpg/rm-pk-decrypt
Remove call to pk_decrypt() in ssl_server2
2025-05-21 12:47:55 +00:00
Manuel Pégourié-Gonnard
6b8f517e4d Avoid a useless copy in cert_{req,write}
I'm just trying to have a shorter name to avoid repeating a long
expression. This is a job for a pointer, not copying a struct.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-21 11:53:59 +02:00
Manuel Pégourié-Gonnard
38317281e9 Fix type in ChangeLog
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-21 11:53:59 +02:00
Manuel Pégourié-Gonnard
bb8c0aba74 Add comment on apparent type mismatch
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-21 11:53:59 +02:00
Manuel Pégourié-Gonnard
8de781d99d Remove redundant free loop
This version is incomplete. I failed to noticed it when adding a more
complete version, making the existing one redundant.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-21 11:53:59 +02:00
Manuel Pégourié-Gonnard
92a9bd345c Remove call to pk_decrypt() in ssl_server2
We no longer use decrypt TLS 1.2 (never did in 1.3) so we no longer need
this path. Further simplifications could probably be made (we currently
have an enum type with only one possible value...) but for now I'm
trying to keep changes minimal.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-20 12:04:26 +02:00
Manuel Pégourié-Gonnard
66c6aaacf6
Merge pull request #10177 from gilles-peskine-arm/union-initialization-gcc15-basic-fix-dev
Test with GCC 15 with sloppy union initialization
2025-05-20 09:56:51 +00: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
421318c074 Update crypto with the union initialization fixes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-19 16:51:19 +02:00
Manuel Pégourié-Gonnard
32745c95f9
Merge pull request #8947 from rojer/consts
Mark ssl_tls12_preset_default_sig_algs const
2025-05-19 10:09:30 +00: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
Deomid rojer Ryabkov
7dddc1724f Mark ssl_tls12_preset_suiteb_sig_algs const
Signed-off-by: Deomid rojer Ryabkov <rojer@rojer.me>
2025-05-15 15:27:40 +03:00
Deomid rojer Ryabkov
e2d71ccc64 Mark ssl_tls12_preset_default_sig_algs const
To place in flash and save RAM on targets where this applies.

Signed-off-by: Deomid rojer Ryabkov <rojer@rojer.me>
2025-05-15 15:27:40 +03: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
Manuel Pégourié-Gonnard
bda3ab9278 Add unit test for new behaviour of string_to_names()
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-12 12:34:11 +02:00
Manuel Pégourié-Gonnard
b095862722 Fix memory leak in cert_write & cert_req
That memory leak had been present ever since the san command-line
argument has been added.

Tested that the following invocation is now fully valgrind clean:

programs/x509/cert_write san=DN:C=NL,CN=#0000,CN=foo;DN:CN=#0000,O=foo,OU=bar,C=UK;IP:1.2.3.4;IP:4.3.2.1;URI:http\\://example.org/;URI:foo;DNS:foo.example.org;DNS:bar.example.org

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-12 12:34:11 +02:00
Manuel Pégourié-Gonnard
6b1147993c Fix runtime error in cert_write & cert_req
The runtime error was introduced two commits ago (while avoiding a
use-after-free). Now the programs run cleanly but still leak memory.

The memory leak is long pre-existing and larger than just DN components
(which are made temporarily slightly worse by this commit) and will be
fixed properly in the next commit.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-12 12:34:11 +02:00
Manuel Pégourié-Gonnard
2dc6b583ac Restore behaviour of mbedtls_x509write_set_foo_name()
The documentation doesn't say you can't call these functions more than
once on the same context, and if you do it shouldn't result in a memory
leak. Historically, the call to mbedtls_asn1_free_named_data_list() in
mbedtls_x509_string_to_names() (that was removed in the previous commit)
was ensuring that. Let's restore it where it makes sense. (These are the
only 3 places calling mbedtls_x509_string_to_names() in the library.)

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-12 12:34:11 +02:00
Manuel Pégourié-Gonnard
43a1e733d8 Fix undocumented free() in x509_string_to_names()
Now programs/x509/cert_write san="DN:CN=#0000;DN:CN=#0000" is no longer
crashing with use-after-free, instead it's now failing cleanly:

 failed
  !  mbedtls_x509_string_to_names returned -0x2800 - X509 - Input invalid

That's better of course but still not great, will be fixed by future
commits.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-05-12 12:34:11 +02: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
Ben Taylor
e718e835ee reverted compat-2.x.h removal from psa-transition.md
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-05-08 14:55:44 +01:00
Ben Taylor
d056136a4d Correct ChangeLog file extension
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-05-08 14:55:44 +01:00
Ben Taylor
4c9ad3cfe6 Add ChangeLog
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-05-08 14:55:44 +01:00
Ben Taylor
e23afdd765 remove compat-2.x.h
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-05-08 14:55:44 +01:00
Gilles Peskine
46771ff0d6 Remove trace of secp224k1
The curve secp224k1 was supported in the legacy API in Mbed TLS <=3.6, but
removed after 3.6, and was never implemented in PSA. Remove this old trace
of it.

This is a partial cherry-pick of 32c82f0c369117b22d8a40e51723c364156d1aff

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-07 19:17:35 +02:00
Gilles Peskine
dcff079ea4 Update submodules
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-05-07 17:16:20 +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