Repository navigation
Conversation
Mbed TLS 4.0 moved the cryptography into TF-PSA-Crypto and makes the random generator internal to PSA: the entropy and CTR-DRBG APIs are private, mbedtls_ssl_conf_rng() was removed, and mbedtls_pk_parse_keyfile() no longer takes RNG arguments. psa_crypto_init(), which is mandatory now, was already called at initialization. - With 4.x, don't set up the per-connection entropy and CTR-DRBG contexts, and use the 3-argument mbedtls_pk_parse_keyfile(). - configure: look for the crypto library with psa_crypto_init() instead of the now private mbedtls_ctr_drbg_init(), and also try libtfpsacrypto. Fixes shirok#1181 Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Assisted-by: Claude:claude-opus-5
The server key used by the TLS tests is encrypted with 3DES, which Mbed TLS 4.x no longer supports, so loading it fails and the remaining tests can't connect. Add the same key encrypted with AES-256-CBC, and fall back to the 3DES version, as Mbed TLS 2.x can't decrypt AES-encrypted keys. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Assisted-by: Claude:claude-opus-5
|
https://lists.trustedfirmware.org/archives/list/mbed-tls@lists.trustedfirmware.org/thread/YPIGCB7WN6GCHOGEGKOJXUYAP7OK527W/#BSRM3JY6JFNWWEHKMY4JQQON5QB3LP5U |
|
Wow, thanks for the info @bitbloxhub . It's sad that even such important OSS is struggling to secure resources. I still intend to merge this. Our TLS layer is already written to support multiple subsystems, so we can simultaneously develop alternatives (maybe openSSL?) |
|
OpenSSL and LibreSSL would be primary candidates. If the footprint is important, wolfSSL or s2n may be suitable. Other candidates are NSS (Mozilla), GnuTLS, Schannel (Windows), Secure Transport (macOS), etc. |
Fixes #1181.
Mbed TLS 4.0 moved the cryptography into TF-PSA-Crypto, and the random generator is now internal to
PSA:
mbedtls_ssl_conf_rng()was removed;mbedtls_pk_parse_keyfile()no longer takes RNG arguments.So
ext/tls/tls-mbed.cno longer compiles against 4.x. This PR adds 4.x support and keeps Mbed TLS2.x and 3.x working. The 4.x changes are selected with
MBEDTLS_VERSION_MAJOR.Commits
mbedtls_ssl_conf_rng()is not called.mbedtls_pk_parse_keyfile()is used.psa_crypto_init(), which 4.x requires, was already called at module initialization.configurefinds the crypto library withpsa_crypto_init()instead ofmbedtls_ctr_drbg_init(), which is private in 4.x, and also trieslibtfpsacrypto.ext/tls/data/test-key.pemis encrypted with PBES2 + 3DES. Mbed TLS 4.xremoved DES/3DES, so it can't load the key, the handshakes fail, and the test then waits forever
in the server thread.
data/test-key-aes.pemcontains the same key encrypted with AES-256-CBC. The test tries itfirst and falls back to
test-key.pem, anddata/READMEexplains how to regenerate it.test-key.pem(3DES)test-key-aes.pem(AES-256-CBC)Testing
Built from this branch with
./DIST genand./configure --with-tls=mbedtlson Linux x86_64 (gcc11), against Mbed TLS 2.28.0 (Ubuntu), 3.6.7 and 4.1.1. There are no warnings in
tls-mbed.c, andwith 4.1.1 the module links
libtfpsacrypto.make checkinext/tlspasses with all three versions: bind, loading the private key andcertificate, connect with certificate verification, the 64 KiB transfer, server shutdown, and poll.
Note on CI: Homebrew's
mbedtlsformula is already 4.2.0, with 3.6 now inmbedtls@3. The macOSjobs install
mbedtlsand still pass, so I suspectconfiguredoesn't find Mbed TLS there andbuilds without TLS support. I couldn't check the job logs to confirm. With this PR, the macOS jobs
should build and test the TLS module with 4.x again.
Not changed:
--with-tls=mbedtls-internalstill downloads Mbed TLS 3.6.4. Moving it to 4.x wouldneed changes in
tools/tls, because the include layout has changed (tf-psa-crypto/); that seemedbetter as a separate step.
I didn't add a ChangeLog entry, since you usually write those yourself.