2024-11-20 12:25:58 +00:00
|
|
|
This document describes how PSA Crypto is used in the X.509 and TLS libraries
|
|
|
|
from a user's perspective.
|
2021-09-20 13:21:25 +02:00
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
In particular:
|
|
|
|
- X.509 and TLS libraries use PSA for cryptographic operations as much as
|
|
|
|
possible, see "Internal changes" below;
|
|
|
|
- APIs for using keys handled by PSA Crypto, such as
|
2023-03-24 09:21:46 +01:00
|
|
|
`mbedtls_pk_setup_opaque()` and `mbedtls_ssl_conf_psk_opaque()`, see
|
2024-11-20 12:25:58 +00:00
|
|
|
"PSA key APIs" below.
|
2022-05-11 13:31:47 +02:00
|
|
|
|
2022-06-10 11:09:03 +02:00
|
|
|
General considerations
|
|
|
|
----------------------
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
**Application code:** you need to call `psa_crypto_init()` before calling any
|
|
|
|
function from the SSL/TLS, X.509 or PK modules, except for the various
|
|
|
|
mbedtls_xxx_init() functions which can be called at any time.
|
|
|
|
|
|
|
|
PSA Key APIs
|
2021-09-21 11:21:23 +02:00
|
|
|
-------------------------
|
|
|
|
|
|
|
|
### PSA-held (opaque) keys in the PK layer
|
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
**API function:** `mbedtls_pk_setup_opaque()` - can be used to wrap a PSA key
|
|
|
|
pair into a PK context. The key can be used for private-key operations and its
|
|
|
|
public part can be exported.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2022-06-10 11:09:03 +02:00
|
|
|
**Benefits:** isolation of long-term secrets, use of PSA Crypto drivers.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2024-03-21 16:49:02 +01:00
|
|
|
**Limitations:** please refer to the documentation of `mbedtls_pk_setup_opaque()`
|
|
|
|
for a full list of supported operations and limitations.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2022-06-10 11:09:03 +02:00
|
|
|
**Use in X.509 and TLS:** opt-in. The application needs to construct the PK context
|
2021-09-21 11:21:23 +02:00
|
|
|
using the new API in order to get the benefits; it can then pass the
|
|
|
|
resulting context to the following existing APIs:
|
|
|
|
|
|
|
|
- `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the
|
2022-06-10 11:09:03 +02:00
|
|
|
key together with a certificate for certificate-based key exchanges;
|
2021-09-21 11:21:23 +02:00
|
|
|
- `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature
|
2022-06-10 11:09:03 +02:00
|
|
|
request);
|
2022-04-20 15:58:00 +02:00
|
|
|
- `mbedtls_x509write_crt_set_issuer_key()` to generate a certificate.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2021-09-24 10:17:07 +02:00
|
|
|
### PSA-held (opaque) keys for TLS pre-shared keys (PSK)
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
**API functions:** `mbedtls_ssl_conf_psk_opaque()` and
|
2021-09-24 10:14:32 +02:00
|
|
|
`mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to
|
2021-09-21 11:21:23 +02:00
|
|
|
register a PSA key for use with a PSK key exchange.
|
|
|
|
|
2022-06-10 11:09:03 +02:00
|
|
|
**Benefits:** isolation of long-term secrets.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2022-06-10 11:09:03 +02:00
|
|
|
**Limitations:** none.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2022-06-10 11:09:03 +02:00
|
|
|
**Use in TLS:** opt-in. The application needs to register the key using one of
|
2024-11-20 12:25:58 +00:00
|
|
|
the above APIs to get the benefits.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2023-03-24 09:26:40 +01:00
|
|
|
### PSA-held (opaque) keys for TLS 1.2 EC J-PAKE key exchange
|
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
**API function:** `mbedtls_ssl_set_hs_ecjpake_password_opaque()`. Call this
|
|
|
|
function from an application to register a PSA key for use with the TLS 1.2 EC
|
|
|
|
J-PAKE key exchange.
|
2023-03-24 09:26:40 +01:00
|
|
|
|
|
|
|
**Benefits:** isolation of long-term secrets.
|
|
|
|
|
|
|
|
**Limitations:** none.
|
|
|
|
|
|
|
|
**Use in TLS:** opt-in. The application needs to register the key using one of
|
2024-11-20 12:25:58 +00:00
|
|
|
the above APIs to get the benefits.
|
2023-03-24 09:26:40 +01:00
|
|
|
|
2021-09-21 11:21:23 +02:00
|
|
|
### PSA-based operations in the Cipher layer
|
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
There is an API function `mbedtls_cipher_setup_psa()` to set up a context
|
2021-09-24 10:14:32 +02:00
|
|
|
that will call PSA to store the key and perform the operations.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2022-04-20 15:58:00 +02:00
|
|
|
This function only worked for a small number of ciphers. It is now deprecated
|
|
|
|
and it is recommended to use `psa_cipher_xxx()` or `psa_aead_xxx()` functions
|
|
|
|
directly instead.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2022-06-10 11:09:03 +02:00
|
|
|
**Warning:** This function will be removed in a future version of Mbed TLS. If
|
|
|
|
you are using it and would like us to keep it, please let us know about your
|
|
|
|
use case.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
Internal uses
|
2021-09-21 11:21:23 +02:00
|
|
|
----------------
|
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
All of these internal uses are relying on PSA Crypto.
|
2021-09-21 11:21:23 +02:00
|
|
|
|
2022-04-20 15:58:00 +02:00
|
|
|
### TLS: most crypto operations based on PSA
|
2021-09-20 13:21:25 +02:00
|
|
|
|
2022-04-20 15:58:00 +02:00
|
|
|
Current exceptions:
|
2021-09-20 13:21:25 +02:00
|
|
|
|
2022-12-06 12:00:33 +01:00
|
|
|
- Finite-field (non-EC) Diffie-Hellman (used in key exchanges: DHE-RSA,
|
|
|
|
DHE-PSK).
|
|
|
|
- Restartable operations when `MBEDTLS_ECP_RESTARTABLE` is also enabled (see
|
|
|
|
the documentation of that option).
|
2021-09-21 13:55:00 +02:00
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
Other than the above exceptions, all crypto operations are based on PSA.
|
2021-09-21 13:55:00 +02:00
|
|
|
|
2022-04-20 15:58:00 +02:00
|
|
|
### X.509: most crypto operations based on PSA
|
2021-09-24 10:06:04 +02:00
|
|
|
|
2022-12-06 12:00:33 +01:00
|
|
|
Current exceptions:
|
2021-09-24 10:06:04 +02:00
|
|
|
|
2022-12-06 12:00:33 +01:00
|
|
|
- Restartable operations when `MBEDTLS_ECP_RESTARTABLE` is also enabled (see
|
|
|
|
the documentation of that option).
|
2021-09-24 10:06:04 +02:00
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
Other than the above exception, all crypto operations are based on PSA.
|
2021-09-24 10:06:04 +02:00
|
|
|
|
2022-04-20 15:58:00 +02:00
|
|
|
### PK layer: most crypto operations based on PSA
|
2021-09-21 13:55:00 +02:00
|
|
|
|
2022-12-06 12:00:33 +01:00
|
|
|
Current exceptions:
|
2021-09-21 13:55:00 +02:00
|
|
|
|
2022-12-21 09:59:33 +01:00
|
|
|
- Verification of RSA-PSS signatures with an MGF hash that's different from
|
|
|
|
the message hash.
|
2022-12-06 12:00:33 +01:00
|
|
|
- Restartable operations when `MBEDTLS_ECP_RESTARTABLE` is also enabled (see
|
|
|
|
the documentation of that option).
|
2021-09-21 13:55:00 +02:00
|
|
|
|
2024-11-20 12:25:58 +00:00
|
|
|
Other than the above exceptions, all crypto operations are based on PSA.
|
2021-09-21 13:55:00 +02:00
|
|
|
|