Hello Mbed TLS team,

we would like to ask for your advice on a TLS client use case where the private key must stay in an external TPM. We have read the relevant issues and the roadmap, and would like to confirm our understanding and ask for tips.

== 1. Our goal ==

Our device is a TLS client with mutual authentication (device certificate / LDevID). The system is split over several processors (see the attached diagram):
Desired handshake flow (as in the diagram):
1) The server sends its hello and a certificate request.
2) Mbed TLS needs to sign the hash of all previous handshake messages (CertificateVerify).
3) Instead of signing locally, the hash is passed via shared memory to the application processor.
4) The application processor has the TPM sign the hash with the private LDevID key and returns the signature.
5) The signature is handed back to Mbed TLS, which sends the CertificateVerify and continues the handshake.
Mbed TLS currently expects the private key to be available locally. We want to delegate only the signature operation, without patching the TLS handshake code. Blocking while waiting for the TPM is acceptable for us, so asynchronous operation is not a requirement.

== 2. What we found so far ==
== 3. Our approach ==

1) Write a PSA opaque driver with our own key location, with a sign_hash function that sends the hash to the TPM and waits for the signature.
2) Create a PSA key ID that refers to the key in the TPM, so that TLS calls psa_sign_hash() with it and the call reaches our driver.
3) Wrap the key ID with mbedtls_pk_wrap_psa() and pass it with the device certificate to mbedtls_ssl_conf_own_cert().
4) Add our location to the driver dispatch code so that sign_hash calls our function.

== 4. Where we have difficulties ==

We have difficulties creating a suitable key ID that actually works the way we imagine. The key already exists in the TPM, and we only want PSA to hold a reference to it, so that the handshake signature ends up in our driver function. We do not know how to do this correctly.

== 5. Our questions ==

1) Is our approach a good one for TLS client authentication with a TPM-held key in Mbed TLS 4.2? Do you have tips or pitfalls to share?
2) How should we create the key ID for a key that already exists in an external device? Are there examples, tests or documentation you would point us to?
3) What exactly is covered by the roadmap item "PSA driver - Handle Opaque Persistent Key in Secure Element - Implementation", and what has been done so far? Is it part of TF-PSA-Crypto 1.2 / Mbed TLS 4.2, and does it address our key-ID problem?
4) Is anything planned to make this easier, so that we do not have to edit the dispatch layer and build so much ourselves?

Thank you very much for your help.
Best regards,

Beste Grüße / Best regards,

Ruien Karimi

 

Software Developer 

Phone: +49 89 45 656 - 307

E-Mail: ruien.karimi@softing.com

 

 Softing_Logo_signature

Softing Industrial Automation (SIA)

Richard-Reitzner-Allee 6 - 85540 Haar - Deutschland

Fax +49 89 45656-492 - www.softing.com 

 

Sitz: Haar bei München, Amtsgericht München, HRB 127 604

Softing Aktiengesellschaft: Vorsitzender des Aufsichtsrates: Dr. Horst Schiessl; Vorstand: Dr. Wolfgang Trier (Vorsitzender), Ernst Homolk

Geschäftsführer: Johann Gschwendtner, Thomas Rummel, Dr. Wolfgang Trier