|
| 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