Skip to content

Commit d2e5941

Browse files
authored
Merge pull request #10894 from dgreen-arm/update-mbedtls-makefile
Add adjust-check-config script to mbedtls importer
2 parents b55344c + 8f6667d commit d2e5941

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

features/mbedtls/importer/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ deploy: rsync
132132
# Adjusting the default mbed TLS config file to mbed purposes
133133
./adjust-config.sh $(MBED_TLS_DIR)/scripts/config.pl $(TARGET_INC)/mbedtls/config.h
134134
#
135+
# Adjusting the default mbed TLS check-config file to mbed purposes
136+
./adjust-check-config.sh $(TARGET_INC)/mbedtls/check_config.h
137+
#
135138
# Copy and adjust the trimmed config that does not require entropy source
136139
cp $(MBED_TLS_DIR)/configs/config-no-entropy.h $(TARGET_INC)/mbedtls/.
137140
./adjust-no-entropy-config.sh $(MBED_TLS_DIR)/scripts/config.pl $(TARGET_INC)/mbedtls/config-no-entropy.h
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
#
3+
# This file is part of mbed TLS (https://tls.mbed.org)
4+
#
5+
# Copyright (c) 2019, Arm Limited, All Rights Reserved
6+
#
7+
# SPDX-License-Identifier: Apache-2.0
8+
# Licensed under the Apache License, Version 2.0 (the License); you may
9+
# not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# * http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an AS IS BASIS, WITHOUT
16+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
#
20+
# Purpose
21+
#
22+
# Removes checks from check_config.h that aren't needed for Mbed OS
23+
#
24+
# Usage: adjust-check-config.sh [path to check_config file]
25+
#
26+
set -eu
27+
28+
if [ $# -ne 1 ]; then
29+
echo "Usage: $0 path/to/check_config.h" >&2
30+
exit 1
31+
fi
32+
33+
FILE=$1
34+
35+
conf() {
36+
$SCRIPT -f $FILE --force $@
37+
}
38+
39+
remove_code() {
40+
MATCH_PATTERN=$(IFS=""; printf "%s" "$*")
41+
42+
perl -0pi -e "s/$MATCH_PATTERN//g" "$FILE"
43+
}
44+
45+
# When using Mbed Crypto's PSA Entropy Injection feature on Mbed OS, it is
46+
# not required to opt out of having entropy sources added to your entropy
47+
# contexts by default (via MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES).
48+
# As integrated in Mbed OS, MBEDTLS_PSA_INJECT_ENTROPY is compatible with
49+
# actual entropy sources. PSA entropy injection is implemented using the
50+
# standard Mbed TLS NV Seed feature, and is as compatible with other
51+
# entropy sources as the standard Mbed TLS NV Seed feature which does
52+
# support entropy mixing.
53+
remove_code \
54+
"#if defined\(MBEDTLS_PSA_INJECT_ENTROPY\) && \\\\\n" \
55+
" !defined\(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES\)\n" \
56+
"#error \"MBEDTLS_PSA_INJECT_ENTROPY is not compatible with actual entropy sources\"\n" \
57+
"#endif\n" \
58+
"\n"

0 commit comments

Comments
 (0)