Skip to content

Commit de6d291

Browse files
authored
Merge pull request #4987 from andresag01/release-mbedtls-2.6.0
Update mbed TLS to version 2.6.0
2 parents 4b98566 + 7c8ed0c commit de6d291

Some content is hidden

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

43 files changed

+1794
-567
lines changed

features/mbedtls/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mbedtls-2.5.0
1+
mbedtls-2.6.0

features/mbedtls/importer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#
2828

2929
# Set the mbed TLS release to import (this can/should be edited before import)
30-
MBED_TLS_RELEASE ?= mbedtls-2.5.0
30+
MBED_TLS_RELEASE ?= mbedtls-2.6.0
3131

3232
# Translate between mbed TLS namespace and mbed namespace
3333
TARGET_PREFIX:=../

features/mbedtls/importer/adjust-config.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ conf unset MBEDTLS_RIPEMD160_C
112112
conf unset MBEDTLS_SHA1_C
113113
conf unset MBEDTLS_XTEA_C
114114

115+
conf set MBEDTLS_AES_ROM_TABLES
116+
115117
conf unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
116118

117119
conf unset MBEDTLS_X509_CSR_PARSE_C

features/mbedtls/inc/mbedtls/aes.h

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -287,42 +287,32 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
287287
#define MBEDTLS_DEPRECATED
288288
#endif
289289
/**
290-
* \brief Internal AES block encryption function
291-
* (Only exposed to allow overriding it,
292-
* see MBEDTLS_AES_ENCRYPT_ALT)
290+
* \brief Deprecated internal AES block encryption function
291+
* without return value.
293292
*
294293
* \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0
295294
*
296295
* \param ctx AES context
297296
* \param input Plaintext block
298297
* \param output Output (ciphertext) block
299298
*/
300-
MBEDTLS_DEPRECATED static inline void mbedtls_aes_encrypt(
301-
mbedtls_aes_context *ctx,
302-
const unsigned char input[16],
303-
unsigned char output[16] )
304-
{
305-
mbedtls_internal_aes_encrypt( ctx, input, output );
306-
}
299+
MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
300+
const unsigned char input[16],
301+
unsigned char output[16] );
307302

308303
/**
309-
* \brief Internal AES block decryption function
310-
* (Only exposed to allow overriding it,
311-
* see MBEDTLS_AES_DECRYPT_ALT)
304+
* \brief Deprecated internal AES block decryption function
305+
* without return value.
312306
*
313307
* \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0
314308
*
315309
* \param ctx AES context
316310
* \param input Ciphertext block
317311
* \param output Output (plaintext) block
318312
*/
319-
MBEDTLS_DEPRECATED static inline void mbedtls_aes_decrypt(
320-
mbedtls_aes_context *ctx,
321-
const unsigned char input[16],
322-
unsigned char output[16] )
323-
{
324-
mbedtls_internal_aes_decrypt( ctx, input, output );
325-
}
313+
MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
314+
const unsigned char input[16],
315+
unsigned char output[16] );
326316

327317
#undef MBEDTLS_DEPRECATED
328318
#endif /* !MBEDTLS_DEPRECATED_REMOVED */

features/mbedtls/inc/mbedtls/bignum.h

Lines changed: 77 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -103,36 +103,71 @@
103103
/*
104104
* Define the base integer type, architecture-wise.
105105
*
106-
* 32-bit integers can be forced on 64-bit arches (eg. for testing purposes)
107-
* by defining MBEDTLS_HAVE_INT32 and undefining MBEDTLS_HAVE_ASM
108-
*/
109-
#if ( ! defined(MBEDTLS_HAVE_INT32) && \
110-
defined(_MSC_VER) && defined(_M_AMD64) )
111-
#define MBEDTLS_HAVE_INT64
112-
typedef int64_t mbedtls_mpi_sint;
113-
typedef uint64_t mbedtls_mpi_uint;
114-
#else
115-
#if ( ! defined(MBEDTLS_HAVE_INT32) && \
116-
defined(__GNUC__) && ( \
117-
defined(__amd64__) || defined(__x86_64__) || \
118-
defined(__ppc64__) || defined(__powerpc64__) || \
119-
defined(__ia64__) || defined(__alpha__) || \
120-
(defined(__sparc__) && defined(__arch64__)) || \
121-
defined(__s390x__) || defined(__mips64) ) )
122-
#define MBEDTLS_HAVE_INT64
123-
typedef int64_t mbedtls_mpi_sint;
124-
typedef uint64_t mbedtls_mpi_uint;
125-
/* mbedtls_t_udbl defined as 128-bit unsigned int */
126-
typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
127-
#define MBEDTLS_HAVE_UDBL
128-
#else
129-
#define MBEDTLS_HAVE_INT32
130-
typedef int32_t mbedtls_mpi_sint;
131-
typedef uint32_t mbedtls_mpi_uint;
132-
typedef uint64_t mbedtls_t_udbl;
133-
#define MBEDTLS_HAVE_UDBL
134-
#endif /* !MBEDTLS_HAVE_INT32 && __GNUC__ && 64-bit platform */
135-
#endif /* !MBEDTLS_HAVE_INT32 && _MSC_VER && _M_AMD64 */
106+
* 32 or 64-bit integer types can be forced regardless of the underlying
107+
* architecture by defining MBEDTLS_HAVE_INT32 or MBEDTLS_HAVE_INT64
108+
* respectively and undefining MBEDTLS_HAVE_ASM.
109+
*
110+
* Double-width integers (e.g. 128-bit in 64-bit architectures) can be
111+
* disabled by defining MBEDTLS_NO_UDBL_DIVISION.
112+
*/
113+
#if !defined(MBEDTLS_HAVE_INT32)
114+
#if defined(_MSC_VER) && defined(_M_AMD64)
115+
/* Always choose 64-bit when using MSC */
116+
#if !defined(MBEDTLS_HAVE_INT64)
117+
#define MBEDTLS_HAVE_INT64
118+
#endif /* !MBEDTLS_HAVE_INT64 */
119+
typedef int64_t mbedtls_mpi_sint;
120+
typedef uint64_t mbedtls_mpi_uint;
121+
#elif defined(__GNUC__) && ( \
122+
defined(__amd64__) || defined(__x86_64__) || \
123+
defined(__ppc64__) || defined(__powerpc64__) || \
124+
defined(__ia64__) || defined(__alpha__) || \
125+
( defined(__sparc__) && defined(__arch64__) ) || \
126+
defined(__s390x__) || defined(__mips64) )
127+
#if !defined(MBEDTLS_HAVE_INT64)
128+
#define MBEDTLS_HAVE_INT64
129+
#endif /* MBEDTLS_HAVE_INT64 */
130+
typedef int64_t mbedtls_mpi_sint;
131+
typedef uint64_t mbedtls_mpi_uint;
132+
#if !defined(MBEDTLS_NO_UDBL_DIVISION)
133+
/* mbedtls_t_udbl defined as 128-bit unsigned int */
134+
typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
135+
#define MBEDTLS_HAVE_UDBL
136+
#endif /* !MBEDTLS_NO_UDBL_DIVISION */
137+
#elif defined(__ARMCC_VERSION) && defined(__aarch64__)
138+
/*
139+
* __ARMCC_VERSION is defined for both armcc and armclang and
140+
* __aarch64__ is only defined by armclang when compiling 64-bit code
141+
*/
142+
#if !defined(MBEDTLS_HAVE_INT64)
143+
#define MBEDTLS_HAVE_INT64
144+
#endif /* !MBEDTLS_HAVE_INT64 */
145+
typedef int64_t mbedtls_mpi_sint;
146+
typedef uint64_t mbedtls_mpi_uint;
147+
#if !defined(MBEDTLS_NO_UDBL_DIVISION)
148+
/* mbedtls_t_udbl defined as 128-bit unsigned int */
149+
typedef __uint128_t mbedtls_t_udbl;
150+
#define MBEDTLS_HAVE_UDBL
151+
#endif /* !MBEDTLS_NO_UDBL_DIVISION */
152+
#elif defined(MBEDTLS_HAVE_INT64)
153+
/* Force 64-bit integers with unknown compiler */
154+
typedef int64_t mbedtls_mpi_sint;
155+
typedef uint64_t mbedtls_mpi_uint;
156+
#endif
157+
#endif /* !MBEDTLS_HAVE_INT32 */
158+
159+
#if !defined(MBEDTLS_HAVE_INT64)
160+
/* Default to 32-bit compilation */
161+
#if !defined(MBEDTLS_HAVE_INT32)
162+
#define MBEDTLS_HAVE_INT32
163+
#endif /* !MBEDTLS_HAVE_INT32 */
164+
typedef int32_t mbedtls_mpi_sint;
165+
typedef uint32_t mbedtls_mpi_uint;
166+
#if !defined(MBEDTLS_NO_UDBL_DIVISION)
167+
typedef uint64_t mbedtls_t_udbl;
168+
#define MBEDTLS_HAVE_UDBL
169+
#endif /* !MBEDTLS_NO_UDBL_DIVISION */
170+
#endif /* !MBEDTLS_HAVE_INT64 */
136171

137172
#ifdef __cplusplus
138173
extern "C" {
@@ -340,7 +375,7 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
340375

341376
#if defined(MBEDTLS_FS_IO)
342377
/**
343-
* \brief Read X from an opened file
378+
* \brief Read MPI from a line in an opened file
344379
*
345380
* \param X Destination MPI
346381
* \param radix Input numeric base
@@ -349,6 +384,15 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
349384
* \return 0 if successful, MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if
350385
* the file read buffer is too small or a
351386
* MBEDTLS_ERR_MPI_XXX error code
387+
*
388+
* \note On success, this function advances the file stream
389+
* to the end of the current line or to EOF.
390+
*
391+
* The function returns 0 on an empty line.
392+
*
393+
* Leading whitespaces are ignored, as is a
394+
* '0x' prefix for radix 16.
395+
*
352396
*/
353397
int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin );
354398

@@ -665,8 +709,8 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B
665709
*
666710
* \return 0 if successful,
667711
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
668-
* MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
669-
MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
712+
* MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is <= 1,
713+
MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N.
670714
*/
671715
int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N );
672716

features/mbedtls/inc/mbedtls/check_config.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,15 @@
650650
#error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites"
651651
#endif
652652

653+
#if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64)
654+
#error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously"
655+
#endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */
656+
657+
#if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \
658+
defined(MBEDTLS_HAVE_ASM)
659+
#error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously"
660+
#endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */
661+
653662
/*
654663
* Avoid warning from -pedantic. This is a convenient place for this
655664
* workaround since this is included by every single file before the

features/mbedtls/inc/mbedtls/config-no-entropy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
#define MBEDTLS_X509_CRT_PARSE_C
8181
#define MBEDTLS_X509_CRL_PARSE_C
8282

83+
/* Miscellaneous options */
84+
#define MBEDTLS_AES_ROM_TABLES
85+
8386
#include "check_config.h"
8487

8588
#endif /* MBEDTLS_CONFIG_H */

features/mbedtls/inc/mbedtls/config.h

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,34 @@
7070
*/
7171
#define MBEDTLS_HAVE_ASM
7272

73+
/**
74+
* \def MBEDTLS_NO_UDBL_DIVISION
75+
*
76+
* The platform lacks support for double-width integer division (64-bit
77+
* division on a 32-bit platform, 128-bit division on a 64-bit platform).
78+
*
79+
* Used in:
80+
* include/mbedtls/bignum.h
81+
* library/bignum.c
82+
*
83+
* The bignum code uses double-width division to speed up some operations.
84+
* Double-width division is often implemented in software that needs to
85+
* be linked with the program. The presence of a double-width integer
86+
* type is usually detected automatically through preprocessor macros,
87+
* but the automatic detection cannot know whether the code needs to
88+
* and can be linked with an implementation of division for that type.
89+
* By default division is assumed to be usable if the type is present.
90+
* Uncomment this option to prevent the use of double-width division.
91+
*
92+
* Note that division for the native integer type is always required.
93+
* Furthermore, a 64-bit type is always required even on a 32-bit
94+
* platform, but it need not support multiplication or division. In some
95+
* cases it is also desirable to disable some double-width operations. For
96+
* example, if double-width division is implemented in software, disabling
97+
* it can reduce code size in some embedded targets.
98+
*/
99+
//#define MBEDTLS_NO_UDBL_DIVISION
100+
73101
/**
74102
* \def MBEDTLS_HAVE_SSE2
75103
*
@@ -178,6 +206,7 @@
178206
//#define MBEDTLS_PLATFORM_PRINTF_ALT
179207
//#define MBEDTLS_PLATFORM_SNPRINTF_ALT
180208
//#define MBEDTLS_PLATFORM_NV_SEED_ALT
209+
//#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT
181210

182211
/**
183212
* \def MBEDTLS_DEPRECATED_WARNING
@@ -288,9 +317,15 @@
288317
* of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible
289318
* with this definition.
290319
*
291-
* Note: if you use the AES_xxx_ALT macros, then is is recommended to also set
292-
* MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES
293-
* tables.
320+
* \note Because of a signature change, the core AES encryption and decryption routines are
321+
* currently named mbedtls_aes_internal_encrypt and mbedtls_aes_internal_decrypt,
322+
* respectively. When setting up alternative implementations, these functions should
323+
* be overriden, but the wrapper functions mbedtls_aes_decrypt and mbedtls_aes_encrypt
324+
* must stay untouched.
325+
*
326+
* \note If you use the AES_xxx_ALT macros, then is is recommended to also set
327+
* MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES
328+
* tables.
294329
*
295330
* Uncomment a macro to enable alternate implementation of the corresponding
296331
* function.
@@ -400,7 +435,7 @@
400435
*
401436
* Uncomment this macro to store the AES tables in ROM.
402437
*/
403-
//#define MBEDTLS_AES_ROM_TABLES
438+
#define MBEDTLS_AES_ROM_TABLES
404439

405440
/**
406441
* \def MBEDTLS_CAMELLIA_SMALL_MEMORY
@@ -2266,7 +2301,8 @@
22662301
* library/ssl_tls.c
22672302
* library/x509write_crt.c
22682303
*
2269-
* This module is required for SSL/TLS and SHA1-signed certificates.
2304+
* This module is required for SSL/TLS up to version 1.1, for TLS 1.2
2305+
* depending on the handshake parameters, and for SHA1-signed certificates.
22702306
*/
22712307
//#define MBEDTLS_SHA1_C
22722308

@@ -2651,6 +2687,26 @@
26512687
//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */
26522688
//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */
26532689

2690+
/**
2691+
* Allow SHA-1 in the default TLS configuration for certificate signing.
2692+
* Without this build-time option, SHA-1 support must be activated explicitly
2693+
* through mbedtls_ssl_conf_cert_profile. Turning on this option is not
2694+
* recommended because of it is possible to generte SHA-1 collisions, however
2695+
* this may be safe for legacy infrastructure where additional controls apply.
2696+
*/
2697+
// #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
2698+
2699+
/**
2700+
* Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake
2701+
* signature and ciphersuite selection. Without this build-time option, SHA-1
2702+
* support must be activated explicitly through mbedtls_ssl_conf_sig_hashes.
2703+
* The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by
2704+
* default. At the time of writing, there is no practical attack on the use
2705+
* of SHA-1 in handshake signatures, hence this option is turned on by default
2706+
* for compatibility with existing peers.
2707+
*/
2708+
#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE
2709+
26542710
/* \} name SECTION: Customisation configuration options */
26552711

26562712
/* Target and application specific configurations */

0 commit comments

Comments
 (0)