blob: c01265896f0e7f899eb52a63af5158704975fe63 [file] [log] [blame] [view]
Manuel Pégourié-Gonnard73a0e1d2021-09-21 13:55:00 +02001This document describes the compile-time configuration option
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +02002`MBEDTLS_USE_PSA_CRYPTO` from a user's perspective.
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +02003
Manuel Pégourié-Gonnardf3f79a02022-05-11 13:31:47 +02004This option makes the X.509 and TLS library use PSA for cryptographic
5operations, and enables new APIs for using keys handled by PSA Crypto.
6
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +02007General limitations
8-------------------
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +02009
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020010Compile-time: enabling `MBEDTLS_USE_PSA_CRYPTO` requires
Manuel Pégourié-Gonnardf3f79a02022-05-11 13:31:47 +020011`MBEDTLS_ECP_RESTARTABLE` to be disabled.
12
13Application code: when this option is enabled, you need to call
14`psa_crypto_init()` before calling any function from the SSL/TLS, X.509 or PK
15module.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020016
Manuel Pégourié-Gonnard97ec0b72022-04-20 15:20:15 +020017Scope: `MBEDTLS_USE_PSA_CRYPTO` has no effect on the parts of the code that
18are specific to TLS 1.3; those parts always use PSA Crypto. The parts of the
19TLS 1.3 code that are common with TLS 1.2, however, follow this option (this
Manuel Pégourié-Gonnard3e830982022-05-11 13:27:44 +020020is currently just the record protection code, and X.509). You need to enable
21`MBEDTLS_USE_PSA_CRYPTO` if you want TLS 1.3 to use PSA everywhere.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020022
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020023New APIs / API extensions
24-------------------------
25
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020026### PSA-held (opaque) keys in the PK layer
27
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020028There is a new API function `mbedtls_pk_setup_opaque()` that can be used to
29wrap a PSA keypair into a PK context. The key can be used for private-key
30operations and its public part can be exported.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020031
32Benefits: isolation of long-term secrets, use of PSA Crypto drivers.
33
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020034Limitations: can only wrap a keypair, can only use it for private key
35operations. (That is, signature generation, and for RSA decryption too.)
36Note: for ECDSA, currently this uses randomized ECDSA while Mbed TLS uses
37deterministic ECDSA by default. The following operations are not supported
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020038with a context set this way, while they would be available with a normal
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020039`mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`, all public key operations.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020040
41Use in X.509 and TLS: opt-in. The application needs to construct the PK context
42using the new API in order to get the benefits; it can then pass the
43resulting context to the following existing APIs:
44
45- `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the
Manuel Pégourié-Gonnard13841cb2021-09-24 11:43:14 +020046 key together with a certificate for ECDSA-based key exchanges (note: while
47this is supported on both sides, it's currently only tested client-side);
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020048- `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature
49 request).
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020050- `mbedtls_x509write_crt_set_issuer_key()` to generate a certificate.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020051
Manuel Pégourié-Gonnard9155b0e2021-09-24 10:17:07 +020052### PSA-held (opaque) keys for TLS pre-shared keys (PSK)
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020053
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020054There are two new API functions `mbedtls_ssl_conf_psk_opaque()` and
55`mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020056register a PSA key for use with a PSK key exchange.
57
58Benefits: isolation of long-term secrets.
59
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020060Limitations: only TLS 1.2 for now.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020061
62Use in TLS: opt-in. The application needs to register the key using the new
63APIs to get the benefits.
64
65### PSA-based operations in the Cipher layer
66
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020067There is a new API function `mbedtls_cipher_setup_psa()` to set up a context
68that will call PSA to store the key and perform the operations.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020069
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020070This function only worked for a small number of ciphers. It is now deprecated
71and it is recommended to use `psa_cipher_xxx()` or `psa_aead_xxx()` functions
72directly instead.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020073
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020074This function will be removed in a future version of Mbed TLS. If you are using
75it and would like us to keep it, please let us know about your use case.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020076
77Internal changes
78----------------
79
80All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO`
81is enabled, no change required on the application side.
82
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020083### TLS: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020084
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020085Current exceptions:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020086
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020087- EC J-PAKE (when `MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED`)
88- finite-field (non-EC) Diffie-Hellman (use in key exchanges: DHE-RSA,
89 DHE-PSK)
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020090
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020091Other than the above exceptions, all crypto operations are based on PSA when
92`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020093
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020094### X.509: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020095
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020096Current exception:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020097
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020098- verification of RSA-PSS signatures with a salt length that is different from
99 the hash length.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200100
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200101Other than the above exceptions, all crypto operations are based on PSA when
102`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200103
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200104### PK layer: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200105
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200106Current exception:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200107
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200108- verification of RSA-PSS signatures with a salt length that is different from
109 the hash length.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200110
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200111Other than the above exceptions, all crypto operations are based on PSA when
112`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200113