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