Skip to content

Commit b481da4

Browse files
authored
Merge pull request #2843 from andresag01/update_mbedtls
Update feature/mbedtls with mbedtls' development HEAD
2 parents 58c12f1 + 11ee1de commit b481da4

31 files changed

+765
-287
lines changed

features/mbedtls/importer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TARGET_SRC:=$(TARGET_PREFIX)src
3535
TARGET_INC:=$(TARGET_PREFIX)inc
3636

3737
# mbed TLS source directory - hidden from mbed via TARGET_IGNORE
38-
MBED_TLS_URL:=https://github.com/ARMmbed/mbedtls-restricted.git
38+
MBED_TLS_URL:=https://github.com/ARMmbed/mbedtls.git
3939
MBED_TLS_DIR:=TARGET_IGNORE/mbedtls
4040
MBED_TLS_API:=$(MBED_TLS_DIR)/include/mbedtls
4141
MBED_TLS_GIT_CFG=$(MBED_TLS_DIR)/.git/config

features/mbedtls/inc/mbedtls/check_config.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,36 @@
256256
#error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously"
257257
#endif
258258

259+
#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\
260+
( !defined(MBEDTLS_PLATFORM_C) ||\
261+
!defined(MBEDTLS_HAVE_TIME) )
262+
#error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites"
263+
#endif
264+
265+
#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
266+
( !defined(MBEDTLS_PLATFORM_C) ||\
267+
!defined(MBEDTLS_HAVE_TIME) )
268+
#error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites"
269+
#endif
270+
271+
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
272+
( !defined(MBEDTLS_PLATFORM_C) ||\
273+
!defined(MBEDTLS_HAVE_TIME) )
274+
#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites"
275+
#endif
276+
277+
#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
278+
( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
279+
defined(MBEDTLS_PLATFORM_TIME_ALT) )
280+
#error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
281+
#endif
282+
283+
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
284+
( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
285+
defined(MBEDTLS_PLATFORM_TIME_ALT) )
286+
#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
287+
#endif
288+
259289
#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
260290
#error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites"
261291
#endif
@@ -352,6 +382,12 @@
352382
#error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
353383
#endif
354384

385+
#if defined(MBEDTLS_PLATFORM_STD_TIME) &&\
386+
( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\
387+
!defined(MBEDTLS_HAVE_TIME) )
388+
#error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites"
389+
#endif
390+
355391
#if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\
356392
!defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
357393
#error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Minimal configuration of features that do not require an entropy source
3+
*
4+
* Copyright (C) 2016, ARM Limited, All Rights Reserved
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
8+
* not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
* This file is part of mbed TLS (https://tls.mbed.org)
20+
*/
21+
/*
22+
* Minimal configuration of features that do not require an entropy source
23+
* Distinguishing reatures:
24+
* - no entropy module
25+
* - no TLS protocol implementation available due to absence of an entropy
26+
* source
27+
*
28+
* See README.txt for usage instructions.
29+
*/
30+
31+
#ifndef MBEDTLS_CONFIG_H
32+
#define MBEDTLS_CONFIG_H
33+
34+
/* System support */
35+
#define MBEDTLS_HAVE_ASM
36+
#define MBEDTLS_HAVE_TIME
37+
38+
/* mbed TLS feature support */
39+
#define MBEDTLS_CIPHER_MODE_CBC
40+
#define MBEDTLS_CIPHER_PADDING_PKCS7
41+
#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES
42+
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
43+
#define MBEDTLS_ECP_DP_SECP384R1_ENABLED
44+
#define MBEDTLS_ECP_DP_CURVE25519_ENABLED
45+
#define MBEDTLS_ECP_NIST_OPTIM
46+
#define MBEDTLS_ECDSA_DETERMINISTIC
47+
#define MBEDTLS_PK_RSA_ALT_SUPPORT
48+
#define MBEDTLS_PKCS1_V15
49+
#define MBEDTLS_PKCS1_V21
50+
#define MBEDTLS_SELF_TEST
51+
#define MBEDTLS_VERSION_FEATURES
52+
#define MBEDTLS_X509_CHECK_KEY_USAGE
53+
#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
54+
55+
/* mbed TLS modules */
56+
#define MBEDTLS_AES_C
57+
#define MBEDTLS_ASN1_PARSE_C
58+
#define MBEDTLS_ASN1_WRITE_C
59+
#define MBEDTLS_BASE64_C
60+
#define MBEDTLS_BIGNUM_C
61+
#define MBEDTLS_CCM_C
62+
#define MBEDTLS_CIPHER_C
63+
#define MBEDTLS_ECDSA_C
64+
#define MBEDTLS_ECP_C
65+
#define MBEDTLS_ERROR_C
66+
#define MBEDTLS_GCM_C
67+
#define MBEDTLS_HMAC_DRBG_C
68+
#define MBEDTLS_MD_C
69+
#define MBEDTLS_OID_C
70+
#define MBEDTLS_PEM_PARSE_C
71+
#define MBEDTLS_PK_C
72+
#define MBEDTLS_PK_PARSE_C
73+
#define MBEDTLS_PK_WRITE_C
74+
#define MBEDTLS_PLATFORM_C
75+
#define MBEDTLS_RSA_C
76+
#define MBEDTLS_SHA256_C
77+
#define MBEDTLS_SHA512_C
78+
#define MBEDTLS_VERSION_C
79+
#define MBEDTLS_X509_USE_C
80+
#define MBEDTLS_X509_CRT_PARSE_C
81+
#define MBEDTLS_X509_CRL_PARSE_C
82+
83+
#include "check_config.h"
84+
85+
#endif /* MBEDTLS_CONFIG_H */

features/mbedtls/inc/mbedtls/config.h

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
*/
2727

2828
#ifndef MBEDTLS_CONFIG_H
29+
30+
#include "platform/inc/platform_mbed.h"
31+
32+
/*
33+
* Only use features that do not require an entropy source when
34+
* DEVICE_ENTROPY_SOURCE is not defined in mbed OS.
35+
*/
36+
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
37+
#include "mbedtls/config-no-entropy.h"
38+
#else
2939
#define MBEDTLS_CONFIG_H
3040

3141
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
@@ -71,6 +81,10 @@
7181
* The time does not need to be correct, only time differences are used,
7282
* by contrast with MBEDTLS_HAVE_TIME_DATE
7383
*
84+
* Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT,
85+
* MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and
86+
* MBEDTLS_PLATFORM_STD_TIME.
87+
*
7488
* Comment if your system does not support time functions
7589
*/
7690
#define MBEDTLS_HAVE_TIME
@@ -148,6 +162,8 @@
148162
* \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as
149163
* MBEDTLS_PLATFORM_XXX_MACRO!
150164
*
165+
* Requires: MBEDTLS_PLATFORM_TIME_ALT requires MBEDTLS_HAVE_TIME
166+
*
151167
* Uncomment a macro to enable alternate implementation of specific base
152168
* platform function
153169
*/
@@ -1954,7 +1970,7 @@
19541970
* environment:
19551971
* https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS
19561972
*
1957-
* Module: library/net.c
1973+
* Module: library/net_sockets.c
19581974
*
19591975
* This module provides networking routines.
19601976
*/
@@ -2503,6 +2519,7 @@
25032519
/* Entropy options */
25042520
//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */
25052521
//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */
2522+
//#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware entropy source mbedtls_hardware_poll() before entropy is released */
25062523

25072524
/* Memory buffer allocator options */
25082525
//#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */
@@ -2512,7 +2529,7 @@
25122529
//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */
25132530
//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
25142531
//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
2515-
//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined */
2532+
//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
25162533
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
25172534
//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
25182535
/* Note: your snprintf must correclty zero-terminate the buffer! */
@@ -2528,8 +2545,8 @@
25282545
//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */
25292546
//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */
25302547
//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */
2531-
//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined */
2532-
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined */
2548+
//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
2549+
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
25332550
//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */
25342551
//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */
25352552
/* Note: your snprintf must correclty zero-terminate the buffer! */
@@ -2563,11 +2580,16 @@
25632580

25642581
/* X509 options */
25652582
//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */
2583+
//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */
25662584

25672585
/* \} name SECTION: Customisation configuration options */
25682586

25692587
/* Target and application specific configurations */
2570-
//#define YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE "target_config.h"
2588+
//#define YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE "mbedtls/target_config.h"
2589+
2590+
#if defined(TARGET_LIKE_MBED) && defined(YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE)
2591+
#include YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE
2592+
#endif
25712593

25722594
/*
25732595
* Allow user to override any previous default.
@@ -2584,4 +2606,5 @@
25842606

25852607
#include "check_config.h"
25862608

2609+
#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT */
25872610
#endif /* MBEDTLS_CONFIG_H */

features/mbedtls/inc/mbedtls/entropy.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,29 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *
255255
/**
256256
* \brief Checkup routine
257257
*
258+
* This module self-test also calls the entropy self-test,
259+
* mbedtls_entropy_source_self_test();
260+
*
258261
* \return 0 if successful, or 1 if a test failed
259262
*/
260263
int mbedtls_entropy_self_test( int verbose );
264+
265+
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
266+
/**
267+
* \brief Checkup routine
268+
*
269+
* Verifies the integrity of the hardware entropy source
270+
* provided by the function 'mbedtls_hardware_poll()'.
271+
*
272+
* Note this is the only hardware entropy source that is known
273+
* at link time, and other entropy sources configured
274+
* dynamically at runtime by the function
275+
* mbedtls_entropy_add_source() will not be tested.
276+
*
277+
* \return 0 if successful, or 1 if a test failed
278+
*/
279+
int mbedtls_entropy_source_self_test( int verbose );
280+
#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */
261281
#endif /* MBEDTLS_SELF_TEST */
262282

263283
#ifdef __cplusplus

features/mbedtls/inc/mbedtls/entropy_poll.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ extern "C" {
4141
#define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
4242
#define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
4343
#define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
44+
#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
4445
#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
46+
#endif
4547

4648
/**
4749
* \brief Entropy poll callback that provides 0 entropy.

0 commit comments

Comments
 (0)