Skip to content

Commit 60252b9

Browse files
committed
mbedtls: Update to Mbed TLS 2.18.0-rc1
Update Mbed TLS to 2.18.0-rc1. Update Mbed Crypto to 1.1.0d0.
1 parent 2626179 commit 60252b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4803
-2384
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.17.0
1+
mbedtls-2.18.0-rc1

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.17.0
31-
MBED_TLS_REPO_URL ?= [email protected]:ARMmbed/mbedtls.git
30+
MBED_TLS_RELEASE ?= mbedtls-2.18.0-rc1
31+
MBED_TLS_REPO_URL ?= [email protected]:ARMmbed/mbedtls-restricted.git
3232

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

features/mbedtls/inc/mbedtls/asn1write.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@
3333
#include "asn1.h"
3434

3535
#define MBEDTLS_ASN1_CHK_ADD(g, f) \
36-
do { \
37-
if( ( ret = f ) < 0 ) \
36+
do \
37+
{ \
38+
if( ( ret = (f) ) < 0 ) \
3839
return( ret ); \
3940
else \
40-
g += ret; \
41+
(g) += ret; \
4142
} while( 0 )
4243

4344
#ifdef __cplusplus

features/mbedtls/inc/mbedtls/bignum.h

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@
4646
#define MBEDTLS_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not acceptable. */
4747
#define MBEDTLS_ERR_MPI_ALLOC_FAILED -0x0010 /**< Memory allocation failed. */
4848

49-
#define MBEDTLS_MPI_CHK(f) do { if( ( ret = f ) != 0 ) goto cleanup; } while( 0 )
49+
#define MBEDTLS_MPI_CHK(f) \
50+
do \
51+
{ \
52+
if( ( ret = (f) ) != 0 ) \
53+
goto cleanup; \
54+
} while( 0 )
5055

5156
/*
5257
* Maximum size MPIs are allowed to grow to in number of limbs.
@@ -490,8 +495,24 @@ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf,
490495
size_t buflen );
491496

492497
/**
493-
* \brief Export an MPI into unsigned big endian binary data
494-
* of fixed size.
498+
* \brief Import X from unsigned binary data, little endian
499+
*
500+
* \param X The destination MPI. This must point to an initialized MPI.
501+
* \param buf The input buffer. This must be a readable buffer of length
502+
* \p buflen Bytes.
503+
* \param buflen The length of the input buffer \p p in Bytes.
504+
*
505+
* \return \c 0 if successful.
506+
* \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed.
507+
* \return Another negative error code on different kinds of failure.
508+
*/
509+
int mbedtls_mpi_read_binary_le( mbedtls_mpi *X,
510+
const unsigned char *buf, size_t buflen );
511+
512+
/**
513+
* \brief Export X into unsigned binary data, big endian.
514+
* Always fills the whole buffer, which will start with zeros
515+
* if the number is smaller.
495516
*
496517
* \param X The source MPI. This must point to an initialized MPI.
497518
* \param buf The output buffer. This must be a writable buffer of length
@@ -506,6 +527,24 @@ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf,
506527
int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf,
507528
size_t buflen );
508529

530+
/**
531+
* \brief Export X into unsigned binary data, little endian.
532+
* Always fills the whole buffer, which will end with zeros
533+
* if the number is smaller.
534+
*
535+
* \param X The source MPI. This must point to an initialized MPI.
536+
* \param buf The output buffer. This must be a writable buffer of length
537+
* \p buflen Bytes.
538+
* \param buflen The size of the output buffer \p buf in Bytes.
539+
*
540+
* \return \c 0 if successful.
541+
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
542+
* large enough to hold the value of \p X.
543+
* \return Another negative error code on different kinds of failure.
544+
*/
545+
int mbedtls_mpi_write_binary_le( const mbedtls_mpi *X,
546+
unsigned char *buf, size_t buflen );
547+
509548
/**
510549
* \brief Perform a left-shift on an MPI: X <<= count
511550
*

features/mbedtls/inc/mbedtls/check_config.h

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@
125125
#error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative or PSA-based ECP implementation"
126126
#endif
127127

128+
#if defined(MBEDTLS_ECP_RESTARTABLE) && \
129+
! defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
130+
#error "MBEDTLS_ECP_RESTARTABLE defined, but not MBEDTLS_ECDH_LEGACY_CONTEXT"
131+
#endif
132+
128133
#if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C)
129134
#error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites"
130135
#endif
@@ -525,26 +530,25 @@
525530
#error "MBEDTLS_PSA_CRYPTO_SPM defined, but not all prerequisites"
526531
#endif
527532

528-
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C) && defined(MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C)
529-
#error "Only one of MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C or MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C can be defined"
530-
#endif
531-
532533
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) && \
533-
!( defined(MBEDTLS_PSA_CRYPTO_C) && \
534-
( defined(MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C) || \
535-
defined(MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C) ) )
534+
! defined(MBEDTLS_PSA_CRYPTO_C)
536535
#error "MBEDTLS_PSA_CRYPTO_STORAGE_C defined, but not all prerequisites"
537536
#endif
538537

539-
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C) && \
540-
!( defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) && \
541-
defined(MBEDTLS_FS_IO) )
542-
#error "MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C defined, but not all prerequisites"
538+
#if defined(MBEDTLS_PSA_INJECT_ENTROPY) && \
539+
!( defined(MBEDTLS_PSA_CRYPTO_STORAGE_C) && \
540+
defined(MBEDTLS_ENTROPY_NV_SEED) )
541+
#error "MBEDTLS_PSA_INJECT_ENTROPY defined, but not all prerequisites"
542+
#endif
543+
544+
#if defined(MBEDTLS_PSA_INJECT_ENTROPY) && \
545+
!defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES)
546+
#error "MBEDTLS_PSA_INJECT_ENTROPY is not compatible with actual entropy sources"
543547
#endif
544548

545-
#if defined(MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C) && \
546-
! defined(MBEDTLS_PSA_CRYPTO_STORAGE_C)
547-
#error "MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C defined, but not all prerequisites"
549+
#if defined(MBEDTLS_PSA_ITS_FILE_C) && \
550+
!defined(MBEDTLS_FS_IO)
551+
#error "MBEDTLS_PSA_ITS_FILE_C defined, but not all prerequisites"
548552
#endif
549553

550554
#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \

features/mbedtls/inc/mbedtls/cipher.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ typedef enum {
176176
MBEDTLS_CIPHER_AES_256_XTS, /**< AES 256-bit cipher in XTS block mode. */
177177
MBEDTLS_CIPHER_CHACHA20, /**< ChaCha20 stream cipher. */
178178
MBEDTLS_CIPHER_CHACHA20_POLY1305, /**< ChaCha20-Poly1305 AEAD cipher. */
179+
MBEDTLS_CIPHER_AES_128_KW, /**< AES cipher with 128-bit NIST KW mode. */
180+
MBEDTLS_CIPHER_AES_192_KW, /**< AES cipher with 192-bit NIST KW mode. */
181+
MBEDTLS_CIPHER_AES_256_KW, /**< AES cipher with 256-bit NIST KW mode. */
182+
MBEDTLS_CIPHER_AES_128_KWP, /**< AES cipher with 128-bit NIST KWP mode. */
183+
MBEDTLS_CIPHER_AES_192_KWP, /**< AES cipher with 192-bit NIST KWP mode. */
184+
MBEDTLS_CIPHER_AES_256_KWP, /**< AES cipher with 256-bit NIST KWP mode. */
179185
} mbedtls_cipher_type_t;
180186

181187
/** Supported cipher modes. */
@@ -191,6 +197,8 @@ typedef enum {
191197
MBEDTLS_MODE_CCM, /**< The CCM cipher mode. */
192198
MBEDTLS_MODE_XTS, /**< The XTS cipher mode. */
193199
MBEDTLS_MODE_CHACHAPOLY, /**< The ChaCha-Poly cipher mode. */
200+
MBEDTLS_MODE_KW, /**< The SP800-38F KW mode */
201+
MBEDTLS_MODE_KWP, /**< The SP800-38F KWP mode */
194202
} mbedtls_cipher_mode_t;
195203

196204
/** Supported cipher padding types. */

features/mbedtls/inc/mbedtls/config.h

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,39 @@
776776
*
777777
* \note This option only works with the default software implementation of
778778
* elliptic curve functionality. It is incompatible with
779-
* MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT and MBEDTLS_ECDSA_XXX_ALT.
779+
* MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT, MBEDTLS_ECDSA_XXX_ALT
780+
* and MBEDTLS_ECDH_LEGACY_CONTEXT.
780781
*/
781782
//#define MBEDTLS_ECP_RESTARTABLE
782783

784+
/**
785+
* \def MBEDTLS_ECDH_LEGACY_CONTEXT
786+
*
787+
* Use a backward compatible ECDH context.
788+
*
789+
* Mbed TLS supports two formats for ECDH contexts (#mbedtls_ecdh_context
790+
* defined in `ecdh.h`). For most applications, the choice of format makes
791+
* no difference, since all library functions can work with either format,
792+
* except that the new format is incompatible with MBEDTLS_ECP_RESTARTABLE.
793+
794+
* The new format used when this option is disabled is smaller
795+
* (56 bytes on a 32-bit platform). In future versions of the library, it
796+
* will support alternative implementations of ECDH operations.
797+
* The new format is incompatible with applications that access
798+
* context fields directly and with restartable ECP operations.
799+
*
800+
* Define this macro if you enable MBEDTLS_ECP_RESTARTABLE or if you
801+
* want to access ECDH context fields directly. Otherwise you should
802+
* comment out this macro definition.
803+
*
804+
* This option has no effect if #MBEDTLS_ECDH_C is not enabled.
805+
*
806+
* \note This configuration option is experimental. Future versions of the
807+
* library may modify the way the ECDH context layout is configured
808+
* and may modify the layout of the new context type.
809+
*/
810+
#define MBEDTLS_ECDH_LEGACY_CONTEXT
811+
783812
/**
784813
* \def MBEDTLS_ECDSA_DETERMINISTIC
785814
*
@@ -1253,14 +1282,17 @@
12531282
//#define MBEDTLS_PSA_CRYPTO_SPM
12541283

12551284
/**
1256-
* \def MBEDTLS_PSA_HAS_ITS_IO
1285+
* \def MBEDTLS_PSA_INJECT_ENTROPY
12571286
*
1258-
* Enable the non-volatile secure storage usage.
1287+
* Enable support for entropy injection at first boot. This feature is
1288+
* required on systems that do not have a built-in entropy source (TRNG).
1289+
* This feature is currently not supported on systems that have a built-in
1290+
* entropy source.
12591291
*
1260-
* This is crucial on systems that do not have a HW TRNG support.
1292+
* Requires: MBEDTLS_PSA_CRYPTO_STORAGE_C, MBEDTLS_ENTROPY_NV_SEED
12611293
*
12621294
*/
1263-
//#define MBEDTLS_PSA_HAS_ITS_IO
1295+
//#define MBEDTLS_PSA_INJECT_ENTROPY
12641296

12651297
/**
12661298
* \def MBEDTLS_RSA_NO_CRT
@@ -1760,6 +1792,25 @@
17601792
*/
17611793
//#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
17621794

1795+
/**
1796+
* \def MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1797+
*
1798+
* If set, this enables the X.509 API `mbedtls_x509_crt_verify_with_ca_cb()`
1799+
* and the SSL API `mbedtls_ssl_conf_ca_cb()` which allow users to configure
1800+
* the set of trusted certificates through a callback instead of a linked
1801+
* list.
1802+
*
1803+
* This is useful for example in environments where a large number of trusted
1804+
* certificates is present and storing them in a linked list isn't efficient
1805+
* enough, or when the set of trusted certificates changes frequently.
1806+
*
1807+
* See the documentation of `mbedtls_x509_crt_verify_with_ca_cb()` and
1808+
* `mbedtls_ssl_conf_ca_cb()` for more information.
1809+
*
1810+
* Uncomment to enable trusted certificate callbacks.
1811+
*/
1812+
//#define MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
1813+
17631814
/**
17641815
* \def MBEDTLS_X509_CHECK_KEY_USAGE
17651816
*
@@ -2757,40 +2808,26 @@
27572808
*
27582809
* Enable the Platform Security Architecture persistent key storage.
27592810
*
2760-
* Module: library/psa_crypto_storage.c
2761-
*
2762-
* Requires: MBEDTLS_PSA_CRYPTO_C and one of either
2763-
* MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C or MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C
2764-
* (but not both)
2811+
* Module: crypto/library/psa_crypto_storage.c
27652812
*
2813+
* Requires: MBEDTLS_PSA_CRYPTO_C,
2814+
* either MBEDTLS_PSA_ITS_FILE_C or a native implementation of
2815+
* the PSA ITS interface
27662816
*/
27672817
//#define MBEDTLS_PSA_CRYPTO_STORAGE_C
27682818

27692819
/**
2770-
* \def MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
2771-
*
2772-
* Enable persistent key storage over files for the
2773-
* Platform Security Architecture cryptography API.
2774-
*
2775-
* Module: library/psa_crypto_storage_file.c
2776-
*
2777-
* Requires: MBEDTLS_PSA_CRYPTO_C, MBEDTLS_FS_IO
2778-
*
2779-
*/
2780-
//#define MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C
2781-
2782-
/**
2783-
* \def MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C
2820+
* \def MBEDTLS_PSA_ITS_FILE_C
27842821
*
2785-
* Enable persistent key storage over PSA ITS for the
2786-
* Platform Security Architecture cryptography API.
2822+
* Enable the emulation of the Platform Security Architecture
2823+
* Internal Trusted Storage (PSA ITS) over files.
27872824
*
2788-
* Module: library/psa_crypto_storage_its.c
2825+
* Module: crypto/library/psa_its_file.c
27892826
*
2790-
* Requires: MBEDTLS_PSA_CRYPTO_C, MBEDTLS_PSA_HAS_ITS_IO
2827+
* Requires: MBEDTLS_FS_IO
27912828
*
27922829
*/
2793-
//#define MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C
2830+
//#define MBEDTLS_PSA_ITS_FILE_C
27942831

27952832
/**
27962833
* \def MBEDTLS_RIPEMD160_C

features/mbedtls/inc/mbedtls/debug.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,3 @@ void mbedtls_debug_printf_ecdh( const mbedtls_ssl_context *ssl, int level,
262262
#endif
263263

264264
#endif /* debug.h */
265-

features/mbedtls/inc/mbedtls/ecdh.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@
4242

4343
#include "ecp.h"
4444

45-
/*
46-
* Use a backward compatible ECDH context.
47-
*
48-
* This flag is always enabled for now and future versions might add a
49-
* configuration option that conditionally undefines this flag.
50-
* The configuration option in question may have a different name.
51-
*
52-
* Features undefining this flag, must have a warning in their description in
53-
* config.h stating that the feature breaks backward compatibility.
54-
*/
55-
#define MBEDTLS_ECDH_LEGACY_CONTEXT
56-
5745
#ifdef __cplusplus
5846
extern "C" {
5947
#endif

0 commit comments

Comments
 (0)