Manuel Pégourié-Gonnard | 73a0e1d | 2021-09-21 13:55:00 +0200 | [diff] [blame] | 1 | This document describes the compile-time configuration option |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 2 | `MBEDTLS_USE_PSA_CRYPTO` from a user's perspective. |
Manuel Pégourié-Gonnard | 13b0beb | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 3 | |
Manuel Pégourié-Gonnard | f3f79a0 | 2022-05-11 13:31:47 +0200 | [diff] [blame] | 4 | This option makes the X.509 and TLS library use PSA for cryptographic |
| 5 | operations, and enables new APIs for using keys handled by PSA Crypto. |
| 6 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 7 | General considerations |
| 8 | ---------------------- |
Manuel Pégourié-Gonnard | 13b0beb | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 9 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 10 | **Application code:** when this option is enabled, you need to call |
Manuel Pégourié-Gonnard | f3f79a0 | 2022-05-11 13:31:47 +0200 | [diff] [blame] | 11 | `psa_crypto_init()` before calling any function from the SSL/TLS, X.509 or PK |
| 12 | module. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 13 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 14 | **Scope:** `MBEDTLS_USE_PSA_CRYPTO` has no effect on the parts of the code that |
Manuel Pégourié-Gonnard | 97ec0b7 | 2022-04-20 15:20:15 +0200 | [diff] [blame] | 15 | are specific to TLS 1.3; those parts always use PSA Crypto. The parts of the |
Manuel Pégourié-Gonnard | 0dba51c | 2022-06-07 10:28:02 +0200 | [diff] [blame] | 16 | TLS 1.3 code that are common with TLS 1.2, however, follow this option; |
| 17 | currently this is the record protection code, computation of the running |
Manuel Pégourié-Gonnard | 481846c | 2022-07-12 09:27:39 +0200 | [diff] [blame] | 18 | handshake hash, and X.509. You need to enable `MBEDTLS_USE_PSA_CRYPTO` if you |
Manuel Pégourié-Gonnard | 0dba51c | 2022-06-07 10:28:02 +0200 | [diff] [blame] | 19 | want TLS 1.3 to use PSA everywhere. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 20 | |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 21 | New APIs / API extensions |
| 22 | ------------------------- |
| 23 | |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 24 | ### PSA-held (opaque) keys in the PK layer |
| 25 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 26 | **New API function:** `mbedtls_pk_setup_opaque()` - can be used to |
| 27 | wrap a PSA key pair into a PK context. The key can be used for private-key |
Manuel Pégourié-Gonnard | ca91017 | 2021-09-24 10:14:32 +0200 | [diff] [blame] | 28 | operations and its public part can be exported. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 29 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 30 | **Benefits:** isolation of long-term secrets, use of PSA Crypto drivers. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 31 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 32 | **Limitations:** can only wrap a key pair, can only use it for private key |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 33 | operations. (That is, signature generation, and for RSA decryption too.) |
| 34 | Note: for ECDSA, currently this uses randomized ECDSA while Mbed TLS uses |
| 35 | deterministic ECDSA by default. The following operations are not supported |
Manuel Pégourié-Gonnard | ca91017 | 2021-09-24 10:14:32 +0200 | [diff] [blame] | 36 | with a context set this way, while they would be available with a normal |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 37 | context: `mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`, all public key |
| 38 | operations. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 39 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 40 | **Use in X.509 and TLS:** opt-in. The application needs to construct the PK context |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 41 | using the new API in order to get the benefits; it can then pass the |
| 42 | resulting context to the following existing APIs: |
| 43 | |
| 44 | - `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 45 | key together with a certificate for certificate-based key exchanges; |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 46 | - `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 47 | request); |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 48 | - `mbedtls_x509write_crt_set_issuer_key()` to generate a certificate. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 49 | |
Manuel Pégourié-Gonnard | 9155b0e | 2021-09-24 10:17:07 +0200 | [diff] [blame] | 50 | ### PSA-held (opaque) keys for TLS pre-shared keys (PSK) |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 51 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 52 | **New API functions:** `mbedtls_ssl_conf_psk_opaque()` and |
Manuel Pégourié-Gonnard | ca91017 | 2021-09-24 10:14:32 +0200 | [diff] [blame] | 53 | `mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 54 | register a PSA key for use with a PSK key exchange. |
| 55 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 56 | **Benefits:** isolation of long-term secrets. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 57 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 58 | **Limitations:** none. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 59 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 60 | **Use in TLS:** opt-in. The application needs to register the key using one of |
| 61 | the new APIs to get the benefits. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 62 | |
| 63 | ### PSA-based operations in the Cipher layer |
| 64 | |
Manuel Pégourié-Gonnard | ca91017 | 2021-09-24 10:14:32 +0200 | [diff] [blame] | 65 | There is a new API function `mbedtls_cipher_setup_psa()` to set up a context |
| 66 | that will call PSA to store the key and perform the operations. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 67 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 68 | This function only worked for a small number of ciphers. It is now deprecated |
| 69 | and it is recommended to use `psa_cipher_xxx()` or `psa_aead_xxx()` functions |
| 70 | directly instead. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 71 | |
Manuel Pégourié-Gonnard | b5b27c1 | 2022-06-10 11:09:03 +0200 | [diff] [blame] | 72 | **Warning:** This function will be removed in a future version of Mbed TLS. If |
| 73 | you are using it and would like us to keep it, please let us know about your |
| 74 | use case. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 75 | |
| 76 | Internal changes |
| 77 | ---------------- |
| 78 | |
| 79 | All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO` |
| 80 | is enabled, no change required on the application side. |
| 81 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 82 | ### TLS: most crypto operations based on PSA |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 83 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 84 | Current exceptions: |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 85 | |
Manuel Pégourié-Gonnard | 55a188b | 2022-12-06 12:00:33 +0100 | [diff] [blame] | 86 | - Finite-field (non-EC) Diffie-Hellman (used in key exchanges: DHE-RSA, |
| 87 | DHE-PSK). |
| 88 | - Restartable operations when `MBEDTLS_ECP_RESTARTABLE` is also enabled (see |
| 89 | the documentation of that option). |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 90 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 91 | Other than the above exceptions, all crypto operations are based on PSA when |
| 92 | `MBEDTLS_USE_PSA_CRYPTO` is enabled. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 93 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 94 | ### X.509: most crypto operations based on PSA |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 95 | |
Manuel Pégourié-Gonnard | 55a188b | 2022-12-06 12:00:33 +0100 | [diff] [blame] | 96 | Current exceptions: |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 97 | |
Manuel Pégourié-Gonnard | 55a188b | 2022-12-06 12:00:33 +0100 | [diff] [blame] | 98 | - Restartable operations when `MBEDTLS_ECP_RESTARTABLE` is also enabled (see |
| 99 | the documentation of that option). |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 100 | |
Manuel Pégourié-Gonnard | 481846c | 2022-07-12 09:27:39 +0200 | [diff] [blame] | 101 | Other than the above exception, all crypto operations are based on PSA when |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 102 | `MBEDTLS_USE_PSA_CRYPTO` is enabled. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 103 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 104 | ### PK layer: most crypto operations based on PSA |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 105 | |
Manuel Pégourié-Gonnard | 55a188b | 2022-12-06 12:00:33 +0100 | [diff] [blame] | 106 | Current exceptions: |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 107 | |
Manuel Pégourié-Gonnard | a6e0291 | 2022-12-21 09:59:33 +0100 | [diff] [blame] | 108 | - Verification of RSA-PSS signatures with an MGF hash that's different from |
| 109 | the message hash. |
Manuel Pégourié-Gonnard | 55a188b | 2022-12-06 12:00:33 +0100 | [diff] [blame] | 110 | - Restartable operations when `MBEDTLS_ECP_RESTARTABLE` is also enabled (see |
| 111 | the documentation of that option). |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 112 | |
Manuel Pégourié-Gonnard | a6e0291 | 2022-12-21 09:59:33 +0100 | [diff] [blame] | 113 | Other than the above exceptions, all crypto operations are based on PSA when |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame] | 114 | `MBEDTLS_USE_PSA_CRYPTO` is enabled. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 115 | |