32837 Commits

Author SHA1 Message Date
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
Alberto Escolar Piedras
c30e6af2cc psa_crypto.c: Fix ifdefs to avoid build warning
Add a couple of missing ifdefs to avoid having unreachable code with
AT_LEAST_ONE_BUILTIN_KDF not defined, which otherwise causes a build
warning with clang.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-04-08 14:58:57 +02:00
Gilles Peskine
278dbecd97 Rename IGNORED_TESTS to UNCOVERED_TESTS
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 11:05:44 +02:00
Gilles Peskine
7b0cc09213 Update framework with UNCOVERED_TESTS in outcome analysis
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-07 11:05:01 +02:00
Viktor Sokolovskiy
c4738fab06 ssl: accept TLS 1.2 rsa_pss_rsae signature schemes
Signed-off-by: Viktor Sokolovskiy <maokaman@gmail.com>
(cherry picked from commit c064ba0edb86e44f3c1c8dcaf05b1139407eebd4)
2026-04-04 20:31:48 +03:00
Manuel Pégourié-Gonnard
559525cd7f ECDH: use more precise error code
The documentation says "or another error code", so it's OK to change the
error code returned here for a more correct one.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-04-02 09:42:05 +02:00
Manuel Pégourié-Gonnard
801f3b3f42 ECDH: improve comment in test function
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-04-02 09:39:00 +02:00
Manuel Pégourié-Gonnard
89aee1e63a Improve Changelog
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-04-02 09:35:42 +02:00
David Horstmann
4eb967981f
Merge pull request #10667 from gilles-peskine-arm/security-md-mention-compiler-3.6
Backport 3.6: Mention compiler optimization in the threat model
2026-04-01 15:44:54 +00:00
Gilles Peskine
168ac78034 Be more specific about what compiler options we consider legitimate
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-01 10:08:29 +02:00
Gilles Peskine
778ea0af9b Mention the new advice about compiler options in the changelog
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-01 10:08:28 +02:00
Gilles Peskine
b937689ba6 Add a section about compiler-introduced timing side channels
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-04-01 10:08:28 +02:00
Minos Galanakis
629898bbba Revert "Added generated files"
This reverts commit 0bebf8b8c7f07abe3571ded48a11aa907a1ffb20.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-03-31 15:37:10 +01:00
Minos Galanakis
2d3fdb6608 Merge tag 'mbedtls-3.6.6' into mbedtls-3.6.6_mergeback
Mbed TLS mbedtls-3.6.6

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-03-31 15:36:51 +01:00
Manuel Pégourié-Gonnard
a2ca5fb23a ECDH: Everest: align error code with ecdh.c
Arguably the value returned by Everest was more precise, but considering
we're in an LTS branch, I'd rather not change the value returned by
ecdh.c, and align the special case on the general case.

The added tests made it apparent that Everest and the generic code were
not returning the same value here. Alignment between the two values is
desirable to keep the test code simple and sweet.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:40:00 +02:00
Manuel Pégourié-Gonnard
fbabe53462 ECDH: Everest: Fix private key managment (static)
Wiping out our private key is OK if we're only doing ephemeral ECDH, but
our API also supports static Diffie-Hellman, where our private key is
long term and should not be wiped out on first use...

Found accidentally with the new test that try calling `calc_secret()`
again with a larger output buffer and expect the same result.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:39:12 +02:00
Manuel Pégourié-Gonnard
f34f6138ca TLS: pass actual size to ecdh_calc_secret()
This is probably a leftover from ancient times where the premaster
buffer was always that size (for FFDH). But these days it can be smaller
depending on the compile-time config. So, use the correct size macro.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:39:10 +02:00
Manuel Pégourié-Gonnard
070ba17a8a ECDH: Add ChangeLog for legacy buffer overflow
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:38:54 +02:00
Manuel Pégourié-Gonnard
1d71bcc31c ECDH: fix possible buffer overflow
We were not comparing the size of the output buffer with the actual
number of bytes we were going to write to it, but with something
possibly smaller.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:01:11 +02:00
Manuel Pégourié-Gonnard
058f57a4dd ECDH: test MSB 0 in shared secret (legacy API)
The values were generated using the script in the message of the
previous commit.

Currently all 4 new tests are failing: without sanitizers, the function
returns 0 instead of an error; with sanitizers, the buffer overwrite is
caught.

This will be fixed in the next commit.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:01:11 +02:00
Manuel Pégourié-Gonnard
216ec7d6fc ECDH: add test cases with MSB 0 in shared secret
The goal is to catch possible bugs where we would compute the output
length based on the bitlength of the shared secret MPI. So, what matters
is the most significant byte, even for Montgomery curves where the
all values are written out little endian.

The values were generated by the following sage script. The script could
be a bit more compact by using E.random_point() instead of the
conventional base point G as the peer's key, but I prefered making the
script deterministic so its output can easily be checked.

p256 = {
    "name": "p256",
    "p": 2^224 * (2^32 - 1) + 2^192 + 2^96 - 1,
    "a": -3,
    "b": 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b,
    "gx": 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296,
    "gy": 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5,
}

p521 = {
    "name": "p521",
    "p": 2^521 - 1,
    "a": -3,
    "b": 0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00,
    "gx": 0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66,
    "gy": 0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650,
}

x255 = {
    "name": "x25519",
    "p": 2^255 - 19,
    "a": 486662,
    "gx": 9,
    "gy": 14781619447589544791020593568409986887264606134616475288964881837755586237401,
}

x448 = {
    "name": "x448",
    "p": 2^448 - 2^224 - 1,
    "a": 156326,
    "gx": 5,
    "gy": 355293926785568175264127502063783334808976399387714271831880898435169088786967410002932673765864550910142774147268105838985595290606362,
}

def byte_len(i):
    return (i.bit_length() + 7) // 8

def leading0(name, p, gx, gy, a, b=None):
    is_montgomery = b is None
    if is_montgomery:
        E = EllipticCurve(GF(p), [0, a, 0, 1, 0])
        increment = 8 # x22519 scalars have the low 3 bits unset
    else:
        E = EllipticCurve(GF(p), [a, b])
        increment = 1

    G = E(gx, gy)
    s = 2^(p.bit_length() - 1) # x25519 scalars have bit 254 set

    Z = G * s
    while byte_len(Z.x().lift()) >= byte_len(p):
        s += increment
        Z += increment * G

    print(name)
    if is_montgomery:
        nbytes = byte_len(p)
        print(f"s: {s.to_bytes(nbytes, "little").hex()}")
        print(f"G: {G.x().lift().to_bytes(nbytes, "little").hex()}")
        print(f"Z: {Z.x().lift().to_bytes(nbytes, "little").hex()}")
    else:
        nibbles = byte_len(p) * 2
        print(f"s: {s:0{nibbles}x}")
        print(f"G: 04{G.x().lift():0{nibbles}x}{G.y().lift():0{nibbles}x}")
        print(f"Z: {Z.x().lift():0{nibbles}x}")

leading0(**p256)
leading0(**p521)
leading0(**x255)
leading0(**x448)

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:01:11 +02:00
Manuel Pégourié-Gonnard
0d318a0f3a ECDH: test calc_secret output buffer too small
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:01:11 +02:00
Manuel Pégourié-Gonnard
df13f5cd52 ECDH: document sufficient size for shared secret
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-03-31 12:00:59 +02:00