blob: bbb6d8ed54885f4dbfd0db11e2da4630d8aa0a5a [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 Rodgman1aea4042021-06-29 13:27:15 +010015- Changing function signatures (e.g., adding return codes or extra parameters); introducing const to arguments.
16- Removal of functions marked as deprecated in 2.x
17
Dave Rodgmand8a10172021-06-29 21:45:24 +010018## Low-level crypto
19
20## High-level crypto
21
22## PSA
23
24## The ALT interface
25
26## X.509
27
28## SSL
29
30## Tooling
31
Dave Rodgmana0e8db02021-06-29 18:05:38 +010032### Introduce a level of indirection and versioning in the config files
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +020033
Dave Rodgmane45e6402021-06-29 13:21:55 +010034`config.h` was split into `build_info.h` and `mbedtls_config.h`.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +020035
Dave Rodgmane45e6402021-06-29 13:21:55 +010036* In code, use `#include <mbedtls/build_info.h>`. Don't include `mbedtls/config.h` and don't refer to `MBEDTLS_CONFIG_FILE`.
37* In build tools, edit `mbedtls_config.h`, or edit `MBEDTLS_CONFIG_FILE` as before.
38* 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.
39
40Also, if you have a custom configuration file:
41
42* Don't include `check_config.h` or `config_psa.h` anymore.
43* Don't define `MBEDTLS_CONFIG_H` anymore.
44
45A config file version symbol, `MBEDTLS_CONFIG_VERSION` was introduced.
46Defining it to a particular value will ensure that Mbed TLS interprets
47the config file in a way that's compatible with the config file format
48used by the Mbed TLS release whose `MBEDTLS_VERSION_NUMBER` has the same
49value.
50The only value supported by Mbed TLS 3.0.0 is `0x03000000`.
51
Dave Rodgmana0e8db02021-06-29 18:05:38 +010052### Remove support for TLS 1.0, 1.1 and DTLS 1.0
Dave Rodgmane45e6402021-06-29 13:21:55 +010053
54This change affects users of the TLS 1.0, 1.1 and DTLS 1.0 protocols.
55
56These versions have been deprecated by RFC 8996.
57Keeping them in the library creates opportunities for misconfiguration
58and possibly downgrade attacks. More generally, more code means a larger attack
59surface, even if the code is supposedly not used.
60
61The migration path is to adopt the latest versions of the protocol.
62
63As a consequence of removing TLS 1.0, support for CBC record splitting was
64also removed, as it was a work-around for a weakness in this particular
65version. There is no migration path since the feature is no longer relevant.
66
67As a consequence of currently supporting only one version of (D)TLS (and in the
Dave Rodgman759c0102021-06-29 15:55:08 +010068future 1.3 which will have a different version negotiation mechanism), support
Dave Rodgmane45e6402021-06-29 13:21:55 +010069for fallback SCSV (RFC 7507) was also removed. There is no migration path as
70it's no longer useful with TLS 1.2 and later.
71
72As a consequence of currently supporting only one version of (D)TLS (and in the
73future 1.3 which will have a different concept of ciphersuites), support for
74configuring ciphersuites separately for each version via
75`mbedtls_ssl_conf_ciphersuites_for_version()` was removed. Use
76`mbedtls_ssl_conf_ciphersuites()` to configure ciphersuites to use with (D)TLS
771.2; in the future a different API will be added for (D)TLS 1.3.
78
Dave Rodgmana0e8db02021-06-29 18:05:38 +010079### Remove support for SSL 3.0
Dave Rodgmane45e6402021-06-29 13:21:55 +010080
81This doesn't affect people using the default configuration as it was already
82disabled by default.
83
84This only affects TLS users who explicitly enabled `MBEDTLS_SSL_PROTO_SSL3`
85and relied on that version in order to communicate with peers that are not up
86to date. If one of your peers is in that case, please try contacting them and
87encouraging them to upgrade their software.
Dave Rodgmane45e6402021-06-29 13:21:55 +010088
Dave Rodgmana0e8db02021-06-29 18:05:38 +010089### Strengthen default algorithm selection for X.509 and TLS
Dave Rodgmane45e6402021-06-29 13:21:55 +010090
91The 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.
92
93Hashes 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.
94
95The compile-time options `MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES` and `MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE` are no longer available.
96
97The 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.
98
99If 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:
100```
101mbedtls_x509_crt_profile my_profile = mbedtls_x509_crt_profile_default;
102my_profile.allowed_mds |= MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA224 );
103```
104
105If 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.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200106
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100107### Deprecated functions were removed from hashing modules
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200108
TRodziewiczf41dc7c2021-06-21 13:27:29 +0200109Modules: MD5, SHA1, SHA256, SHA512, MD.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200110
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100111- The functions `mbedtls_xxx_starts_ret()`, `mbedtls_xxx_update_ret()`,
112 `mbedtls_xxx_finish_ret()` and `mbedtls_xxx_ret()` were renamed to replace
113 the corresponding functions without `_ret` appended. Please call the name without `_ret` appended and check the return value.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200114- The function `mbedtls_md_init_ctx()` was removed; please use
115 `mbedtls_md_setup()` instead.
116- The functions `mbedtls_xxx_process()` were removed. You normally don't need
Manuel Pégourié-Gonnard143b1e32021-05-05 09:46:01 +0200117 to call that from application code. However if you do (or if you want to
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100118 provide your own version of that function), please use
119 `mbedtls_internal_xxx_process()` instead, and check the return value.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200120
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100121### Deprecated error codes for hardware failures were removed
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200122
123- The macros `MBEDTLS_ERR_xxx_FEATURE_UNSUPPORTED` from various crypto modules
124 were removed; `MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED` is now used
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100125 instead.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200126- The macros `MBEDTLS_ERR_xxx_HW_ACCEL_FAILED` from various crypto modules
127 were removed; `MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED` is now used instead.
128
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100129### Deprecated names for PSA constants and types were removed
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200130
Manuel Pégourié-Gonnard2960b2e2021-04-26 09:57:36 +0200131Some constants and types that were present in beta versions of the PSA Crypto
Manuel Pégourié-Gonnard143b1e32021-05-05 09:46:01 +0200132API were removed from version 1.0 of specification. Please switch to the new
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200133names provided by the 1.0 specification instead.
134
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100135### Internal / alt-focused headers were moved to a private location
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200136
137This shouldn't affect users who took care not to include headers that
138were documented as internal, despite being in the public include directory.
139
140If you're providing alt implementations of ECP or RSA, you'll need to add our
141`library` directory to your include path when building your alt
142implementations, and note that `ecp_internal.h` and `rsa_internal.h` have been
Gilles Peskine6a2fb612021-05-24 22:25:04 +0200143renamed to `ecp_internal_alt.h` and `rsa_alt_helpers.h` respectively.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200144
145If you're a library user and used to rely on having access to a structure or
146function that's now in a private header, please reach out on the mailing list
147and explain your need; we'll consider adding a new API in a future version.
148
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100149### Remove the certs module from the library
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200150
151This should not affect production use of the library, as the certificates and
152keys included there were never suitable for production use.
153
154However it might affect you if you relied on them for testing purposes. In
155that case, please embed your own test certificates in your test code; now that
156`certs.c` is out of the library there is no longer any stability guaranteed
157and it may change in incompatible ways at any time.
158
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100159### Remove the HAVEGE module
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200160
161This doesn't affect people using the default configuration as it was already
162disabled by default.
163
164This only affects users who called the HAVEGE modules directly (not
Manuel Pégourié-Gonnard143b1e32021-05-05 09:46:01 +0200165recommended), or users who used it through the entropy module but had it as the
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200166only source of entropy. If you're in that case, please declare OS or hardware
167RNG interfaces with `mbedtls_entropy_add_source()` and/or use an entropy seed
168file created securely during device provisioning. See
169<https://tls.mbed.org/kb/how-to/add-entropy-sources-to-entropy-pool> for more
170information.
171
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100172### Remove support for parsing SSLv2 ClientHello
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200173
174This doesn't affect people using the default configuration as it was already
175disabled by default.
176
Manuel Pégourié-Gonnard143b1e32021-05-05 09:46:01 +0200177This only affects TLS servers that have clients who send an SSLv2 ClientHello.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200178These days clients are very unlikely to do that. If you have a client that
179does, please try contacting them and encouraging them to upgrade their
180software.
181
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100182### Remove support for truncated HMAC
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200183
Thomas Daubneyac844692021-06-18 14:08:56 +0100184This affects users of truncated HMAC, that is, users who called
185`mbedtls_ssl_conf_truncated_hmac( ..., MBEDTLS_SSL_TRUNC_HMAC_ENABLED)`,
186regardless of whether the standard version was used or compatibility version
187(`MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT`).
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200188
Thomas Daubneyac844692021-06-18 14:08:56 +0100189The recommended migration path for people who want minimal overhead is to use a
190CCM-8 ciphersuite.
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200191
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100192### Remove support for TLS record-level compression
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200193
194This doesn't affect people using the default configuration as it was already
195disabled by default.
196
197This only affects TLS users who enabled `MBEDTLS_ZLIB_SUPPORT`. This will not
198cause any failures however if you used to enable TLS record-level compression
199you may find that your bandwidth usage increases without compression. There's
200no general solution to this problem; application protocols might have their
201own compression mechanisms and are in a better position than the TLS stack to
202avoid variants of the CRIME and BREACH attacks.
203
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100204### Remove support for TLS RC4-based ciphersuites
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200205
Bence Szépkútibb0cfeb2021-05-28 09:42:25 +0200206This does not affect people who used the default `mbedtls_config.h` and the default
Manuel Pégourié-Gonnard2960b2e2021-04-26 09:57:36 +0200207list of ciphersuites, as RC4-based ciphersuites were already not negotiated in
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200208that case.
209
210Please switch to any of the modern, recommended ciphersuites (based on
211AES-GCM, AES-CCM or ChachaPoly for example) and if your peer doesn't support
212any, encourage them to upgrade their software.
213
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100214### Remove support for TLS single-DES ciphersuites
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200215
216This doesn't affect people using the default configuration as it was already
217disabled by default.
218
219Please switch to any of the modern, recommended ciphersuites (based on
220AES-GCM, AES-CCM or ChachaPoly for example) and if your peer doesn't support
221any, encourage them to upgrade their software.
222
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100223### Remove support for TLS record-level hardware acceleration
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200224
225This doesn't affect people using the default configuration as it was already
226disabled by default.
227
228This feature had been broken for a while so we doubt anyone still used it.
229However if you did, please reach out on the mailing list and let us know about
230your use case.
231
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100232### Remove wrapper for libpkcs11-helper
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200233
234This doesn't affect people using the default configuration as it was already
235disabled by default.
236
237If you used to rely on this module in order to store your private keys
238securely, please have a look at the key management facilities provided by the
239PSA crypto API. If you have a use case that's not covered yet by this API,
240please reach out on the mailing list.
241
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100242### Remove config option `MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME`
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200243
244This doesn't affect people using the default configuration.
245
Manuel Pégourié-Gonnard57e93e52021-04-26 09:59:47 +0200246This option has not had any effect for a long time. Please use the `lifetime`
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200247parameter of `mbedtls_ssl_ticket_setup()` instead.
248
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100249### Remove helpers for the transition from Mbed TLS 1.3 to Mbed TLS 2.0
Manuel Pégourié-Gonnard89d4ab02021-04-23 11:54:27 +0200250
251This only affects people who've been using Mbed TLS since before version 2.0
252and still relied on `compat-1.3.h` in their code.
253
254Please use the new names directly in your code; `scripts/rename.pl` (from any
Dave Rodgman949c21b2021-06-29 18:05:04 +0100255of the 2.x releases — no longer included in 3.0) might help you do that.
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100256
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100257### Remove 3DES ciphersuites
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100258
259This change does not affect users using default settings for 3DES in `mbedtls_config.h`
260because the 3DES ciphersuites were disabled by that.
261
2623DES has weaknesses/limitations and there are better alternatives, and more and
263more standard bodies are recommending against its use in TLS.
264
Dave Rodgman759c0102021-06-29 15:55:08 +0100265The migration path here is to chose from the recommended in literature alternatives.
266
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100267### CCM interface changes: impact for alternative implementations
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100268
269The CCM interface has changed with the addition of support for
270multi-part operations. Five new API functions have been defined:
271mbedtls_ccm_starts(), mbedtls_ccm_set_lengths(),
272mbedtls_ccm_update_ad(), mbedtls_ccm_update() and mbedtls_ccm_finish().
273Alternative implementations of CCM (`MBEDTLS_CCM_ALT`) have now to
274implement those additional five API functions.
Dave Rodgman759c0102021-06-29 15:55:08 +0100275
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100276### Calling `mbedtls_cipher_finish()` is mandatory for all multi-part operations
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100277
278This only affects people who use the cipher module to perform AEAD operations
279using the multi-part API.
280
281Previously, the documentation didn't state explicitly if it was OK to call
282`mbedtls_cipher_check_tag()` or `mbedtls_cipher_write_tag()` directly after
Dave Rodgman949c21b2021-06-29 18:05:04 +0100283the last call to `mbedtls_cipher_update()` that is, without calling
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100284`mbedtls_cipher_finish()` in-between. If you code was missing that call,
285please add it and be prepared to get as much as 15 bytes of output.
286
287Currently the output is always 0 bytes, but it may be more when alternative
288implementations of the underlying primitives are in use, or with future
289versions of the library.
Dave Rodgman759c0102021-06-29 15:55:08 +0100290
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100291### Combine the `MBEDTLS_SSL_CID_PADDING_GRANULARITY` and `MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY` options
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100292
293This change affects users who modified the default `mbedtls_config.h` padding granularity
294settings, i.e. enabled at least one of the options.
295
296The `mbedtls_config.h` options `MBEDTLS_SSL_CID_PADDING_GRANULARITY` and
297`MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY` were combined into one option because
298they used exactly the same padding mechanism and hence their respective padding
299granularities can be used in exactly the same way. This change simplifies the
300code maintenance.
301
302The new single option `MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY` can be used
303for both DTLS-CID and TLS 1.3.
Dave Rodgman759c0102021-06-29 15:55:08 +0100304
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100305### Change the API to allow adding critical extensions to CSRs
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100306
307This affects applications that call the `mbedtls_x509write_csr_set_extension`
308function.
309
310The API is changed to include the parameter `critical` which allow to mark an
Dave Rodgman7b0c4de2021-06-29 16:05:28 +0100311extension included in a CSR as critical. To get the previous behavior pass 0.
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100312
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100313### TLS now favors faster curves over larger curves
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100314
315The 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.
316
317If you prefer a different order, call `mbedtls_ssl_conf_curves()` when configuring a TLS connection.
Dave Rodgman759c0102021-06-29 15:55:08 +0100318
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100319### GCM interface changes: impact for alternative implementations
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100320
321The 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:
322
323* `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.
324* `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:
325 * Always return the partial output immediately, even if it does not consist of a whole number of blocks.
326 * Buffer the data for the last partial block, to be returned in the next call to `mbedtls_gcm_update()` or `mbedtls_gcm_finish()`.
327* `mbedtls_gcm_finish()` now takes an extra output buffer for the last partial block if needed.
Dave Rodgman759c0102021-06-29 15:55:08 +0100328
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100329### GCM multipart interface: application changes
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100330
331The GCM module now supports arbitrary chunked input in the multipart interface.
332This changes the interface for applications using the GCM module directly for multipart operations.
333Applications using one-shot GCM or using GCM via the `mbedtls_cipher_xxx` or `psa_aead_xxx` interfaces do not require any changes.
334
335* `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.
336* `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:
337 * As long as the input remains block-aligned, the output length is exactly the input length, as before.
338 * 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()`.
339* `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.
Dave Rodgman759c0102021-06-29 15:55:08 +0100340
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100341### SSL key export interface change
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100342
343This affects users of the SSL key export APIs:
344```
345 mbedtls_ssl_conf_export_keys_cb()
346 mbedtls_ssl_conf_export_keys_ext_cb()
347```
348
349Those APIs have been removed and replaced by the new API
350`mbedtls_ssl_set_export_keys_cb()`. This API differs from
351the previous key export API in the following ways:
352
353- It is no longer bound to an SSL configuration, but to an
354 SSL context. This allows users to more easily identify the
355 connection an exported key belongs to.
356- It no longer exports raw keys and IV.
357- A secret type parameter has been added to identify which key
358 is being exported. For TLS 1.2, only the master secret is
359 exported, but upcoming TLS 1.3 support will add other kinds of keys.
360- The callback now specifies a void return type, rather than
361 returning an error code. It is the responsibility of the application
362 to handle failures in the key export callback, for example by
363 shutting down the TLS connection.
364
365For users which do not rely on raw keys and IV, adjusting to the new
Dave Rodgman949c21b2021-06-29 18:05:04 +0100366callback type should be straightforward see the example programs
367`programs/ssl/ssl_client2` and `programs/ssl/ssl_server2` for callbacks
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100368for NSSKeylog, EAP-TLS and DTLS-SRTP.
369
370Users which require access to the raw keys used to secure application
371traffic may derive those by hand based on the master secret and the
372handshake transcript hashes which can be obtained from the raw data
373on the wire. Such users are also encouraged to reach out to the
374Mbed TLS team on the mailing list, to let the team know about their
375use case.
Dave Rodgman759c0102021-06-29 15:55:08 +0100376
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100377### The RNG parameter is now mandatory for all functions that accept one
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100378
379This change affects all users who called a function accepting a `f_rng`
380parameter with `NULL` as the value of this argument; this is no longer
381supported.
382
383The changed functions are: the X.509 CRT and CSR writing functions; the PK and
384RSA sign and decrypt functions; `mbedtls_rsa_private()`; the functions in DHM
385and ECDH that compute the shared secret; the scalar multiplication functions in
386ECP.
387
388You now need to pass a properly seeded, cryptographically secure RNG to all
389functions that accept a `f_rng` parameter. It is of course still possible to
390pass `NULL` as the context pointer `p_rng` if your RNG function doesn't need a
391context.
392
393Alternative implementations of a module (enabled with the `MBEDTLS_module_ALT`
394configuration options) may have their own internal and are free to ignore the
395`f_rng` argument but must allow users to pass one anyway.
396
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100397### Some functions gained an RNG parameter
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100398
399This affects users of the following functions: `mbedtls_ecp_check_pub_priv()`,
400`mbedtls_pk_check_pair()`, `mbedtls_pk_parse_key()`, and
401`mbedtls_pk_parse_keyfile()`.
402
403You now need to pass a properly seeded, cryptographically secure RNG when
Dave Rodgman949c21b2021-06-29 18:05:04 +0100404calling these functions. It is used for blinding, a countermeasure against
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100405side-channel attacks.
406
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100407### The configuration option `MBEDTLS_ECP_NO_INTERNAL_RNG` was removed
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100408
409This doesn't affect users of the default configuration; it only affects people
410who were explicitly setting this option.
411
Dave Rodgman949c21b2021-06-29 18:05:04 +0100412This was a trade-off between code size and countermeasures; it is no longer
413relevant as the countermeasure is now always on at no cost in code size.
Dave Rodgman759c0102021-06-29 15:55:08 +0100414
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100415### Remove MaximumFragmentLength (MFL) query API
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100416
417This affects users which use the MFL query APIs
418`mbedtls_ssl_get_{input,output}_max_frag_len()` to
419infer upper bounds on the plaintext size of incoming and
420outgoing record.
421
422Users should switch to `mbedtls_ssl_get_max_{in,out}_record_payload()`
423instead, which also provides such upper bounds but takes more factors
424than just the MFL configuration into account.
Dave Rodgman759c0102021-06-29 15:55:08 +0100425
Dave Rodgmand267ec32021-06-29 21:31:58 +0100426### Change `MBEDTLS_ECP_FIXED_POINT_OPTIM` behavior
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100427
Dave Rodgman36bb5ff2021-06-29 21:39:55 +0100428The option `MBEDTLS_ECP_FIXED_POINT_OPTIM` now increases code size and it does
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100429not increase peak RAM usage anymore.
430
431If you are limited by code size, you can define `MBEDTLS_ECP_FIXED_POINT_OPTIM`
432to `0` in your config file. The impact depends on the number and size of
433enabled curves. For example, for P-256 the difference is 1KB; see the documentation
434of this option for details.
435
Dave Rodgmand267ec32021-06-29 21:31:58 +0100436### Replaced `MBEDTLS_SHA512_NO_SHA384` with `MBEDTLS_SHA384_C`
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100437
438This does not affect users who use the default `mbedtls_config.h`.
439MBEDTLS_SHA512_NO_SHA384 was disabled by default, now MBEDTLS_SHA384_C is
440enabled by default.
441
442If you were using a config file with both MBEDTLS_SHA512_C and
443MBEDTLS_SHA512_NO_SHA384, then just remove the MBEDTLS_SHA512_NO_SHA384.
444If you were using a config file with MBEDTLS_SHA512_C and without
445MBEDTLS_SHA512_NO_SHA384 and you need the SHA-384 algorithm, then add
446`#define MBEDTLS_SHA384_C` to your config file.
Dave Rodgman759c0102021-06-29 15:55:08 +0100447
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100448### Move part of timing module out of the library
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100449
450The change affects users who use any of the following functions:
451`mbedtls_timing_self_test()`, `mbedtls_hardclock_poll()`,
452`mbedtls_timing_hardclock()` and `mbedtls_set_alarm()`.
453
454If you were relying on these functions, you'll now need to change to using your
455platform's corresponding functions directly.
Dave Rodgman759c0102021-06-29 15:55:08 +0100456
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100457### Extra parameter for the output buffer size
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100458
459The following functions now take an extra parameter indicating the size of the output buffer:
460
461* `mbedtls_ecdsa_write_signature()`, `mbedtls_ecdsa_write_signature_restartable()`
462* `mbedtls_pk_sign()`, `mbedtls_pk_sign_restartable()`
463
464The 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 Rodgman759c0102021-06-29 15:55:08 +0100465
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100466### Relaxed semantics for PSK configuration
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100467
468This affects users which call the PSK configuration APIs
469`mbedtlsl_ssl_conf_psk()` and `mbedtls_ssl_conf_psk_opaque()`
470multiple times on the same SSL configuration.
471
472In Mbed TLS 2.x, users would observe later calls overwriting
473the effect of earlier calls, with the prevailing PSK being
474the one that has been configured last. In Mbed TLS 3.0,
475calling `mbedtls_ssl_conf_[opaque_]psk()` multiple times
476will return an error, leaving the first PSK intact.
477
478To achieve equivalent functionality when migrating to Mbed TLS 3.0,
479users calling `mbedtls_ssl_conf_[opaque_]psk()` multiple times should
480remove all but the last call, so that only one call to _either_
481`mbedtls_ssl_conf_psk()` _or_ `mbedtls_ssl_conf_psk_opaque()`
482remains.
Dave Rodgman759c0102021-06-29 15:55:08 +0100483
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100484### Remove the configuration to enable weak ciphersuites in SSL / TLS
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100485
486This does not affect users who use the default `mbedtls_config.h`, as this option was
487already off by default.
488
489If you were using a weak cipher, please switch to any of the modern,
490recommended ciphersuites (based on AES-GCM, AES-CCM or ChachaPoly for example)
491and if your peer doesn't support any, encourage them to upgrade their software.
492
493If you were using a ciphersuite without encryption, you just have to
494enable MBEDTLS_CIPHER_NULL_CIPHER now.
Dave Rodgman759c0102021-06-29 15:55:08 +0100495
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100496### Remove the `MBEDTLS_SSL_MAX_CONTENT_LEN` configuration option
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100497
498This affects users who use the `MBEDTLS_SSL_MAX_CONTENT_LEN` option to
499set the maximum length of incoming and outgoing plaintext fragments,
500which can save memory by reducing the size of the TLS I/O buffers.
501
502This option is replaced by the more fine-grained options
503`MBEDTLS_SSL_IN_CONTENT_LEN` and `MBEDTLS_SSL_OUT_CONTENT_LEN` that set
504the maximum incoming and outgoing plaintext fragment lengths, respectively.
Dave Rodgman759c0102021-06-29 15:55:08 +0100505
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100506### Remove the `MBEDTLS_TEST_NULL_ENTROPY` configuration option
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100507
508This does not affect users who use the default `mbedtls_config.h`, as this option was
509already off by default.
510
511If you were using the `MBEDTLS_TEST_NULL_ENTROPY` option and your platform
512doesn't have any entropy source, you should use `MBEDTLS_ENTROPY_NV_SEED`
513and make sure your device is provisioned with a strong random seed.
514Alternatively, for testing purposes only, you can create and register a fake
515entropy function.
Dave Rodgman759c0102021-06-29 15:55:08 +0100516
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100517### Remove the mode parameter from RSA functions
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100518
519This affects all users who use the RSA encryption, decryption, sign and
520verify APIs.
521
522The RSA module no longer supports private-key operations with the public key or
523vice versa. As a consequence, RSA operation functions no longer have a mode
524parameter. If you were calling RSA operations with the normal mode (public key
525for verification or encryption, private key for signature or decryption), remove
526the `MBEDTLS_MODE_PUBLIC` or `MBEDTLS_MODE_PRIVATE` argument. If you were calling
527RSA operations with the wrong mode, which rarely makes sense from a security
528perspective, this is no longer supported.
529
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100530### Remove the RNG parameter from RSA verify functions
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100531
532RSA verification functions also no longer take random generator arguments (this
533was only needed when using a private key). This affects all applications using
534the RSA verify functions.
535
Dave Rodgmand267ec32021-06-29 21:31:58 +0100536### Remove the SSL API `mbedtls_ssl_get_session_pointer()`
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100537
538This affects two classes of users:
539
5401. Users who manually inspect parts of the current session through
541 direct structure field access.
542
5432. Users of session resumption who query the current session
544 via `mbedtls_ssl_get_session_pointer()` prior to saving or exporting
545 it via `mbedtls_ssl_session_copy()` or `mbedtls_ssl_session_save()`,
546 respectively.
547
548Migration paths:
549
Dave Rodgman759c0102021-06-29 15:55:08 +01005501. Mbed TLS 3.0 does not offer a migration path for the use case 1: Like many
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100551 other Mbed TLS structures, the structure of `mbedtls_ssl_session` is no
552 longer part of the public API in Mbed TLS 3.0, and direct structure field
553 access is no longer supported. Please see the corresponding migration guide.
554
5552. Users should replace calls to `mbedtls_ssl_get_session_pointer()` by
556 calls to `mbedtls_ssl_get_session()` as demonstrated in the example
557 program `programs/ssl/ssl_client2.c`.
Dave Rodgman759c0102021-06-29 15:55:08 +0100558
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100559### Remove the config option MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100560
Dave Rodgman759c0102021-06-29 15:55:08 +0100561This change does not affect users of the default configuration; it only affects
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100562users who enable this option.
563
564The X.509 standard says that implementations must reject critical extensions that
565they don't recognize, and this is what Mbed TLS does by default. This option
566allowed to continue parsing those certificates but didn't provide a convenient
567way to handle those extensions.
568
569The migration path from that option is to use the
570`mbedtls_x509_crt_parse_der_with_ext_cb()` function which is functionally
571equivalent to `mbedtls_x509_crt_parse_der()`, and/or
572`mbedtls_x509_crt_parse_der_nocopy()` but it calls the callback with every
573unsupported certificate extension and additionally the "certificate policies"
574extension if it contains any unsupported certificate policies.
Dave Rodgman759c0102021-06-29 15:55:08 +0100575
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100576### Remove `MBEDTLS_X509_CHECK_*_KEY_USAGE` options from `mbedtls_config.h`
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100577
578This change affects users who have chosen the configuration options to disable the
579library's verification of the `keyUsage` and `extendedKeyUsage` fields of x509
580certificates.
581
582The `MBEDTLS_X509_CHECK_KEY_USAGE` and `MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE`
583configuration options are removed and the X509 code now behaves as if they were
584always enabled. It is consequently not possible anymore to disable at compile
585time the verification of the `keyUsage` and `extendedKeyUsage` fields of X509
586certificates.
587
588The verification of the `keyUsage` and `extendedKeyUsage` fields is important,
589disabling it can cause security issues and it is thus not recommended. If the
590verification is for some reason undesirable, it can still be disabled by means
591of the verification callback function passed to `mbedtls_x509_crt_verify()` (see
592the documentation of this function for more information).
Dave Rodgman759c0102021-06-29 15:55:08 +0100593
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100594### Remove MD2, MD4, RC4, Blowfish and XTEA algorithms
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100595
596This change affects users of the MD2, MD4, RC4, Blowfish and XTEA algorithms.
597
598They are already niche or obsolete and most of them are weak or broken. For
599those reasons possible users should consider switching to modern and safe
600alternatives to be found in literature.
Dave Rodgman759c0102021-06-29 15:55:08 +0100601
Dave Rodgmand267ec32021-06-29 21:31:58 +0100602### Remove `MBEDTLS_SSL_DTLS_BADMAC_LIMIT` option
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100603
604This change does not affect users who used the default `mbedtls_config.h`, as the option
605MBEDTLS_SSL_DTLS_BADMAC_LIMIT was already on by default.
606
607This option was a trade-off between functionality and code size: it allowed
608users who didn't need that feature to avoid paying the cost in code size, by
609disabling it.
610
611This option is no longer present, but its functionality is now always enabled.
Dave Rodgman759c0102021-06-29 15:55:08 +0100612
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100613### Deprecated functions were removed from AES
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100614
615The functions `mbedtls_aes_encrypt()` and `mbedtls_aes_decrypt()` were
616removed.
617
618If you're simply using the AES module, you should be calling the higher-level
619functions `mbedtls_aes_crypt_xxx()`.
620
621If you're providing an alternative implementation using
622`MBEDTLS_AES_ENCRYPT_ALT` or `MBEDTLS_AES_DECRYPT_ALT`, you should be
623replacing the removed functions with `mbedtls_internal_aes_encrypt()` and
624`mbedtls_internal_aes_decrypt()` respectively.
625
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100626### Deprecated functions were removed from bignum
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100627
628The function `mbedtls_mpi_is_prime()` was removed. Please use
629`mbedtls_mpi_is_prime_ext()` instead which additionally allows specifying the
630number of Miller-Rabin rounds.
631
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100632### Deprecated functions were removed from cipher
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100633
634The functions `mbedtls_cipher_auth_encrypt()` and
635`mbedtls_cipher_auth_decrypt()` were removed. They were superseded by
636`mbedtls_cipher_auth_encrypt_ext()` and `mbedtls_cipher_auth_decrypt_ext()`
637respectively which additionally support key wrapping algorithms such as
638NIST_KW.
639
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100640### Deprecated functions were removed from DRBGs
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100641
642The functions `mbedtls_ctr_drbg_update()` and `mbedtls_hmac_drbg_update()`
643were removed. They were superseded by `mbedtls_ctr_drbg_update_ret()` and
644`mbedtls_hmac_drbg_update_ret()` respectively.
645
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100646### Deprecated functions were removed from ECDSA
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100647
648The functions `mbedtls_ecdsa_write_signature_det()` and
649`mbedtls_ecdsa_sign_det()` were removed. They were superseded by
650`mbedtls_ecdsa_write_signature()` and `mbedtls_ecdsa_sign_det_ext()`
651respectively.
652
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100653### Deprecated functions were removed from SSL
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100654
655The function `mbedtls_ssl_conf_dh_param()` was removed. Please use
656`mbedtls_ssl_conf_dh_param_bin()` or `mbedtls_ssl_conf_dh_param_ctx()` instead.
657
658The function `mbedtls_ssl_get_max_frag_len()` was removed. Please use
659`mbedtls_ssl_get_max_out_record_payload()` and
660`mbedtls_ssl_get_max_in_record_payload()`
661instead.
662
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100663### Deprecated hex-encoded primes were removed from DHM
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100664
665The macros `MBEDTLS_DHM_RFC5114_MODP_2048_P`, `MBEDTLS_DHM_RFC5114_MODP_2048_G`,
666`MBEDTLS_DHM_RFC3526_MODP_2048_P`, `MBEDTLS_DHM_RFC3526_MODP_2048_G`,
667`MBEDTLS_DHM_RFC3526_MODP_3072_P`, `MBEDTLS_DHM_RFC3526_MODP_3072_G`,
668`MBEDTLS_DHM_RFC3526_MODP_4096_P `and `MBEDTLS_DHM_RFC3526_MODP_4096_G` were
669removed. The primes from RFC 5114 are deprecated because their derivation is not
670documented and therefore their usage constitutes a security risk; they are fully
671removed from the library. Please use parameters from RFC3526 (still in the
672library, only in binary form) or RFC 7919 (also available in the library) or
673other trusted sources instead.
674
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100675### Deprecated net.h file was removed
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100676
677The file `include/mbedtls/net.h` was removed because its only function was to
678include `mbedtls/net_sockets.h` which now should be included directly.
Dave Rodgman759c0102021-06-29 15:55:08 +0100679
Dave Rodgmand267ec32021-06-29 21:31:58 +0100680### Remove `MBEDTLS_CHECK_PARAMS` option
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100681
682This change does not affect users who use the default configuration; it only
683affects users who enabled that option.
684
685The option `MBEDTLS_CHECK_PARAMS` (disabled by default) enabled certain kinds
686of parameter validation”. It covered two kinds of validations:
687
688- In some functions that require a valid pointer, parameter validation checks
689that the pointer is non-null. With the feature disabled, a null pointer is not
690treated differently from any other invalid pointer, and typically leads to a
691runtime crash. 90% of the uses of the feature are of this kind.
692- In some functions that take an enum-like argument, parameter validation
693checks that the value is a valid one. With the feature disabled, an invalid
694value causes a silent default to one of the valid values.
695
696The default reaction to a failed check was to call a function
697`mbedtls_param_failed()` which the application had to provide. If this function
698returned, its caller returned an error `MBEDTLS_ERR_xxx_BAD_INPUT_DATA`.
699
700This feature was only used in some classic (non-PSA) cryptography modules. It was
701not used in X.509, TLS or in PSA crypto, and it was not implemented in all
702classic crypto modules.
703
704This feature has been removed. The library no longer checks for NULL pointers;
705checks for enum-like arguments will be kept or re-introduced on a case-by-case
706basis, but their presence will no longer be dependent on a compile-time option.
707
708Validation of enum-like values is somewhat useful, but not extremely important,
709because the parameters concerned are usually constants in applications.
710
711For more information see issue #4313.
Dave Rodgman759c0102021-06-29 15:55:08 +0100712
Dave Rodgmand267ec32021-06-29 21:31:58 +0100713### Remove `MBEDTLS_SSL_RECORD_CHECKING` option and enable its action by default
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100714
715This change does not affect users who use the default mbedtls_config.h, as the
716option MBEDTLS_SSL_RECORD_CHECKING was already on by default.
717
718This option was added only to control compilation of one function,
719mbedtls_ssl_check_record(), which is only useful in some specific cases, so it
720was made optional to allow users who don't need it to save some code space.
721However, the same effect can be achieve by using link-time garbage collection.
722
723Users who changed the default setting of the option need to change the config/
724build system to remove that change.
Dave Rodgman759c0102021-06-29 15:55:08 +0100725
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100726### Remove the `MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3` option
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100727
728This change does not affect users who were using the default configuration, as
729this option was already disabled by default. Also, it does not affect users who
730are working with current V3 X.509 certificates.
731
732Extensions were added in V3 of the X.509 specification, so pre-V3 certificates
733containing extensions were never compliant. Mbed TLS now rejects them with a
734parsing error in all configurations, as it did previously in the default
735configuration.
736
737If you are working with the pre-V3 certificates you need to switch to the
738current ones.
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100739
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100740### Rename mbedtls_*_ret() cryptography functions whose deprecated variants have been removed
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100741
742This change affects users who were using the `mbedtls_*_ret()` cryptography
743functions.
744
745Those functions were created based on now-deprecated functions according to a
746requirement that a function needs to return a value. This change brings back the
747original names of those functions. The renamed functions are:
748
749| name before this change | after the change |
750|------------------------------|--------------------------|
751| mbedtls_ctr_drbg_update_ret | mbedtls_ctr_drbg_update |
752| mbedtls_hmac_drbg_update_ret | mbedtls_hmac_drbg_update |
753| mbedtls_md5_starts_ret | mbedtls_md5_starts |
754| mbedtls_md5_update_ret | mbedtls_md5_update |
755| mbedtls_md5_finish_ret | mbedtls_md5_finish |
756| mbedtls_md5_ret | mbedtls_md5 |
757| mbedtls_ripemd160_starts_ret | mbedtls_ripemd160_starts |
758| mbedtls_ripemd160_update_ret | mbedtls_ripemd160_update |
759| mbedtls_ripemd160_finish_ret | mbedtls_ripemd160_finish |
760| mbedtls_ripemd160_ret | mbedtls_ripemd160 |
761| mbedtls_sha1_starts_ret | mbedtls_sha1_starts |
762| mbedtls_sha1_update_ret | mbedtls_sha1_update |
763| mbedtls_sha1_finish_ret | mbedtls_sha1_finish |
764| mbedtls_sha1_ret | mbedtls_sha1 |
765| mbedtls_sha256_starts_ret | mbedtls_sha256_starts |
766| mbedtls_sha256_update_ret | mbedtls_sha256_update |
767| mbedtls_sha256_finish_ret | mbedtls_sha256_finish |
768| mbedtls_sha256_ret | mbedtls_sha256 |
769| mbedtls_sha512_starts_ret | mbedtls_sha512_starts |
770| mbedtls_sha512_update_ret | mbedtls_sha512_update |
771| mbedtls_sha512_finish_ret | mbedtls_sha512_finish |
772| mbedtls_sha512_ret | mbedtls_sha512 |
773
774To migrate to the this change the user can keep the `*_ret` names in their code
775and include the `compat_2.x.h` header file which holds macros with proper
776renaming or to rename those function in their code according to the list from
777mentioned header file.
778
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100779### Signature functions now require the hash length to match the expected value
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100780
781This 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.
782
783All the functions in the RSA module that accept a `hashlen` parameter used to
784ignore it unless the `md_alg` parameter was `MBEDTLS_MD_NONE`, indicating raw
785data was signed. The `hashlen` parameter is now always the size that is read
786from the `hash` input buffer. This length must be equal to the output size of
787the hash algorithm used when signing a hash. (The requirements when signing
788raw data are unchanged.) This affects the following functions:
789
790* `mbedtls_rsa_pkcs1_sign`, `mbedtls_rsa_pkcs1_verify`
791* `mbedtls_rsa_rsassa_pkcs1_v15_sign`, `mbedtls_rsa_rsassa_pkcs1_v15_verify`
792* `mbedtls_rsa_rsassa_pss_sign`, `mbedtls_rsa_rsassa_pss_verify`
793* `mbedtls_rsa_rsassa_pss_sign_ext`, `mbedtls_rsa_rsassa_pss_verify_ext`
794
795The 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:
796
797* `mbedtls_pk_sign`, `mbedtls_pk_verify`
798* `mbedtls_pk_sign_restartable`, `mbedtls_pk_verify_restartable`
799* `mbedtls_pk_verify_ext`
800
801The migration path is to pass the correct value to those functions.
Dave Rodgman759c0102021-06-29 15:55:08 +0100802
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100803### Remove the padding parameters from mbedtls_rsa_init()
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100804
805This affects all users who use the RSA encryption, decryption, sign and
806verify APIs.
807
808The function mbedtls_rsa_init() no longer supports selecting the PKCS#1 v2.1
809encoding and its hash. It just selects the PKCS#1 v1.5 encoding by default. If
810you were using the PKCS#1 v2.1 encoding you now need, subsequently to the call
811to mbedtls_rsa_init(), to call mbedtls_rsa_set_padding() to set it.
812
813To choose the padding type when initializing a context, instead of
814```C
815 mbedtls_rsa_init(ctx, padding, hash_id);
816```
817, use
818```C
819 mbedtls_rsa_init(ctx);
820 mbedtls_rsa_set_padding(ctx, padding, hash_id);
821```
822
823To use PKCS#1 v1.5 padding, instead of
824```C
825 mbedtls_rsa_init(ctx, MBEDTLS_RSA_PKCS_V15, <ignored>);
826```
827, just use
828```C
829 mbedtls_rsa_init(ctx);
830```
Dave Rodgman759c0102021-06-29 15:55:08 +0100831
Dave Rodgmand267ec32021-06-29 21:31:58 +0100832### Separated `MBEDTLS_SHA224_C` and `MBEDTLS_SHA256_C`
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100833
834This does not affect users who use the default `mbedtls_config.h`. MBEDTLS_SHA256_C
835was enabled by default. Now both MBEDTLS_SHA256_C and MBEDTLS_SHA224_C are
836enabled.
837
838If you were using custom config file with MBEDTLS_SHA256_C enabled, then
839you will need to add `#define MBEDTLS_SHA224_C` option your config.
840Current version of the library does not support enabling MBEDTLS_SHA256_C
841without MBEDTLS_SHA224_C.
Dave Rodgman759c0102021-06-29 15:55:08 +0100842
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100843### Session Cache API Change
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100844
845This affects users who use `mbedtls_ssl_conf_session_cache()`
846to configure a custom session cache implementation different
847from the one Mbed TLS implements in `library/ssl_cache.c`.
848
849Those users will need to modify the API of their session cache
850implementation to that of a key-value store with keys being
851session IDs and values being instances of `mbedtls_ssl_session`:
852
853```
854typedef int mbedtls_ssl_cache_get_t( void *data,
855 unsigned char const *session_id,
856 size_t session_id_len,
857 mbedtls_ssl_session *session );
858typedef int mbedtls_ssl_cache_set_t( void *data,
859 unsigned char const *session_id,
860 size_t session_id_len,
861 const mbedtls_ssl_session *session );
862```
863
864Since the structure of `mbedtls_ssl_session` is no longer public from 3.0
865onwards, portable session cache implementations must not access fields of
866`mbedtls_ssl_session`. See the corresponding migration guide. Users that
867find themselves unable to migrate their session cache functionality without
Dave Rodgman759c0102021-06-29 15:55:08 +0100868accessing fields of `mbedtls_ssl_session` should describe their use case
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100869on the Mbed TLS mailing list.
Dave Rodgman759c0102021-06-29 15:55:08 +0100870
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100871### SHA-512 and SHA-256 output type change
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100872
873The output parameter of `mbedtls_sha256_finish_ret()`, `mbedtls_sha256_ret()`, `mbedtls_sha512_finish_ret()`, `mbedtls_sha512_ret()` 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.
874
875This 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.
876
877Alternative implementations of the SHA256 and SHA512 modules must adjust their functions' prototype accordingly.
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100878
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100879### Removal of some SSL error codes
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100880
881This affects users manually checking for the following error codes:
Dave Rodgman759c0102021-06-29 15:55:08 +0100882
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100883- `MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED`
884- `MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH`
885- `MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE`
886- `MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN`
887- `MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE`
888- `MBEDTLS_ERR_SSL_BAD_HS_XXX`
889
890Migration paths:
891- `MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED` and `MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH`
892 should never be returned from Mbed TLS, and there is no need to check for it.
Dave Rodgman759c0102021-06-29 15:55:08 +0100893
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100894 Users should simply remove manual checks for those codes, and let the Mbed TLS
Dave Rodgman949c21b2021-06-29 18:05:04 +0100895 team know if contrary to the team's understanding — there is in fact a situation
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100896 where one of them was ever returned.
Dave Rodgman759c0102021-06-29 15:55:08 +0100897
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100898- `MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE` has been removed, and
899 `MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL` is returned instead if the user's own certificate
Dave Rodgman759c0102021-06-29 15:55:08 +0100900 is too large to fit into the output buffers.
901
902 Users should check for `MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL` instead, and potentially
903 compare the size of their own certificate against the configured size of the output buffer to
904 understand if the error is due to an overly large certificate.
905
906- `MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN` and `MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE` have been replaced by `MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE`
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100907
Dave Rodgman759c0102021-06-29 15:55:08 +0100908- all codes of the form `MBEDTLS_ERR_SSL_BAD_HS_XXX` have been replaced by various alternatives.
909
Dave Rodgmand267ec32021-06-29 21:31:58 +0100910### Modified semantics of `mbedtls_ssl_{get,set}_session()`
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100911
912This affects users who call `mbedtls_ssl_get_session()` or
913`mbedtls_ssl_set_session()` multiple times on the same SSL context
914representing an established TLS 1.2 connection.
915Those users will now observe the second call to fail with
916`MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE`.
917
918Migration path:
919- Exporting the same TLS 1.2 connection multiple times via
920 `mbedtls_ssl_get_session()` leads to multiple copies of
921 the same session. This use of `mbedtls_ssl_get_session()`
922 is discouraged, and the following should be considered:
923 * If the various session copies are later loaded into
924 fresh SSL contexts via `mbedtls_ssl_set_session()`,
925 export via `mbedtls_ssl_get_session()` only once and
926 load the same session into different contexts via
927 `mbedtls_ssl_set_session()`. Since `mbedtls_ssl_set_session()`
928 makes a copy of the session that's being loaded, this
929 is functionally equivalent.
930 * If the various session copies are later serialized
931 via `mbedtls_ssl_session_save()`, export and serialize
932 the session only once via `mbedtls_ssl_get_session()` and
933 `mbedtls_ssl_session_save()` and make copies of the raw
934 data instead.
935- Calling `mbedtls_ssl_set_session()` multiple times in Mbed TLS 2.x
936 is not useful since subsequent calls overwrite the effect of previous
Dave Rodgman759c0102021-06-29 15:55:08 +0100937 calls. Applications achieve equivalent functional behavior by
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100938 issuing only the very last call to `mbedtls_ssl_set_session()`.
939
Dave Rodgmand267ec32021-06-29 21:31:58 +0100940### Turn `MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE` configuration option into a runtime option
Dave Rodgman8cccbe12021-06-29 13:15:50 +0100941
942This change affects users who were enabling MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE
943option in the `mbedtls_config.h`
944
945This option has been removed and a new function with similar functionality has
946been introduced into the SSL API.
947
948This new function `mbedtls_ssl_conf_preference_order()` can be used to
949change the preferred order of ciphersuites on the server to those used on the client,
950e.g.: `mbedtls_ssl_conf_preference_order(ssl_config, MBEDTLS_SSL_SRV_CIPHERSUITE_ORDER_CLIENT)`
951has the same effect as enabling the removed option. The default state is to use
952the server order of suites.
Dave Rodgmane45e6402021-06-29 13:21:55 +0100953
Dave Rodgmana0e8db02021-06-29 18:05:38 +0100954### Some function parameters were made const
Dave Rodgmane45e6402021-06-29 13:21:55 +0100955
956Various functions in the PK and ASN.1 modules had a `const` qualifier added to
957some of their parameters.
958
959This normally doesn't affect your code, unless you use pointers to reference
960those functions. In this case, you'll need to update the type of your pointers
961in order to match the new signature.