blob: 470cd914bdad3db343e243359979e056e3e8c4de [file] [log] [blame]
Gilles Peskine3de7be82020-03-27 16:35:23 +01001#! /usr/bin/env bash
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01002
Simon Butcher3ea7f522016-03-07 23:22:10 +00003# all.sh
4#
Bence Szépkúti1e148272020-08-07 13:07:28 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútic7da1fe2020-05-26 01:54:15 +02006# SPDX-License-Identifier: Apache-2.0
7#
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.
Gilles Peskine192c72f2017-12-21 15:59:21 +010019
20
21
22################################################################
23#### Documentation
24################################################################
25
Simon Butcher3ea7f522016-03-07 23:22:10 +000026# Purpose
Gilles Peskine192c72f2017-12-21 15:59:21 +010027# -------
Simon Butcher3ea7f522016-03-07 23:22:10 +000028#
SimonB2e23c822016-04-16 21:54:39 +010029# To run all tests possible or available on the platform.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +010030#
Gilles Peskine192c72f2017-12-21 15:59:21 +010031# Notes for users
32# ---------------
33#
SimonB2e23c822016-04-16 21:54:39 +010034# Warning: the test is destructive. It includes various build modes and
35# configurations, and can and will arbitrarily change the current CMake
Gilles Peskine192c72f2017-12-21 15:59:21 +010036# configuration. The following files must be committed into git:
37# * include/mbedtls/config.h
Gilles Peskine636c26a2020-03-04 20:46:15 +010038# * Makefile, library/Makefile, programs/Makefile, tests/Makefile,
39# programs/fuzz/Makefile
Gilles Peskine192c72f2017-12-21 15:59:21 +010040# After running this script, the CMake cache will be lost and CMake
41# will no longer be initialised.
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +010042#
Gilles Peskine192c72f2017-12-21 15:59:21 +010043# The script assumes the presence of a number of tools:
44# * Basic Unix tools (Windows users note: a Unix-style find must be before
45# the Windows find in the PATH)
46# * Perl
47# * GNU Make
48# * CMake
49# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
Andrzej Kurek05be06c2018-06-28 04:41:50 -040050# * G++
Gilles Peskine192c72f2017-12-21 15:59:21 +010051# * arm-gcc and mingw-gcc
52# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
Gilles Peskine192c72f2017-12-21 15:59:21 +010053# * OpenSSL and GnuTLS command line tools, recent enough for the
54# interoperability tests. If they don't support SSLv3 then a legacy
55# version of these tools must be present as well (search for LEGACY
56# below).
57# See the invocation of check_tools below for details.
58#
59# This script must be invoked from the toplevel directory of a git
60# working copy of Mbed TLS.
61#
Gilles Peskine7105a332020-03-28 18:50:43 +010062# The behavior on an error depends on whether --keep-going (alias -k)
63# is in effect.
64# * Without --keep-going: the script stops on the first error without
65# cleaning up. This lets you work in the configuration of the failing
66# component.
67# * With --keep-going: the script runs all requested components and
68# reports failures at the end. In particular the script always cleans
69# up on exit.
70#
Gilles Peskine192c72f2017-12-21 15:59:21 +010071# Note that the output is not saved. You may want to run
72# script -c tests/scripts/all.sh
73# or
74# tests/scripts/all.sh >all.log 2>&1
75#
76# Notes for maintainers
77# ---------------------
78#
Gilles Peskine8f073122018-11-27 15:58:47 +010079# The bulk of the code is organized into functions that follow one of the
80# following naming conventions:
81# * pre_XXX: things to do before running the tests, in order.
82# * component_XXX: independent components. They can be run in any order.
Gilles Peskinec70637a2019-01-09 22:29:17 +010083# * component_check_XXX: quick tests that aren't worth parallelizing.
84# * component_build_XXX: build things but don't run them.
85# * component_test_XXX: build and test.
Gilles Peskine878cf602019-01-06 20:50:38 +000086# * support_XXX: if support_XXX exists and returns false then
87# component_XXX is not run by default.
Gilles Peskine8f073122018-11-27 15:58:47 +010088# * post_XXX: things to do after running the tests.
89# * other: miscellaneous support functions.
90#
Gilles Peskinec70637a2019-01-09 22:29:17 +010091# Each component must start by invoking `msg` with a short informative message.
92#
Gilles Peskine39a3b112020-03-28 21:27:40 +010093# Warning: due to the way bash detects errors, the failure of a command
94# inside 'if' or '!' is not detected. Use the 'not' function instead of '!'.
95#
Gilles Peskine7105a332020-03-28 18:50:43 +010096# Each component is executed in a separate shell process. The component
97# fails if any command in it returns a non-zero status.
98#
Gilles Peskinec70637a2019-01-09 22:29:17 +010099# The framework performs some cleanup tasks after each component. This
100# means that components can assume that the working directory is in a
101# cleaned-up state, and don't need to perform the cleanup themselves.
102# * Run `make clean`.
103# * Restore `include/mbedtks/config.h` from a backup made before running
104# the component.
Gilles Peskine636c26a2020-03-04 20:46:15 +0100105# * Check out `Makefile`, `library/Makefile`, `programs/Makefile`,
106# `tests/Makefile` and `programs/fuzz/Makefile` from git.
107# This cleans up after an in-tree use of CMake.
Gilles Peskinec70637a2019-01-09 22:29:17 +0100108#
Gilles Peskine192c72f2017-12-21 15:59:21 +0100109# The tests are roughly in order from fastest to slowest. This doesn't
110# have to be exact, but in general you should add slower tests towards
111# the end and fast checks near the beginning.
Gilles Peskine192c72f2017-12-21 15:59:21 +0100112
113
114
115################################################################
116#### Initialization and command line parsing
117################################################################
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100118
Gilles Peskine8ab29942020-03-28 18:50:49 +0100119# Abort on errors (even on the left-hand side of a pipe).
120# Treat uninitialised variables as errors.
121set -e -o pipefail -u
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100122
Gilles Peskine79598582022-08-30 21:02:44 +0200123# Enable ksh/bash extended file matching patterns
124shopt -s extglob
125
Gilles Peskine8f073122018-11-27 15:58:47 +0100126pre_check_environment () {
Gilles Peskinea16c2b12019-01-06 19:58:02 +0000127 if [ -d library -a -d include -a -d tests ]; then :; else
Gilles Peskine8f073122018-11-27 15:58:47 +0100128 echo "Must be run from mbed TLS root" >&2
129 exit 1
130 fi
131}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100132
Gilles Peskine8f073122018-11-27 15:58:47 +0100133pre_initialize_variables () {
134 CONFIG_H='include/mbedtls/config.h'
John Durkopbd069d32020-10-31 22:14:03 -0700135 CRYPTO_CONFIG_H='include/psa/crypto_config.h'
Gilles Peskine24bdf022020-03-30 20:11:39 +0200136
137 # Files that are clobbered by some jobs will be backed up. Use a different
138 # suffix from auxiliary scripts so that all.sh and auxiliary scripts can
139 # independently decide when to remove the backup file.
140 backup_suffix='.all.bak'
141 # Files clobbered by config.py
142 files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H"
Gilles Peskineef64e7f2021-07-12 18:16:01 +0200143 # Files clobbered by in-tree cmake
144 files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile"
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200145
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200146 append_outcome=0
Gilles Peskine8f073122018-11-27 15:58:47 +0100147 MEMORY=0
148 FORCE=0
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200149 QUIET=0
Gilles Peskine8f073122018-11-27 15:58:47 +0100150 KEEP_GOING=0
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100151
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200152 # Seed value used with the --release-test option.
Manuel Pégourié-Gonnard54304472020-06-22 10:11:47 +0200153 #
154 # See also RELEASE_SEED in basic-build-test.sh. Debugging is easier if
155 # both values are kept in sync. If you change the value here because it
156 # breaks some tests, you'll definitely want to change it in
157 # basic-build-test.sh as well.
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200158 RELEASE_SEED=1
159
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200160 : ${MBEDTLS_TEST_OUTCOME_FILE=}
Gilles Peskine9004a172019-09-16 15:20:36 +0200161 : ${MBEDTLS_TEST_PLATFORM="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200162 export MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine9004a172019-09-16 15:20:36 +0200163 export MBEDTLS_TEST_PLATFORM
164
Jaeden Ameroc4cc2512019-01-30 15:35:44 +0000165 # Default commands, can be overridden by the environment
Gilles Peskine8f073122018-11-27 15:58:47 +0100166 : ${OPENSSL:="openssl"}
167 : ${OPENSSL_LEGACY:="$OPENSSL"}
168 : ${OPENSSL_NEXT:="$OPENSSL"}
169 : ${GNUTLS_CLI:="gnutls-cli"}
170 : ${GNUTLS_SERV:="gnutls-serv"}
171 : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
172 : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
173 : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
174 : ${ARMC5_BIN_DIR:=/usr/bin}
175 : ${ARMC6_BIN_DIR:=/usr/bin}
Gilles Peskine6d061342020-04-30 18:19:32 +0200176 : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200177 : ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}
Gowtham Suresh Kumarcc029af2023-08-01 09:48:32 +0100178 : ${CLANG_LATEST:="clang-latest"}
179 : ${CLANG_EARLIEST:="clang-earliest"}
180 : ${GCC_LATEST:="gcc-latest"}
181 : ${GCC_EARLIEST:="gcc-earliest"}
Andres AGdc192212016-08-31 17:33:13 +0100182
Gilles Peskine8f073122018-11-27 15:58:47 +0100183 # if MAKEFLAGS is not set add the -j option to speed up invocations of make
Gilles Peskinea1fc4b52019-01-06 20:15:26 +0000184 if [ -z "${MAKEFLAGS+set}" ]; then
Gilles Peskine85229ac2021-09-30 18:24:21 +0200185 export MAKEFLAGS="-j$(all_sh_nproc)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100186 fi
Gilles Peskine878cf602019-01-06 20:50:38 +0000187
Gilles Peskinec761d8f2021-09-20 18:57:55 +0200188 # Include more verbose output for failing tests run by CMake or make
Jaeden Amerod48e9c72019-02-07 17:43:39 +0000189 export CTEST_OUTPUT_ON_FAILURE=1
190
Gilles Peskine8fd59422019-10-21 17:11:33 +0200191 # CFLAGS and LDFLAGS for Asan builds that don't use CMake
Manuel Pégourié-Gonnard717f2302022-11-30 10:42:03 +0100192 # default to -O2, use -Ox _after_ this if you want another level
Manuel Pégourié-Gonnard154b84e2022-11-28 13:12:10 +0100193 ASAN_CFLAGS='-O2 -Werror -fsanitize=address,undefined -fno-sanitize-recover=all'
Gilles Peskine8fd59422019-10-21 17:11:33 +0200194
Andrzej Kurekd95b8ed2023-06-27 10:02:09 -0400195 # Platform tests have an allocation that returns null
196 export ASAN_OPTIONS="allocator_may_return_null=1"
Andrzej Kurek6e4a9be2023-07-05 08:32:43 -0400197 export MSAN_OPTIONS="allocator_may_return_null=1"
Andrzej Kurekd95b8ed2023-06-27 10:02:09 -0400198
Gilles Peskine878cf602019-01-06 20:50:38 +0000199 # Gather the list of available components. These are the functions
200 # defined in this script whose name starts with "component_".
Gowtham Suresh Kumar13850f32023-07-28 16:41:21 +0100201 ALL_COMPONENTS=$(compgen -A function component_ | sed 's/component_//')
Gilles Peskine878cf602019-01-06 20:50:38 +0000202
203 # Exclude components that are not supported on this platform.
204 SUPPORTED_COMPONENTS=
205 for component in $ALL_COMPONENTS; do
206 case $(type "support_$component" 2>&1) in
207 *' function'*)
208 if ! support_$component; then continue; fi;;
209 esac
210 SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component"
211 done
Gilles Peskine8f073122018-11-27 15:58:47 +0100212}
Andres AG38495a32016-07-12 16:54:33 +0100213
Gilles Peskinea28db922019-01-10 00:05:18 +0100214# Test whether the component $1 is included in the command line patterns.
215is_component_included()
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100216{
Gilles Peskine6702ce92021-08-06 11:35:17 +0200217 # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS
218 # only does word splitting.
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100219 set -f
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000220 for pattern in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine81b96ed2018-11-27 21:37:53 +0100221 set +f
222 case ${1#component_} in $pattern) return 0;; esac
223 done
224 set +f
225 return 1
226}
Andres AG7770ea82016-10-10 15:46:20 +0100227
Simon Butcher41eeccf2016-09-07 00:07:09 +0100228usage()
Andres AGd9eba4b2016-08-26 14:42:14 +0100229{
Gilles Peskine709346a2017-12-10 23:43:39 +0100230 cat <<EOF
Gilles Peskine92525112018-11-27 18:15:35 +0100231Usage: $0 [OPTION]... [COMPONENT]...
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100232Run mbedtls release validation tests.
Gilles Peskine92525112018-11-27 18:15:35 +0100233By default, run all tests. With one or more COMPONENT, run only those.
Gilles Peskinea28db922019-01-10 00:05:18 +0100234COMPONENT can be the name of a component or a shell wildcard pattern.
235
236Examples:
237 $0 "check_*"
238 Run all sanity checks.
239 $0 --no-armcc --except test_memsan
240 Run everything except builds that require armcc and MemSan.
Gilles Peskine348fb9a2018-11-27 17:04:29 +0100241
242Special options:
243 -h|--help Print this help and exit.
Gilles Peskine878cf602019-01-06 20:50:38 +0000244 --list-all-components List all available test components and exit.
245 --list-components List components supported on this platform and exit.
Gilles Peskine709346a2017-12-10 23:43:39 +0100246
247General options:
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200248 -q|--quiet Only output component names, and errors if any.
Gilles Peskine709346a2017-12-10 23:43:39 +0100249 -f|--force Force the tests to overwrite any modified files.
Gilles Peskine7c652162017-12-11 00:01:40 +0100250 -k|--keep-going Run all tests and report errors at the end.
Gilles Peskine709346a2017-12-10 23:43:39 +0100251 -m|--memory Additional optional memory tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200252 --append-outcome Append to the outcome file (if used).
Gilles Peskine6d061342020-04-30 18:19:32 +0200253 --arm-none-eabi-gcc-prefix=<string>
254 Prefix for a cross-compiler for arm-none-eabi
255 (default: "${ARM_NONE_EABI_GCC_PREFIX}")
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200256 --arm-linux-gnueabi-gcc-prefix=<string>
257 Prefix for a cross-compiler for arm-linux-gnueabi
258 (default: "${ARM_LINUX_GNUEABI_GCC_PREFIX}")
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100259 --armcc Run ARM Compiler builds (on by default).
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200260 --restore First clean up the build tree, restoring backed up
261 files. Do not run any components unless they are
262 explicitly specified.
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100263 --error-test Error test mode: run a failing function in addition
Gilles Peskinea25c5672021-08-05 15:11:33 +0200264 to any specified component. May be repeated.
Gilles Peskinea28db922019-01-10 00:05:18 +0100265 --except Exclude the COMPONENTs listed on the command line,
266 instead of running only those.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200267 --no-append-outcome Write a new outcome file and analyze it (default).
Gilles Peskinebca6ab92017-12-19 18:24:31 +0100268 --no-armcc Skip ARM Compiler builds.
Gilles Peskine38d81652018-03-21 08:40:26 +0100269 --no-force Refuse to overwrite modified files (default).
270 --no-keep-going Stop at the first error (default).
271 --no-memory No additional memory tests (default).
Shaun Case0e7791f2021-12-20 21:14:10 -0800272 --no-quiet Print full output from components.
Gilles Peskine709346a2017-12-10 23:43:39 +0100273 --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200274 --outcome-file=<path> File where test outcomes are written (not done if
275 empty; default: \$MBEDTLS_TEST_OUTCOME_FILE).
Gilles Peskine38d81652018-03-21 08:40:26 +0100276 --random-seed Use a random seed value for randomized tests (default).
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200277 -r|--release-test Run this script in release mode. This fixes the seed value to ${RELEASE_SEED}.
Gilles Peskine709346a2017-12-10 23:43:39 +0100278 -s|--seed Integer seed value to use for this test run.
279
280Tool path options:
281 --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
282 --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100283 --clang-earliest=<Clang_earliest_path> Earliest version of clang available
284 --clang-latest=<Clang_latest_path> Latest version of clang available
285 --gcc-earliest=<GCC_earliest_path> Earliest version of GCC available
286 --gcc-latest=<GCC_latest_path> Latest version of GCC available
Gilles Peskine709346a2017-12-10 23:43:39 +0100287 --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
288 --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
289 --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
290 --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
291 --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
292 --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100293 --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA
Gilles Peskine709346a2017-12-10 23:43:39 +0100294EOF
SimonB2e23c822016-04-16 21:54:39 +0100295}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100296
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200297# Cleanup before/after running a component.
298# Remove built files as well as the cmake cache/config.
299# Does not remove generated source files.
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100300cleanup()
301{
Gilles Peskine7c652162017-12-11 00:01:40 +0100302 command make clean
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200303
Gilles Peskine31b07e22018-03-21 12:15:06 +0100304 # Remove CMake artefacts
Jaeden Amero2d0e00f2018-11-07 18:46:41 +0000305 find . -name .git -prune -o \
Gilles Peskine31b07e22018-03-21 12:15:06 +0100306 -iname CMakeFiles -exec rm -rf {} \+ -o \
307 \( -iname cmake_install.cmake -o \
308 -iname CTestTestfile.cmake -o \
309 -iname CMakeCache.txt \) -exec rm {} \+
310 # Recover files overwritten by in-tree CMake builds
Gilles Peskine79598582022-08-30 21:02:44 +0200311 rm -f include/Makefile include/mbedtls/Makefile programs/!(fuzz)/Makefile
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200312
Jaeden Ameroab83fdf2019-06-20 17:38:22 +0100313 # Remove any artifacts from the component_test_cmake_as_subdirectory test.
314 rm -rf programs/test/cmake_subproject/build
315 rm -f programs/test/cmake_subproject/Makefile
316 rm -f programs/test/cmake_subproject/cmake_subproject
317
Gilles Peskine24bdf022020-03-30 20:11:39 +0200318 # Restore files that may have been clobbered by the job
319 for x in $files_to_back_up; do
Gilles Peskine423dd132022-08-30 21:02:00 +0200320 if [[ -e "$x$backup_suffix" ]]; then
321 cp -p "$x$backup_suffix" "$x"
322 fi
Gilles Peskine24bdf022020-03-30 20:11:39 +0200323 done
324}
John Durkopbd069d32020-10-31 22:14:03 -0700325
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200326# Final cleanup when this script exits (except when exiting on a failure
327# in non-keep-going mode).
Gilles Peskine24bdf022020-03-30 20:11:39 +0200328final_cleanup () {
329 cleanup
330
331 for x in $files_to_back_up; do
332 rm -f "$x$backup_suffix"
333 done
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100334}
335
Gilles Peskine7c652162017-12-11 00:01:40 +0100336# Executed on exit. May be redefined depending on command line options.
337final_report () {
338 :
339}
340
341fatal_signal () {
Gilles Peskine24bdf022020-03-30 20:11:39 +0200342 final_cleanup
Gilles Peskine7c652162017-12-11 00:01:40 +0100343 final_report $1
344 trap - $1
345 kill -$1 $$
346}
347
348trap 'fatal_signal HUP' HUP
349trap 'fatal_signal INT' INT
350trap 'fatal_signal TERM' TERM
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +0200351
Gilles Peskine85229ac2021-09-30 18:24:21 +0200352# Number of processors on this machine. Used as the default setting
353# for parallel make.
354all_sh_nproc ()
355{
356 {
357 nproc || # Linux
358 sysctl -n hw.ncpuonline || # NetBSD, OpenBSD
359 sysctl -n hw.ncpu || # FreeBSD
360 echo 1
361 } 2>/dev/null
362}
363
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100364msg()
365{
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100366 if [ -n "${current_component:-}" ]; then
367 current_section="${current_component#component_}: $1"
368 else
369 current_section="$1"
370 fi
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200371
372 if [ $QUIET -eq 1 ]; then
373 return
374 fi
375
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100376 echo ""
377 echo "******************************************************************"
Gilles Peskineffcdeff2018-12-04 12:49:28 +0100378 echo "* $current_section "
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +0000379 printf "* "; date
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +0100380 echo "******************************************************************"
381}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +0100382
Gilles Peskine8f073122018-11-27 15:58:47 +0100383armc6_build_test()
384{
385 FLAGS="$1"
Andres AGa5cd9732016-10-17 15:23:10 +0100386
Gilles Peskine18487f62020-04-30 23:11:54 +0200387 msg "build: ARM Compiler 6 ($FLAGS)"
Gilles Peskine8f073122018-11-27 15:58:47 +0100388 ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
Dave Rodgman6cda3d32023-03-02 13:39:04 +0000389 WARNING_CFLAGS='-Werror -xc -std=c99' make lib
Gilles Peskine18487f62020-04-30 23:11:54 +0200390
391 msg "size: ARM Compiler 6 ($FLAGS)"
392 "$ARMC6_FROMELF" -z library/*.o
393
Gilles Peskine8f073122018-11-27 15:58:47 +0100394 make clean
395}
Andres AGa5cd9732016-10-17 15:23:10 +0100396
Andres AGd9eba4b2016-08-26 14:42:14 +0100397err_msg()
398{
399 echo "$1" >&2
400}
401
402check_tools()
403{
404 for TOOL in "$@"; do
Andres AG98393602017-01-31 17:04:45 +0000405 if ! `type "$TOOL" >/dev/null 2>&1`; then
Andres AGd9eba4b2016-08-26 14:42:14 +0100406 err_msg "$TOOL not found!"
407 exit 1
408 fi
409 done
410}
411
Gilles Peskine8f073122018-11-27 15:58:47 +0100412pre_parse_command_line () {
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000413 COMMAND_LINE_COMPONENTS=
Gilles Peskinea28db922019-01-10 00:05:18 +0100414 all_except=0
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100415 error_test=0
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200416 restore_first=0
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000417 no_armcc=
SimonB2e23c822016-04-16 21:54:39 +0100418
Jaeden Amero9b90f2e2018-11-02 18:34:17 +0000419 # Note that legacy options are ignored instead of being omitted from this
420 # list of options, so invocations that worked with previous version of
421 # all.sh will still run and work properly.
Gilles Peskine8f073122018-11-27 15:58:47 +0100422 while [ $# -gt 0 ]; do
Gilles Peskine55f7c942019-01-09 22:28:21 +0100423 case "$1" in
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200424 --append-outcome) append_outcome=1;;
Gilles Peskine6d061342020-04-30 18:19:32 +0200425 --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";;
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +0200426 --arm-linux-gnueabi-gcc-prefix) shift; ARM_LINUX_GNUEABI_GCC_PREFIX="$1";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000427 --armcc) no_armcc=;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100428 --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";;
429 --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";;
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100430 --clang-earliest) shift; CLANG_EARLIEST="$1";;
431 --clang-latest) shift; CLANG_LATEST="$1";;
Gilles Peskinea5eb22d2020-03-28 21:09:21 +0100432 --error-test) error_test=$((error_test + 1));;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000433 --except) all_except=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100434 --force|-f) FORCE=1;;
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +0100435 --gcc-earliest) shift; GCC_EARLIEST="$1";;
436 --gcc-latest) shift; GCC_LATEST="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100437 --gnutls-cli) shift; GNUTLS_CLI="$1";;
438 --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";;
439 --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";;
440 --gnutls-serv) shift; GNUTLS_SERV="$1";;
441 --help|-h) usage; exit;;
442 --keep-going|-k) KEEP_GOING=1;;
Gilles Peskine878cf602019-01-06 20:50:38 +0000443 --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;;
444 --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100445 --memory|-m) MEMORY=1;;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200446 --no-append-outcome) append_outcome=0;;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000447 --no-armcc) no_armcc=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100448 --no-force) FORCE=0;;
449 --no-keep-going) KEEP_GOING=0;;
450 --no-memory) MEMORY=0;;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200451 --no-quiet) QUIET=0;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100452 --openssl) shift; OPENSSL="$1";;
453 --openssl-legacy) shift; OPENSSL_LEGACY="$1";;
454 --openssl-next) shift; OPENSSL_NEXT="$1";;
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200455 --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100456 --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200457 --quiet|-q) QUIET=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100458 --random-seed) unset SEED;;
Manuel Pégourié-Gonnarde0501912020-06-08 12:59:27 +0200459 --release-test|-r) SEED=$RELEASE_SEED;;
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200460 --restore) restore_first=1;;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100461 --seed|-s) shift; SEED="$1";;
462 -*)
463 echo >&2 "Unknown option: $1"
464 echo >&2 "Run $0 --help for usage."
465 exit 120
466 ;;
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000467 *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";;
Gilles Peskine55f7c942019-01-09 22:28:21 +0100468 esac
469 shift
Gilles Peskine8f073122018-11-27 15:58:47 +0100470 done
SimonB2e23c822016-04-16 21:54:39 +0100471
Gilles Peskinea28db922019-01-10 00:05:18 +0100472 # With no list of components, run everything.
Gilles Peskine8eb3c952021-08-06 11:51:59 +0200473 if [ -z "$COMMAND_LINE_COMPONENTS" ] && [ $restore_first -eq 0 ]; then
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000474 all_except=1
Andres AGdc192212016-08-31 17:33:13 +0100475 fi
476
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000477 # --no-armcc is a legacy option. The modern way is --except '*_armcc*'.
478 # Ignore it if components are listed explicitly on the command line.
Gilles Peskinea28db922019-01-10 00:05:18 +0100479 if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000480 COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*"
SimonB2e23c822016-04-16 21:54:39 +0100481 fi
SimonB2e23c822016-04-16 21:54:39 +0100482
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200483 # Error out if an explicitly requested component doesn't exist.
Gilles Peskinee8056c52020-03-28 21:37:59 +0100484 if [ $all_except -eq 0 ]; then
485 unsupported=0
Gilles Peskine6702ce92021-08-06 11:35:17 +0200486 # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS
487 # only does word splitting.
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200488 set -f
Gilles Peskinee8056c52020-03-28 21:37:59 +0100489 for component in $COMMAND_LINE_COMPONENTS; do
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200490 set +f
Gilles Peskine4fa948f2021-08-03 13:44:28 +0200491 # If the requested name includes a wildcard character, don't
492 # check it. Accept wildcard patterns that don't match anything.
Gilles Peskinee8056c52020-03-28 21:37:59 +0100493 case $component in
494 *[*?\[]*) continue;;
495 esac
496 case " $SUPPORTED_COMPONENTS " in
497 *" $component "*) :;;
498 *)
499 echo >&2 "Component $component was explicitly requested, but is not known or not supported."
500 unsupported=$((unsupported + 1));;
501 esac
502 done
Gilles Peskine8bfe15f2021-08-03 13:43:36 +0200503 set +f
Gilles Peskinee8056c52020-03-28 21:37:59 +0100504 if [ $unsupported -ne 0 ]; then
505 exit 2
506 fi
507 fi
508
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000509 # Build the list of components to run.
Gilles Peskinea28db922019-01-10 00:05:18 +0100510 RUN_COMPONENTS=
511 for component in $SUPPORTED_COMPONENTS; do
512 if is_component_included "$component"; [ $? -eq $all_except ]; then
513 RUN_COMPONENTS="$RUN_COMPONENTS $component"
514 fi
515 done
Gilles Peskinebeb3a812019-01-06 22:11:25 +0000516
517 unset all_except
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000518 unset no_armcc
Gilles Peskine8f073122018-11-27 15:58:47 +0100519}
SimonB2e23c822016-04-16 21:54:39 +0100520
Gilles Peskine8f073122018-11-27 15:58:47 +0100521pre_check_git () {
522 if [ $FORCE -eq 1 ]; then
Gilles Peskine53190e62019-01-09 23:17:35 +0100523 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +0100524 git checkout-index -f -q $CONFIG_H
525 cleanup
526 else
SimonB2e23c822016-04-16 21:54:39 +0100527
Gilles Peskine8f073122018-11-27 15:58:47 +0100528 if [ -d "$OUT_OF_SOURCE_DIR" ]; then
529 echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2
530 echo "You can either delete this directory manually, or force the test by rerunning"
531 echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR"
532 exit 1
533 fi
534
Gilles Peskined1174cf2019-01-09 22:30:01 +0100535 if ! git diff --quiet include/mbedtls/config.h; then
Gilles Peskine8f073122018-11-27 15:58:47 +0100536 err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
537 echo "You can either delete or preserve your work, or force the test by rerunning the"
538 echo "script as: $0 --force"
539 exit 1
540 fi
SimonB2e23c822016-04-16 21:54:39 +0100541 fi
Andrzej Kurekeb508712019-02-14 07:18:59 -0500542}
543
Gilles Peskineef64e7f2021-07-12 18:16:01 +0200544pre_restore_files () {
545 # If the makefiles have been generated by a framework such as cmake,
546 # restore them from git. If the makefiles look like modifications from
547 # the ones checked into git, take care not to modify them. Whatever
548 # this function leaves behind is what the script will restore before
549 # each component.
550 case "$(head -n1 Makefile)" in
551 *[Gg]enerated*)
552 git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
553 git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile
554 ;;
555 esac
556}
557
Gilles Peskine24bdf022020-03-30 20:11:39 +0200558pre_back_up () {
559 for x in $files_to_back_up; do
560 cp -p "$x" "$x$backup_suffix"
561 done
562}
563
Gilles Peskine8f073122018-11-27 15:58:47 +0100564pre_setup_keep_going () {
Gilles Peskine7105a332020-03-28 18:50:43 +0100565 failure_count=0 # Number of failed components
566 last_failure_status=0 # Last failure status in this component
567
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100568 # See err_trap
569 previous_failure_status=0
570 previous_failed_command=
571 previous_failure_funcall_depth=0
Gilles Peskine39a3b112020-03-28 21:27:40 +0100572 unset report_failed_command
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100573
Gilles Peskine7c652162017-12-11 00:01:40 +0100574 start_red=
575 end_color=
576 if [ -t 1 ]; then
Gilles Peskine9736b9d2018-01-02 21:54:17 +0100577 case "${TERM:-}" in
Gilles Peskine7c652162017-12-11 00:01:40 +0100578 *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
579 start_red=$(printf '\033[31m')
580 end_color=$(printf '\033[0m')
581 ;;
582 esac
583 fi
Gilles Peskine7105a332020-03-28 18:50:43 +0100584
585 # Keep a summary of failures in a file. We'll print it out at the end.
586 failure_summary_file=$PWD/all-sh-failures-$$.log
587 : >"$failure_summary_file"
588
589 # Whether it makes sense to keep a component going after the specified
590 # command fails (test command) or not (configure or build).
Gilles Peskine6702ce92021-08-06 11:35:17 +0200591 # This function normally receives the failing simple command
592 # ($BASH_COMMAND) as an argument, but if $report_failed_command is set,
593 # this is passed instead.
Gilles Peskine7105a332020-03-28 18:50:43 +0100594 # This doesn't have to be 100% accurate: all failures are recorded anyway.
Gilles Peskine76d40fa2021-08-02 23:29:53 +0200595 # False positives result in running things that can't be expected to
596 # work. False negatives result in things not running after something else
597 # failed even though they might have given useful feedback.
Gilles Peskine7105a332020-03-28 18:50:43 +0100598 can_keep_going_after_failure () {
599 case "$1" in
600 "msg "*) false;;
Gilles Peskine76d40fa2021-08-02 23:29:53 +0200601 "cd "*) false;;
602 *make*[\ /]tests*) false;; # make tests, make CFLAGS=-I../tests, ...
603 *test*) true;; # make test, tests/stuff, env V=v tests/stuff, ...
604 *make*check*) true;;
605 "grep "*) true;;
606 "[ "*) true;;
607 "! "*) true;;
Gilles Peskine7105a332020-03-28 18:50:43 +0100608 *) false;;
Gilles Peskine7c652162017-12-11 00:01:40 +0100609 esac
610 }
Gilles Peskine7105a332020-03-28 18:50:43 +0100611
612 # This function runs if there is any error in a component.
613 # It must either exit with a nonzero status, or set
614 # last_failure_status to a nonzero value.
615 err_trap () {
616 # Save $? (status of the failing command). This must be the very
617 # first thing, before $? is overridden.
618 last_failure_status=$?
Gilles Peskine39a3b112020-03-28 21:27:40 +0100619 failed_command=${report_failed_command-$BASH_COMMAND}
Gilles Peskine7105a332020-03-28 18:50:43 +0100620
Gilles Peskine4848d7b2020-03-28 19:34:23 +0100621 if [[ $last_failure_status -eq $previous_failure_status &&
622 "$failed_command" == "$previous_failed_command" &&
623 ${#FUNCNAME[@]} == $((previous_failure_funcall_depth - 1)) ]]
624 then
625 # The same command failed twice in a row, but this time one level
626 # less deep in the function call stack. This happens when the last
627 # command of a function returns a nonzero status, and the function
628 # returns that same status. Ignore the second failure.
629 previous_failure_funcall_depth=${#FUNCNAME[@]}
630 return
631 fi
632 previous_failure_status=$last_failure_status
633 previous_failed_command=$failed_command
634 previous_failure_funcall_depth=${#FUNCNAME[@]}
635
Gilles Peskine7105a332020-03-28 18:50:43 +0100636 text="$current_section: $failed_command -> $last_failure_status"
637 echo "${start_red}^^^^$text^^^^${end_color}" >&2
638 echo "$text" >>"$failure_summary_file"
639
640 # If the command is fatal (configure or build command), stop this
641 # component. Otherwise (test command) keep the component running
642 # (run more tests from the same build).
643 if ! can_keep_going_after_failure "$failed_command"; then
644 exit $last_failure_status
645 fi
646 }
647
Gilles Peskine7c652162017-12-11 00:01:40 +0100648 final_report () {
649 if [ $failure_count -gt 0 ]; then
650 echo
651 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
Gilles Peskine7105a332020-03-28 18:50:43 +0100652 echo "${start_red}FAILED: $failure_count components${end_color}"
653 cat "$failure_summary_file"
Gilles Peskine7c652162017-12-11 00:01:40 +0100654 echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
655 elif [ -z "${1-}" ]; then
656 echo "SUCCESS :)"
657 fi
658 if [ -n "${1-}" ]; then
659 echo "Killed by SIG$1."
660 fi
Gilles Peskine7105a332020-03-28 18:50:43 +0100661 rm -f "$failure_summary_file"
662 if [ $failure_count -gt 0 ]; then
663 exit 1
664 fi
Gilles Peskine7c652162017-12-11 00:01:40 +0100665 }
Gilles Peskine8f073122018-11-27 15:58:47 +0100666}
667
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200668# record_status() and if_build_succeeded() are kept temporarily for backward
669# compatibility. Don't use them in new components.
Gilles Peskine7105a332020-03-28 18:50:43 +0100670record_status () {
671 "$@"
Gilles Peskine7c652162017-12-11 00:01:40 +0100672}
Gilles Peskine7c652162017-12-11 00:01:40 +0100673if_build_succeeded () {
Gilles Peskine7105a332020-03-28 18:50:43 +0100674 "$@"
Gilles Peskine7c652162017-12-11 00:01:40 +0100675}
676
Gilles Peskine39a3b112020-03-28 21:27:40 +0100677# '! true' does not trigger the ERR trap. Arrange to trigger it, with
678# a reasonably informative error message (not just "$@").
679not () {
680 if "$@"; then
681 report_failed_command="! $*"
682 false
683 unset report_failed_command
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200684 fi
685}
686
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200687pre_prepare_outcome_file () {
688 case "$MBEDTLS_TEST_OUTCOME_FILE" in
689 [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";;
690 esac
691 if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then
692 rm -f "$MBEDTLS_TEST_OUTCOME_FILE"
693 fi
694}
695
Gilles Peskine8f073122018-11-27 15:58:47 +0100696pre_print_configuration () {
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200697 if [ $QUIET -eq 1 ]; then
698 return
699 fi
700
Gilles Peskine8f073122018-11-27 15:58:47 +0100701 msg "info: $0 configuration"
702 echo "MEMORY: $MEMORY"
703 echo "FORCE: $FORCE"
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200704 echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}"
Gilles Peskine8f073122018-11-27 15:58:47 +0100705 echo "SEED: ${SEED-"UNSET"}"
Gilles Peskine636c26a2020-03-04 20:46:15 +0100706 echo
Gilles Peskine8f073122018-11-27 15:58:47 +0100707 echo "OPENSSL: $OPENSSL"
708 echo "OPENSSL_LEGACY: $OPENSSL_LEGACY"
709 echo "OPENSSL_NEXT: $OPENSSL_NEXT"
710 echo "GNUTLS_CLI: $GNUTLS_CLI"
711 echo "GNUTLS_SERV: $GNUTLS_SERV"
712 echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
713 echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
714 echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
715 echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
716}
Andres AG7770ea82016-10-10 15:46:20 +0100717
Andres AGd9eba4b2016-08-26 14:42:14 +0100718# Make sure the tools we need are available.
Gilles Peskine8f073122018-11-27 15:58:47 +0100719pre_check_tools () {
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000720 # Build the list of variables to pass to output_env.sh.
721 set env
SimonB2e23c822016-04-16 21:54:39 +0100722
Gilles Peskine87964262019-01-06 22:40:00 +0000723 case " $RUN_COMPONENTS " in
724 # Require OpenSSL and GnuTLS if running any tests (as opposed to
725 # only doing builds). Not all tests run OpenSSL and GnuTLS, but this
726 # is a good enough approximation in practice.
727 *" test_"*)
728 # To avoid setting OpenSSL and GnuTLS for each call to compat.sh
729 # and ssl-opt.sh, we just export the variables they require.
Manuel Pégourié-Gonnard89d40272022-12-19 11:42:12 +0100730 export OPENSSL="$OPENSSL"
Gilles Peskine87964262019-01-06 22:40:00 +0000731 export GNUTLS_CLI="$GNUTLS_CLI"
732 export GNUTLS_SERV="$GNUTLS_SERV"
733 # Avoid passing --seed flag in every call to ssl-opt.sh
734 if [ -n "${SEED-}" ]; then
735 export SEED
736 fi
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000737 set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY"
738 set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV"
739 set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI"
740 set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV"
Gilles Peskine87964262019-01-06 22:40:00 +0000741 check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \
742 "$GNUTLS_CLI" "$GNUTLS_SERV" \
743 "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV"
744 ;;
745 esac
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200746
Gilles Peskine87964262019-01-06 22:40:00 +0000747 case " $RUN_COMPONENTS " in
748 *_doxygen[_\ ]*) check_tools "doxygen" "dot";;
749 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100750
Gilles Peskine87964262019-01-06 22:40:00 +0000751 case " $RUN_COMPONENTS " in
Gilles Peskine6d061342020-04-30 18:19:32 +0200752 *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";;
Gilles Peskine87964262019-01-06 22:40:00 +0000753 esac
Andres AGd9eba4b2016-08-26 14:42:14 +0100754
Gilles Peskine87964262019-01-06 22:40:00 +0000755 case " $RUN_COMPONENTS " in
756 *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";;
757 esac
758
759 case " $RUN_COMPONENTS " in
760 *" test_zeroize "*) check_tools "gdb";;
761 esac
762
763 case " $RUN_COMPONENTS " in
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000764 *_armcc*)
Gilles Peskine87964262019-01-06 22:40:00 +0000765 ARMC5_CC="$ARMC5_BIN_DIR/armcc"
766 ARMC5_AR="$ARMC5_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200767 ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf"
Gilles Peskine87964262019-01-06 22:40:00 +0000768 ARMC6_CC="$ARMC6_BIN_DIR/armclang"
769 ARMC6_AR="$ARMC6_BIN_DIR/armar"
Gilles Peskine18487f62020-04-30 23:11:54 +0200770 ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf"
771 check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \
772 "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";;
Gilles Peskine5331c6e2019-01-06 22:23:42 +0000773 esac
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000774
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +0200775 # past this point, no call to check_tool, only printing output
776 if [ $QUIET -eq 1 ]; then
777 return
778 fi
779
Gilles Peskinecc9f0b92019-01-06 22:46:21 +0000780 msg "info: output_env.sh"
781 case $RUN_COMPONENTS in
782 *_armcc*)
783 set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;;
784 *) set "$@" RUN_ARMCC=0;;
785 esac
786 "$@" scripts/output_env.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100787}
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100788
Gilles Peskine192c72f2017-12-21 15:59:21 +0100789
790
791################################################################
792#### Basic checks
793################################################################
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +0100794
795#
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200796# Test Suites to be executed
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100797#
Manuel Pégourié-Gonnard3d404b42015-07-08 21:59:16 +0100798# The test ordering tries to optimize for the following criteria:
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200799# 1. Catch possible problems early, by running first tests that run quickly
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100800# and/or are more likely to fail than others (eg I use Clang most of the
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200801# time, so start with a GCC build).
802# 2. Minimize total running time, by avoiding useless rebuilds
Manuel Pégourié-Gonnard89d69b32014-11-20 13:48:53 +0100803#
Manuel Pégourié-Gonnard259b08a2016-01-08 16:27:41 +0100804# Indicative running times are given for reference.
805
Gilles Peskine8f073122018-11-27 15:58:47 +0100806component_check_recursion () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200807 msg "Check: recursion.pl" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200808 tests/scripts/recursion.pl library/*.c
Gilles Peskine8f073122018-11-27 15:58:47 +0100809}
Janos Follathb72c6782016-07-19 14:54:17 +0100810
Gilles Peskine8f073122018-11-27 15:58:47 +0100811component_check_generated_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200812 msg "Check: freshness of generated source files" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200813 tests/scripts/check-generated-files.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100814}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200815
Gilles Peskine8f073122018-11-27 15:58:47 +0100816component_check_doxy_blocks () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200817 msg "Check: doxygen markup outside doxygen blocks" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200818 tests/scripts/check-doxy-blocks.pl
Gilles Peskine8f073122018-11-27 15:58:47 +0100819}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200820
Gilles Peskine8f073122018-11-27 15:58:47 +0100821component_check_files () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200822 msg "Check: file sanity checks (permissions, encodings)" # < 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200823 tests/scripts/check_files.py
Gilles Peskine8f073122018-11-27 15:58:47 +0100824}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200825
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200826component_check_changelog () {
827 msg "Check: changelog entries" # < 1s
828 rm -f ChangeLog.new
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200829 scripts/assemble_changelog.py -o ChangeLog.new
Gilles Peskine30e0bb42020-05-10 17:40:49 +0200830 if [ -e ChangeLog.new ]; then
831 # Show the diff for information. It isn't an error if the diff is
832 # non-empty.
833 diff -u ChangeLog ChangeLog.new || true
834 rm ChangeLog.new
835 fi
836}
837
Gilles Peskine8f073122018-11-27 15:58:47 +0100838component_check_names () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200839 msg "Check: declared and exported names (builds the library)" # < 3s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200840 tests/scripts/check_names.py -v
Gilles Peskine8f073122018-11-27 15:58:47 +0100841}
Darryl Greena07039c2018-03-13 16:48:16 +0000842
Gilles Peskine895868b2019-09-19 21:30:05 +0200843component_check_test_cases () {
844 msg "Check: test case descriptions" # < 1s
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200845 if [ $QUIET -eq 1 ]; then
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200846 opt='--quiet'
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200847 else
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200848 opt=''
Manuel Pégourié-Gonnarda9119162020-06-02 11:51:40 +0200849 fi
Gilles Peskine58987962022-12-15 14:46:31 +0100850 tests/scripts/check_test_cases.py -q $opt
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +0200851 unset opt
Gilles Peskine895868b2019-09-19 21:30:05 +0200852}
853
Gilles Peskine8f073122018-11-27 15:58:47 +0100854component_check_doxygen_warnings () {
Gilles Peskine600bb692019-09-19 21:29:11 +0200855 msg "Check: doxygen warnings (builds the documentation)" # ~ 3s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200856 tests/scripts/doxygen.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100857}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200858
Gilles Peskine192c72f2017-12-21 15:59:21 +0100859
Gilles Peskine636c26a2020-03-04 20:46:15 +0100860
Gilles Peskine192c72f2017-12-21 15:59:21 +0100861################################################################
862#### Build and test many configurations and targets
863################################################################
864
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200865component_test_default_out_of_box () {
866 msg "build: make, default config (out-of-box)" # ~1min
867 make
Gilles Peskine67ffdaf2019-09-16 15:55:46 +0200868 # Disable fancy stuff
869 unset MBEDTLS_TEST_OUTCOME_FILE
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200870
871 msg "test: main suites make, default config (out-of-box)" # ~10s
872 make test
873
874 msg "selftest: make, default config (out-of-box)" # ~10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200875 programs/test/selftest
Gilles Peskine7832c9f2019-04-08 17:00:15 +0200876}
877
Gilles Peskine8f073122018-11-27 15:58:47 +0100878component_test_default_cmake_gcc_asan () {
879 msg "build: cmake, gcc, ASan" # ~ 1 min 50s
Gilles Peskine8f073122018-11-27 15:58:47 +0100880 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
881 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200882
Gilles Peskine8f073122018-11-27 15:58:47 +0100883 msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s
884 make test
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200885
Gilles Peskine97bea012020-04-23 23:37:45 +0200886 msg "test: selftest (ASan build)" # ~ 10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200887 programs/test/selftest
Gilles Peskine97bea012020-04-23 23:37:45 +0200888
Gilles Peskine8f073122018-11-27 15:58:47 +0100889 msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200890 tests/ssl-opt.sh
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200891
Gilles Peskine8f073122018-11-27 15:58:47 +0100892 msg "test: compat.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200893 tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200894
895 msg "test: context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200896 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +0100897}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +0200898
Hanno Becker01635512019-02-26 14:27:09 +0000899component_test_full_cmake_gcc_asan () {
900 msg "build: full config, cmake, gcc, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +0200901 scripts/config.py full
Hanno Becker01635512019-02-26 14:27:09 +0000902 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
903 make
904
905 msg "test: main suites (inc. selftests) (full config, ASan build)"
906 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +0100907
Gilles Peskine97bea012020-04-23 23:37:45 +0200908 msg "test: selftest (ASan build)" # ~ 10s
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200909 programs/test/selftest
Gilles Peskine97bea012020-04-23 23:37:45 +0200910
Gilles Peskine636c26a2020-03-04 20:46:15 +0100911 msg "test: ssl-opt.sh (full config, ASan build)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200912 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +0100913
914 msg "test: compat.sh (full config, ASan build)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200915 tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +0200916
917 msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200918 tests/context-info.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +0100919}
920
Ronald Cronc3623db2020-10-29 10:51:32 +0100921component_test_psa_crypto_key_id_encodes_owner () {
922 msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
923 scripts/config.py full
924 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
925 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
926 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
927 make
928
929 msg "test: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
930 make test
931}
932
Gilles Peskine99a34622021-06-17 11:37:52 +0200933# check_renamed_symbols HEADER LIB
934# Check that if HEADER contains '#define MACRO ...' then MACRO is not a symbol
935# name is LIB.
936check_renamed_symbols () {
937 ! nm "$2" | sed 's/.* //' |
938 grep -x -F "$(sed -n 's/^ *# *define *\([A-Z_a-z][0-9A-Z_a-z]*\)..*/\1/p' "$1")"
939}
940
Gilles Peskine984c19f2021-06-15 18:37:38 +0200941component_build_psa_crypto_spm () {
942 msg "build: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER + PSA_CRYPTO_SPM, make, gcc"
943 scripts/config.py full
944 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
945 scripts/config.py unset MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
946 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
947 scripts/config.py set MBEDTLS_PSA_CRYPTO_SPM
948 # We can only compile, not link, since our test and sample programs
949 # aren't equipped for the modified names used when MBEDTLS_PSA_CRYPTO_SPM
950 # is active.
951 make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' lib
Gilles Peskine99a34622021-06-17 11:37:52 +0200952
953 # Check that if a symbol is renamed by crypto_spe.h, the non-renamed
954 # version is not present.
955 echo "Checking for renamed symbols in the library"
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200956 check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a
Gilles Peskine984c19f2021-06-15 18:37:38 +0200957}
958
Ronald Cron336678b2021-01-28 17:54:24 +0100959component_test_psa_crypto_client () {
960 msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make"
961 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
962 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
963 scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT
964 make
965
966 msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make"
967 make test
968}
969
Gilles Peskine636c26a2020-03-04 20:46:15 +0100970component_test_zlib_make() {
971 msg "build: zlib enabled, make"
972 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
Gilles Peskine6fa69862021-10-05 09:36:03 +0200973 make ZLIB=1 CFLAGS='-Werror -O2'
Gilles Peskine636c26a2020-03-04 20:46:15 +0100974
975 msg "test: main suites (zlib, make)"
976 make test
977
978 msg "test: ssl-opt.sh (zlib, make)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +0200979 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +0100980}
981support_test_zlib_make () {
982 base=support_test_zlib_$$
983 cat <<'EOF' > ${base}.c
984#include "zlib.h"
985int main(void) { return 0; }
986EOF
987 gcc -o ${base}.exe ${base}.c -lz 2>/dev/null
988 ret=$?
989 rm -f ${base}.*
990 return $ret
991}
992
993component_test_zlib_cmake() {
994 msg "build: zlib enabled, cmake"
995 scripts/config.py set MBEDTLS_ZLIB_SUPPORT
Gilles Peskine25319702021-10-07 19:34:57 +0200996 cmake -D ENABLE_ZLIB_SUPPORT=On -D CMAKE_BUILD_TYPE:String=Release .
Gilles Peskine636c26a2020-03-04 20:46:15 +0100997 make
998
999 msg "test: main suites (zlib, cmake)"
1000 make test
1001
1002 msg "test: ssl-opt.sh (zlib, cmake)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001003 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001004}
1005support_test_zlib_cmake () {
1006 support_test_zlib_make "$@"
Manuel Pégourié-Gonnardf2e29022020-01-24 10:17:20 +01001007}
Manuel Pégourié-Gonnard95e04492020-01-02 11:45:12 +01001008
Jaeden Ameroc17f2932021-05-14 08:34:32 +01001009component_test_psa_crypto_rsa_no_genprime() {
1010 msg "build: default config minus MBEDTLS_GENPRIME"
1011 scripts/config.py unset MBEDTLS_GENPRIME
1012 make
1013
1014 msg "test: default config minus MBEDTLS_GENPRIME"
1015 make test
1016}
1017
Gilles Peskine782f4112018-11-27 16:11:09 +01001018component_test_ref_configs () {
1019 msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
1020 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001021 tests/scripts/test-ref-configs.pl
Gilles Peskine782f4112018-11-27 16:11:09 +01001022}
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +02001023
Gilles Peskine8f073122018-11-27 15:58:47 +01001024component_test_sslv3 () {
1025 msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001026 scripts/config.py set MBEDTLS_SSL_PROTO_SSL3
Gilles Peskine8f073122018-11-27 15:58:47 +01001027 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1028 make
Manuel Pégourié-Gonnard57255b12014-06-09 11:21:49 +02001029
Gilles Peskine8f073122018-11-27 15:58:47 +01001030 msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s
1031 make test
Simon Butcher3ea7f522016-03-07 23:22:10 +00001032
Gilles Peskine8f073122018-11-27 15:58:47 +01001033 msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
Xiaofei Baif40545d2021-12-02 08:43:35 +00001034 tests/compat.sh -m 'tls1 tls1_1 tls12 dtls1 dtls12'
Manuel Pégourié-Gonnard89d40272022-12-19 11:42:12 +01001035 env OPENSSL="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
Simon Butcher3ea7f522016-03-07 23:22:10 +00001036
Gilles Peskine8f073122018-11-27 15:58:47 +01001037 msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001038 tests/ssl-opt.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001039
1040 msg "build: SSLv3 - context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001041 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001042}
Simon Butcher3ea7f522016-03-07 23:22:10 +00001043
Gilles Peskine8f073122018-11-27 15:58:47 +01001044component_test_no_renegotiation () {
1045 msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001046 scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION
Gilles Peskine8f073122018-11-27 15:58:47 +01001047 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1048 make
Simon Butcher3ea7f522016-03-07 23:22:10 +00001049
Gilles Peskine8f073122018-11-27 15:58:47 +01001050 msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
1051 make test
Hanno Becker134c2ab2017-10-12 15:29:50 +01001052
Gilles Peskine8f073122018-11-27 15:58:47 +01001053 msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001054 tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001055}
Hanno Becker134c2ab2017-10-12 15:29:50 +01001056
Gilles Peskine56194432023-02-01 18:44:11 +01001057component_test_no_certs () {
1058 msg "build: full minus MBEDTLS_CERTS_C"
1059 scripts/config.py full
1060 scripts/config.py unset MBEDTLS_CERTS_C
1061 # Quick build+test (we're checking for stray uses of the test certs,
1062 # not expecting their absence to lead to subtle problems).
1063 make
1064
1065 msg "test: full minus MBEDTLS_CERTS_C - main suites"
1066 make test
1067}
1068
Gilles Peskine636c26a2020-03-04 20:46:15 +01001069component_test_no_pem_no_fs () {
1070 msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)"
1071 scripts/config.py unset MBEDTLS_PEM_PARSE_C
1072 scripts/config.py unset MBEDTLS_FS_IO
1073 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem
1074 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS
1075 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1076 make
1077
1078 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s
1079 make test
1080
1081 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001082 tests/ssl-opt.sh
Gilles Peskine636c26a2020-03-04 20:46:15 +01001083}
1084
Gilles Peskine8f073122018-11-27 15:58:47 +01001085component_test_rsa_no_crt () {
1086 msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001087 scripts/config.py set MBEDTLS_RSA_NO_CRT
Gilles Peskine8f073122018-11-27 15:58:47 +01001088 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1089 make
Manuel Pégourié-Gonnard246978d2014-11-20 13:29:53 +01001090
Gilles Peskine8f073122018-11-27 15:58:47 +01001091 msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
1092 make test
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001093
Gilles Peskine8f073122018-11-27 15:58:47 +01001094 msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001095 tests/ssl-opt.sh -f RSA
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001096
Gilles Peskine8f073122018-11-27 15:58:47 +01001097 msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001098 tests/compat.sh -t RSA
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02001099
1100 msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001101 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01001102}
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001103
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001104component_test_no_ctr_drbg_classic () {
1105 msg "build: Full minus CTR_DRBG, classic crypto in TLS"
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001106 scripts/config.py full
1107 scripts/config.py unset MBEDTLS_CTR_DRBG_C
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001108 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001109
1110 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1111 make
1112
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001113 msg "test: Full minus CTR_DRBG, classic crypto - main suites"
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001114 make test
1115
Gilles Peskineba749042021-01-13 20:02:03 +01001116 # In this configuration, the TLS test programs use HMAC_DRBG.
1117 # The SSL tests are slow, so run a small subset, just enough to get
1118 # confidence that the SSL code copes with HMAC_DRBG.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001119 msg "test: Full minus CTR_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001120 tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
Gilles Peskineba749042021-01-13 20:02:03 +01001121
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001122 msg "test: Full minus CTR_DRBG, classic crypto - compat.sh (subset)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001123 tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001124}
1125
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001126component_test_no_ctr_drbg_use_psa () {
1127 msg "build: Full minus CTR_DRBG, PSA crypto in TLS"
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001128 scripts/config.py full
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001129 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1130 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001131
1132 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1133 make
1134
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001135 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - main suites"
1136 make test
1137
1138 # In this configuration, the TLS test programs use HMAC_DRBG.
1139 # The SSL tests are slow, so run a small subset, just enough to get
1140 # confidence that the SSL code copes with HMAC_DRBG.
1141 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001142 tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001143
1144 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - compat.sh (subset)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001145 tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001146}
1147
1148component_test_no_hmac_drbg_classic () {
1149 msg "build: Full minus HMAC_DRBG, classic crypto in TLS"
1150 scripts/config.py full
1151 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1152 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1153 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1154
1155 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1156 make
1157
1158 msg "test: Full minus HMAC_DRBG, classic crypto - main suites"
Manuel Pégourié-Gonnard5b942dc2020-06-05 09:29:51 +02001159 make test
1160
Gilles Peskinea2224342020-11-19 22:14:34 +01001161 # Normally our ECDSA implementation uses deterministic ECDSA. But since
1162 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
1163 # instead.
1164 # Test SSL with non-deterministic ECDSA. Only test features that
1165 # might be affected by how ECDSA signature is performed.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001166 msg "test: Full minus HMAC_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001167 tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
Gilles Peskinea2224342020-11-19 22:14:34 +01001168
1169 # To save time, only test one protocol version, since this part of
1170 # the protocol is identical in (D)TLS up to 1.2.
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001171 msg "test: Full minus HMAC_DRBG, classic crypto - compat.sh (ECDSA)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001172 tests/compat.sh -m tls12 -t 'ECDSA'
Manuel Pégourié-Gonnard817e3682020-05-28 12:55:10 +02001173}
1174
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001175component_test_no_hmac_drbg_use_psa () {
1176 msg "build: Full minus HMAC_DRBG, PSA crypto in TLS"
1177 scripts/config.py full
1178 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1179 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1180 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1181
1182 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1183 make
1184
1185 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - main suites"
1186 make test
1187
1188 # Normally our ECDSA implementation uses deterministic ECDSA. But since
1189 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
1190 # instead.
1191 # Test SSL with non-deterministic ECDSA. Only test features that
1192 # might be affected by how ECDSA signature is performed.
1193 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001194 tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001195
1196 # To save time, only test one protocol version, since this part of
1197 # the protocol is identical in (D)TLS up to 1.2.
1198 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - compat.sh (ECDSA)"
Xiaofei Baif40545d2021-12-02 08:43:35 +00001199 tests/compat.sh -m tls12 -t 'ECDSA'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001200}
1201
1202component_test_psa_external_rng_no_drbg_classic () {
1203 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto in TLS"
1204 scripts/config.py full
1205 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1206 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Gilles Peskine38c12fd2021-02-08 21:02:53 +01001207 scripts/config.py unset MBEDTLS_ENTROPY_C
1208 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1209 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001210 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1211 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1212 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1213 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
Gilles Peskine8eb29432021-02-03 20:07:11 +01001214 # When MBEDTLS_USE_PSA_CRYPTO is disabled and there is no DRBG,
1215 # the SSL test programs don't have an RNG and can't work. Explicitly
1216 # make them use the PSA RNG with -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG.
1217 make CFLAGS="$ASAN_CFLAGS -O2 -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001218
1219 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - main suites"
1220 make test
1221
Gilles Peskine8eb29432021-02-03 20:07:11 +01001222 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001223 tests/ssl-opt.sh -f 'Default'
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001224}
1225
1226component_test_psa_external_rng_no_drbg_use_psa () {
1227 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto in TLS"
Gilles Peskinec109b372020-11-23 17:39:04 +01001228 scripts/config.py full
1229 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
Gilles Peskine38c12fd2021-02-08 21:02:53 +01001230 scripts/config.py unset MBEDTLS_ENTROPY_C
1231 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
1232 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskinec109b372020-11-23 17:39:04 +01001233 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1234 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1235 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1236 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1237 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1238
Gilles Peskine2747d7d2021-02-03 14:56:51 +01001239 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - main suites"
Gilles Peskinec109b372020-11-23 17:39:04 +01001240 make test
1241
Gilles Peskine8eb29432021-02-03 20:07:11 +01001242 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - ssl-opt.sh (subset)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001243 tests/ssl-opt.sh -f 'Default\|opaque'
Gilles Peskinec109b372020-11-23 17:39:04 +01001244}
1245
1246component_test_psa_external_rng_use_psa_crypto () {
1247 msg "build: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1248 scripts/config.py full
1249 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
1250 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1251 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1252 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1253
1254 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
1255 make test
1256
Gilles Peskineba749042021-01-13 20:02:03 +01001257 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001258 tests/ssl-opt.sh -f 'Default\|opaque'
Gilles Peskinec109b372020-11-23 17:39:04 +01001259}
1260
Gilles Peskine55e89982023-04-28 21:04:28 +02001261component_test_psa_inject_entropy () {
1262 msg "build: full + MBEDTLS_PSA_INJECT_ENTROPY"
1263 scripts/config.py full
1264 scripts/config.py set MBEDTLS_PSA_INJECT_ENTROPY
1265 scripts/config.py set MBEDTLS_ENTROPY_NV_SEED
1266 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
1267 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
1268 scripts/config.py unset MBEDTLS_PLATFORM_STD_NV_SEED_READ
1269 scripts/config.py unset MBEDTLS_PLATFORM_STD_NV_SEED_WRITE
1270 make CFLAGS="$ASAN_CFLAGS '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" LDFLAGS="$ASAN_CFLAGS"
1271
1272 msg "test: full + MBEDTLS_PSA_INJECT_ENTROPY"
1273 make test
1274}
1275
Manuel Pégourié-Gonnard1a3f9ed2020-05-19 12:38:31 +02001276component_test_ecp_no_internal_rng () {
1277 msg "build: Default plus ECP_NO_INTERNAL_RNG minus DRBG modules"
1278 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1279 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1280 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1281 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1282 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires a DRBG
1283 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
1284
1285 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1286 make
1287
1288 msg "test: ECP_NO_INTERNAL_RNG, no DRBG module"
1289 make test
1290
1291 # no SSL tests as they all depend on having a DRBG
1292}
1293
Manuel Pégourié-Gonnard53fb66d2020-06-04 09:43:14 +02001294component_test_ecp_restartable_no_internal_rng () {
1295 msg "build: Default plus ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG"
1296 scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
1297 scripts/config.py set MBEDTLS_ECP_RESTARTABLE
1298 scripts/config.py unset MBEDTLS_CTR_DRBG_C
1299 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
1300 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
1301 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG
1302 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
1303
1304 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1305 make
1306
1307 msg "test: ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG module"
1308 make test
1309
1310 # no SSL tests as they all depend on having a DRBG
1311}
1312
Przemek Stekiele5352702022-10-05 11:37:54 +02001313component_test_tls1_2_default_stream_cipher_only () {
1314 msg "build: default with only stream cipher"
1315
1316 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C
1317 scripts/config.py unset MBEDTLS_GCM_C
1318 scripts/config.py unset MBEDTLS_CCM_C
1319 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1320 # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1321 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1322 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1323 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1324 # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1325 scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
1326 # Modules that depend on AEAD
1327 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001328 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001329
1330 make
1331
1332 msg "test: default with only stream cipher"
1333 make test
1334
1335 # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
1336}
1337
1338component_test_tls1_2_default_stream_cipher_only_use_psa () {
1339 msg "build: default with only stream cipher use psa"
1340
1341 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1342 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1343 scripts/config.py unset MBEDTLS_GCM_C
1344 scripts/config.py unset MBEDTLS_CCM_C
1345 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1346 # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1347 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
1348 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1349 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1350 # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1351 scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
1352 # Modules that depend on AEAD
1353 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001354 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001355
1356 make
1357
1358 msg "test: default with only stream cipher use psa"
1359 make test
1360
1361 # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
1362}
1363
1364component_test_tls1_2_default_cbc_legacy_cipher_only () {
1365 msg "build: default with only CBC-legacy cipher"
1366
1367 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1368 scripts/config.py unset MBEDTLS_GCM_C
1369 scripts/config.py unset MBEDTLS_CCM_C
1370 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1371 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1372 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1373 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1374 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1375 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1376 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1377 # Modules that depend on AEAD
1378 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001379 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001380
1381 make
1382
1383 msg "test: default with only CBC-legacy cipher"
1384 make test
1385
1386 msg "test: default with only CBC-legacy cipher - ssl-opt.sh (subset)"
1387 tests/ssl-opt.sh -f "TLS 1.2"
1388}
1389
1390component_test_tls1_2_deafult_cbc_legacy_cipher_only_use_psa () {
1391 msg "build: default with only CBC-legacy cipher use psa"
1392
1393 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1394 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1395 scripts/config.py unset MBEDTLS_GCM_C
1396 scripts/config.py unset MBEDTLS_CCM_C
1397 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1398 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1399 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1400 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1401 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
1402 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1403 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1404 # Modules that depend on AEAD
1405 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001406 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001407
1408 make
1409
1410 msg "test: default with only CBC-legacy cipher use psa"
1411 make test
1412
1413 msg "test: default with only CBC-legacy cipher use psa - ssl-opt.sh (subset)"
1414 tests/ssl-opt.sh -f "TLS 1.2"
1415}
1416
1417component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only () {
1418 msg "build: default with only CBC-legacy and CBC-EtM ciphers"
1419
1420 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1421 scripts/config.py unset MBEDTLS_GCM_C
1422 scripts/config.py unset MBEDTLS_CCM_C
1423 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1424 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1425 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1426 # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1427 scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
1428 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1429 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1430 # Modules that depend on AEAD
1431 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001432 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001433
1434 make
1435
1436 msg "test: default with only CBC-legacy and CBC-EtM ciphers"
1437 make test
1438
1439 msg "test: default with only CBC-legacy and CBC-EtM ciphers - ssl-opt.sh (subset)"
1440 tests/ssl-opt.sh -f "TLS 1.2"
1441}
1442
1443component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only_use_psa () {
1444 msg "build: default with only CBC-legacy and CBC-EtM ciphers use psa"
1445
1446 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
1447 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
1448 scripts/config.py unset MBEDTLS_GCM_C
1449 scripts/config.py unset MBEDTLS_CCM_C
1450 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
1451 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
1452 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
1453 # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
1454 scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
1455 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
1456 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
1457 # Modules that depend on AEAD
1458 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
Przemek Stekiel97d57402022-10-10 14:08:51 +02001459 scripts/config.py unset MBEDTLS_SSL_TICKET_C
Przemek Stekiele5352702022-10-05 11:37:54 +02001460
1461 make
1462
1463 msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa"
1464 make test
1465
1466 msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa - ssl-opt.sh (subset)"
1467 tests/ssl-opt.sh -f "TLS 1.2"
1468}
1469
Gilles Peskine636c26a2020-03-04 20:46:15 +01001470component_test_new_ecdh_context () {
1471 msg "build: new ECDH context (ASan build)" # ~ 6 min
1472 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1473 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1474 make
1475
1476 msg "test: new ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1477 make test
1478
1479 msg "test: new ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001480 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01001481
1482 msg "test: new ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1483 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001484 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine636c26a2020-03-04 20:46:15 +01001485}
1486
1487component_test_everest () {
1488 msg "build: Everest ECDH context (ASan build)" # ~ 6 min
1489 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1490 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
1491 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan .
1492 make
1493
1494 msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
1495 make test
1496
1497 msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001498 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01001499
1500 msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
1501 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001502 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine636c26a2020-03-04 20:46:15 +01001503}
1504
Gilles Peskined3beca92020-07-03 00:15:37 +02001505component_test_everest_curve25519_only () {
1506 msg "build: Everest ECDH context, only Curve25519" # ~ 6 min
1507 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
1508 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
1509 scripts/config.py unset MBEDTLS_ECDSA_C
1510 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
1511 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
1512 # Disable all curves
1513 for c in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do
1514 scripts/config.py unset "$c"
1515 done
1516 scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED
1517
1518 make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
1519
1520 msg "test: Everest ECDH context, only Curve25519" # ~ 50s
1521 make test
1522}
1523
Gilles Peskine8f073122018-11-27 15:58:47 +01001524component_test_small_ssl_out_content_len () {
1525 msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001526 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
1527 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01001528 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1529 make
Hanno Beckerd5ba5ef2017-09-28 12:53:51 +01001530
Gilles Peskine8f073122018-11-27 15:58:47 +01001531 msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001532 tests/ssl-opt.sh -f "Max fragment\|Large packet"
Gilles Peskine8f073122018-11-27 15:58:47 +01001533}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001534
Gilles Peskine8f073122018-11-27 15:58:47 +01001535component_test_small_ssl_in_content_len () {
1536 msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001537 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096
1538 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
Gilles Peskine8f073122018-11-27 15:58:47 +01001539 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1540 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001541
Gilles Peskine8f073122018-11-27 15:58:47 +01001542 msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001543 tests/ssl-opt.sh -f "Max fragment"
Gilles Peskine8f073122018-11-27 15:58:47 +01001544}
Angus Grattonc4dd0732018-04-11 16:28:39 +10001545
Gilles Peskine8f073122018-11-27 15:58:47 +01001546component_test_small_ssl_dtls_max_buffering () {
1547 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001548 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
Gilles Peskine8f073122018-11-27 15:58:47 +01001549 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1550 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10001551
Gilles Peskine8f073122018-11-27 15:58:47 +01001552 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001553 tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
Gilles Peskine8f073122018-11-27 15:58:47 +01001554}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001555
Gilles Peskine8f073122018-11-27 15:58:47 +01001556component_test_small_mbedtls_ssl_dtls_max_buffering () {
1557 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
Gilles Peskine636c26a2020-03-04 20:46:15 +01001558 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190
Gilles Peskine8f073122018-11-27 15:58:47 +01001559 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
1560 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001561
Gilles Peskine8f073122018-11-27 15:58:47 +01001562 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001563 tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
Gilles Peskine8f073122018-11-27 15:58:47 +01001564}
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001565
Gilles Peskine75cc7712019-09-06 19:47:17 +02001566component_test_psa_collect_statuses () {
1567 msg "build+test: psa_collect_statuses" # ~30s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02001568 scripts/config.py full
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001569 tests/scripts/psa_collect_statuses.py
Gilles Peskine75cc7712019-09-06 19:47:17 +02001570 # Check that psa_crypto_init() succeeded at least once
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001571 grep -q '^0:psa_crypto_init:' tests/statuses.log
Gilles Peskine75cc7712019-09-06 19:47:17 +02001572 rm -f tests/statuses.log
1573}
1574
Gilles Peskine8f073122018-11-27 15:58:47 +01001575component_test_full_cmake_clang () {
1576 msg "build: cmake, full config, clang" # ~ 50s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001577 scripts/config.py full
Gilles Peskine83264be2022-10-30 21:02:40 +01001578 CC=clang CXX=clang cmake -D CMAKE_BUILD_TYPE:String=Release -D ENABLE_TESTING=On -D TEST_CPP=1 .
Gilles Peskine8f073122018-11-27 15:58:47 +01001579 make
Hanno Becker2f5aa4c2018-08-24 14:43:44 +01001580
k-stachowiak0291cb72019-06-26 15:52:12 +02001581 msg "test: main suites (full config, clang)" # ~ 5s
Gilles Peskine8f073122018-11-27 15:58:47 +01001582 make test
Manuel Pégourié-Gonnard3895f5a2014-03-27 14:44:04 +01001583
Gilles Peskine83264be2022-10-30 21:02:40 +01001584 msg "test: cpp_dummy_build (full config, clang)" # ~ 1s
1585 programs/test/cpp_dummy_build
1586
k-stachowiak0291cb72019-06-26 15:52:12 +02001587 msg "test: psa_constant_names (full config, clang)" # ~ 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001588 tests/scripts/test_psa_constant_names.py
Gilles Peskine69e8f7f2020-02-26 19:51:43 +01001589
Gilles Peskine8f073122018-11-27 15:58:47 +01001590 msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001591 tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001592
Andres Amaya Garcia2dadab72019-01-08 21:42:27 +00001593 msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min
Manuel Pégourié-Gonnard89d40272022-12-19 11:42:12 +01001594 env OPENSSL="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES\|RC4\|ARCFOUR'
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001595
Gilles Peskine8f073122018-11-27 15:58:47 +01001596 msg "test: compat.sh ARIA + ChachaPoly"
Manuel Pégourié-Gonnard89d40272022-12-19 11:42:12 +01001597 env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
Gilles Peskine8f073122018-11-27 15:58:47 +01001598}
Manuel Pégourié-Gonnarde73b2632014-07-12 04:00:00 +02001599
Gilles Peskine9603a442022-11-29 16:01:41 +01001600skip_suites_without_constant_flow () {
1601 # Skip the test suites that don't have any constant-flow annotations.
1602 # This will need to be adjusted if we ever start declaring things as
1603 # secret from macros or functions inside tests/include or tests/src.
1604 SKIP_TEST_SUITES=$(
1605 git -C tests/suites grep -L TEST_CF_ 'test_suite_*.function' |
1606 sed 's/test_suite_//; s/\.function$//' |
1607 tr '\n' ,)
1608 export SKIP_TEST_SUITES
1609}
1610
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001611component_test_memsan_constant_flow () {
Manuel Pégourié-Gonnard0b2112d2020-07-22 11:09:28 +02001612 # This tests both (1) accesses to undefined memory, and (2) branches or
1613 # memory access depending on secret values. To distinguish between those:
1614 # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist?
1615 # - or alternatively, change the build type to MemSanDbg, which enables
1616 # origin tracking and nicer stack traces (which are useful for debugging
1617 # anyway), and check if the origin was TEST_CF_SECRET() or something else.
1618 msg "build: cmake MSan (clang), full config with constant flow testing"
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001619 scripts/config.py full
1620 scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN
1621 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
1622 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
1623 make
1624
Manuel Pégourié-Gonnard0b2112d2020-07-22 11:09:28 +02001625 msg "test: main suites (Msan + constant flow)"
Manuel Pégourié-Gonnard6240def2020-07-10 09:35:54 +02001626 make test
1627}
1628
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001629component_test_valgrind_constant_flow () {
1630 # This tests both (1) everything that valgrind's memcheck usually checks
1631 # (heap buffer overflows, use of uninitialized memory, use-after-free,
1632 # etc.) and (2) branches or memory access depending on secret values,
1633 # which will be reported as uninitialized memory. To distinguish between
1634 # secret and actually uninitialized:
1635 # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist?
1636 # - or alternatively, build with debug info and manually run the offending
1637 # test suite with valgrind --track-origins=yes, then check if the origin
1638 # was TEST_CF_SECRET() or something else.
1639 msg "build: cmake release GCC, full config with constant flow testing"
1640 scripts/config.py full
1641 scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND
Gilles Peskine9603a442022-11-29 16:01:41 +01001642 skip_suites_without_constant_flow
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001643 cmake -D CMAKE_BUILD_TYPE:String=Release .
1644 make
1645
1646 # this only shows a summary of the results (how many of each type)
1647 # details are left in Testing/<date>/DynamicAnalysis.xml
Gilles Peskine9603a442022-11-29 16:01:41 +01001648 msg "test: some suites (valgrind + constant flow)"
Manuel Pégourié-Gonnard73afa372020-08-19 10:27:38 +02001649 make memcheck
1650}
1651
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001652component_test_default_no_deprecated () {
Gilles Peskine8386ea22020-04-30 09:07:29 +02001653 # Test that removing the deprecated features from the default
1654 # configuration leaves something consistent.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001655 msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s
1656 scripts/config.py set MBEDTLS_DEPRECATED_REMOVED
1657 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1658
1659 msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s
1660 make test
1661}
1662
1663component_test_full_no_deprecated () {
Gilles Peskine30de2e82020-04-20 21:39:22 +02001664 msg "build: make, full_no_deprecated config" # ~ 30s
1665 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001666 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1667
Gilles Peskine30de2e82020-04-20 21:39:22 +02001668 msg "test: make, full_no_deprecated config" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001669 make test
1670}
1671
Gilles Peskine8386ea22020-04-30 09:07:29 +02001672component_test_full_no_deprecated_deprecated_warning () {
1673 # Test that there is nothing deprecated in "full_no_deprecated".
1674 # A deprecated feature would trigger a warning (made fatal) from
1675 # MBEDTLS_DEPRECATED_WARNING.
Gilles Peskine30de2e82020-04-20 21:39:22 +02001676 msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s
1677 scripts/config.py full_no_deprecated
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001678 scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED
1679 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
1680 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra'
1681
Gilles Peskine30de2e82020-04-20 21:39:22 +02001682 msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001683 make test
1684}
1685
Gilles Peskine8386ea22020-04-30 09:07:29 +02001686component_test_full_deprecated_warning () {
1687 # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes
1688 # with only certain whitelisted types of warnings.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001689 msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001690 scripts/config.py full
1691 scripts/config.py set MBEDTLS_DEPRECATED_WARNING
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001692 # Expect warnings from '#warning' directives in check_config.h.
1693 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +01001694
Gilles Peskine8386ea22020-04-30 09:07:29 +02001695 msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s
1696 # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features.
1697 # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set.
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001698 # Expect warnings from '#warning' directives in check_config.h and
1699 # from the use of deprecated functions in test suites.
1700 make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=deprecated-declarations -Wno-error=cpp -DMBEDTLS_TEST_DEPRECATED' tests
Gilles Peskine841b14b2019-11-26 17:37:37 +01001701
Gilles Peskine1093d9f2020-04-13 01:03:21 +02001702 msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s
1703 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01001704}
Jaeden Ameroed93bdc2018-11-02 16:57:24 +00001705
Gilles Peskineec541fe2020-01-31 14:24:14 +01001706# Check that the specified libraries exist and are empty.
1707are_empty_libraries () {
1708 nm "$@" >/dev/null 2>/dev/null
1709 ! nm "$@" 2>/dev/null | grep -v ':$' | grep .
1710}
1711
1712component_build_crypto_default () {
1713 msg "build: make, crypto only"
1714 scripts/config.py crypto
Gilles Peskine6bb39152020-02-03 11:59:20 +01001715 make CFLAGS='-O1 -Werror'
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001716 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001717}
1718
1719component_build_crypto_full () {
1720 msg "build: make, crypto only, full config"
1721 scripts/config.py crypto_full
Gilles Peskine6bb39152020-02-03 11:59:20 +01001722 make CFLAGS='-O1 -Werror'
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001723 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001724}
1725
Gilles Peskine8df27482022-10-21 19:34:54 +02001726component_test_crypto_for_psa_service () {
Gilles Peskine21503df2022-10-11 21:05:06 +02001727 msg "build: make, config for PSA crypto service"
1728 scripts/config.py crypto
1729 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
1730 # Disable things that are not needed for just cryptography, to
1731 # reach a configuration that would be typical for a PSA cryptography
1732 # service providing all implemented PSA algorithms.
1733 # System stuff
1734 scripts/config.py unset MBEDTLS_ERROR_C
1735 scripts/config.py unset MBEDTLS_TIMING_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001736 scripts/config.py unset MBEDTLS_VERSION_FEATURES
Gilles Peskine21503df2022-10-11 21:05:06 +02001737 # Crypto stuff with no PSA interface
1738 scripts/config.py unset MBEDTLS_BASE64_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001739 scripts/config.py unset MBEDTLS_BLOWFISH_C
1740 # Keep MBEDTLS_CIPHER_C because psa_crypto_cipher, CCM and GCM need it.
1741 # Keep MBEDTLS_MD_C because RSA and ECDSA need it, also HMAC_DRBG which
1742 # is needed for deterministic ECDSA.
1743 scripts/config.py unset MBEDTLS_ECJPAKE_C
1744 scripts/config.py unset MBEDTLS_HKDF_C # PSA's HKDF is independent
Gilles Peskine21503df2022-10-11 21:05:06 +02001745 scripts/config.py unset MBEDTLS_NIST_KW_C
1746 scripts/config.py unset MBEDTLS_PEM_PARSE_C
1747 scripts/config.py unset MBEDTLS_PEM_WRITE_C
1748 scripts/config.py unset MBEDTLS_PKCS12_C
1749 scripts/config.py unset MBEDTLS_PKCS5_C
Gilles Peskine031c8c22022-10-25 21:09:49 +02001750 # We keep MBEDTLS_PK_{,PARSE,WRITE}_C because PSA with RSA needs it.
1751 scripts/config.py unset MBEDTLS_XTEA_C
Gilles Peskine21503df2022-10-11 21:05:06 +02001752 make CFLAGS='-O1 -Werror' all test
1753 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
1754}
1755
Gilles Peskineec541fe2020-01-31 14:24:14 +01001756component_build_crypto_baremetal () {
1757 msg "build: make, crypto only, baremetal config"
1758 scripts/config.py crypto_baremetal
David Horstmann3cb5e9b2021-11-30 11:40:54 +00001759 make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001760 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
Gilles Peskineec541fe2020-01-31 14:24:14 +01001761}
Daniel Axtens6f63cc72020-09-02 21:30:13 +10001762support_build_crypto_baremetal () {
Daniel Axtens1a021af2020-08-31 14:22:58 +10001763 support_build_baremetal "$@"
1764}
1765
1766component_build_baremetal () {
1767 msg "build: make, baremetal config"
1768 scripts/config.py baremetal
David Horstmann3cb5e9b2021-11-30 11:40:54 +00001769 make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
Daniel Axtens1a021af2020-08-31 14:22:58 +10001770}
1771support_build_baremetal () {
Daniel Axtens6f63cc72020-09-02 21:30:13 +10001772 # Older Glibc versions include time.h from other headers such as stdlib.h,
1773 # which makes the no-time.h-in-baremetal check fail. Ubuntu 16.04 has this
1774 # problem, Ubuntu 18.04 is ok.
1775 ! grep -q -F time.h /usr/include/x86_64-linux-gnu/sys/types.h
1776}
Gilles Peskineec541fe2020-01-31 14:24:14 +01001777
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001778# depends.py family of tests
Andrzej Kurek85d69302022-10-05 09:14:07 -04001779component_test_depends_py_cipher_id () {
1780 msg "test/build: depends.py cipher_id (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001781 tests/scripts/depends.py cipher_id --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001782}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001783
Andrzej Kurek85d69302022-10-05 09:14:07 -04001784component_test_depends_py_cipher_chaining () {
1785 msg "test/build: depends.py cipher_chaining (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001786 tests/scripts/depends.py cipher_chaining --unset-use-psa
John Durkopc14be902020-08-20 06:16:41 -07001787}
1788
Andrzej Kurek85d69302022-10-05 09:14:07 -04001789component_test_depends_py_cipher_padding () {
1790 msg "test/build: depends.py cipher_padding (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001791 tests/scripts/depends.py cipher_padding --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001792}
Jaeden Ameroacaabe72018-11-07 11:52:52 +00001793
Andrzej Kurek85d69302022-10-05 09:14:07 -04001794component_test_depends_py_curves () {
1795 msg "test/build: depends.py curves (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001796 tests/scripts/depends.py curves --unset-use-psa
John Durkop2ec2eaa2020-08-24 18:29:15 -07001797}
1798
Andrzej Kurek85d69302022-10-05 09:14:07 -04001799component_test_depends_py_hashes () {
1800 msg "test/build: depends.py hashes (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001801 tests/scripts/depends.py hashes --unset-use-psa
Gilles Peskine8f073122018-11-27 15:58:47 +01001802}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001803
Andrzej Kurek85d69302022-10-05 09:14:07 -04001804component_test_depends_py_kex () {
1805 msg "test/build: depends.py kex (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001806 tests/scripts/depends.py kex --unset-use-psa
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001807}
1808
Andrzej Kurek85d69302022-10-05 09:14:07 -04001809component_test_depends_py_pkalgs () {
1810 msg "test/build: depends.py pkalgs (gcc)"
Andrzej Kurek20d8a5f2022-10-24 10:49:22 -04001811 tests/scripts/depends.py pkalgs --unset-use-psa
1812}
1813
1814# PSA equivalents of the depends.py tests
1815component_test_depends_py_cipher_id_psa () {
1816 msg "test/build: depends.py cipher_id (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1817 tests/scripts/depends.py cipher_id
1818}
1819
1820component_test_depends_py_cipher_chaining_psa () {
1821 msg "test/build: depends.py cipher_chaining (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1822 tests/scripts/depends.py cipher_chaining
1823}
1824
1825component_test_depends_py_cipher_padding_psa () {
1826 msg "test/build: depends.py cipher_padding (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1827 tests/scripts/depends.py cipher_padding
1828}
1829
1830component_test_depends_py_curves_psa () {
1831 msg "test/build: depends.py curves (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1832 tests/scripts/depends.py curves
1833}
1834
1835component_test_depends_py_hashes_psa () {
1836 msg "test/build: depends.py hashes (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1837 tests/scripts/depends.py hashes
1838}
1839
1840component_test_depends_py_kex_psa () {
1841 msg "test/build: depends.py kex (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
1842 tests/scripts/depends.py kex
1843}
1844
1845component_test_depends_py_pkalgs_psa () {
1846 msg "test/build: depends.py pkalgs (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
Andrzej Kurek85d69302022-10-05 09:14:07 -04001847 tests/scripts/depends.py pkalgs
Gilles Peskine8f073122018-11-27 15:58:47 +01001848}
Manuel Pégourié-Gonnard655c0a82018-10-30 11:20:45 +01001849
Dave Rodgman5fce4f62023-01-20 13:18:05 +00001850component_build_no_pk_rsa_alt_support () {
1851 msg "build: !MBEDTLS_PK_RSA_ALT_SUPPORT" # ~30s
1852
1853 scripts/config.py full
1854 scripts/config.py unset MBEDTLS_PK_RSA_ALT_SUPPORT
1855 scripts/config.py set MBEDTLS_RSA_C
1856 scripts/config.py set MBEDTLS_X509_CRT_WRITE_C
1857
1858 # Only compile - this is primarily to test for compile issues
1859 make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy'
1860}
1861
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001862component_test_no_use_psa_crypto_full_cmake_asan() {
1863 # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh
Gilles Peskinedc3a1792019-09-03 11:42:04 +02001864 msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001865 scripts/config.py full
1866 scripts/config.py set MBEDTLS_ECP_RESTARTABLE # not using PSA, so enable restartable ECC
1867 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
1868 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1869 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskinedc6d8382020-04-12 14:21:55 +02001870 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02001871 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
Manuel Pégourié-Gonnardd8167e82019-02-01 11:12:52 +01001872 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001873 make
Manuel Pégourié-Gonnard43be6cd2017-06-20 09:53:42 +02001874
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001875 msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)"
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001876 make test
Manuel Pégourié-Gonnard503a5ef2015-10-23 09:04:45 +02001877
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001878 msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001879 tests/ssl-opt.sh
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01001880
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001881 msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02001882 tests/compat.sh
Andrzej Kurek991f9fe2018-07-02 09:08:21 -04001883
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001884 msg "test: compat.sh RC4, DES & NULL (full minus MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnard89d40272022-12-19 11:42:12 +01001885 env OPENSSL="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001886
Manuel Pégourié-Gonnard971dea32019-02-01 12:38:40 +01001887 msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)"
Manuel Pégourié-Gonnard89d40272022-12-19 11:42:12 +01001888 env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA'
Andrzej Kurekde5a0072019-02-01 07:03:03 -05001889}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05001890
Ronald Crond2c53e62021-09-13 09:38:05 +02001891component_test_psa_crypto_config_accel_ecdsa () {
1892 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
1893
1894 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
1895 # partial support for cipher operations in the driver test library.
1896 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
1897 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
Gilles Peskine62de7672022-04-21 11:05:16 +02001898 # Disable obsolete hashes (alternatively we could enable support for them
1899 # in the driver test library).
1900 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1901 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
Ronald Crond2c53e62021-09-13 09:38:05 +02001902
1903 # SHA384 needed for some ECDSA signature tests.
1904 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA512_C
1905
1906 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA KEY_TYPE_ECC_KEY_PAIR KEY_TYPE_ECC_PUBLIC_KEY"
1907 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
1908 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
1909
1910 # Restore test driver base configuration
1911 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA512_C
1912
1913 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1914 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1915 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1916 scripts/config.py unset MBEDTLS_ECDSA_C
1917 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
1918 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
1919
1920 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
1921 make CFLAGS="$ASAN_CFLAGS -O -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
1922
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01001923 not grep mbedtls_ecdsa_ library/ecdsa.o
Ronald Crond2c53e62021-09-13 09:38:05 +02001924
1925 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
1926 make test
1927}
1928
1929component_test_psa_crypto_config_accel_rsa_signature () {
1930 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature"
1931
1932 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
1933 # partial support for cipher operations in the driver test library.
1934 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
1935 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
1936
1937 # It seems it is not possible to remove only the support for RSA signature
1938 # in the library. Thus we have to remove all RSA support (signature and
1939 # encryption/decryption). AS there is no driver support for asymmetric
1940 # encryption/decryption so far remove RSA encryption/decryption from the
1941 # application algorithm list.
1942 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
1943 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
1944
1945 # Make sure both the library and the test library support the SHA hash
1946 # algorithms and only those ones (SHA256 is included by default). That way:
1947 # - the test library can compute the RSA signatures even in the case of a
1948 # composite RSA signature algorithm based on a SHA hash (no other hash
1949 # used in the unit tests).
1950 # - the dependency of RSA signature tests on PSA_WANT_ALG_SHA_xyz is
1951 # fulfilled as the hash SHA algorithm is supported by the library, and
1952 # thus the tests are run, not skipped.
1953 # - when testing a signature key with an algorithm wildcard built from
1954 # PSA_ALG_ANY_HASH as algorithm to test with the key, the chosen hash
1955 # algorithm based on the hashes supported by the library is also
1956 # supported by the test library.
1957 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
1958 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
1959 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
1960 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160_C
1961
1962 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA1_C
1963 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_SHA512_C
1964 # We need PEM parsing in the test library as well to support the import
1965 # of PEM encoded RSA keys.
1966 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_PEM_PARSE_C
1967 scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_BASE64_C
1968
1969 loc_accel_list="ALG_RSA_PKCS1V15_SIGN ALG_RSA_PSS KEY_TYPE_RSA_KEY_PAIR KEY_TYPE_RSA_PUBLIC_KEY"
1970 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
1971 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
1972
1973 # Restore test driver base configuration
1974 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA1_C
1975 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_SHA512_C
1976 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_PEM_PARSE_C
1977 scripts/config.py -f tests/include/test/drivers/config_test_driver.h unset MBEDTLS_BASE64_C
1978
1979
1980 # Mbed TLS library build
1981 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
1982 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1983
1984 # Remove RSA support and its dependencies
1985 scripts/config.py unset MBEDTLS_PKCS1_V15
1986 scripts/config.py unset MBEDTLS_PKCS1_V21
1987 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
1988 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
1989 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
1990 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
1991 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
1992 scripts/config.py unset MBEDTLS_RSA_C
1993 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
1994
1995 scripts/config.py unset MBEDTLS_MD2_C
1996 scripts/config.py unset MBEDTLS_MD4_C
1997 scripts/config.py unset MBEDTLS_MD5_C
1998 scripts/config.py unset MBEDTLS_RIPEMD160_C
1999 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1
2000 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_1
2001 scripts/config.py unset MBEDTLS_SSL_CBC_RECORD_SPLITTING
2002
2003 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2004 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2005
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002006 not grep mbedtls_rsa_rsassa_pkcs1_v15_sign library/rsa.o
2007 not grep mbedtls_rsa_rsassa_pss_sign_ext library/rsa.o
Ronald Crond2c53e62021-09-13 09:38:05 +02002008
2009 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature"
2010 make test
2011}
2012
Ronald Cronf7e483c2021-05-08 14:32:59 +02002013component_test_psa_crypto_config_accel_hash () {
2014 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2015
2016 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2017 # partial support for cipher operations in the driver test library.
2018 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2019 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
2020
2021 loc_accel_list="ALG_MD4 ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512"
2022 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2023 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2024
2025 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2026 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2027 scripts/config.py unset MBEDTLS_MD2_C
2028 scripts/config.py unset MBEDTLS_MD4_C
2029 scripts/config.py unset MBEDTLS_MD5_C
2030 scripts/config.py unset MBEDTLS_RIPEMD160_C
2031 scripts/config.py unset MBEDTLS_SHA1_C
2032 # Don't unset MBEDTLS_SHA256_C as it is needed by PSA crypto core.
2033 scripts/config.py unset MBEDTLS_SHA512_C
2034 # Unset MBEDTLS_SSL_PROTO_SSL3, MBEDTLS_SSL_PROTO_TLS1 and MBEDTLS_SSL_PROTO_TLS1_1 as they depend on MBEDTLS_SHA1_C
2035 scripts/config.py unset MBEDTLS_SSL_PROTO_SSL3
2036 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1
2037 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_1
2038 # Unset MBEDTLS_SSL_CBC_RECORD_SPLITTING as it depends on MBEDTLS_SSL_PROTO_TLS1 in the default configuration.
2039 scripts/config.py unset MBEDTLS_SSL_CBC_RECORD_SPLITTING
2040 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2041 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2042
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002043 not grep mbedtls_sha512_init library/sha512.o
2044 not grep mbedtls_sha1_init library/sha1.o
Ronald Cronf7e483c2021-05-08 14:32:59 +02002045
2046 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2047 make test
2048}
2049
Ronald Cron09623702021-10-18 11:26:01 +02002050component_test_psa_crypto_config_accel_cipher () {
2051 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated cipher"
2052
Gilles Peskine186331872022-04-12 15:58:03 +02002053 # This test case focuses on cipher+AEAD. We don't yet support all
2054 # combinations of configurations, so deactivate block-cipher-based MACs.
2055 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_CMAC
2056
Ronald Cron09623702021-10-18 11:26:01 +02002057 loc_accel_list="ALG_CBC_NO_PADDING ALG_CBC_PKCS7 ALG_CTR ALG_CFB ALG_OFB ALG_XTS KEY_TYPE_DES"
2058 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2059 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2060
2061 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2062 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2063
2064 # There is no intended accelerator support for ALG STREAM_CIPHER and
2065 # ALG_ECB_NO_PADDING. Therefore, asking for them in the build implies the
2066 # inclusion of the Mbed TLS cipher operations. As we want to test here with
2067 # cipher operations solely supported by accelerators, disabled those
2068 # PSA configuration options.
2069 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2070 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
Ronald Cron09623702021-10-18 11:26:01 +02002071
2072 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2073 scripts/config.py unset MBEDTLS_CIPHER_PADDING_PKCS7
2074 scripts/config.py unset MBEDTLS_CIPHER_MODE_CTR
2075 scripts/config.py unset MBEDTLS_CIPHER_MODE_CFB
2076 scripts/config.py unset MBEDTLS_CIPHER_MODE_OFB
2077 scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
2078 scripts/config.py unset MBEDTLS_DES_C
2079
2080 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2081 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2082
Gilles Peskined4c5c3d2022-02-04 00:30:54 +01002083 not grep mbedtls_des* library/des.o
Ronald Cron09623702021-10-18 11:26:01 +02002084
2085 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
2086 make test
2087}
2088
Przemek Stekiel8b56f232022-10-02 20:58:39 +02002089component_test_psa_crypto_config_accel_aead () {
2090 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD"
2091
2092 # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having
2093 # partial support for cipher operations in the driver test library.
2094 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
2095 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
2096
2097 loc_accel_list="ALG_GCM ALG_CCM ALG_CHACHA20_POLY1305 KEY_TYPE_AES KEY_TYPE_CHACHA20 KEY_TYPE_ARIA KEY_TYPE_CAMELLIA"
2098 loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' )
2099 make -C tests libtestdriver1.a CFLAGS="$ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS"
2100
2101 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2102 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2103
2104 scripts/config.py unset MBEDTLS_GCM_C
2105 scripts/config.py unset MBEDTLS_CCM_C
2106 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2107 # Features that depend on AEAD
2108 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
2109 scripts/config.py unset MBEDTLS_SSL_TICKET_C
2110
2111 loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
2112 make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -I../../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"
2113
2114 # There's a risk of something getting re-enabled via config_psa.h
2115 # make sure it did not happen.
2116 not grep mbedtls_ccm library/ccm.o
2117 not grep mbedtls_gcm library/gcm.o
2118 not grep mbedtls_chachapoly library/chachapoly.o
2119
2120 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD"
2121 make test
2122}
2123
John Durkop4377bf72020-10-23 01:26:57 -07002124component_test_psa_crypto_config_no_driver() {
John Durkop4377bf72020-10-23 01:26:57 -07002125 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS"
2126 scripts/config.py full
2127 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2128 scripts/config.py unset MBEDTLS_PSA_CRYPTO_DRIVERS
2129 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkope7012c72020-10-26 09:55:01 -07002130 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkop4377bf72020-10-23 01:26:57 -07002131
2132 msg "test: full + MBEDTLS_PSA_CRYPTO_CONFIG minus MBEDTLS_PSA_CRYPTO_DRIVERS"
John Durkopd8959392020-09-20 23:09:17 -07002133 make test
2134}
2135
Gilles Peskined4c85af2023-07-20 22:19:45 +02002136component_test_aead_chachapoly_disabled() {
2137 msg "build: full minus CHACHAPOLY"
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002138 scripts/config.py full
2139 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
Gilles Peskined4c85af2023-07-20 22:19:45 +02002140 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CHACHA20_POLY1305
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002141 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
2142
Gilles Peskined4c85af2023-07-20 22:19:45 +02002143 msg "test: full minus CHACHAPOLY"
2144 make test
2145}
2146
2147component_test_aead_only_ccm() {
2148 msg "build: full minus CHACHAPOLY and GCM"
2149 scripts/config.py full
2150 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2151 scripts/config.py unset MBEDTLS_GCM_C
2152 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CHACHA20_POLY1305
2153 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_GCM
2154 make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
2155
2156 msg "test: full minus CHACHAPOLY and GCM"
Przemyslaw Stekiel7ce979a2021-10-13 11:09:44 +02002157 make test
2158}
2159
John Durkopd0321952020-10-29 21:37:36 -07002160# This should be renamed to test and updated once the accelerator ECDH code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002161component_build_psa_accel_alg_ecdh() {
John Durkopd0321952020-10-29 21:37:36 -07002162 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C"
2163 scripts/config.py full
2164 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2165 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2166 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2167 scripts/config.py unset MBEDTLS_ECDH_C
2168 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
2169 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
2170 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
2171 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
2172 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
2173 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2174 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2175}
2176
John Durkopf4c4cb02020-10-28 20:09:55 -07002177# This should be renamed to test and updated once the accelerator ECC key pair code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002178component_build_psa_accel_key_type_ecc_key_pair() {
John Durkop9814fa22020-11-04 12:28:15 -08002179 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR"
John Durkopf4c4cb02020-10-28 20:09:55 -07002180 scripts/config.py full
2181 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2182 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2183 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkop9814fa22020-11-04 12:28:15 -08002184 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_KEY_PAIR 1
John Durkop07cc04a2020-11-16 22:08:34 -08002185 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
John Durkopf4c4cb02020-10-28 20:09:55 -07002186 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
John Durkop9814fa22020-11-04 12:28:15 -08002187 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_KEY_PAIR -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkopf4c4cb02020-10-28 20:09:55 -07002188}
2189
2190# This should be renamed to test and updated once the accelerator ECC public key code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002191component_build_psa_accel_key_type_ecc_public_key() {
John Durkop9814fa22020-11-04 12:28:15 -08002192 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY"
John Durkopf4c4cb02020-10-28 20:09:55 -07002193 scripts/config.py full
2194 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2195 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2196 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkop9814fa22020-11-04 12:28:15 -08002197 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1
2198 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR
John Durkopf4c4cb02020-10-28 20:09:55 -07002199 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
John Durkop9814fa22020-11-04 12:28:15 -08002200 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_ECC_PUBLIC_KEY -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkopf4c4cb02020-10-28 20:09:55 -07002201}
2202
John Durkopd0321952020-10-29 21:37:36 -07002203# This should be renamed to test and updated once the accelerator HMAC code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002204component_build_psa_accel_alg_hmac() {
John Durkopd0321952020-10-29 21:37:36 -07002205 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_HMAC"
2206 scripts/config.py full
2207 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2208 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2209 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2210 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2211 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2212}
2213
2214# This should be renamed to test and updated once the accelerator HKDF code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002215component_build_psa_accel_alg_hkdf() {
John Durkopd0321952020-10-29 21:37:36 -07002216 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C"
2217 scripts/config.py full
2218 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2219 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2220 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2221 scripts/config.py unset MBEDTLS_HKDF_C
John Durkopbd069d32020-10-31 22:14:03 -07002222 # Make sure to unset TLS1_3_EXPERIMENTAL since it requires HKDF_C and will not build properly without it.
2223 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
John Durkopd0321952020-10-29 21:37:36 -07002224 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2225 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2226}
2227
John Durkop1b7ee052020-11-27 08:51:22 -08002228# This should be renamed to test and updated once the accelerator MD2 code is in place and ready to test.
2229component_build_psa_accel_alg_md2() {
John Durkop1b7ee052020-11-27 08:51:22 -08002230 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_MD2 - other hashes"
2231 scripts/config.py full
2232 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2233 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2234 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2235 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2236 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2237 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2238 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2239 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2240 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2241 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2242 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2243 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2244 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD2 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2245}
2246
2247# This should be renamed to test and updated once the accelerator MD4 code is in place and ready to test.
2248component_build_psa_accel_alg_md4() {
John Durkop1b7ee052020-11-27 08:51:22 -08002249 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_MD4 - other hashes"
2250 scripts/config.py full
2251 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2252 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2253 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2254 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2255 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2256 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2257 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2258 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2259 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2260 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2261 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2262 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2263 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD4 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2264}
2265
2266# This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test.
2267component_build_psa_accel_alg_md5() {
John Durkop1b7ee052020-11-27 08:51:22 -08002268 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_MD5 - other hashes"
2269 scripts/config.py full
2270 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2271 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2272 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2273 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2274 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2275 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2276 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2277 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2278 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2279 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2280 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2281 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2282 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2283}
2284
2285# This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test.
2286component_build_psa_accel_alg_ripemd160() {
John Durkop1b7ee052020-11-27 08:51:22 -08002287 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RIPEMD160 - other hashes"
2288 scripts/config.py full
2289 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2290 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2291 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2292 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2293 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2294 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2295 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2296 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2297 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2298 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2299 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2300 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2301 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2302}
2303
2304# This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test.
2305component_build_psa_accel_alg_sha1() {
John Durkop1b7ee052020-11-27 08:51:22 -08002306 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_1 - other hashes"
2307 scripts/config.py full
2308 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2309 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2310 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2311 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2312 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2313 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2314 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2315 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2316 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2317 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2318 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2319 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2320 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2321}
2322
2323# This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test.
2324component_build_psa_accel_alg_sha224() {
John Durkop1b7ee052020-11-27 08:51:22 -08002325 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_224 - other hashes"
2326 scripts/config.py full
2327 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2328 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2329 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2330 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2331 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2332 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2333 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2334 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2335 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2336 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2337 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2338 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2339}
2340
2341# This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test.
2342component_build_psa_accel_alg_sha256() {
John Durkop1b7ee052020-11-27 08:51:22 -08002343 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_256 - other hashes"
2344 scripts/config.py full
2345 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2346 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2347 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2348 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2349 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2350 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2351 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2352 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2353 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2354 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2355 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512
2356 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2357 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2358}
2359
2360# This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test.
2361component_build_psa_accel_alg_sha384() {
John Durkop1b7ee052020-11-27 08:51:22 -08002362 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_384 - other hashes"
2363 scripts/config.py full
2364 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2365 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2366 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2367 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2368 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2369 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2370 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2371 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2372 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2373 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2374 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2375 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2376}
2377
2378# This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test.
2379component_build_psa_accel_alg_sha512() {
John Durkop1b7ee052020-11-27 08:51:22 -08002380 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_512 - other hashes"
2381 scripts/config.py full
2382 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2383 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2384 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2385 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD2
2386 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD4
2387 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5
2388 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160
2389 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1
2390 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224
2391 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256
2392 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384
2393 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2394 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2395}
2396
John Durkopd0321952020-10-29 21:37:36 -07002397# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002398component_build_psa_accel_alg_rsa_pkcs1v15_crypt() {
John Durkopbd069d32020-10-31 22:14:03 -07002399 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
John Durkopd0321952020-10-29 21:37:36 -07002400 scripts/config.py full
2401 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2402 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2403 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
John Durkopbd069d32020-10-31 22:14:03 -07002404 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002405 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2406 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
2407 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopd0321952020-10-29 21:37:36 -07002408 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
John Durkopbd069d32020-10-31 22:14:03 -07002409 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2410}
2411
2412# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002413component_build_psa_accel_alg_rsa_pkcs1v15_sign() {
John Durkopbd069d32020-10-31 22:14:03 -07002414 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PKCS1V15_SIGN + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
2415 scripts/config.py full
2416 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2417 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2418 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2419 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002420 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2421 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
2422 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopbd069d32020-10-31 22:14:03 -07002423 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2424 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2425}
2426
2427# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002428component_build_psa_accel_alg_rsa_oaep() {
John Durkopbd069d32020-10-31 22:14:03 -07002429 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_OAEP + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
2430 scripts/config.py full
2431 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2432 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2433 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2434 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_OAEP 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002435 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2436 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2437 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS
John Durkopbd069d32020-10-31 22:14:03 -07002438 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2439 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2440}
2441
2442# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002443component_build_psa_accel_alg_rsa_pss() {
John Durkopbd069d32020-10-31 22:14:03 -07002444 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PSS + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
2445 scripts/config.py full
2446 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2447 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2448 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2449 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
John Durkop7fc75ea2020-11-03 19:05:36 -08002450 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2451 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2452 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP
John Durkopbd069d32020-10-31 22:14:03 -07002453 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2454 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2455}
2456
2457# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002458component_build_psa_accel_key_type_rsa_key_pair() {
John Durkopbd069d32020-10-31 22:14:03 -07002459 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR + PSA_WANT_ALG_RSA_PSS"
2460 scripts/config.py full
2461 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2462 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2463 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2464 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
2465 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR 1
2466 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2467 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
2468}
2469
2470# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
John Durkop6ba40d12020-11-10 08:50:04 -08002471component_build_psa_accel_key_type_rsa_public_key() {
John Durkopbd069d32020-10-31 22:14:03 -07002472 msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + PSA_WANT_ALG_RSA_PSS"
2473 scripts/config.py full
2474 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2475 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
2476 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2477 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1
2478 scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1
2479 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2480 make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS"
John Durkopd0321952020-10-29 21:37:36 -07002481}
2482
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002483component_test_check_params_functionality () {
2484 msg "build+test: MBEDTLS_CHECK_PARAMS functionality"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002485 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002486 # Make MBEDTLS_PARAM_FAILED call mbedtls_param_failed().
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002487 scripts/config.py unset MBEDTLS_CHECK_PARAMS_ASSERT
Ronald Crona1236142020-07-01 16:01:21 +02002488 make CC=gcc CFLAGS='-Werror -O1' all test
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002489}
2490
Gilles Peskineb28636b2019-01-02 19:06:24 +01002491component_test_check_params_without_platform () {
2492 msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002493 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002494 # Keep MBEDTLS_PARAM_FAILED as assert.
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002495 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
2496 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
2497 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
2498 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
Gilles Peskine32e889d2020-04-12 23:43:28 +02002499 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002500 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
2501 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Gilles Peskine9c764bf2022-09-18 14:05:23 +02002502 scripts/config.py unset MBEDTLS_PLATFORM_VSNPRINTF_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002503 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
2504 scripts/config.py unset MBEDTLS_PLATFORM_C
Gilles Peskineb28636b2019-01-02 19:06:24 +01002505 make CC=gcc CFLAGS='-Werror -O1' all test
2506}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002507
Gilles Peskineb28636b2019-01-02 19:06:24 +01002508component_test_check_params_silent () {
2509 msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002510 scripts/config.py full # includes CHECK_PARAMS
Gilles Peskineadcde5e2019-06-12 16:05:50 +02002511 # Set MBEDTLS_PARAM_FAILED to nothing.
Gilles Peskineb28636b2019-01-02 19:06:24 +01002512 sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H"
2513 make CC=gcc CFLAGS='-Werror -O1' all test
2514}
Andrzej Kurekc470b6b2019-01-31 08:20:20 -05002515
Dave Rodgman173227d2023-06-29 09:29:00 +01002516component_build_aes_variations() { # ~45s
2517 msg "build: aes.o for all combinations of relevant config options"
Dave Rodgmanbf998282023-06-29 12:10:45 +01002518
Dave Rodgman173227d2023-06-29 09:29:00 +01002519 for a in set unset; do
2520 for b in set unset; do
2521 for c in set unset; do
2522 for d in set unset; do
2523 for e in set unset; do
2524 for f in set unset; do
2525 for g in set unset; do
Dave Rodgmanbf998282023-06-29 12:10:45 +01002526 echo ./scripts/config.py $a MBEDTLS_AES_SETKEY_ENC_ALT
2527 echo ./scripts/config.py $b MBEDTLS_AES_DECRYPT_ALT
2528 echo ./scripts/config.py $c MBEDTLS_AES_ROM_TABLES
2529 echo ./scripts/config.py $d MBEDTLS_AES_ENCRYPT_ALT
2530 echo ./scripts/config.py $e MBEDTLS_AES_SETKEY_DEC_ALT
2531 echo ./scripts/config.py $f MBEDTLS_AES_FEWER_TABLES
2532 echo ./scripts/config.py $g MBEDTLS_PADLOCK_C
Dave Rodgman173227d2023-06-29 09:29:00 +01002533
Dave Rodgmanbf998282023-06-29 12:10:45 +01002534 ./scripts/config.py $a MBEDTLS_AES_SETKEY_ENC_ALT
2535 ./scripts/config.py $b MBEDTLS_AES_DECRYPT_ALT
2536 ./scripts/config.py $c MBEDTLS_AES_ROM_TABLES
2537 ./scripts/config.py $d MBEDTLS_AES_ENCRYPT_ALT
2538 ./scripts/config.py $e MBEDTLS_AES_SETKEY_DEC_ALT
2539 ./scripts/config.py $f MBEDTLS_AES_FEWER_TABLES
2540 ./scripts/config.py $g MBEDTLS_PADLOCK_C
Dave Rodgman173227d2023-06-29 09:29:00 +01002541
Dave Rodgmanbf998282023-06-29 12:10:45 +01002542 rm -f library/aes.o
2543 make -C library aes.o CC="clang" CFLAGS="-O0 -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused"
Dave Rodgman173227d2023-06-29 09:29:00 +01002544 done
2545 done
2546 done
2547 done
2548 done
2549 done
2550 done
2551}
2552
Gilles Peskine8f073122018-11-27 15:58:47 +01002553component_test_no_platform () {
2554 # Full configuration build, without platform support, file IO and net sockets.
2555 # This should catch missing mbedtls_printf definitions, and by disabling file
2556 # IO, it should catch missing '#include <stdio.h>'
2557 msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002558 scripts/config.py full
2559 scripts/config.py unset MBEDTLS_PLATFORM_C
2560 scripts/config.py unset MBEDTLS_NET_C
2561 scripts/config.py unset MBEDTLS_PLATFORM_MEMORY
2562 scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT
2563 scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT
2564 scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT
Gilles Peskine9c764bf2022-09-18 14:05:23 +02002565 scripts/config.py unset MBEDTLS_PLATFORM_VSNPRINTF_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002566 scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT
2567 scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT
Gilles Peskine32e889d2020-04-12 23:43:28 +02002568 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002569 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
2570 scripts/config.py unset MBEDTLS_FS_IO
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002571 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002572 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
2573 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
Gilles Peskine8f073122018-11-27 15:58:47 +01002574 # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
2575 # to re-enable platform integration features otherwise disabled in C99 builds
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002576 make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs
2577 make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test
Gilles Peskine8f073122018-11-27 15:58:47 +01002578}
Manuel Pégourié-Gonnarda71780e2015-02-13 13:56:55 +00002579
Gilles Peskine8f073122018-11-27 15:58:47 +01002580component_build_no_std_function () {
2581 # catch compile bugs in _uninit functions
2582 msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002583 scripts/config.py full
2584 scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
2585 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02002586 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine31fdda12021-10-08 11:45:47 +02002587 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
Gilles Peskine25319702021-10-07 19:34:57 +02002588 make
Gilles Peskine8f073122018-11-27 15:58:47 +01002589}
Manuel Pégourié-Gonnarddccb80b2015-06-03 10:20:33 +01002590
Gilles Peskine8f073122018-11-27 15:58:47 +01002591component_build_no_ssl_srv () {
2592 msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002593 scripts/config.py full
2594 scripts/config.py unset MBEDTLS_SSL_SRV_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002595 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01002596}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02002597
Gilles Peskine8f073122018-11-27 15:58:47 +01002598component_build_no_ssl_cli () {
2599 msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002600 scripts/config.py full
2601 scripts/config.py unset MBEDTLS_SSL_CLI_C
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002602 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
Gilles Peskine8f073122018-11-27 15:58:47 +01002603}
Manuel Pégourié-Gonnard66b8e952015-05-20 11:13:56 +02002604
Gilles Peskine8f073122018-11-27 15:58:47 +01002605component_build_no_sockets () {
2606 # Note, C99 compliance can also be tested with the sockets support disabled,
2607 # as that requires a POSIX platform (which isn't the same as C99).
2608 msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002609 scripts/config.py full
2610 scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
2611 scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
Gilles Peskine6ec0f0f2019-09-20 19:23:10 +02002612 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01002613}
Manuel Pégourié-Gonnard009a2642015-05-29 10:31:13 +02002614
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04002615component_test_memory_buffer_allocator_backtrace () {
2616 msg "build: default config with memory buffer allocator and backtrace enabled"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002617 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2618 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2619 scripts/config.py set MBEDTLS_MEMORY_BACKTRACE
2620 scripts/config.py set MBEDTLS_MEMORY_DEBUG
Gilles Peskineff30bd02021-10-19 21:33:32 +02002621 CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release .
Andrzej Kurek69f20aa2019-09-05 09:27:47 -04002622 make
2623
2624 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE"
2625 make test
2626}
2627
2628component_test_memory_buffer_allocator () {
2629 msg "build: default config with memory buffer allocator"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002630 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2631 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
Gilles Peskineff30bd02021-10-19 21:33:32 +02002632 CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release .
Hanno Becker0fb9ba22019-02-26 14:34:13 +00002633 make
2634
2635 msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C"
2636 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01002637
2638 msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C"
2639 # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002640 tests/ssl-opt.sh -e '^DTLS proxy'
Hanno Becker0fb9ba22019-02-26 14:34:13 +00002641}
2642
Gilles Peskine8f073122018-11-27 15:58:47 +01002643component_test_no_max_fragment_length () {
2644 # Run max fragment length tests with MFL disabled
2645 msg "build: default config except MFL extension (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002646 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
Gilles Peskine8f073122018-11-27 15:58:47 +01002647 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2648 make
Hanno Becker5175ac62017-09-18 15:36:25 +01002649
Gilles Peskine8f073122018-11-27 15:58:47 +01002650 msg "test: ssl-opt.sh, MFL-related tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002651 tests/ssl-opt.sh -f "Max fragment length"
Gilles Peskine8f073122018-11-27 15:58:47 +01002652}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00002653
Hanno Becker545ced42019-02-19 11:10:48 +00002654component_test_asan_remove_peer_certificate () {
2655 msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002656 scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
Hanno Becker545ced42019-02-19 11:10:48 +00002657 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2658 make
2659
2660 msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
2661 make test
2662
2663 msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002664 tests/ssl-opt.sh
Hanno Becker545ced42019-02-19 11:10:48 +00002665
2666 msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002667 tests/compat.sh
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002668
2669 msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002670 tests/context-info.sh
Hanno Becker545ced42019-02-19 11:10:48 +00002671}
2672
Gilles Peskine8f073122018-11-27 15:58:47 +01002673component_test_no_max_fragment_length_small_ssl_out_content_len () {
2674 msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002675 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2676 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
2677 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
Gilles Peskine8f073122018-11-27 15:58:47 +01002678 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2679 make
Angus Grattonc4dd0732018-04-11 16:28:39 +10002680
Gilles Peskine8f073122018-11-27 15:58:47 +01002681 msg "test: MFL tests (disabled MFL extension case) & large packet tests"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002682 tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02002683
2684 msg "test: context-info.sh (disabled MFL extension case)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002685 tests/context-info.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01002686}
Angus Grattonc4dd0732018-04-11 16:28:39 +10002687
Darryl Greenaad82f92019-12-02 10:53:11 +00002688component_test_variable_ssl_in_out_buffer_len () {
2689 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)"
2690 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2691 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2692 make
2693
2694 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
2695 make test
2696
2697 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002698 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002699
2700 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002701 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002702}
2703
2704component_test_variable_ssl_in_out_buffer_len_CID () {
2705 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled (ASan build)"
2706 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2707 scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID
2708
2709 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2710 make
2711
2712 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID"
2713 make test
2714
2715 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002716 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002717
2718 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_DTLS_CONNECTION_ID enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002719 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002720}
2721
2722component_test_variable_ssl_in_out_buffer_len_record_splitting () {
2723 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled (ASan build)"
2724 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
2725 scripts/config.py set MBEDTLS_SSL_CBC_RECORD_SPLITTING
2726
2727 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2728 make
2729
2730 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING"
2731 make test
2732
2733 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002734 tests/ssl-opt.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002735
2736 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH and MBEDTLS_SSL_CBC_RECORD_SPLITTING enabled"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002737 tests/compat.sh
Darryl Greenaad82f92019-12-02 10:53:11 +00002738}
2739
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002740component_test_ssl_alloc_buffer_and_mfl () {
2741 msg "build: default config with memory buffer allocator and MFL extension"
2742 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
2743 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2744 scripts/config.py set MBEDTLS_MEMORY_DEBUG
2745 scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
2746 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
Gilles Peskineff30bd02021-10-19 21:33:32 +02002747 CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release .
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002748 make
2749
2750 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
2751 make test
2752
2753 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002754 tests/ssl-opt.sh -f "Handshake memory usage"
Piotr Nowicki0937ed22019-11-26 16:32:40 +01002755}
2756
Gilles Peskine636c26a2020-03-04 20:46:15 +01002757component_test_when_no_ciphersuites_have_mac () {
2758 msg "build: when no ciphersuites have MAC"
2759 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
2760 scripts/config.py unset MBEDTLS_ARC4_C
2761 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2762 make
2763
2764 msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
2765 make test
2766
2767 msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002768 tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM'
Gilles Peskine636c26a2020-03-04 20:46:15 +01002769}
2770
Gilles Peskine8f073122018-11-27 15:58:47 +01002771component_test_null_entropy () {
2772 msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002773 scripts/config.py set MBEDTLS_TEST_NULL_ENTROPY
2774 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
2775 scripts/config.py set MBEDTLS_ENTROPY_C
2776 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
Gilles Peskine32e889d2020-04-12 23:43:28 +02002777 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002778 scripts/config.py unset MBEDTLS_ENTROPY_HARDWARE_ALT
2779 scripts/config.py unset MBEDTLS_HAVEGE_C
Gilles Peskine5fa32a72019-01-06 19:48:30 +00002780 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON .
Gilles Peskine8f073122018-11-27 15:58:47 +01002781 make
Janos Follath06c54002016-06-09 13:57:40 +01002782
Gilles Peskine8f073122018-11-27 15:58:47 +01002783 msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)"
2784 make test
2785}
Janos Follath06c54002016-06-09 13:57:40 +01002786
Raoul Strackxa4e86142020-06-15 17:03:13 +02002787component_test_no_date_time () {
2788 msg "build: default config without MBEDTLS_HAVE_TIME_DATE"
2789 scripts/config.py unset MBEDTLS_HAVE_TIME_DATE
Gilles Peskine31fdda12021-10-08 11:45:47 +02002790 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check .
Raoul Strackxa4e86142020-06-15 17:03:13 +02002791 make
2792
2793 msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites"
2794 make test
2795}
2796
Andrzej Kurekc890b222023-01-17 04:03:19 -05002797component_test_alt_timing() {
2798 msg "build: alternate timing implementation"
2799 scripts/config.py set MBEDTLS_TIMING_ALT
2800 make lib TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../tests/src/external_timing"
2801
2802 msg "test: MBEDTLS_TIMING_ALT - test suites"
2803 make test TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../tests/src/external_timing"
Andrzej Kurek3a261a42023-01-26 04:33:59 -05002804
2805 msg "selftest - MBEDTLS-TIMING_ALT"
2806 make programs TEST_TIMING_ALT_IMPL=1 CFLAGS="-I../../tests/src/external_timing -I../tests/src/external_timing"
2807 programs/test/selftest
Andrzej Kurekc890b222023-01-17 04:03:19 -05002808}
2809
Gilles Peskine8f073122018-11-27 15:58:47 +01002810component_test_platform_calloc_macro () {
2811 msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02002812 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
2813 scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc
2814 scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free
Gilles Peskine8f073122018-11-27 15:58:47 +01002815 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2816 make
Hanno Beckere5fecec2018-10-11 11:02:52 +01002817
Gilles Peskine8f073122018-11-27 15:58:47 +01002818 msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)"
2819 make test
2820}
Hanno Beckere5fecec2018-10-11 11:02:52 +01002821
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002822component_test_malloc_0_null () {
2823 msg "build: malloc(0) returns NULL (ASan+UBSan build)"
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01002824 scripts/config.py full
Gilles Peskine2e70f1c2023-07-20 19:00:15 +02002825 make CC=gcc CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"$PWD/tests/configs/user-config-malloc-0-null.h\"' $ASAN_CFLAGS -O" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002826
2827 msg "test: malloc(0) returns NULL (ASan+UBSan build)"
2828 make test
2829
2830 msg "selftest: malloc(0) returns NULL (ASan+UBSan build)"
2831 # Just the calloc selftest. "make test" ran the others as part of the
2832 # test suites.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002833 programs/test/selftest calloc
Gilles Peskine765d2402020-02-11 18:26:34 +01002834
2835 msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)"
2836 # Run a subset of the tests. The choice is a balance between coverage
2837 # and time (including time indirectly wasted due to flaky tests).
2838 # The current choice is to skip tests whose description includes
2839 # "proxy", which is an approximation of skipping tests that use the
2840 # UDP proxy, which tend to be slower and flakier.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02002841 tests/ssl-opt.sh -e 'proxy'
Gilles Peskinec4ef7a92019-09-17 19:04:38 +02002842}
2843
Gilles Peskine8f073122018-11-27 15:58:47 +01002844component_test_aes_fewer_tables () {
2845 msg "build: default config with AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002846 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01002847 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002848
Gilles Peskine8f073122018-11-27 15:58:47 +01002849 msg "test: AES_FEWER_TABLES"
2850 make test
2851}
Hanno Becker83ebf782017-07-07 12:29:15 +01002852
Gilles Peskine8f073122018-11-27 15:58:47 +01002853component_test_aes_rom_tables () {
2854 msg "build: default config with AES_ROM_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002855 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01002856 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002857
Gilles Peskine8f073122018-11-27 15:58:47 +01002858 msg "test: AES_ROM_TABLES"
2859 make test
2860}
Hanno Becker83ebf782017-07-07 12:29:15 +01002861
Gilles Peskine8f073122018-11-27 15:58:47 +01002862component_test_aes_fewer_tables_and_rom_tables () {
2863 msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002864 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
2865 scripts/config.py set MBEDTLS_AES_ROM_TABLES
Gilles Peskine8f073122018-11-27 15:58:47 +01002866 make CC=gcc CFLAGS='-Werror -Wall -Wextra'
Hanno Becker83ebf782017-07-07 12:29:15 +01002867
Gilles Peskine8f073122018-11-27 15:58:47 +01002868 msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
2869 make test
2870}
2871
Gilles Peskine592f5912019-10-07 18:49:32 +02002872component_test_ctr_drbg_aes_256_sha_256 () {
2873 msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01002874 scripts/config.py full
2875 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
2876 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02002877 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2878 make
2879
2880 msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
2881 make test
2882}
2883
2884component_test_ctr_drbg_aes_128_sha_512 () {
2885 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01002886 scripts/config.py full
2887 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
2888 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
Gilles Peskine592f5912019-10-07 18:49:32 +02002889 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2890 make
2891
2892 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
2893 make test
2894}
2895
2896component_test_ctr_drbg_aes_128_sha_256 () {
2897 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
Gilles Peskine3b46cd32020-02-18 17:56:33 +01002898 scripts/config.py full
2899 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
2900 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
2901 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
Gilles Peskine592f5912019-10-07 18:49:32 +02002902 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
2903 make
2904
2905 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
2906 make test
2907}
2908
Gilles Peskinef96aefe2019-07-24 14:58:38 +02002909component_test_se_default () {
2910 msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02002911 scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C
Gilles Peskine004206c2019-10-21 17:11:33 +02002912 make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS"
Gilles Peskinef96aefe2019-07-24 14:58:38 +02002913
2914 msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C"
2915 make test
2916}
2917
Steven Cooremand57203d2020-07-16 20:28:59 +02002918component_test_psa_crypto_drivers () {
Steven Cooreman55ae2172020-07-17 19:46:15 +02002919 msg "build: MBEDTLS_PSA_CRYPTO_DRIVERS w/ driver hooks"
Steven Cooreman753f9732021-03-15 11:38:44 +01002920 scripts/config.py full
Steven Cooremand57203d2020-07-16 20:28:59 +02002921 scripts/config.py set MBEDTLS_PSA_CRYPTO_DRIVERS
Steven Cooreman6801f082021-02-19 17:21:22 +01002922 scripts/config.py set MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
Gilles Peskinefe0acc62021-09-20 19:20:04 +02002923 loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL"
2924 loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'"
Ronald Cron17b3afc2020-12-10 18:17:09 +01002925 loc_cflags="${loc_cflags} -I../tests/include -O2"
2926
2927 make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS"
Steven Cooremand57203d2020-07-16 20:28:59 +02002928
Steven Cooreman753f9732021-03-15 11:38:44 +01002929 msg "test: full + MBEDTLS_PSA_CRYPTO_DRIVERS"
Steven Cooremand57203d2020-07-16 20:28:59 +02002930 make test
2931}
2932
Gilles Peskine8f073122018-11-27 15:58:47 +01002933component_test_make_shared () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01002934 msg "build/test: make shared" # ~ 40s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04002935 make SHARED=1 all check
Gilles Peskine56c01612019-07-03 20:43:32 +02002936 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskine27482f12021-11-04 12:52:14 +01002937 programs/test/dlopen_demo.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01002938}
Manuel Pégourié-Gonnard9b06abe2015-06-25 09:56:07 +02002939
Gilles Peskinecf740502019-07-03 20:43:05 +02002940component_test_cmake_shared () {
2941 msg "build/test: cmake shared" # ~ 2min
2942 cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
2943 make
Gilles Peskine56c01612019-07-03 20:43:32 +02002944 ldd programs/util/strerror | grep libmbedcrypto
Gilles Peskinecf740502019-07-03 20:43:05 +02002945 make test
Gilles Peskine27482f12021-11-04 12:52:14 +01002946 programs/test/dlopen_demo.sh
Gilles Peskinecf740502019-07-03 20:43:05 +02002947}
2948
Gilles Peskineec10bf12019-09-20 19:56:06 +02002949test_build_opt () {
2950 info=$1 cc=$2; shift 2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01002951 $cc --version
Gilles Peskineec10bf12019-09-20 19:56:06 +02002952 for opt in "$@"; do
2953 msg "build/test: $cc $opt, $info" # ~ 30s
Gilles Peskinee094a182020-04-14 20:08:41 +02002954 make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror"
Gilles Peskineec10bf12019-09-20 19:56:06 +02002955 # We're confident enough in compilers to not run _all_ the tests,
2956 # but at least run the unit tests. In particular, runs with
2957 # optimizations use inline assembly whereas runs with -O0
2958 # skip inline assembly.
2959 make test # ~30s
2960 make clean
2961 done
2962}
2963
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01002964# For FreeBSD we invoke the function by name so this condition is added
2965# to disable the existing test_clang_opt function for linux.
2966if [[ $(uname) != "Linux" ]]; then
2967 component_test_clang_opt () {
2968 scripts/config.py full
2969 test_build_opt 'full config' clang -O0 -Os -O2
2970 }
2971fi
2972
2973component_test_clang_latest_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01002974 scripts/config.py full
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01002975 test_build_opt 'full config' "$CLANG_LATEST" -O0 -Os -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01002976}
2977support_test_clang_latest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01002978 type "$CLANG_LATEST" >/dev/null 2>/dev/null
Gilles Peskineec10bf12019-09-20 19:56:06 +02002979}
2980
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01002981component_test_clang_earliest_opt () {
Manuel Pégourié-Gonnard68192fc2020-03-04 10:34:47 +01002982 scripts/config.py full
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01002983 test_build_opt 'full config' "$CLANG_EARLIEST" -O0
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01002984}
2985support_test_clang_earliest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01002986 type "$CLANG_EARLIEST" >/dev/null 2>/dev/null
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01002987}
2988
2989component_test_gcc_latest_opt () {
2990 scripts/config.py full
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01002991 test_build_opt 'full config' "$GCC_LATEST" -O0 -Os -O2
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01002992}
2993support_test_gcc_latest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01002994 type "$GCC_LATEST" >/dev/null 2>/dev/null
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01002995}
2996
2997component_test_gcc_earliest_opt () {
2998 scripts/config.py full
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01002999 test_build_opt 'full config' "$GCC_EARLIEST" -O0
Gowtham Suresh Kumar1e3af242023-07-19 08:39:20 +01003000}
3001support_test_gcc_earliest_opt () {
Gowtham Suresh Kumar2afb24f2023-08-01 09:45:57 +01003002 type "$GCC_EARLIEST" >/dev/null 2>/dev/null
Gilles Peskineec10bf12019-09-20 19:56:06 +02003003}
3004
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02003005component_build_mbedtls_config_file () {
3006 msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s
Gilles Peskine6af9dc92022-04-07 20:55:57 +02003007 scripts/config.py -w full_config.h full
Gilles Peskineabf9b4d2019-07-03 20:42:16 +02003008 echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H"
3009 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'"
Gilles Peskine932b30b2022-04-13 23:23:21 +02003010 # Make sure this feature is enabled. We'll disable it in the next phase.
Gilles Peskine036a9bb2022-04-07 21:06:41 +02003011 programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3012 make clean
3013
3014 msg "build: make with MBEDTLS_CONFIG_FILE + MBEDTLS_USER_CONFIG_FILE"
3015 # In the user config, disable one feature (for simplicity, pick a feature
3016 # that nothing else depends on).
3017 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3018 make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"' -DMBEDTLS_USER_CONFIG_FILE='\"user_config.h\"'"
3019 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3020
3021 rm -f user_config.h full_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003022}
3023
Gilles Peskine690a2ef2022-04-07 21:59:14 +02003024component_build_psa_config_file () {
3025 msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE" # ~40s
3026 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
3027 cp "$CRYPTO_CONFIG_H" psa_test_config.h
3028 echo '#error "MBEDTLS_PSA_CRYPTO_CONFIG_FILE is not working"' >"$CRYPTO_CONFIG_H"
3029 make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"'"
Gilles Peskine932b30b2022-04-13 23:23:21 +02003030 # Make sure this feature is enabled. We'll disable it in the next phase.
Gilles Peskine690a2ef2022-04-07 21:59:14 +02003031 programs/test/query_compile_time_config MBEDTLS_CMAC_C
3032 make clean
3033
3034 msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE + MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE" # ~40s
3035 # In the user config, disable one feature, which will reflect on the
3036 # mbedtls configuration so we can query it with query_compile_time_config.
3037 echo '#undef PSA_WANT_ALG_CMAC' >psa_user_config.h
3038 scripts/config.py unset MBEDTLS_CMAC_C
3039 make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"' -DMBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE='\"psa_user_config.h\"'"
3040 not programs/test/query_compile_time_config MBEDTLS_CMAC_C
3041
3042 rm -f psa_test_config.h psa_user_config.h
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003043}
3044
Gilles Peskine8f073122018-11-27 15:58:47 +01003045component_test_m32_o0 () {
Gilles Peskinea0c51fb2021-10-07 19:27:16 +02003046 # Build without optimization, so as to use portable C code (in a 32-bit
3047 # build) and not the i386-specific inline assembly.
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003048 msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003049 scripts/config.py full
Gilles Peskine8fd59422019-10-21 17:11:33 +02003050 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS"
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01003051
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003052 msg "test: i386, make, gcc -O0 (ASan build)"
3053 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01003054}
Gilles Peskine878cf602019-01-06 20:50:38 +00003055support_test_m32_o0 () {
3056 case $(uname -m) in
Pengyu Lva89b3672022-10-21 10:50:26 +00003057 amd64|x86_64) true;;
Gilles Peskine878cf602019-01-06 20:50:38 +00003058 *) false;;
3059 esac
3060}
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003061
Gilles Peskine6fa69862021-10-05 09:36:03 +02003062component_test_m32_o2 () {
3063 # Build with optimization, to use the i386 specific inline assembly
3064 # and go faster for tests.
3065 msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003066 scripts/config.py full
Gilles Peskine6fa69862021-10-05 09:36:03 +02003067 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Simon Butcher8e6a22a2018-07-20 21:27:33 +01003068
Gilles Peskine6fa69862021-10-05 09:36:03 +02003069 msg "test: i386, make, gcc -O2 (ASan build)"
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003070 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01003071
Gilles Peskine6fa69862021-10-05 09:36:03 +02003072 msg "test ssl-opt.sh, i386, make, gcc-O2"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003073 tests/ssl-opt.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01003074}
Gilles Peskine3daa83e2021-10-07 19:25:29 +02003075support_test_m32_o2 () {
Gilles Peskine878cf602019-01-06 20:50:38 +00003076 support_test_m32_o0 "$@"
3077}
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003078
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003079component_test_m32_everest () {
3080 msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003081 scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
3082 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
Gilles Peskine8fd59422019-10-21 17:11:33 +02003083 make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS"
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003084
3085 msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
3086 make test
Gilles Peskine636c26a2020-03-04 20:46:15 +01003087
3088 msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003089 tests/ssl-opt.sh -f ECDH
Gilles Peskine636c26a2020-03-04 20:46:15 +01003090
3091 msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
3092 # Exclude some symmetric ciphers that are redundant here to gain time.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003093 tests/compat.sh -f ECDH -V NO -e 'ARCFOUR\|ARIA\|CAMELLIA\|CHACHA\|DES\|RC4'
Gilles Peskine0c6b7992019-04-12 20:29:48 +02003094}
3095support_test_m32_everest () {
3096 support_test_m32_o0 "$@"
3097}
3098
Gilles Peskine8f073122018-11-27 15:58:47 +01003099component_test_mx32 () {
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003100 msg "build: 64-bit ILP32, make, gcc" # ~ 30s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003101 scripts/config.py full
Gilles Peskine5d26e7c2019-06-07 14:50:09 +02003102 make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32'
Andres Amaya Garciaf4fbdda2017-05-08 11:19:19 +01003103
3104 msg "test: 64-bit ILP32, make, gcc"
3105 make test
Gilles Peskine8f073122018-11-27 15:58:47 +01003106}
Gilles Peskine878cf602019-01-06 20:50:38 +00003107support_test_mx32 () {
3108 case $(uname -m) in
3109 amd64|x86_64) true;;
3110 *) false;;
3111 esac
3112}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003113
Peter Kolbus60c6da22018-12-27 06:59:04 -06003114component_test_min_mpi_window_size () {
3115 msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003116 scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1
Peter Kolbus60c6da22018-12-27 06:59:04 -06003117 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3118 make
3119
3120 msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s
3121 make test
3122}
3123
Gilles Peskine8f073122018-11-27 15:58:47 +01003124component_test_have_int32 () {
3125 msg "build: gcc, force 32-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003126 scripts/config.py unset MBEDTLS_HAVE_ASM
3127 scripts/config.py unset MBEDTLS_AESNI_C
3128 scripts/config.py unset MBEDTLS_PADLOCK_C
Gilles Peskine8f073122018-11-27 15:58:47 +01003129 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
Andres Amaya Garcia84e6ce82017-05-04 11:35:51 +01003130
Gilles Peskine8f073122018-11-27 15:58:47 +01003131 msg "test: gcc, force 32-bit bignum limbs"
3132 make test
3133}
Andres Amaya Garciafe843a32017-07-20 13:21:34 +01003134
Gilles Peskine8f073122018-11-27 15:58:47 +01003135component_test_have_int64 () {
3136 msg "build: gcc, force 64-bit bignum limbs"
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003137 scripts/config.py unset MBEDTLS_HAVE_ASM
3138 scripts/config.py unset MBEDTLS_AESNI_C
3139 scripts/config.py unset MBEDTLS_PADLOCK_C
Gilles Peskine8f073122018-11-27 15:58:47 +01003140 make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
Gilles Peskine14c3c062018-01-29 21:25:12 +01003141
Gilles Peskine8f073122018-11-27 15:58:47 +01003142 msg "test: gcc, force 64-bit bignum limbs"
3143 make test
3144}
Manuel Pégourié-Gonnardedb2dc92015-02-10 14:36:31 +00003145
Gilles Peskine8f073122018-11-27 15:58:47 +01003146component_test_no_udbl_division () {
3147 msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003148 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003149 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskine8f073122018-11-27 15:58:47 +01003150 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003151
Gilles Peskine8f073122018-11-27 15:58:47 +01003152 msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s
3153 make test
3154}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003155
Gilles Peskine8f073122018-11-27 15:58:47 +01003156component_test_no_64bit_multiplication () {
3157 msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003158 scripts/config.py full
Gilles Peskine3bdd4122019-07-27 23:52:53 +02003159 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskine8f073122018-11-27 15:58:47 +01003160 make CFLAGS='-Werror -O1'
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003161
Gilles Peskine8f073122018-11-27 15:58:47 +01003162 msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s
3163 make test
3164}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003165
Gilles Peskine3809f5f2020-11-09 15:40:05 +01003166component_test_no_strings () {
3167 msg "build: no strings" # ~10s
3168 scripts/config.py full
3169 # Disable options that activate a large amount of string constants.
3170 scripts/config.py unset MBEDTLS_DEBUG_C
3171 scripts/config.py unset MBEDTLS_ERROR_C
3172 scripts/config.py set MBEDTLS_ERROR_STRERROR_DUMMY
3173 scripts/config.py unset MBEDTLS_VERSION_FEATURES
3174 make CFLAGS='-Werror -Os'
3175
3176 msg "test: no strings" # ~ 10s
3177 make test
3178}
3179
Gilles Peskine8f073122018-11-27 15:58:47 +01003180component_build_arm_none_eabi_gcc () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003181 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003182 scripts/config.py baremetal
Gilles Peskineaeedd742020-09-02 11:03:04 +02003183 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -O1' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02003184
Gilles Peskine60d99472021-09-01 20:00:33 +02003185 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug"
Gilles Peskine18487f62020-04-30 23:11:54 +02003186 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003187}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003188
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003189component_build_arm_linux_gnueabi_gcc_arm5vte () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003190 msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003191 scripts/config.py baremetal
Gilles Peskine2c897d72019-08-09 16:05:05 +02003192 # Build for a target platform that's close to what Debian uses
3193 # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort).
Dave Rodgman52af7692022-03-31 14:27:24 +01003194 # See https://github.com/Mbed-TLS/mbedtls/pull/2169 and comments.
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003195 # Build everything including programs, see for example
Dave Rodgman52af7692022-03-31 14:27:24 +01003196 # https://github.com/Mbed-TLS/mbedtls/pull/3449#issuecomment-675313720
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003197 make CC="${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc" AR="${ARM_LINUX_GNUEABI_GCC_PREFIX}ar" CFLAGS='-Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te'
3198
Gilles Peskine60d99472021-09-01 20:00:33 +02003199 msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003200 ${ARM_LINUX_GNUEABI_GCC_PREFIX}size library/*.o
3201}
3202support_build_arm_linux_gnueabi_gcc_arm5vte () {
3203 type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1
3204}
3205
3206component_build_arm_none_eabi_gcc_arm5vte () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003207 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s
Manuel Pégourié-Gonnard71930162020-08-18 10:28:51 +02003208 scripts/config.py baremetal
3209 # This is an imperfect substitute for
3210 # component_build_arm_linux_gnueabi_gcc_arm5vte
Manuel Pégourié-Gonnard9a260a62021-07-06 09:44:59 +02003211 # in case the gcc-arm-linux-gnueabi toolchain is not available
Gilles Peskineaeedd742020-09-02 11:03:04 +02003212 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" CFLAGS='-std=c99 -Werror -Wall -Wextra -march=armv5te -O1' LDFLAGS='-march=armv5te' SHELL='sh -x' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02003213
Gilles Peskine60d99472021-09-01 20:00:33 +02003214 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
Gilles Peskine18487f62020-04-30 23:11:54 +02003215 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine93e4e032019-08-05 11:34:25 +02003216}
3217
Gilles Peskine6e2fb862020-04-30 23:00:53 +02003218component_build_arm_none_eabi_gcc_m0plus () {
Gilles Peskine60d99472021-09-01 20:00:33 +02003219 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus, baremetal_size" # ~ 10s
3220 scripts/config.py baremetal_size
Gilles Peskineaeedd742020-09-02 11:03:04 +02003221 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra -mthumb -mcpu=cortex-m0plus -Os' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02003222
Gilles Peskine60d99472021-09-01 20:00:33 +02003223 msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size"
Gilles Peskine18487f62020-04-30 23:11:54 +02003224 ${ARM_NONE_EABI_GCC_PREFIX}size library/*.o
Gilles Peskine6e2fb862020-04-30 23:00:53 +02003225}
3226
Gilles Peskine8f073122018-11-27 15:58:47 +01003227component_build_arm_none_eabi_gcc_no_udbl_division () {
Gilles Peskine6d061342020-04-30 18:19:32 +02003228 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003229 scripts/config.py baremetal
3230 scripts/config.py set MBEDTLS_NO_UDBL_DIVISION
Gilles Peskineaeedd742020-09-02 11:03:04 +02003231 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01003232 echo "Checking that software 64-bit division is not required"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003233 not grep __aeabi_uldiv library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003234}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003235
Gilles Peskine8f073122018-11-27 15:58:47 +01003236component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
Gilles Peskine6d061342020-04-30 18:19:32 +02003237 msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003238 scripts/config.py baremetal
3239 scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION
Gilles Peskineaeedd742020-09-02 11:03:04 +02003240 make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -O1 -march=armv6-m -mthumb' lib
Gilles Peskine8f073122018-11-27 15:58:47 +01003241 echo "Checking that software 64-bit multiplication is not required"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003242 not grep __aeabi_lmul library/*.o
Gilles Peskine8f073122018-11-27 15:58:47 +01003243}
Manuel Pégourié-Gonnard2adb3752018-06-07 10:51:44 +02003244
Dave Rodgman43ea9ab2023-06-02 10:26:24 -04003245component_build_arm_clang_thumb () {
3246 # ~ 30s
3247
3248 scripts/config.py baremetal
3249
3250 msg "build: clang thumb 2, make"
3251 make clean
3252 make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -march=armv7-m -mthumb' lib
3253
3254 # Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os
3255 msg "build: clang thumb 1 -O0, make"
3256 make clean
3257 make CC="clang" CFLAGS='-std=c99 -Werror -O0 --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
3258
3259 msg "build: clang thumb 1 -Os, make"
3260 make clean
3261 make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib
3262}
3263
Gilles Peskine8f073122018-11-27 15:58:47 +01003264component_build_armcc () {
Gilles Peskine18487f62020-04-30 23:11:54 +02003265 msg "build: ARM Compiler 5"
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003266 scripts/config.py baremetal
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003267 make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
Gilles Peskine18487f62020-04-30 23:11:54 +02003268
3269 msg "size: ARM Compiler 5"
3270 "$ARMC5_FROMELF" -z library/*.o
3271
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003272 make clean
Andres AG87bb5772016-09-27 15:05:15 +01003273
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003274 # Compile mostly with -O1 since some Arm inline assembly is disabled for -O0.
3275
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003276 # ARM Compiler 6 - Target ARMv7-A
3277 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
Simon Butcher940737f2017-07-23 13:42:36 +02003278
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003279 # ARM Compiler 6 - Target ARMv7-M
3280 armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
Simon Butcher940737f2017-07-23 13:42:36 +02003281
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003282 # ARM Compiler 6 - Target ARMv8-A - AArch32
3283 armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
Simon Butcher940737f2017-07-23 13:42:36 +02003284
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003285 # ARM Compiler 6 - Target ARMv8-M
3286 armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
Simon Butcher940737f2017-07-23 13:42:36 +02003287
Gilles Peskinebca6ab92017-12-19 18:24:31 +01003288 # ARM Compiler 6 - Target ARMv8-A - AArch64
3289 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003290
3291 # ARM Compiler 6 - Target Cortex-M0 - no optimisation
3292 armc6_build_test "-O0 --target=arm-arm-none-eabi -mcpu=cortex-m0"
3293
3294 # ARM Compiler 6 - Target Cortex-M0
3295 armc6_build_test "-Os --target=arm-arm-none-eabi -mcpu=cortex-m0"
Gilles Peskine8f073122018-11-27 15:58:47 +01003296}
Dave Rodgmanc2e225b2023-06-02 13:54:00 -04003297
Pengyu Lvd216c042023-03-03 18:23:35 +08003298support_build_armcc () {
3299 armc5_cc="$ARMC5_BIN_DIR/armcc"
3300 armc6_cc="$ARMC6_BIN_DIR/armclang"
3301 (check_tools "$armc5_cc" "$armc6_cc" > /dev/null 2>&1)
3302}
Manuel Pégourié-Gonnardc5c59392015-02-10 17:38:54 +01003303
Manuel Pégourié-Gonnarddd8807f2020-02-26 09:56:27 +01003304component_build_ssl_hw_record_accel() {
3305 msg "build: default config with MBEDTLS_SSL_HW_RECORD_ACCEL enabled"
3306 scripts/config.pl set MBEDTLS_SSL_HW_RECORD_ACCEL
3307 make CFLAGS='-Werror -O1'
3308}
3309
Hanno Beckera711f6e2020-05-04 12:03:51 +01003310component_test_tls13_experimental () {
3311 msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
3312 scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
3313 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
3314 make
3315 msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
3316 make test
3317}
3318
Gilles Peskine8f073122018-11-27 15:58:47 +01003319component_build_mingw () {
3320 msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04003321 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
Hanno Beckere963efa2018-01-03 10:03:43 +00003322
Gilles Peskine8f073122018-11-27 15:58:47 +01003323 # note Make tests only builds the tests, but doesn't run them
Andrzej Kurek232e8f92019-10-03 03:18:01 -04003324 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
Gilles Peskine8f073122018-11-27 15:58:47 +01003325 make WINDOWS_BUILD=1 clean
Gilles Peskine2a458da2017-05-12 15:26:58 +02003326
Gilles Peskine8f073122018-11-27 15:58:47 +01003327 msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
Andrzej Kurek232e8f92019-10-03 03:18:01 -04003328 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs
3329 make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests
Gilles Peskine8f073122018-11-27 15:58:47 +01003330 make WINDOWS_BUILD=1 clean
3331}
Jaeden Amero117b8a42019-04-17 15:19:26 +01003332support_build_mingw() {
Pengyu Lva19ce122023-02-24 15:38:52 +08003333 case $(i686-w64-mingw32-gcc -dumpversion 2>/dev/null) in
3334 [0-5]*|"") false;;
Jaeden Amero117b8a42019-04-17 15:19:26 +01003335 *) true;;
3336 esac
3337}
Simon Butcher91aef332016-11-17 09:20:50 +00003338
Gilles Peskine8f073122018-11-27 15:58:47 +01003339component_test_memsan () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003340 msg "build: MSan (clang)" # ~ 1 min 20s
Gilles Peskine5d46f6a2019-07-27 23:52:53 +02003341 scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003342 CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
3343 make
Manuel Pégourié-Gonnard4a9dc2a2014-05-09 13:46:59 +02003344
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003345 msg "test: main suites (MSan)" # ~ 10s
3346 make test
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003347
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003348 msg "test: ssl-opt.sh (MSan)" # ~ 1 min
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003349 tests/ssl-opt.sh
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003350
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003351 # Optional part(s)
Manuel Pégourié-Gonnard9bda9b32014-11-20 13:10:22 +01003352
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003353 if [ "$MEMORY" -gt 0 ]; then
3354 msg "test: compat.sh (MSan)" # ~ 6 min 20s
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003355 tests/compat.sh
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003356 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01003357}
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003358
Gilles Peskine69f190e2019-01-10 00:11:42 +01003359component_test_valgrind () {
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003360 msg "build: Release (clang)"
Gilles Peskine619b73d2022-11-29 16:45:30 +01003361 # default config, in particular without MBEDTLS_USE_PSA_CRYPTO
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003362 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
3363 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003364
Gilles Peskine619b73d2022-11-29 16:45:30 +01003365 msg "test: main suites, Valgrind (default config)"
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003366 make memcheck
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003367
Gilles Peskine636c26a2020-03-04 20:46:15 +01003368 # Optional parts (slow; currently broken on OS X because programs don't
3369 # seem to receive signals under valgrind on OS X).
Gilles Peskine619b73d2022-11-29 16:45:30 +01003370 # These optional parts don't run on the CI.
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003371 if [ "$MEMORY" -gt 0 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003372 msg "test: ssl-opt.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003373 tests/ssl-opt.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003374 fi
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003375
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003376 if [ "$MEMORY" -gt 1 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003377 msg "test: compat.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003378 tests/compat.sh --memcheck
Gilles Peskine7ad603e2017-12-10 23:22:20 +01003379 fi
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02003380
3381 if [ "$MEMORY" -gt 0 ]; then
Gilles Peskine619b73d2022-11-29 16:45:30 +01003382 msg "test: context-info.sh --memcheck (default config)"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003383 tests/context-info.sh --memcheck
Piotr Nowicki9978e6e2020-04-07 16:07:05 +02003384 fi
Gilles Peskine8f073122018-11-27 15:58:47 +01003385}
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003386
Gilles Peskine619b73d2022-11-29 16:45:30 +01003387component_test_valgrind_psa () {
3388 msg "build: Release, full (clang)"
3389 # full config, in particular with MBEDTLS_USE_PSA_CRYPTO
3390 scripts/config.py full
3391 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
3392 make
3393
3394 msg "test: main suites, Valgrind (full config)"
3395 make memcheck
3396}
3397
Paul Elliott2ab9a7a2021-11-25 17:29:40 +00003398support_test_cmake_out_of_source () {
3399 distrib_id=""
3400 distrib_ver=""
3401 distrib_ver_minor=""
3402 distrib_ver_major=""
3403
3404 # Attempt to parse lsb-release to find out distribution and version. If not
3405 # found this should fail safe (test is supported).
3406 if [[ -f /etc/lsb-release ]]; then
3407
3408 while read -r lsb_line; do
3409 case "$lsb_line" in
3410 "DISTRIB_ID"*) distrib_id=${lsb_line/#DISTRIB_ID=};;
3411 "DISTRIB_RELEASE"*) distrib_ver=${lsb_line/#DISTRIB_RELEASE=};;
3412 esac
3413 done < /etc/lsb-release
3414
3415 distrib_ver_major="${distrib_ver%%.*}"
3416 distrib_ver="${distrib_ver#*.}"
3417 distrib_ver_minor="${distrib_ver%%.*}"
3418 fi
3419
3420 # Running the out of source CMake test on Ubuntu 16.04 using more than one
3421 # processor (as the CI does) can create a race condition whereby the build
3422 # fails to see a generated file, despite that file actually having been
3423 # generated. This problem appears to go away with 18.04 or newer, so make
3424 # the out of source tests unsupported on Ubuntu 16.04.
3425 [ "$distrib_id" != "Ubuntu" ] || [ "$distrib_ver_major" -gt 16 ]
3426}
3427
Gilles Peskine8f073122018-11-27 15:58:47 +01003428component_test_cmake_out_of_source () {
3429 msg "build: cmake 'out-of-source' build"
Gilles Peskine8f073122018-11-27 15:58:47 +01003430 MBEDTLS_ROOT_DIR="$PWD"
3431 mkdir "$OUT_OF_SOURCE_DIR"
3432 cd "$OUT_OF_SOURCE_DIR"
Gilles Peskine25319702021-10-07 19:34:57 +02003433 cmake -D CMAKE_BUILD_TYPE:String=Check "$MBEDTLS_ROOT_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +01003434 make
Manuel Pégourié-Gonnard392d3dd2015-01-26 14:03:56 +00003435
Gilles Peskine8f073122018-11-27 15:58:47 +01003436 msg "test: cmake 'out-of-source' build"
3437 make test
3438 # Test an SSL option that requires an auxiliary script in test/scripts/.
3439 # Also ensure that there are no error messages such as
3440 # "No such file or directory", which would indicate that some required
3441 # file is missing (ssl-opt.sh tolerates the absence of some files so
3442 # may exit with status 0 but emit errors).
Gilles Peskinee8133cb2022-04-15 22:43:38 +02003443 ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' >ssl-opt.out 2>ssl-opt.err
3444 grep PASS ssl-opt.out
Gilles Peskine0a7984f2020-03-28 18:56:09 +01003445 cat ssl-opt.err >&2
3446 # If ssl-opt.err is non-empty, record an error and keep going.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003447 [ ! -s ssl-opt.err ]
Gilles Peskinee8133cb2022-04-15 22:43:38 +02003448 rm ssl-opt.out ssl-opt.err
Gilles Peskine8f073122018-11-27 15:58:47 +01003449 cd "$MBEDTLS_ROOT_DIR"
3450 rm -rf "$OUT_OF_SOURCE_DIR"
Gilles Peskine8f073122018-11-27 15:58:47 +01003451}
Andres AGdc192212016-08-31 17:33:13 +01003452
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003453component_test_cmake_as_subdirectory () {
3454 msg "build: cmake 'as-subdirectory' build"
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003455 cd programs/test/cmake_subproject
3456 cmake .
3457 make
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003458 ./cmake_subproject
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003459}
Gilles Peskineca9cfca2022-02-04 00:21:12 +01003460support_test_cmake_as_subdirectory () {
3461 support_test_cmake_out_of_source
3462}
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01003463
David Horstmann175afbd2023-01-12 14:17:01 +00003464component_build_cmake_custom_config_file () {
David Horstmann67622312023-01-31 10:34:44 +00003465 # Make a copy of config file to use for the in-tree test
3466 cp "$CONFIG_H" include/mbedtls_config_in_tree_copy.h
David Horstmann175afbd2023-01-12 14:17:01 +00003467
3468 MBEDTLS_ROOT_DIR="$PWD"
3469 mkdir "$OUT_OF_SOURCE_DIR"
3470 cd "$OUT_OF_SOURCE_DIR"
3471
David Horstmann67622312023-01-31 10:34:44 +00003472 # Build once to get the generated files (which need an intact config file)
David Horstmann175afbd2023-01-12 14:17:01 +00003473 cmake "$MBEDTLS_ROOT_DIR"
3474 make
3475
3476 msg "build: cmake with -DMBEDTLS_CONFIG_FILE"
3477 scripts/config.py -w full_config.h full
David Horstmann67622312023-01-31 10:34:44 +00003478 echo '#error "cmake -DMBEDTLS_CONFIG_FILE is not working."' > "$MBEDTLS_ROOT_DIR/$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003479 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h "$MBEDTLS_ROOT_DIR"
3480 make
3481
3482 msg "build: cmake with -DMBEDTLS_CONFIG_FILE + -DMBEDTLS_USER_CONFIG_FILE"
3483 # In the user config, disable one feature (for simplicity, pick a feature
3484 # that nothing else depends on).
3485 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3486
3487 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h -DMBEDTLS_USER_CONFIG_FILE=user_config.h "$MBEDTLS_ROOT_DIR"
3488 make
3489 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3490
3491 rm -f user_config.h full_config.h
3492
3493 cd "$MBEDTLS_ROOT_DIR"
3494 rm -rf "$OUT_OF_SOURCE_DIR"
3495
3496 # Now repeat the test for an in-tree build:
3497
David Horstmann67622312023-01-31 10:34:44 +00003498 # Restore config for the in-tree test
3499 mv include/mbedtls_config_in_tree_copy.h "$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003500
David Horstmann67622312023-01-31 10:34:44 +00003501 # Build once to get the generated files (which need an intact config)
David Horstmann175afbd2023-01-12 14:17:01 +00003502 cmake .
3503 make
3504
3505 msg "build: cmake (in-tree) with -DMBEDTLS_CONFIG_FILE"
3506 scripts/config.py -w full_config.h full
David Horstmann67622312023-01-31 10:34:44 +00003507 echo '#error "cmake -DMBEDTLS_CONFIG_FILE is not working."' > "$MBEDTLS_ROOT_DIR/$CONFIG_H"
David Horstmann175afbd2023-01-12 14:17:01 +00003508 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h .
3509 make
3510
3511 msg "build: cmake (in-tree) with -DMBEDTLS_CONFIG_FILE + -DMBEDTLS_USER_CONFIG_FILE"
3512 # In the user config, disable one feature (for simplicity, pick a feature
3513 # that nothing else depends on).
3514 echo '#undef MBEDTLS_NIST_KW_C' >user_config.h
3515
3516 cmake -DGEN_FILES=OFF -DMBEDTLS_CONFIG_FILE=full_config.h -DMBEDTLS_USER_CONFIG_FILE=user_config.h .
3517 make
3518 not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C
3519
3520 rm -f user_config.h full_config.h
3521}
3522support_build_cmake_custom_config_file () {
3523 support_test_cmake_out_of_source
3524}
3525
3526
Gilles Peskine8f073122018-11-27 15:58:47 +01003527component_test_zeroize () {
3528 # Test that the function mbedtls_platform_zeroize() is not optimized away by
3529 # different combinations of compilers and optimization flags by using an
3530 # auxiliary GDB script. Unfortunately, GDB does not return error values to the
3531 # system in all cases that the script fails, so we must manually search the
3532 # output to check whether the pass string is present and no failure strings
3533 # were printed.
Andres AGdc192212016-08-31 17:33:13 +01003534
Gilles Peskine4976e822019-01-06 19:52:22 +00003535 # Don't try to disable ASLR. We don't care about ASLR here. We do care
3536 # about a spurious message if Gdb tries and fails, so suppress that.
3537 gdb_disable_aslr=
3538 if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then
3539 gdb_disable_aslr='set disable-randomization off'
3540 fi
3541
Gilles Peskine8f073122018-11-27 15:58:47 +01003542 for optimization_flag in -O2 -O3 -Ofast -Os; do
Gilles Peskine55f7c942019-01-09 22:28:21 +01003543 for compiler in clang gcc; do
3544 msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()"
3545 make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003546 gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log
3547 grep "The buffer was correctly zeroized" test_zeroize.log
3548 not grep -i "error" test_zeroize.log
Gilles Peskine55f7c942019-01-09 22:28:21 +01003549 rm -f test_zeroize.log
3550 make clean
3551 done
Andres Amaya Garcia29673812017-10-25 10:35:51 +01003552 done
Gilles Peskine8f073122018-11-27 15:58:47 +01003553}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003554
Bence Szépkúti9f849112021-10-19 15:05:36 +02003555component_test_psa_compliance () {
Bence Szépkútic1e79fd2021-11-11 20:13:14 +01003556 msg "build: make, default config + CMAC, libmbedcrypto.a only"
3557 scripts/config.py set MBEDTLS_CMAC_C
Bence Szépkútiab796e62021-10-25 19:29:07 +02003558 make -C library libmbedcrypto.a
Bence Szépkúti9f849112021-10-19 15:05:36 +02003559
3560 msg "unit test: test_psa_compliance.py"
3561 ./tests/scripts/test_psa_compliance.py
3562}
3563
3564support_test_psa_compliance () {
Bence Szépkútid6cf0892021-11-03 11:36:09 +01003565 # psa-compliance-tests only supports CMake >= 3.10.0
Bence Szépkútiab796e62021-10-25 19:29:07 +02003566 ver="$(cmake --version)"
3567 ver="${ver#cmake version }"
3568 ver_major="${ver%%.*}"
3569
3570 ver="${ver#*.}"
3571 ver_minor="${ver%%.*}"
3572
3573 [ "$ver_major" -eq 3 ] && [ "$ver_minor" -ge 10 ]
Bence Szépkúti9f849112021-10-19 15:05:36 +02003574}
3575
Gilles Peskineb9e56fb2022-12-09 12:23:35 +01003576component_check_code_style () {
3577 msg "Check C code style"
3578 ./scripts/code_style.py
David Horstmanne09c4762022-11-10 18:30:52 +00003579}
3580
Gilles Peskineb9e56fb2022-12-09 12:23:35 +01003581support_check_code_style() {
David Horstmanne09c4762022-11-10 18:30:52 +00003582 case $(uncrustify --version) in
3583 *0.75.1*) true;;
3584 *) false;;
3585 esac
3586}
3587
Gilles Peskine8f073122018-11-27 15:58:47 +01003588component_check_python_files () {
3589 msg "Lint: Python scripts"
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003590 tests/scripts/check-python-files.sh
Gilles Peskine8f073122018-11-27 15:58:47 +01003591}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003592
Gilles Peskine8f073122018-11-27 15:58:47 +01003593component_check_generate_test_code () {
3594 msg "uint test: generate_test_code.py"
Manuel Pégourié-Gonnarddfb114a2020-06-02 11:40:08 +02003595 # unittest writes out mundane stuff like number or tests run on stderr.
3596 # Our convention is to reserve stderr for actual errors, and write
3597 # harmless info on stdout so it can be suppress with --quiet.
Gilles Peskinef6d29c62021-07-08 18:41:16 +02003598 ./tests/scripts/test_generate_test_code.py 2>&1
Gilles Peskine8f073122018-11-27 15:58:47 +01003599}
Gilles Peskine192c72f2017-12-21 15:59:21 +01003600
3601################################################################
3602#### Termination
3603################################################################
3604
Gilles Peskine8f073122018-11-27 15:58:47 +01003605post_report () {
3606 msg "Done, cleaning up"
Gilles Peskine24bdf022020-03-30 20:11:39 +02003607 final_cleanup
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003608
Gilles Peskine8f073122018-11-27 15:58:47 +01003609 final_report
3610}
3611
3612
3613
3614################################################################
3615#### Run all the things
3616################################################################
3617
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003618# Function invoked by --error-test to test error reporting.
3619pseudo_component_error_test () {
Gilles Peskine202e9b42021-08-02 23:28:00 +02003620 msg "Testing error reporting $error_test_i"
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003621 if [ $KEEP_GOING -ne 0 ]; then
3622 echo "Expect three failing commands."
3623 fi
Gilles Peskine202e9b42021-08-02 23:28:00 +02003624 # If the component doesn't run in a subshell, changing error_test_i to an
3625 # invalid integer will cause an error in the loop that runs this function.
3626 error_test_i=this_should_not_be_used_since_the_component_runs_in_a_subshell
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003627 # Expected error: 'grep non_existent /dev/null -> 1'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003628 grep non_existent /dev/null
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003629 # Expected error: '! grep -q . tests/scripts/all.sh -> 1'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003630 not grep -q . "$0"
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003631 # Expected error: 'make unknown_target -> 2'
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003632 make unknown_target
3633 false "this should not be executed"
3634}
3635
Gilles Peskinee48351a2018-11-27 16:06:30 +01003636# Run one component and clean up afterwards.
Gilles Peskine8f073122018-11-27 15:58:47 +01003637run_component () {
Gilles Peskineffcdeff2018-12-04 12:49:28 +01003638 current_component="$1"
Gilles Peskine9004a172019-09-16 15:20:36 +02003639 export MBEDTLS_TEST_CONFIGURATION="$current_component"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003640
3641 # Unconditionally create a seedfile that's sufficiently long.
3642 # Do this before each component, because a previous component may
3643 # have messed it up or shortened it.
Gilles Peskinef3133362021-07-08 19:03:50 +02003644 local dd_cmd
3645 dd_cmd=(dd if=/dev/urandom of=./tests/seedfile bs=64 count=1)
3646 case $OSTYPE in
3647 linux*|freebsd*|openbsd*|darwin*) dd_cmd+=(status=none)
3648 esac
3649 "${dd_cmd[@]}"
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003650
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003651 # Run the component in a subshell, with error trapping and output
3652 # redirection set up based on the relevant options.
Gilles Peskine7105a332020-03-28 18:50:43 +01003653 if [ $KEEP_GOING -eq 1 ]; then
Gilles Peskinecb4bfac2021-08-02 23:14:03 +02003654 # We want to keep running if the subshell fails, so 'set -e' must
3655 # be off when the subshell runs.
Gilles Peskine7105a332020-03-28 18:50:43 +01003656 set +e
Manuel Pégourié-Gonnard2b2bdaa2020-06-02 11:28:07 +02003657 fi
Gilles Peskine7105a332020-03-28 18:50:43 +01003658 (
3659 if [ $QUIET -eq 1 ]; then
3660 # msg() will be silenced, so just print the component name here.
3661 echo "${current_component#component_}"
3662 exec >/dev/null
3663 fi
3664 if [ $KEEP_GOING -eq 1 ]; then
3665 # Keep "set -e" off, and run an ERR trap instead to record failures.
3666 set -E
3667 trap err_trap ERR
3668 fi
3669 # The next line is what runs the component
3670 "$@"
3671 if [ $KEEP_GOING -eq 1 ]; then
3672 trap - ERR
3673 exit $last_failure_status
3674 fi
3675 )
3676 component_status=$?
3677 if [ $KEEP_GOING -eq 1 ]; then
3678 set -e
3679 if [ $component_status -ne 0 ]; then
3680 failure_count=$((failure_count + 1))
3681 fi
3682 fi
Gilles Peskine2ef377d2019-10-07 18:44:21 +02003683
3684 # Restore the build tree to a clean state.
Gilles Peskinee48351a2018-11-27 16:06:30 +01003685 cleanup
Manuel Pégourié-Gonnard304b0992020-06-08 10:59:41 +02003686 unset current_component
Gilles Peskine8f073122018-11-27 15:58:47 +01003687}
3688
3689# Preliminary setup
3690pre_check_environment
3691pre_initialize_variables
3692pre_parse_command_line "$@"
Gilles Peskine348fb9a2018-11-27 17:04:29 +01003693
Gilles Peskine878cf602019-01-06 20:50:38 +00003694pre_check_git
Gilles Peskineef64e7f2021-07-12 18:16:01 +02003695pre_restore_files
Gilles Peskine24bdf022020-03-30 20:11:39 +02003696pre_back_up
Andrzej Kurekeb508712019-02-14 07:18:59 -05003697
Gilles Peskine878cf602019-01-06 20:50:38 +00003698build_status=0
3699if [ $KEEP_GOING -eq 1 ]; then
3700 pre_setup_keep_going
Gilles Peskine8f073122018-11-27 15:58:47 +01003701fi
Gilles Peskine67ffdaf2019-09-16 15:55:46 +02003702pre_prepare_outcome_file
Gilles Peskine878cf602019-01-06 20:50:38 +00003703pre_print_configuration
3704pre_check_tools
Manuel Pégourié-Gonnard80955ee2014-03-19 18:29:01 +01003705cleanup
3706
Gilles Peskinebeb3a812019-01-06 22:11:25 +00003707# Run the requested tests.
Gilles Peskine202e9b42021-08-02 23:28:00 +02003708for ((error_test_i=1; error_test_i <= error_test; error_test_i++)); do
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003709 run_component pseudo_component_error_test
Gilles Peskinea5eb22d2020-03-28 21:09:21 +01003710done
Gilles Peskine202e9b42021-08-02 23:28:00 +02003711unset error_test_i
Gilles Peskinebeb3a812019-01-06 22:11:25 +00003712for component in $RUN_COMPONENTS; do
3713 run_component "component_$component"
3714done
Gilles Peskine8f073122018-11-27 15:58:47 +01003715
3716# We're done.
Gilles Peskine878cf602019-01-06 20:50:38 +00003717post_report