Skip to content

Commit 2a0f48a

Browse files
authored
Merge pull request #43 from Patater/update-2.16-dev
Update to a development version of Mbed TLS 2.16.0
2 parents 6fd4ee2 + 7f04214 commit 2a0f48a

Some content is hidden

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

49 files changed

+1641
-416
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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,58 @@ Changes
66
* Add unit tests for AES-GCM when called through mbedtls_cipher_auth_xxx()
77
from the cipher abstraction layer. Fixes #2198.
88

9+
= mbed TLS 2.14.0+01b34fb316a5 branch released xxxx-xx-xx
10+
11+
Security
12+
* Fix timing variations and memory access variations in RSA PKCS#1 v1.5
13+
decryption that could lead to a Bleichenbacher-style padding oracle
14+
attack. In TLS, this affects servers that accept ciphersuites based on
15+
RSA decryption (i.e. ciphersuites whose name contains RSA but not
16+
(EC)DH(E)). Discovered by Eyal Ronen (Weizmann Institute), Robert Gillham
17+
(University of Adelaide), Daniel Genkin (University of Michigan),
18+
Adi Shamir (Weizmann Institute), David Wong (NCC Group), and Yuval Yarom
19+
(University of Adelaide, Data61). The attack is described in more detail
20+
in the paper available here: http://cat.eyalro.net/cat.pdf CVE-2018-19608
21+
* In mbedtls_mpi_write_binary(), don't leak the exact size of the number
22+
via branching and memory access patterns. An attacker who could submit
23+
a plaintext for RSA PKCS#1 v1.5 decryption but only observe the timing
24+
of the decryption and not its result could nonetheless decrypt RSA
25+
plaintexts and forge RSA signatures. Other asymmetric algorithms may
26+
have been similarly vulnerable. Reported by Eyal Ronen, Robert Gillham,
27+
Daniel Genkin, Adi Shamir, David Wong and Yuval Yarom.
28+
* Wipe sensitive buffers on the stack in the CTR_DRBG and HMAC_DRBG
29+
modules.
30+
31+
API Changes
32+
* The following functions in the random generator modules have been
33+
deprecated and replaced as shown below. The new functions change
34+
the return type from void to int to allow returning error codes when
35+
using MBEDTLS_<MODULE>_ALT for the underlying AES or message digest
36+
primitive. Fixes #1798.
37+
mbedtls_ctr_drbg_update() -> mbedtls_ctr_drbg_update_ret()
38+
mbedtls_hmac_drbg_update() -> mbedtls_hmac_drbg_update_ret()
39+
* Extend ECDH interface to enable alternative implementations.
40+
41+
New deprecations
42+
* Deprecate mbedtls_ctr_drbg_update and mbedtls_hmac_drbg_update
43+
in favor of functions that can return an error code.
44+
45+
Bugfix
46+
* Fix for Clang, which was reporting a warning for the bignum.c inline
47+
assembly for AMD64 targets creating string literals greater than those
48+
permitted by the ISO C99 standard. Found by Aaron Jones. Fixes #482.
49+
* Fix runtime error in `mbedtls_platform_entropy_poll()` when run
50+
through qemu user emulation. Reported and fix suggested by randombit
51+
in #1212. Fixes #1212.
52+
* Fix an unsafe bounds check when restoring an SSL session from a ticket.
53+
This could lead to a buffer overflow, but only in case ticket authentication
54+
was broken. Reported and fix suggested by Guido Vranken in #659.
55+
* Add explicit integer to enumeration type casts to example program
56+
programs/pkey/gen_key which previously led to compilation failure
57+
on some toolchains. Reported by phoenixmcallister. Fixes #2170.
58+
* Fix double initialization of ECC hardware that made some accelerators
59+
hang.
60+
961
= mbed TLS 2.14.0 branch released 2018-11-19
1062

1163
Security

include/mbedtls/bn_mul.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,19 @@
170170

171171
#define MULADDC_INIT \
172172
asm( \
173-
"xorq %%r8, %%r8 \n\t"
173+
"xorq %%r8, %%r8\n"
174174

175175
#define MULADDC_CORE \
176-
"movq (%%rsi), %%rax \n\t" \
177-
"mulq %%rbx \n\t" \
178-
"addq $8, %%rsi \n\t" \
179-
"addq %%rcx, %%rax \n\t" \
180-
"movq %%r8, %%rcx \n\t" \
181-
"adcq $0, %%rdx \n\t" \
182-
"nop \n\t" \
183-
"addq %%rax, (%%rdi) \n\t" \
184-
"adcq %%rdx, %%rcx \n\t" \
185-
"addq $8, %%rdi \n\t"
176+
"movq (%%rsi), %%rax\n" \
177+
"mulq %%rbx\n" \
178+
"addq $8, %%rsi\n" \
179+
"addq %%rcx, %%rax\n" \
180+
"movq %%r8, %%rcx\n" \
181+
"adcq $0, %%rdx\n" \
182+
"nop \n" \
183+
"addq %%rax, (%%rdi)\n" \
184+
"adcq %%rdx, %%rcx\n" \
185+
"addq $8, %%rdi\n"
186186

187187
#define MULADDC_STOP \
188188
: "+c" (c), "+D" (d), "+S" (s) \

include/mbedtls/check_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
defined(MBEDTLS_ECDSA_SIGN_ALT) || \
115115
defined(MBEDTLS_ECDSA_VERIFY_ALT) || \
116116
defined(MBEDTLS_ECDSA_GENKEY_ALT) || \
117+
defined(MBEDTLS_ECP_INTERNAL_ALT) || \
117118
defined(MBEDTLS_ECP_ALT) )
118119
#error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative ECP implementation"
119120
#endif
@@ -137,6 +138,10 @@
137138
#error "MBEDTLS_ECP_C defined, but not all prerequisites"
138139
#endif
139140

141+
#if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_ASN1_PARSE_C)
142+
#error "MBEDTLS_PK_PARSE_C defined, but not all prerequesites"
143+
#endif
144+
140145
#if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \
141146
!defined(MBEDTLS_SHA256_C))
142147
#error "MBEDTLS_ENTROPY_C defined, but not all prerequisites"

include/mbedtls/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,11 @@
414414
* unsigned char mbedtls_internal_ecp_grp_capable(
415415
* const mbedtls_ecp_group *grp )
416416
* int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp )
417-
* void mbedtls_internal_ecp_deinit( const mbedtls_ecp_group *grp )
417+
* void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp )
418418
* The mbedtls_internal_ecp_grp_capable function should return 1 if the
419419
* replacement functions implement arithmetic for the given group and 0
420420
* otherwise.
421-
* The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_deinit are
421+
* The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_free are
422422
* called before and after each point operation and provide an opportunity to
423423
* implement optimized set up and tear down instructions.
424424
*

include/mbedtls/ctr_drbg.h

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,18 +239,20 @@ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx,
239239
/**
240240
* \brief This function updates the state of the CTR_DRBG context.
241241
*
242-
* \note If \p add_len is greater than
243-
* #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT, only the first
244-
* #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT Bytes are used.
245-
* The remaining Bytes are silently discarded.
246-
*
247242
* \param ctx The CTR_DRBG context.
248243
* \param additional The data to update the state with.
249-
* \param add_len Length of \p additional data.
250-
*
244+
* \param add_len Length of \p additional in bytes. This must be at
245+
* most #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT.
246+
*
247+
* \return \c 0 on success.
248+
* \return #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG if
249+
* \p add_len is more than
250+
* #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT.
251+
* \return An error from the underlying AES cipher on failure.
251252
*/
252-
void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx,
253-
const unsigned char *additional, size_t add_len );
253+
int mbedtls_ctr_drbg_update_ret( mbedtls_ctr_drbg_context *ctx,
254+
const unsigned char *additional,
255+
size_t add_len );
254256

255257
/**
256258
* \brief This function updates a CTR_DRBG instance with additional
@@ -290,6 +292,35 @@ int mbedtls_ctr_drbg_random_with_add( void *p_rng,
290292
int mbedtls_ctr_drbg_random( void *p_rng,
291293
unsigned char *output, size_t output_len );
292294

295+
296+
#if ! defined(MBEDTLS_DEPRECATED_REMOVED)
297+
#if defined(MBEDTLS_DEPRECATED_WARNING)
298+
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
299+
#else
300+
#define MBEDTLS_DEPRECATED
301+
#endif
302+
/**
303+
* \brief This function updates the state of the CTR_DRBG context.
304+
*
305+
* \deprecated Superseded by mbedtls_ctr_drbg_update_ret()
306+
* in 2.16.0.
307+
*
308+
* \note If \p add_len is greater than
309+
* #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT, only the first
310+
* #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT Bytes are used.
311+
* The remaining Bytes are silently discarded.
312+
*
313+
* \param ctx The CTR_DRBG context.
314+
* \param additional The data to update the state with.
315+
* \param add_len Length of \p additional data.
316+
*/
317+
MBEDTLS_DEPRECATED void mbedtls_ctr_drbg_update(
318+
mbedtls_ctr_drbg_context *ctx,
319+
const unsigned char *additional,
320+
size_t add_len );
321+
#undef MBEDTLS_DEPRECATED
322+
#endif /* !MBEDTLS_DEPRECATED_REMOVED */
323+
293324
#if defined(MBEDTLS_FS_IO)
294325
/**
295326
* \brief This function writes a seed file.

include/mbedtls/debug.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt )
6666
#endif
6767

68+
#if defined(MBEDTLS_ECDH_C)
69+
#define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) \
70+
mbedtls_debug_printf_ecdh( ssl, level, __FILE__, __LINE__, ecdh, attr )
71+
#endif
72+
6873
#else /* MBEDTLS_DEBUG_C */
6974

7075
#define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 )
@@ -73,6 +78,7 @@
7378
#define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
7479
#define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 )
7580
#define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
81+
#define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) do { } while( 0 )
7682

7783
#endif /* MBEDTLS_DEBUG_C */
7884

@@ -221,6 +227,36 @@ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
221227
const char *text, const mbedtls_x509_crt *crt );
222228
#endif
223229

230+
#if defined(MBEDTLS_ECDH_C)
231+
typedef enum
232+
{
233+
MBEDTLS_DEBUG_ECDH_Q,
234+
MBEDTLS_DEBUG_ECDH_QP,
235+
MBEDTLS_DEBUG_ECDH_Z,
236+
} mbedtls_debug_ecdh_attr;
237+
238+
/**
239+
* \brief Print a field of the ECDH structure in the SSL context to the debug
240+
* output. This function is always used through the
241+
* MBEDTLS_SSL_DEBUG_ECDH() macro, which supplies the ssl context, file
242+
* and line number parameters.
243+
*
244+
* \param ssl SSL context
245+
* \param level error level of the debug message
246+
* \param file file the error has occurred in
247+
* \param line line number the error has occurred in
248+
* \param ecdh the ECDH context
249+
* \param attr the identifier of the attribute being output
250+
*
251+
* \attention This function is intended for INTERNAL usage within the
252+
* library only.
253+
*/
254+
void mbedtls_debug_printf_ecdh( const mbedtls_ssl_context *ssl, int level,
255+
const char *file, int line,
256+
const mbedtls_ecdh_context *ecdh,
257+
mbedtls_debug_ecdh_attr attr );
258+
#endif
259+
224260
#ifdef __cplusplus
225261
}
226262
#endif

0 commit comments

Comments
 (0)