blob: c1789b30dc4816e2ef5ec18ef7c9d5670b597358 [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
Manuel Pégourié-Gonnard3e830982022-05-11 13:27:44 +020014is currently just the record protection code, and X.509). You need to enable
15`MBEDTLS_USE_PSA_CRYPTO` if you want TLS 1.3 to use PSA everywhere.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020016
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020017New APIs / API extensions
18-------------------------
19
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020020### PSA-held (opaque) keys in the PK layer
21
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020022There is a new API function `mbedtls_pk_setup_opaque()` that can be used to
23wrap a PSA keypair into a PK context. The key can be used for private-key
24operations and its public part can be exported.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020025
26Benefits: isolation of long-term secrets, use of PSA Crypto drivers.
27
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020028Limitations: can only wrap a keypair, can only use it for private key
29operations. (That is, signature generation, and for RSA decryption too.)
30Note: for ECDSA, currently this uses randomized ECDSA while Mbed TLS uses
31deterministic ECDSA by default. The following operations are not supported
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020032with a context set this way, while they would be available with a normal
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020033`mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`, all public key operations.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020034
35Use in X.509 and TLS: opt-in. The application needs to construct the PK context
36using the new API in order to get the benefits; it can then pass the
37resulting context to the following existing APIs:
38
39- `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the
Manuel Pégourié-Gonnard13841cb2021-09-24 11:43:14 +020040 key together with a certificate for ECDSA-based key exchanges (note: while
41this is supported on both sides, it's currently only tested client-side);
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020042- `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature
43 request).
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020044- `mbedtls_x509write_crt_set_issuer_key()` to generate a certificate.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020045
Manuel Pégourié-Gonnard9155b0e2021-09-24 10:17:07 +020046### PSA-held (opaque) keys for TLS pre-shared keys (PSK)
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020047
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020048There are two new API functions `mbedtls_ssl_conf_psk_opaque()` and
49`mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020050register a PSA key for use with a PSK key exchange.
51
52Benefits: isolation of long-term secrets.
53
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020054Limitations: only TLS 1.2 for now.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020055
56Use in TLS: opt-in. The application needs to register the key using the new
57APIs to get the benefits.
58
59### PSA-based operations in the Cipher layer
60
Manuel Pégourié-Gonnardca910172021-09-24 10:14:32 +020061There is a new API function `mbedtls_cipher_setup_psa()` to set up a context
62that will call PSA to store the key and perform the operations.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020063
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020064This function only worked for a small number of ciphers. It is now deprecated
65and it is recommended to use `psa_cipher_xxx()` or `psa_aead_xxx()` functions
66directly instead.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020067
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020068This function will be removed in a future version of Mbed TLS. If you are using
69it and would like us to keep it, please let us know about your use case.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020070
71Internal changes
72----------------
73
74All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO`
75is enabled, no change required on the application side.
76
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020077### TLS: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020078
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020079Current exceptions:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020080
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020081- EC J-PAKE (when `MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED`)
82- finite-field (non-EC) Diffie-Hellman (use in key exchanges: DHE-RSA,
83 DHE-PSK)
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020084
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020085Other than the above exceptions, all crypto operations are based on PSA when
86`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020087
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020088### X.509: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020089
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020090Current exception:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020091
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020092- verification of RSA-PSS signatures with a salt length that is different from
93 the hash length.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020094
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020095Other than the above exceptions, all crypto operations are based on PSA when
96`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020097
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +020098### PK layer: most crypto operations based on PSA
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020099
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200100Current exception:
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200101
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200102- verification of RSA-PSS signatures with a salt length that is different from
103 the hash length.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200104
Manuel Pégourié-Gonnardb2bd34e2022-04-20 15:58:00 +0200105Other than the above exceptions, all crypto operations are based on PSA when
106`MBEDTLS_USE_PSA_CRYPTO` is enabled.
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +0200107