Skip to content

Commit b28636b

Browse files
Merge tag 'mbedtls-2.16.0' into all_sh-2.14
Merge the work on all.sh that was done on mbedtls-2.14.0 with the changes from mbedtls-2.14.0 to mbedtls-2.16.0. There is a merge conflict in test/scripts/all.sh, which is the only file that was modified in the all.sh work branch. I resolved it by taking the copy from the all.sh branch and applying the changes between mbedtls-2.14.0 and mbedtls-2.16.0. These changes consisted of two commits: * "Add tests to all.sh for CHECK_PARAMS edge cases": adds two test components which are reproduced here as test_check_params_without_platform and component_test_check_params_silent. * "tests: Backup config.h before modifying it": moot because the component framework introduced in the all.sh branch backs up config.h systematically.
2 parents 608953e + fb1972d commit b28636b

File tree

181 files changed

+10559
-2487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+10559
-2487
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ compiler:
44
- gcc
55
sudo: false
66
cache: ccache
7+
8+
# blocklist
9+
branches:
10+
except:
11+
- development-psa
12+
- coverity_scan
13+
714
script:
815
- tests/scripts/recursion.pl library/*.c
916
- tests/scripts/check-generated-files.sh
@@ -34,7 +41,7 @@ addons:
3441
coverity_scan:
3542
project:
3643
name: "ARMmbed/mbedtls"
37-
notification_email: [email protected]
44+
notification_email: [email protected]
3845
build_command_prepend:
3946
build_command: make
4047
branch_pattern: coverity_scan

ChangeLog

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,91 @@
11
mbed TLS ChangeLog (Sorted per branch, date)
22

3+
= mbed TLS 2.16.0 branch released 2018-12-21
4+
5+
Features
6+
* Add a new config.h option of MBEDTLS_CHECK_PARAMS that enables validation
7+
of parameters in the API. This allows detection of obvious misuses of the
8+
API, such as passing NULL pointers. The API of existing functions hasn't
9+
changed, but requirements on parameters have been made more explicit in
10+
the documentation. See the corresponding API documentation for each
11+
function to see for which parameter values it is defined. This feature is
12+
disabled by default. See its API documentation in config.h for additional
13+
steps you have to take when enabling it.
14+
15+
API Changes
16+
* The following functions in the random generator modules have been
17+
deprecated and replaced as shown below. The new functions change
18+
the return type from void to int to allow returning error codes when
19+
using MBEDTLS_<MODULE>_ALT for the underlying AES or message digest
20+
primitive. Fixes #1798.
21+
mbedtls_ctr_drbg_update() -> mbedtls_ctr_drbg_update_ret()
22+
mbedtls_hmac_drbg_update() -> mbedtls_hmac_drbg_update_ret()
23+
* Extend ECDH interface to enable alternative implementations.
24+
* Deprecate error codes of the form MBEDTLS_ERR_xxx_INVALID_KEY_LENGTH for
25+
ARIA, CAMELLIA and Blowfish. These error codes will be replaced by
26+
the more generic per-module error codes MBEDTLS_ERR_xxx_BAD_INPUT_DATA.
27+
* Additional parameter validation checks have been added for the following
28+
modules - AES, ARIA, Blowfish, CAMELLIA, CCM, GCM, DHM, ECP, ECDSA, ECDH,
29+
ECJPAKE, SHA, Chacha20 and Poly1305, cipher, pk, RSA, and MPI.
30+
Where modules have had parameter validation added, existing parameter
31+
checks may have changed. Some modules, such as Chacha20 had existing
32+
parameter validation whereas other modules had little. This has now been
33+
changed so that the same level of validation is present in all modules, and
34+
that it is now optional with the MBEDTLS_CHECK_PARAMS flag which by default
35+
is off. That means that checks which were previously present by default
36+
will no longer be.
37+
38+
New deprecations
39+
* Deprecate mbedtls_ctr_drbg_update and mbedtls_hmac_drbg_update
40+
in favor of functions that can return an error code.
41+
42+
Bugfix
43+
* Fix for Clang, which was reporting a warning for the bignum.c inline
44+
assembly for AMD64 targets creating string literals greater than those
45+
permitted by the ISO C99 standard. Found by Aaron Jones. Fixes #482.
46+
* Fix runtime error in `mbedtls_platform_entropy_poll()` when run
47+
through qemu user emulation. Reported and fix suggested by randombit
48+
in #1212. Fixes #1212.
49+
* Fix an unsafe bounds check when restoring an SSL session from a ticket.
50+
This could lead to a buffer overflow, but only in case ticket authentication
51+
was broken. Reported and fix suggested by Guido Vranken in #659.
52+
* Add explicit integer to enumeration type casts to example program
53+
programs/pkey/gen_key which previously led to compilation failure
54+
on some toolchains. Reported by phoenixmcallister. Fixes #2170.
55+
* Fix double initialization of ECC hardware that made some accelerators
56+
hang.
57+
* Clarify documentation of mbedtls_ssl_set_own_cert() regarding the absence
58+
of check for certificate/key matching. Reported by Attila Molnar, #507.
59+
60+
= mbed TLS 2.14.1 branch released 2018-11-30
61+
62+
Security
63+
* Fix timing variations and memory access variations in RSA PKCS#1 v1.5
64+
decryption that could lead to a Bleichenbacher-style padding oracle
65+
attack. In TLS, this affects servers that accept ciphersuites based on
66+
RSA decryption (i.e. ciphersuites whose name contains RSA but not
67+
(EC)DH(E)). Discovered by Eyal Ronen (Weizmann Institute), Robert Gillham
68+
(University of Adelaide), Daniel Genkin (University of Michigan),
69+
Adi Shamir (Weizmann Institute), David Wong (NCC Group), and Yuval Yarom
70+
(University of Adelaide, Data61). The attack is described in more detail
71+
in the paper available here: http://cat.eyalro.net/cat.pdf CVE-2018-19608
72+
* In mbedtls_mpi_write_binary(), don't leak the exact size of the number
73+
via branching and memory access patterns. An attacker who could submit
74+
a plaintext for RSA PKCS#1 v1.5 decryption but only observe the timing
75+
of the decryption and not its result could nonetheless decrypt RSA
76+
plaintexts and forge RSA signatures. Other asymmetric algorithms may
77+
have been similarly vulnerable. Reported by Eyal Ronen, Robert Gillham,
78+
Daniel Genkin, Adi Shamir, David Wong and Yuval Yarom.
79+
* Wipe sensitive buffers on the stack in the CTR_DRBG and HMAC_DRBG
80+
modules.
81+
82+
API Changes
83+
* The new functions mbedtls_ctr_drbg_update_ret() and
84+
mbedtls_hmac_drbg_update_ret() are similar to mbedtls_ctr_drbg_update()
85+
and mbedtls_hmac_drbg_update() respectively, but the new functions
86+
report errors whereas the old functions return void. We recommend that
87+
applications use the new functions.
88+
389
= mbed TLS 2.14.0 branch released 2018-11-19
490

591
Security

doxygen/input/doc_mainpage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
/**
27-
* @mainpage mbed TLS v2.14.0 source code documentation
27+
* @mainpage mbed TLS v2.16.0 source code documentation
2828
*
2929
* This documentation describes the internal structure of mbed TLS. It was
3030
* automatically generated from specially formatted comment blocks in

doxygen/mbedtls.doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ DOXYFILE_ENCODING = UTF-8
2828
# identify the project. Note that if you do not use Doxywizard you need
2929
# to put quotes around the project name if it contains spaces.
3030

31-
PROJECT_NAME = "mbed TLS v2.14.0"
31+
PROJECT_NAME = "mbed TLS v2.16.0"
3232

3333
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
3434
# This could be handy for archiving the generated documentation or

include/mbedtls/aes.h

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,16 @@ typedef struct mbedtls_aes_xts_context
121121
* It must be the first API called before using
122122
* the context.
123123
*
124-
* \param ctx The AES context to initialize.
124+
* \param ctx The AES context to initialize. This must not be \c NULL.
125125
*/
126126
void mbedtls_aes_init( mbedtls_aes_context *ctx );
127127

128128
/**
129129
* \brief This function releases and clears the specified AES context.
130130
*
131131
* \param ctx The AES context to clear.
132+
* If this is \c NULL, this function does nothing.
133+
* Otherwise, the context must have been at least initialized.
132134
*/
133135
void mbedtls_aes_free( mbedtls_aes_context *ctx );
134136

@@ -139,14 +141,16 @@ void mbedtls_aes_free( mbedtls_aes_context *ctx );
139141
* It must be the first API called before using
140142
* the context.
141143
*
142-
* \param ctx The AES XTS context to initialize.
144+
* \param ctx The AES XTS context to initialize. This must not be \c NULL.
143145
*/
144146
void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx );
145147

146148
/**
147149
* \brief This function releases and clears the specified AES XTS context.
148150
*
149151
* \param ctx The AES XTS context to clear.
152+
* If this is \c NULL, this function does nothing.
153+
* Otherwise, the context must have been at least initialized.
150154
*/
151155
void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
152156
#endif /* MBEDTLS_CIPHER_MODE_XTS */
@@ -155,7 +159,9 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
155159
* \brief This function sets the encryption key.
156160
*
157161
* \param ctx The AES context to which the key should be bound.
162+
* It must be initialized.
158163
* \param key The encryption key.
164+
* This must be a readable buffer of size \p keybits bits.
159165
* \param keybits The size of data passed in bits. Valid options are:
160166
* <ul><li>128 bits</li>
161167
* <li>192 bits</li>
@@ -171,7 +177,9 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
171177
* \brief This function sets the decryption key.
172178
*
173179
* \param ctx The AES context to which the key should be bound.
180+
* It must be initialized.
174181
* \param key The decryption key.
182+
* This must be a readable buffer of size \p keybits bits.
175183
* \param keybits The size of data passed. Valid options are:
176184
* <ul><li>128 bits</li>
177185
* <li>192 bits</li>
@@ -189,8 +197,10 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
189197
* sets the encryption key.
190198
*
191199
* \param ctx The AES XTS context to which the key should be bound.
200+
* It must be initialized.
192201
* \param key The encryption key. This is comprised of the XTS key1
193202
* concatenated with the XTS key2.
203+
* This must be a readable buffer of size \p keybits bits.
194204
* \param keybits The size of \p key passed in bits. Valid options are:
195205
* <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
196206
* <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
@@ -207,8 +217,10 @@ int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
207217
* sets the decryption key.
208218
*
209219
* \param ctx The AES XTS context to which the key should be bound.
220+
* It must be initialized.
210221
* \param key The decryption key. This is comprised of the XTS key1
211222
* concatenated with the XTS key2.
223+
* This must be a readable buffer of size \p keybits bits.
212224
* \param keybits The size of \p key passed in bits. Valid options are:
213225
* <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
214226
* <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
@@ -234,10 +246,13 @@ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
234246
* call to this API with the same context.
235247
*
236248
* \param ctx The AES context to use for encryption or decryption.
249+
* It must be initialized and bound to a key.
237250
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
238251
* #MBEDTLS_AES_DECRYPT.
239-
* \param input The 16-Byte buffer holding the input data.
240-
* \param output The 16-Byte buffer holding the output data.
252+
* \param input The buffer holding the input data.
253+
* It must be readable and at least \c 16 Bytes long.
254+
* \param output The buffer where the output data will be written.
255+
* It must be writeable and at least \c 16 Bytes long.
241256
242257
* \return \c 0 on success.
243258
*/
@@ -260,8 +275,8 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
260275
* mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
261276
* before the first call to this API with the same context.
262277
*
263-
* \note This function operates on aligned blocks, that is, the input size
264-
* must be a multiple of the AES block size of 16 Bytes.
278+
* \note This function operates on full blocks, that is, the input size
279+
* must be a multiple of the AES block size of \c 16 Bytes.
265280
*
266281
* \note Upon exit, the content of the IV is updated so that you can
267282
* call the same function again on the next
@@ -272,13 +287,17 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
272287
*
273288
*
274289
* \param ctx The AES context to use for encryption or decryption.
290+
* It must be initialized and bound to a key.
275291
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
276292
* #MBEDTLS_AES_DECRYPT.
277293
* \param length The length of the input data in Bytes. This must be a
278-
* multiple of the block size (16 Bytes).
294+
* multiple of the block size (\c 16 Bytes).
279295
* \param iv Initialization vector (updated after use).
296+
* It must be a readable and writeable buffer of \c 16 Bytes.
280297
* \param input The buffer holding the input data.
298+
* It must be readable and of size \p length Bytes.
281299
* \param output The buffer holding the output data.
300+
* It must be writeable and of size \p length Bytes.
282301
*
283302
* \return \c 0 on success.
284303
* \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
@@ -306,25 +325,26 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
306325
* returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
307326
*
308327
* \param ctx The AES XTS context to use for AES XTS operations.
328+
* It must be initialized and bound to a key.
309329
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
310330
* #MBEDTLS_AES_DECRYPT.
311-
* \param length The length of a data unit in bytes. This can be any
331+
* \param length The length of a data unit in Bytes. This can be any
312332
* length between 16 bytes and 2^24 bytes inclusive
313333
* (between 1 and 2^20 block cipher blocks).
314334
* \param data_unit The address of the data unit encoded as an array of 16
315335
* bytes in little-endian format. For disk encryption, this
316336
* is typically the index of the block device sector that
317337
* contains the data.
318338
* \param input The buffer holding the input data (which is an entire
319-
* data unit). This function reads \p length bytes from \p
339+
* data unit). This function reads \p length Bytes from \p
320340
* input.
321341
* \param output The buffer holding the output data (which is an entire
322-
* data unit). This function writes \p length bytes to \p
342+
* data unit). This function writes \p length Bytes to \p
323343
* output.
324344
*
325345
* \return \c 0 on success.
326346
* \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
327-
* smaller than an AES block in size (16 bytes) or if \p
347+
* smaller than an AES block in size (16 Bytes) or if \p
328348
* length is larger than 2^20 blocks (16 MiB).
329349
*/
330350
int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
@@ -360,13 +380,18 @@ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
360380
*
361381
*
362382
* \param ctx The AES context to use for encryption or decryption.
383+
* It must be initialized and bound to a key.
363384
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
364385
* #MBEDTLS_AES_DECRYPT.
365-
* \param length The length of the input data.
386+
* \param length The length of the input data in Bytes.
366387
* \param iv_off The offset in IV (updated after use).
388+
* It must point to a valid \c size_t.
367389
* \param iv The initialization vector (updated after use).
390+
* It must be a readable and writeable buffer of \c 16 Bytes.
368391
* \param input The buffer holding the input data.
392+
* It must be readable and of size \p length Bytes.
369393
* \param output The buffer holding the output data.
394+
* It must be writeable and of size \p length Bytes.
370395
*
371396
* \return \c 0 on success.
372397
*/
@@ -401,12 +426,16 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
401426
*
402427
*
403428
* \param ctx The AES context to use for encryption or decryption.
429+
* It must be initialized and bound to a key.
404430
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
405431
* #MBEDTLS_AES_DECRYPT
406432
* \param length The length of the input data.
407433
* \param iv The initialization vector (updated after use).
434+
* It must be a readable and writeable buffer of \c 16 Bytes.
408435
* \param input The buffer holding the input data.
436+
* It must be readable and of size \p length Bytes.
409437
* \param output The buffer holding the output data.
438+
* It must be writeable and of size \p length Bytes.
410439
*
411440
* \return \c 0 on success.
412441
*/
@@ -451,11 +480,16 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
451480
* will compromise security.
452481
*
453482
* \param ctx The AES context to use for encryption or decryption.
483+
* It must be initialized and bound to a key.
454484
* \param length The length of the input data.
455485
* \param iv_off The offset in IV (updated after use).
486+
* It must point to a valid \c size_t.
456487
* \param iv The initialization vector (updated after use).
488+
* It must be a readable and writeable buffer of \c 16 Bytes.
457489
* \param input The buffer holding the input data.
490+
* It must be readable and of size \p length Bytes.
458491
* \param output The buffer holding the output data.
492+
* It must be writeable and of size \p length Bytes.
459493
*
460494
* \return \c 0 on success.
461495
*/
@@ -527,15 +561,21 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
527561
* securely discarded as soon as it's no longer needed.
528562
*
529563
* \param ctx The AES context to use for encryption or decryption.
564+
* It must be initialized and bound to a key.
530565
* \param length The length of the input data.
531566
* \param nc_off The offset in the current \p stream_block, for
532567
* resuming within the current cipher stream. The
533568
* offset pointer should be 0 at the start of a stream.
569+
* It must point to a valid \c size_t.
534570
* \param nonce_counter The 128-bit nonce and counter.
571+
* It must be a readable-writeable buffer of \c 16 Bytes.
535572
* \param stream_block The saved stream block for resuming. This is
536573
* overwritten by the function.
574+
* It must be a readable-writeable buffer of \c 16 Bytes.
537575
* \param input The buffer holding the input data.
576+
* It must be readable and of size \p length Bytes.
538577
* \param output The buffer holding the output data.
578+
* It must be writeable and of size \p length Bytes.
539579
*
540580
* \return \c 0 on success.
541581
*/
@@ -588,7 +628,7 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
588628
* \brief Deprecated internal AES block encryption function
589629
* without return value.
590630
*
591-
* \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0.
631+
* \deprecated Superseded by mbedtls_internal_aes_encrypt()
592632
*
593633
* \param ctx The AES context to use for encryption.
594634
* \param input Plaintext block.
@@ -602,7 +642,7 @@ MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
602642
* \brief Deprecated internal AES block decryption function
603643
* without return value.
604644
*
605-
* \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0.
645+
* \deprecated Superseded by mbedtls_internal_aes_decrypt()
606646
*
607647
* \param ctx The AES context to use for decryption.
608648
* \param input Ciphertext block.

0 commit comments

Comments
 (0)