Skip to content

Commit cfc9e9f

Browse files
committed
tls: Update Mbed TLS to 2.20.0d1
1 parent 3cff077 commit cfc9e9f

File tree

19 files changed

+249
-218
lines changed

19 files changed

+249
-218
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.20.0d0
1+
mbedtls-2.20.0d1

features/mbedtls/importer/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#
2828

2929
# Set the mbed TLS release to import (this can/should be edited before import)
30-
MBED_TLS_RELEASE ?= mbedtls-2.20.0d0
31-
MBED_TLS_REPO_URL ?= [email protected]:ARMmbed/mbedtls-restricted.git
30+
MBED_TLS_RELEASE ?= mbedtls-2.20.0d1
31+
MBED_TLS_REPO_URL ?= [email protected]:ARMmbed/mbedtls.git
3232

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

features/mbedtls/inc/mbedtls/error.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@
5252
* For historical reasons, low-level error codes are divided in even and odd,
5353
* even codes were assigned first, and -1 is reserved for other errors.
5454
*
55-
* Low-level module errors (0x0002-0x007E, 0x0003-0x007F)
55+
* Low-level module errors (0x0002-0x007E, 0x0001-0x007F)
5656
*
5757
* Module Nr Codes assigned
58+
* ERROR 2 0x006E 0x0001
5859
* MPI 7 0x0002-0x0010
5960
* GCM 3 0x0012-0x0014 0x0013-0x0013
6061
* BLOWFISH 3 0x0016-0x0018 0x0017-0x0017
@@ -86,7 +87,7 @@
8687
* CHACHA20 3 0x0051-0x0055
8788
* POLY1305 3 0x0057-0x005B
8889
* CHACHAPOLY 2 0x0054-0x0056
89-
* PLATFORM 1 0x0070-0x0072
90+
* PLATFORM 2 0x0070-0x0072
9091
*
9192
* High-level module nr (3 bits - 0x0...-0x7...)
9293
* Name ID Nr of Errors
@@ -112,6 +113,9 @@
112113
extern "C" {
113114
#endif
114115

116+
#define MBEDTLS_ERR_ERROR_GENERIC_ERROR -0x0001 /**< Generic error */
117+
#define MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED -0x006E /**< This is a bug in the library */
118+
115119
/**
116120
* \brief Translate a mbed TLS error code into a string representation,
117121
* Result is truncated if necessary and always includes a terminating

features/mbedtls/src/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,22 @@ libmbedx509.so: libmbedx509.$(SOEXT_X509)
146146
echo " LN $@ -> $<"
147147
ln -sf $< $@
148148

149-
libmbedx509.dylib: $(OBJS_X509) libmbedcrypto.dylib
149+
libmbedx509.dylib: $(OBJS_X509) $(CRYPTO)libmbedcrypto.dylib
150150
echo " LD $@"
151151
$(CC) -dynamiclib -L. -lmbedcrypto $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ $(OBJS_X509)
152152

153-
libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll
153+
libmbedx509.dll: $(OBJS_X509) $(CRYPTO)libmbedcrypto.dll
154154
echo " LD $@"
155155
$(CC) -shared -Wl,-soname,$@ -Wl,--out-implib,$@.a -o $@ $(OBJS_X509) -lws2_32 -lwinmm -lgdi32 -L. -lmbedcrypto -static-libgcc $(LOCAL_LDFLAGS) $(LDFLAGS)
156156

157157
libmbedcrypto.%:
158158
$(MAKE) CRYPTO_INCLUDES:="-I../../include -I../include" -C ../crypto/library $@
159159

160+
libmbedcrypto.$(DLEXT): $(CRYPTO)libmbedcrypto.$(DLEXT)
161+
162+
$(CRYPTO)libmbedcrypto.$(DLEXT): | libmbedcrypto.a
163+
$(MAKE) CRYPTO_INCLUDES:="-I../../include -I../include" -C ../crypto/library libmbedcrypto.$(DLEXT)
164+
160165
.c.o:
161166
echo " CC $<"
162167
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<

features/mbedtls/src/debug.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#endif
4040

4141
#include "mbedtls/debug.h"
42+
#include "mbedtls/error.h"
4243

4344
#include <stdarg.h>
4445
#include <stdio.h>
@@ -85,7 +86,7 @@ void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
8586
{
8687
va_list argp;
8788
char str[DEBUG_BUF_SIZE];
88-
int ret;
89+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
8990

9091
if( NULL == ssl ||
9192
NULL == ssl->conf ||

features/mbedtls/src/error.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
#include MBEDTLS_CONFIG_FILE
2626
#endif
2727

28-
#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
29-
#include "mbedtls/error.h"
28+
#if defined(MBEDTLS_ERROR_STRERROR_DUMMY)
3029
#include <string.h>
3130
#endif
3231

@@ -109,6 +108,10 @@
109108
#include "mbedtls/entropy.h"
110109
#endif
111110

111+
#if defined(MBEDTLS_ERROR_C)
112+
#include "mbedtls/error.h"
113+
#endif
114+
112115
#if defined(MBEDTLS_GCM_C)
113116
#include "mbedtls/gcm.h"
114117
#endif
@@ -754,6 +757,13 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
754757
mbedtls_snprintf( buf, buflen, "ENTROPY - Read/write error in file" );
755758
#endif /* MBEDTLS_ENTROPY_C */
756759

760+
#if defined(MBEDTLS_ERROR_C)
761+
if( use_ret == -(MBEDTLS_ERR_ERROR_GENERIC_ERROR) )
762+
mbedtls_snprintf( buf, buflen, "ERROR - Generic error" );
763+
if( use_ret == -(MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED) )
764+
mbedtls_snprintf( buf, buflen, "ERROR - This is a bug in the library" );
765+
#endif /* MBEDTLS_ERROR_C */
766+
757767
#if defined(MBEDTLS_GCM_C)
758768
if( use_ret == -(MBEDTLS_ERR_GCM_AUTH_FAILED) )
759769
mbedtls_snprintf( buf, buflen, "GCM - Authenticated decryption failed" );

features/mbedtls/src/net_sockets.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#endif
4646

4747
#include "mbedtls/net_sockets.h"
48+
#include "mbedtls/error.h"
4849

4950
#include <string.h>
5051

@@ -147,7 +148,7 @@ void mbedtls_net_init( mbedtls_net_context *ctx )
147148
int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host,
148149
const char *port, int proto )
149150
{
150-
int ret;
151+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
151152
struct addrinfo hints, *addr_list, *cur;
152153

153154
if( ( ret = net_prepare() ) != 0 )
@@ -313,7 +314,7 @@ int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
313314
mbedtls_net_context *client_ctx,
314315
void *client_ip, size_t buf_size, size_t *ip_len )
315316
{
316-
int ret;
317+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
317318
int type;
318319

319320
struct sockaddr_storage client_addr;
@@ -455,7 +456,7 @@ int mbedtls_net_set_nonblock( mbedtls_net_context *ctx )
455456

456457
int mbedtls_net_poll( mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout )
457458
{
458-
int ret;
459+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
459460
struct timeval tv;
460461

461462
fd_set read_fds;
@@ -540,7 +541,7 @@ void mbedtls_net_usleep( unsigned long usec )
540541
*/
541542
int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len )
542543
{
543-
int ret;
544+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
544545
int fd = ((mbedtls_net_context *) ctx)->fd;
545546

546547
if( fd < 0 )
@@ -577,7 +578,7 @@ int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len )
577578
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf,
578579
size_t len, uint32_t timeout )
579580
{
580-
int ret;
581+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
581582
struct timeval tv;
582583
fd_set read_fds;
583584
int fd = ((mbedtls_net_context *) ctx)->fd;
@@ -620,7 +621,7 @@ int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf,
620621
*/
621622
int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len )
622623
{
623-
int ret;
624+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
624625
int fd = ((mbedtls_net_context *) ctx)->fd;
625626

626627
if( fd < 0 )

features/mbedtls/src/ssl_cli.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
#define mbedtls_free free
3636
#endif
3737

38-
#include "mbedtls/debug.h"
3938
#include "mbedtls/ssl.h"
4039
#include "mbedtls/ssl_internal.h"
40+
#include "mbedtls/debug.h"
41+
#include "mbedtls/error.h"
4142

4243
#if defined(MBEDTLS_USE_PSA_CRYPTO)
4344
#include "mbedtls/psa_util.h"
@@ -402,7 +403,7 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl,
402403
unsigned char *buf,
403404
size_t *olen )
404405
{
405-
int ret;
406+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
406407
unsigned char *p = buf;
407408
const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN;
408409
size_t kkpp_len;
@@ -766,7 +767,7 @@ static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl,
766767
*/
767768
static int ssl_generate_random( mbedtls_ssl_context *ssl )
768769
{
769-
int ret;
770+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
770771
unsigned char *p = ssl->handshake->randbytes;
771772
#if defined(MBEDTLS_HAVE_TIME)
772773
mbedtls_time_t t;
@@ -858,7 +859,7 @@ static int ssl_validate_ciphersuite( const mbedtls_ssl_ciphersuite_t * suite_inf
858859

859860
static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
860861
{
861-
int ret;
862+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
862863
size_t i, n, olen, ext_len = 0;
863864
unsigned char *buf;
864865
unsigned char *p, *q;
@@ -1470,7 +1471,7 @@ static int ssl_parse_ecjpake_kkpp( mbedtls_ssl_context *ssl,
14701471
const unsigned char *buf,
14711472
size_t len )
14721473
{
1473-
int ret;
1474+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
14741475

14751476
if( ssl->handshake->ciphersuite_info->key_exchange !=
14761477
MBEDTLS_KEY_EXCHANGE_ECJPAKE )
@@ -2384,7 +2385,7 @@ static int ssl_write_encrypted_pms( mbedtls_ssl_context *ssl,
23842385
size_t offset, size_t *olen,
23852386
size_t pms_offset )
23862387
{
2387-
int ret;
2388+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
23882389
size_t len_bytes = ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ? 0 : 2;
23892390
unsigned char *p = ssl->handshake->premaster + pms_offset;
23902391
mbedtls_pk_context * peer_pk;
@@ -2531,7 +2532,7 @@ static int ssl_parse_signature_algorithm( mbedtls_ssl_context *ssl,
25312532
defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
25322533
static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl )
25332534
{
2534-
int ret;
2535+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
25352536
const mbedtls_ecp_keypair *peer_key;
25362537
mbedtls_pk_context * peer_pk;
25372538

@@ -2582,7 +2583,7 @@ static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl )
25822583

25832584
static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl )
25842585
{
2585-
int ret;
2586+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
25862587
const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
25872588
ssl->handshake->ciphersuite_info;
25882589
unsigned char *p = NULL, *end = NULL;
@@ -2971,7 +2972,7 @@ static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
29712972
#else /* MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED */
29722973
static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
29732974
{
2974-
int ret;
2975+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
29752976
unsigned char *buf;
29762977
size_t n = 0;
29772978
size_t cert_type_len = 0, dn_len = 0;
@@ -3135,7 +3136,7 @@ static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
31353136

31363137
static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl )
31373138
{
3138-
int ret;
3139+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
31393140

31403141
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server hello done" ) );
31413142

@@ -3174,7 +3175,7 @@ static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl )
31743175

31753176
static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl )
31763177
{
3177-
int ret;
3178+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
31783179

31793180
size_t header_len;
31803181
size_t content_len;
@@ -3595,7 +3596,7 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
35953596
{
35963597
const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
35973598
ssl->handshake->ciphersuite_info;
3598-
int ret;
3599+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
35993600

36003601
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate verify" ) );
36013602

@@ -3790,7 +3791,7 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
37903791
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
37913792
static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl )
37923793
{
3793-
int ret;
3794+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
37943795
uint32_t lifetime;
37953796
size_t ticket_len;
37963797
unsigned char *ticket;

features/mbedtls/src/ssl_cookie.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#include "mbedtls/ssl_cookie.h"
4242
#include "mbedtls/ssl_internal.h"
43+
#include "mbedtls/error.h"
4344
#include "mbedtls/platform_util.h"
4445

4546
#include <string.h>
@@ -104,7 +105,7 @@ int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx,
104105
int (*f_rng)(void *, unsigned char *, size_t),
105106
void *p_rng )
106107
{
107-
int ret;
108+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
108109
unsigned char key[COOKIE_MD_OUTLEN];
109110

110111
if( ( ret = f_rng( p_rng, key, sizeof( key ) ) ) != 0 )
@@ -157,7 +158,7 @@ int mbedtls_ssl_cookie_write( void *p_ctx,
157158
unsigned char **p, unsigned char *end,
158159
const unsigned char *cli_id, size_t cli_id_len )
159160
{
160-
int ret;
161+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
161162
mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx;
162163
unsigned long t;
163164

0 commit comments

Comments
 (0)