Hi Frank,
Support for HSM keys in Mbed TLS is a work in progress. The way it will
work eventually is by plugging an HSM driver under the PSA crypto API,
which supports both transparent and opaque keys.
The TLS code can already use the PSA crypto API for some things,
including client signature. Enable MBEDTLS_USE_PSA_CRYPTO, call
mbedtls_pk_setup_opaque() to create a PK object for the key, and declare
the key to the TLS code with mbedtls_ssl_conf_own_cert() as usual.
To create the key, you will need to write a PKCS#11 secure element
driver. ("Secure element" = "HSM" for this purpose.) I think it would
make sense to have one in Mbed TLS, but I don't know when we might get
around to writing one.
There are two secure element driver interfaces in Mbed TLS right now:
MBEDTLS_PSA_CRYPTO_SE_C (dynamic secure element interface) and
MBEDTLS_PSA_CRYPTO_DRIVERS (unified driver interface). Both are still
experimental: we can't guarantee API stability at this stage.
MBEDTLS_PSA_CRYPTO_SE_C was the first proposal, and its development is
currently frozen and may be abandonned, so I don't recommend investing
any effort in it at the moment, but if you need something fast (e.g. for
a demo/proof-of-concept), it's your best bet. MBEDTLS_PSA_CRYPTO_DRIVERS
is the way of the future, but it's an active work in progress.
If you're creating the key from your application, just call
psa_generate_key. If the key was provisioned externally, it's
unfortunately not so easy. With MBEDTLS_PSA_CRYPTO_SE_C, you can
register a key that's already present in the secure element with
mbedtls_psa_register_se_key(). The corresponding facility in the
MBEDTLS_PSA_CRYPTO_DRIVERS interface is a "get_builtin_key" entry point,
but this is not implemented yet. (There's a prototype at
https://github.com/ARMmbed/mbedtls/pull/3822 but nobody is working on
it. The specification is in docs/proposed/psa-driver-interface.md.)
There's an example application with a MBEDTLS_PSA_CRYPTO_SE_C driver at
https://github.com/ARMmbed/mbed-os-example-atecc608a . We don't have
example code for MBEDTLS_PSA_CRYPTO_DRIVERS yet, or good documentation,
or an easy-to-use build system — those are still a few months in the future.
If you write a driver in the next few months, I recommend that you stay
in touch with the Mbed TLS development team and follow the development
branch of Mbed TLS closely, since it's a very active area of development
at the moment.
--
Gilles Peskine
Mbed TLS developer
On 06/02/2021 16:59, Frank Bergmann via mbed-tls wrote:
> Hi,
>
> I want to use PKCS#11 with mbed TLS...
>
> - cross platform: Windows, mobile device (e.g. Android), *nix
> - on *client* side
> - to create keys (for certs) and store private keys in an HSM (could also be e.g. softhsm as fallback)
>
> How to "integrate" PKCS#11 with mbed TLS and achieve those requirements?
>
>
> cheers,
> Frank
>
Dear Farhad,
Sure, the thing you need to do is to call mbedtls_ssl_conf_authmode( conf, MBEDTLS_SSL_VERIFY_REQUIRED ) where conf is the ssl_config of the server. For more details, see that function's documentation (in ssl.h). For an example, see the command-line option auth_mode in programs/ssl/ssl_server2.c.
Hope this helps!
Best regards,
Manuel
________________________________
From: mbed-tls <mbed-tls-bounces(a)lists.trustedfirmware.org> on behalf of saghili via mbed-tls <mbed-tls(a)lists.trustedfirmware.org>
Sent: 05 February 2021 17:34
To: mbed-tls(a)lists.trustedfirmware.org <mbed-tls(a)lists.trustedfirmware.org>
Subject: [mbed-tls] DTLS Mutual authentication
Dear,
I would like to have mutual authentication using dtls_client.c and
dtls_server.c examples.
In the current version of the example, the client does not send his own
certificate and the server does not verify the certificate of the
client.
Could you please provide me the changes that I need to make in both
dtls_client.c and dtls_server.c examples?
Best regards,
Farhad
--
mbed-tls mailing list
mbed-tls(a)lists.trustedfirmware.org
https://lists.trustedfirmware.org/mailman/listinfo/mbed-tls
Hi,
I want to use PKCS#11 with mbed TLS...
- cross platform: Windows, mobile device (e.g. Android), *nix
- on *client* side
- to create keys (for certs) and store private keys in an HSM (could also be e.g. softhsm as fallback)
How to "integrate" PKCS#11 with mbed TLS and achieve those requirements?
cheers,
Frank
Dear,
I would like to have mutual authentication using dtls_client.c and
dtls_server.c examples.
In the current version of the example, the client does not send his own
certificate and the server does not verify the certificate of the
client.
Could you please provide me the changes that I need to make in both
dtls_client.c and dtls_server.c examples?
Best regards,
Farhad