Skip to content

Commit f2d42bf

Browse files
committed
Update Mbed TLS to version 2.20.0d0
1 parent 262a62a commit f2d42bf

File tree

7 files changed

+43
-24
lines changed

7 files changed

+43
-24
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.1
1+
mbedtls-2.20.0d0

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.1
30+
MBED_TLS_RELEASE ?= mbedtls-2.20.0d0
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#endif
4646

4747
/* Fix the config here. Not convenient to put an #ifdef _WIN32 in config.h as
48-
* it would confuse config.pl. */
48+
* it would confuse config.py. */
4949
#if !defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) && \
5050
!defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO)
5151
#define MBEDTLS_PLATFORM_SNPRINTF_ALT

features/mbedtls/inc/mbedtls/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3275,7 +3275,7 @@
32753275

32763276
/* MPI / BIGNUM options */
32773277
//#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */
3278-
#define MBEDTLS_MPI_MAX_SIZE 512
3278+
#define MBEDTLS_MPI_MAX_SIZE 512
32793279

32803280
/* CTR_DRBG options */
32813281
//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */
@@ -3534,7 +3534,7 @@
35343534
* on it, and considering stronger message digests instead.
35353535
*
35363536
*/
3537-
// #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
3537+
//#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
35383538

35393539
/**
35403540
* Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake

features/mbedtls/inc/mbedtls/version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
*/
4141
#define MBEDTLS_VERSION_MAJOR 2
4242
#define MBEDTLS_VERSION_MINOR 19
43-
#define MBEDTLS_VERSION_PATCH 0
43+
#define MBEDTLS_VERSION_PATCH 1
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 0x02130000
51-
#define MBEDTLS_VERSION_STRING "2.19.0"
52-
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.19.0"
50+
#define MBEDTLS_VERSION_NUMBER 0x02130100
51+
#define MBEDTLS_VERSION_STRING "2.19.1"
52+
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.19.1"
5353

5454
#if defined(MBEDTLS_VERSION_C)
5555

features/mbedtls/src/error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
642642
if( use_ret == -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH) )
643643
mbedtls_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" );
644644
if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_DATA) )
645-
mbedtls_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" );
645+
mbedtls_snprintf( buf, buflen, "ASN1 - Data is invalid" );
646646
if( use_ret == -(MBEDTLS_ERR_ASN1_ALLOC_FAILED) )
647647
mbedtls_snprintf( buf, buflen, "ASN1 - Memory allocation failed" );
648648
if( use_ret == -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL) )

features/mbedtls/src/ssl_tls.c

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -711,9 +711,18 @@ static psa_status_t setup_psa_key_derivation( psa_key_derivation_operation_t* de
711711
if( status != PSA_SUCCESS )
712712
return( status );
713713

714-
status = psa_key_derivation_input_key( derivation,
715-
PSA_KEY_DERIVATION_INPUT_SECRET,
716-
slot );
714+
if( slot == 0 )
715+
{
716+
status = psa_key_derivation_input_bytes(
717+
derivation, PSA_KEY_DERIVATION_INPUT_SECRET,
718+
NULL, 0 );
719+
}
720+
else
721+
{
722+
status = psa_key_derivation_input_key(
723+
derivation, PSA_KEY_DERIVATION_INPUT_SECRET,
724+
slot );
725+
}
717726
if( status != PSA_SUCCESS )
718727
return( status );
719728

@@ -743,8 +752,7 @@ static int tls_prf_generic( mbedtls_md_type_t md_type,
743752
{
744753
psa_status_t status;
745754
psa_algorithm_t alg;
746-
psa_key_attributes_t key_attributes;
747-
psa_key_handle_t master_slot;
755+
psa_key_handle_t master_slot = 0;
748756
psa_key_derivation_operation_t derivation =
749757
PSA_KEY_DERIVATION_OPERATION_INIT;
750758

@@ -753,14 +761,24 @@ static int tls_prf_generic( mbedtls_md_type_t md_type,
753761
else
754762
alg = PSA_ALG_TLS12_PRF(PSA_ALG_SHA_256);
755763

756-
key_attributes = psa_key_attributes_init();
757-
psa_set_key_usage_flags( &key_attributes, PSA_KEY_USAGE_DERIVE );
758-
psa_set_key_algorithm( &key_attributes, alg );
759-
psa_set_key_type( &key_attributes, PSA_KEY_TYPE_DERIVE );
760-
761-
status = psa_import_key( &key_attributes, secret, slen, &master_slot );
762-
if( status != PSA_SUCCESS )
763-
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
764+
/* Normally a "secret" should be long enough to be impossible to
765+
* find by brute force, and in particular should not be empty. But
766+
* this PRF is also used to derive an IV, in particular in EAP-TLS,
767+
* and for this use case it makes sense to have a 0-length "secret".
768+
* Since the key API doesn't allow importing a key of length 0,
769+
* keep master_slot=0, which setup_psa_key_derivation() understands
770+
* to mean a 0-length "secret" input. */
771+
if( slen != 0 )
772+
{
773+
psa_key_attributes_t key_attributes = psa_key_attributes_init();
774+
psa_set_key_usage_flags( &key_attributes, PSA_KEY_USAGE_DERIVE );
775+
psa_set_key_algorithm( &key_attributes, alg );
776+
psa_set_key_type( &key_attributes, PSA_KEY_TYPE_DERIVE );
777+
778+
status = psa_import_key( &key_attributes, secret, slen, &master_slot );
779+
if( status != PSA_SUCCESS )
780+
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
781+
}
764782

765783
status = setup_psa_key_derivation( &derivation,
766784
master_slot, alg,
@@ -790,7 +808,8 @@ static int tls_prf_generic( mbedtls_md_type_t md_type,
790808
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
791809
}
792810

793-
status = psa_destroy_key( master_slot );
811+
if( master_slot != 0 )
812+
status = psa_destroy_key( master_slot );
794813
if( status != PSA_SUCCESS )
795814
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
796815

0 commit comments

Comments
 (0)