Manuel Pégourié-Gonnard | 6cf7d94 | 2021-09-21 13:55:00 +0200 | [diff] [blame] | 1 | This document describes the compile-time configuration option |
| 2 | `MBEDTLS_USE_PSA_CRYPTO` from a user's perspective, more specifically its |
| 3 | current effects as well as the parts that aren't covered yet. |
Manuel Pégourié-Gonnard | 00b72fc | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 4 | |
| 5 | Current effects |
| 6 | =============== |
| 7 | |
Manuel Pégourié-Gonnard | 04bc687 | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 8 | General limitations |
| 9 | ------------------- |
Manuel Pégourié-Gonnard | 00b72fc | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 10 | |
Manuel Pégourié-Gonnard | 04bc687 | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 11 | Compile-time: enabling `MBEDTLS_USE_PSA_CRYPTO` requires |
| 12 | `MBEDTLS_ECP_RESTARTABLE` and |
| 13 | `MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER` to be disabled. |
| 14 | |
| 15 | Effect: `MBEDTLS_USE_PSA_CRYPTO` currently has no effect on TLS 1.3 (which is |
| 16 | itself experimental and only partially supported so far): TLS 1.3 always uses |
| 17 | the legacy APIs even when this option is set. |
| 18 | |
| 19 | Stability: any API that's only available when `MBEDTLS_USE_PSA_CRYPTO` is |
| 20 | defined is considered experimental and may change in incompatible ways at any |
| 21 | time. Said otherwise, these APIs are explicitly excluded from the usual API |
| 22 | stability promises. |
| 23 | |
| 24 | New APIs / API extensions |
| 25 | ------------------------- |
| 26 | |
| 27 | Some of these APIs are meant for the application to use in place of |
| 28 | pre-existing APIs, in order to get access to the benefits; in the sub-sections |
| 29 | below these are indicated by "Use in (X.509 and) TLS: opt-in", meaning that |
| 30 | this requires changes to the application code for the (X.509 and) TLS layers |
| 31 | to pick up the improvements. |
| 32 | |
| 33 | Some of these APIs are mostly meant for internal use by the TLS (and X.509) |
| 34 | layers; they are indicated below by "Use in (X.509 and) TLS: automatic", |
| 35 | meaning that no changes to the application code are required for the TLS (and |
| 36 | X.509) layers to pick up the improvements. |
| 37 | |
| 38 | ### PSA-held (opaque) keys in the PK layer |
| 39 | |
Manuel Pégourié-Gonnard | 12ab49a | 2021-09-24 10:14:32 +0200 | [diff] [blame^] | 40 | There is a new API function `mbedtls_pk_setup_opaque()` that can be used to |
| 41 | wrap a PSA keypair into a PK context. The key can be used for private-key |
| 42 | operations and its public part can be exported. |
Manuel Pégourié-Gonnard | 04bc687 | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 43 | |
| 44 | Benefits: isolation of long-term secrets, use of PSA Crypto drivers. |
| 45 | |
| 46 | Limitations: only for private keys, only ECC. (That is, only ECDSA signature |
Manuel Pégourié-Gonnard | 12ab49a | 2021-09-24 10:14:32 +0200 | [diff] [blame^] | 47 | generation. Note: currently this will use randomized ECDSA while Mbed TLS uses |
| 48 | deterministic ECDSA by default.) The following operations are not supported |
| 49 | with a context set this way, while they would be available with a normal |
| 50 | `ECKEY` context: `mbedtls_pk_verify()`, `mbedtls_pk_check_pair()`, |
| 51 | `mbedtls_pk_debug()`. |
Manuel Pégourié-Gonnard | 04bc687 | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 52 | |
| 53 | Use in X.509 and TLS: opt-in. The application needs to construct the PK context |
| 54 | using the new API in order to get the benefits; it can then pass the |
| 55 | resulting context to the following existing APIs: |
| 56 | |
| 57 | - `mbedtls_ssl_conf_own_cert()` or `mbedtls_ssl_set_hs_own_cert()` to use the |
| 58 | key together with a certificate for ECDSA-based key exchanges; |
| 59 | - `mbedtls_x509write_csr_set_key()` to generate a CSR (certificate signature |
| 60 | request). |
| 61 | |
Manuel Pégourié-Gonnard | 12ab49a | 2021-09-24 10:14:32 +0200 | [diff] [blame^] | 62 | In the TLS and X.509 API, there are two other functions which accept a key or |
Manuel Pégourié-Gonnard | 04bc687 | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 63 | keypair as a PK context: `mbedtls_x509write_crt_set_subject_key()` and |
| 64 | `mbedtls_x509write_crt_set_issuer_key()`. Use of opaque contexts here probably |
| 65 | works but is so far untested. |
| 66 | |
| 67 | ### PSA-held (opaque) keys for TLS 1.2 pre-shared keys (PSK) |
| 68 | |
Manuel Pégourié-Gonnard | 12ab49a | 2021-09-24 10:14:32 +0200 | [diff] [blame^] | 69 | There are two new API functions `mbedtls_ssl_conf_psk_opaque()` and |
| 70 | `mbedtls_ssl_set_hs_psk_opaque()`. Call one of these from an application to |
Manuel Pégourié-Gonnard | 04bc687 | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 71 | register a PSA key for use with a PSK key exchange. |
| 72 | |
| 73 | Benefits: isolation of long-term secrets. |
| 74 | |
| 75 | Limitations: the key can only be used with with TLS 1.2, and only with "pure" |
| 76 | PSK key exchanges (ciphersuites starting with `TLS_PSK_WITH_`), to the |
| 77 | exclusion of RSA-PSK, DHE-PSK and ECDHE-PSK key exchanges. It is the responsibility of |
| 78 | the user to make sure that when provisioning an opaque pre-shared key, the |
| 79 | only PSK ciphersuites that can be negotiated are "pure" PSK; other XXX-PSK key |
| 80 | exchanges will result in a handshake failure with the handshake function |
| 81 | returning `MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE`. |
| 82 | |
| 83 | Use in TLS: opt-in. The application needs to register the key using the new |
| 84 | APIs to get the benefits. |
| 85 | |
| 86 | ### PSA-based operations in the Cipher layer |
| 87 | |
Manuel Pégourié-Gonnard | 12ab49a | 2021-09-24 10:14:32 +0200 | [diff] [blame^] | 88 | There is a new API function `mbedtls_cipher_setup_psa()` to set up a context |
| 89 | that will call PSA to store the key and perform the operations. |
Manuel Pégourié-Gonnard | 04bc687 | 2021-09-21 11:21:23 +0200 | [diff] [blame] | 90 | |
| 91 | Benefits: use of PSA Crypto drivers; partial isolation of short-term secrets |
| 92 | (still generated outside of PSA, but then held by PSA). |
| 93 | |
| 94 | Limitations: the key is still passed in the clear by the application. The |
| 95 | multi-part APIs are not supported, only the one-shot APIs. The only modes |
| 96 | supported are ECB, CBC without padding, GCM and CCM (this excludes stream |
| 97 | ciphers and ChachaPoly); the only cipher supported is AES (this excludes Aria, |
| 98 | Camellia, and ChachaPoly). |
| 99 | |
| 100 | Use in TLS: automatic. Used when the cipher and mode is supported (with |
| 101 | gracious fallback to the legacy API otherwise) in all places where a cipher is |
| 102 | used. There are two such places: in `ssl_tls.c` for record protection, and in |
| 103 | `ssl_ticket.c` for protecting tickets we issue. |
| 104 | |
| 105 | Internal changes |
| 106 | ---------------- |
| 107 | |
| 108 | All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO` |
| 109 | is enabled, no change required on the application side. |
| 110 | |
| 111 | ### TLS: cipher operations based on PSA |
| 112 | |
| 113 | See "PSA-based operations in the Cipher layer" above. |
| 114 | |
| 115 | ### PK layer: ECDSA verification based on PSA |
| 116 | |
| 117 | Scope: `mbedtls_pk_verify()` will call to PSA for ECDSA signature |
| 118 | verification. |
| 119 | |
| 120 | Benefits: use of PSA Crypto drivers. |
| 121 | |
| 122 | Use in TLS and X.509: in all places where an ECDSA signature is verified. |
| 123 | |
| 124 | ### TLS: ECDHE computation based on PSA |
| 125 | |
| 126 | Scope: Client-side, for ECDHE-RSA and ECDHE-ECDSA key exchanges, the |
| 127 | computation of the ECDHE key exchange is done by PSA. |
| 128 | |
| 129 | Limitations: client-side only, ECDHE-PSK not covered |
| 130 | |
| 131 | Benefits: use of PSA Crypto drivers. |
| 132 | |
| 133 | ### TLS: handshake hashes and PRF computed with PSA |
| 134 | |
| 135 | Scope: with TLS 1.2, the following are computed with PSA: |
| 136 | - the running handshake hashes; |
| 137 | - the hash of the ServerKeyExchange part that is signed; |
| 138 | - the `verify_data` part of the Finished message; |
| 139 | - the TLS PRF. |
| 140 | |
| 141 | Benefits: use of PSA Crypto drivers. |
| 142 | |
| 143 | ### X.509: some hashes computed with PSA |
| 144 | |
| 145 | Scope: the following hashes are computed with PSA: |
| 146 | - when verifying a certificate chain, hash of the child for verifying the |
| 147 | parent's signature; |
| 148 | - when writing a CSR, hash of the request for self-signing the request. |
| 149 | |
| 150 | Benefits: use of PSA Crypto drivers. |
| 151 | |
| 152 | Parts that are not covered yet |
| 153 | ============================== |
Manuel Pégourié-Gonnard | 00b72fc | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 154 | |
Manuel Pégourié-Gonnard | 6cf7d94 | 2021-09-21 13:55:00 +0200 | [diff] [blame] | 155 | This is only a high-level overview, grouped by theme |
Manuel Pégourié-Gonnard | 00b72fc | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 156 | |
Manuel Pégourié-Gonnard | 6cf7d94 | 2021-09-21 13:55:00 +0200 | [diff] [blame] | 157 | TLS: key exchanges / asymmetric crypto |
| 158 | -------------------------------------- |
Manuel Pégourié-Gonnard | 00b72fc | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 159 | |
Manuel Pégourié-Gonnard | b4113ba | 2021-09-24 10:06:04 +0200 | [diff] [blame] | 160 | The following key exchanges are not covered at all: |
| 161 | |
| 162 | - RSA |
| 163 | - DHE-RSA |
| 164 | - DHE-PSK |
| 165 | - RSA-PSK |
| 166 | - ECDHE-PSK |
| 167 | - ECDH-RSA |
| 168 | - ECDH-ECDSA |
| 169 | - ECJPAKE |
| 170 | |
| 171 | The following key exchanges are only partially covered: |
| 172 | |
| 173 | - ECDHE-RSA: RSA operations are not covered and, server-side, the ECDHE |
| 174 | operation isn't either |
| 175 | - ECDHE-ECDSA: server-side, the ECDHE operation isn't covered. (ECDSA |
| 176 | signature generation is only covered if using `mbedtls_pk_setup_opaque()`.) |
| 177 | |
| 178 | PSK if covered when the application uses `mbedtls_ssl_conf_psk_opaque()` or |
| 179 | `mbedtls_ssl_set_hs_psk_opaque()`. |
Manuel Pégourié-Gonnard | 00b72fc | 2021-09-20 13:21:25 +0200 | [diff] [blame] | 180 | |
Manuel Pégourié-Gonnard | 6cf7d94 | 2021-09-21 13:55:00 +0200 | [diff] [blame] | 181 | TLS: symmetric crypto |
| 182 | --------------------- |
| 183 | |
| 184 | - some ciphers not supported via PSA yet: ARIA, Camellia, ChachaPoly (silent |
| 185 | fallback to the legacy APIs) |
Manuel Pégourié-Gonnard | b4113ba | 2021-09-24 10:06:04 +0200 | [diff] [blame] | 186 | - the HMAC part of the CBC and NULL ciphersuites |
Manuel Pégourié-Gonnard | 6cf7d94 | 2021-09-21 13:55:00 +0200 | [diff] [blame] | 187 | - the HMAC computation in `ssl_cookie.c` |
| 188 | |
| 189 | X.509 |
| 190 | ----- |
| 191 | |
| 192 | - most hash operations are still done via the legacy API, except the few that |
| 193 | are documented above as using PSA |
Manuel Pégourié-Gonnard | b4113ba | 2021-09-24 10:06:04 +0200 | [diff] [blame] | 194 | - RSA PKCS#1 v1.5 signature generation (from PSA-held keys) |
| 195 | - RSA PKCS#1 v1.5 signature verification |
| 196 | - RSA-PSS signature verification |