31191 Commits

Author SHA1 Message Date
nilesh.kale
f635fed592 bignum: update API mbedtls_mpi_exp_mod_unsafe to support hardware implementation 2024-09-24 16:17:38 +05:30
nilesh.kale
b8e884f0bc Remove dependency on submodule 'framework'
ESP_IDF dose not have support for recursive updation of submodules, also
it has no dependency on submodule 'framework' currently.
Therefore, this commit eliminates the dependency on the 'framework' submodule.
2024-09-06 14:53:57 +05:30
harshal.patil
803d5e8c91 gcm: Support software fallback for non-AES ciphers in a gcm operation.
When MBEDTLS_HARDWARE_GCM is enabled, we ALT all the GCM functions that are
declared in mbedtls/gcm.h with our H/W port functions, due to which even
if non-AES ciphers such as ARIA, CAMELLIA, BLOWFISH, etc. are selected
for a GCM operation, we perform an AES-GCM operation, thus resulting into
an incorrect calculation.
Thus in such cases we need to fallback to the software definitions of
GCM.

Currently, it is not directly possible to pull in software definitions of GCM
related functions directly due to gcm_alt.h, but this commit renames the
functions by appending `_soft` to their names, thus making them look different
functions in all and thus they are made available to pull in during compilation.

The change is configrable using the config MBEDTLS_GCM_NON_AES_CIPHER_SOFT_FALLBACK.
As this config is enabled by default, building the mbedtls crypto library
(libmbedcrypto.a) with this change increases its size by ~2.5KB.
2024-09-06 14:53:57 +05:30
Frantisek Hrbata
3f0cdd8b5e initial version of the sbom.yml file
This is an initial version of the sbom.yml file for Espressif's mbedtls.
It's used by the esp-idf-sbom[1] tool to generate an SBOM file in the SPDX
format for esp-idf projects.

[1] - https://github.com/espressif/esp-idf-sbom

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>

fix(sbom): add note about Espressif modifications

Since our mbedtls code is not a pure upstream version, let's add a note
about this in the SBOM manifest description, which will be included in
the generated SPDX file. We used the same approach e.g. for freertos.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2024-09-06 14:53:57 +05:30
Laukik Hase
e9b0c91fd7 cmake: Removed CMake flags for controlling C standard
- `CMAKE_C_EXTENSIONS`: Enable/disable compiler-specific extensions
- `CMAKE_C_STANDARD`: Set C standard (C99, C11)
- These variables (as set in mbedtls) set the C standard to C99
  for ESP-IDF as well, resulting in build errors related to
  `asm volatile`

(cherry picked from commit e39975969d548572a39875ad29abd88b23285f94)
2024-09-06 14:53:57 +05:30
Sachin Parekh
c7aaa33ee3 ecp: Add support for hardware implementation of ECP routines
- ESP32C2 has a hardware ECC accelerator that supports NIST P-192 and NIST P-256 curves,
    which can increase the performance of the point multiplication and point
    verification operation.
  - Provision is also added to fallback to software implementation in
    case the curve is not from the supported curves

- Override ecp_mul_restartable_internal with accelerator
  - Many ECC operations use the internal API ecp_mul_restartable_internal
    instead of the public API mbedtls_ecp_mul for point multiplication.
    This will improve the performance of all those parent operations as
    well

(cherry picked from commit 0ecb27b9d88059e8980c8ae6e111283f5f2859f8)
2024-09-06 14:53:50 +05:30
Mahavir Jain
e97654f3b5 bignum: add provision for combined software and hardware MPI approach
For exponential mod (API mbedtls_mpi_exp_mod) operation, some ESP target
chips needs to have ability for both hardware and software implementation.

Hardware implementation provided performance advantage but it can only
support upto 3072 bit operations (e.g., ESP32-C3) and hence we fallback
to software implementation in such cases (e.g., 4096 bit operations).

Earlier this was handled using linker "--wrap" flag but that does not
work in all scenarios as API `mbedtls_mpi_exp_mod` is being used in
same tranlation (compilation unit).

This approach was found to be next best option with minimal changes in
mbedTLS library.

(cherry picked from commit ab3a845107377c6cdf148f86015cad94434a1f2e)
2024-09-06 14:49:33 +05:30
Angus Gratton
1c2c205089 mbedtls: Re-apply MBEDTLS_BIGNUM_ALT & related macros for custom bignum functions
(IDF-specific patch.)

(cherry picked from commit f859b9bc7579246703446c158270ae038442351c)
2024-09-06 14:27:34 +05:30
David Horstmann
71c569d44b
Merge pull request #1286 from Mbed-TLS/mbedtls-3.6.1rc0-pr
Mbedtls 3.6.1rc0 PR
mbedtls-3.6.1
2024-08-30 10:11:54 +01:00
David Horstmann
4c8ca72a88 Move some ChangeLog entries to a different section
2 ChangeLog entries that were originally placed under "Changes" are
more appropriately placed under "Default behaviour changes".

Move these 2 entries to the correct section.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:58:24 +01:00
David Horstmann
fedf9a2096 Add CVE IDs to security ChangeLog
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:56:16 +01:00
David Horstmann
18f3bebb6f Update BRANCHES.md
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:56:16 +01:00
David Horstmann
0d1117692e Add generated files
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:56:16 +01:00
David Horstmann
ea44fa7f35 Finalise ChangeLog
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:56:16 +01:00
David Horstmann
1d2dcfce6f Bump version to 3.6.1
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:56:16 +01:00
David Horstmann
9cf929d421 Assemble ChangeLog
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:56:16 +01:00
David Horstmann
636367f757 Don't clean test_keys.h and test_certs.h
This is in keeping with other generated files (such as generated .data
files) that are added to releases.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:56:16 +01:00
David Horstmann
204c4b41f5 Fix typos in make clean target for Windows
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:56:16 +01:00
David Horstmann
9f10979853 Merge branch 'mbedtls-3.6-restricted' into mbedtls-3.6.1rc0-pr
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-08-28 20:48:27 +01:00
Gilles Peskine
72064b202e
Merge pull request #9507 from ronald-cron-arm/disable-new-session-tickets
3.6: Disable new session tickets at runtime
2024-08-28 18:20:56 +00:00
Ronald Cron
c46edd4423 Fix/Improve documentation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 18:15:36 +02:00
Ronald Cron
9f44c883f4 Rename some "new_session_tickets" symbols
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 17:47:46 +02:00
Ronald Cron
c9884b04ad Fix change log
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 16:36:07 +02:00
Ronald Cron
48a9f562ba Improve documentation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 13:36:43 +02:00
Ronald Cron
ba45a44f13 Move session tickets getter functions to ssl_misc.h
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 13:22:26 +02:00
Ronald Cron
31b40b3600 Add change logs
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 10:42:01 +02:00
Ronald Cron
97dc5832c5 Improve debug logs
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 10:42:01 +02:00
Ronald Cron
fc76718dcd Move MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET doc
Move MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET
error code documentation to the documentation of
mbedtls_ssl_read() as we cannot have long error
descriptions because of a limitation in
generate_errors.pl.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 10:42:01 +02:00
Ronald Cron
d67f801c63 Do not add a new field in the SSL config
We cannot add a new field in SSL config in
an LTS. Use `session_tickets` field instead.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 10:41:54 +02:00
Ronald Cron
57ad182644 ssl_client2: Fix new_session_tickets option parsing
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 10:30:24 +02:00
Ronald Cron
e55659d576 Document NewSessionTicket handling being disabled by default
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-28 10:30:17 +02:00
Ronald Cron
9df056390a Improve MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET documentation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-27 18:04:44 +02:00
Ronald Cron
0e5d4fdfc5 Document MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET.
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-27 16:20:47 +02:00
Ronald Cron
23303a47f4 Enable TLS 1.3 ticket handling in resumption tests
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-27 16:20:40 +02:00
Ronald Cron
b675b2ba5d TLS 1.3: Ignore tickets if disabled at runtime
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-27 15:41:24 +02:00
Ronald Cron
bedddd707a Add mbedtls_ssl_conf_enable_new_session_tickets() API
Add mbedtls_ssl_conf_enable_new_session_tickets() API
to be able to enable and disable the handling of TLS 1.3
NewSessionTicket messages.

The TLS 1.2 equivalent function is named
mbedtls_ssl_conf_session_tickets() thus the most
natural name would have been
mbedtls_ssl_conf_new_session_tickets() but it is
already used on server side thus rather
mbedtls_ssl_conf_enable_new_session_tickets().

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-08-27 15:41:18 +02:00
Gilles Peskine
7defa41fb3
Merge pull request #9501 from gilles-peskine-arm/tls13-psa-init-auto-3.6
[3.6] TLS 1.3: call psa_crypto_init
2024-08-26 15:26:35 +00:00
Manuel Pégourié-Gonnard
8b8228ce2e
Merge pull request #1282 from gilles-peskine-arm/merge-3.6-restricted-20240823
Merge 3.6 into -restricted
2024-08-26 12:07:24 +02:00
Gilles Peskine
57dbd69945 TLS 1.3 server: move crypto_init after protocol negotiation
This reduces the workflows where psa_crypto_init is called when not
necessary: it won't be called when a dual-version server receives a 1.2-only
ClientHello.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-26 12:04:39 +02:00
Gilles Peskine
aa6ef7da50 Changelog entry for psa_crypto_init potentially being called from TLS
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-26 12:01:31 +02:00
Gilles Peskine
92e803ea5b Clarify "negotiating"
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-26 11:59:48 +02:00
Gilles Peskine
50476272a9 Error translation and init are needed in PSK-only builds as well
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-26 09:28:41 +02:00
Gilles Peskine
069bccdf78 Call psa_crypto_init in the library when required for TLS 1.3
For backward compatibility with Mbed TLS <=3.5.x, applications must be able
to make a TLS connection with a peer that supports both TLS 1.2 and TLS 1.3,
regardless of whether they call psa_crypto_init(). Since Mbed TLS 3.6.0,
we enable TLS 1.3 in the default configuration, so we must take care of
calling psa_crypto_init() if needed. This is a change from TLS 1.3 in
previous versions, where enabling MBEDTLS_SSL_PROTO_TLS1_3 was a user
choice and could have additional requirement.

This commit makes the library call psa_crypto_init() when it needs PSA
crypto in a situation where the application might not have called it,
namely, when starting a TLS 1.3 connection.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-25 10:44:39 +02:00
Gilles Peskine
cd4da16eea Don't call psa_crypto_init in test programs when not required for TLS 1.3
For backward compatibility with Mbed TLS <=3.5.x, applications must be able
to make a TLS connection with a peer that supports both TLS 1.2 and TLS 1.3,
regardless of whether they call psa_crypto_init(). Since Mbed TLS 3.6.0,
we enable TLS 1.3 in the default configuration, so we must take care of
calling psa_crypto_init() if needed. This is a change from TLS 1.3 in
previous versions, where enabling MBEDTLS_SSL_PROTO_TLS1_3 was a user
choice and could have additional requirement.

This commit changes our test programs to validate that the library
does not have the compatibility-breaking requirement.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-25 10:44:39 +02:00
Gilles Peskine
5950301740 Don't call psa_crypto_init in unit tests when not required for TLS 1.3
For backward compatibility with Mbed TLS <=3.5.x, applications must be able
to make a TLS connection with a peer that supports both TLS 1.2 and TLS 1.3,
regardless of whether they call psa_crypto_init(). Since Mbed TLS 3.6.0,
we enable TLS 1.3 in the default configuration, so we must take care of
calling psa_crypto_init() if needed. This is a change from TLS 1.3 in
previous versions, where enabling MBEDTLS_SSL_PROTO_TLS1_3 was a user
choice and could have additional requirement.

This commit changes our unit tests to validate that the library
does not have the compatibility-breaking requirement.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-25 10:44:39 +02:00
Gilles Peskine
590bdcbddf Call psa_crypto_init in the library when required for TLS 1.3: doc
For backward compatibility with Mbed TLS <=3.5.x, applications must be able
to make a TLS connection with a peer that supports both TLS 1.2 and TLS 1.3,
regardless of whether they call psa_crypto_init(). Since Mbed TLS 3.6.0,
we enable TLS 1.3 in the default configuration, so we must take care of
calling psa_crypto_init() if needed. This is a change from TLS 1.3 in
previous versions, where enabling MBEDTLS_SSL_PROTO_TLS1_3 was a user
choice and could have additional requirement.

This commit removes the compatibility-breaking requirement from the
documentation.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-25 10:44:39 +02:00
Gilles Peskine
4002e6fdee Merge remote-tracking branch 'mbedtls-3.6' into mbedtls-3.6-restricted 2024-08-23 11:15:11 +02:00
Gilles Peskine
86a4c25136
Merge pull request #9499 from waleed-elmelegy-arm/fix-legacy-compression-issue-3.6
[Backport 3.6] Fix issue in handling legacy_compression_methods in ssl_tls13_parse_client_hello()
2024-08-22 18:23:33 +00:00
Gilles Peskine
df0ef8a624
Merge pull request #9281 from mpg/rsapub
[3.6] Reduce performance regression in RSA public operations
2024-08-22 16:50:38 +00:00
Waleed Elmelegy
8ac9caf89b Fix the capitalisation in the changelog entry
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2024-08-22 16:42:18 +00:00