blob: 8261b8b93c55ff3df9d997cff0573c195d9e29f4 [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
Manuel Pégourié-Gonnard0dba51c2022-06-07 10:28:02 +020019TLS 1.3 code that are common with TLS 1.2, however, follow this option;
20currently this is the record protection code, computation of the running
21handshake hash, and X.509). You need to enable `MBEDTLS_USE_PSA_CRYPTO` if you
22want TLS 1.3 to use PSA everywhere.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020023
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020024New APIs / API extensions
25-------------------------
26
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020027### PSA-held (opaque) keys in the PK layer
28
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020029There is a new API function `mbedtls_pk_setup_opaque()` that can be used to
30wrap a PSA keypair into a PK context. The key can be used for private-key
31operations and its public part can be exported.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020032
33Benefits: isolation of long-term secrets, use of PSA Crypto drivers.
34
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020035Limitations: can only wrap a keypair, can only use it for private key
36operations. (That is, signature generation, and for RSA decryption too.)
37Note: for ECDSA, currently this uses randomized ECDSA while Mbed TLS uses
38deterministic ECDSA by default. The following operations are not supported
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020039with a context set this way, while they would be available with a normal
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020040`mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`, all public key operations.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020041
42Use in X.509 and TLS: opt-in. The application needs to construct the PK context
43using the new API in order to get the benefits; it can then pass the
44resulting context to the following existing APIs:
45
46- `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the
Manuel Pégourié-Gonnard13841cb2021-09-24 11:43:14 +020047 key together with a certificate for ECDSA-based key exchanges (note: while
48this is supported on both sides, it's currently only tested client-side);
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020049- `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature
50 request).
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020051- `mbedtls_x509write_crt_set_issuer_key()` to generate a certificate.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020052
Manuel Pégourié-Gonnard9155b0e2021-09-24 10:17:07 +020053### PSA-held (opaque) keys for TLS pre-shared keys (PSK)
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020054
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020055There are two new API functions `mbedtls_ssl_conf_psk_opaque()` and
56`mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020057register a PSA key for use with a PSK key exchange.
58
59Benefits: isolation of long-term secrets.
60
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020061Limitations: only TLS 1.2 for now.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020062
63Use in TLS: opt-in. The application needs to register the key using the new
64APIs to get the benefits.
65
66### PSA-based operations in the Cipher layer
67
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020068There is a new API function `mbedtls_cipher_setup_psa()` to set up a context
69that will call PSA to store the key and perform the operations.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020070
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020071This function only worked for a small number of ciphers. It is now deprecated
72and it is recommended to use `psa_cipher_xxx()` or `psa_aead_xxx()` functions
73directly instead.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020074
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020075This function will be removed in a future version of Mbed TLS. If you are using
76it and would like us to keep it, please let us know about your use case.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020077
78Internal changes
79----------------
80
81All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO`
82is enabled, no change required on the application side.
83
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020084### TLS: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020085
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020086Current exceptions:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020087
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020088- EC J-PAKE (when `MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED`)
89- finite-field (non-EC) Diffie-Hellman (use in key exchanges: DHE-RSA,
90 DHE-PSK)
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020091
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020092Other than the above exceptions, all crypto operations are based on PSA when
93`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020094
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020095### X.509: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020096
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020097Current exception:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020098
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020099- verification of RSA-PSS signatures with a salt length that is different from
100 the hash length.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200101
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200102Other than the above exceptions, all crypto operations are based on PSA when
103`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200104
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200105### PK layer: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200106
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200107Current exception:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200108
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200109- verification of RSA-PSS signatures with a salt length that is different from
110 the hash length.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200111
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200112Other than the above exceptions, all crypto operations are based on PSA when
113`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200114