32809 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
0395de165b bignum: update comment about users of bignum_core
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:45:11 +02:00
Manuel Pégourié-Gonnard
8f682e8f8e ecp: clarify contract of internal function
The "shortcut" implementation was using the fact that this function is
called in a single place where we know that the top limb of A is zero.

But the function's documentation was not stating that as a requirement.

Align the documentation and "non-shortcut" implementation on the
"shortcut" implementation. This should be a tiny bit better for
performance: using the fact that A's top limb is zero means we have one
limb less to load from memory. (Copying is load + store, while setting
to 0 is only a store.)

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:45:11 +02:00
Manuel Pégourié-Gonnard
422dcad498 ecp: test mod_pXXX_raw() also without WITH_MPI_UINT
The functions being tested are now used regardless of whether
MBEDTLS_ECP_WITH_MPI_UINT is defined, so they should also be tested
regardless of that option.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:45:11 +02:00
Manuel Pégourié-Gonnard
6b4b14ae71 ecp: fix implementation-defined behaviour
The comment about optimizing compiler's likely behaviour has been
checked with GCC and Clang on x86-64, 32-bit Arm and 64-bit Arm.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:45:11 +02:00
Manuel Pégourié-Gonnard
ec70994ba9 ecp: mbedtls_ecp_mod_p448_raw(): fix big-endian bug
Using memcpy / memmove works only when:
- the size being copied is a multiple of the limb size -> 224 is a
  multiple of 32 but not of 64;
- or the endianness is the same as the order we store limbs, which is
  little-endian (that is, X[0] is the least significant limb).

Said otherwise, it breaks on big-endian 64-bit platforms.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:45:11 +02:00
Manuel Pégourié-Gonnard
83ed698713 ecp: align mbedtls_ecp_mod_p448_raw() with others
The size checks were wrong, and the removed comment was misleading:
this is not about tests, it's just the normal way to wrap a "new bignum"
(aka "raw") function, that expects a fixed number of limbs, to a "legacy
bignum" function, that accepts any size (and allocates).

Also, this aligns ecp_mod_p448() and mbedtls_ecp_mod_p448_raw() with all
other ecp_mod_pXXX() and mbedtls_ecp_mod_pXXX_raw() functions.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:45:11 +02:00
Manuel Pégourié-Gonnard
0f8a09a99c ecp: clarify static constants in grp
This is not really necessary for 1.0+, but for the 3.6 branch where the
structure and these constants are still public, it is cleaner.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:45:11 +02:00
Manuel Pégourié-Gonnard
0ebb3a9ff0 ecp: take advantage of new modp functions
The old functions only guaranteed an output in the range [-a * P, b * P]
for a and b "small enough".

The new functions have a stricter contract, allowing the final reduction
to be done efficiently in constant time.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:45:11 +02:00
Manuel Pégourié-Gonnard
a7840f4b5e ecp: rename ecp_curves_new to ecp_curves
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:43:59 +02:00
Manuel Pégourié-Gonnard
8c806d3cf4 ecp: rm old ecp_curves.c
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:37:40 +02:00
Manuel Pégourié-Gonnard
a3edad8422 ecp: use ecp_curves_new always
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:36:13 +02:00
Manuel Pégourié-Gonnard
4f8212ab7e ecp: rm mbedtls_ecp_get_variant()
Currently there's only one file that has two variants, and we are going
to merge it back, so variant checking no longer really makes sense.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-05-18 10:35:59 +02:00
Manuel Pégourié-Gonnard
aecc26ac7c
Merge pull request #1593 from gilles-peskine-arm/3.6-restricted-merge-20260506
3.6 only: Merge public into restricted
2026-05-07 09:12:06 +02:00
Gilles Peskine
30f9444cd0 Merge remote-tracking branch 'mbedtls-3.6' into mbedtls-3.6-restricted 2026-05-06 22:40:58 +02:00
Gilles Peskine
2f2b202f8e
Merge pull request #10637 from yiwu0b11/destdir_install_env_support-3.6
Backport 3.6: tests: add CMake DESTDIR install coverage in components-build-system
2026-04-29 14:37:21 +00:00
Gilles Peskine
f1f1d414ed
Merge pull request #10202 from LoveKarlsson/iar-alignment-fix
[3.6] Fix alignment problems with IAR and Zephyr
2026-04-29 14:16:47 +00:00
Lars-Ove Karlsson
e7fd09246d Updated the url to the IAR technical note about unaligned access
To be the same link as in the tf-psa-crypto file.

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@qt.io>
2026-04-29 12:16:35 +02:00
Lars-Ove Karlsson
05890c71c8 Added a changelog entry for IAR unalignment fix.
Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2026-04-27 08:38:52 +02:00
Lars-Ove Karlsson
595b0b577b * [3.6] Fix alignment problems with IAR and Zephyr
Since __packed is a reserved keyword for IAR compilers, and
Zephyr defines it to attribute(__packed__), some typedef constructs
in mbedtls does not work with attribute(packed), only with the
keyword packed.

This fix temporary undefs the macro and restores it after the typedefs.

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2026-04-27 08:38:51 +02:00
Valerio Setti
9576d65f0f
Merge pull request #10692 from valeriosetti/backport-pr743
[backport 3.6] platform: fix -Wcast-align warnings in memory_buffer_alloc.c
2026-04-22 14:42:06 +00:00
Yi Wu
800e7f7928 test: remove tfpsacrypto checks in 3.6 DESTDIR install test
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-20 17:06:39 +01:00
Yi Wu
3e8625c396 test: improve symlink checks
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-20 11:07:39 +01:00
Yi Wu
50d85c11c5 test: versioned symlink order fix
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-20 11:07:39 +01:00
Yi Wu
e7e329e70b test: reorder if-else structure
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-20 11:07:39 +01:00
Yi Wu
033e44b4c4 test: add debug output and fix for win config
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-20 11:07:39 +01:00
Yi Wu
a51dc8201c tests: fix DESTDIR install checks and add macOS compatibility
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-20 11:07:39 +01:00
Yi Wu
909ba26843 Test: add symlinks and dangling link check
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-20 11:07:39 +01:00
Yi Wu
c283582015 tests: add cmake DESTDIR install test
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-04-20 11:07:16 +01:00
Ronald Cron
8e19a8e78e
Merge pull request #10702 from minosgalanakis/docs/3.6.6_changelog_fixes
ChangeLog 3.6: Fixed  references to TF-PSA-Crypto
2026-04-20 09:45:58 +00:00
Ronald Cron
7da1c560e3
Merge pull request #10674 from Maokaman1/fix/tls12-rsa-pss-sigalgs-3.6
Backport 3.6: ssl: accept TLS 1.2 rsa_pss_rsae signature algorithms
2026-04-20 08:03:56 +00:00
Viktor Sokolovskiy
2b2ac6e782 Pacify uncrustify
Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
2026-04-18 01:57:20 +03:00
Viktor Sokolovskiy
3833db7c7c ssl: narrow TLS 1.2 RSA-PSS handling and add interop coverage
Narrow TLS 1.2 RSA-PSS handling to the client ServerKeyExchange parse path and add OpenSSL and GnuTLS interoperability tests.

Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
2026-04-17 19:09:29 +03:00
Minos Galanakis
b4f4be1a60 Changelog: Fixed references to TF-PSA-Crypto
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-04-17 15:48:03 +01:00
Gilles Peskine
935e271d13
Merge pull request #1540 from mpg/restricted-fix-ecdh-calc-secret
[3.6] Fix ecdh calc secret buffer overflow
2026-04-15 11:46:31 +02:00
Gilles Peskine
1958093556
Merge pull request #10686 from gilles-peskine-arm/maintainer-scripts-create-directory-3.6
Backport 3.6: Create a directory for maintainer-only Python scripts
2026-04-15 08:19:27 +00:00
Gilles Peskine
3ff1783005
Merge pull request #10680 from gilles-peskine-arm/pake-init-gcc15-3.6
Backport 3.6: PAKE getters test failure with GCC 15
2026-04-15 08:18:28 +00:00
Mohamed Moawad
827b12d459 platform: fix -Wcast-align warnings in memory_buffer_alloc.c
Cast from 'unsigned char *' to 'memory_header *' through an
intermediate 'void *' to suppress -Wcast-align warnings.

Some Clang-based toolchains (e.g. MetaWare/ARC) enable -Wcast-align
as part of -Wall, unlike standard Clang on x86/ARM. Combined with
-Werror this turns the casts into fatal build errors.

The casts are already alignment-safe at runtime:
- In mbedtls_memory_buffer_alloc_init(), buf is explicitly aligned
  to MBEDTLS_MEMORY_ALIGN_MULTIPLE before the cast.
- In buffer_alloc_calloc(), p is computed from an aligned base plus
  aligned offsets (sizeof(memory_header) and len are both multiples
  of MBEDTLS_MEMORY_ALIGN_MULTIPLE).
- In buffer_alloc_free(), p is derived from a previously aligned
  allocation pointer minus the aligned header size.

Signed-off-by: Mohamed Moawad <moawad@synopsys.com>
2026-04-14 16:35:22 +02:00
Valerio Setti
6d403ad146
Merge pull request #10690 from valeriosetti/backport-pr1006
[Backport 3.6] Rename BEFORE_COLON/BC to avoid conflicts
2026-04-14 13:47:58 +00:00
Stefan Gloor
f20aecf116 fix: rename BEFORE_COLON and BC to avoid conflicts
Namespace BEFORE_COLON and BC defines by prepending MBEDTLS_
and expanding BC to BEFORE_COLON_STR. This is to avoid naming
conflicts with third-party code. No functional change.

Signed-off-by: Stefan Gloor <stefan.gloor@siemens.com>
2026-04-13 14:27:49 +02:00
Stefan Gloor
6d2afad395 fix: remove superfluous BEFORE_COLON in x509_crl.c
BEFORE_COLON and BC defines with the accompanying comment are only
required in x509_crt and x509_csr, but not used in x509_crl.c.

Signed-off-by: Stefan Gloor <stefan.gloor@siemens.com>
2026-04-13 14:27:49 +02:00
Manuel Pégourié-Gonnard
00d767aef5 Copy-editing
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-04-13 11:55:07 +02:00
Manuel Pégourié-Gonnard
d5cf74c7da ECDH: update comment to reference new test fucntion
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-04-13 11:38:07 +02:00
Manuel Pégourié-Gonnard
7e45882dc2 ECDH: add tests for static ECDH with context reuse
A bug there was fixed in a previous commit, but without complete tests
or a ChangeLog entry. This commit completes the fix.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-04-13 11:23:17 +02:00
Gilles Peskine
4a62fdc25a
Merge pull request #10677 from gilles-peskine-arm/analyze_outcomes-uncovered-3.6
Outcome analysis: rename IGNORED_TESTS to UNCOVERED_TESTS
2026-04-10 14:51:40 +00:00
Gilles Peskine
4877c0838d Fix an infinite loop if cleanup fails in some tests
Don't call a macro that does `goto exit` on failure after the `exit:` label:
that would cause an infinite loop if something does go wrong.

Generally, cleanup functions don't error out, so it is unlikely to be a
problem in practice. If an error does happen during cleanup, it's probably
due to memory corruption caused by a bug that happened earlier, and that is
likely to have been detected in an earlier function. So we don't really need
to assert the return code of functions called during cleanup, and normally
we don't. Only a few places did so, wrongly.

I found the problematic places with
```
ag 'exit:[^}]*(PSA_ASSERT|TEST_ASSERT|TEST_EQUAL)' tests/suites/*.function
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-10 11:48:46 +02:00
Gilles Peskine
dd921414d3 Don't assert anything about uninitialized parts of structures
In a PAKE operation that has been initialized with `PSA_PAKE_OPERATION_INIT`
or `psa_pake_operation_init()`, the content of the driver-specific part is
indeterminate. It is actually all-bits-zero on most platforms, but not all,
e.g. not with GCC 15 or CompCert. So don't assert anything about it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-10 11:39:09 +02:00
Gilles Peskine
9e7fe65b2c Create a directory for maintainer-only Python scripts
This directory is currently excluded from `check-python-files.sh`, because
we run it on the CI in an old Python version that doesn't support some of
our new maintainer scripts.

There are no such scripts in mbedtls for now (only in TF-PSA-Crypto), but be
ready if we want to add some.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-09 19:38:21 +02:00
Valerio Setti
f7350dc4ff
Merge pull request #10679 from valeriosetti/backport-pr723
[3.6] psa_crypto.c: Fix ifdefs to avoid build warning
2026-04-09 14:05:10 +00:00
Gilles Peskine
87eba69926
Merge pull request #10658 from gilles-peskine-arm/audit_validity_dates-move-to-framework-3.6-actually-remove-scripts
3.6 only: Move some scripts from mbedtls into the framework redux
2026-04-09 07:58:45 +00:00
Gilles Peskine
c3fe74f302 Use short initializers in PAKE tests
When initializing a PAKE operation structure, use an
auxiliary function that doesn't initialize union members to all-bits-zero.
Context: on most compilers, initializing a union to `{0}` initializes it to
all bits zero; but on some compilers, the trailing part of members other
than the first is left uninitialized. This way, we can run the tests on any
platform and validate that the code would work correctly on platforms where
union initialization is short, such as GCC 15.

This commit extends 93dd99571b46f012a462c7a2494ccfe9ec0603a1 to
`test_suite_psa_crypto_pake.function`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-09 09:42:42 +02:00