Skip to content

Commit 6a98132

Browse files
galaknashif
authored andcommitted
ext: lib: mbedtls: Upgrading mbedTLS library
Upgrading mbedTLS to version 2.4.2 from 2.4 Origin: https://tls.mbed.org/download/start/mbedtls-2.4.2-apache.tgz Jira: ZEP-1800 Change-Id: If9341a4310ee7c9f42e4cb0a2a34cf27aeb89d09 Signed-off-by: Kumar Gala <[email protected]> Signed-off-by: Anas Nashif <[email protected]>
1 parent 3426508 commit 6a98132

28 files changed

+403
-259
lines changed

ext/lib/crypto/mbedtls/README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
The mbed TLS library in Zephyr is a downstream of an externally maintained
22
open source project. The original upstream code can be found at:
33

4-
https://tls.mbed.org/download/start/mbedtls-2.4.0-apache.tgz
4+
https://tls.mbed.org/download/start/mbedtls-2.4.2-apache.tgz
55

6-
At version 2.4.0
6+
At version 2.4.2
77

88
The following is the license information for this code:
99

ext/lib/crypto/mbedtls/include/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

ext/lib/crypto/mbedtls/include/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

ext/lib/crypto/mbedtls/include/mbedtls/config.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@
15251525
* library/pkwrite.c
15261526
* library/x509_create.c
15271527
* library/x509write_crt.c
1528-
* library/mbedtls_x509write_csr.c
1528+
* library/x509write_csr.c
15291529
*/
15301530
#define MBEDTLS_ASN1_WRITE_C
15311531

@@ -1886,7 +1886,7 @@
18861886
*
18871887
* Enable the generic message digest layer.
18881888
*
1889-
* Module: library/mbedtls_md.c
1889+
* Module: library/md.c
18901890
* Caller:
18911891
*
18921892
* Uncomment to enable generic message digest wrappers.
@@ -1898,7 +1898,7 @@
18981898
*
18991899
* Enable the MD2 hash algorithm.
19001900
*
1901-
* Module: library/mbedtls_md2.c
1901+
* Module: library/md2.c
19021902
* Caller:
19031903
*
19041904
* Uncomment to enable support for (rare) MD2-signed X.509 certs.
@@ -1910,7 +1910,7 @@
19101910
*
19111911
* Enable the MD4 hash algorithm.
19121912
*
1913-
* Module: library/mbedtls_md4.c
1913+
* Module: library/md4.c
19141914
* Caller:
19151915
*
19161916
* Uncomment to enable support for (rare) MD4-signed X.509 certs.
@@ -1922,8 +1922,8 @@
19221922
*
19231923
* Enable the MD5 hash algorithm.
19241924
*
1925-
* Module: library/mbedtls_md5.c
1926-
* Caller: library/mbedtls_md.c
1925+
* Module: library/md5.c
1926+
* Caller: library/md.c
19271927
* library/pem.c
19281928
* library/ssl_tls.c
19291929
*
@@ -1980,11 +1980,11 @@
19801980
* library/rsa.c
19811981
* library/x509.c
19821982
* library/x509_create.c
1983-
* library/mbedtls_x509_crl.c
1984-
* library/mbedtls_x509_crt.c
1985-
* library/mbedtls_x509_csr.c
1983+
* library/x509_crl.c
1984+
* library/x509_crt.c
1985+
* library/x509_csr.c
19861986
* library/x509write_crt.c
1987-
* library/mbedtls_x509write_csr.c
1987+
* library/x509write_csr.c
19881988
*
19891989
* This modules translates between OIDs and internal values.
19901990
*/
@@ -2012,9 +2012,9 @@
20122012
* Module: library/pem.c
20132013
* Caller: library/dhm.c
20142014
* library/pkparse.c
2015-
* library/mbedtls_x509_crl.c
2016-
* library/mbedtls_x509_crt.c
2017-
* library/mbedtls_x509_csr.c
2015+
* library/x509_crl.c
2016+
* library/x509_crt.c
2017+
* library/x509_csr.c
20182018
*
20192019
* Requires: MBEDTLS_BASE64_C
20202020
*
@@ -2030,7 +2030,7 @@
20302030
* Module: library/pem.c
20312031
* Caller: library/pkwrite.c
20322032
* library/x509write_crt.c
2033-
* library/mbedtls_x509write_csr.c
2033+
* library/x509write_csr.c
20342034
*
20352035
* Requires: MBEDTLS_BASE64_C
20362036
*
@@ -2060,8 +2060,8 @@
20602060
* Enable the generic public (asymetric) key parser.
20612061
*
20622062
* Module: library/pkparse.c
2063-
* Caller: library/mbedtls_x509_crt.c
2064-
* library/mbedtls_x509_csr.c
2063+
* Caller: library/x509_crt.c
2064+
* library/x509_csr.c
20652065
*
20662066
* Requires: MBEDTLS_PK_C
20672067
*
@@ -2152,8 +2152,8 @@
21522152
*
21532153
* Enable the RIPEMD-160 hash algorithm.
21542154
*
2155-
* Module: library/mbedtls_ripemd160.c
2156-
* Caller: library/mbedtls_md.c
2155+
* Module: library/ripemd160.c
2156+
* Caller: library/md.c
21572157
*
21582158
*/
21592159
#define MBEDTLS_RIPEMD160_C
@@ -2181,8 +2181,8 @@
21812181
*
21822182
* Enable the SHA1 cryptographic hash algorithm.
21832183
*
2184-
* Module: library/mbedtls_sha1.c
2185-
* Caller: library/mbedtls_md.c
2184+
* Module: library/sha1.c
2185+
* Caller: library/md.c
21862186
* library/ssl_cli.c
21872187
* library/ssl_srv.c
21882188
* library/ssl_tls.c
@@ -2197,9 +2197,9 @@
21972197
*
21982198
* Enable the SHA-224 and SHA-256 cryptographic hash algorithms.
21992199
*
2200-
* Module: library/mbedtls_sha256.c
2200+
* Module: library/sha256.c
22012201
* Caller: library/entropy.c
2202-
* library/mbedtls_md.c
2202+
* library/md.c
22032203
* library/ssl_cli.c
22042204
* library/ssl_srv.c
22052205
* library/ssl_tls.c
@@ -2214,9 +2214,9 @@
22142214
*
22152215
* Enable the SHA-384 and SHA-512 cryptographic hash algorithms.
22162216
*
2217-
* Module: library/mbedtls_sha512.c
2217+
* Module: library/sha512.c
22182218
* Caller: library/entropy.c
2219-
* library/mbedtls_md.c
2219+
* library/md.c
22202220
* library/ssl_cli.c
22212221
* library/ssl_srv.c
22222222
*
@@ -2364,9 +2364,9 @@
23642364
* Enable X.509 core for using certificates.
23652365
*
23662366
* Module: library/x509.c
2367-
* Caller: library/mbedtls_x509_crl.c
2368-
* library/mbedtls_x509_crt.c
2369-
* library/mbedtls_x509_csr.c
2367+
* Caller: library/x509_crl.c
2368+
* library/x509_crt.c
2369+
* library/x509_csr.c
23702370
*
23712371
* Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C,
23722372
* MBEDTLS_PK_PARSE_C
@@ -2380,7 +2380,7 @@
23802380
*
23812381
* Enable X.509 certificate parsing.
23822382
*
2383-
* Module: library/mbedtls_x509_crt.c
2383+
* Module: library/x509_crt.c
23842384
* Caller: library/ssl_cli.c
23852385
* library/ssl_srv.c
23862386
* library/ssl_tls.c
@@ -2396,8 +2396,8 @@
23962396
*
23972397
* Enable X.509 CRL parsing.
23982398
*
2399-
* Module: library/mbedtls_x509_crl.c
2400-
* Caller: library/mbedtls_x509_crt.c
2399+
* Module: library/x509_crl.c
2400+
* Caller: library/x509_crt.c
24012401
*
24022402
* Requires: MBEDTLS_X509_USE_C
24032403
*
@@ -2410,7 +2410,7 @@
24102410
*
24112411
* Enable X.509 Certificate Signing Request (CSR) parsing.
24122412
*
2413-
* Module: library/mbedtls_x509_csr.c
2413+
* Module: library/x509_csr.c
24142414
* Caller: library/x509_crt_write.c
24152415
*
24162416
* Requires: MBEDTLS_X509_USE_C

ext/lib/crypto/mbedtls/include/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

ext/lib/crypto/mbedtls/include/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
*

ext/lib/crypto/mbedtls/include/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

ext/lib/crypto/mbedtls/include/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

ext/lib/crypto/mbedtls/library/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 )

ext/lib/crypto/mbedtls/library/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
{

0 commit comments

Comments
 (0)