blob: fba3779adabb56b23a8e0e3877a1d23b59a2a061 [file] [log] [blame] [view]
Manuel Pégourié-Gonnard6d5f4942023-07-07 12:00:49 +02001This document explains how to create builds of Mbed TLS where some
2cryptographic mechanisms are provided only by PSA drivers (that is, no
3built-in implementation of those algorithms), from a user's perspective.
4
5This is useful to save code size for people who are using either a hardware
Manuel Pégourié-Gonnard030f11b2023-09-23 09:02:42 +02006accelerator, or an alternative software implementation that is more
Manuel Pégourié-Gonnard6d5f4942023-07-07 12:00:49 +02007aggressively optimized for code size than the default one in Mbed TLS.
8
9General considerations
10----------------------
11
12This document assumes that you already have a working driver.
13Otherwise, please see the [PSA driver example and
14guide](psa-driver-example-and-guide.md) for information on writing a
15driver.
16
17In order to have some mechanism provided only by a driver, you'll want
18the following compile-time configuration options enabled:
19- `MBEDTLS_PSA_CRYPTO_C` (enabled by default) - this enables PSA Crypto.
20- `MBEDTLS_USE_PSA_CRYPTO` (disabled by default) - this makes PK, X.509 and
21 TLS use PSA Crypto. You need to enable this if you're using PK, X.509 or TLS
22and want them to have access to the algorithms provided by your driver. (See
23[the dedicated document](use-psa-crypto.md) for details.)
24- `MBEDTLS_PSA_CRYPTO_CONFIG` (disabled by default) - this enables
25 configuration of cryptographic algorithms using `PSA_WANT` macros in
26`include/psa/crypto_config.h`. See [Conditional inclusion of cryptographic
27mechanism through the PSA API in Mbed
28TLS](proposed/psa-conditional-inclusion-c.md) for details.
29
30In addition, for each mechanism you want provided only by your driver:
31- Define the corresponding `PSA_WANT` macro in `psa/crypto_config.h` - this
32 means the algorithm will be available in the PSA Crypto API.
Manuel Pégourié-Gonnardfb22c272023-07-18 10:40:56 +020033- Define the corresponding `MBEDTLS_PSA_ACCEL` in your build. This could be
34 defined in `psa/crypto_config.h` or your compiler's command line. This
35informs the PSA code that an accelerator is available for this mechanism.
Manuel Pégourié-Gonnard6d5f4942023-07-07 12:00:49 +020036- Undefine / comment out the corresponding `MBEDTLS_xxx_C` macro in
37 `mbedtls/mbedtls_config.h`. This ensures the built-in implementation is not
38included in the build.
39
40For example, if you want SHA-256 to be provided only by a driver, you'll want
41`PSA_WANT_ALG_SHA_256` and `MBEDTLS_PSA_ACCEL_SHA_256` defined, and
42`MBEDTLS_SHA256_C` undefined.
43
44In addition to these compile-time considerations, at runtime you'll need to
45make sure you call `psa_crypto_init()` before any function that uses the
Manuel Pégourié-Gonnardfb22c272023-07-18 10:40:56 +020046driver-only mechanisms. Note that this is already a requirement for any use of
47the PSA Crypto API, as well as for use of the PK, X.509 and TLS modules when
48`MBEDTLS_USE_PSA_CRYPTO` is enabled, so in most cases your application will
49already be doing this.
Manuel Pégourié-Gonnard6d5f4942023-07-07 12:00:49 +020050
51Mechanisms covered
52------------------
53
Manuel Pégourié-Gonnardc9777512023-07-11 11:11:20 +020054For now, only the following (families of) mechanisms are supported:
Manuel Pégourié-Gonnard6d5f4942023-07-07 12:00:49 +020055- hashes: SHA-3, SHA-2, SHA-1, MD5, etc.
56- elliptic-curve cryptography (ECC): ECDH, ECDSA, EC J-PAKE, ECC key types.
Manuel Pégourié-Gonnardc9777512023-07-11 11:11:20 +020057- finite-field Diffie-Hellman: FFDH algorithm, DH key types.
Valerio Setti7e11dd62023-12-18 15:52:44 +010058- AEADs:
59 - GCM and CCM with AES, ARIA and Camellia key types
60 - ChachaPoly with ChaCha20 Key type
61- Ciphers:
62 - key types: AES, ARIA, Camellia, DES
63 - modes: ECB, CBC, CTR, CFB, OFB, XTS
Manuel Pégourié-Gonnard6d5f4942023-07-07 12:00:49 +020064
65Supported means that when those are provided only by drivers, everything
66(including PK, X.509 and TLS if `MBEDTLS_USE_PSA_CRYPTO` is enabled) should
67work in the same way as if the mechanisms where built-in, except as documented
68in the "Limitations" sub-sections of the sections dedicated to each family
69below.
70
Manuel Pégourié-Gonnardc9777512023-07-11 11:11:20 +020071Currently (mid-2023) we don't have plans to extend this to RSA. If
72you're interested in driver-only support for RSA, please let us know.
Manuel Pégourié-Gonnard6d5f4942023-07-07 12:00:49 +020073
74Hashes
75------
76
Manuel Pégourié-Gonnard030f11b2023-09-23 09:02:42 +020077It is possible to have all hash operations provided only by a driver.
Manuel Pégourié-Gonnard1f61b7b2023-09-22 10:15:22 +020078
79More precisely:
80- you can enable `PSA_WANT_ALG_SHA_256` without `MBEDTLS_SHA256_C`, provided
81 you have `MBEDTLS_PSA_ACCEL_ALG_SHA_256` enabled;
82- and similarly for all supported hash algorithms: `MD5`, `RIPEMD160`,
83 `SHA_1`, `SHA_224`, `SHA_256`, `SHA_384`, `SHA_512`, `SHA3_224`, `SHA3_256`,
84`SHA3_384`, `SHA3_512`.
85
86In such a build, all crypto operations (via the PSA Crypto API, or non-PSA
87APIs), as well as X.509 and TLS, will work as usual, except that direct calls
88to low-level hash APIs (`mbedtls_sha256()` etc.) are not possible for the
89modules that are disabled.
90
Manuel Pégourié-Gonnard030f11b2023-09-23 09:02:42 +020091You need to call `psa_crypto_init()` before any crypto operation that uses
92a hash algorithm that is provided only by a driver, as mentioned in [General
Manuel Pégourié-Gonnard1f61b7b2023-09-22 10:15:22 +020093considerations](#general-considerations) above.
94
95If you want to check at compile-time whether a certain hash algorithm is
96available in the present build of Mbed TLS, regardless of whether it's
97provided by a driver or built-in, you should use the following macros:
98- for code that uses only the PSA Crypto API: `PSA_WANT_ALG_xxx` from
99 `psa/crypto.h`;
Manuel Pégourié-Gonnard030f11b2023-09-23 09:02:42 +0200100- for code that uses non-PSA crypto APIs: `MBEDTLS_MD_CAN_xxx` from
Manuel Pégourié-Gonnard1f61b7b2023-09-22 10:15:22 +0200101 `mbedtls/md.h`.
Manuel Pégourié-Gonnard6d5f4942023-07-07 12:00:49 +0200102
103Elliptic-curve cryptography (ECC)
104---------------------------------
105
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200106It is possible to have most ECC operations provided only by a driver:
107- the ECDH, ECDSA and EC J-PAKE algorithms;
108- key import, export, and random generation.
109
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200110More precisely, if:
111- you have driver support for ECC public and using private keys (that is,
112`MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY` and
113`MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR_BASIC` are enabled), and
114- you have driver support for all ECC curves that are enabled (that is, for
115 each `PSA_WANT_ECC_xxx` macro enabled, the corresponding
116`MBEDTLS_PSA_ACCEL_ECC_xxx` macros is enabled as well);
Manuel Pégourié-Gonnard8c40f3d2023-09-28 11:06:09 +0200117
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200118then you can:
119- enable `PSA_WANT_ALG_ECDH` without `MBEDTLS_ECDH_C`, provided
120 `MBEDTLS_PSA_ACCEL_ALG_ECDH` is enabled
121- enable `PSA_WANT_ALG_ECDSA` without `MBEDTLS_ECDSA_C`, provided
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200122 `MBEDTLS_PSA_ACCEL_ALG_ECDSA` is enabled;
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200123- enable `PSA_WANT_ALG_JPAKE` without `MBEDTLS_ECJPAKE_C`, provided
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200124 `MBEDTLS_PSA_ACCEL_ALG_JPAKE` is enabled.
125
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200126In addition, if:
127- none of `MBEDTLS_ECDH_C`, `MBEDTLS_ECDSA_C`, `MBEDTLS_ECJPAKE_C` are enabled
128 (see conditions above), and
129- you have driver support for all enabled ECC key pair operations - that is,
130 for each `PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_xxx` macro enabled, the
131corresponding `MBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR_xxx` macros is also
132enabled,
Manuel Pégourié-Gonnard8c40f3d2023-09-28 11:06:09 +0200133
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200134then you can also disable `MBEDTLS_ECP_C`. However, a small subset of it might
135still be included in the build, see limitations sub-section below.
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200136
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200137In addition, if:
138- `MBEDTLS_ECP_C` is fully removed (see limitation sub-section below), and
139- support for RSA key types and algorithms is fully disabled, and
140- support for DH key types and the FFDH algorithm is either disabled, or
141 fully provided by a driver,
Manuel Pégourié-Gonnard8c40f3d2023-09-28 11:06:09 +0200142
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200143then you can also disable `MBEDTLS_BIGNUM_C`.
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200144
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200145In such builds, all crypto operations via the PSA Crypto API will work as
146usual, as well as the PK, X.509 and TLS modules if `MBEDTLS_USE_PSA_CRYPTO` is
147enabled, with the following exceptions:
148- direct calls to APIs from the disabled modules are not possible;
149- PK, X.509 and TLS will not support restartable ECC operations (see
150 limitation sub-section below).
151
152If you want to check at compile-time whether a certain curve is available in
153the present build of Mbed TLS, regardless of whether ECC is provided by a
154driver or built-in, you should use the following macros:
155- for code that uses only the PSA Crypto API: `PSA_WANT_ECC_xxx` from
156 `psa/crypto.h`;
157- for code that may also use non-PSA crypto APIs: `MBEDTLS_ECP_HAVE_xxx` from
158 `mbedtls/build_info.h` where xxx can take the same values as for
159`MBEDTLS_ECP_DP_xxx` macros.
Valerio Settid31b2842023-08-15 10:59:58 +0200160
Manuel Pégourié-Gonnard140c08e2023-09-28 11:02:37 +0200161Note that for externally-provided drivers, the integrator is responsible for
162ensuring the appropriate `MBEDTLS_PSA_ACCEL_xxx` macros are defined. However,
163for the p256-m driver that's provided with the library, those macros are
164automatically defined when enabling `MBEDTLS_PSA_P256M_DRIVER_ENABLED`.
165
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200166### Limitations regarding fully removing `ecp.c`
167
168A limited subset of `ecp.c` will still be automatically re-enabled if any of
169the following is enabled:
170- `MBEDTLS_PK_PARSE_EC_COMPRESSED` - support for parsing ECC keys where the
171 public part is in compressed format;
172- `MBEDTLS_PK_PARSE_EC_EXTENDED` - support for parsing ECC keys where the
173 curve is identified not by name, but by explicit parameters;
174- `PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE` - support for deterministic
175 derivation of an ECC keypair with `psa_key_derivation_output_key()`.
176
Manuel Pégourié-Gonnard1937cf82023-07-11 11:14:15 +0200177Note: when any of the above options is enabled, a subset of `ecp.c` will
178automatically be included in the build in order to support it. Therefore
179you can still disable `MBEDTLS_ECP_C` in `mbedtls_config.h` and this will
180result in some code size savings, but not as much as when none of the
181above features are enabled.
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200182
183We do have plans to support each of these with `ecp.c` fully removed in the
Manuel Pégourié-Gonnardfb22c272023-07-18 10:40:56 +0200184future, however there is no established timeline. If you're interested, please
185let us know, so we can take it into consideration in our planning.
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200186
187### Limitations regarding restartable / interruptible ECC operations
188
Manuel Pégourié-Gonnard89ae2662023-09-22 13:05:25 +0200189At the moment, there is no driver support for interruptible operations
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200190(see `psa_sign_hash_start()` + `psa_sign_hash_complete()` etc.) so as a
191consequence these are not supported in builds without `MBEDTLS_ECDSA_C`.
192
193Similarly, there is no PSA support for interruptible ECDH operations so these
194are not supported without `ECDH_C`. See also limitations regarding
195restartable operations with `MBEDTLS_USE_PSA_CRYPTO` in [its
196documentation](use-psa-crypto.md).
197
Manuel Pégourié-Gonnardfb22c272023-07-18 10:40:56 +0200198Again, we have plans to support this in the future but not with an established
Manuel Pégourié-Gonnard7a82e272023-07-07 16:43:56 +0200199timeline, please let us know if you're interested.
200
Manuel Pégourié-Gonnardf7dc6cf2023-09-27 10:34:52 +0200201### Limitations regarding "mixed" builds (driver and built-in)
202
203In order for a build to be driver-only (no built-in implementation), all the
204requested algorithms, key types (key operations) and curves must be
205accelerated (plus a few other restrictions, see "Limitations regarding fully
206removing `ecp.c`" above). However, what if you have an accelerator that only
207supports some algorithms, some key types (key operations), or some curves, but
208want to have more enabled in you build?
209
210It is possible to have acceleration for only a subset of the requested
211algorithms. In this case, the built-in implementation of the accelerated
212algorithms will be disabled, provided all the requested curves and key types
213that can be used with this algorithm are also declared as accelerated.
214
215There is very limited support for having acceleration for only a subset of the
216requested key type operations. The only configuration that's tested is that of
217a driver accelerating `PUBLIC_KEY`, `KEY_PAIR_BASIC`, `KEY_PAIR_IMPORT`,
218`KEY_PAIR_EXPORT` but not `KEY_PAIR_GENERATE`. (Note: currently the driver
219interface does not support `KEY_PAIR_DERIVE`.)
220
221There is limited support for having acceleration for only a subset of the
222requested curves. In such builds, only the PSA API is currently tested and
223working; there are known issues in PK, and X.509 and TLS are untested.
224
Manuel Pégourié-Gonnardc9777512023-07-11 11:11:20 +0200225Finite-field Diffie-Hellman
226---------------------------
227
Valerio Settid31b2842023-08-15 10:59:58 +0200228Support is pretty similar to the "Elliptic-curve cryptography (ECC)" section
229above.
230Key management and usage can be enabled by means of the usual `PSA_WANT` +
231`MBEDTLS_PSA_ACCEL` pairs:
232
233- `[PSA_WANT|MBEDTLS_PSA_ACCEL]_KEY_TYPE_DH_PUBLIC_KEY`;
234- `[PSA_WANT|MBEDTLS_PSA_ACCEL]_KEY_TYPE_DH_KEY_PAIR_BASIC`;
235- `[PSA_WANT|MBEDTLS_PSA_ACCEL]_KEY_TYPE_DH_KEY_PAIR_IMPORT`;
236- `[PSA_WANT|MBEDTLS_PSA_ACCEL]_KEY_TYPE_DH_KEY_PAIR_EXPORT`;
237- `[PSA_WANT|MBEDTLS_PSA_ACCEL]_KEY_TYPE_DH_KEY_PAIR_GENERATE`;
238
239The same holds for the associated algorithm:
Valerio Setti7373a662023-09-04 13:59:03 +0200240`[PSA_WANT|MBEDTLS_PSA_ACCEL]_ALG_FFDH` allow builds accelerating FFDH and
Valerio Settid31b2842023-08-15 10:59:58 +0200241removing builtin support (i.e. `MBEDTLS_DHM_C`).
242
Valerio Setti7e11dd62023-12-18 15:52:44 +0100243Ciphers and AEADs
244-----------------
Valerio Setti20e93a22023-12-04 11:29:36 +0100245
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100246It is possible to have all ciphers and AEAD operations provided only by a
Valerio Setti7e11dd62023-12-18 15:52:44 +0100247driver. More precisely, for each desired combination of key type and
248algorithm/mode you can:
249- enable desired PSA key type(s):
250 - `PSA_WANT_KEY_TYPE_AES`,
251 - `PSA_WANT_KEY_TYPE_ARIA`,
252 - `PSA_WANT_KEY_TYPE_CAMELLIA`,
253 - `PSA_WANT_KEY_TYPE_CHACHA20`,
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100254 - `PSA_WANT_KEY_TYPE_DES`.
Valerio Setti7e11dd62023-12-18 15:52:44 +0100255- enable desired PSA algorithm(s):
256 - unauthenticated ciphers modes:
257 - `PSA_WANT_ALG_CBC_NO_PADDING`,
258 - `PSA_WANT_ALG_CBC_PKCS7`,
259 - `PSA_WANT_ALG_CCM_STAR_NO_TAG`,
260 - `PSA_WANT_ALG_CFB`,
261 - `PSA_WANT_ALG_CTR`,
262 - `PSA_WANT_ALG_ECB_NO_PADDING`,
263 - `PSA_WANT_ALG_OFB`,
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100264 - `PSA_WANT_ALG_STREAM_CIPHER`.
Valerio Setti7e11dd62023-12-18 15:52:44 +0100265 - AEADs:
266 - `PSA_WANT_ALG_CCM`,
267 - `PSA_WANT_ALG_GCM`,
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100268 - `PSA_WANT_ALG_CHACHA20_POLY1305`.
Valerio Setti7e11dd62023-12-18 15:52:44 +0100269- enable `MBEDTLS_PSA_ACCEL_[KEY_TYPE_xxx|ALG_yyy]` symbol(s) which correspond
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100270 to the PSA_WANT_KEY_TYPE_xxx` and `PSA_WANT_ALG_yyy` of the previous steps.
Valerio Setti7e11dd62023-12-18 15:52:44 +0100271- disable builtin support of key types:
272 - `MBEDTLS_AES_C`,
273 - `MBEDTLS_ARIA_C`,
274 - `MBEDTLS_CAMELLIA_C`,
275 - `MBEDTLS_DES_C`,
276 - `MBEDTLS_CHACHA20_C`;
277 and algorithms/modes:
278 - `MBEDTLS_CBC_C`
279 - `MBEDTLS_CFB_C`
280 - `MBEDTLS_CTR_C`
281 - `MBEDTLS_OFB_C`
282 - `MBEDTLS_XTS_C`
283 - `MBEDTLS_CCM_C`
284 - `MBEDTLS_GCM_C`
285 - `MBEDTLS_CHACHAPOLY_C`
286 - `MBEDTLS_NULL_CIPHER`
Valerio Settiacd7baf2023-12-06 15:17:12 +0100287
Valerio Setti49067d72023-12-21 17:07:10 +0100288Once a key type and related algorithm are accelerated, all the PSA Crypto APIs
289will work, as well as X.509 and TLS (with MBEDTLS_USE_PSA_CRYPTO enabled) but
290some non-PSA APIs will be absent or have reduced functionality, see
291[Disabling CIPHER_C](#disabling-cipher_c) for details.
Valerio Setti20e93a22023-12-04 11:29:36 +0100292
Valerio Setti66134662023-12-20 17:06:13 +0100293### Restrictions
294
295- If an algorithm other than GCM and CCM (see
296 ["Partial acceleration for CCM/GCM"](#partial-acceleration-for-ccmgcm) below)
297 is enabled but not accelerated, then all key types than can be used with it
298 will need to be built-in;
299- if a key type is enabled but not accelerated, then all algorithms than can be
300 used with it will need to be built-in.
301
Valerio Setti7e11dd62023-12-18 15:52:44 +0100302### Legacy <-> PSA matching
Valerio Setti20e93a22023-12-04 11:29:36 +0100303
Valerio Setti7e11dd62023-12-18 15:52:44 +0100304It should be noticed that the matching between legacy (i.e. `MBEDTLS_xxx_C`)
305and PSA (i.e. `PSA_WANT_xxx`) symbols is not always 1:1. For example:
306- ECB mode is always enabled in legacy configuration for each key type that
307 allows it (AES, ARIA, Camellia, DES), whereas it must be explicitly enabled
Valerio Setti3fab8a42023-12-20 14:25:37 +0100308 in PSA with `PSA_WANT_ALG_ECB_NO_PADDING`;
Valerio Setti7e11dd62023-12-18 15:52:44 +0100309- similarly for stream ciphers, it is automatically enabled for key types that
310 support it (`CHACHA20_C` and `NULL_CIPHER`) whereas it must be explicitly
311 enabled in PSA with `PSA_WANT_ALG_STREAM_CIPHER`;
312- legacy symbol `MBEDTLS_CCM_C` adds support for both cipher and AEAD, whereas
313 in PSA there are 2 different symbols: `PSA_WANT_ALG_CCM_STAR_NO_TAG` and
314 `PSA_WANT_ALG_CCM`, respectively.
315
316### Partial acceleration for CCM/GCM
317
318[This section depends on #8598 so it might updated while that PR progresses.]
319
320In case legacy CCM/GCM algorithms are enabled it is still possible to benefit
321from PSA acceleration by enabling support for ECB mode
322(`PSA_WANT_ALG_ECB_NO_PADDING`) together with desired key type(s)
323(`PSA_WANT_KEY_TYPE_[AES|ARIA|CAMELLIA]`). In such configuration it is possible
324to:
325- still benefit from legacy functions belonging to CCM/GCM modules
326 (`mbedtls_[ccm|gcm]_xxx()`),
327- disable legacy key types (`MBEDTLS_[AES|ARIA|CAMELLIA]_C`) if there is no
328 other dependency requiring them, of course.
329
330ChaChaPoly has not such feature, so it requires full acceleration (key type +
331algorithm) in order to work with a driver.
332
333### CTR-DRBG
334
335Legacy CTR-DRBG module (enabled by `MBEDTLS_CTR_DRBG_C`) can also benefit from
336PSA acceleration when:
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100337- the legacy AES module is not enabled (`MBEDTLS_AES_C`) and
338- AES is supported on the PSA side together with ECB mode, i.e.
Valerio Setti7e11dd62023-12-18 15:52:44 +0100339 `PSA_WANT_KEY_TYPE_AES` + `PSA_WANT_ALG_ECB_NO_PADDING`.
340
341### Disabling CIPHER_C
342
Valerio Settiaf531322023-12-20 15:56:09 +0100343This only depends on unauthenticated ciphers: they can be either completely
344accelerated or disabled in order to remove the dependency on `MBEDTLS_CIPHER_C`.
Valerio Setti7e11dd62023-12-18 15:52:44 +0100345
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100346AEADs do not have such a restriction. Of course they can be accelerated as well,
Valerio Settiaf531322023-12-20 15:56:09 +0100347but they can also rely on the legacy modules (`MBEDTLS_[CCM|GCM|CHACHAPOLY]`)
348with the following conditions on the underlying key types:
349- CCM/GCM can either use legacy key type modules `MBEDTLS_[AES|ARIA|CAMELLIA]_C`
350 or their accelerated version, as described in section
Valerio Setti66134662023-12-20 17:06:13 +0100351 ["Partial acceleration for CCM/GCM"](#partial-acceleration-for-ccmgcm).
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100352- ChaChaPoly instead can only rely on the legacy key type module
353 `MBEDTLS_CHACHA20_C` and algorithm `MBEDTLS_POLY1305_C`.
Valerio Setti7e11dd62023-12-18 15:52:44 +0100354
Valerio Setti8c1e6bb2023-12-21 15:02:48 +0100355It should be noticed that disabling `MBEDTLS_CIPHER_C` helps to reduce the
Valerio Setti49067d72023-12-21 17:07:10 +0100356code's footprint, but unfortunately it makes the following features unavailable:
357- encryption/decryption in PKCS5 and PKCS12 modules (key derivations will still
358 be available),
359- encrypted PEM (write and unecrypted read work normally),
360- parsing of encrypted keys (PKCS5 or PKCS12) in PK modules,
361- NIST-KW (`MBEDTLS_NIST_KW_C`).
Valerio Setti7e11dd62023-12-18 15:52:44 +0100362
Valerio Setti20e93a22023-12-04 11:29:36 +0100363