I would expect that nowadays if somebody needs TLS in their product, they just tell Claude what they want and Claude will grab the relevant parts of MbedTLS, fix known bugs, replace some extremely slow code with the latest arm32-assembler versions (10x to 100x speedup on EC, IIRC, reportedly) and instead of having 200k+ code in your product you have just what you need.
Of course this means that if your customer demands MbedTLS version xx.xx (the very latest) then you are a bit stuffed. But that is the way with all open source code, whose devs eventually move on and abandon the project. LWIP was de facto abandoned > 10 years ago but remains a great chunk of code. Same with FatFS, FreeRTOS, etc.
Peter (owner of a small industrial electronics company)
Hello,
We're building Infineon drivers on top of TF-PSA-Crypto, including one for the Secure Enclave (SE) of PSOC Edge, an isolated on-chip core with its own key storage. For the driver spec [1] it is an opaque driver with internal key storage, it plays the role of a "secure element". Most of what we need is already in your driver spec or in open issues. We'd like to know what is planned, and where we could help.
General (all drivers)
- Plugging in drivers [2] [3] - The wrapper generator already accepts another JSON directory and output directory, but it can't combine the built-in and vendor driver sets, and it doesn't generate the operation-context unions in crypto_driver_contexts_*.h. So a multipart driver still needs patches; TF-M's cc3xx patches both the context headers and the generated wrappers. #783 [2] proposes extending the generator. Another option would be two small build-time hooks:
- one optional macro per context union (e.g. ..._EXTRA_HASH_CONTEXTS), defined in a vendor header chosen at build time, through which a driver adds its context members;
- a build option to use wrapper outputs (psa_crypto_driver_wrappers.h and psa_crypto_driver_wrappers_no_static.c) generated outside the source tree, also when pre-generated copies are present (release archives, generation turned off).
Which way do you prefer?
Opaque drivers (Secure Enclave)
Keys stored in the SE [4] [5] - Our SE stores keys itself. Deleting them, and cleaning up after a failed creation, needs the power-failure-safe design from #739 [5]. Is #739 planned? For persistent keys our SE accepts a key ID chosen in advance (the PSA key ID and owner), so implementing allocate_key looks feasible.
mac_verify [6] - Our SE checks a MAC without giving the real MAC to the core. mbedtls#8043 is marked help-wanted. Should we send the PR to TF-PSA-Crypto? Should the issue be moved there first?
Key derivation in the SE [7] [8] [9] [10] [11] - Our SE can derive keys internally. Is the design in these issues still valid? Is it planned? If we help, which issue should we start with?
Key agreement with SE keys [12] - Still present on development: psa_raw_key_agreement() and psa_key_derivation_key_agreement() reject SE keys, even though the driver could handle them. Another SE driver developer hit this too. May we re-file it in TF-PSA-Crypto and send a fix?
IV/nonce made by the driver [13] [14] - Our SE must generate the IV/nonce itself (it is still returned to the caller). Are driver entry points for this still planned? Only for SE (opaque) drivers, or for all drivers?
Location numbers [2] - Our SE and TF-M's built-in key loader both use location 0x800001. Who should assign these numbers? Is the vendor registry from the spec [1] still planned? Should the generator report it when two selected drivers use the same number?
Keys provisioned into the SE outside PSA [15] [16] - Some keys are provisioned into our SE out of band, and the SE keeps their metadata. Is mbedtls_psa_register_opaque_key (#9255) the intended way to register them with the core? Is it planned?
Where something isn't planned, we're happy to contribute. Please tell us what would be welcome.
References [1] PSA driver interface specification (proposed) - https://github.com/Mbed-TLS/TF-PSA-Crypto/blob/development/docs/proposed/psa... [2] TF-PSA-Crypto#783 - Enhance the JSON-to-C generator to support linking drivers from TF-PSA-Crypto-Drivers to TF-PSA-Crypto - https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/783 [3] TF-PSA-Crypto#699 - Test the driver dispatch layer - https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/699 [4] TF-PSA-Crypto#738 - psa_destroy_key does not dispatch to opaque driver's destroy_key entry point - https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/738 [5] TF-PSA-Crypto#739 - Stateful secure element drivers are not resilient - https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/739 [6] mbedtls#8043 - Implement mac_verify driver entry point - https://github.com/Mbed-TLS/mbedtls/issues/8043 [7] mbedtls#5480 - Move key derivation driver dispatch to the template code - https://github.com/Mbed-TLS/mbedtls/issues/5480 [8] mbedtls#5484 - Add support for key derivation in opaque drivers - https://github.com/Mbed-TLS/mbedtls/issues/5484 [9] mbedtls#5486 - Support key derivation entirely inside a secure element - https://github.com/Mbed-TLS/mbedtls/issues/5486 [10] mbedtls#5487 - Implement key_derivation_set_capacity driver entry point - https://github.com/Mbed-TLS/mbedtls/issues/5487 [11] mbedtls#5491 - Add support for key agreement inside a secure element - https://github.com/Mbed-TLS/mbedtls/issues/5491 [12] mbedtls#8747 - psa_raw_key_agreement() and psa_key_derivation_key_agreement() don't work with opaque drivers - https://github.com/Mbed-TLS/mbedtls/issues/8747 [13] mbedtls#4571 - Support PSA opaque drivers with generate_iv or generate_nonce entry points - https://github.com/Mbed-TLS/mbedtls/issues/4571 [14] mbedtls#3653 - Should a transparent driver have a cipher_generate_iv entry point? - https://github.com/Mbed-TLS/mbedtls/issues/3653 [15] mbedtls#9255 - Make mbedtls_psa_register_se_key usable with opaque drivers - https://github.com/Mbed-TLS/mbedtls/issues/9255 [16] TF-PSA-Crypto PR #191 - Make mbedtls_psa_register_se_key usable with opaque drivers - https://github.com/Mbed-TLS/TF-PSA-Crypto/pull/191
Best regards, Ivan Kozemchuk