Skip to content

Commit c64108d

Browse files
committed
tls/crypto: Make mbed-crypto importer independent
Obtain the version of Mbed Crypto to use not from the Mbed TLS submodule, but independently through the Mbed Crypto importer instead.
1 parent 16e544d commit c64108d

File tree

4 files changed

+117
-45
lines changed

4 files changed

+117
-45
lines changed

features/mbedtls/importer/Makefile

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,15 @@ MBED_TLS_REPO_URL ?= [email protected]:ARMmbed/mbedtls-restricted.git
3232

3333
# Translate between mbed TLS namespace and mbed namespace
3434
TARGET_PREFIX:=../
35-
TARGET_PREFIX_CRYPTO:=../mbed-crypto/
3635
TARGET_SRC:=$(TARGET_PREFIX)src
3736
TARGET_INC:=$(TARGET_PREFIX)inc
3837
TARGET_TESTS:=$(TARGET_PREFIX)TESTS
3938

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

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-
6344
.PHONY: all deploy deploy-tests rsync mbedtls clean update
6445

6546
all: mbedtls
@@ -81,23 +62,6 @@ rsync:
8162
cp $(MBED_TLS_DIR)/LICENSE $(TARGET_PREFIX)
8263
cp $(MBED_TLS_DIR)/apache-2.0.txt $(TARGET_PREFIX)
8364
#
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)
10165

10266
deploy: rsync
10367
#
@@ -128,14 +92,8 @@ update: $(MBED_TLS_GIT_CFG) $(MBED_TLS_HA_GIT_CFG)
12892
# Checking out the required release
12993
git -C $(MBED_TLS_DIR) checkout $(MBED_TLS_RELEASE)
13094
#
131-
# Update and checkout git submodules
132-
git -C $(MBED_TLS_DIR) submodule update --init --recursive
133-
#
13495
# Updating checked out version tag
13596
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
13997

14098
$(MBED_TLS_GIT_CFG):
14199
rm -rf $(MBED_TLS_DIR)
@@ -149,5 +107,3 @@ clean:
149107
rm -rf $(TARGET_SRC)
150108
rm -rf $(TARGET_INC)
151109
rm -rf $(MBED_TLS_DIR)
152-
rm -rf $(TARGET_SRV_IMPL)
153-
rm -rf $(TARGET_SPE)

features/mbedtls/importer/adjust-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ conf unset MBEDTLS_PLATFORM_TIME_TYPE_MACRO
146146
# which should fit RSA 4096 bit keys.
147147
conf set MBEDTLS_MPI_MAX_SIZE 512
148148

149-
# The following configurations are a needed for Mbed Crypto submodule.
149+
# The following configurations are needed for Mbed Crypto.
150150
# They are related to the persistent key storage feature.
151151
conf set MBEDTLS_PSA_CRYPTO_STORAGE_C
152152
conf set MBEDTLS_PSA_CRYPTO_STORAGE_ITS_C
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
###########################################################################
2+
#
3+
# Copyright (c) 2016, ARM Limited, All Rights Reserved
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7+
# not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
###########################################################################
19+
20+
#
21+
# Use this file to import an Mbed Crypto release into Mbed OS as follows:
22+
#
23+
# 1) Set the CRYPTO_RELEASE variable to the required Mbed Crypto release
24+
# tag
25+
# 2) make update
26+
# 3) make
27+
# 4) commit and push changes via git
28+
#
29+
30+
# Set the Mbed Crypto release to import (this can/should be edited before
31+
# import)
32+
CRYPTO_RELEASE ?= mbedcrypto-0.1.0b2
33+
CRYPTO_REPO_URL ?= [email protected]:ARMmbed/mbed-crypto.git
34+
35+
# Translate between Mbed Crypto namespace and Mbed OS namespace
36+
TARGET_PREFIX:=..
37+
TARGET_INC:=$(TARGET_PREFIX)/inc
38+
39+
# A folder structure is introduced here for targets that have both a Secure
40+
# Processing Environment (SPE) targets and Non-secure Processing Environment
41+
# (NSPE). Documentation for each folder as follows:
42+
# COMPONENT_PSA_SRV_IMPL - Include secure service implementation code. For
43+
# example PSA Crypto or PSA Secure Time implementations
44+
TARGET_SRV_IMPL:=$(TARGET_PREFIX)/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL
45+
# COMPONENT_SPE - Include code that compiles ONLY to the SPE image and never
46+
# compiles to the NSPE image
47+
TARGET_SPE:=$(TARGET_PREFIX)/platform/TARGET_PSA/COMPONENT_SPE
48+
# COMPONENT_NSPE - Include code that compiles ONLY to the NSPE image and never
49+
# compiles to the SPE image
50+
TARGET_NSPE:=$(TARGET_SRV_IMPL)/COMPONENT_NSPE
51+
52+
# Mbed Crypto source directory - hidden from mbed via TARGET_IGNORE
53+
CRYPTO_DIR:=TARGET_IGNORE/mbed-crypto
54+
CRYPTO_API:=$(CRYPTO_DIR)/include/psa
55+
CRYPTO_GIT_CFG=$(CRYPTO_DIR)/.git/config
56+
57+
58+
.PHONY: all rsync clean update
59+
60+
all: rsync
61+
62+
rsync:
63+
#
64+
# Copying Mbed Crypto headers to includes...
65+
rm -rf $(TARGET_INC)
66+
mkdir -p $(TARGET_INC)
67+
rsync -a --delete --exclude='crypto_struct.h' $(CRYPTO_API) $(TARGET_INC)/
68+
#
69+
# Copying licenses
70+
cp $(CRYPTO_DIR)/LICENSE $(TARGET_PREFIX)/
71+
cp $(CRYPTO_DIR)/apache-2.0.txt $(TARGET_PREFIX)/
72+
#
73+
# Copying Mbed Crypto into Mbed OS...
74+
rm -rf $(TARGET_SRV_IMPL)
75+
rm -rf $(TARGET_SPE)
76+
77+
mkdir -p $(TARGET_SRV_IMPL)
78+
mkdir -p $(TARGET_SPE)
79+
mkdir -p $(TARGET_NSPE)
80+
81+
rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_NSPE)/
82+
rsync -a --delete $(CRYPTO_API)/crypto_struct.h $(TARGET_SPE)/crypto_struct_spe.h
83+
rsync -a --delete $(CRYPTO_DIR)/library/psa_*.c $(TARGET_SRV_IMPL)/
84+
rsync -a --delete $(CRYPTO_DIR)/library/psa_*.h $(TARGET_SRV_IMPL)/
85+
86+
update: $(CRYPTO_GIT_CFG)
87+
#
88+
# Updating to the specified Mbed Crypto library version
89+
# (If it is not an initial checkout we will start with the repository
90+
# being in a detached head state)
91+
git -C $(CRYPTO_DIR) checkout development
92+
git -C $(CRYPTO_DIR) pull --rebase origin development
93+
#
94+
# Checking out the required release
95+
git -C $(CRYPTO_DIR) checkout $(CRYPTO_RELEASE)
96+
#
97+
# Update and checkout git submodules
98+
git -C $(CRYPTO_DIR) submodule update --init --recursive
99+
#
100+
# Updating Mbed Crypto checked out version tag
101+
git -C $(CRYPTO_DIR) describe --tags --abbrev=12 --dirty --always > $(TARGET_PREFIX)/VERSION.txt
102+
103+
$(CRYPTO_GIT_CFG):
104+
rm -rf $(CRYPTO_DIR)
105+
git clone $(CRYPTO_REPO_URL) $(CRYPTO_DIR)
106+
107+
clean:
108+
rm -f $(TARGET_PREFIX)/LICENSE
109+
rm -f $(TARGET_PREFIX)/apache-2.0.txt
110+
rm -f $(TARGET_PREFIX)/VERSION.txt
111+
rm -f $(TARGET_PREFIX)/AUTHORS.txt
112+
rm -rf $(TARGET_INC)
113+
rm -rf $(CRYPTO_DIR)
114+
rm -rf $(TARGET_SRV_IMPL)
115+
rm -rf $(TARGET_SPE)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mbed-crypto

0 commit comments

Comments
 (0)