Skip to content

Commit 67f8092

Browse files
authored
Merge pull request ARMmbed#3877 from andresag01/update-mbedtls-2.4.2
Update mbed TLS feature to mbedtls-2.4.2
2 parents 8a56c8c + 1c8d7c1 commit 67f8092

29 files changed

+403
-259
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.4.0
1+
mbedtls-2.4.2

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.4.0
30+
MBED_TLS_RELEASE ?= mbedtls-2.4.2
3131

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

features/mbedtls/inc/mbedtls/cmac.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ struct mbedtls_cmac_context_t
5858
/**
5959
* \brief Set the CMAC key and prepare to authenticate the input
6060
* data.
61-
* Should be called with an initialised cipher context.
61+
* Should be called with an initialized cipher context.
6262
*
63-
* \param ctx Cipher context
63+
* \param ctx Cipher context. This should be a cipher context,
64+
* initialized to be one of the following types:
65+
* MBEDTLS_CIPHER_AES_128_ECB, MBEDTLS_CIPHER_AES_192_ECB,
66+
* MBEDTLS_CIPHER_AES_256_ECB or
67+
* MBEDTLS_CIPHER_DES_EDE3_ECB.
6468
* \param key CMAC key
6569
* \param keybits length of the CMAC key in bits
6670
* (must be acceptable by the cipher)
@@ -115,7 +119,7 @@ int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
115119
int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );
116120

117121
/**
118-
* \brief Output = Generic_CMAC( hmac key, input buffer )
122+
* \brief Output = Generic_CMAC( cmac key, input buffer )
119123
*
120124
* \param cipher_info message digest info
121125
* \param key CMAC key

features/mbedtls/inc/mbedtls/compat-1.3.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,7 +2453,6 @@
24532453
#define ssl_set_arc4_support mbedtls_ssl_conf_arc4_support
24542454
#define ssl_set_authmode mbedtls_ssl_conf_authmode
24552455
#define ssl_set_bio mbedtls_ssl_set_bio
2456-
#define ssl_set_bio mbedtls_ssl_set_bio_timeout
24572456
#define ssl_set_ca_chain mbedtls_ssl_conf_ca_chain
24582457
#define ssl_set_cbc_record_splitting mbedtls_ssl_conf_cbc_record_splitting
24592458
#define ssl_set_ciphersuites mbedtls_ssl_conf_ciphersuites

features/mbedtls/inc/mbedtls/config.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@
15401540
* library/pkwrite.c
15411541
* library/x509_create.c
15421542
* library/x509write_crt.c
1543-
* library/mbedtls_x509write_csr.c
1543+
* library/x509write_csr.c
15441544
*/
15451545
#define MBEDTLS_ASN1_WRITE_C
15461546

@@ -1901,7 +1901,7 @@
19011901
*
19021902
* Enable the generic message digest layer.
19031903
*
1904-
* Module: library/mbedtls_md.c
1904+
* Module: library/md.c
19051905
* Caller:
19061906
*
19071907
* Uncomment to enable generic message digest wrappers.
@@ -1913,7 +1913,7 @@
19131913
*
19141914
* Enable the MD2 hash algorithm.
19151915
*
1916-
* Module: library/mbedtls_md2.c
1916+
* Module: library/md2.c
19171917
* Caller:
19181918
*
19191919
* Uncomment to enable support for (rare) MD2-signed X.509 certs.
@@ -1925,7 +1925,7 @@
19251925
*
19261926
* Enable the MD4 hash algorithm.
19271927
*
1928-
* Module: library/mbedtls_md4.c
1928+
* Module: library/md4.c
19291929
* Caller:
19301930
*
19311931
* Uncomment to enable support for (rare) MD4-signed X.509 certs.
@@ -1937,8 +1937,8 @@
19371937
*
19381938
* Enable the MD5 hash algorithm.
19391939
*
1940-
* Module: library/mbedtls_md5.c
1941-
* Caller: library/mbedtls_md.c
1940+
* Module: library/md5.c
1941+
* Caller: library/md.c
19421942
* library/pem.c
19431943
* library/ssl_tls.c
19441944
*
@@ -1995,11 +1995,11 @@
19951995
* library/rsa.c
19961996
* library/x509.c
19971997
* library/x509_create.c
1998-
* library/mbedtls_x509_crl.c
1999-
* library/mbedtls_x509_crt.c
2000-
* library/mbedtls_x509_csr.c
1998+
* library/x509_crl.c
1999+
* library/x509_crt.c
2000+
* library/x509_csr.c
20012001
* library/x509write_crt.c
2002-
* library/mbedtls_x509write_csr.c
2002+
* library/x509write_csr.c
20032003
*
20042004
* This modules translates between OIDs and internal values.
20052005
*/
@@ -2027,9 +2027,9 @@
20272027
* Module: library/pem.c
20282028
* Caller: library/dhm.c
20292029
* library/pkparse.c
2030-
* library/mbedtls_x509_crl.c
2031-
* library/mbedtls_x509_crt.c
2032-
* library/mbedtls_x509_csr.c
2030+
* library/x509_crl.c
2031+
* library/x509_crt.c
2032+
* library/x509_csr.c
20332033
*
20342034
* Requires: MBEDTLS_BASE64_C
20352035
*
@@ -2045,7 +2045,7 @@
20452045
* Module: library/pem.c
20462046
* Caller: library/pkwrite.c
20472047
* library/x509write_crt.c
2048-
* library/mbedtls_x509write_csr.c
2048+
* library/x509write_csr.c
20492049
*
20502050
* Requires: MBEDTLS_BASE64_C
20512051
*
@@ -2075,8 +2075,8 @@
20752075
* Enable the generic public (asymetric) key parser.
20762076
*
20772077
* Module: library/pkparse.c
2078-
* Caller: library/mbedtls_x509_crt.c
2079-
* library/mbedtls_x509_csr.c
2078+
* Caller: library/x509_crt.c
2079+
* library/x509_csr.c
20802080
*
20812081
* Requires: MBEDTLS_PK_C
20822082
*
@@ -2167,8 +2167,8 @@
21672167
*
21682168
* Enable the RIPEMD-160 hash algorithm.
21692169
*
2170-
* Module: library/mbedtls_ripemd160.c
2171-
* Caller: library/mbedtls_md.c
2170+
* Module: library/ripemd160.c
2171+
* Caller: library/md.c
21722172
*
21732173
*/
21742174
//#define MBEDTLS_RIPEMD160_C
@@ -2196,8 +2196,8 @@
21962196
*
21972197
* Enable the SHA1 cryptographic hash algorithm.
21982198
*
2199-
* Module: library/mbedtls_sha1.c
2200-
* Caller: library/mbedtls_md.c
2199+
* Module: library/sha1.c
2200+
* Caller: library/md.c
22012201
* library/ssl_cli.c
22022202
* library/ssl_srv.c
22032203
* library/ssl_tls.c
@@ -2212,9 +2212,9 @@
22122212
*
22132213
* Enable the SHA-224 and SHA-256 cryptographic hash algorithms.
22142214
*
2215-
* Module: library/mbedtls_sha256.c
2215+
* Module: library/sha256.c
22162216
* Caller: library/entropy.c
2217-
* library/mbedtls_md.c
2217+
* library/md.c
22182218
* library/ssl_cli.c
22192219
* library/ssl_srv.c
22202220
* library/ssl_tls.c
@@ -2229,9 +2229,9 @@
22292229
*
22302230
* Enable the SHA-384 and SHA-512 cryptographic hash algorithms.
22312231
*
2232-
* Module: library/mbedtls_sha512.c
2232+
* Module: library/sha512.c
22332233
* Caller: library/entropy.c
2234-
* library/mbedtls_md.c
2234+
* library/md.c
22352235
* library/ssl_cli.c
22362236
* library/ssl_srv.c
22372237
*
@@ -2379,9 +2379,9 @@
23792379
* Enable X.509 core for using certificates.
23802380
*
23812381
* Module: library/x509.c
2382-
* Caller: library/mbedtls_x509_crl.c
2383-
* library/mbedtls_x509_crt.c
2384-
* library/mbedtls_x509_csr.c
2382+
* Caller: library/x509_crl.c
2383+
* library/x509_crt.c
2384+
* library/x509_csr.c
23852385
*
23862386
* Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C,
23872387
* MBEDTLS_PK_PARSE_C
@@ -2395,7 +2395,7 @@
23952395
*
23962396
* Enable X.509 certificate parsing.
23972397
*
2398-
* Module: library/mbedtls_x509_crt.c
2398+
* Module: library/x509_crt.c
23992399
* Caller: library/ssl_cli.c
24002400
* library/ssl_srv.c
24012401
* library/ssl_tls.c
@@ -2411,8 +2411,8 @@
24112411
*
24122412
* Enable X.509 CRL parsing.
24132413
*
2414-
* Module: library/mbedtls_x509_crl.c
2415-
* Caller: library/mbedtls_x509_crt.c
2414+
* Module: library/x509_crl.c
2415+
* Caller: library/x509_crt.c
24162416
*
24172417
* Requires: MBEDTLS_X509_USE_C
24182418
*
@@ -2425,7 +2425,7 @@
24252425
*
24262426
* Enable X.509 Certificate Signing Request (CSR) parsing.
24272427
*
2428-
* Module: library/mbedtls_x509_csr.c
2428+
* Module: library/x509_csr.c
24292429
* Caller: library/x509_crt_write.c
24302430
*
24312431
* Requires: MBEDTLS_X509_USE_C

features/mbedtls/inc/mbedtls/rsa.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rs
206206
* \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
207207
*
208208
* \note This function does NOT take care of message
209-
* padding. Also, be sure to set input[0] = 0 or assure that
209+
* padding. Also, be sure to set input[0] = 0 or ensure that
210210
* input is smaller than N.
211211
*
212212
* \note The input and output buffers must be large

features/mbedtls/inc/mbedtls/ssl.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout )
11461146
*
11471147
* \note See the documentation of \c mbedtls_ssl_set_timer_t and
11481148
* \c mbedtls_ssl_get_timer_t for the conventions this pair of
1149-
* callbacks must fallow.
1149+
* callbacks must follow.
11501150
*
11511151
* \note On some platforms, timing.c provides
11521152
* \c mbedtls_timing_set_delay() and
@@ -2183,7 +2183,7 @@ void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_
21832183

21842184
/**
21852185
* \brief Set record counter threshold for periodic renegotiation.
2186-
* (Default: 2^64 - 256.)
2186+
* (Default: 2^48 - 1)
21872187
*
21882188
* Renegotiation is automatically triggered when a record
21892189
* counter (outgoing or ingoing) crosses the defined
@@ -2194,9 +2194,17 @@ void mbedtls_ssl_conf_renegotiation_enforced( mbedtls_ssl_config *conf, int max_
21942194
* Lower values can be used to enforce policies such as "keys
21952195
* must be refreshed every N packets with cipher X".
21962196
*
2197+
* The renegotiation period can be disabled by setting
2198+
* conf->disable_renegotiation to
2199+
* MBEDTLS_SSL_RENEGOTIATION_DISABLED.
2200+
*
2201+
* \note When the configured transport is
2202+
* MBEDTLS_SSL_TRANSPORT_DATAGRAM the maximum renegotiation
2203+
* period is 2^48 - 1, and for MBEDTLS_SSL_TRANSPORT_STREAM,
2204+
* the maximum renegotiation period is 2^64 - 1.
2205+
*
21972206
* \param conf SSL configuration
21982207
* \param period The threshold value: a big-endian 64-bit number.
2199-
* Set to 2^64 - 1 to disable periodic renegotiation
22002208
*/
22012209
void mbedtls_ssl_conf_renegotiation_period( mbedtls_ssl_config *conf,
22022210
const unsigned char period[8] );
@@ -2428,7 +2436,7 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
24282436
* \param len how many bytes must be written
24292437
*
24302438
* \return the number of bytes actually written (may be less than len),
2431-
* or MBEDTLS_ERR_SSL_WANT_WRITE of MBEDTLS_ERR_SSL_WANT_READ,
2439+
* or MBEDTLS_ERR_SSL_WANT_WRITE or MBEDTLS_ERR_SSL_WANT_READ,
24322440
* or another negative error code.
24332441
*
24342442
* \note If this function returns something other than a positive
@@ -2513,7 +2521,6 @@ void mbedtls_ssl_config_init( mbedtls_ssl_config *conf );
25132521
* \param transport MBEDTLS_SSL_TRANSPORT_STREAM for TLS, or
25142522
* MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS
25152523
* \param preset a MBEDTLS_SSL_PRESET_XXX value
2516-
* (currently unused).
25172524
*
25182525
* \note See \c mbedtls_ssl_conf_transport() for notes on DTLS.
25192526
*

features/mbedtls/inc/mbedtls/version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@
3939
*/
4040
#define MBEDTLS_VERSION_MAJOR 2
4141
#define MBEDTLS_VERSION_MINOR 4
42-
#define MBEDTLS_VERSION_PATCH 0
42+
#define MBEDTLS_VERSION_PATCH 2
4343

4444
/**
4545
* The single version number has the following structure:
4646
* MMNNPP00
4747
* Major version | Minor version | Patch version
4848
*/
49-
#define MBEDTLS_VERSION_NUMBER 0x02040000
50-
#define MBEDTLS_VERSION_STRING "2.4.0"
51-
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.4.0"
49+
#define MBEDTLS_VERSION_NUMBER 0x02040200
50+
#define MBEDTLS_VERSION_STRING "2.4.2"
51+
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.4.2"
5252

5353
#if defined(MBEDTLS_VERSION_C)
5454

features/mbedtls/inc/mbedtls/x509.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
#define MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY (1 << 13)
158158
#define MBEDTLS_X509_EXT_FRESHEST_CRL (1 << 14)
159159

160-
#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16) /* Parsed (and then ?) */
160+
#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16)
161161

162162
/*
163163
* Storage format identifiers

features/mbedtls/src/base64.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
192192
return( 0 );
193193
}
194194

195-
n = ( ( n * 6 ) + 7 ) >> 3;
195+
/* The following expression is to calculate the following formula without
196+
* risk of integer overflow in n:
197+
* n = ( ( n * 6 ) + 7 ) >> 3;
198+
*/
199+
n = ( 6 * ( n >> 3 ) ) + ( ( 6 * ( n & 0x7 ) + 7 ) >> 3 );
196200
n -= j;
197201

198202
if( dst == NULL || dlen < n )

features/mbedtls/src/bignum.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,12 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix,
534534
n = mbedtls_mpi_bitlen( X );
535535
if( radix >= 4 ) n >>= 1;
536536
if( radix >= 16 ) n >>= 1;
537-
n += 3;
537+
/*
538+
* Round up the buffer length to an even value to ensure that there is
539+
* enough room for hexadecimal values that can be represented in an odd
540+
* number of digits.
541+
*/
542+
n += 3 + ( ( n + 1 ) & 1 );
538543

539544
if( buflen < n )
540545
{

features/mbedtls/src/cipher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i
326326
* If there is not enough data for a full block, cache it.
327327
*/
328328
if( ( ctx->operation == MBEDTLS_DECRYPT &&
329-
ilen + ctx->unprocessed_len <= block_size ) ||
329+
ilen <= block_size - ctx->unprocessed_len ) ||
330330
( ctx->operation == MBEDTLS_ENCRYPT &&
331-
ilen + ctx->unprocessed_len < block_size ) )
331+
ilen < block_size - ctx->unprocessed_len ) )
332332
{
333333
memcpy( &( ctx->unprocessed_data[ctx->unprocessed_len] ), input,
334334
ilen );

0 commit comments

Comments
 (0)