Skip to content

Commit b1c3cae

Browse files
committed
Add adjust-check-config script to mbedtls importer
In Mbed OS, there are configuration options with Mbed TLS that we are more comfortable allowing than we do with Mbed TLS on its own. Add a check-config adjusting script to enable removing or changing options in check_config.h
1 parent 15b5b5d commit b1c3cae

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
# Purpose
8+
#
9+
# Removes checks from check_config.h that aren't needed for Mbed OS
10+
#
11+
# Usage: adjust-check-config.sh [path to check_config file]
12+
#
13+
set -eu
14+
15+
if [ $# -ne 1 ]; then
16+
echo "Usage: $0 path/to/check_config.h" >&2
17+
exit 1
18+
fi
19+
20+
FILE=$1
21+
22+
conf() {
23+
$SCRIPT -f $FILE --force $@
24+
}
25+
26+
remove_code() {
27+
MATCH_PATTERN=$(IFS=""; printf "%s" "$*")
28+
29+
perl -0pi -e "s/$MATCH_PATTERN//g" "$FILE"
30+
}
31+
32+
remove_code \
33+
"#if defined\(MBEDTLS_PSA_INJECT_ENTROPY\) && \\\\\n" \
34+
" !defined\(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES\)\n" \
35+
"#error \"MBEDTLS_PSA_INJECT_ENTROPY is not compatible with actual entropy sources\"\n" \
36+
"#endif\n" \
37+
"\n"

0 commit comments

Comments
 (0)