Skip to content

Commit 3900b81

Browse files
committed
Update Mbed TLS to mbedtls-2.15.0
1 parent 70f9497 commit 3900b81

Some content is hidden

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

87 files changed

+17924
-1285
lines changed

features/mbedtls/VERSION.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
mbedtls-2.13.1
1+
mbedtls-2.15.0
2+
mbedcrypto-0.1.0b

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.13.1
30+
MBED_TLS_RELEASE ?= mbedtls-2.15.0
3131

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

features/mbedtls/inc/mbedtls/aes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@
6060

6161
/* Error codes in range 0x0021-0x0025 */
6262
#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021 /**< Invalid input data. */
63+
64+
/* MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE is deprecated and should not be used. */
6365
#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 /**< Feature not available. For example, an unsupported AES key size. */
66+
67+
/* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */
6468
#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */
6569

6670
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \

features/mbedtls/inc/mbedtls/arc4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include <stddef.h>
3838

39+
/* MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED is deprecated and should not be used. */
3940
#define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */
4041

4142
#ifdef __cplusplus

features/mbedtls/inc/mbedtls/aria.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848

4949
#define MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH -0x005C /**< Invalid key length. */
5050
#define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */
51+
52+
/* MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE is deprecated and should not be used.
53+
*/
5154
#define MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE -0x005A /**< Feature not available. For example, an unsupported ARIA key size. */
55+
56+
/* MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED is deprecated and should not be used. */
5257
#define MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED -0x0058 /**< ARIA hardware accelerator failed. */
5358

5459
#if !defined(MBEDTLS_ARIA_ALT)

features/mbedtls/inc/mbedtls/asn1write.h

Lines changed: 196 additions & 114 deletions
Large diffs are not rendered by default.

features/mbedtls/inc/mbedtls/bignum.h

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,36 +725,85 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B
725725
*/
726726
int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N );
727727

728+
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
729+
#if defined(MBEDTLS_DEPRECATED_WARNING)
730+
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
731+
#else
732+
#define MBEDTLS_DEPRECATED
733+
#endif
734+
/**
735+
* \brief Miller-Rabin primality test with error probability of
736+
* 2<sup>-80</sup>
737+
*
738+
* \deprecated Superseded by mbedtls_mpi_is_prime_ext() which allows
739+
* specifying the number of Miller-Rabin rounds.
740+
*
741+
* \param X MPI to check
742+
* \param f_rng RNG function
743+
* \param p_rng RNG parameter
744+
*
745+
* \return 0 if successful (probably prime),
746+
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
747+
* MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if X is not prime
748+
*/
749+
MBEDTLS_DEPRECATED int mbedtls_mpi_is_prime( const mbedtls_mpi *X,
750+
int (*f_rng)(void *, unsigned char *, size_t),
751+
void *p_rng );
752+
#undef MBEDTLS_DEPRECATED
753+
#endif /* !MBEDTLS_DEPRECATED_REMOVED */
754+
728755
/**
729-
* \brief Miller-Rabin primality test
756+
* \brief Miller-Rabin primality test.
757+
*
758+
* \warning If \p X is potentially generated by an adversary, for example
759+
* when validating cryptographic parameters that you didn't
760+
* generate yourself and that are supposed to be prime, then
761+
* \p rounds should be at least the half of the security
762+
* strength of the cryptographic algorithm. On the other hand,
763+
* if \p X is chosen uniformly or non-adversially (as is the
764+
* case when mbedtls_mpi_gen_prime calls this function), then
765+
* \p rounds can be much lower.
730766
*
731767
* \param X MPI to check
768+
* \param rounds Number of bases to perform Miller-Rabin primality test for.
769+
* The probability of returning 0 on a composite is at most
770+
* 2<sup>-2*\p rounds</sup>.
732771
* \param f_rng RNG function
733772
* \param p_rng RNG parameter
734773
*
735774
* \return 0 if successful (probably prime),
736775
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
737776
* MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if X is not prime
738777
*/
739-
int mbedtls_mpi_is_prime( const mbedtls_mpi *X,
740-
int (*f_rng)(void *, unsigned char *, size_t),
741-
void *p_rng );
778+
int mbedtls_mpi_is_prime_ext( const mbedtls_mpi *X, int rounds,
779+
int (*f_rng)(void *, unsigned char *, size_t),
780+
void *p_rng );
781+
/**
782+
* \brief Flags for mbedtls_mpi_gen_prime()
783+
*
784+
* Each of these flags is a constraint on the result X returned by
785+
* mbedtls_mpi_gen_prime().
786+
*/
787+
typedef enum {
788+
MBEDTLS_MPI_GEN_PRIME_FLAG_DH = 0x0001, /**< (X-1)/2 is prime too */
789+
MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR = 0x0002, /**< lower error rate from 2<sup>-80</sup> to 2<sup>-128</sup> */
790+
} mbedtls_mpi_gen_prime_flag_t;
742791

743792
/**
744793
* \brief Prime number generation
745794
*
746795
* \param X Destination MPI
747796
* \param nbits Required size of X in bits
748797
* ( 3 <= nbits <= MBEDTLS_MPI_MAX_BITS )
749-
* \param dh_flag If 1, then (X-1)/2 will be prime too
798+
* \param flags Mask of flags of type #mbedtls_mpi_gen_prime_flag_t
750799
* \param f_rng RNG function
751800
* \param p_rng RNG parameter
752801
*
753802
* \return 0 if successful (probably prime),
754803
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
755804
* MBEDTLS_ERR_MPI_BAD_INPUT_DATA if nbits is < 3
756805
*/
757-
int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag,
806+
int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int flags,
758807
int (*f_rng)(void *, unsigned char *, size_t),
759808
void *p_rng );
760809

features/mbedtls/inc/mbedtls/blowfish.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@
4141
#define MBEDTLS_BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */
4242

4343
#define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH -0x0016 /**< Invalid key length. */
44+
45+
/* MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED is deprecated and should not be used.
46+
*/
4447
#define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED -0x0017 /**< Blowfish hardware accelerator failed. */
48+
4549
#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018 /**< Invalid data input length. */
4650

4751
#ifdef __cplusplus

features/mbedtls/inc/mbedtls/bn_mul.h

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,8 @@
565565
#endif /* TriCore */
566566

567567
/*
568-
* gcc -O0 by default uses r7 for the frame pointer, so it complains about our
569-
* use of r7 below, unless -fomit-frame-pointer is passed. Unfortunately,
570-
* passing that option is not easy when building with yotta.
568+
* Note, gcc -O0 by default uses r7 for the frame pointer, so it complains about
569+
* our use of r7 below, unless -fomit-frame-pointer is passed.
571570
*
572571
* On the other hand, -fomit-frame-pointer is implied by any -Ox options with
573572
* x !=0, which we can detect using __OPTIMIZE__ (which is also defined by
@@ -637,6 +636,23 @@
637636
"r6", "r7", "r8", "r9", "cc" \
638637
);
639638

639+
#elif defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)
640+
641+
#define MULADDC_INIT \
642+
asm(
643+
644+
#define MULADDC_CORE \
645+
"ldr r0, [%0], #4 \n\t" \
646+
"ldr r1, [%1] \n\t" \
647+
"umaal r1, %2, %3, r0 \n\t" \
648+
"str r1, [%1], #4 \n\t"
649+
650+
#define MULADDC_STOP \
651+
: "=r" (s), "=r" (d), "=r" (c) \
652+
: "r" (b), "0" (s), "1" (d), "2" (c) \
653+
: "r0", "r1", "memory" \
654+
);
655+
640656
#else
641657

642658
#define MULADDC_INIT \

features/mbedtls/inc/mbedtls/camellia.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838

3939
#define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024 /**< Invalid key length. */
4040
#define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026 /**< Invalid data input length. */
41+
42+
/* MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED is deprecated and should not be used.
43+
*/
4144
#define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027 /**< Camellia hardware accelerator failed. */
4245

4346
#ifdef __cplusplus

features/mbedtls/inc/mbedtls/ccm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353

5454
#define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /**< Bad input parameters to the function. */
5555
#define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F /**< Authenticated decryption failed. */
56+
57+
/* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */
5658
#define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011 /**< CCM hardware accelerator failed. */
5759

5860

features/mbedtls/inc/mbedtls/chacha20.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@
4343
#include <stddef.h>
4444

4545
#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x0051 /**< Invalid input parameter(s). */
46+
47+
/* MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE is deprecated and should not be
48+
* used. */
4649
#define MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE -0x0053 /**< Feature not available. For example, s part of the API is not implemented. */
50+
51+
/* MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED is deprecated and should not be used.
52+
*/
4753
#define MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED -0x0055 /**< Chacha20 hardware accelerator failed. */
4854

4955
#ifdef __cplusplus

features/mbedtls/inc/mbedtls/check_config.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@
108108
#error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites"
109109
#endif
110110

111+
#if defined(MBEDTLS_ECP_RESTARTABLE) && \
112+
( defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) || \
113+
defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT) || \
114+
defined(MBEDTLS_ECDSA_SIGN_ALT) || \
115+
defined(MBEDTLS_ECDSA_VERIFY_ALT) || \
116+
defined(MBEDTLS_ECDSA_GENKEY_ALT) || \
117+
defined(MBEDTLS_ECP_ALT) )
118+
#error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative ECP implementation"
119+
#endif
120+
111121
#if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C)
112122
#error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites"
113123
#endif
@@ -486,6 +496,12 @@
486496
#error "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO and MBEDTLS_PLATFORM_STD_NV_SEED_WRITE cannot be defined simultaneously"
487497
#endif
488498

499+
#if defined(MBEDTLS_PSA_CRYPTO_C) && \
500+
!( defined(MBEDTLS_CTR_DRBG_C) && \
501+
defined(MBEDTLS_ENTROPY_C) )
502+
#error "MBEDTLS_PSA_CRYPTO_C defined, but not all prerequisites"
503+
#endif
504+
489505
#if defined(MBEDTLS_RSA_C) && ( !defined(MBEDTLS_BIGNUM_C) || \
490506
!defined(MBEDTLS_OID_C) )
491507
#error "MBEDTLS_RSA_C defined, but not all prerequisites"
@@ -628,6 +644,10 @@
628644
#endif
629645
#undef MBEDTLS_THREADING_IMPL
630646

647+
#if defined(MBEDTLS_USE_PSA_CRYPTO) && !defined(MBEDTLS_PSA_CRYPTO_C)
648+
#error "MBEDTLS_USE_PSA_CRYPTO defined, but not all prerequisites"
649+
#endif
650+
631651
#if defined(MBEDTLS_VERSION_FEATURES) && !defined(MBEDTLS_VERSION_C)
632652
#error "MBEDTLS_VERSION_FEATURES defined, but not all prerequisites"
633653
#endif

0 commit comments

Comments
 (0)