Skip to content

Commit 860e4be

Browse files
authored
Merge pull request #8859 from Patater/dev/Patater/import-mbed-tls-and-crypto
Import Mbed TLS v2.15.0 with Mbed Crypto
2 parents d7f2e30 + 3900b81 commit 860e4be

Some content is hidden

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

89 files changed

+17978
-1287
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: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,39 @@
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:=../
34+
TARGET_PREFIX_CRYPTO:=../mbed-crypto/
3435
TARGET_SRC:=$(TARGET_PREFIX)src
3536
TARGET_INC:=$(TARGET_PREFIX)inc
3637
TARGET_TESTS:=$(TARGET_PREFIX)TESTS
3738

39+
# New folder structure is introduced here for targets with Secured-Partition-Environment
40+
# and Non-Secured-Partition-Environment, below documentation for each folder:
41+
# COMPONENT_PSA_SRV_IMPL - include secure service business logic implementation
42+
# code. For example Mbed Crypto or secure time core logic
43+
TARGET_SRV_IMPL:=$(TARGET_PREFIX_CRYPTO)/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL
44+
# COMPONENT_SPE - include code that compiles ONLY to secure image and never
45+
# compiles to non-secure image
46+
TARGET_SPE:=$(TARGET_PREFIX_CRYPTO)/platform/TARGET_PSA/COMPONENT_SPE
47+
# The folder contain specific target implementation using hardware.
48+
TARGET_PSA_DRIVERS:=$(TARGET_PREFIX_CRYPTO)/targets
49+
# COMPONENT_NSPE - include code that compiles ONLY to non-secure image and
50+
# never compiles to secure image
51+
TARGET_NSPE:=$(TARGET_SRV_IMPL)/COMPONENT_NSPE
52+
3853
# mbed TLS source directory - hidden from mbed via TARGET_IGNORE
3954
MBED_TLS_URL:[email protected]:ARMmbed/mbedtls-restricted.git
4055
MBED_TLS_DIR:=TARGET_IGNORE/mbedtls
4156
MBED_TLS_API:=$(MBED_TLS_DIR)/include/mbedtls
4257
MBED_TLS_GIT_CFG=$(MBED_TLS_DIR)/.git/config
4358

59+
# Mbed Crypto directory - hidden from mbed via TARGET_IGNORE
60+
MBED_CRYPTO_DIR:=$(MBED_TLS_DIR)/crypto
61+
MBED_CRYPTO_API:=$(MBED_CRYPTO_DIR)/include/psa
62+
4463
.PHONY: all deploy deploy-tests rsync mbedtls clean update
4564

4665
all: mbedtls
@@ -62,6 +81,23 @@ rsync:
6281
cp $(MBED_TLS_DIR)/LICENSE $(TARGET_PREFIX)
6382
cp $(MBED_TLS_DIR)/apache-2.0.txt $(TARGET_PREFIX)
6483
#
84+
# Create Mbed Crypto target folder
85+
mkdir -p $(TARGET_PREFIX_CRYPTO)
86+
#
87+
# Copying Mbed Crypto into Mbed OS..
88+
rm -rf $(TARGET_SRV_IMPL)
89+
rm -rf $(TARGET_SPE)
90+
91+
mkdir -p $(TARGET_SRV_IMPL)
92+
mkdir -p $(TARGET_SPE)
93+
mkdir -p $(TARGET_NSPE)
94+
mkdir -p $(TARGET_PSA_DRIVERS)
95+
96+
rsync -a --delete --exclude='crypto_struct.h' $(MBED_CRYPTO_API) $(TARGET_INC)
97+
rsync -a --delete $(MBED_CRYPTO_API)/crypto_struct.h $(TARGET_NSPE)
98+
rsync -a --delete $(MBED_CRYPTO_API)/crypto_struct.h $(TARGET_SPE)/crypto_struct_spe.h
99+
rsync -a --delete $(MBED_CRYPTO_DIR)/library/psa_*.c $(TARGET_SRV_IMPL)
100+
rsync -a --delete $(MBED_CRYPTO_DIR)/library/psa_*.h $(TARGET_SRV_IMPL)
65101

66102
deploy: rsync
67103
#
@@ -92,8 +128,14 @@ update: $(MBED_TLS_GIT_CFG) $(MBED_TLS_HA_GIT_CFG)
92128
# Checking out the required release
93129
git -C $(MBED_TLS_DIR) checkout $(MBED_TLS_RELEASE)
94130
#
131+
# Update and checkout git submodules
132+
git -C $(MBED_TLS_DIR) submodule update --init --recursive
133+
#
95134
# Updating checked out version tag
96135
echo $(MBED_TLS_RELEASE) > $(TARGET_PREFIX)VERSION.txt
136+
#
137+
# Updating Mbed Crypto checked out version tag
138+
git -C $(MBED_CRYPTO_DIR) describe --tags --abbrev=12 --dirty --always >> $(TARGET_PREFIX)VERSION.txt
97139

98140
$(MBED_TLS_GIT_CFG):
99141
rm -rf $(MBED_TLS_DIR)
@@ -107,4 +149,5 @@ clean:
107149
rm -rf $(TARGET_SRC)
108150
rm -rf $(TARGET_INC)
109151
rm -rf $(MBED_TLS_DIR)
110-
152+
rm -rf $(TARGET_SRV_IMPL)
153+
rm -rf $(TARGET_SPE)

features/mbedtls/importer/adjust-config.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SCRIPT=$1
2222
FILE=$2
2323

2424
conf() {
25-
$SCRIPT -f $FILE $@
25+
$SCRIPT -f $FILE --force $@
2626
}
2727

2828
add_code() {
@@ -140,3 +140,8 @@ conf unset MBEDTLS_SSL_TRUNCATED_HMAC
140140

141141
conf unset MBEDTLS_PLATFORM_TIME_TYPE_MACRO
142142

143+
# The following configurations are a needed for Mbed Crypto submodule.
144+
# They are related to the persistent key storage feature.
145+
conf set MBEDTLS_PSA_CRYPTO_STORAGE_C
146+
conf set MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C
147+
conf unset MBEDTLS_PSA_CRYPTO_STORAGE_FILE_C

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)

0 commit comments

Comments
 (0)