blob: 4292aa6b94aa1a8b0271653713fdbe7e0436000f [file] [log] [blame] [view]
Manuel Pégourié-Gonnard73a0e1d2021-09-21 13:55:00 +02001This document describes the compile-time configuration option
2`MBEDTLS_USE_PSA_CRYPTO` from a user's perspective, more specifically its
3current effects as well as the parts that aren't covered yet.
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +02004
5Current effects
6===============
7
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +02008General limitations
9-------------------
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +020010
Manuel Pégourié-Gonnard1b08c5f2021-09-21 11:21:23 +020011Compile-time: enabling `MBEDTLS_USE_PSA_CRYPTO` requires
12`MBEDTLS_ECP_RESTARTABLE` and
13`MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER` to be disabled.
14
15Effect: `MBEDTLS_USE_PSA_CRYPTO` currently has no effect on TLS 1.3 (which is
16itself experimental and only partially supported so far): TLS 1.3 always uses
17the legacy APIs even when this option is set.
18
19Stability: any API that's only available when `MBEDTLS_USE_PSA_CRYPTO` is
20defined is considered experimental and may change in incompatible ways at any
21time. Said otherwise, these APIs are explicitly excluded from the usual API
22stability promises.
23
24New APIs / API extensions
25-------------------------
26
27Some of these APIs are meant for the application to use in place of
28pre-existing APIs, in order to get access to the benefits; in the sub-sections
29below these are indicated by "Use in (X.509 and) TLS: opt-in", meaning that
30this requires changes to the application code for the (X.509 and) TLS layers
31to pick up the improvements.
32
33Some of these APIs are mostly meant for internal use by the TLS (and X.509)
34layers; they are indicated below by "Use in (X.509 and) TLS: automatic",
35meaning that no changes to the application code are required for the TLS (and
36X.509) layers to pick up the improvements.
37
38### PSA-held (opaque) keys in the PK layer
39
40Add `mbedtls_pk_setup_opaque()` to wrap a PSA keypair into a PK context. The key
41can be used for private-key operations and its public part can be written out.
42
43Benefits: isolation of long-term secrets, use of PSA Crypto drivers.
44
45Limitations: only for private keys, only ECC. (That is, only ECDSA signature
46generation.) The following operations are not supported with a context set
47this way, while they would be available with a normal `ECKEY` context:
48`mbedtls_pk_verify()`, `mbedtls_pk_check_pair()`, `mbedtls_pk_debug()`.
49
50Use in X.509 and TLS: opt-in. The application needs to construct the PK context
51using the new API in order to get the benefits; it can then pass the
52resulting 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
59In the TLS and X.509 API, there's two other function which accept a key or
60keypair as a PK context: `mbedtls_x509write_crt_set_subject_key()` and
61`mbedtls_x509write_crt_set_issuer_key()`. Use of opaque contexts here probably
62works but is so far untested.
63
64### PSA-held (opaque) keys for TLS 1.2 pre-shared keys (PSK)
65
66Add `mbedtls_ssl_conf_psk_opaque()` and `mbedtls_ssl_set_hs_psk_opaque()` to
67register a PSA key for use with a PSK key exchange.
68
69Benefits: isolation of long-term secrets.
70
71Limitations: the key can only be used with with TLS 1.2, and only with "pure"
72PSK key exchanges (ciphersuites starting with `TLS_PSK_WITH_`), to the
73exclusion of RSA-PSK, DHE-PSK and ECDHE-PSK key exchanges. It is the responsibility of
74the user to make sure that when provisioning an opaque pre-shared key, the
75only PSK ciphersuites that can be negotiated are "pure" PSK; other XXX-PSK key
76exchanges will result in a handshake failure with the handshake function
77returning `MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE`.
78
79Use in TLS: opt-in. The application needs to register the key using the new
80APIs to get the benefits.
81
82### PSA-based operations in the Cipher layer
83
84Add `mbedtls_cipher_setup_psa()` to set up a context that will call PSA to
85store the key and perform the operations.
86
87Benefits: use of PSA Crypto drivers; partial isolation of short-term secrets
88(still generated outside of PSA, but then held by PSA).
89
90Limitations: the key is still passed in the clear by the application. The
91multi-part APIs are not supported, only the one-shot APIs. The only modes
92supported are ECB, CBC without padding, GCM and CCM (this excludes stream
93ciphers and ChachaPoly); the only cipher supported is AES (this excludes Aria,
94Camellia, and ChachaPoly).
95
96Use in TLS: automatic. Used when the cipher and mode is supported (with
97gracious fallback to the legacy API otherwise) in all places where a cipher is
98used. There are two such places: in `ssl_tls.c` for record protection, and in
99`ssl_ticket.c` for protecting tickets we issue.
100
101Internal changes
102----------------
103
104All of these internal changes are active as soon as `MBEDTLS_USE_PSA_CRYPTO`
105is enabled, no change required on the application side.
106
107### TLS: cipher operations based on PSA
108
109See "PSA-based operations in the Cipher layer" above.
110
111### PK layer: ECDSA verification based on PSA
112
113Scope: `mbedtls_pk_verify()` will call to PSA for ECDSA signature
114verification.
115
116Benefits: use of PSA Crypto drivers.
117
118Use in TLS and X.509: in all places where an ECDSA signature is verified.
119
120### TLS: ECDHE computation based on PSA
121
122Scope: Client-side, for ECDHE-RSA and ECDHE-ECDSA key exchanges, the
123computation of the ECDHE key exchange is done by PSA.
124
125Limitations: client-side only, ECDHE-PSK not covered
126
127Benefits: use of PSA Crypto drivers.
128
129### TLS: handshake hashes and PRF computed with PSA
130
131Scope: 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
137Benefits: use of PSA Crypto drivers.
138
139### X.509: some hashes computed with PSA
140
141Scope: 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
146Benefits: use of PSA Crypto drivers.
147
148Parts that are not covered yet
149==============================
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +0200150
Manuel Pégourié-Gonnard73a0e1d2021-09-21 13:55:00 +0200151This is only a high-level overview, grouped by theme
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +0200152
Manuel Pégourié-Gonnard73a0e1d2021-09-21 13:55:00 +0200153TLS: key exchanges / asymmetric crypto
154--------------------------------------
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +0200155
Manuel Pégourié-Gonnardd3ac4a92021-09-24 10:06:04 +0200156The 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
167The 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
174PSK if covered when the application uses `mbedtls_ssl_conf_psk_opaque()` or
175`mbedtls_ssl_set_hs_psk_opaque()`.
Manuel Pégourié-Gonnard13b0beb2021-09-20 13:21:25 +0200176
Manuel Pégourié-Gonnard73a0e1d2021-09-21 13:55:00 +0200177TLS: 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é-Gonnardd3ac4a92021-09-24 10:06:04 +0200182- the HMAC part of the CBC and NULL ciphersuites
Manuel Pégourié-Gonnard73a0e1d2021-09-21 13:55:00 +0200183- the HMAC computation in `ssl_cookie.c`
184
185X.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é-Gonnardd3ac4a92021-09-24 10:06:04 +0200190- RSA PKCS#1 v1.5 signature generation (from PSA-held keys)
191- RSA PKCS#1 v1.5 signature verification
192- RSA-PSS signature verification