blob: b9983b72487f3238a67bdbbb71f8c4cc9c223eaa [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é-Gonnard1b08c5f2021-09-21 11:21:23 +02004General limitations
5-------------------
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +02006
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +02007Compile-time: enabling `MBEDTLS_USE_PSA_CRYPTO` requires
8`MBEDTLS_ECP_RESTARTABLE` and
9`MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER` to be disabled.
10
Manuel Pégourié-Gonnard97ec0b72022-04-20 15:20:15 +020011Scope: `MBEDTLS_USE_PSA_CRYPTO` has no effect on the parts of the code that
12are specific to TLS 1.3; those parts always use PSA Crypto. The parts of the
13TLS 1.3 code that are common with TLS 1.2, however, follow this option (this
14is currently just the record protection code).
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020015
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020016New APIs / API extensions
17-------------------------
18
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020019### PSA-held (opaque) keys in the PK layer
20
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020021There is a new API function `mbedtls_pk_setup_opaque()` that can be used to
22wrap a PSA keypair into a PK context. The key can be used for private-key
23operations and its public part can be exported.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020024
25Benefits: isolation of long-term secrets, use of PSA Crypto drivers.
26
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020027Limitations: can only wrap a keypair, can only use it for private key
28operations. (That is, signature generation, and for RSA decryption too.)
29Note: for ECDSA, currently this uses randomized ECDSA while Mbed TLS uses
30deterministic ECDSA by default. The following operations are not supported
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020031with a context set this way, while they would be available with a normal
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020032`mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`, all public key operations.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020033
34Use in X.509 and TLS: opt-in. The application needs to construct the PK context
35using the new API in order to get the benefits; it can then pass the
36resulting context to the following existing APIs:
37
38- `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the
Manuel Pégourié-Gonnard13841cb2021-09-24 11:43:14 +020039 key together with a certificate for ECDSA-based key exchanges (note: while
40this is supported on both sides, it's currently only tested client-side);
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020041- `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature
42 request).
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020043- `mbedtls_x509write_crt_set_issuer_key()` to generate a certificate.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020044
Manuel Pégourié-Gonnard9155b0e2021-09-24 10:17:07 +020045### PSA-held (opaque) keys for TLS pre-shared keys (PSK)
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020046
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020047There are two new API functions `mbedtls_ssl_conf_psk_opaque()` and
48`mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020049register a PSA key for use with a PSK key exchange.
50
51Benefits: isolation of long-term secrets.
52
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020053Limitations: only TLS 1.2 for now.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020054
55Use in TLS: opt-in. The application needs to register the key using the new
56APIs to get the benefits.
57
58### PSA-based operations in the Cipher layer
59
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020060There is a new API function `mbedtls_cipher_setup_psa()` to set up a context
61that will call PSA to store the key and perform the operations.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020062
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020063This function only worked for a small number of ciphers. It is now deprecated
64and it is recommended to use `psa_cipher_xxx()` or `psa_aead_xxx()` functions
65directly instead.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020066
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020067This function will be removed in a future version of Mbed TLS. If you are using
68it and would like us to keep it, please let us know about your use case.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020069
70Internal changes
71----------------
72
73All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO`
74is enabled, no change required on the application side.
75
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020076### TLS: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020077
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020078Current exceptions:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020079
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020080- EC J-PAKE (when `MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED`)
81- finite-field (non-EC) Diffie-Hellman (use in key exchanges: DHE-RSA,
82 DHE-PSK)
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020083
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020084Other than the above exceptions, all crypto operations are based on PSA when
85`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020086
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020087### X.509: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020088
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020089Current exception:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020090
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020091- verification of RSA-PSS signatures with a salt length that is different from
92 the hash length.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020093
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020094Other than the above exceptions, all crypto operations are based on PSA when
95`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020096
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020097### PK layer: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020098
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020099Current exception:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200100
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200101- verification of RSA-PSS signatures with a salt length that is different from
102 the hash length.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200103
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200104Other than the above exceptions, all crypto operations are based on PSA when
105`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200106