1a8e1175bSopenharmony_ci# Migrating from Mbed TLS 2.x to Mbed TLS 3.0
2a8e1175bSopenharmony_ci
3a8e1175bSopenharmony_ciThis guide details the steps required to migrate from Mbed TLS version 2.x to
4a8e1175bSopenharmony_ciMbed TLS version 3.0 or greater. Unlike normal releases, Mbed TLS 3.0 breaks
5a8e1175bSopenharmony_cicompatibility with previous versions, so users (and alt implementers) might
6a8e1175bSopenharmony_cineed to change their own code in order to make it work with Mbed TLS 3.0.
7a8e1175bSopenharmony_ci
8a8e1175bSopenharmony_ciHere's the list of breaking changes; each entry should help you answer these
9a8e1175bSopenharmony_citwo questions: (1) am I affected? (2) if yes, what's my migration path?
10a8e1175bSopenharmony_ci
11a8e1175bSopenharmony_ciThe changes are detailed below, and include:
12a8e1175bSopenharmony_ci
13a8e1175bSopenharmony_ci- Removal of many insecure or obsolete features
14a8e1175bSopenharmony_ci- Tidying up of configuration options (including removing some less useful options).
15a8e1175bSopenharmony_ci- Changing function signatures, e.g. adding return codes, adding extra parameters, or making some arguments const.
16a8e1175bSopenharmony_ci- Removal of functions, macros, and types previously marked as deprecated.
17a8e1175bSopenharmony_ci
18a8e1175bSopenharmony_ciMuch of the information needed to determine a migration path can be found in the Mbed TLS 2.x documentation.
19a8e1175bSopenharmony_ci
20a8e1175bSopenharmony_ci
21a8e1175bSopenharmony_ci## Accessing the Mbed TLS 2.x documentation
22a8e1175bSopenharmony_ci
23a8e1175bSopenharmony_ciFor features previously marked as deprecated, Mbed TLS 2.x documentation may
24a8e1175bSopenharmony_ciexplain how to upgrade, and should be referred to when migrating code. Where a
25a8e1175bSopenharmony_cimigration path is not provided in prior documentation, changes made and the
26a8e1175bSopenharmony_ciupgrade steps required will be explained later in this guide.
27a8e1175bSopenharmony_ci
28a8e1175bSopenharmony_ciIt's best to use the latest version of Mbed TLS 2.x for this purpose, which is the 2.28 LTS release.
29a8e1175bSopenharmony_ciSo to generate the documentation, checkout the `mbedtls-2.28` branch and follow
30a8e1175bSopenharmony_cithe instructions in the [Documentation section of the README](https://github.com/Mbed-TLS/mbedtls/blob/mbedtls-2.28/README.md#documentation).
31a8e1175bSopenharmony_ciThen browse `apidoc/deprecated.html` for guidance on upgrading deprecated code.
32a8e1175bSopenharmony_ci
33a8e1175bSopenharmony_ciFor some deprecated functions, 2.x documentation will suggest using a variant
34a8e1175bSopenharmony_cisuffixed with `_ret`. In Mbed TLS 3.x, this change may not be required, as most
35a8e1175bSopenharmony_ciof these variants have been renamed without the suffix. The section
36a8e1175bSopenharmony_ci[Rename mbedtls_*_ret...](#rename-mbedtls__ret-cryptography-functions-whose-deprecated-variants-have-been-removed)
37a8e1175bSopenharmony_cihas further detail on which functions this applies to.
38a8e1175bSopenharmony_ci
39a8e1175bSopenharmony_ci
40a8e1175bSopenharmony_ci## General changes
41a8e1175bSopenharmony_ci
42a8e1175bSopenharmony_ci### Introduce a level of indirection and versioning in the config files
43a8e1175bSopenharmony_ci
44a8e1175bSopenharmony_ci`config.h` was split into `build_info.h` and `mbedtls_config.h`.
45a8e1175bSopenharmony_ci
46a8e1175bSopenharmony_ci* In code, use `#include <mbedtls/build_info.h>`. Don't include `mbedtls/config.h` and don't refer to `MBEDTLS_CONFIG_FILE`.
47a8e1175bSopenharmony_ci* In build tools, edit `mbedtls_config.h`, or edit `MBEDTLS_CONFIG_FILE` as before.
48a8e1175bSopenharmony_ci* If you had a tool that parsed the library version from `include/mbedtls/version.h`, this has moved to `include/mbedtls/build_info.h`. From C code, both headers now define the `MBEDTLS_VERSION_xxx` macros.
49a8e1175bSopenharmony_ci
50a8e1175bSopenharmony_ciAlso, if you have a custom configuration file:
51a8e1175bSopenharmony_ci
52a8e1175bSopenharmony_ci* Don't include `check_config.h` or `config_psa.h` anymore.
53a8e1175bSopenharmony_ci* Don't define `MBEDTLS_CONFIG_H` anymore.
54a8e1175bSopenharmony_ci
55a8e1175bSopenharmony_ciA config file version symbol, `MBEDTLS_CONFIG_VERSION` was introduced.
56a8e1175bSopenharmony_ciDefining it to a particular value will ensure that Mbed TLS interprets
57a8e1175bSopenharmony_cithe config file in a way that's compatible with the config file format
58a8e1175bSopenharmony_ciused by the Mbed TLS release whose `MBEDTLS_VERSION_NUMBER` has the same
59a8e1175bSopenharmony_civalue.
60a8e1175bSopenharmony_ciThe only value supported by Mbed TLS 3.0.0 is `0x03000000`.
61a8e1175bSopenharmony_ci
62a8e1175bSopenharmony_ci### Most structure fields are now private
63a8e1175bSopenharmony_ci
64a8e1175bSopenharmony_ciDirect access to fields of structures (`struct` types) declared in public headers is no longer supported. In Mbed TLS 3, the layout of structures is not considered part of the stable API, and minor versions (3.1, 3.2, etc.) may add, remove, rename, reorder or change the type of structure fields.
65a8e1175bSopenharmony_ci
66a8e1175bSopenharmony_ciThere is a small number of exceptions where some fields are guaranteed to remain stable throughout the lifetime of Mbed TLS 3.x. These fields are explicitly documented as public. Please note that even if all the fields of a structure are public, future versions may add new fields. Also, as before, some public fields should be considered read-only, since modifying them may make the structure inconsistent; check the documentation in each case.
67a8e1175bSopenharmony_ci
68a8e1175bSopenharmony_ciAttempting to access a private field directly will result in a compilation error.
69a8e1175bSopenharmony_ci
70a8e1175bSopenharmony_ciIf you were accessing structure fields directly, and these fields are not documented as public, you need to change your code. If an accessor (getter/setter) function exists, use that. Direct accessor functions are usually called `mbedtls_<MODULE>_{get,set}_<FIELD>` or `mbedtls_<MODULE>_<STRUCTURE>_{get,set}_<FIELD>`. Accessor functions that change the format may use different verbs, for example `read`/`write` for functions that import/export data from/to a text or byte string.
71a8e1175bSopenharmony_ci
72a8e1175bSopenharmony_ciIf no accessor function exists, please open an [enhancement request against Mbed TLS](https://github.com/Mbed-TLS/mbedtls/issues/new?template=feature_request.md) and describe your use case. The Mbed TLS development team is aware that some useful accessor functions are missing in the 3.0 release, and we expect to add them to the first minor release(s) (3.1, etc.).
73a8e1175bSopenharmony_ci
74a8e1175bSopenharmony_ciAs a last resort, you can access the field `foo` of a structure `bar` by writing `bar.MBEDTLS_PRIVATE(foo)`. Note that you do so at your own risk, since such code is likely to break in a future minor version of Mbed TLS.
75a8e1175bSopenharmony_ci
76a8e1175bSopenharmony_ci### Move part of timing module out of the library
77a8e1175bSopenharmony_ci
78a8e1175bSopenharmony_ciThe change affects users who use any of the following functions:
79a8e1175bSopenharmony_ci`mbedtls_timing_self_test()`, `mbedtls_hardclock_poll()`,
80a8e1175bSopenharmony_ci`mbedtls_timing_hardclock()` and `mbedtls_set_alarm()`.
81a8e1175bSopenharmony_ci
82a8e1175bSopenharmony_ciIf you were relying on these functions, you'll now need to change to using your
83a8e1175bSopenharmony_ciplatform's corresponding functions directly.
84a8e1175bSopenharmony_ci
85a8e1175bSopenharmony_ci### Deprecated net.h file was removed
86a8e1175bSopenharmony_ci
87a8e1175bSopenharmony_ciThe file `include/mbedtls/net.h` was removed because its only function was to
88a8e1175bSopenharmony_ciinclude `mbedtls/net_sockets.h` which now should be included directly.
89a8e1175bSopenharmony_ci
90a8e1175bSopenharmony_ci### Remove `MBEDTLS_CHECK_PARAMS` option
91a8e1175bSopenharmony_ci
92a8e1175bSopenharmony_ciThis change does not affect users who use the default configuration; it only
93a8e1175bSopenharmony_ciaffects users who enabled that option.
94a8e1175bSopenharmony_ci
95a8e1175bSopenharmony_ciThe option `MBEDTLS_CHECK_PARAMS` (disabled by default) enabled certain kinds
96a8e1175bSopenharmony_ciof “parameter validation”. It covered two kinds of validations:
97a8e1175bSopenharmony_ci
98a8e1175bSopenharmony_ci- In some functions that require a valid pointer, “parameter validation” checks
99a8e1175bSopenharmony_cithat the pointer is non-null. With the feature disabled, a null pointer is not
100a8e1175bSopenharmony_citreated differently from any other invalid pointer, and typically leads to a
101a8e1175bSopenharmony_ciruntime crash. 90% of the uses of the feature are of this kind.
102a8e1175bSopenharmony_ci- In some functions that take an enum-like argument, “parameter validation”
103a8e1175bSopenharmony_cichecks that the value is a valid one. With the feature disabled, an invalid
104a8e1175bSopenharmony_civalue causes a silent default to one of the valid values.
105a8e1175bSopenharmony_ci
106a8e1175bSopenharmony_ciThe default reaction to a failed check was to call a function
107a8e1175bSopenharmony_ci`mbedtls_param_failed()` which the application had to provide. If this function
108a8e1175bSopenharmony_cireturned, its caller returned an error `MBEDTLS_ERR_xxx_BAD_INPUT_DATA`.
109a8e1175bSopenharmony_ci
110a8e1175bSopenharmony_ciThis feature was only used in some classic (non-PSA) cryptography modules. It was
111a8e1175bSopenharmony_cinot used in X.509, TLS or in PSA crypto, and it was not implemented in all
112a8e1175bSopenharmony_ciclassic crypto modules.
113a8e1175bSopenharmony_ci
114a8e1175bSopenharmony_ciThis feature has been removed. The library no longer checks for NULL pointers;
115a8e1175bSopenharmony_cichecks for enum-like arguments will be kept or re-introduced on a case-by-case
116a8e1175bSopenharmony_cibasis, but their presence will no longer be dependent on a compile-time option.
117a8e1175bSopenharmony_ci
118a8e1175bSopenharmony_ciValidation of enum-like values is somewhat useful, but not extremely important,
119a8e1175bSopenharmony_cibecause the parameters concerned are usually constants in applications.
120a8e1175bSopenharmony_ci
121a8e1175bSopenharmony_ciFor more information see issue #4313.
122a8e1175bSopenharmony_ci
123a8e1175bSopenharmony_ci### Remove the `MBEDTLS_TEST_NULL_ENTROPY` configuration option
124a8e1175bSopenharmony_ci
125a8e1175bSopenharmony_ciThis does not affect users who use the default `mbedtls_config.h`, as this option was
126a8e1175bSopenharmony_cialready off by default.
127a8e1175bSopenharmony_ci
128a8e1175bSopenharmony_ciIf you were using the `MBEDTLS_TEST_NULL_ENTROPY` option and your platform
129a8e1175bSopenharmony_cidoesn't have any entropy source, you should use `MBEDTLS_ENTROPY_NV_SEED`
130a8e1175bSopenharmony_ciand make sure your device is provisioned with a strong random seed.
131a8e1175bSopenharmony_ciAlternatively, for testing purposes only, you can create and register a fake
132a8e1175bSopenharmony_cientropy function.
133a8e1175bSopenharmony_ci
134a8e1175bSopenharmony_ci### Remove the HAVEGE module
135a8e1175bSopenharmony_ci
136a8e1175bSopenharmony_ciThis doesn't affect people using the default configuration as it was already
137a8e1175bSopenharmony_cidisabled by default.
138a8e1175bSopenharmony_ci
139a8e1175bSopenharmony_ciThis only affects users who called the HAVEGE modules directly (not
140a8e1175bSopenharmony_cirecommended), or users who used it through the entropy module but had it as the
141a8e1175bSopenharmony_cionly source of entropy. If you're in that case, please declare OS or hardware
142a8e1175bSopenharmony_ciRNG interfaces with `mbedtls_entropy_add_source()` and/or use an entropy seed
143a8e1175bSopenharmony_cifile created securely during device provisioning. See
144a8e1175bSopenharmony_ci<https://mbed-tls.readthedocs.io/en/latest/kb/how-to/add-entropy-sources-to-entropy-pool> for more
145a8e1175bSopenharmony_ciinformation.
146a8e1175bSopenharmony_ci
147a8e1175bSopenharmony_ci### Remove helpers for the transition from Mbed TLS 1.3 to Mbed TLS 2.0
148a8e1175bSopenharmony_ci
149a8e1175bSopenharmony_ciThis only affects people who've been using Mbed TLS since before version 2.0
150a8e1175bSopenharmony_ciand still relied on `compat-1.3.h` in their code.
151a8e1175bSopenharmony_ci
152a8e1175bSopenharmony_ciPlease use the new names directly in your code; `scripts/rename.pl` (from any
153a8e1175bSopenharmony_ciof the 2.x releases — no longer included in 3.0) might help you do that.
154a8e1175bSopenharmony_ci
155a8e1175bSopenharmony_ci
156a8e1175bSopenharmony_ci## Low-level crypto
157a8e1175bSopenharmony_ci
158a8e1175bSopenharmony_ciPlease also refer to the section [High-level crypto](#high-level-crypto) for
159a8e1175bSopenharmony_cichanges that could sit in either category.
160a8e1175bSopenharmony_ci
161a8e1175bSopenharmony_ci### Deprecated functions were removed from bignum
162a8e1175bSopenharmony_ci
163a8e1175bSopenharmony_ciThe function `mbedtls_mpi_is_prime()` was removed. Please use
164a8e1175bSopenharmony_ci`mbedtls_mpi_is_prime_ext()` instead which additionally allows specifying the
165a8e1175bSopenharmony_cinumber of Miller-Rabin rounds.
166a8e1175bSopenharmony_ci
167a8e1175bSopenharmony_ci### Deprecated functions were removed from DRBGs
168a8e1175bSopenharmony_ci
169a8e1175bSopenharmony_ciThe functions `mbedtls_ctr_drbg_update_ret()` and `mbedtls_hmac_drbg_update_ret()`
170a8e1175bSopenharmony_ciwere renamed to replace the corresponding functions without `_ret` appended. Please call
171a8e1175bSopenharmony_cithe name without `_ret` appended and check the return value.
172a8e1175bSopenharmony_ci
173a8e1175bSopenharmony_ci### Deprecated hex-encoded primes were removed from DHM
174a8e1175bSopenharmony_ci
175a8e1175bSopenharmony_ciThe macros `MBEDTLS_DHM_RFC5114_MODP_2048_P`, `MBEDTLS_DHM_RFC5114_MODP_2048_G`,
176a8e1175bSopenharmony_ci`MBEDTLS_DHM_RFC3526_MODP_2048_P`, `MBEDTLS_DHM_RFC3526_MODP_2048_G`,
177a8e1175bSopenharmony_ci`MBEDTLS_DHM_RFC3526_MODP_3072_P`, `MBEDTLS_DHM_RFC3526_MODP_3072_G`,
178a8e1175bSopenharmony_ci`MBEDTLS_DHM_RFC3526_MODP_4096_P `and `MBEDTLS_DHM_RFC3526_MODP_4096_G` were
179a8e1175bSopenharmony_ciremoved. The primes from RFC 5114 are deprecated because their derivation is not
180a8e1175bSopenharmony_cidocumented and therefore their usage constitutes a security risk; they are fully
181a8e1175bSopenharmony_ciremoved from the library. Please use parameters from RFC 3526 (still in the
182a8e1175bSopenharmony_cilibrary, only in binary form) or RFC 7919 (also available in the library) or
183a8e1175bSopenharmony_ciother trusted sources instead.
184a8e1175bSopenharmony_ci
185a8e1175bSopenharmony_ci### Deprecated functions were removed from hashing modules
186a8e1175bSopenharmony_ci
187a8e1175bSopenharmony_ciModules: MD5, SHA1, SHA256, SHA512, MD.
188a8e1175bSopenharmony_ci
189a8e1175bSopenharmony_ci- The functions `mbedtls_xxx_starts_ret()`, `mbedtls_xxx_update_ret()`,
190a8e1175bSopenharmony_ci  `mbedtls_xxx_finish_ret()` and `mbedtls_xxx_ret()` were renamed to replace
191a8e1175bSopenharmony_ci  the corresponding functions without `_ret` appended. Please call the name without `_ret` appended and check the return value.
192a8e1175bSopenharmony_ci- The function `mbedtls_md_init_ctx()` was removed; please use
193a8e1175bSopenharmony_ci  `mbedtls_md_setup()` instead.
194a8e1175bSopenharmony_ci- The functions `mbedtls_xxx_process()` were removed. You normally don't need
195a8e1175bSopenharmony_ci  to call that from application code. However if you do (or if you want to
196a8e1175bSopenharmony_ci  provide your own version of that function), please use
197a8e1175bSopenharmony_ci  `mbedtls_internal_xxx_process()` instead, and check the return value.
198a8e1175bSopenharmony_ci
199a8e1175bSopenharmony_ci### Change `MBEDTLS_ECP_FIXED_POINT_OPTIM` behavior
200a8e1175bSopenharmony_ci
201a8e1175bSopenharmony_ciThe option `MBEDTLS_ECP_FIXED_POINT_OPTIM` now increases code size and it does
202a8e1175bSopenharmony_cinot increase peak RAM usage anymore.
203a8e1175bSopenharmony_ci
204a8e1175bSopenharmony_ciIf you are limited by code size, you can define `MBEDTLS_ECP_FIXED_POINT_OPTIM`
205a8e1175bSopenharmony_cito `0` in your config file. The impact depends on the number and size of
206a8e1175bSopenharmony_cienabled curves. For example, for P-256 the difference is 1KB; see the documentation
207a8e1175bSopenharmony_ciof this option for details.
208a8e1175bSopenharmony_ci
209a8e1175bSopenharmony_ci### Separated `MBEDTLS_SHA224_C` and `MBEDTLS_SHA256_C`
210a8e1175bSopenharmony_ci
211a8e1175bSopenharmony_ciThis does not affect users who use the default `mbedtls_config.h`. `MBEDTLS_SHA256_C`
212a8e1175bSopenharmony_ciwas enabled by default. Now both `MBEDTLS_SHA256_C` and `MBEDTLS_SHA224_C` are
213a8e1175bSopenharmony_cienabled.
214a8e1175bSopenharmony_ci
215a8e1175bSopenharmony_ciIf you were using custom config file with `MBEDTLS_SHA256_C` enabled, then
216a8e1175bSopenharmony_ciyou will need to add `#define MBEDTLS_SHA224_C` option to your config.
217a8e1175bSopenharmony_ciCurrent version of the library does not support enabling `MBEDTLS_SHA256_C`
218a8e1175bSopenharmony_ciwithout `MBEDTLS_SHA224_C`.
219a8e1175bSopenharmony_ci
220a8e1175bSopenharmony_ci### Replaced `MBEDTLS_SHA512_NO_SHA384` with `MBEDTLS_SHA384_C`
221a8e1175bSopenharmony_ci
222a8e1175bSopenharmony_ciThis does not affect users who use the default `mbedtls_config.h`.
223a8e1175bSopenharmony_ci`MBEDTLS_SHA512_NO_SHA384` was disabled by default, now `MBEDTLS_SHA384_C` is
224a8e1175bSopenharmony_cienabled by default.
225a8e1175bSopenharmony_ci
226a8e1175bSopenharmony_ciIf you were using a config file with both `MBEDTLS_SHA512_C` and
227a8e1175bSopenharmony_ciMBEDTLS_SHA512_NO_SHA384, then just remove the `MBEDTLS_SHA512_NO_SHA384`.
228a8e1175bSopenharmony_ciIf you were using a config file with `MBEDTLS_SHA512_C` and without
229a8e1175bSopenharmony_ci`MBEDTLS_SHA512_NO_SHA384` and you need the SHA-384 algorithm, then add
230a8e1175bSopenharmony_ci`#define MBEDTLS_SHA384_C` to your config file.
231a8e1175bSopenharmony_ci
232a8e1175bSopenharmony_ci### GCM multipart interface: application changes
233a8e1175bSopenharmony_ci
234a8e1175bSopenharmony_ciThe GCM module now supports arbitrary chunked input in the multipart interface.
235a8e1175bSopenharmony_ciThis changes the interface for applications using the GCM module directly for multipart operations.
236a8e1175bSopenharmony_ciApplications using one-shot GCM or using GCM via the `mbedtls_cipher_xxx` or `psa_aead_xxx` interfaces do not require any changes.
237a8e1175bSopenharmony_ci
238a8e1175bSopenharmony_ci* `mbedtls_gcm_starts()` now only sets the mode and the nonce (IV). Call the new function `mbedtls_gcm_update_ad()` to pass the associated data.
239a8e1175bSopenharmony_ci* `mbedtls_gcm_update()` now takes an extra parameter to indicate the actual output length. In Mbed TLS 2.x, applications had to pass inputs consisting of whole 16-byte blocks except for the last block (this limitation has been lifted). In this case:
240a8e1175bSopenharmony_ci    * As long as the input remains block-aligned, the output length is exactly the input length, as before.
241a8e1175bSopenharmony_ci    * If the length of the last input is not a multiple of 16, alternative implementations may return the last partial block in the call to `mbedtls_gcm_finish()` instead of returning it in the last call to `mbedtls_gcm_update()`.
242a8e1175bSopenharmony_ci* `mbedtls_gcm_finish()` now takes an extra output buffer for the last partial block. This is needed for alternative implementations that can only process a whole block at a time.
243a8e1175bSopenharmony_ci
244a8e1175bSopenharmony_ci### GCM interface changes: impact for alternative implementations
245a8e1175bSopenharmony_ci
246a8e1175bSopenharmony_ciThe GCM multipart interface has changed as described in [“GCM multipart interface: application changes”](#gcm-multipart-interface-application-changes). The consequences for an alternative implementation of GCM (`MBEDTLS_GCM_ALT`) are as follows:
247a8e1175bSopenharmony_ci
248a8e1175bSopenharmony_ci* `mbedtls_gcm_starts()` now only sets the mode and the nonce (IV). The new function `mbedtls_gcm_update_ad()` receives the associated data. It may be called multiple times.
249a8e1175bSopenharmony_ci* `mbedtls_gcm_update()` now allows arbitrary-length inputs, takes an extra parameter to indicate the actual output length. Alternative implementations may choose between two modes:
250a8e1175bSopenharmony_ci    * Always return the partial output immediately, even if it does not consist of a whole number of blocks.
251a8e1175bSopenharmony_ci    * Buffer the data for the last partial block, to be returned in the next call to `mbedtls_gcm_update()` or `mbedtls_gcm_finish()`.
252a8e1175bSopenharmony_ci* `mbedtls_gcm_finish()` now takes an extra output buffer for the last partial block if needed.
253a8e1175bSopenharmony_ci
254a8e1175bSopenharmony_ci### The configuration option `MBEDTLS_ECP_NO_INTERNAL_RNG` was removed
255a8e1175bSopenharmony_ci
256a8e1175bSopenharmony_ciThis doesn't affect users of the default configuration; it only affects people
257a8e1175bSopenharmony_ciwho were explicitly setting this option.
258a8e1175bSopenharmony_ci
259a8e1175bSopenharmony_ciThis was a trade-off between code size and countermeasures; it is no longer
260a8e1175bSopenharmony_cirelevant as the countermeasure is now always on at no cost in code size.
261a8e1175bSopenharmony_ci
262a8e1175bSopenharmony_ci### SHA-512 and SHA-256 output type change
263a8e1175bSopenharmony_ci
264a8e1175bSopenharmony_ciThe output parameter of `mbedtls_sha256_finish()`, `mbedtls_sha256()`, `mbedtls_sha512_finish()`, `mbedtls_sha512()` now has a pointer type rather than array type. This makes no difference in terms of C semantics, but removes spurious warnings in some compilers when outputting a SHA-384 hash into a 48-byte buffer or a SHA-224 hash into a 28-byte buffer.
265a8e1175bSopenharmony_ci
266a8e1175bSopenharmony_ciThis makes no difference to a vast majority of applications. If your code takes a pointer to one of these functions, you may need to change the type of the pointer.
267a8e1175bSopenharmony_ci
268a8e1175bSopenharmony_ciAlternative implementations of the SHA256 and SHA512 modules must adjust their functions' prototype accordingly.
269a8e1175bSopenharmony_ci
270a8e1175bSopenharmony_ci### Deprecated error codes for hardware failures were removed
271a8e1175bSopenharmony_ci
272a8e1175bSopenharmony_ci- The macros `MBEDTLS_ERR_xxx_FEATURE_UNAVAILABLE` from various crypto modules
273a8e1175bSopenharmony_ci  were removed; `MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED` is now used
274a8e1175bSopenharmony_ci  instead.
275a8e1175bSopenharmony_ci- The macro `MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION` was removed;
276a8e1175bSopenharmony_ci  `MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED` is now used instead.
277a8e1175bSopenharmony_ci- The macros `MBEDTLS_ERR_xxx_HW_ACCEL_FAILED` from various crypto modules
278a8e1175bSopenharmony_ci  were removed; `MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED` is now used instead.
279a8e1175bSopenharmony_ci
280a8e1175bSopenharmony_ci### Deprecated error codes for invalid input data were removed
281a8e1175bSopenharmony_ci
282a8e1175bSopenharmony_ci- The macros `MBEDTLS_ERR_xxx_INVALID_KEY_LENGTH` from ARIA and Camellia
283a8e1175bSopenharmony_ci  modules were removed; `MBEDTLS_ERR_xxx_BAD_INPUT_DATA` is now used instead.
284a8e1175bSopenharmony_ci
285a8e1175bSopenharmony_ci### Remove the mode parameter from RSA functions
286a8e1175bSopenharmony_ci
287a8e1175bSopenharmony_ciThis affects all users who use the RSA encrypt, decrypt, sign and
288a8e1175bSopenharmony_civerify APIs.
289a8e1175bSopenharmony_ci
290a8e1175bSopenharmony_ciThe RSA module no longer supports private-key operations with the public key or
291a8e1175bSopenharmony_civice versa. As a consequence, RSA operation functions no longer have a mode
292a8e1175bSopenharmony_ciparameter. If you were calling RSA operations with the normal mode (public key
293a8e1175bSopenharmony_cifor verification or encryption, private key for signature or decryption), remove
294a8e1175bSopenharmony_cithe `MBEDTLS_RSA_PUBLIC` or `MBEDTLS_RSA_PRIVATE` argument. If you were calling
295a8e1175bSopenharmony_ciRSA operations with the wrong mode, which rarely makes sense from a security
296a8e1175bSopenharmony_ciperspective, this is no longer supported.
297a8e1175bSopenharmony_ci
298a8e1175bSopenharmony_ci### Deprecated functions were removed from AES
299a8e1175bSopenharmony_ci
300a8e1175bSopenharmony_ciThe functions `mbedtls_aes_encrypt()` and `mbedtls_aes_decrypt()` were
301a8e1175bSopenharmony_ciremoved.
302a8e1175bSopenharmony_ci
303a8e1175bSopenharmony_ciIf you're simply using the AES module, you should be calling the higher-level
304a8e1175bSopenharmony_cifunctions `mbedtls_aes_crypt_xxx()`.
305a8e1175bSopenharmony_ci
306a8e1175bSopenharmony_ciIf you're providing an alternative implementation using
307a8e1175bSopenharmony_ci`MBEDTLS_AES_ENCRYPT_ALT` or `MBEDTLS_AES_DECRYPT_ALT`, you should be
308a8e1175bSopenharmony_cireplacing the removed functions with `mbedtls_internal_aes_encrypt()` and
309a8e1175bSopenharmony_ci`mbedtls_internal_aes_decrypt()` respectively.
310a8e1175bSopenharmony_ci
311a8e1175bSopenharmony_ci### Deprecated functions were removed from ECDSA
312a8e1175bSopenharmony_ci
313a8e1175bSopenharmony_ciThe functions `mbedtls_ecdsa_write_signature_det()` and
314a8e1175bSopenharmony_ci`mbedtls_ecdsa_sign_det()` were removed. They were superseded by
315a8e1175bSopenharmony_ci`mbedtls_ecdsa_write_signature()` and `mbedtls_ecdsa_sign_det_ext()`
316a8e1175bSopenharmony_cirespectively.
317a8e1175bSopenharmony_ci
318a8e1175bSopenharmony_ci### Rename `mbedtls_*_ret()` cryptography functions whose deprecated variants have been removed
319a8e1175bSopenharmony_ci
320a8e1175bSopenharmony_ciThis change affects users who were using the `mbedtls_*_ret()` cryptography
321a8e1175bSopenharmony_cifunctions.
322a8e1175bSopenharmony_ci
323a8e1175bSopenharmony_ciThose functions were created based on now-deprecated functions according to a
324a8e1175bSopenharmony_cirequirement that a function needs to return a value. This change brings back the
325a8e1175bSopenharmony_cioriginal names of those functions. The renamed functions are:
326a8e1175bSopenharmony_ci
327a8e1175bSopenharmony_ci| name before this change        | after the change           |
328a8e1175bSopenharmony_ci|--------------------------------|----------------------------|
329a8e1175bSopenharmony_ci| `mbedtls_ctr_drbg_update_ret`  | `mbedtls_ctr_drbg_update`  |
330a8e1175bSopenharmony_ci| `mbedtls_hmac_drbg_update_ret` | `mbedtls_hmac_drbg_update` |
331a8e1175bSopenharmony_ci| `mbedtls_md5_starts_ret`       | `mbedtls_md5_starts`       |
332a8e1175bSopenharmony_ci| `mbedtls_md5_update_ret`       | `mbedtls_md5_update`       |
333a8e1175bSopenharmony_ci| `mbedtls_md5_finish_ret`       | `mbedtls_md5_finish`       |
334a8e1175bSopenharmony_ci| `mbedtls_md5_ret`              | `mbedtls_md5`              |
335a8e1175bSopenharmony_ci| `mbedtls_ripemd160_starts_ret` | `mbedtls_ripemd160_starts` |
336a8e1175bSopenharmony_ci| `mbedtls_ripemd160_update_ret` | `mbedtls_ripemd160_update` |
337a8e1175bSopenharmony_ci| `mbedtls_ripemd160_finish_ret` | `mbedtls_ripemd160_finish` |
338a8e1175bSopenharmony_ci| `mbedtls_ripemd160_ret`        | `mbedtls_ripemd160`        |
339a8e1175bSopenharmony_ci| `mbedtls_sha1_starts_ret`      | `mbedtls_sha1_starts`      |
340a8e1175bSopenharmony_ci| `mbedtls_sha1_update_ret`      | `mbedtls_sha1_update`      |
341a8e1175bSopenharmony_ci| `mbedtls_sha1_finish_ret`      | `mbedtls_sha1_finish`      |
342a8e1175bSopenharmony_ci| `mbedtls_sha1_ret`             | `mbedtls_sha1`             |
343a8e1175bSopenharmony_ci| `mbedtls_sha256_starts_ret`    | `mbedtls_sha256_starts`    |
344a8e1175bSopenharmony_ci| `mbedtls_sha256_update_ret`    | `mbedtls_sha256_update`    |
345a8e1175bSopenharmony_ci| `mbedtls_sha256_finish_ret`    | `mbedtls_sha256_finish`    |
346a8e1175bSopenharmony_ci| `mbedtls_sha256_ret`           | `mbedtls_sha256`           |
347a8e1175bSopenharmony_ci| `mbedtls_sha512_starts_ret`    | `mbedtls_sha512_starts`    |
348a8e1175bSopenharmony_ci| `mbedtls_sha512_update_ret`    | `mbedtls_sha512_update`    |
349a8e1175bSopenharmony_ci| `mbedtls_sha512_finish_ret`    | `mbedtls_sha512_finish`    |
350a8e1175bSopenharmony_ci| `mbedtls_sha512_ret`           | `mbedtls_sha512`           |
351a8e1175bSopenharmony_ci
352a8e1175bSopenharmony_ciTo migrate to the this change the user can keep the `*_ret` names in their code
353a8e1175bSopenharmony_ciand include the `compat_2.x.h` header file which holds macros with proper
354a8e1175bSopenharmony_cirenaming or to rename those functions in their code according to the list from
355a8e1175bSopenharmony_cimentioned header file.
356a8e1175bSopenharmony_ci
357a8e1175bSopenharmony_ci### Remove the RNG parameter from RSA verify functions
358a8e1175bSopenharmony_ci
359a8e1175bSopenharmony_ciRSA verification functions also no longer take random generator arguments (this
360a8e1175bSopenharmony_ciwas only needed when using a private key). This affects all applications using
361a8e1175bSopenharmony_cithe RSA verify functions.
362a8e1175bSopenharmony_ci
363a8e1175bSopenharmony_ci### Remove the padding parameters from `mbedtls_rsa_init()`
364a8e1175bSopenharmony_ci
365a8e1175bSopenharmony_ciThis affects all users who use the RSA encrypt, decrypt, sign and
366a8e1175bSopenharmony_civerify APIs.
367a8e1175bSopenharmony_ci
368a8e1175bSopenharmony_ciThe function `mbedtls_rsa_init()` no longer supports selecting the PKCS#1 v2.1
369a8e1175bSopenharmony_ciencoding and its hash. It just selects the PKCS#1 v1.5 encoding by default. If
370a8e1175bSopenharmony_ciyou were using the PKCS#1 v2.1 encoding you now need, subsequently to the call
371a8e1175bSopenharmony_cito `mbedtls_rsa_init()`, to call `mbedtls_rsa_set_padding()` to set it.
372a8e1175bSopenharmony_ci
373a8e1175bSopenharmony_ciTo choose the padding type when initializing a context, instead of
374a8e1175bSopenharmony_ci
375a8e1175bSopenharmony_ci```C
376a8e1175bSopenharmony_ci    mbedtls_rsa_init(ctx, padding, hash_id);
377a8e1175bSopenharmony_ci```
378a8e1175bSopenharmony_ci
379a8e1175bSopenharmony_ciuse
380a8e1175bSopenharmony_ci
381a8e1175bSopenharmony_ci```C
382a8e1175bSopenharmony_ci    mbedtls_rsa_init(ctx);
383a8e1175bSopenharmony_ci    mbedtls_rsa_set_padding(ctx, padding, hash_id);
384a8e1175bSopenharmony_ci```
385a8e1175bSopenharmony_ci
386a8e1175bSopenharmony_ciTo use PKCS#1 v1.5 padding, instead of
387a8e1175bSopenharmony_ci
388a8e1175bSopenharmony_ci```C
389a8e1175bSopenharmony_ci    mbedtls_rsa_init(ctx, MBEDTLS_RSA_PKCS_V15, <ignored>);
390a8e1175bSopenharmony_ci```
391a8e1175bSopenharmony_ci
392a8e1175bSopenharmony_cijust use
393a8e1175bSopenharmony_ci
394a8e1175bSopenharmony_ci```C
395a8e1175bSopenharmony_ci    mbedtls_rsa_init(ctx);
396a8e1175bSopenharmony_ci```
397a8e1175bSopenharmony_ci
398a8e1175bSopenharmony_ci
399a8e1175bSopenharmony_ci## High-level crypto
400a8e1175bSopenharmony_ci
401a8e1175bSopenharmony_ciPlease also refer to the section [Low-level crypto](#low-level-crypto) for
402a8e1175bSopenharmony_cichanges that could sit in either category.
403a8e1175bSopenharmony_ci
404a8e1175bSopenharmony_ci### Calling `mbedtls_cipher_finish()` is mandatory for all multi-part operations
405a8e1175bSopenharmony_ci
406a8e1175bSopenharmony_ciThis only affects people who use the cipher module to perform AEAD operations
407a8e1175bSopenharmony_ciusing the multi-part API.
408a8e1175bSopenharmony_ci
409a8e1175bSopenharmony_ciPreviously, the documentation didn't state explicitly if it was OK to call
410a8e1175bSopenharmony_ci`mbedtls_cipher_check_tag()` or `mbedtls_cipher_write_tag()` directly after
411a8e1175bSopenharmony_cithe last call to `mbedtls_cipher_update()` — that is, without calling
412a8e1175bSopenharmony_ci`mbedtls_cipher_finish()` in-between. If you code was missing that call,
413a8e1175bSopenharmony_ciplease add it and be prepared to get as much as 15 bytes of output.
414a8e1175bSopenharmony_ci
415a8e1175bSopenharmony_ciCurrently the output is always 0 bytes, but it may be more when alternative
416a8e1175bSopenharmony_ciimplementations of the underlying primitives are in use, or with future
417a8e1175bSopenharmony_civersions of the library.
418a8e1175bSopenharmony_ci
419a8e1175bSopenharmony_ci### Remove MD2, MD4, RC4, Blowfish and XTEA algorithms
420a8e1175bSopenharmony_ci
421a8e1175bSopenharmony_ciThis change affects users of the MD2, MD4, RC4, Blowfish and XTEA algorithms.
422a8e1175bSopenharmony_ci
423a8e1175bSopenharmony_ciThey are already niche or obsolete and most of them are weak or broken. For
424a8e1175bSopenharmony_cithose reasons possible users should consider switching to modern and safe
425a8e1175bSopenharmony_cialternatives to be found in literature.
426a8e1175bSopenharmony_ci
427a8e1175bSopenharmony_ci### Deprecated functions were removed from cipher
428a8e1175bSopenharmony_ci
429a8e1175bSopenharmony_ciThe functions `mbedtls_cipher_auth_encrypt()` and
430a8e1175bSopenharmony_ci`mbedtls_cipher_auth_decrypt()` were removed. They were superseded by
431a8e1175bSopenharmony_ci`mbedtls_cipher_auth_encrypt_ext()` and `mbedtls_cipher_auth_decrypt_ext()`
432a8e1175bSopenharmony_cirespectively which additionally support key wrapping algorithms such as
433a8e1175bSopenharmony_ciNIST_KW.
434a8e1175bSopenharmony_ci
435a8e1175bSopenharmony_ci### Extra parameter for the output buffer size
436a8e1175bSopenharmony_ci
437a8e1175bSopenharmony_ciThe following functions now take an extra parameter indicating the size of the output buffer:
438a8e1175bSopenharmony_ci
439a8e1175bSopenharmony_ci* `mbedtls_ecdsa_write_signature()`, `mbedtls_ecdsa_write_signature_restartable()`
440a8e1175bSopenharmony_ci* `mbedtls_pk_sign()`, `mbedtls_pk_sign_restartable()`
441a8e1175bSopenharmony_ci
442a8e1175bSopenharmony_ciThe requirements for the output buffer have not changed, but passing a buffer that is too small now reliably causes the functions to return an error, rather than overflowing the buffer.
443a8e1175bSopenharmony_ci
444a8e1175bSopenharmony_ci### Signature functions now require the hash length to match the expected value
445a8e1175bSopenharmony_ci
446a8e1175bSopenharmony_ciThis affects users of the PK API as well as users of the low-level API in the RSA module. Users of the PSA API or of the ECDSA module are unaffected.
447a8e1175bSopenharmony_ci
448a8e1175bSopenharmony_ciAll the functions in the RSA module that accept a `hashlen` parameter used to
449a8e1175bSopenharmony_ciignore it unless the `md_alg` parameter was `MBEDTLS_MD_NONE`, indicating raw
450a8e1175bSopenharmony_cidata was signed. The `hashlen` parameter is now always the size that is read
451a8e1175bSopenharmony_cifrom the `hash` input buffer. This length must be equal to the output size of
452a8e1175bSopenharmony_cithe hash algorithm used when signing a hash. (The requirements when signing
453a8e1175bSopenharmony_ciraw data are unchanged.) This affects the following functions:
454a8e1175bSopenharmony_ci
455a8e1175bSopenharmony_ci* `mbedtls_rsa_pkcs1_sign`, `mbedtls_rsa_pkcs1_verify`
456a8e1175bSopenharmony_ci* `mbedtls_rsa_rsassa_pkcs1_v15_sign`, `mbedtls_rsa_rsassa_pkcs1_v15_verify`
457a8e1175bSopenharmony_ci* `mbedtls_rsa_rsassa_pss_sign`, `mbedtls_rsa_rsassa_pss_verify`
458a8e1175bSopenharmony_ci* `mbedtls_rsa_rsassa_pss_sign_ext`, `mbedtls_rsa_rsassa_pss_verify_ext`
459a8e1175bSopenharmony_ci
460a8e1175bSopenharmony_ciThe signature functions in the PK module no longer accept 0 as the `hash_len` parameter. The `hash_len` parameter is now always the size that is read from the `hash` input buffer. This affects the following functions:
461a8e1175bSopenharmony_ci
462a8e1175bSopenharmony_ci* `mbedtls_pk_sign`, `mbedtls_pk_verify`
463a8e1175bSopenharmony_ci* `mbedtls_pk_sign_restartable`, `mbedtls_pk_verify_restartable`
464a8e1175bSopenharmony_ci* `mbedtls_pk_verify_ext`
465a8e1175bSopenharmony_ci
466a8e1175bSopenharmony_ciThe migration path is to pass the correct value to those functions.
467a8e1175bSopenharmony_ci
468a8e1175bSopenharmony_ci### Some function parameters were made const
469a8e1175bSopenharmony_ci
470a8e1175bSopenharmony_ciVarious functions in the PK and ASN.1 modules had a `const` qualifier added to
471a8e1175bSopenharmony_cisome of their parameters.
472a8e1175bSopenharmony_ci
473a8e1175bSopenharmony_ciThis normally doesn't affect your code, unless you use pointers to reference
474a8e1175bSopenharmony_cithose functions. In this case, you'll need to update the type of your pointers
475a8e1175bSopenharmony_ciin order to match the new signature.
476a8e1175bSopenharmony_ci
477a8e1175bSopenharmony_ci### The RNG parameter is now mandatory for all functions that accept one
478a8e1175bSopenharmony_ci
479a8e1175bSopenharmony_ciThis change affects all users who called a function accepting a `f_rng`
480a8e1175bSopenharmony_ciparameter with `NULL` as the value of this argument; this is no longer
481a8e1175bSopenharmony_cisupported.
482a8e1175bSopenharmony_ci
483a8e1175bSopenharmony_ciThe changed functions are: the X.509 CRT and CSR writing functions; the PK and
484a8e1175bSopenharmony_ciRSA sign and decrypt functions; `mbedtls_rsa_private()`; the functions in DHM
485a8e1175bSopenharmony_ciand ECDH that compute the shared secret; the scalar multiplication functions in
486a8e1175bSopenharmony_ciECP.
487a8e1175bSopenharmony_ci
488a8e1175bSopenharmony_ciYou now need to pass a properly seeded, cryptographically secure RNG to all
489a8e1175bSopenharmony_cifunctions that accept a `f_rng` parameter. It is of course still possible to
490a8e1175bSopenharmony_cipass `NULL` as the context pointer `p_rng` if your RNG function doesn't need a
491a8e1175bSopenharmony_cicontext.
492a8e1175bSopenharmony_ci
493a8e1175bSopenharmony_ciAlternative implementations of a module (enabled with the `MBEDTLS_module_ALT`
494a8e1175bSopenharmony_ciconfiguration options) may have their own internal and are free to ignore the
495a8e1175bSopenharmony_ci`f_rng` argument but must allow users to pass one anyway.
496a8e1175bSopenharmony_ci
497a8e1175bSopenharmony_ci### Some functions gained an RNG parameter
498a8e1175bSopenharmony_ci
499a8e1175bSopenharmony_ciThis affects users of the following functions: `mbedtls_ecp_check_pub_priv()`,
500a8e1175bSopenharmony_ci`mbedtls_pk_check_pair()`, `mbedtls_pk_parse_key()`, and
501a8e1175bSopenharmony_ci`mbedtls_pk_parse_keyfile()`.
502a8e1175bSopenharmony_ci
503a8e1175bSopenharmony_ciYou now need to pass a properly seeded, cryptographically secure RNG when
504a8e1175bSopenharmony_cicalling these functions. It is used for blinding, a countermeasure against
505a8e1175bSopenharmony_ciside-channel attacks.
506a8e1175bSopenharmony_ci
507a8e1175bSopenharmony_ci
508a8e1175bSopenharmony_ci## PSA
509a8e1175bSopenharmony_ci
510a8e1175bSopenharmony_ci### Deprecated names for PSA constants and types were removed
511a8e1175bSopenharmony_ci
512a8e1175bSopenharmony_ciSome constants and types that were present in beta versions of the PSA Crypto
513a8e1175bSopenharmony_ciAPI were removed from version 1.0 of specification. Please switch to the new
514a8e1175bSopenharmony_cinames provided by the 1.0 specification instead.
515a8e1175bSopenharmony_ci
516a8e1175bSopenharmony_ci
517a8e1175bSopenharmony_ci## Changes that only affect alternative implementations
518a8e1175bSopenharmony_ci
519a8e1175bSopenharmony_ci### Internal / alt-focused headers were moved to a private location
520a8e1175bSopenharmony_ci
521a8e1175bSopenharmony_ciThis shouldn't affect users who took care not to include headers that
522a8e1175bSopenharmony_ciwere documented as internal, despite being in the public include directory.
523a8e1175bSopenharmony_ci
524a8e1175bSopenharmony_ciIf you're providing alt implementations of ECP or RSA, you'll need to add our
525a8e1175bSopenharmony_ci`library` directory to your include path when building your alt
526a8e1175bSopenharmony_ciimplementations, and note that `ecp_internal.h` and `rsa_internal.h` have been
527a8e1175bSopenharmony_cirenamed to `ecp_internal_alt.h` and `rsa_alt_helpers.h` respectively.
528a8e1175bSopenharmony_ci
529a8e1175bSopenharmony_ciIf you're a library user and used to rely on having access to a structure or
530a8e1175bSopenharmony_cifunction that's now in a private header, please reach out on the mailing list
531a8e1175bSopenharmony_ciand explain your need; we'll consider adding a new API in a future version.
532a8e1175bSopenharmony_ci
533a8e1175bSopenharmony_ci### CCM interface changes: impact for alternative implementations
534a8e1175bSopenharmony_ci
535a8e1175bSopenharmony_ciThe CCM interface has changed with the addition of support for
536a8e1175bSopenharmony_cimulti-part operations. Five new API functions have been defined:
537a8e1175bSopenharmony_ci `mbedtls_ccm_starts()`, `mbedtls_ccm_set_lengths()`,
538a8e1175bSopenharmony_ci `mbedtls_ccm_update_ad()`, `mbedtls_ccm_update()` and `mbedtls_ccm_finish()`.
539a8e1175bSopenharmony_ciAlternative implementations of CCM (`MBEDTLS_CCM_ALT`) have now to
540a8e1175bSopenharmony_ciimplement those additional five API functions.
541a8e1175bSopenharmony_ci
542a8e1175bSopenharmony_ci
543a8e1175bSopenharmony_ci## X.509
544a8e1175bSopenharmony_ci
545a8e1175bSopenharmony_ci### Remove the certs module from the library
546a8e1175bSopenharmony_ci
547a8e1175bSopenharmony_ciThis should not affect production use of the library, as the certificates and
548a8e1175bSopenharmony_cikeys included there were never suitable for production use.
549a8e1175bSopenharmony_ci
550a8e1175bSopenharmony_ciHowever it might affect you if you relied on them for testing purposes. In
551a8e1175bSopenharmony_cithat case, please embed your own test certificates in your test code; now that
552a8e1175bSopenharmony_ci`certs.c` is out of the library there is no longer any stability guaranteed
553a8e1175bSopenharmony_ciand it may change in incompatible ways at any time.
554a8e1175bSopenharmony_ci
555a8e1175bSopenharmony_ci### Change the API to allow adding critical extensions to CSRs
556a8e1175bSopenharmony_ci
557a8e1175bSopenharmony_ciThis affects applications that call the `mbedtls_x509write_csr_set_extension`
558a8e1175bSopenharmony_cifunction.
559a8e1175bSopenharmony_ci
560a8e1175bSopenharmony_ciThe API is changed to include the parameter `critical` which enables marking an
561a8e1175bSopenharmony_ciextension included in a CSR as critical. To get the previous behavior pass 0.
562a8e1175bSopenharmony_ci
563a8e1175bSopenharmony_ci### Remove the config option `MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION`
564a8e1175bSopenharmony_ci
565a8e1175bSopenharmony_ciThis change does not affect users of the default configuration; it only affects
566a8e1175bSopenharmony_ciusers who enable this option.
567a8e1175bSopenharmony_ci
568a8e1175bSopenharmony_ciThe X.509 standard says that implementations must reject critical extensions that
569a8e1175bSopenharmony_cithey don't recognize, and this is what Mbed TLS does by default. This option
570a8e1175bSopenharmony_ciallowed to continue parsing those certificates but didn't provide a convenient
571a8e1175bSopenharmony_ciway to handle those extensions.
572a8e1175bSopenharmony_ci
573a8e1175bSopenharmony_ciThe migration path from that option is to use the
574a8e1175bSopenharmony_ci`mbedtls_x509_crt_parse_der_with_ext_cb()` function which is functionally
575a8e1175bSopenharmony_ciequivalent to `mbedtls_x509_crt_parse_der()`, and/or
576a8e1175bSopenharmony_ci`mbedtls_x509_crt_parse_der_nocopy()` but it calls the callback with every
577a8e1175bSopenharmony_ciunsupported certificate extension and additionally the "certificate policies"
578a8e1175bSopenharmony_ciextension if it contains any unsupported certificate policies.
579a8e1175bSopenharmony_ci
580a8e1175bSopenharmony_ci### Remove `MBEDTLS_X509_CHECK_*_KEY_USAGE` options from `mbedtls_config.h`
581a8e1175bSopenharmony_ci
582a8e1175bSopenharmony_ciThis change affects users who have chosen the configuration options to disable the
583a8e1175bSopenharmony_cilibrary's verification of the `keyUsage` and `extendedKeyUsage` fields of X.509
584a8e1175bSopenharmony_cicertificates.
585a8e1175bSopenharmony_ci
586a8e1175bSopenharmony_ciThe `MBEDTLS_X509_CHECK_KEY_USAGE` and `MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE`
587a8e1175bSopenharmony_ciconfiguration options are removed and the X.509 code now behaves as if they were
588a8e1175bSopenharmony_cialways enabled. It is consequently not possible anymore to disable at compile
589a8e1175bSopenharmony_citime the verification of the `keyUsage` and `extendedKeyUsage` fields of X.509
590a8e1175bSopenharmony_cicertificates.
591a8e1175bSopenharmony_ci
592a8e1175bSopenharmony_ciThe verification of the `keyUsage` and `extendedKeyUsage` fields is important,
593a8e1175bSopenharmony_cidisabling it can cause security issues and it is thus not recommended. If the
594a8e1175bSopenharmony_civerification is for some reason undesirable, it can still be disabled by means
595a8e1175bSopenharmony_ciof the verification callback function passed to `mbedtls_x509_crt_verify()` (see
596a8e1175bSopenharmony_cithe documentation of this function for more information).
597a8e1175bSopenharmony_ci
598a8e1175bSopenharmony_ci### Remove the `MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3` option
599a8e1175bSopenharmony_ci
600a8e1175bSopenharmony_ciThis change does not affect users who were using the default configuration, as
601a8e1175bSopenharmony_cithis option was already disabled by default. Also, it does not affect users who
602a8e1175bSopenharmony_ciare working with current V3 X.509 certificates.
603a8e1175bSopenharmony_ci
604a8e1175bSopenharmony_ciExtensions were added in V3 of the X.509 specification, so pre-V3 certificates
605a8e1175bSopenharmony_cicontaining extensions were never compliant. Mbed TLS now rejects them with a
606a8e1175bSopenharmony_ciparsing error in all configurations, as it did previously in the default
607a8e1175bSopenharmony_ciconfiguration.
608a8e1175bSopenharmony_ci
609a8e1175bSopenharmony_ciIf you are working with the pre-V3 certificates you need to switch to the
610a8e1175bSopenharmony_cicurrent ones.
611a8e1175bSopenharmony_ci
612a8e1175bSopenharmony_ci### Strengthen default algorithm selection for X.509
613a8e1175bSopenharmony_ci
614a8e1175bSopenharmony_ciThis is described in the section [Strengthen default algorithm selection for X.509 and TLS](#strengthen-default-algorithm-selection-for-x.509-and-tls).
615a8e1175bSopenharmony_ci
616a8e1175bSopenharmony_ci### Remove wrapper for libpkcs11-helper
617a8e1175bSopenharmony_ci
618a8e1175bSopenharmony_ciThis doesn't affect people using the default configuration as it was already
619a8e1175bSopenharmony_cidisabled by default.
620a8e1175bSopenharmony_ci
621a8e1175bSopenharmony_ciIf you used to rely on this module in order to store your private keys
622a8e1175bSopenharmony_cisecurely, please have a look at the key management facilities provided by the
623a8e1175bSopenharmony_ciPSA crypto API. If you have a use case that's not covered yet by this API,
624a8e1175bSopenharmony_ciplease reach out on the mailing list.
625a8e1175bSopenharmony_ci
626a8e1175bSopenharmony_ci
627a8e1175bSopenharmony_ci## SSL
628a8e1175bSopenharmony_ci
629a8e1175bSopenharmony_ci### Remove support for TLS 1.0, 1.1 and DTLS 1.0
630a8e1175bSopenharmony_ci
631a8e1175bSopenharmony_ciThis change affects users of the TLS 1.0, 1.1 and DTLS 1.0 protocols.
632a8e1175bSopenharmony_ci
633a8e1175bSopenharmony_ciThese versions have been deprecated by RFC 8996.
634a8e1175bSopenharmony_ciKeeping them in the library creates opportunities for misconfiguration
635a8e1175bSopenharmony_ciand possibly downgrade attacks. More generally, more code means a larger attack
636a8e1175bSopenharmony_cisurface, even if the code is supposedly not used.
637a8e1175bSopenharmony_ci
638a8e1175bSopenharmony_ciThe migration path is to adopt the latest versions of the protocol.
639a8e1175bSopenharmony_ci
640a8e1175bSopenharmony_ciAs a consequence of removing TLS 1.0, support for CBC record splitting was
641a8e1175bSopenharmony_cialso removed, as it was a work-around for a weakness in this particular
642a8e1175bSopenharmony_civersion. There is no migration path since the feature is no longer relevant.
643a8e1175bSopenharmony_ci
644a8e1175bSopenharmony_ciAs a consequence of currently supporting only one version of (D)TLS (and in the
645a8e1175bSopenharmony_cifuture 1.3 which will have a different version negotiation mechanism), support
646a8e1175bSopenharmony_cifor fallback SCSV (RFC 7507) was also removed. There is no migration path as
647a8e1175bSopenharmony_ciit's no longer useful with TLS 1.2 and later.
648a8e1175bSopenharmony_ci
649a8e1175bSopenharmony_ciAs a consequence of currently supporting only one version of (D)TLS (and in the
650a8e1175bSopenharmony_cifuture 1.3 which will have a different concept of ciphersuites), support for
651a8e1175bSopenharmony_ciconfiguring ciphersuites separately for each version via
652a8e1175bSopenharmony_ci`mbedtls_ssl_conf_ciphersuites_for_version()` was removed. Use
653a8e1175bSopenharmony_ci`mbedtls_ssl_conf_ciphersuites()` to configure ciphersuites to use with (D)TLS
654a8e1175bSopenharmony_ci1.2; in the future a different API will be added for (D)TLS 1.3.
655a8e1175bSopenharmony_ci
656a8e1175bSopenharmony_ci### Remove support for SSL 3.0
657a8e1175bSopenharmony_ci
658a8e1175bSopenharmony_ciThis doesn't affect people using the default configuration as it was already
659a8e1175bSopenharmony_cidisabled by default.
660a8e1175bSopenharmony_ci
661a8e1175bSopenharmony_ciThis only affects TLS users who explicitly enabled `MBEDTLS_SSL_PROTO_SSL3`
662a8e1175bSopenharmony_ciand relied on that version in order to communicate with peers that are not up
663a8e1175bSopenharmony_cito date. If one of your peers is in that case, please try contacting them and
664a8e1175bSopenharmony_ciencouraging them to upgrade their software.
665a8e1175bSopenharmony_ci
666a8e1175bSopenharmony_ci### Remove support for parsing SSLv2 ClientHello
667a8e1175bSopenharmony_ci
668a8e1175bSopenharmony_ciThis doesn't affect people using the default configuration as it was already
669a8e1175bSopenharmony_cidisabled by default.
670a8e1175bSopenharmony_ci
671a8e1175bSopenharmony_ciThis only affects TLS servers that have clients who send an SSLv2 ClientHello.
672a8e1175bSopenharmony_ciThese days clients are very unlikely to do that. If you have a client that
673a8e1175bSopenharmony_cidoes, please try contacting them and encouraging them to upgrade their
674a8e1175bSopenharmony_cisoftware.
675a8e1175bSopenharmony_ci
676a8e1175bSopenharmony_ci### Remove support for truncated HMAC
677a8e1175bSopenharmony_ci
678a8e1175bSopenharmony_ciThis affects users of truncated HMAC, that is, users who called
679a8e1175bSopenharmony_ci`mbedtls_ssl_conf_truncated_hmac( ..., MBEDTLS_SSL_TRUNC_HMAC_ENABLED)`,
680a8e1175bSopenharmony_ciregardless of whether the standard version was used or compatibility version
681a8e1175bSopenharmony_ci(`MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT`).
682a8e1175bSopenharmony_ci
683a8e1175bSopenharmony_ciThe recommended migration path for people who want minimal overhead is to use a
684a8e1175bSopenharmony_ciCCM-8 ciphersuite.
685a8e1175bSopenharmony_ci
686a8e1175bSopenharmony_ci### Remove support for TLS record-level compression
687a8e1175bSopenharmony_ci
688a8e1175bSopenharmony_ciThis doesn't affect people using the default configuration as it was already
689a8e1175bSopenharmony_cidisabled by default.
690a8e1175bSopenharmony_ci
691a8e1175bSopenharmony_ciThis only affects TLS users who enabled `MBEDTLS_ZLIB_SUPPORT`. This will not
692a8e1175bSopenharmony_cicause any failures however if you used to enable TLS record-level compression
693a8e1175bSopenharmony_ciyou may find that your bandwidth usage increases without compression. There's
694a8e1175bSopenharmony_cino general solution to this problem; application protocols might have their
695a8e1175bSopenharmony_ciown compression mechanisms and are in a better position than the TLS stack to
696a8e1175bSopenharmony_ciavoid variants of the CRIME and BREACH attacks.
697a8e1175bSopenharmony_ci
698a8e1175bSopenharmony_ci### Remove support for TLS RC4-based ciphersuites
699a8e1175bSopenharmony_ci
700a8e1175bSopenharmony_ciThis does not affect people who used the default `mbedtls_config.h` and the default
701a8e1175bSopenharmony_cilist of ciphersuites, as RC4-based ciphersuites were already not negotiated in
702a8e1175bSopenharmony_cithat case.
703a8e1175bSopenharmony_ci
704a8e1175bSopenharmony_ciPlease switch to any of the modern, recommended ciphersuites (based on
705a8e1175bSopenharmony_ciAES-GCM, AES-CCM or ChachaPoly for example) and if your peer doesn't support
706a8e1175bSopenharmony_ciany, encourage them to upgrade their software.
707a8e1175bSopenharmony_ci
708a8e1175bSopenharmony_ci### Remove support for TLS single-DES ciphersuites
709a8e1175bSopenharmony_ci
710a8e1175bSopenharmony_ciThis doesn't affect people using the default configuration as it was already
711a8e1175bSopenharmony_cidisabled by default.
712a8e1175bSopenharmony_ci
713a8e1175bSopenharmony_ciPlease switch to any of the modern, recommended ciphersuites (based on
714a8e1175bSopenharmony_ciAES-GCM, AES-CCM or ChachaPoly for example) and if your peer doesn't support
715a8e1175bSopenharmony_ciany, encourage them to upgrade their software.
716a8e1175bSopenharmony_ci
717a8e1175bSopenharmony_ci### Remove support for TLS record-level hardware acceleration
718a8e1175bSopenharmony_ci
719a8e1175bSopenharmony_ciThis doesn't affect people using the default configuration as it was already
720a8e1175bSopenharmony_cidisabled by default.
721a8e1175bSopenharmony_ci
722a8e1175bSopenharmony_ciThis feature had been broken for a while so we doubt anyone still used it.
723a8e1175bSopenharmony_ciHowever if you did, please reach out on the mailing list and let us know about
724a8e1175bSopenharmony_ciyour use case.
725a8e1175bSopenharmony_ci
726a8e1175bSopenharmony_ci### Remove config option `MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME`
727a8e1175bSopenharmony_ci
728a8e1175bSopenharmony_ciThis doesn't affect people using the default configuration.
729a8e1175bSopenharmony_ci
730a8e1175bSopenharmony_ciThis option has not had any effect for a long time. Please use the `lifetime`
731a8e1175bSopenharmony_ciparameter of `mbedtls_ssl_ticket_setup()` instead.
732a8e1175bSopenharmony_ci
733a8e1175bSopenharmony_ci### Combine the `MBEDTLS_SSL_CID_PADDING_GRANULARITY` and `MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY` options
734a8e1175bSopenharmony_ci
735a8e1175bSopenharmony_ciThis change affects users who modified the default `mbedtls_config.h` padding granularity
736a8e1175bSopenharmony_cisettings, i.e. enabled at least one of the options.
737a8e1175bSopenharmony_ci
738a8e1175bSopenharmony_ciThe `mbedtls_config.h` options `MBEDTLS_SSL_CID_PADDING_GRANULARITY` and
739a8e1175bSopenharmony_ci`MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY` were combined into one option because
740a8e1175bSopenharmony_cithey used exactly the same padding mechanism and hence their respective padding
741a8e1175bSopenharmony_cigranularities can be used in exactly the same way. This change simplifies the
742a8e1175bSopenharmony_cicode maintenance.
743a8e1175bSopenharmony_ci
744a8e1175bSopenharmony_ciThe new single option `MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY` can be used
745a8e1175bSopenharmony_cifor both DTLS-CID and TLS 1.3.
746a8e1175bSopenharmony_ci
747a8e1175bSopenharmony_ci### TLS now favors faster curves over larger curves
748a8e1175bSopenharmony_ci
749a8e1175bSopenharmony_ciThe default preference order for curves in TLS now favors resource usage (performance and memory consumption) over size. The exact order is unspecified and may change, but generally you can expect 256-bit curves to be preferred over larger curves.
750a8e1175bSopenharmony_ci
751a8e1175bSopenharmony_ciIf you prefer a different order, call `mbedtls_ssl_conf_curves()` when configuring a TLS connection.
752a8e1175bSopenharmony_ci
753a8e1175bSopenharmony_ci### SSL key export interface change
754a8e1175bSopenharmony_ci
755a8e1175bSopenharmony_ciThis affects users of the SSL key export APIs:
756a8e1175bSopenharmony_ci```
757a8e1175bSopenharmony_ci    mbedtls_ssl_conf_export_keys_cb()
758a8e1175bSopenharmony_ci    mbedtls_ssl_conf_export_keys_ext_cb()
759a8e1175bSopenharmony_ci```
760a8e1175bSopenharmony_ci
761a8e1175bSopenharmony_ciThose APIs have been removed and replaced by the new API
762a8e1175bSopenharmony_ci`mbedtls_ssl_set_export_keys_cb()`. This API differs from
763a8e1175bSopenharmony_cithe previous key export API in the following ways:
764a8e1175bSopenharmony_ci
765a8e1175bSopenharmony_ci- It is no longer bound to an SSL configuration, but to an
766a8e1175bSopenharmony_ci  SSL context. This allows users to more easily identify the
767a8e1175bSopenharmony_ci  connection an exported key belongs to.
768a8e1175bSopenharmony_ci- It no longer exports raw keys and IV.
769a8e1175bSopenharmony_ci- A secret type parameter has been added to identify which key
770a8e1175bSopenharmony_ci  is being exported. For TLS 1.2, only the master secret is
771a8e1175bSopenharmony_ci  exported, but upcoming TLS 1.3 support will add other kinds of keys.
772a8e1175bSopenharmony_ci- The callback now specifies a void return type, rather than
773a8e1175bSopenharmony_ci  returning an error code. It is the responsibility of the application
774a8e1175bSopenharmony_ci  to handle failures in the key export callback, for example by
775a8e1175bSopenharmony_ci  shutting down the TLS connection.
776a8e1175bSopenharmony_ci
777a8e1175bSopenharmony_ciFor users which do not rely on raw keys and IV, adjusting to the new
778a8e1175bSopenharmony_cicallback type should be straightforward — see the example programs
779a8e1175bSopenharmony_ci`programs/ssl/ssl_client2` and `programs/ssl/ssl_server2` for callbacks
780a8e1175bSopenharmony_cifor NSSKeylog, EAP-TLS and DTLS-SRTP.
781a8e1175bSopenharmony_ci
782a8e1175bSopenharmony_ciUsers which require access to the raw keys used to secure application
783a8e1175bSopenharmony_citraffic may derive those by hand based on the master secret and the
784a8e1175bSopenharmony_cihandshake transcript hashes which can be obtained from the raw data
785a8e1175bSopenharmony_cion the wire. Such users are also encouraged to reach out to the
786a8e1175bSopenharmony_ciMbed TLS team on the mailing list, to let the team know about their
787a8e1175bSopenharmony_ciuse case.
788a8e1175bSopenharmony_ci
789a8e1175bSopenharmony_ci### Remove MaximumFragmentLength (MFL) query API
790a8e1175bSopenharmony_ci
791a8e1175bSopenharmony_ciThis affects users which use the MFL query APIs
792a8e1175bSopenharmony_ci`mbedtls_ssl_get_{input,output}_max_frag_len()` to
793a8e1175bSopenharmony_ciinfer upper bounds on the plaintext size of incoming and
794a8e1175bSopenharmony_cioutgoing record.
795a8e1175bSopenharmony_ci
796a8e1175bSopenharmony_ciUsers should switch to `mbedtls_ssl_get_max_{in,out}_record_payload()`
797a8e1175bSopenharmony_ciinstead, which also provides such upper bounds but takes more factors
798a8e1175bSopenharmony_cithan just the MFL configuration into account.
799a8e1175bSopenharmony_ci
800a8e1175bSopenharmony_ci### Relaxed semantics for PSK configuration
801a8e1175bSopenharmony_ci
802a8e1175bSopenharmony_ciThis affects users which call the PSK configuration APIs
803a8e1175bSopenharmony_ci`mbedtls_ssl_conf_psk()` and `mbedtls_ssl_conf_psk_opaque()`
804a8e1175bSopenharmony_cimultiple times on the same SSL configuration.
805a8e1175bSopenharmony_ci
806a8e1175bSopenharmony_ciIn Mbed TLS 2.x, users would observe later calls overwriting
807a8e1175bSopenharmony_cithe effect of earlier calls, with the prevailing PSK being
808a8e1175bSopenharmony_cithe one that has been configured last. In Mbed TLS 3.0,
809a8e1175bSopenharmony_cicalling `mbedtls_ssl_conf_[opaque_]psk()` multiple times
810a8e1175bSopenharmony_ciwill return an error, leaving the first PSK intact.
811a8e1175bSopenharmony_ci
812a8e1175bSopenharmony_ciTo achieve equivalent functionality when migrating to Mbed TLS 3.0,
813a8e1175bSopenharmony_ciusers calling `mbedtls_ssl_conf_[opaque_]psk()` multiple times should
814a8e1175bSopenharmony_ciremove all but the last call, so that only one call to _either_
815a8e1175bSopenharmony_ci`mbedtls_ssl_conf_psk()` _or_ `mbedtls_ssl_conf_psk_opaque()`
816a8e1175bSopenharmony_ciremains.
817a8e1175bSopenharmony_ci
818a8e1175bSopenharmony_ci### Remove the configuration to enable weak ciphersuites in SSL / TLS
819a8e1175bSopenharmony_ci
820a8e1175bSopenharmony_ciThis does not affect users who use the default `mbedtls_config.h`, as this option was
821a8e1175bSopenharmony_cialready off by default.
822a8e1175bSopenharmony_ci
823a8e1175bSopenharmony_ciIf you were using a weak cipher, please switch to any of the modern,
824a8e1175bSopenharmony_cirecommended ciphersuites (based on AES-GCM, AES-CCM or ChachaPoly for example)
825a8e1175bSopenharmony_ciand if your peer doesn't support any, encourage them to upgrade their software.
826a8e1175bSopenharmony_ci
827a8e1175bSopenharmony_ciIf you were using a ciphersuite without encryption, you just have to
828a8e1175bSopenharmony_cienable `MBEDTLS_CIPHER_NULL_CIPHER` now.
829a8e1175bSopenharmony_ci
830a8e1175bSopenharmony_ci### Remove the `MBEDTLS_SSL_MAX_CONTENT_LEN` configuration option
831a8e1175bSopenharmony_ci
832a8e1175bSopenharmony_ciThis affects users who use the `MBEDTLS_SSL_MAX_CONTENT_LEN` option to
833a8e1175bSopenharmony_ciset the maximum length of incoming and outgoing plaintext fragments,
834a8e1175bSopenharmony_ciwhich can save memory by reducing the size of the TLS I/O buffers.
835a8e1175bSopenharmony_ci
836a8e1175bSopenharmony_ciThis option is replaced by the more fine-grained options
837a8e1175bSopenharmony_ci`MBEDTLS_SSL_IN_CONTENT_LEN` and `MBEDTLS_SSL_OUT_CONTENT_LEN` that set
838a8e1175bSopenharmony_cithe maximum incoming and outgoing plaintext fragment lengths, respectively.
839a8e1175bSopenharmony_ci
840a8e1175bSopenharmony_ci### Remove the SSL API `mbedtls_ssl_get_session_pointer()`
841a8e1175bSopenharmony_ci
842a8e1175bSopenharmony_ciThis affects two classes of users:
843a8e1175bSopenharmony_ci
844a8e1175bSopenharmony_ci1. Users who manually inspect parts of the current session through
845a8e1175bSopenharmony_ci   direct structure field access.
846a8e1175bSopenharmony_ci
847a8e1175bSopenharmony_ci2. Users of session resumption who query the current session
848a8e1175bSopenharmony_ci   via `mbedtls_ssl_get_session_pointer()` prior to saving or exporting
849a8e1175bSopenharmony_ci   it via `mbedtls_ssl_session_copy()` or `mbedtls_ssl_session_save()`,
850a8e1175bSopenharmony_ci   respectively.
851a8e1175bSopenharmony_ci
852a8e1175bSopenharmony_ciMigration paths:
853a8e1175bSopenharmony_ci
854a8e1175bSopenharmony_ci1. Mbed TLS 3.0 does not offer a migration path for the use case 1: Like many
855a8e1175bSopenharmony_ci   other Mbed TLS structures, the structure of `mbedtls_ssl_session` is no
856a8e1175bSopenharmony_ci   longer part of the public API in Mbed TLS 3.0, and direct structure field
857a8e1175bSopenharmony_ci   access is no longer supported. Please see the [section on private structure fields](#most-structure-fields-are-now-private) for more details.
858a8e1175bSopenharmony_ci
859a8e1175bSopenharmony_ci2. Users should replace calls to `mbedtls_ssl_get_session_pointer()` by
860a8e1175bSopenharmony_ci   calls to `mbedtls_ssl_get_session()` as demonstrated in the example
861a8e1175bSopenharmony_ci   program `programs/ssl/ssl_client2.c`.
862a8e1175bSopenharmony_ci
863a8e1175bSopenharmony_ci### Remove `MBEDTLS_SSL_DTLS_BADMAC_LIMIT` option
864a8e1175bSopenharmony_ci
865a8e1175bSopenharmony_ciThis change does not affect users who used the default `mbedtls_config.h`, as the option
866a8e1175bSopenharmony_ci`MBEDTLS_SSL_DTLS_BADMAC_LIMIT` was already on by default.
867a8e1175bSopenharmony_ci
868a8e1175bSopenharmony_ciThis option was a trade-off between functionality and code size: it allowed
869a8e1175bSopenharmony_ciusers who didn't need that feature to avoid paying the cost in code size, by
870a8e1175bSopenharmony_cidisabling it.
871a8e1175bSopenharmony_ci
872a8e1175bSopenharmony_ciThis option is no longer present, but its functionality is now always enabled.
873a8e1175bSopenharmony_ci
874a8e1175bSopenharmony_ci### Deprecated functions were removed from SSL
875a8e1175bSopenharmony_ci
876a8e1175bSopenharmony_ciThe function `mbedtls_ssl_conf_dh_param()` was removed. Please use
877a8e1175bSopenharmony_ci`mbedtls_ssl_conf_dh_param_bin()` or `mbedtls_ssl_conf_dh_param_ctx()` instead.
878a8e1175bSopenharmony_ci
879a8e1175bSopenharmony_ciThe function `mbedtls_ssl_get_max_frag_len()` was removed. Please use
880a8e1175bSopenharmony_ci`mbedtls_ssl_get_max_out_record_payload()` and
881a8e1175bSopenharmony_ci`mbedtls_ssl_get_max_in_record_payload()`
882a8e1175bSopenharmony_ciinstead.
883a8e1175bSopenharmony_ci
884a8e1175bSopenharmony_ci### Remove `MBEDTLS_SSL_RECORD_CHECKING` option and enable its action by default
885a8e1175bSopenharmony_ci
886a8e1175bSopenharmony_ciThis change does not affect users who use the default `mbedtls_config.h`, as the
887a8e1175bSopenharmony_cioption `MBEDTLS_SSL_RECORD_CHECKING` was already on by default.
888a8e1175bSopenharmony_ci
889a8e1175bSopenharmony_ciThis option was added only to control compilation of one function,
890a8e1175bSopenharmony_ci `mbedtls_ssl_check_record()`, which is only useful in some specific cases, so it
891a8e1175bSopenharmony_ciwas made optional to allow users who don't need it to save some code space.
892a8e1175bSopenharmony_ciHowever, the same effect can be achieved by using link-time garbage collection.
893a8e1175bSopenharmony_ci
894a8e1175bSopenharmony_ciUsers who changed the default setting of the option need to change the config/
895a8e1175bSopenharmony_cibuild system to remove that change.
896a8e1175bSopenharmony_ci
897a8e1175bSopenharmony_ci### Session Cache API Change
898a8e1175bSopenharmony_ci
899a8e1175bSopenharmony_ciThis affects users who use `mbedtls_ssl_conf_session_cache()`
900a8e1175bSopenharmony_cito configure a custom session cache implementation different
901a8e1175bSopenharmony_cifrom the one Mbed TLS implements in `library/ssl_cache.c`.
902a8e1175bSopenharmony_ci
903a8e1175bSopenharmony_ciThose users will need to modify the API of their session cache
904a8e1175bSopenharmony_ciimplementation to that of a key-value store with keys being
905a8e1175bSopenharmony_cisession IDs and values being instances of `mbedtls_ssl_session`:
906a8e1175bSopenharmony_ci
907a8e1175bSopenharmony_ci```C
908a8e1175bSopenharmony_citypedef int mbedtls_ssl_cache_get_t( void *data,
909a8e1175bSopenharmony_ci                                     unsigned char const *session_id,
910a8e1175bSopenharmony_ci                                     size_t session_id_len,
911a8e1175bSopenharmony_ci                                     mbedtls_ssl_session *session );
912a8e1175bSopenharmony_citypedef int mbedtls_ssl_cache_set_t( void *data,
913a8e1175bSopenharmony_ci                                     unsigned char const *session_id,
914a8e1175bSopenharmony_ci                                     size_t session_id_len,
915a8e1175bSopenharmony_ci                                     const mbedtls_ssl_session *session );
916a8e1175bSopenharmony_ci```
917a8e1175bSopenharmony_ci
918a8e1175bSopenharmony_ciSince the structure of `mbedtls_ssl_session` is no longer public from 3.0
919a8e1175bSopenharmony_cionwards, portable session cache implementations must not access fields of
920a8e1175bSopenharmony_ci`mbedtls_ssl_session`. See the corresponding migration guide. Users that
921a8e1175bSopenharmony_cifind themselves unable to migrate their session cache functionality without
922a8e1175bSopenharmony_ciaccessing fields of `mbedtls_ssl_session` should describe their use case
923a8e1175bSopenharmony_cion the Mbed TLS mailing list.
924a8e1175bSopenharmony_ci
925a8e1175bSopenharmony_ci### Changes in the SSL error code space
926a8e1175bSopenharmony_ci
927a8e1175bSopenharmony_ciThis affects users manually checking for the following error codes:
928a8e1175bSopenharmony_ci
929a8e1175bSopenharmony_ci- `MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED`
930a8e1175bSopenharmony_ci- `MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH`
931a8e1175bSopenharmony_ci- `MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE`
932a8e1175bSopenharmony_ci- `MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN`
933a8e1175bSopenharmony_ci- `MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE`
934a8e1175bSopenharmony_ci- `MBEDTLS_ERR_SSL_BAD_HS_XXX`
935a8e1175bSopenharmony_ci
936a8e1175bSopenharmony_ciMigration paths:
937a8e1175bSopenharmony_ci- `MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE` has been removed, and
938a8e1175bSopenharmony_ci  `MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL` is returned instead if the user's own certificate
939a8e1175bSopenharmony_ci  is too large to fit into the output buffers.
940a8e1175bSopenharmony_ci  
941a8e1175bSopenharmony_ci  Users should check for `MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL` instead, and potentially
942a8e1175bSopenharmony_ci  compare the size of their own certificate against the configured size of the output buffer to
943a8e1175bSopenharmony_ci  understand if the error is due to an overly large certificate.
944a8e1175bSopenharmony_ci
945a8e1175bSopenharmony_ci- `MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN` and `MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE` have been
946a8e1175bSopenharmony_ci  replaced by `MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE`.
947a8e1175bSopenharmony_ci
948a8e1175bSopenharmony_ci- All codes of the form `MBEDTLS_ERR_SSL_BAD_HS_XXX` have been replaced by various alternatives, which give more information about the type of error raised.
949a8e1175bSopenharmony_ci
950a8e1175bSopenharmony_ci  Users should check for the newly introduced generic error codes
951a8e1175bSopenharmony_ci
952a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_DECODE_ERROR`
953a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER`,
954a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE`
955a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION`
956a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_BAD_CERTIFICATE`
957a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_UNRECOGNIZED_NAME`
958a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION`
959a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_NO_APPLICATION_PROTOCOL`
960a8e1175bSopenharmony_ci
961a8e1175bSopenharmony_ci  and the pre-existing generic error codes
962a8e1175bSopenharmony_ci
963a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE`
964a8e1175bSopenharmony_ci  * `MBEDTLS_ERR_SSL_INTERNAL_ERROR`
965a8e1175bSopenharmony_ci
966a8e1175bSopenharmony_ci  instead.
967a8e1175bSopenharmony_ci
968a8e1175bSopenharmony_ci### Modified semantics of `mbedtls_ssl_{get,set}_session()`
969a8e1175bSopenharmony_ci
970a8e1175bSopenharmony_ciThis affects users who call `mbedtls_ssl_get_session()` or
971a8e1175bSopenharmony_ci`mbedtls_ssl_set_session()` multiple times on the same SSL context
972a8e1175bSopenharmony_cirepresenting an established TLS 1.2 connection.
973a8e1175bSopenharmony_ciThose users will now observe the second call to fail with
974a8e1175bSopenharmony_ci`MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE`.
975a8e1175bSopenharmony_ci
976a8e1175bSopenharmony_ciMigration path:
977a8e1175bSopenharmony_ci- Exporting the same TLS 1.2 connection multiple times via
978a8e1175bSopenharmony_ci  `mbedtls_ssl_get_session()` leads to multiple copies of
979a8e1175bSopenharmony_ci  the same session. This use of `mbedtls_ssl_get_session()`
980a8e1175bSopenharmony_ci  is discouraged, and the following should be considered:
981a8e1175bSopenharmony_ci  * If the various session copies are later loaded into
982a8e1175bSopenharmony_ci    fresh SSL contexts via `mbedtls_ssl_set_session()`,
983a8e1175bSopenharmony_ci    export via `mbedtls_ssl_get_session()` only once and
984a8e1175bSopenharmony_ci    load the same session into different contexts via
985a8e1175bSopenharmony_ci    `mbedtls_ssl_set_session()`. Since `mbedtls_ssl_set_session()`
986a8e1175bSopenharmony_ci    makes a copy of the session that's being loaded, this
987a8e1175bSopenharmony_ci    is functionally equivalent.
988a8e1175bSopenharmony_ci  * If the various session copies are later serialized
989a8e1175bSopenharmony_ci    via `mbedtls_ssl_session_save()`, export and serialize
990a8e1175bSopenharmony_ci    the session only once via `mbedtls_ssl_get_session()` and
991a8e1175bSopenharmony_ci    `mbedtls_ssl_session_save()` and make copies of the raw
992a8e1175bSopenharmony_ci    data instead.
993a8e1175bSopenharmony_ci- Calling `mbedtls_ssl_set_session()` multiple times in Mbed TLS 2.x
994a8e1175bSopenharmony_ci  is not useful since subsequent calls overwrite the effect of previous
995a8e1175bSopenharmony_ci  calls. Applications achieve equivalent functional behavior by
996a8e1175bSopenharmony_ci  issuing only the very last call to `mbedtls_ssl_set_session()`.
997a8e1175bSopenharmony_ci
998a8e1175bSopenharmony_ci### Turn `MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE` configuration option into a runtime option
999a8e1175bSopenharmony_ci
1000a8e1175bSopenharmony_ciThis change affects users who were enabling `MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE`
1001a8e1175bSopenharmony_cioption in the `mbedtls_config.h`
1002a8e1175bSopenharmony_ci
1003a8e1175bSopenharmony_ciThis option has been removed and a new function with similar functionality has
1004a8e1175bSopenharmony_cibeen introduced into the SSL API.
1005a8e1175bSopenharmony_ci
1006a8e1175bSopenharmony_ciThis new function `mbedtls_ssl_conf_preference_order()` can be used to
1007a8e1175bSopenharmony_cichange the preferred order of ciphersuites on the server to those used on the client,
1008a8e1175bSopenharmony_cie.g.: `mbedtls_ssl_conf_preference_order(ssl_config, MBEDTLS_SSL_SRV_CIPHERSUITE_ORDER_CLIENT)`
1009a8e1175bSopenharmony_cihas the same effect as enabling the removed option. The default state is to use
1010a8e1175bSopenharmony_cithe server order of suites.
1011a8e1175bSopenharmony_ci
1012a8e1175bSopenharmony_ci### Strengthen default algorithm selection for X.509 and TLS
1013a8e1175bSopenharmony_ci
1014a8e1175bSopenharmony_ciThe default X.509 verification profile (`mbedtls_x509_crt_profile_default`) and the default curve and hash selection in TLS have changed. They are now aligned, except that the X.509 profile only lists curves that support signature verification.
1015a8e1175bSopenharmony_ci
1016a8e1175bSopenharmony_ciHashes and curves weaker than 255 bits (security strength less than 128 bits) are no longer accepted by default. The following hashes have been removed: SHA-1 (formerly only accepted for key exchanges but not for certificate signatures), SHA-224 (weaker hashes were already not accepted). The following curves have been removed: secp192r1, secp224r1, secp192k1, secp224k1.
1017a8e1175bSopenharmony_ci
1018a8e1175bSopenharmony_ciThe compile-time options `MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES` and `MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE` are no longer available.
1019a8e1175bSopenharmony_ci
1020a8e1175bSopenharmony_ciThe curve secp256k1 has also been removed from the default X.509 and TLS profiles. [RFC 8422](https://datatracker.ietf.org/doc/html/rfc8422#section-5.1.1) deprecates it in TLS, and it is very rarely used, although it is not known to be weak at the time of writing.
1021a8e1175bSopenharmony_ci
1022a8e1175bSopenharmony_ciIf you still need to accept certificates signed with algorithms that have been removed from the default profile, call `mbedtls_x509_crt_verify_with_profile` instead of `mbedtls_x509_crt_verify` and pass a profile that allows the curves and hashes you want. For example, to allow SHA-224:
1023a8e1175bSopenharmony_ci```C
1024a8e1175bSopenharmony_cimbedtls_x509_crt_profile my_profile = mbedtls_x509_crt_profile_default;
1025a8e1175bSopenharmony_cimy_profile.allowed_mds |= MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA224 );
1026a8e1175bSopenharmony_ci```
1027a8e1175bSopenharmony_ci
1028a8e1175bSopenharmony_ciIf you still need to allow hashes and curves in TLS that have been removed from the default configuration, call `mbedtls_ssl_conf_sig_hashes()` and `mbedtls_ssl_conf_curves()` with the desired lists.
1029a8e1175bSopenharmony_ci
1030a8e1175bSopenharmony_ci### Remove 3DES ciphersuites
1031a8e1175bSopenharmony_ci
1032a8e1175bSopenharmony_ciThis change does not affect users using default settings for 3DES in `mbedtls_config.h`
1033a8e1175bSopenharmony_cibecause the 3DES ciphersuites were disabled by that.
1034a8e1175bSopenharmony_ci
1035a8e1175bSopenharmony_ci3DES has weaknesses/limitations and there are better alternatives, and more and
1036a8e1175bSopenharmony_cimore standard bodies are recommending against its use in TLS.
1037a8e1175bSopenharmony_ci
1038a8e1175bSopenharmony_ciThe migration path here is to chose from the alternatives recommended in the
1039a8e1175bSopenharmony_ciliterature, such as AES.
1040