1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-04-19 01:04:04 +03:00

7617 Commits

Author SHA1 Message Date
Minos Galanakis
92e298ed2a Version Bump for 2.28.10
./scripts/bump_version.sh --version 2.28.10

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-18 17:17:34 +00:00
Minos Galanakis
d69bfb904d Merge remote-tracking branch 'upstream/mbedtls-2.28' into pre-2.28.9-upstream-merge 2025-03-14 14:26:47 +00:00
Gilles Peskine
23981ad57f
Merge pull request #10026 from waleed-elmelegy-arm/mbedtls-2.28-fix-key-deriv-bad-state-error
Backport 2.28: Fix psa_key_derivation_input_bytes() not detecting bad state
2025-03-13 09:31:07 +00:00
David Horstmann
6070470dfd
Merge pull request #1321 from davidhorstmann-arm/calc-finished-check-return-2.28
[Backport 2.28] TLS1.2: Check for failures in Finished calculation
2025-03-12 17:35:48 +00:00
David Horstmann
226daac168 Declare conversion function even without 1.2
In 2.28 we may only enable TLS 1.0 or 1.1 in which case this function is
still needed.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2025-03-12 13:58:01 +00:00
David Horstmann
09072663a7 Convert PSA errors to Mbed TLS MD errors
Factor out a static function to perform error conversion and use it for
the calc_verify() functions along with the place where it is currently
used.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2025-03-12 12:03:13 +00:00
David Horstmann
2b85729d23 Add checking to missed case of calc_finished()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2025-03-11 18:13:02 +00:00
Waleed Elmelegy
254cadac70 Replace zero by PSA_ALG_NONE in key derivation internal functions
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-11 12:27:34 +00:00
David Horstmann
68014b2b80 Return and propagate errors in calc_finished()
Allow calc_finished to return an error code and propagate that back to
the original function. If an error is returned by a PSA function,
propagate it upwards instead of continuing, so that we do not fail to
properly check the finished message.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2025-03-10 14:29:11 +00:00
Gilles Peskine
466ebe8ced Zeroize temporary heap buffers used in PSA operations
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 22:43:23 +01:00
Waleed Elmelegy
e014887ea5 Fix code style for key derivation input function
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-03 15:01:38 +00:00
Waleed Elmelegy
c8c89eda5d Fix psa_key_derivation_input_integer() not detecting bad state
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-03 13:04:12 +00:00
Gilles Peskine
6310e98fa5 Expose mbedtls_ssl_get_hostname_pointer()
In 2.28, the `hostname` field of `mbedtls_ssl_context` is part of the public
API. We've slightly changed its meaning in order to fix a security issue.
Document the new function mbedtls_ssl_get_hostname_pointer() which
returns what used to be the value of this field.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-25 18:47:55 +01:00
Gilles Peskine
551756df7c Require calling mbedtls_ssl_set_hostname() for security
In a TLS client, when using certificate authentication, the client should
check that the certificate is valid for the server name that the client
expects. Otherwise, in most scenarios, a malicious server can impersonate
another server.

Normally, the application code should call mbedtls_ssl_set_hostname().
However, it's easy to forget. So raise an error if mandatory certificate
authentication is in effect and mbedtls_ssl_set_hostname() has not been
called. Raise the new error code
MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME, for easy
identification.

But don't raise the error if the backward compatibility option
MBEDTLS_SSL_CLI_ALLOW_WEAK_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME is
enabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-24 18:04:29 +01:00
Gilles Peskine
ae59c52322 Create configuration option to bypass the mbedtls_ssl_set_hostname check
Update generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-24 18:04:14 +01:00
Gilles Peskine
63f958df77 Create error code for mbedtls_ssl_set_hostname not called
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-21 19:33:55 +01:00
Gilles Peskine
f33c45f84d Keep track of whether mbedtls_ssl_set_hostname() has been called
Use a special marker as ssl->hostname if mbedtls_ssl_set_hostname() has been
called with NULL. If mbedtls_ssl_set_hostname() has never been called, the
field is NULL, as before.

No behavior change apart from now emitting a different log message depending
on whether mbedtls_ssl_set_hostname() has been called with NULL or not at all.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-21 19:33:53 +01:00
Gilles Peskine
3a2f75d8d5 Access ssl->hostname through abstractions
New abstractions to access ssl->hostname:
mbedtls_ssl_has_set_hostname_been_called() (only implemented approximatively
for now), mbedtls_ssl_get_hostname_pointer(), mbedtls_ssl_free_hostname().

Only access ssl->hostname directly in these functions and in
mbedtls_ssl_set_hostname().

Use these abstractions to access the hostname with the opportunity for
extra checks in mbedtls_ssl_verify_certificate().

No behavior change except for a new log message.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-21 19:32:59 +01:00
Gilles Peskine
ff25715cb4 Move mbedtls_ssl_set_hostname up
Refactoring to prepare for "Access ssl->hostname through abstractions".

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-20 13:57:51 +01:00
Minos Galanakis
49d440372f tf-psa-crypto/drivers/builtin/src/ecp.c
Update tf-psa-crypto/drivers/builtin/src/ecp.c

Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-01-23 15:29:58 +00:00
Solar Designer
4ad27aa47e Specify previously missed XMM register clobbers in AES-NI asm blocks
Noticed by Gilles Peskine

Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Solar Designer <solar@openwall.com>
2024-12-13 02:14:13 +01:00
Solar Designer
4115440aa7 Specify register clobbers in mbedtls_aesni_crypt_ecb()
Signed-off-by: Solar Designer <solar@openwall.com>
2024-12-13 02:13:03 +01:00
SuperIlu
6d327128b5 Make mbedTLS compile with MS-DOS DJGPP
Signed-off-by: SuperIlu <superilu@yahoo.com>
2024-12-01 10:32:46 +01:00
makejian
aa6ae3f649 net/mbedtls_net_connect: Preventing double close problem
In the test examples and real usage scenarios, 'mbedtls_net_free' is called after 'mbedtls_net_connect' fails, which will cause the problem of double close the same fd. It is possible to close this closed fd which has been applied by other link.

Signed-off-by: makejian <makejian@xiaomi.com>
2024-10-22 20:06:10 +08:00
Manuel Pégourié-Gonnard
9f7cc4c14f Bump version to 2.28.9
Soversions unchanged.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-26 12:44:41 +02:00
Gilles Peskine
69555ea884 Merge remote-tracking branch 'mbedtls-2.28' into mbedtls-2.28-restricted 2024-08-23 11:15:46 +02:00
Gowtham Suresh Kumar
d9e16c4870 Free allocated memory where methods were returning without freeing
Signed-off-by: Sam Berry <sam.berry@arm.com>
Signed-off-by: Gowtham Suresh Kumar <gowtham.sureshkumar@arm.com>
2024-08-19 13:22:35 +01:00
Gilles Peskine
36548eefa4
Merge pull request #9256 from gilles-peskine-arm/psa-keystore-dynamic-backport-2.28
Backport 2.28: prepare for dynamically sized key store
2024-08-09 08:00:01 +00:00
Gilles Peskine
d0ba2b0d1f Fix inverted assertion message
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-08 15:57:48 +02:00
Manuel Pégourié-Gonnard
55aa72fe21 Merge remote-tracking branch 'public/mbedtls-2.28' into merge-2.28
* public/mbedtls-2.28: (88 commits)
  tests/ssl_helpers: Check that message queue is popped
  Upgrade python dependencies in requirements file
  Fix some typo for include folder
  Adjust TLS protocol cases for 2.28
  Fix copypasta
  Declare the new generated files
  Add generated config tests
  Remove some settings that don't exist in 2.28
  Adjust generate_config_tests.py for 2.28
  Terminology: use "dependencies" for a list of settings
  Terminology: consistently use "setting", not "option"
  Explain why we require TLS client and server simultaneously
  Fix missing negation
  Pacify mypy
  Detect sub-options
  Generate config test cases for single options
  Anchor relative paths
  New test suite to report configuration options
  Recognize that a double-inclusion guard is not a config setting
  Add and update some .gitignore files
  ...
2024-08-08 10:03:24 +02:00
Gilles Peskine
18f659b1e7 Assert that the key ID range for volatile keys is large enough
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-07 11:17:32 +02:00
Gilles Peskine
f16263e286 Assert that key ID ranges don't overlap
Ensure that a key ID can't be in range for more than one of volatile keys,
persistent (i.e. user-chosen) keys or built-in keys.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-07 11:17:32 +02:00
Gilles Peskine
37a4fcc5b4 Prevent mbedtls_psa_register_se_key with volatile keys
mbedtls_psa_register_se_key() is not usable with volatile keys, since there
is no way to return the implementation-chosen key identifier which would be
needed to use the key. Document this limitation. Reject an attempt to create
such an unusable key. Fixes #9253.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-07 11:17:32 +02:00
Gilles Peskine
f555a4e26f MBEDTLS_STATIC_ASSERT: make it work outside of a function
At the top level, the macro would have had to be used without a following
semicolon (except with permissive compilers that accept spurious semicolons
outside of a function), which is confusing to humans and indenters. Fix
that.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-07 11:17:32 +02:00
Gilles Peskine
e752eaf73a Force MBEDTLS_PSA_HMAC_DRBG_MD_TYPE based on CTR_DRBG
If MBEDTLS_CTR_DRBG_C is enabled, force MBEDTLS_PSA_HMAC_DRBG_MD_TYPE to be
disabled. This resolves the former inconsistency in builds where
MBEDTLS_PSA_HMAC_DRBG_MD_TYPE is explicitly defined but MBEDTLS_CTR_DRBG_C
remains enabled, where PSA called the CTR_DRBG functions but other parts of
the code based assumed that HMAC was in use, in particular error code
conversions (leading to a test failure in test_suite_psa_crypto_init).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-07-25 18:30:51 +02:00
Gilles Peskine
ff2c049eaf
Merge pull request #9270 from sezrab/silence-2.28
[Backport 2.28] Silence gcc 12.2.0 warning
2024-07-04 14:49:34 +00:00
Gilles Peskine
f514f25f88
Merge pull request #9025 from gilles-peskine-arm/psa-storage-test-cases-never-supported-2.28
Backport 2.28: Fix the detection of not-supported mechanisms in systematically generated PSA tests
2024-06-14 18:23:38 +00:00
Patrick Wildt
ed9a4948b9 Silence gcc 12.2.0 warning
Unfortunately this compiler complains about a variable potentially being
used un-initialized.  Silence the warning by initializing it to a sane
default.

Signed-off-by: Patrick Wildt <pwildt@google.com>
2024-06-14 16:29:47 +01:00
lhuang04
0a2dd6d4eb Set psk to NULL in ssl_psk_remove-backport to 2.28
Summary:
Back port [PR 9241](https://github.com/Mbed-TLS/mbedtls/pull/9241) to
2.28 branch

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
Signed-off-by: lhuang04 <lhuang04@fb.com>
2024-06-11 13:00:28 -07:00
Gilles Peskine
9ebf9aa448
Merge pull request #9153 from gilles-peskine-arm/oid-limits-2.28
2.28 only: Fix the build without check_config.h (inclusion of limits.h)
2024-05-29 16:14:24 +00:00
Gilles Peskine
a8cd2e6421 Fix the build without check_config.h (inclusion of limits.h)
Including `mbedtls/check_config.h` from `mbedtls/config.h` is optional. If
done, `limits.h` gets included. If not done, we were missing the inclusion
of `limits.h` in several source files. Fix this and add a test build that
doesn't include `mbedtls/check_config.h`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-05-17 19:00:46 +02:00
Gilles Peskine
e32671f0d7
Merge pull request #9086 from nileshkale123/fix/redefinition_warning_for_gnu_source_backport_2.28
Backport 2.28: Fixed issue of redefinition warning messages for _GNU_SOURCE
2024-05-06 12:40:41 +00:00
Gilles Peskine
791331158c
Merge pull request #8544 from Ryan-Everett-arm/8537-2.28
Backport 2.28: Fix error handling for secure element keys in `psa_start_key_creation`
2024-05-02 16:06:11 +00:00
nilesh.kale
52b6fefcc4 Fixed issue of redefinition warning messages for _GNU_SOURCE
Signed-off-by: nilesh.kale <nilesh.kale@espressif.com>
2024-05-02 14:47:54 +05:30
Gilles Peskine
b6e362b82e PSA sign/verify: more uniform error on an unsupported hash
Uniformly return PSA_ERROR_NOT_SUPPORTED if given an algorithm that includes
a hash, but that hash algorithm is not supported. This will make it easier
to have a uniform treatment of unsupported hashes in automatically generated
tests.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-11 22:00:55 +02:00
Paul Elliott
6766a19027
Merge pull request #8875 from stevenwdv/mbedtls-2.28
[backport] Fix compilation on macOS without apple-clang
2024-03-29 13:59:14 +00:00
Minos Galanakis
6fe0ae026f Version bump for 2.28.8
./scripts/bump_version.sh --version 2.28.8

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2024-03-21 17:52:54 +00:00
Minos Galanakis
d4b3fe7597 Merge branch 'mbedtls-2.28' into 'mbedtls-2.28-restricted' 2024-03-20 09:27:24 +00:00
Steven WdV
f7acf91e5f Check C/C++ compilers separately for AppleClang ranlib
Signed-off-by: Steven WdV <swdv@cs.ru.nl>
2024-03-19 11:39:22 +01:00
Waleed Elmelegy
98ebf488f5 Fix bug in ALPN loading from serialized session
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-03-15 14:29:24 +00:00