33174 Commits

Author SHA1 Message Date
Gilles Peskine
e7bbfb86ff
Merge pull request #11011 from v1rtu3x/fix-x509-basic-constraints-integer-first-3.6
Fix x509 basic constraints integer first 3.6
2026-10-21 15:07:35 +00:00
v1rtu3x
07192886c1 tests: Clarify pathLenConstraint values in test descriptions
Signed-off-by: v1rtu3x <149050962+v1rtu3x@users.noreply.github.com>
(cherry picked from commit 1b3bbfd4a24b3d3c17cf5ac94c4576bba81f6ce5)
2026-10-21 13:44:32 +03:00
v1rtu3x
5af05a964a x509: Accept basicConstraints with omitted cA
RFC 5280 defines cA as BOOLEAN DEFAULT FALSE, so a basicConstraints
extension containing only pathLenConstraint (SEQUENCE { INTEGER n })
is syntactically valid and must be interpreted as cA=FALSE. The fix
for CVE-2026-49300 rejected this encoding outright, breaking
compatibility with certificates emitted by devices such as
Eaton/CODESYS PLCs.

Tolerate MBEDTLS_ERR_ASN1_UNEXPECTED_TAG from the cA BOOLEAN parse,
keeping cA FALSE and letting the existing INTEGER parser validate
pathLenConstraint. The INTEGER value is never used to determine cA,
so the CVE fix is preserved.

Fixes #11006

Signed-off-by: v1rtu3x <149050962+v1rtu3x@users.noreply.github.com>
(cherry picked from commit 62dd8a556c01cc289d4fb3f19352a78ede90dac2)
2026-10-21 13:09:57 +03:00
Manuel Pégourié-Gonnard
8a04fc0861
Merge pull request #10998 from jan-bruckner/mbedtls-3.6
Backport 3.6: Add linkage guard to constant_time.h
2026-10-16 07:20:38 +00:00
Jan Bruckner
622b850ac5 Add linebreak to changelog entry
Signed-off-by: Jan Bruckner <jan@janbruckner.de>
2026-10-15 15:10:28 +02:00
Manuel Pégourié-Gonnard
e6e126523b
Merge pull request #11000 from mpg/rsa-revert-keygen-hardening-3.6
[3.6] Fix RSA Key Generation performance regression
2026-10-14 11:01:24 +00:00
Manuel Pégourié-Gonnard
b11a53c506
Merge pull request #10996 from subotac/fix/numeric-oid-overflow-3.6
Backport 3.6: Reject overflowing numeric OID components
2026-10-13 09:24:35 +00:00
Manuel Pégourié-Gonnard
e42ac5aafe Add ChangeLog entry for reversal
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-10-09 09:51:00 +02:00
Manuel Pégourié-Gonnard
4344ca4417 Revert "Fix side-channel in prime checking/generation"
This reverts commit 7a29052238b176b02b82d54d9f929fd4c368c008.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-10-09 09:50:47 +02:00
Manuel Pégourié-Gonnard
311c4dff5a Revert "bignum: make small primes product static"
This reverts commit 1a3cfa5fe7c1e4b1702d6f9ea573fa4fa8d84ce4.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-10-09 09:50:47 +02:00
Manuel Pégourié-Gonnard
9585f8201e Revert "bignum: compact primality check for small values"
This reverts commit 075e76b65ba1e25002f60e46460e397462c3667a.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-10-09 09:50:47 +02:00
Manuel Pégourié-Gonnard
ddb5a7d197 Revert "bignum: fix a typo in a comment"
This reverts commit c6a1f9c83899cefd94612b59da682d4d9856a63a.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-10-09 09:50:47 +02:00
Jan Bruckner
0dcca172bb Add linkage guard to constant_time.h
Signed-off-by: Jan Bruckner <jan@janbruckner.de>
2026-10-08 11:45:04 +02:00
Manuel Pégourié-Gonnard
bd39c1b7c6
Merge pull request #10975 from Johnsonajibi/fix-sha256-4gib-overflow
sha256: fold high bits of ilen into total[1] on 64-bit platforms
2026-10-08 07:03:33 +00:00
subotac
83a9004401 Reject overflowing numeric OID components
Backport of f79eac885dec294d6e441bada15be1605dcb75b0. Adapt the check and tests to the 3.6 OID parser.

Refs Mbed-TLS/mbedtls#10911.

Signed-off-by: subotac <73706465+subotac@users.noreply.github.com>
2026-10-06 23:18:23 +03:00
Manuel Pégourié-Gonnard
27e5c190dc
Merge pull request #10994 from saadgodikat/backport-10973-3.6
[3.6] Fix DER certificate output on Windows
2026-10-06 09:38:27 +00:00
Ronald Cron
8396312553
Merge pull request #10990 from nvxbug/ssl-context-load-alpn-bounds-3.6
Backport 3.6: Reject out-of-bounds ALPN length in ssl_context_load
2026-10-05 11:39:59 +00:00
saadgodikat
955c52b246 Add changelog for DER certificate output fix
Signed-off-by: saadgodikat <saadgodikat601@gmail.com>
2026-10-05 16:19:05 +05:30
saadgodikat
d8fd242a72 Fix DER certificate output on Windows
Fixes #10152

Signed-off-by: saadgodikat <saadgodikat601@gmail.com>
2026-10-05 16:17:00 +05:30
Naveed
ebcb95c130 Add regression tests for ssl_context_load length checks
Backport the ssl_context_load_rejects_oob_length test function from
development in its final form, with cases for the serialized in_cid,
out_cid and ALPN lengths.

mbedtls_test_ssl_dtls_join_endpoints() and
mbedtls_test_ssl_perform_connection() do not exist on this branch, so
set up the DTLS endpoints and run the handshake with the helpers that
do: mbedtls_test_ssl_endpoint_init() with message queues,
mbedtls_test_mock_socket_connect() and
mbedtls_test_move_handshake_to_state(). Exchange application data
explicitly before saving the context, as
mbedtls_test_ssl_perform_connection() does on development: the server
keeps its handshake structure until then, and
mbedtls_ssl_context_save() refuses to run while it exists.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:53:31 +05:30
Naveed
f0e6883dd9 Reject out-of-bounds ALPN length in ssl_context_load
The serialized ALPN length was passed to memcmp() against each configured protocol without checking it against the remaining serialized data, so a malformed context could read past the end of the buffer. Bound it before the comparison, like the adjacent CID fields.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:49:43 +05:30
Johnson Ajibi
320fd18555 changelog: list every affected API explicitly per review feedback
Previous wording only named the four low-level update() functions
directly touched by the fix. mpg pointed out a normal user calling
mbedtls_md_update(), psa_hash_compare(), or any of the one-shot
wrappers (mbedtls_md5(), mbedtls_sha256(), psa_hash_compute(), etc.)
has no way to tell from that wording whether they are affected, and
that SHA-224 should be listed explicitly even though it shares
mbedtls_sha256_update() under the hood, since that implementation
detail should not be something a ChangeLog reader needs to already
know.

Signed-off-by: Johnson Ajibi <ajibijohnson@gmail.com>
2026-10-02 22:03:47 +01:00
Johnson Ajibi
23a2fa734b md5/sha1/ripemd160: fix the same 4GiB ilen truncation as sha256
Per mpg's review, MD5, SHA-1 and RIPEMD-160 have the exact same bug as
SHA-256: mbedtls_*_update() truncates ilen to its low 32 bits before
adding it to ctx->total[0], and the overflow check right after only
catches the single wraparound of that 32-bit addition -- neither step
folds in bits 32 and up of ilen itself when a single update() call is
passed >= 2^32 bytes on a 64-bit platform.

SHA-512 does not have this bug (confirmed by TimothyPMann and
independently by me): it tracks its 128-bit byte count in two
uint64_t words, so ilen (a 64-bit size_t at most) can never overflow
the low word before the carry-in step even runs.

Applied the identical fix to all three: fold ilen >> 32 into total[1],
guarded on SIZE_MAX so 32-bit platforms are unaffected.

Verified live with the same method as the SHA-256 fix: hashed a real
4GiB + 64 byte file with mbedtls_md5_update()/sha1_update()/
ripemd160_update() in a single call and compared against md5sum(1),
sha1sum(1), and `openssl dgst -rmd160`.

  algorithm    before fix (wrong)                          after fix (matches reference tool)
  MD5          0e8b3fdad1980e2c4e66ef714abc3f0c             8b647773014d9f640da9887274f444cd
  SHA-1        b190a761fceaafdc19b62cbcc729ec22b02e7d0c     703fe5b4441eb203af67ed4fbc20263d44bc5f5c
  RIPEMD-160   68956d1517f2ebcef4761d2c0fddf11331a1e6b6     d14d7e80c32ddc603c677151bfd59fd8cf867c42

Also reworded the ChangeLog entry per feedback to cover all four
functions concisely instead of describing the SHA-256 internals in
detail.

Signed-off-by: Johnson Ajibi <ajibijohnson@gmail.com>
2026-09-30 22:20:09 +01:00
Johnson Ajibi
33a1fa3a2c sha256: fold high bits of ilen into total[1] on 64-bit platforms
mbedtls_sha256_update() tracks the running byte count in a 64-bit
counter split across ctx->total[0]/[1] (32 bits each), used at
finalization to encode the message length into the padding.

ctx->total[0] += (uint32_t) ilen truncates ilen to its low 32 bits
before adding, and the overflow check right after (ctx->total[0] <
(uint32_t) ilen) only detects the single wraparound of that 32-bit
addition. Neither step ever looks at bits 32 and up of ilen itself.
So when a single update() call is passed >= 2^32 bytes on a 64-bit
platform (size_t wider than 32 bits), every byte is correctly hashed
into the message, but the length folded into the final padding block
is wrong by a multiple of 2^32 bytes, producing an incorrect digest
despite no error being returned.

Fold ilen>>32 into total[1] directly, guarded on SIZE_MAX so 32-bit
platforms (where ilen cannot exceed 2^32-1 and the shift would be
UB-adjacent) are unaffected.

Verified live: generated a 4GiB+64 byte random file, hashed it with
mbedtls_sha256_update() in a single call both before and after this
fix, and compared against sha256sum of the same file.
  - before: 803ab176fbafaf3cf345cbe22e2a35715c3ae8f7fbf241a00677d4d733db0214 (wrong)
  - after:  21a1f671cd9797227f341a243fed82c8fe95a769a58a6f3965e958f047e969d6 (matches sha256sum)
Also re-verified normal-sized inputs (empty string, "abc") against
known SHA-256 vectors, and that a two-call split of a 100-byte input
still agrees with a single whole-buffer call.

Fixes #10964.

Signed-off-by: Johnson Ajibi <ajibijohnson@gmail.com>
2026-09-27 09:52:45 +01:00
Gilles Peskine
1ee94c5a11
Merge pull request #10400 from gilles-peskine-arm/compliance-split-3.6
Backport 3.6: Split test_psa_compliance.py
2026-09-17 10:23:54 +00:00
Gilles Peskine
eea0f8c0c1 Clarify that this is the "calling script"
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-09-15 12:04:47 +02:00
Gilles Peskine
32da0ae9c3 Improve docstring following the split
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-09-15 12:04:47 +02:00
Gilles Peskine
22885b6bd9 Import PSA compliance test script entry point from the framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-09-15 12:04:47 +02:00
Gilles Peskine
623eda9700 Update framework with psa_compliance.py module
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-09-15 12:04:45 +02:00
David Horstmann
08e82477d8
Merge pull request #10811 from davidhorstmann-arm/2026-07-update-python-dependencies-3.6
[Backport 3.6] Update Python docs dependencies
2026-09-09 13:46:17 +00:00
David Horstmann
86207cd137 Update Python packages for docs
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-09-09 11:05:12 +01:00
Ronald Cron
7b7ff06d6a
Merge pull request #10947 from gilles-peskine-arm/update-submodule-20261008-3.6
Backport 3.6: Update framework with check-python-files fix
2026-09-09 09:08:01 +02:00
Gilles Peskine
212aedf694 Update framework with check-python-files fix
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-09-08 19:24:49 +02:00
Gilles Peskine
091fd1b188
Merge pull request #10945 from okning/backport/3.6-musl-getrandom
Backport 3.6: Fix getrandom detection with musl libc
2026-09-03 16:41:13 +00:00
Ning Xia
5d7359d884 fix(platform): detect getrandom syscall support
Backport the final approved implementation from Mbed-TLS/TF-PSA-Crypto#843
to mbedtls-3.6.

Enable the existing Linux getrandom syscall path when sys/syscall.h
is available and defines SYS_getrandom. Preserve the existing
glibc/Midipix detection and runtime ENOSYS fallback.

Apply the platform change to library/entropy_poll.c in this branch.

Signed-off-by: Ning Xia <hi@nosec.me>
2026-09-03 19:17:28 +08:00
David Horstmann
3003321c07
Merge pull request #10943 from ronald-cron-arm/cve_id_issue_1618-3.6
3.6: Add CVE-2026-73096 ID in ChangeLog
2026-09-03 11:02:35 +00:00
minosgalanakis
d6664ceac9
Merge pull request #10920 from yiwu0b11/psa-its-uid0-errorcode-fix-3.6
[Backport 3.6] PSA its function uid0 errorcode fix
2026-09-02 14:46:59 +00:00
Ronald Cron
0f82ff2d25 Add CVE ID
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-09-02 09:37:47 +02:00
Gilles Peskine
154a78c78b
Merge pull request #10912 from yiwu0b11/cmake-config-3.6
[Backport 3.6] Cmake custom compile-time config support
2026-09-01 14:43:32 +00:00
Valerio Setti
e6e01cd4d9
Merge pull request #10586 from gilles-peskine-arm/all.sh-silence-support-failures-3.6
Backport 3.6: Silence support failures in all.sh
2026-08-31 14:36:50 +00:00
David Horstmann
8d692f375d
Merge pull request #10850 from AaryanCdry/fix/sha3-docs-olen
Backport 3.6: Fix inconsistent docs for mbedtls_sha3_finish and mbedtls_sha3 olen
2026-08-27 16:13:00 +00:00
Yi Wu
7d443f3534 improve test coverage
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-21 15:14:20 +01:00
Gilles Peskine
70058ce4b6
Merge pull request #10845 from gilles-peskine-arm/issue1585-backport3.6-visualc
[3.6 only] Test mbedtls_ssl_session_reset()
2026-08-20 16:01:14 +00:00
Yi Wu
51a8076902 CMake improvements: relocatable, transformation, and more test
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-20 09:10:41 +01:00
Yi Wu
d039c5fe50 test: use TEST_EQUAL for ITS UID 0 errors
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-12 20:18:29 +01:00
Yi Wu
9a23f70ee0 Reject UID 0 in pas_its
function changed: psa_its_set, _get, _get_info, _remove

Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-12 16:00:36 +01:00
Yi Wu
1e8647ff92 CMake: add support for config options
Signed-off-by: Yi Wu <yi.wu2@arm.com>
2026-08-10 08:58:34 +01:00
Valerio Setti
35bc09db98
Merge pull request #10853 from nvxbug/tls12-session-id-bounds-3.6
Backport 3.6: Reject out-of-bounds session ID length in ssl_tls12_session_load
2026-08-03 14:24:00 +00:00
Naveed
61a2877a8e Force sentinel session ID length in serialized-load test
Signed-off-by: Naveed <naveed@bugqore.com>
2026-08-03 13:45:52 +05:30
Naveed
b6d607d310 Reject out-of-bounds session ID length in ssl_tls12_session_load
Signed-off-by: Naveed <naveed@bugqore.com>
2026-08-03 13:45:52 +05:30