Skip to content

WIP: mbedTLS 4 / PSA Crypto support on 2_x_dev#813

Draft
vikramdattu wants to merge 3 commits into
cisco:2_x_devfrom
vikramdattu:feat/mbedtls4-backport
Draft

WIP: mbedTLS 4 / PSA Crypto support on 2_x_dev#813
vikramdattu wants to merge 3 commits into
cisco:2_x_devfrom
vikramdattu:feat/mbedtls4-backport

Conversation

@vikramdattu
Copy link
Copy Markdown

@vikramdattu vikramdattu commented Jun 1, 2026

WIP backport of mbedTLS 4 PSA Crypto. Gated under #if MBEDTLS_VERSION_MAJOR >= 4; legacy mbedTLS 3 path unchanged.

Local: both mbedTLS 3.6.4 and 4.0.0 → 10/10 ctest pass.

Closes #812. cc @pabuhler

Adds a parallel PSA Crypto code path for the mbedTLS backend, gated
under `#if MBEDTLS_VERSION_MAJOR >= 4`. The legacy mbedTLS 3 path
stays unchanged and remains the default.

Covers crypto/cipher/aes_icm_mbedtls.c, aes_gcm_mbedtls.c,
crypto/hash/hmac_mbedtls.c, the matching struct headers, plus
cmake/FindMbedTLS.cmake (additionally finds libtfpsacrypto) and
meson.build. CI matrix adds an mbedtls4 entry that builds
mbedtls-4.0.0 from source on Ubuntu + macOS.

Local: tested against system mbedTLS 3.6.4 (brew) and mbedTLS 4.0.0
(built from source), 10/10 ctest passing on both.

For cisco#812.
…nter

- GCM encrypt/decrypt now require exact dir match (catches crossed-ctx
  bugs PSA does not, since the key carries both ENCRYPT and DECRYPT
  usage flags)
- GCM enc_fail returns cipher_fail (not bad_param) for genuine PSA
  crypto failures
- AES-ICM: comment that PSA_ALG_CTR uses a full 128-bit counter, same
  as the legacy mbedtls_aes_crypt_ctr path; SRTP packet sizes
  (< 1 MiB) are unaffected
- mbedtls 2.x ships only mbedtls/version.h, not mbedtls/build_info.h;
  wrap the include with __has_include so the gate resolves on 2.x too
- mbedtls4 install needs -DCMAKE_POSITION_INDEPENDENT_CODE=ON so static
  libtfpsacrypto can be linked into libsrtp2.so on Ubuntu
- macOS mbedtls4 install path moved out of $GITHUB_WORKSPACE which the
  later actions/checkout@v2 step wipes; install to /tmp/ instead
@vikramdattu vikramdattu force-pushed the feat/mbedtls4-backport branch from acf4582 to bd11b49 Compare June 1, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant