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 | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 4 | General limitations |
| 5 | ------------------- |
Manuel Pégourié-Gonnard | 13b0beb | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 6 | |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 7 | Compile-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é-Gonnard | 97ec0b7 | 2022-04-20 15:20:15 +0200 | [diff] [blame] | 11 | Scope: `MBEDTLS_USE_PSA_CRYPTO` has no effect on the parts of the code that |
| 12 | are specific to TLS 1.3; those parts always use PSA Crypto. The parts of the |
| 13 | TLS 1.3 code that are common with TLS 1.2, however, follow this option (this |
| 14 | is currently just the record protection code). |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 15 | |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 16 | New APIs / API extensions |
| 17 | ------------------------- |
| 18 | |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 19 | ### PSA-held (opaque) keys in the PK layer |
| 20 | |
Manuel Pégourié-Gonnard | ca91017 | 2021-09-24 10:14:32 +0200 | [diff] [blame] | 21 | There is a new API function `mbedtls_pk_setup_opaque()` that can be used to |
| 22 | wrap a PSA keypair into a PK context. The key can be used for private-key |
| 23 | operations and its public part can be exported. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 24 | |
| 25 | Benefits: isolation of long-term secrets, use of PSA Crypto drivers. |
| 26 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 27 | Limitations: can only wrap a keypair, can only use it for private key |
| 28 | operations. (That is, signature generation, and for RSA decryption too.) |
| 29 | Note: for ECDSA, currently this uses randomized ECDSA while Mbed TLS uses |
| 30 | deterministic ECDSA by default. The following operations are not supported |
Manuel Pégourié-Gonnard | ca91017 | 2021-09-24 10:14:32 +0200 | [diff] [blame] | 31 | with a context set this way, while they would be available with a normal |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 32 | `mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`, all public key operations. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 33 | |
| 34 | Use in X.509 and TLS: opt-in. The application needs to construct the PK context |
| 35 | using the new API in order to get the benefits; it can then pass the |
| 36 | resulting 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é-Gonnard | 13841cb | 2021-09-24 11:43:14 +0200 | [diff] [blame] | 39 | key together with a certificate for ECDSA-based key exchanges (note: while |
| 40 | this is supported on both sides, it's currently only tested client-side); |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 41 | - `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature |
| 42 | request). |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 43 | - `mbedtls_x509write_crt_set_issuer_key()` to generate a certificate. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 44 | |
Manuel Pégourié-Gonnard | 9155b0e | 2021-09-24 10:17:07 +0200 | [diff] [blame] | 45 | ### PSA-held (opaque) keys for TLS pre-shared keys (PSK) |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 46 | |
Manuel Pégourié-Gonnard | ca91017 | 2021-09-24 10:14:32 +0200 | [diff] [blame] | 47 | There 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é-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 49 | register a PSA key for use with a PSK key exchange. |
| 50 | |
| 51 | Benefits: isolation of long-term secrets. |
| 52 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 53 | Limitations: only TLS 1.2 for now. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 54 | |
| 55 | Use in TLS: opt-in. The application needs to register the key using the new |
| 56 | APIs to get the benefits. |
| 57 | |
| 58 | ### PSA-based operations in the Cipher layer |
| 59 | |
Manuel Pégourié-Gonnard | ca91017 | 2021-09-24 10:14:32 +0200 | [diff] [blame] | 60 | There is a new API function `mbedtls_cipher_setup_psa()` to set up a context |
| 61 | 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] | 62 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 63 | This function only worked for a small number of ciphers. It is now deprecated |
| 64 | and it is recommended to use `psa_cipher_xxx()` or `psa_aead_xxx()` functions |
| 65 | directly instead. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 66 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 67 | This function will be removed in a future version of Mbed TLS. If you are using |
| 68 | it and would like us to keep it, please let us know about your use case. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 69 | |
| 70 | Internal changes |
| 71 | ---------------- |
| 72 | |
| 73 | All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO` |
| 74 | is enabled, no change required on the application side. |
| 75 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 76 | ### TLS: most crypto operations based on PSA |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 77 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 78 | Current exceptions: |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 79 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 80 | - 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é-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 | Other than the above exceptions, all crypto operations are based on PSA when |
| 85 | `MBEDTLS_USE_PSA_CRYPTO` is enabled. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 86 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 87 | ### X.509: most crypto operations based on PSA |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 88 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 89 | Current exception: |
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 | - verification of RSA-PSS signatures with a salt length that is different from |
| 92 | the hash length. |
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 | Other than the above exceptions, all crypto operations are based on PSA when |
| 95 | `MBEDTLS_USE_PSA_CRYPTO` is enabled. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 96 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 97 | ### PK layer: most crypto operations based on PSA |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 98 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 99 | Current exception: |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 100 | |
Manuel Pégourié-Gonnard | b2bd34e | 2022-04-20 15:58:00 +0200 | [diff] [blame^] | 101 | - verification of RSA-PSS signatures with a salt length that is different from |
| 102 | the hash length. |
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 | Other than the above exceptions, all crypto operations are based on PSA when |
| 105 | `MBEDTLS_USE_PSA_CRYPTO` is enabled. |
Manuel Pégourié-Gonnard | 1b08c5f | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 106 | |