blob: 84740690370fea14a30ef71113cc84d25eb81161 [file] [log] [blame] [view]
Dave Rodgmana0e8db02021-06-29 18:05:38 +01001# Migrating from Mbed TLS 2.x to Mbed TLS 3.0
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +02002
3This guide details the steps required to migrate from Mbed TLS version 2.x to
4Mbed TLS version 3.0 or greater. Unlike normal releases, Mbed TLS 3.0 breaks
5compatibility with previous versions, so users (and alt implementors) might
6need to change their own code in order to make it work with Mbed TLS 3.0.
7
8Here's the list of breaking changes; each entry should help you answer these
9two questions: (1) am I affected? (2) if yes, what's my migration path?
10
Dave Rodgman1aea4042021-06-29 13:27:15 +010011The changes are detailed below, and include:
Dave Rodgman759c0102021-06-29 15:55:08 +010012
Dave Rodgman949c21b2021-06-29 18:05:04 +010013- Removal of many insecure or obsolete features
14- Tidying up of configuration options (including removing some less useful options).
Dave Rodgman70789732021-06-30 09:18:55 +010015- Changing function signatures, e.g. adding return codes, adding extra parameters, or making some arguments const.
Werner Lewis745fcde2022-06-23 12:19:27 +010016- Removal of functions, macros, and types previously marked as deprecated.
17
Werner Lewisf5b86f32022-06-27 09:20:01 +010018Much of the information needed to determine a migration path can be found in the Mbed TLS 2.x documentation.
Werner Lewis745fcde2022-06-23 12:19:27 +010019
Werner Lewisf5b86f32022-06-27 09:20:01 +010020
21## Accessing the Mbed TLS 2.x documentation
Werner Lewis745fcde2022-06-23 12:19:27 +010022
23For features previously marked as deprecated, Mbed TLS 2.x documentation may
24explain how to upgrade, and should be referred to when migrating code. Where a
25migration path is not provided in prior documentation, changes made and the
26upgrade steps required will be explained in this guide.
27
Werner Lewisf8a47872022-06-24 11:02:54 +010028To generate the documentation, checkout the `mbedtls-2.28` branch and follow
29the instructions in the [Documentation section of the README](https://github.com/Mbed-TLS/mbedtls/blob/development/README.md#documentation).
30Then browse `apidoc/deprecated.html` for guidance on upgrading deprecated code.
31
Werner Lewis745fcde2022-06-23 12:19:27 +010032For some deprecated functions, 2.x documentation will suggest using a variant
33suffixed with `_ret`. In Mbed TLS 3.x, this change may not be required, as most
34of these variants have been renamed without the suffix. The section
35[Rename mbedtls_*_ret...](#rename-mbedtls__ret-cryptography-functions-whose-deprecated-variants-have-been-removed)
36has further detail on which functions this applies to.
Dave Rodgmand8a10172021-06-29 21:45:24 +010037
Dave Rodgmand8a10172021-06-29 21:45:24 +010038
Dave Rodgman4ea56432021-06-30 14:16:22 +010039## General changes
Dave Rodgmand8a10172021-06-29 21:45:24 +010040
Dave Rodgmana0e8db02021-06-29 18:05:38 +010041### Introduce a level of indirection and versioning in the config files
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +020042
Dave Rodgmane45e6402021-06-29 13:21:55 +010043`config.h` was split into `build_info.h` and `mbedtls_config.h`.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +020044
Dave Rodgmane45e6402021-06-29 13:21:55 +010045* In code, use `#include <mbedtls/build_info.h>`. Don't include `mbedtls/config.h` and don't refer to `MBEDTLS_CONFIG_FILE`.
46* In build tools, edit `mbedtls_config.h`, or edit `MBEDTLS_CONFIG_FILE` as before.
47* 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.
48
49Also, if you have a custom configuration file:
50
51* Don't include `check_config.h` or `config_psa.h` anymore.
52* Don't define `MBEDTLS_CONFIG_H` anymore.
53
54A config file version symbol, `MBEDTLS_CONFIG_VERSION` was introduced.
55Defining it to a particular value will ensure that Mbed TLS interprets
56the config file in a way that's compatible with the config file format
57used by the Mbed TLS release whose `MBEDTLS_VERSION_NUMBER` has the same
58value.
59The only value supported by Mbed TLS 3.0.0 is `0x03000000`.
60
Dave Rodgman70180532021-06-30 18:40:24 +010061### Most structure fields are now private
62
63Direct 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.
64
65There 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.
66
67Attempting to access a private field directly will result in a compilation error.
68
69If 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.
70
Dave Rodgman017a1992022-03-31 14:07:01 +010071If 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.).
Dave Rodgman70180532021-06-30 18:40:24 +010072
73As 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.
74
Dave Rodgmana0e8db02021-06-29 18:05:38 +010075### Move part of timing module out of the library
Dave Rodgman8cccbe12021-06-29 13:15:50 +010076
77The change affects users who use any of the following functions:
78`mbedtls_timing_self_test()`, `mbedtls_hardclock_poll()`,
79`mbedtls_timing_hardclock()` and `mbedtls_set_alarm()`.
80
81If you were relying on these functions, you'll now need to change to using your
82platform's corresponding functions directly.
Dave Rodgman759c0102021-06-29 15:55:08 +010083
Dave Rodgmana0e8db02021-06-29 18:05:38 +010084### Deprecated net.h file was removed
Dave Rodgman8cccbe12021-06-29 13:15:50 +010085
86The file `include/mbedtls/net.h` was removed because its only function was to
87include `mbedtls/net_sockets.h` which now should be included directly.
Dave Rodgman759c0102021-06-29 15:55:08 +010088
Dave Rodgmand267ec32021-06-29 21:31:58 +010089### Remove `MBEDTLS_CHECK_PARAMS` option
Dave Rodgman8cccbe12021-06-29 13:15:50 +010090
91This change does not affect users who use the default configuration; it only
92affects users who enabled that option.
93
94The option `MBEDTLS_CHECK_PARAMS` (disabled by default) enabled certain kinds
95of “parameter validation”. It covered two kinds of validations:
96
97- In some functions that require a valid pointer, “parameter validation” checks
98that the pointer is non-null. With the feature disabled, a null pointer is not
99treated differently from any other invalid pointer, and typically leads to a
100runtime crash. 90% of the uses of the feature are of this kind.
101- In some functions that take an enum-like argument, “parameter validation”
102checks that the value is a valid one. With the feature disabled, an invalid
103value causes a silent default to one of the valid values.
104
105The default reaction to a failed check was to call a function
106`mbedtls_param_failed()` which the application had to provide. If this function
107returned, its caller returned an error `MBEDTLS_ERR_xxx_BAD_INPUT_DATA`.
108
109This feature was only used in some classic (non-PSA) cryptography modules. It was
110not used in X.509, TLS or in PSA crypto, and it was not implemented in all
111classic crypto modules.
112
113This feature has been removed. The library no longer checks for NULL pointers;
114checks for enum-like arguments will be kept or re-introduced on a case-by-case
115basis, but their presence will no longer be dependent on a compile-time option.
116
117Validation of enum-like values is somewhat useful, but not extremely important,
118because the parameters concerned are usually constants in applications.
119
120For more information see issue #4313.
Dave Rodgman759c0102021-06-29 15:55:08 +0100121
Dave Rodgman30dc6032021-06-29 22:20:58 +0100122### Remove the `MBEDTLS_TEST_NULL_ENTROPY` configuration option
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100123
Dave Rodgman30dc6032021-06-29 22:20:58 +0100124This does not affect users who use the default `mbedtls_config.h`, as this option was
125already off by default.
126
127If you were using the `MBEDTLS_TEST_NULL_ENTROPY` option and your platform
128doesn't have any entropy source, you should use `MBEDTLS_ENTROPY_NV_SEED`
129and make sure your device is provisioned with a strong random seed.
130Alternatively, for testing purposes only, you can create and register a fake
131entropy function.
132
Dave Rodgman30dc6032021-06-29 22:20:58 +0100133### Remove the HAVEGE module
134
135This doesn't affect people using the default configuration as it was already
136disabled by default.
137
138This only affects users who called the HAVEGE modules directly (not
139recommended), or users who used it through the entropy module but had it as the
140only source of entropy. If you're in that case, please declare OS or hardware
141RNG interfaces with `mbedtls_entropy_add_source()` and/or use an entropy seed
142file created securely during device provisioning. See
143<https://tls.mbed.org/kb/how-to/add-entropy-sources-to-entropy-pool> for more
144information.
145
Dave Rodgmana3758202021-06-30 14:17:03 +0100146### Remove helpers for the transition from Mbed TLS 1.3 to Mbed TLS 2.0
147
148This only affects people who've been using Mbed TLS since before version 2.0
149and still relied on `compat-1.3.h` in their code.
150
151Please use the new names directly in your code; `scripts/rename.pl` (from any
152of the 2.x releases — no longer included in 3.0) might help you do that.
153
Dave Rodgman30dc6032021-06-29 22:20:58 +0100154
155## Low-level crypto
156
Dave Rodgman92170cc2021-06-30 14:23:27 +0100157Please also refer to the section [High-level crypto](#high-level-crypto) for
Dave Rodgman26ad6c72021-06-30 17:14:01 +0100158changes that could sit in either category.
Dave Rodgman92170cc2021-06-30 14:23:27 +0100159
Dave Rodgman30dc6032021-06-29 22:20:58 +0100160### Deprecated functions were removed from bignum
161
162The function `mbedtls_mpi_is_prime()` was removed. Please use
163`mbedtls_mpi_is_prime_ext()` instead which additionally allows specifying the
164number of Miller-Rabin rounds.
165
166### Deprecated functions were removed from DRBGs
167
Dave Rodgman2b034572021-06-30 18:59:49 +0100168The functions `mbedtls_ctr_drbg_update_ret()` and `mbedtls_hmac_drbg_update_ret()`
169were renamed to replace the corresponding functions without `_ret` appended. Please call
170the name without `_ret` appended and check the return value.
Dave Rodgman30dc6032021-06-29 22:20:58 +0100171
172### Deprecated hex-encoded primes were removed from DHM
173
174The macros `MBEDTLS_DHM_RFC5114_MODP_2048_P`, `MBEDTLS_DHM_RFC5114_MODP_2048_G`,
175`MBEDTLS_DHM_RFC3526_MODP_2048_P`, `MBEDTLS_DHM_RFC3526_MODP_2048_G`,
176`MBEDTLS_DHM_RFC3526_MODP_3072_P`, `MBEDTLS_DHM_RFC3526_MODP_3072_G`,
177`MBEDTLS_DHM_RFC3526_MODP_4096_P `and `MBEDTLS_DHM_RFC3526_MODP_4096_G` were
178removed. The primes from RFC 5114 are deprecated because their derivation is not
179documented and therefore their usage constitutes a security risk; they are fully
180removed from the library. Please use parameters from RFC3526 (still in the
181library, only in binary form) or RFC 7919 (also available in the library) or
182other trusted sources instead.
183
Dave Rodgman2d05e0f2021-06-30 18:42:34 +0100184### Deprecated functions were removed from hashing modules
185
186Modules: MD5, SHA1, SHA256, SHA512, MD.
187
188- The functions `mbedtls_xxx_starts_ret()`, `mbedtls_xxx_update_ret()`,
189 `mbedtls_xxx_finish_ret()` and `mbedtls_xxx_ret()` were renamed to replace
190 the corresponding functions without `_ret` appended. Please call the name without `_ret` appended and check the return value.
191- The function `mbedtls_md_init_ctx()` was removed; please use
192 `mbedtls_md_setup()` instead.
193- The functions `mbedtls_xxx_process()` were removed. You normally don't need
194 to call that from application code. However if you do (or if you want to
195 provide your own version of that function), please use
196 `mbedtls_internal_xxx_process()` instead, and check the return value.
197
Dave Rodgmana3758202021-06-30 14:17:03 +0100198### Change `MBEDTLS_ECP_FIXED_POINT_OPTIM` behavior
199
200The option `MBEDTLS_ECP_FIXED_POINT_OPTIM` now increases code size and it does
201not increase peak RAM usage anymore.
202
203If you are limited by code size, you can define `MBEDTLS_ECP_FIXED_POINT_OPTIM`
204to `0` in your config file. The impact depends on the number and size of
205enabled curves. For example, for P-256 the difference is 1KB; see the documentation
206of this option for details.
207
208### Separated `MBEDTLS_SHA224_C` and `MBEDTLS_SHA256_C`
209
Dave Rodgmana0148312021-06-30 19:08:51 +0100210This does not affect users who use the default `mbedtls_config.h`. `MBEDTLS_SHA256_C`
211was enabled by default. Now both `MBEDTLS_SHA256_C` and `MBEDTLS_SHA224_C` are
Dave Rodgmana3758202021-06-30 14:17:03 +0100212enabled.
213
Dave Rodgmana0148312021-06-30 19:08:51 +0100214If you were using custom config file with `MBEDTLS_SHA256_C` enabled, then
Dave Rodgmana3758202021-06-30 14:17:03 +0100215you will need to add `#define MBEDTLS_SHA224_C` option to your config.
Dave Rodgmana0148312021-06-30 19:08:51 +0100216Current version of the library does not support enabling `MBEDTLS_SHA256_C`
217without `MBEDTLS_SHA224_C`.
Dave Rodgmana3758202021-06-30 14:17:03 +0100218
219### Replaced `MBEDTLS_SHA512_NO_SHA384` with `MBEDTLS_SHA384_C`
220
221This does not affect users who use the default `mbedtls_config.h`.
Dave Rodgmana0148312021-06-30 19:08:51 +0100222`MBEDTLS_SHA512_NO_SHA384` was disabled by default, now `MBEDTLS_SHA384_C` is
Dave Rodgmana3758202021-06-30 14:17:03 +0100223enabled by default.
224
Dave Rodgmana0148312021-06-30 19:08:51 +0100225If you were using a config file with both `MBEDTLS_SHA512_C` and
226MBEDTLS_SHA512_NO_SHA384, then just remove the `MBEDTLS_SHA512_NO_SHA384`.
227If you were using a config file with `MBEDTLS_SHA512_C` and without
228`MBEDTLS_SHA512_NO_SHA384` and you need the SHA-384 algorithm, then add
Dave Rodgmana3758202021-06-30 14:17:03 +0100229`#define MBEDTLS_SHA384_C` to your config file.
230
Dave Rodgman68547182021-06-30 18:53:09 +0100231### GCM multipart interface: application changes
232
233The GCM module now supports arbitrary chunked input in the multipart interface.
234This changes the interface for applications using the GCM module directly for multipart operations.
235Applications using one-shot GCM or using GCM via the `mbedtls_cipher_xxx` or `psa_aead_xxx` interfaces do not require any changes.
236
237* `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.
238* `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:
239 * As long as the input remains block-aligned, the output length is exactly the input length, as before.
240 * 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()`.
241* `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.
242
243### GCM interface changes: impact for alternative implementations
244
Dave Rodgman24826502021-06-30 19:00:48 +0100245The 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:
Dave Rodgman68547182021-06-30 18:53:09 +0100246
247* `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.
248* `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:
249 * Always return the partial output immediately, even if it does not consist of a whole number of blocks.
250 * Buffer the data for the last partial block, to be returned in the next call to `mbedtls_gcm_update()` or `mbedtls_gcm_finish()`.
251* `mbedtls_gcm_finish()` now takes an extra output buffer for the last partial block if needed.
252
Dave Rodgmana3758202021-06-30 14:17:03 +0100253### The configuration option `MBEDTLS_ECP_NO_INTERNAL_RNG` was removed
254
255This doesn't affect users of the default configuration; it only affects people
256who were explicitly setting this option.
257
258This was a trade-off between code size and countermeasures; it is no longer
259relevant as the countermeasure is now always on at no cost in code size.
260
261### SHA-512 and SHA-256 output type change
262
Dave Rodgman8e5020d2021-07-02 12:16:03 +0100263The 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.
Dave Rodgmana3758202021-06-30 14:17:03 +0100264
265This 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.
266
267Alternative implementations of the SHA256 and SHA512 modules must adjust their functions' prototype accordingly.
268
Dave Rodgman30dc6032021-06-29 22:20:58 +0100269### Deprecated error codes for hardware failures were removed
270
Werner Lewis016cec12022-06-23 12:33:35 +0100271- The macros `MBEDTLS_ERR_xxx_FEATURE_UNAVAILABLE` from various crypto modules
Dave Rodgman30dc6032021-06-29 22:20:58 +0100272 were removed; `MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED` is now used
273 instead.
Werner Lewis016cec12022-06-23 12:33:35 +0100274- The macro `MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION` was removed;
275 `MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED` is now used instead.
Dave Rodgman30dc6032021-06-29 22:20:58 +0100276- The macros `MBEDTLS_ERR_xxx_HW_ACCEL_FAILED` from various crypto modules
277 were removed; `MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED` is now used instead.
278
Werner Lewis016cec12022-06-23 12:33:35 +0100279### Deprecated error codes for invalid input data were removed
280
281- The macros `MBEDTLS_ERR_xxx_INVALID_KEY_LENGTH` from ARIA and Camellia
282 modules were removed; `MBEDTLS_ERR_xxx_BAD_INPUT_DATA` is now used instead.
283
Dave Rodgman507827e2021-06-30 18:54:35 +0100284### Remove the mode parameter from RSA functions
285
286This affects all users who use the RSA encryption, decryption, sign and
287verify APIs.
288
289The RSA module no longer supports private-key operations with the public key or
290vice versa. As a consequence, RSA operation functions no longer have a mode
291parameter. If you were calling RSA operations with the normal mode (public key
292for verification or encryption, private key for signature or decryption), remove
Werner Lewis016cec12022-06-23 12:33:35 +0100293the `MBEDTLS_RSA_PUBLIC` or `MBEDTLS_RSA_PRIVATE` argument. If you were calling
Dave Rodgman507827e2021-06-30 18:54:35 +0100294RSA operations with the wrong mode, which rarely makes sense from a security
295perspective, this is no longer supported.
296
Dave Rodgman71596682021-06-30 18:56:20 +0100297### Deprecated functions were removed from AES
298
299The functions `mbedtls_aes_encrypt()` and `mbedtls_aes_decrypt()` were
300removed.
301
302If you're simply using the AES module, you should be calling the higher-level
303functions `mbedtls_aes_crypt_xxx()`.
304
305If you're providing an alternative implementation using
306`MBEDTLS_AES_ENCRYPT_ALT` or `MBEDTLS_AES_DECRYPT_ALT`, you should be
307replacing the removed functions with `mbedtls_internal_aes_encrypt()` and
308`mbedtls_internal_aes_decrypt()` respectively.
309
Dave Rodgman8128b692021-06-30 18:56:33 +0100310### Deprecated functions were removed from ECDSA
311
312The functions `mbedtls_ecdsa_write_signature_det()` and
313`mbedtls_ecdsa_sign_det()` were removed. They were superseded by
314`mbedtls_ecdsa_write_signature()` and `mbedtls_ecdsa_sign_det_ext()`
315respectively.
316
Dave Rodgmanb4d15b12021-06-30 18:57:37 +0100317### Rename `mbedtls_*_ret()` cryptography functions whose deprecated variants have been removed
318
319This change affects users who were using the `mbedtls_*_ret()` cryptography
320functions.
321
322Those functions were created based on now-deprecated functions according to a
323requirement that a function needs to return a value. This change brings back the
324original names of those functions. The renamed functions are:
325
326| name before this change | after the change |
327|--------------------------------|----------------------------|
328| `mbedtls_ctr_drbg_update_ret` | `mbedtls_ctr_drbg_update` |
329| `mbedtls_hmac_drbg_update_ret` | `mbedtls_hmac_drbg_update` |
330| `mbedtls_md5_starts_ret` | `mbedtls_md5_starts` |
331| `mbedtls_md5_update_ret` | `mbedtls_md5_update` |
332| `mbedtls_md5_finish_ret` | `mbedtls_md5_finish` |
333| `mbedtls_md5_ret` | `mbedtls_md5` |
334| `mbedtls_ripemd160_starts_ret` | `mbedtls_ripemd160_starts` |
335| `mbedtls_ripemd160_update_ret` | `mbedtls_ripemd160_update` |
336| `mbedtls_ripemd160_finish_ret` | `mbedtls_ripemd160_finish` |
337| `mbedtls_ripemd160_ret` | `mbedtls_ripemd160` |
338| `mbedtls_sha1_starts_ret` | `mbedtls_sha1_starts` |
339| `mbedtls_sha1_update_ret` | `mbedtls_sha1_update` |
340| `mbedtls_sha1_finish_ret` | `mbedtls_sha1_finish` |
341| `mbedtls_sha1_ret` | `mbedtls_sha1` |
342| `mbedtls_sha256_starts_ret` | `mbedtls_sha256_starts` |
343| `mbedtls_sha256_update_ret` | `mbedtls_sha256_update` |
344| `mbedtls_sha256_finish_ret` | `mbedtls_sha256_finish` |
345| `mbedtls_sha256_ret` | `mbedtls_sha256` |
346| `mbedtls_sha512_starts_ret` | `mbedtls_sha512_starts` |
347| `mbedtls_sha512_update_ret` | `mbedtls_sha512_update` |
348| `mbedtls_sha512_finish_ret` | `mbedtls_sha512_finish` |
349| `mbedtls_sha512_ret` | `mbedtls_sha512` |
350
351To migrate to the this change the user can keep the `*_ret` names in their code
352and include the `compat_2.x.h` header file which holds macros with proper
353renaming or to rename those functions in their code according to the list from
354mentioned header file.
355
Dave Rodgmanb0e6bb52021-06-30 20:03:55 +0100356### Remove the RNG parameter from RSA verify functions
357
358RSA verification functions also no longer take random generator arguments (this
359was only needed when using a private key). This affects all applications using
360the RSA verify functions.
361
Dave Rodgman7b743192021-06-30 20:10:10 +0100362### Remove the padding parameters from `mbedtls_rsa_init()`
363
364This affects all users who use the RSA encryption, decryption, sign and
365verify APIs.
366
367The function `mbedtls_rsa_init()` no longer supports selecting the PKCS#1 v2.1
368encoding and its hash. It just selects the PKCS#1 v1.5 encoding by default. If
369you were using the PKCS#1 v2.1 encoding you now need, subsequently to the call
370to `mbedtls_rsa_init()`, to call `mbedtls_rsa_set_padding()` to set it.
371
372To choose the padding type when initializing a context, instead of
373
374```C
375 mbedtls_rsa_init(ctx, padding, hash_id);
376```
377
378use
379
380```C
381 mbedtls_rsa_init(ctx);
382 mbedtls_rsa_set_padding(ctx, padding, hash_id);
383```
384
385To use PKCS#1 v1.5 padding, instead of
386
387```C
388 mbedtls_rsa_init(ctx, MBEDTLS_RSA_PKCS_V15, <ignored>);
389```
390
391just use
392
393```C
394 mbedtls_rsa_init(ctx);
395```
396
Dave Rodgman897a95f2021-06-30 18:50:57 +0100397
398## High-level crypto
399
400Please also refer to the section [Low-level crypto](#low-level-crypto) for
401changes that could sit in either category.
402
Dave Rodgman30dc6032021-06-29 22:20:58 +0100403### Calling `mbedtls_cipher_finish()` is mandatory for all multi-part operations
404
405This only affects people who use the cipher module to perform AEAD operations
406using the multi-part API.
407
408Previously, the documentation didn't state explicitly if it was OK to call
409`mbedtls_cipher_check_tag()` or `mbedtls_cipher_write_tag()` directly after
410the last call to `mbedtls_cipher_update()` — that is, without calling
411`mbedtls_cipher_finish()` in-between. If you code was missing that call,
412please add it and be prepared to get as much as 15 bytes of output.
413
414Currently the output is always 0 bytes, but it may be more when alternative
415implementations of the underlying primitives are in use, or with future
416versions of the library.
417
Dave Rodgman30dc6032021-06-29 22:20:58 +0100418### Remove MD2, MD4, RC4, Blowfish and XTEA algorithms
419
420This change affects users of the MD2, MD4, RC4, Blowfish and XTEA algorithms.
421
422They are already niche or obsolete and most of them are weak or broken. For
423those reasons possible users should consider switching to modern and safe
424alternatives to be found in literature.
425
Dave Rodgman30dc6032021-06-29 22:20:58 +0100426### Deprecated functions were removed from cipher
427
428The functions `mbedtls_cipher_auth_encrypt()` and
429`mbedtls_cipher_auth_decrypt()` were removed. They were superseded by
430`mbedtls_cipher_auth_encrypt_ext()` and `mbedtls_cipher_auth_decrypt_ext()`
431respectively which additionally support key wrapping algorithms such as
432NIST_KW.
433
Dave Rodgman30dc6032021-06-29 22:20:58 +0100434### Extra parameter for the output buffer size
435
436The following functions now take an extra parameter indicating the size of the output buffer:
437
438* `mbedtls_ecdsa_write_signature()`, `mbedtls_ecdsa_write_signature_restartable()`
439* `mbedtls_pk_sign()`, `mbedtls_pk_sign_restartable()`
440
441The 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.
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100442
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100443### Signature functions now require the hash length to match the expected value
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100444
445This 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.
446
447All the functions in the RSA module that accept a `hashlen` parameter used to
448ignore it unless the `md_alg` parameter was `MBEDTLS_MD_NONE`, indicating raw
449data was signed. The `hashlen` parameter is now always the size that is read
450from the `hash` input buffer. This length must be equal to the output size of
451the hash algorithm used when signing a hash. (The requirements when signing
452raw data are unchanged.) This affects the following functions:
453
454* `mbedtls_rsa_pkcs1_sign`, `mbedtls_rsa_pkcs1_verify`
455* `mbedtls_rsa_rsassa_pkcs1_v15_sign`, `mbedtls_rsa_rsassa_pkcs1_v15_verify`
456* `mbedtls_rsa_rsassa_pss_sign`, `mbedtls_rsa_rsassa_pss_verify`
457* `mbedtls_rsa_rsassa_pss_sign_ext`, `mbedtls_rsa_rsassa_pss_verify_ext`
458
459The 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:
460
461* `mbedtls_pk_sign`, `mbedtls_pk_verify`
462* `mbedtls_pk_sign_restartable`, `mbedtls_pk_verify_restartable`
463* `mbedtls_pk_verify_ext`
464
465The migration path is to pass the correct value to those functions.
Dave Rodgman759c0102021-06-29 15:55:08 +0100466
Dave Rodgman30dc6032021-06-29 22:20:58 +0100467### Some function parameters were made const
468
469Various functions in the PK and ASN.1 modules had a `const` qualifier added to
470some of their parameters.
471
472This normally doesn't affect your code, unless you use pointers to reference
473those functions. In this case, you'll need to update the type of your pointers
474in order to match the new signature.
475
Dave Rodgman9637bd32021-06-30 20:07:57 +0100476### The RNG parameter is now mandatory for all functions that accept one
477
478This change affects all users who called a function accepting a `f_rng`
479parameter with `NULL` as the value of this argument; this is no longer
480supported.
481
482The changed functions are: the X.509 CRT and CSR writing functions; the PK and
483RSA sign and decrypt functions; `mbedtls_rsa_private()`; the functions in DHM
484and ECDH that compute the shared secret; the scalar multiplication functions in
485ECP.
486
487You now need to pass a properly seeded, cryptographically secure RNG to all
488functions that accept a `f_rng` parameter. It is of course still possible to
489pass `NULL` as the context pointer `p_rng` if your RNG function doesn't need a
490context.
491
492Alternative implementations of a module (enabled with the `MBEDTLS_module_ALT`
493configuration options) may have their own internal and are free to ignore the
494`f_rng` argument but must allow users to pass one anyway.
495
496### Some functions gained an RNG parameter
497
498This affects users of the following functions: `mbedtls_ecp_check_pub_priv()`,
499`mbedtls_pk_check_pair()`, `mbedtls_pk_parse_key()`, and
500`mbedtls_pk_parse_keyfile()`.
501
502You now need to pass a properly seeded, cryptographically secure RNG when
503calling these functions. It is used for blinding, a countermeasure against
504side-channel attacks.
505
Dave Rodgman30dc6032021-06-29 22:20:58 +0100506
Dave Rodgman30dc6032021-06-29 22:20:58 +0100507## PSA
508
509### Deprecated names for PSA constants and types were removed
510
511Some constants and types that were present in beta versions of the PSA Crypto
512API were removed from version 1.0 of specification. Please switch to the new
513names provided by the 1.0 specification instead.
514
515
Dave Rodgman4ea56432021-06-30 14:16:22 +0100516## Changes that only affect alternative implementations
Dave Rodgman30dc6032021-06-29 22:20:58 +0100517
518### Internal / alt-focused headers were moved to a private location
519
520This shouldn't affect users who took care not to include headers that
521were documented as internal, despite being in the public include directory.
522
523If you're providing alt implementations of ECP or RSA, you'll need to add our
524`library` directory to your include path when building your alt
525implementations, and note that `ecp_internal.h` and `rsa_internal.h` have been
526renamed to `ecp_internal_alt.h` and `rsa_alt_helpers.h` respectively.
527
528If you're a library user and used to rely on having access to a structure or
529function that's now in a private header, please reach out on the mailing list
530and explain your need; we'll consider adding a new API in a future version.
531
532### CCM interface changes: impact for alternative implementations
533
534The CCM interface has changed with the addition of support for
535multi-part operations. Five new API functions have been defined:
Dave Rodgman9d341782021-06-30 18:35:43 +0100536 `mbedtls_ccm_starts()`, `mbedtls_ccm_set_lengths()`,
537 `mbedtls_ccm_update_ad()`, `mbedtls_ccm_update()` and `mbedtls_ccm_finish()`.
Dave Rodgman30dc6032021-06-29 22:20:58 +0100538Alternative implementations of CCM (`MBEDTLS_CCM_ALT`) have now to
539implement those additional five API functions.
540
541
Dave Rodgman30dc6032021-06-29 22:20:58 +0100542## X.509
543
Dave Rodgman30dc6032021-06-29 22:20:58 +0100544### Remove the certs module from the library
545
546This should not affect production use of the library, as the certificates and
547keys included there were never suitable for production use.
548
549However it might affect you if you relied on them for testing purposes. In
550that case, please embed your own test certificates in your test code; now that
551`certs.c` is out of the library there is no longer any stability guaranteed
552and it may change in incompatible ways at any time.
553
554### Change the API to allow adding critical extensions to CSRs
555
556This affects applications that call the `mbedtls_x509write_csr_set_extension`
557function.
558
Dave Rodgman6753a772021-06-30 17:15:28 +0100559The API is changed to include the parameter `critical` which enables marking an
Dave Rodgman30dc6032021-06-29 22:20:58 +0100560extension included in a CSR as critical. To get the previous behavior pass 0.
561
Dave Rodgmana0148312021-06-30 19:08:51 +0100562### Remove the config option `MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION`
Dave Rodgman30dc6032021-06-29 22:20:58 +0100563
564This change does not affect users of the default configuration; it only affects
565users who enable this option.
566
567The X.509 standard says that implementations must reject critical extensions that
568they don't recognize, and this is what Mbed TLS does by default. This option
569allowed to continue parsing those certificates but didn't provide a convenient
570way to handle those extensions.
571
572The migration path from that option is to use the
573`mbedtls_x509_crt_parse_der_with_ext_cb()` function which is functionally
574equivalent to `mbedtls_x509_crt_parse_der()`, and/or
575`mbedtls_x509_crt_parse_der_nocopy()` but it calls the callback with every
576unsupported certificate extension and additionally the "certificate policies"
577extension if it contains any unsupported certificate policies.
578
579### Remove `MBEDTLS_X509_CHECK_*_KEY_USAGE` options from `mbedtls_config.h`
580
581This change affects users who have chosen the configuration options to disable the
582library's verification of the `keyUsage` and `extendedKeyUsage` fields of x509
583certificates.
584
585The `MBEDTLS_X509_CHECK_KEY_USAGE` and `MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE`
586configuration options are removed and the X509 code now behaves as if they were
587always enabled. It is consequently not possible anymore to disable at compile
588time the verification of the `keyUsage` and `extendedKeyUsage` fields of X509
589certificates.
590
591The verification of the `keyUsage` and `extendedKeyUsage` fields is important,
592disabling it can cause security issues and it is thus not recommended. If the
593verification is for some reason undesirable, it can still be disabled by means
594of the verification callback function passed to `mbedtls_x509_crt_verify()` (see
595the documentation of this function for more information).
596
597### Remove the `MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3` option
598
599This change does not affect users who were using the default configuration, as
600this option was already disabled by default. Also, it does not affect users who
601are working with current V3 X.509 certificates.
602
603Extensions were added in V3 of the X.509 specification, so pre-V3 certificates
604containing extensions were never compliant. Mbed TLS now rejects them with a
605parsing error in all configurations, as it did previously in the default
606configuration.
607
608If you are working with the pre-V3 certificates you need to switch to the
609current ones.
610
Dave Rodgmanb1c6b4a2021-06-30 14:17:21 +0100611### Strengthen default algorithm selection for X.509
Dave Rodgman30dc6032021-06-29 22:20:58 +0100612
Dave Rodgman7d2ac882021-06-30 19:02:36 +0100613This is described in the section [Strengthen default algorithm selection for X.509 and TLS](#strengthen-default-algorithm-selection-for-x.509-and-tls).
Dave Rodgman30dc6032021-06-29 22:20:58 +0100614
Dave Rodgmanaa1fba22021-06-30 18:41:24 +0100615### Remove wrapper for libpkcs11-helper
616
617This doesn't affect people using the default configuration as it was already
618disabled by default.
619
620If you used to rely on this module in order to store your private keys
621securely, please have a look at the key management facilities provided by the
622PSA crypto API. If you have a use case that's not covered yet by this API,
623please reach out on the mailing list.
624
Dave Rodgmanc936bbb2021-06-30 14:19:30 +0100625
Dave Rodgman30dc6032021-06-29 22:20:58 +0100626## SSL
627
628### Remove support for TLS 1.0, 1.1 and DTLS 1.0
629
630This change affects users of the TLS 1.0, 1.1 and DTLS 1.0 protocols.
631
632These versions have been deprecated by RFC 8996.
633Keeping them in the library creates opportunities for misconfiguration
634and possibly downgrade attacks. More generally, more code means a larger attack
635surface, even if the code is supposedly not used.
636
637The migration path is to adopt the latest versions of the protocol.
638
639As a consequence of removing TLS 1.0, support for CBC record splitting was
640also removed, as it was a work-around for a weakness in this particular
641version. There is no migration path since the feature is no longer relevant.
642
643As a consequence of currently supporting only one version of (D)TLS (and in the
644future 1.3 which will have a different version negotiation mechanism), support
645for fallback SCSV (RFC 7507) was also removed. There is no migration path as
646it's no longer useful with TLS 1.2 and later.
647
648As a consequence of currently supporting only one version of (D)TLS (and in the
649future 1.3 which will have a different concept of ciphersuites), support for
650configuring ciphersuites separately for each version via
651`mbedtls_ssl_conf_ciphersuites_for_version()` was removed. Use
652`mbedtls_ssl_conf_ciphersuites()` to configure ciphersuites to use with (D)TLS
6531.2; in the future a different API will be added for (D)TLS 1.3.
654
655### Remove support for SSL 3.0
656
657This doesn't affect people using the default configuration as it was already
658disabled by default.
659
660This only affects TLS users who explicitly enabled `MBEDTLS_SSL_PROTO_SSL3`
661and relied on that version in order to communicate with peers that are not up
662to date. If one of your peers is in that case, please try contacting them and
663encouraging them to upgrade their software.
664
665### Remove support for parsing SSLv2 ClientHello
666
667This doesn't affect people using the default configuration as it was already
668disabled by default.
669
670This only affects TLS servers that have clients who send an SSLv2 ClientHello.
671These days clients are very unlikely to do that. If you have a client that
672does, please try contacting them and encouraging them to upgrade their
673software.
674
675### Remove support for truncated HMAC
676
677This affects users of truncated HMAC, that is, users who called
678`mbedtls_ssl_conf_truncated_hmac( ..., MBEDTLS_SSL_TRUNC_HMAC_ENABLED)`,
679regardless of whether the standard version was used or compatibility version
680(`MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT`).
681
682The recommended migration path for people who want minimal overhead is to use a
683CCM-8 ciphersuite.
684
685### Remove support for TLS record-level compression
686
687This doesn't affect people using the default configuration as it was already
688disabled by default.
689
690This only affects TLS users who enabled `MBEDTLS_ZLIB_SUPPORT`. This will not
691cause any failures however if you used to enable TLS record-level compression
692you may find that your bandwidth usage increases without compression. There's
693no general solution to this problem; application protocols might have their
694own compression mechanisms and are in a better position than the TLS stack to
695avoid variants of the CRIME and BREACH attacks.
696
697### Remove support for TLS RC4-based ciphersuites
698
699This does not affect people who used the default `mbedtls_config.h` and the default
700list of ciphersuites, as RC4-based ciphersuites were already not negotiated in
701that case.
702
703Please switch to any of the modern, recommended ciphersuites (based on
704AES-GCM, AES-CCM or ChachaPoly for example) and if your peer doesn't support
705any, encourage them to upgrade their software.
706
707### Remove support for TLS single-DES ciphersuites
708
709This doesn't affect people using the default configuration as it was already
710disabled by default.
711
712Please switch to any of the modern, recommended ciphersuites (based on
713AES-GCM, AES-CCM or ChachaPoly for example) and if your peer doesn't support
714any, encourage them to upgrade their software.
715
716### Remove support for TLS record-level hardware acceleration
717
718This doesn't affect people using the default configuration as it was already
719disabled by default.
720
721This feature had been broken for a while so we doubt anyone still used it.
722However if you did, please reach out on the mailing list and let us know about
723your use case.
724
725### Remove config option `MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME`
726
727This doesn't affect people using the default configuration.
728
729This option has not had any effect for a long time. Please use the `lifetime`
730parameter of `mbedtls_ssl_ticket_setup()` instead.
731
Dave Rodgman30dc6032021-06-29 22:20:58 +0100732### Combine the `MBEDTLS_SSL_CID_PADDING_GRANULARITY` and `MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY` options
733
734This change affects users who modified the default `mbedtls_config.h` padding granularity
735settings, i.e. enabled at least one of the options.
736
737The `mbedtls_config.h` options `MBEDTLS_SSL_CID_PADDING_GRANULARITY` and
738`MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY` were combined into one option because
739they used exactly the same padding mechanism and hence their respective padding
740granularities can be used in exactly the same way. This change simplifies the
741code maintenance.
742
743The new single option `MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY` can be used
744for both DTLS-CID and TLS 1.3.
745
746### TLS now favors faster curves over larger curves
747
748The 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.
749
750If you prefer a different order, call `mbedtls_ssl_conf_curves()` when configuring a TLS connection.
751
752### SSL key export interface change
753
754This affects users of the SSL key export APIs:
Dave Rodgman26c12eb2021-06-30 19:58:00 +0100755```
Dave Rodgman30dc6032021-06-29 22:20:58 +0100756 mbedtls_ssl_conf_export_keys_cb()
757 mbedtls_ssl_conf_export_keys_ext_cb()
758```
759
760Those APIs have been removed and replaced by the new API
761`mbedtls_ssl_set_export_keys_cb()`. This API differs from
762the previous key export API in the following ways:
763
764- It is no longer bound to an SSL configuration, but to an
765 SSL context. This allows users to more easily identify the
766 connection an exported key belongs to.
767- It no longer exports raw keys and IV.
768- A secret type parameter has been added to identify which key
769 is being exported. For TLS 1.2, only the master secret is
770 exported, but upcoming TLS 1.3 support will add other kinds of keys.
771- The callback now specifies a void return type, rather than
772 returning an error code. It is the responsibility of the application
773 to handle failures in the key export callback, for example by
774 shutting down the TLS connection.
775
776For users which do not rely on raw keys and IV, adjusting to the new
777callback type should be straightforward — see the example programs
778`programs/ssl/ssl_client2` and `programs/ssl/ssl_server2` for callbacks
779for NSSKeylog, EAP-TLS and DTLS-SRTP.
780
781Users which require access to the raw keys used to secure application
782traffic may derive those by hand based on the master secret and the
783handshake transcript hashes which can be obtained from the raw data
784on the wire. Such users are also encouraged to reach out to the
785Mbed TLS team on the mailing list, to let the team know about their
786use case.
787
788### Remove MaximumFragmentLength (MFL) query API
789
790This affects users which use the MFL query APIs
791`mbedtls_ssl_get_{input,output}_max_frag_len()` to
792infer upper bounds on the plaintext size of incoming and
793outgoing record.
794
795Users should switch to `mbedtls_ssl_get_max_{in,out}_record_payload()`
796instead, which also provides such upper bounds but takes more factors
797than just the MFL configuration into account.
798
799### Relaxed semantics for PSK configuration
800
801This affects users which call the PSK configuration APIs
802`mbedtlsl_ssl_conf_psk()` and `mbedtls_ssl_conf_psk_opaque()`
803multiple times on the same SSL configuration.
804
805In Mbed TLS 2.x, users would observe later calls overwriting
806the effect of earlier calls, with the prevailing PSK being
807the one that has been configured last. In Mbed TLS 3.0,
808calling `mbedtls_ssl_conf_[opaque_]psk()` multiple times
809will return an error, leaving the first PSK intact.
810
811To achieve equivalent functionality when migrating to Mbed TLS 3.0,
812users calling `mbedtls_ssl_conf_[opaque_]psk()` multiple times should
813remove all but the last call, so that only one call to _either_
814`mbedtls_ssl_conf_psk()` _or_ `mbedtls_ssl_conf_psk_opaque()`
815remains.
816
817### Remove the configuration to enable weak ciphersuites in SSL / TLS
818
819This does not affect users who use the default `mbedtls_config.h`, as this option was
820already off by default.
821
822If you were using a weak cipher, please switch to any of the modern,
823recommended ciphersuites (based on AES-GCM, AES-CCM or ChachaPoly for example)
824and if your peer doesn't support any, encourage them to upgrade their software.
825
826If you were using a ciphersuite without encryption, you just have to
Dave Rodgman9d341782021-06-30 18:35:43 +0100827enable `MBEDTLS_CIPHER_NULL_CIPHER` now.
Dave Rodgman30dc6032021-06-29 22:20:58 +0100828
829### Remove the `MBEDTLS_SSL_MAX_CONTENT_LEN` configuration option
830
831This affects users who use the `MBEDTLS_SSL_MAX_CONTENT_LEN` option to
832set the maximum length of incoming and outgoing plaintext fragments,
833which can save memory by reducing the size of the TLS I/O buffers.
834
835This option is replaced by the more fine-grained options
836`MBEDTLS_SSL_IN_CONTENT_LEN` and `MBEDTLS_SSL_OUT_CONTENT_LEN` that set
837the maximum incoming and outgoing plaintext fragment lengths, respectively.
838
839### Remove the SSL API `mbedtls_ssl_get_session_pointer()`
840
841This affects two classes of users:
842
8431. Users who manually inspect parts of the current session through
844 direct structure field access.
845
8462. Users of session resumption who query the current session
847 via `mbedtls_ssl_get_session_pointer()` prior to saving or exporting
848 it via `mbedtls_ssl_session_copy()` or `mbedtls_ssl_session_save()`,
849 respectively.
850
851Migration paths:
852
8531. Mbed TLS 3.0 does not offer a migration path for the use case 1: Like many
854 other Mbed TLS structures, the structure of `mbedtls_ssl_session` is no
855 longer part of the public API in Mbed TLS 3.0, and direct structure field
Dave Rodgmana5a3cce2021-06-30 11:06:58 +0100856 access is no longer supported. Please see the [section on private structure fields](#most-structure-fields-are-now-private) for more details.
Dave Rodgman30dc6032021-06-29 22:20:58 +0100857
8582. Users should replace calls to `mbedtls_ssl_get_session_pointer()` by
859 calls to `mbedtls_ssl_get_session()` as demonstrated in the example
860 program `programs/ssl/ssl_client2.c`.
861
862### Remove `MBEDTLS_SSL_DTLS_BADMAC_LIMIT` option
863
864This change does not affect users who used the default `mbedtls_config.h`, as the option
Dave Rodgman9d341782021-06-30 18:35:43 +0100865`MBEDTLS_SSL_DTLS_BADMAC_LIMIT` was already on by default.
Dave Rodgman30dc6032021-06-29 22:20:58 +0100866
867This option was a trade-off between functionality and code size: it allowed
868users who didn't need that feature to avoid paying the cost in code size, by
869disabling it.
870
871This option is no longer present, but its functionality is now always enabled.
872
873### Deprecated functions were removed from SSL
874
875The function `mbedtls_ssl_conf_dh_param()` was removed. Please use
876`mbedtls_ssl_conf_dh_param_bin()` or `mbedtls_ssl_conf_dh_param_ctx()` instead.
877
878The function `mbedtls_ssl_get_max_frag_len()` was removed. Please use
879`mbedtls_ssl_get_max_out_record_payload()` and
880`mbedtls_ssl_get_max_in_record_payload()`
881instead.
882
883### Remove `MBEDTLS_SSL_RECORD_CHECKING` option and enable its action by default
884
Dave Rodgman9d341782021-06-30 18:35:43 +0100885This change does not affect users who use the default `mbedtls_config.h`, as the
886option `MBEDTLS_SSL_RECORD_CHECKING` was already on by default.
Dave Rodgman30dc6032021-06-29 22:20:58 +0100887
888This option was added only to control compilation of one function,
Dave Rodgman9d341782021-06-30 18:35:43 +0100889 `mbedtls_ssl_check_record()`, which is only useful in some specific cases, so it
Dave Rodgman30dc6032021-06-29 22:20:58 +0100890was made optional to allow users who don't need it to save some code space.
Dave Rodgmane4ec8462021-06-30 09:52:40 +0100891However, the same effect can be achieved by using link-time garbage collection.
Dave Rodgman30dc6032021-06-29 22:20:58 +0100892
893Users who changed the default setting of the option need to change the config/
894build system to remove that change.
Dave Rodgman759c0102021-06-29 15:55:08 +0100895
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100896### Session Cache API Change
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100897
898This affects users who use `mbedtls_ssl_conf_session_cache()`
899to configure a custom session cache implementation different
900from the one Mbed TLS implements in `library/ssl_cache.c`.
901
902Those users will need to modify the API of their session cache
903implementation to that of a key-value store with keys being
904session IDs and values being instances of `mbedtls_ssl_session`:
905
Dave Rodgman10963272021-06-30 19:11:22 +0100906```C
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100907typedef int mbedtls_ssl_cache_get_t( void *data,
908 unsigned char const *session_id,
909 size_t session_id_len,
910 mbedtls_ssl_session *session );
911typedef int mbedtls_ssl_cache_set_t( void *data,
912 unsigned char const *session_id,
913 size_t session_id_len,
914 const mbedtls_ssl_session *session );
915```
916
917Since the structure of `mbedtls_ssl_session` is no longer public from 3.0
918onwards, portable session cache implementations must not access fields of
919`mbedtls_ssl_session`. See the corresponding migration guide. Users that
920find themselves unable to migrate their session cache functionality without
Dave Rodgman759c0102021-06-29 15:55:08 +0100921accessing fields of `mbedtls_ssl_session` should describe their use case
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100922on the Mbed TLS mailing list.
Dave Rodgman759c0102021-06-29 15:55:08 +0100923
Dave Rodgmanb491b2b2021-06-30 09:46:07 +0100924### Changes in the SSL error code space
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100925
926This affects users manually checking for the following error codes:
Dave Rodgman759c0102021-06-29 15:55:08 +0100927
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100928- `MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED`
929- `MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH`
930- `MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE`
931- `MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN`
932- `MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE`
933- `MBEDTLS_ERR_SSL_BAD_HS_XXX`
934
935Migration paths:
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100936- `MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE` has been removed, and
937 `MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL` is returned instead if the user's own certificate
Dave Rodgman759c0102021-06-29 15:55:08 +0100938 is too large to fit into the output buffers.
939
940 Users should check for `MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL` instead, and potentially
941 compare the size of their own certificate against the configured size of the output buffer to
942 understand if the error is due to an overly large certificate.
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100943
Dave Rodgmanb491b2b2021-06-30 09:46:07 +0100944- `MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN` and `MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE` have been
945 replaced by `MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE`.
946
Dave Rodgmana54c1682021-06-30 11:11:07 +0100947- 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.
Dave Rodgmanb491b2b2021-06-30 09:46:07 +0100948
949 Users should check for the newly introduced generic error codes
950
951 * `MBEDTLS_ERR_SSL_DECODE_ERROR`
952 * `MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER`,
953 * `MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE`
954 * `MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION`
955 * `MBEDTLS_ERR_SSL_BAD_CERTIFICATE`
956 * `MBEDTLS_ERR_SSL_UNRECOGNIZED_NAME`
957 * `MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION`
958 * `MBEDTLS_ERR_SSL_NO_APPLICATION_PROTOCOL`
959
960 and the pre-existing generic error codes
961
962 * `MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE`
963 * `MBEDTLS_ERR_SSL_INTERNAL_ERROR`
964
965 instead.
Dave Rodgman759c0102021-06-29 15:55:08 +0100966
Dave Rodgmand267ec32021-06-29 21:31:58 +0100967### Modified semantics of `mbedtls_ssl_{get,set}_session()`
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100968
969This affects users who call `mbedtls_ssl_get_session()` or
970`mbedtls_ssl_set_session()` multiple times on the same SSL context
971representing an established TLS 1.2 connection.
972Those users will now observe the second call to fail with
973`MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE`.
974
975Migration path:
976- Exporting the same TLS 1.2 connection multiple times via
977 `mbedtls_ssl_get_session()` leads to multiple copies of
978 the same session. This use of `mbedtls_ssl_get_session()`
979 is discouraged, and the following should be considered:
980 * If the various session copies are later loaded into
981 fresh SSL contexts via `mbedtls_ssl_set_session()`,
982 export via `mbedtls_ssl_get_session()` only once and
983 load the same session into different contexts via
984 `mbedtls_ssl_set_session()`. Since `mbedtls_ssl_set_session()`
985 makes a copy of the session that's being loaded, this
986 is functionally equivalent.
987 * If the various session copies are later serialized
988 via `mbedtls_ssl_session_save()`, export and serialize
989 the session only once via `mbedtls_ssl_get_session()` and
990 `mbedtls_ssl_session_save()` and make copies of the raw
991 data instead.
992- Calling `mbedtls_ssl_set_session()` multiple times in Mbed TLS 2.x
993 is not useful since subsequent calls overwrite the effect of previous
Dave Rodgman759c0102021-06-29 15:55:08 +0100994 calls. Applications achieve equivalent functional behavior by
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100995 issuing only the very last call to `mbedtls_ssl_set_session()`.
996
Dave Rodgmand267ec32021-06-29 21:31:58 +0100997### Turn `MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE` configuration option into a runtime option
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100998
Dave Rodgman9d341782021-06-30 18:35:43 +0100999This change affects users who were enabling `MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE`
Dave Rodgman8cccbe12021-06-29 13:15:50 +01001000option in the `mbedtls_config.h`
1001
1002This option has been removed and a new function with similar functionality has
1003been introduced into the SSL API.
1004
1005This new function `mbedtls_ssl_conf_preference_order()` can be used to
1006change the preferred order of ciphersuites on the server to those used on the client,
1007e.g.: `mbedtls_ssl_conf_preference_order(ssl_config, MBEDTLS_SSL_SRV_CIPHERSUITE_ORDER_CLIENT)`
1008has the same effect as enabling the removed option. The default state is to use
1009the server order of suites.
Dave Rodgmane45e6402021-06-29 13:21:55 +01001010
Dave Rodgmana3758202021-06-30 14:17:03 +01001011### Strengthen default algorithm selection for X.509 and TLS
1012
1013The 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.
1014
1015Hashes 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.
1016
1017The compile-time options `MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES` and `MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE` are no longer available.
1018
1019The 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.
1020
1021If 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:
Dave Rodgman10963272021-06-30 19:11:22 +01001022```C
Dave Rodgmana3758202021-06-30 14:17:03 +01001023mbedtls_x509_crt_profile my_profile = mbedtls_x509_crt_profile_default;
1024my_profile.allowed_mds |= MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA224 );
1025```
1026
1027If 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.
Dave Rodgman3f669432021-06-30 18:43:49 +01001028
1029### Remove 3DES ciphersuites
1030
1031This change does not affect users using default settings for 3DES in `mbedtls_config.h`
1032because the 3DES ciphersuites were disabled by that.
1033
10343DES has weaknesses/limitations and there are better alternatives, and more and
1035more standard bodies are recommending against its use in TLS.
1036
1037The migration path here is to chose from the alternatives recommended in the
1038literature, such as AES.