Skip to content

Commit 612255f

Browse files
committed
tls: Update to Mbed TLS 2.19.0
1 parent d8c2c6f commit 612255f

File tree

12 files changed

+85
-19
lines changed

12 files changed

+85
-19
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.19.0d0
1+
mbedtls-2.19.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.19.0d0
30+
MBED_TLS_RELEASE ?= mbedtls-2.19.0
3131
MBED_TLS_REPO_URL ?= [email protected]:ARMmbed/mbedtls-restricted.git
3232

3333
# Translate between mbed TLS namespace and mbed namespace

features/mbedtls/inc/mbedtls/check_config.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,16 @@
130130
#error "MBEDTLS_ECP_RESTARTABLE defined, but not MBEDTLS_ECDH_LEGACY_CONTEXT"
131131
#endif
132132

133+
#if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED) && \
134+
defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
135+
#error "MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED defined, but MBEDTLS_ECDH_LEGACY_CONTEXT not disabled"
136+
#endif
137+
133138
#if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C)
134139
#error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites"
135140
#endif
136141

137-
#if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \
142+
#if defined(MBEDTLS_ECP_C) && ( !defined(MBEDTLS_BIGNUM_C) || ( \
138143
!defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) && \
139144
!defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) && \
140145
!defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) && \
@@ -145,7 +150,9 @@
145150
!defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) && \
146151
!defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) && \
147152
!defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) && \
148-
!defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) ) )
153+
!defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) && \
154+
!defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) && \
155+
!defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) ) )
149156
#error "MBEDTLS_ECP_C defined, but not all prerequisites"
150157
#endif
151158

features/mbedtls/inc/mbedtls/config.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,6 +3592,15 @@
35923592
*/
35933593
//#define MBEDTLS_PLATFORM_GMTIME_R_ALT
35943594

3595+
/**
3596+
* Enable the verified implementations of ECDH primitives from Project Everest
3597+
* (currently only Curve25519). This feature changes the layout of ECDH
3598+
* contexts and therefore is a compatibility break for applications that access
3599+
* fields of a mbedtls_ecdh_context structure directly. See also
3600+
* MBEDTLS_ECDH_LEGACY_CONTEXT in include/mbedtls/ecdh.h.
3601+
*/
3602+
//#define MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
3603+
35953604
/* \} name SECTION: Customisation configuration options */
35963605

35973606
/* Target and application specific configurations

features/mbedtls/inc/mbedtls/net_sockets.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
257257
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
258258
uint32_t timeout );
259259

260+
/**
261+
* \brief Closes down the connection and free associated data
262+
*
263+
* \param ctx The context to close
264+
*/
265+
void mbedtls_net_close( mbedtls_net_context *ctx );
266+
260267
/**
261268
* \brief Gracefully shutdown the connection and free associated data
262269
*

features/mbedtls/inc/mbedtls/version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@
3939
* Major, Minor, Patchlevel
4040
*/
4141
#define MBEDTLS_VERSION_MAJOR 2
42-
#define MBEDTLS_VERSION_MINOR 18
42+
#define MBEDTLS_VERSION_MINOR 19
4343
#define MBEDTLS_VERSION_PATCH 0
4444

4545
/**
4646
* The single version number has the following structure:
4747
* MMNNPP00
4848
* Major version | Minor version | Patch version
4949
*/
50-
#define MBEDTLS_VERSION_NUMBER 0x02120000
51-
#define MBEDTLS_VERSION_STRING "2.18.0"
52-
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.18.0"
50+
#define MBEDTLS_VERSION_NUMBER 0x02130000
51+
#define MBEDTLS_VERSION_STRING "2.19.0"
52+
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.19.0"
5353

5454
#if defined(MBEDTLS_VERSION_C)
5555

features/mbedtls/src/Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ OBJS_TLS= debug.o net_sockets.o \
8080
ssl_srv.o ssl_ticket.o \
8181
ssl_tls.o
8282

83+
INCLUDING_FROM_MBEDTLS:=1
84+
include ../crypto/3rdparty/Makefile.inc
85+
LOCAL_CFLAGS += $(patsubst -I../3rdparty/%, -I../crypto/3rdparty/%, $(THIRDPARTY_INCLUDES))
86+
OBJS_CRYPTO += $(patsubst ../3rdparty/%, ../crypto/3rdparty/%, $(THIRDPARTY_CRYPTO_OBJECTS))
87+
88+
8389
.SILENT:
8490

8591
.PHONY: all static shared clean
@@ -153,11 +159,13 @@ libmbedcrypto.%:
153159

154160
.c.o:
155161
echo " CC $<"
156-
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $<
162+
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
157163

158164
clean:
159165
ifndef WINDOWS
160-
rm -f *.o libmbed*
166+
rm -f *.o libmbed* $(OBJS_CRYPTO)
161167
else
162-
del /Q /F *.o libmbed*
168+
if exist *.o del /Q /F *.o
169+
if exist libmbed* del /Q /F libmbed*
170+
if exist $(OBJS_CRYPTO) del /Q /F $(OBJS_CRYPTO)
163171
endif

features/mbedtls/src/net_sockets.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,19 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len )
651651
return( ret );
652652
}
653653

654+
/*
655+
* Close the connection
656+
*/
657+
void mbedtls_net_close( mbedtls_net_context *ctx )
658+
{
659+
if( ctx->fd == -1 )
660+
return;
661+
662+
close( ctx->fd );
663+
664+
ctx->fd = -1;
665+
}
666+
654667
/*
655668
* Gracefully close the connection
656669
*/

features/mbedtls/src/ssl_tls.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11950,6 +11950,10 @@ static int ssl_context_load( mbedtls_ssl_context *ssl,
1195011950
ssl->major_ver = MBEDTLS_SSL_MAJOR_VERSION_3;
1195111951
ssl->minor_ver = MBEDTLS_SSL_MINOR_VERSION_3;
1195211952

11953+
/* Adjust pointers for header fields of outgoing records to
11954+
* the given transform, accounting for explicit IV and CID. */
11955+
ssl_update_out_pointers( ssl, ssl->transform );
11956+
1195311957
#if defined(MBEDTLS_SSL_PROTO_DTLS)
1195411958
ssl->in_epoch = 1;
1195511959
#endif

features/mbedtls/src/x509_crt.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,15 +2611,13 @@ static int x509_crt_find_parent_in(
26112611
continue;
26122612
}
26132613

2614-
break;
2615-
}
2616-
2617-
if( parent != NULL )
2618-
{
26192614
*r_parent = parent;
26202615
*r_signature_is_good = signature_is_good;
2616+
2617+
break;
26212618
}
2622-
else
2619+
2620+
if( parent == NULL )
26232621
{
26242622
*r_parent = fallback_parent;
26252623
*r_signature_is_good = fallback_signature_is_good;

features/mbedtls/src/x509write_crt.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@
4545
#include "mbedtls/pem.h"
4646
#endif /* MBEDTLS_PEM_WRITE_C */
4747

48+
/*
49+
* For the currently used signature algorithms the buffer to store any signature
50+
* must be at least of size MAX(MBEDTLS_ECDSA_MAX_LEN, MBEDTLS_MPI_MAX_SIZE)
51+
*/
52+
#if MBEDTLS_ECDSA_MAX_LEN > MBEDTLS_MPI_MAX_SIZE
53+
#define SIGNATURE_MAX_SIZE MBEDTLS_ECDSA_MAX_LEN
54+
#else
55+
#define SIGNATURE_MAX_SIZE MBEDTLS_MPI_MAX_SIZE
56+
#endif
57+
4858
void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx )
4959
{
5060
memset( ctx, 0, sizeof( mbedtls_x509write_cert ) );
@@ -337,7 +347,7 @@ int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx,
337347
size_t sig_oid_len = 0;
338348
unsigned char *c, *c2;
339349
unsigned char hash[64];
340-
unsigned char sig[MBEDTLS_MPI_MAX_SIZE];
350+
unsigned char sig[SIGNATURE_MAX_SIZE];
341351
size_t sub_len = 0, pub_len = 0, sig_and_oid_len = 0, sig_len;
342352
size_t len = 0;
343353
mbedtls_pk_type_t pk_alg;

features/mbedtls/src/x509write_csr.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
#include "mbedtls/pem.h"
5050
#endif
5151

52+
/*
53+
* For the currently used signature algorithms the buffer to store any signature
54+
* must be at least of size MAX(MBEDTLS_ECDSA_MAX_LEN, MBEDTLS_MPI_MAX_SIZE)
55+
*/
56+
#if MBEDTLS_ECDSA_MAX_LEN > MBEDTLS_MPI_MAX_SIZE
57+
#define SIGNATURE_MAX_SIZE MBEDTLS_ECDSA_MAX_LEN
58+
#else
59+
#define SIGNATURE_MAX_SIZE MBEDTLS_MPI_MAX_SIZE
60+
#endif
61+
5262
void mbedtls_x509write_csr_init( mbedtls_x509write_csr *ctx )
5363
{
5464
memset( ctx, 0, sizeof( mbedtls_x509write_csr ) );
@@ -138,7 +148,7 @@ int mbedtls_x509write_csr_der( mbedtls_x509write_csr *ctx, unsigned char *buf, s
138148
size_t sig_oid_len = 0;
139149
unsigned char *c, *c2;
140150
unsigned char hash[64];
141-
unsigned char sig[MBEDTLS_MPI_MAX_SIZE];
151+
unsigned char sig[SIGNATURE_MAX_SIZE];
142152
unsigned char tmp_buf[2048];
143153
size_t pub_len = 0, sig_and_oid_len = 0, sig_len;
144154
size_t len = 0;

0 commit comments

Comments
 (0)