Gilles Peskine | 62cf2e8 | 2020-03-27 16:35:23 +0100 | [diff] [blame] | 1 | #! /usr/bin/env bash |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2 | |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 3 | # all.sh |
| 4 | # |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 5 | # Copyright The Mbed TLS Contributors |
Bence Szépkúti | c7da1fe | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 6 | # 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 Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 19 | |
| 20 | |
| 21 | |
| 22 | ################################################################ |
| 23 | #### Documentation |
| 24 | ################################################################ |
| 25 | |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 26 | # Purpose |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 27 | # ------- |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 28 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 29 | # To run all tests possible or available on the platform. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 30 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 31 | # Notes for users |
| 32 | # --------------- |
| 33 | # |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 34 | # Warning: the test is destructive. It includes various build modes and |
| 35 | # configurations, and can and will arbitrarily change the current CMake |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 36 | # configuration. The following files must be committed into git: |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 37 | # * include/mbedtls/mbedtls_config.h |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 38 | # * Makefile, library/Makefile, programs/Makefile, tests/Makefile, |
| 39 | # programs/fuzz/Makefile |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 40 | # After running this script, the CMake cache will be lost and CMake |
| 41 | # will no longer be initialised. |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 42 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 43 | # 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 Kurek | 05be06c | 2018-06-28 04:41:50 -0400 | [diff] [blame] | 50 | # * G++ |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 51 | # * arm-gcc and mingw-gcc |
| 52 | # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 53 | # * OpenSSL and GnuTLS command line tools, recent enough for the |
Mateusz Starzyk | f5c5351 | 2021-04-15 13:28:52 +0200 | [diff] [blame] | 54 | # interoperability tests. If they don't support old features which we want |
| 55 | # to test, then a legacy version of these tools must be present as well |
| 56 | # (search for LEGACY below). |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 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 Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 62 | # 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 Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 71 | # 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 Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 79 | # 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 Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 83 | # * 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 Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 86 | # * support_XXX: if support_XXX exists and returns false then |
| 87 | # component_XXX is not run by default. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 88 | # * post_XXX: things to do after running the tests. |
| 89 | # * other: miscellaneous support functions. |
| 90 | # |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 91 | # Each component must start by invoking `msg` with a short informative message. |
| 92 | # |
Gilles Peskine | a681c59 | 2020-03-28 21:27:40 +0100 | [diff] [blame] | 93 | # 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 Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 96 | # 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 Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 99 | # 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`. |
Bence Szépkúti | 414d6bd | 2021-06-28 14:11:11 +0100 | [diff] [blame] | 103 | # * Restore `include/mbedtls/mbedtls_config.h` from a backup made before running |
Gilles Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 104 | # the component. |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 105 | # * 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 Peskine | c70637a | 2019-01-09 22:29:17 +0100 | [diff] [blame] | 108 | # |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 109 | # 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 Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 112 | |
| 113 | |
| 114 | |
| 115 | ################################################################ |
| 116 | #### Initialization and command line parsing |
| 117 | ################################################################ |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 118 | |
Gilles Peskine | 3664780 | 2020-03-28 18:50:49 +0100 | [diff] [blame] | 119 | # Abort on errors (even on the left-hand side of a pipe). |
| 120 | # Treat uninitialised variables as errors. |
| 121 | set -e -o pipefail -u |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 122 | |
Gilles Peskine | 076f725 | 2022-08-30 21:02:44 +0200 | [diff] [blame] | 123 | # Enable ksh/bash extended file matching patterns |
| 124 | shopt -s extglob |
| 125 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 126 | pre_check_environment () { |
Gilles Peskine | a16c2b1 | 2019-01-06 19:58:02 +0000 | [diff] [blame] | 127 | if [ -d library -a -d include -a -d tests ]; then :; else |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 128 | echo "Must be run from mbed TLS root" >&2 |
| 129 | exit 1 |
| 130 | fi |
| 131 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 132 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 133 | pre_initialize_variables () { |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 134 | CONFIG_H='include/mbedtls/mbedtls_config.h' |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 135 | CRYPTO_CONFIG_H='include/psa/crypto_config.h' |
Manuel Pégourié-Gonnard | 462e3a9 | 2022-12-27 12:35:11 +0100 | [diff] [blame] | 136 | CONFIG_TEST_DRIVER_H='tests/include/test/drivers/config_test_driver.h' |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 137 | |
| 138 | # Files that are clobbered by some jobs will be backed up. Use a different |
| 139 | # suffix from auxiliary scripts so that all.sh and auxiliary scripts can |
| 140 | # independently decide when to remove the backup file. |
| 141 | backup_suffix='.all.bak' |
| 142 | # Files clobbered by config.py |
Manuel Pégourié-Gonnard | 462e3a9 | 2022-12-27 12:35:11 +0100 | [diff] [blame] | 143 | files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H $CONFIG_TEST_DRIVER_H" |
Gilles Peskine | 568f53a | 2021-07-12 18:16:01 +0200 | [diff] [blame] | 144 | # Files clobbered by in-tree cmake |
| 145 | files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile" |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 146 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 147 | append_outcome=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 148 | MEMORY=0 |
| 149 | FORCE=0 |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 150 | QUIET=0 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 151 | KEEP_GOING=0 |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 152 | |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 153 | # Seed value used with the --release-test option. |
Manuel Pégourié-Gonnard | 5430447 | 2020-06-22 10:11:47 +0200 | [diff] [blame] | 154 | # |
| 155 | # See also RELEASE_SEED in basic-build-test.sh. Debugging is easier if |
| 156 | # both values are kept in sync. If you change the value here because it |
| 157 | # breaks some tests, you'll definitely want to change it in |
| 158 | # basic-build-test.sh as well. |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 159 | RELEASE_SEED=1 |
| 160 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 161 | : ${MBEDTLS_TEST_OUTCOME_FILE=} |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 162 | : ${MBEDTLS_TEST_PLATFORM="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"} |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 163 | export MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 164 | export MBEDTLS_TEST_PLATFORM |
| 165 | |
Jaeden Amero | c4cc251 | 2019-01-30 15:35:44 +0000 | [diff] [blame] | 166 | # Default commands, can be overridden by the environment |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 167 | : ${OPENSSL:="openssl"} |
| 168 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 169 | : ${OPENSSL_NEXT:="$OPENSSL"} |
| 170 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 171 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 172 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 173 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 174 | : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} |
| 175 | : ${ARMC5_BIN_DIR:=/usr/bin} |
| 176 | : ${ARMC6_BIN_DIR:=/usr/bin} |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 177 | : ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-} |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 178 | : ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-} |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 179 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 180 | # if MAKEFLAGS is not set add the -j option to speed up invocations of make |
Gilles Peskine | a1fc4b5 | 2019-01-06 20:15:26 +0000 | [diff] [blame] | 181 | if [ -z "${MAKEFLAGS+set}" ]; then |
Gilles Peskine | 050d2fc | 2021-09-30 18:24:21 +0200 | [diff] [blame] | 182 | export MAKEFLAGS="-j$(all_sh_nproc)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 183 | fi |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 184 | |
Gilles Peskine | 396853a | 2021-09-20 18:57:55 +0200 | [diff] [blame] | 185 | # Include more verbose output for failing tests run by CMake or make |
Jaeden Amero | d48e9c7 | 2019-02-07 17:43:39 +0000 | [diff] [blame] | 186 | export CTEST_OUTPUT_ON_FAILURE=1 |
| 187 | |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 188 | # CFLAGS and LDFLAGS for Asan builds that don't use CMake |
Manuel Pégourié-Gonnard | fe549a7 | 2022-11-30 10:42:03 +0100 | [diff] [blame] | 189 | # default to -O2, use -Ox _after_ this if you want another level |
Przemek Stekiel | 6efa608 | 2023-05-31 09:38:21 +0200 | [diff] [blame] | 190 | ASAN_CFLAGS='-O2 -Werror -fsanitize=address,undefined -fno-sanitize-recover=all' |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 191 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 192 | # Gather the list of available components. These are the functions |
| 193 | # defined in this script whose name starts with "component_". |
Gilles Peskine | 62cf2e8 | 2020-03-27 16:35:23 +0100 | [diff] [blame] | 194 | # Parse the script with sed. This way we get the functions in the order |
| 195 | # they are defined. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 196 | ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") |
| 197 | |
| 198 | # Exclude components that are not supported on this platform. |
| 199 | SUPPORTED_COMPONENTS= |
| 200 | for component in $ALL_COMPONENTS; do |
| 201 | case $(type "support_$component" 2>&1) in |
| 202 | *' function'*) |
| 203 | if ! support_$component; then continue; fi;; |
| 204 | esac |
| 205 | SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" |
| 206 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 207 | } |
Andres AG | 38495a3 | 2016-07-12 16:54:33 +0100 | [diff] [blame] | 208 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 209 | # Test whether the component $1 is included in the command line patterns. |
| 210 | is_component_included() |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 211 | { |
Gilles Peskine | 03af678 | 2021-08-06 11:35:17 +0200 | [diff] [blame] | 212 | # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS |
| 213 | # only does word splitting. |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 214 | set -f |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 215 | for pattern in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 81b96ed | 2018-11-27 21:37:53 +0100 | [diff] [blame] | 216 | set +f |
| 217 | case ${1#component_} in $pattern) return 0;; esac |
| 218 | done |
| 219 | set +f |
| 220 | return 1 |
| 221 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 222 | |
Simon Butcher | 41eeccf | 2016-09-07 00:07:09 +0100 | [diff] [blame] | 223 | usage() |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 224 | { |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 225 | cat <<EOF |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 226 | Usage: $0 [OPTION]... [COMPONENT]... |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 227 | Run mbedtls release validation tests. |
Gilles Peskine | 9252511 | 2018-11-27 18:15:35 +0100 | [diff] [blame] | 228 | By default, run all tests. With one or more COMPONENT, run only those. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 229 | COMPONENT can be the name of a component or a shell wildcard pattern. |
| 230 | |
| 231 | Examples: |
| 232 | $0 "check_*" |
| 233 | Run all sanity checks. |
| 234 | $0 --no-armcc --except test_memsan |
| 235 | Run everything except builds that require armcc and MemSan. |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 236 | |
| 237 | Special options: |
| 238 | -h|--help Print this help and exit. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 239 | --list-all-components List all available test components and exit. |
| 240 | --list-components List components supported on this platform and exit. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 241 | |
| 242 | General options: |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 243 | -q|--quiet Only output component names, and errors if any. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 244 | -f|--force Force the tests to overwrite any modified files. |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 245 | -k|--keep-going Run all tests and report errors at the end. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 246 | -m|--memory Additional optional memory tests. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 247 | --append-outcome Append to the outcome file (if used). |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 248 | --arm-none-eabi-gcc-prefix=<string> |
| 249 | Prefix for a cross-compiler for arm-none-eabi |
| 250 | (default: "${ARM_NONE_EABI_GCC_PREFIX}") |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 251 | --arm-linux-gnueabi-gcc-prefix=<string> |
| 252 | Prefix for a cross-compiler for arm-linux-gnueabi |
| 253 | (default: "${ARM_LINUX_GNUEABI_GCC_PREFIX}") |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 254 | --armcc Run ARM Compiler builds (on by default). |
Gilles Peskine | 80ddb99 | 2021-08-06 11:51:59 +0200 | [diff] [blame] | 255 | --restore First clean up the build tree, restoring backed up |
| 256 | files. Do not run any components unless they are |
| 257 | explicitly specified. |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 258 | --error-test Error test mode: run a failing function in addition |
Gilles Peskine | 86f6129 | 2021-08-05 15:11:33 +0200 | [diff] [blame] | 259 | to any specified component. May be repeated. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 260 | --except Exclude the COMPONENTs listed on the command line, |
| 261 | instead of running only those. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 262 | --no-append-outcome Write a new outcome file and analyze it (default). |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 263 | --no-armcc Skip ARM Compiler builds. |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 264 | --no-force Refuse to overwrite modified files (default). |
| 265 | --no-keep-going Stop at the first error (default). |
| 266 | --no-memory No additional memory tests (default). |
Shaun Case | 8b0ecbc | 2021-12-20 21:14:10 -0800 | [diff] [blame] | 267 | --no-quiet Print full output from components. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 268 | --out-of-source-dir=<path> Directory used for CMake out-of-source build tests. |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 269 | --outcome-file=<path> File where test outcomes are written (not done if |
| 270 | empty; default: \$MBEDTLS_TEST_OUTCOME_FILE). |
Gilles Peskine | 38d8165 | 2018-03-21 08:40:26 +0100 | [diff] [blame] | 271 | --random-seed Use a random seed value for randomized tests (default). |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 272 | -r|--release-test Run this script in release mode. This fixes the seed value to ${RELEASE_SEED}. |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 273 | -s|--seed Integer seed value to use for this test run. |
| 274 | |
| 275 | Tool path options: |
| 276 | --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory. |
| 277 | --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory. |
| 278 | --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests. |
| 279 | --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests. |
| 280 | --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests. |
| 281 | --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests. |
| 282 | --openssl=<OpenSSL_path> OpenSSL executable to use for most tests. |
Mateusz Starzyk | 06b07fb | 2021-02-18 13:55:21 +0100 | [diff] [blame] | 283 | --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests.. |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 284 | --openssl-next=<OpenSSL_path> OpenSSL executable to use for recent things like ARIA |
Gilles Peskine | 709346a | 2017-12-10 23:43:39 +0100 | [diff] [blame] | 285 | EOF |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 286 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 287 | |
Gilles Peskine | bf66e2c | 2021-08-03 13:44:28 +0200 | [diff] [blame] | 288 | # Cleanup before/after running a component. |
| 289 | # Remove built files as well as the cmake cache/config. |
| 290 | # Does not remove generated source files. |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 291 | cleanup() |
| 292 | { |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 293 | command make clean |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 294 | |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 295 | # Remove CMake artefacts |
Jaeden Amero | 2d0e00f | 2018-11-07 18:46:41 +0000 | [diff] [blame] | 296 | find . -name .git -prune -o \ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 297 | -iname CMakeFiles -exec rm -rf {} \+ -o \ |
| 298 | \( -iname cmake_install.cmake -o \ |
| 299 | -iname CTestTestfile.cmake -o \ |
Manuel Pégourié-Gonnard | bfe54d7 | 2021-09-09 11:11:44 +0200 | [diff] [blame] | 300 | -iname CMakeCache.txt -o \ |
| 301 | -path './cmake/*.cmake' \) -exec rm -f {} \+ |
Gilles Peskine | 31b07e2 | 2018-03-21 12:15:06 +0100 | [diff] [blame] | 302 | # Recover files overwritten by in-tree CMake builds |
Gilles Peskine | 076f725 | 2022-08-30 21:02:44 +0200 | [diff] [blame] | 303 | rm -f include/Makefile include/mbedtls/Makefile programs/!(fuzz)/Makefile |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 304 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 305 | # Remove any artifacts from the component_test_cmake_as_subdirectory test. |
| 306 | rm -rf programs/test/cmake_subproject/build |
| 307 | rm -f programs/test/cmake_subproject/Makefile |
| 308 | rm -f programs/test/cmake_subproject/cmake_subproject |
| 309 | |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 310 | # Remove any artifacts from the component_test_cmake_as_package test. |
| 311 | rm -rf programs/test/cmake_package/build |
| 312 | rm -f programs/test/cmake_package/Makefile |
| 313 | rm -f programs/test/cmake_package/cmake_package |
| 314 | |
| 315 | # Remove any artifacts from the component_test_cmake_as_installed_package test. |
| 316 | rm -rf programs/test/cmake_package_install/build |
| 317 | rm -f programs/test/cmake_package_install/Makefile |
| 318 | rm -f programs/test/cmake_package_install/cmake_package_install |
| 319 | |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 320 | # Restore files that may have been clobbered by the job |
| 321 | for x in $files_to_back_up; do |
Gilles Peskine | dd06efb | 2022-08-30 21:02:00 +0200 | [diff] [blame] | 322 | if [[ -e "$x$backup_suffix" ]]; then |
| 323 | cp -p "$x$backup_suffix" "$x" |
| 324 | fi |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 325 | done |
| 326 | } |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 327 | |
Gilles Peskine | bf66e2c | 2021-08-03 13:44:28 +0200 | [diff] [blame] | 328 | # Final cleanup when this script exits (except when exiting on a failure |
| 329 | # in non-keep-going mode). |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 330 | final_cleanup () { |
| 331 | cleanup |
| 332 | |
| 333 | for x in $files_to_back_up; do |
| 334 | rm -f "$x$backup_suffix" |
| 335 | done |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 336 | } |
| 337 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 338 | # Executed on exit. May be redefined depending on command line options. |
| 339 | final_report () { |
| 340 | : |
| 341 | } |
| 342 | |
| 343 | fatal_signal () { |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 344 | final_cleanup |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 345 | final_report $1 |
| 346 | trap - $1 |
| 347 | kill -$1 $$ |
| 348 | } |
| 349 | |
| 350 | trap 'fatal_signal HUP' HUP |
| 351 | trap 'fatal_signal INT' INT |
| 352 | trap 'fatal_signal TERM' TERM |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 353 | |
Gilles Peskine | 050d2fc | 2021-09-30 18:24:21 +0200 | [diff] [blame] | 354 | # Number of processors on this machine. Used as the default setting |
| 355 | # for parallel make. |
| 356 | all_sh_nproc () |
| 357 | { |
| 358 | { |
| 359 | nproc || # Linux |
| 360 | sysctl -n hw.ncpuonline || # NetBSD, OpenBSD |
| 361 | sysctl -n hw.ncpu || # FreeBSD |
| 362 | echo 1 |
| 363 | } 2>/dev/null |
| 364 | } |
| 365 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 366 | msg() |
| 367 | { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 368 | if [ -n "${current_component:-}" ]; then |
| 369 | current_section="${current_component#component_}: $1" |
| 370 | else |
| 371 | current_section="$1" |
| 372 | fi |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 373 | |
| 374 | if [ $QUIET -eq 1 ]; then |
| 375 | return |
| 376 | fi |
| 377 | |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 378 | echo "" |
| 379 | echo "******************************************************************" |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 380 | echo "* $current_section " |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 381 | printf "* "; date |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 382 | echo "******************************************************************" |
| 383 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 384 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 385 | armc6_build_test() |
| 386 | { |
| 387 | FLAGS="$1" |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 388 | |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 389 | msg "build: ARM Compiler 6 ($FLAGS)" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 390 | ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ |
Dave Rodgman | 1c232a8 | 2023-03-02 13:39:04 +0000 | [diff] [blame] | 391 | WARNING_CFLAGS='-Werror -xc -std=c99' make lib |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 392 | |
| 393 | msg "size: ARM Compiler 6 ($FLAGS)" |
| 394 | "$ARMC6_FROMELF" -z library/*.o |
| 395 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 396 | make clean |
| 397 | } |
Andres AG | a5cd973 | 2016-10-17 15:23:10 +0100 | [diff] [blame] | 398 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 399 | err_msg() |
| 400 | { |
| 401 | echo "$1" >&2 |
| 402 | } |
| 403 | |
| 404 | check_tools() |
| 405 | { |
| 406 | for TOOL in "$@"; do |
Andres AG | 9839360 | 2017-01-31 17:04:45 +0000 | [diff] [blame] | 407 | if ! `type "$TOOL" >/dev/null 2>&1`; then |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 408 | err_msg "$TOOL not found!" |
| 409 | exit 1 |
| 410 | fi |
| 411 | done |
| 412 | } |
| 413 | |
Tom Cosgrove | 730addc | 2023-06-09 14:20:18 +0100 | [diff] [blame] | 414 | pre_parse_command_line_for_dirs () { |
| 415 | # Make an early pass through the options given, so we can set directories |
| 416 | # for Arm compilers, before SUPPORTED_COMPONENTS is determined. |
| 417 | while [ $# -gt 0 ]; do |
| 418 | case "$1" in |
| 419 | --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; |
| 420 | --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; |
| 421 | esac |
| 422 | shift |
| 423 | done |
| 424 | } |
| 425 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 426 | pre_parse_command_line () { |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 427 | COMMAND_LINE_COMPONENTS= |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 428 | all_except=0 |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 429 | error_test=0 |
Gilles Peskine | 80ddb99 | 2021-08-06 11:51:59 +0200 | [diff] [blame] | 430 | restore_first=0 |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 431 | no_armcc= |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 432 | |
Jaeden Amero | 9b90f2e | 2018-11-02 18:34:17 +0000 | [diff] [blame] | 433 | # Note that legacy options are ignored instead of being omitted from this |
| 434 | # list of options, so invocations that worked with previous version of |
| 435 | # all.sh will still run and work properly. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 436 | while [ $# -gt 0 ]; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 437 | case "$1" in |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 438 | --append-outcome) append_outcome=1;; |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 439 | --arm-none-eabi-gcc-prefix) shift; ARM_NONE_EABI_GCC_PREFIX="$1";; |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 440 | --arm-linux-gnueabi-gcc-prefix) shift; ARM_LINUX_GNUEABI_GCC_PREFIX="$1";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 441 | --armcc) no_armcc=;; |
Tom Cosgrove | 730addc | 2023-06-09 14:20:18 +0100 | [diff] [blame] | 442 | --armc5-bin-dir) shift; ;; # assignment to ARMC5_BIN_DIR done in pre_parse_command_line_for_dirs |
| 443 | --armc6-bin-dir) shift; ;; # assignment to ARMC6_BIN_DIR done in pre_parse_command_line_for_dirs |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 444 | --error-test) error_test=$((error_test + 1));; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 445 | --except) all_except=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 446 | --force|-f) FORCE=1;; |
| 447 | --gnutls-cli) shift; GNUTLS_CLI="$1";; |
| 448 | --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; |
| 449 | --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; |
| 450 | --gnutls-serv) shift; GNUTLS_SERV="$1";; |
| 451 | --help|-h) usage; exit;; |
| 452 | --keep-going|-k) KEEP_GOING=1;; |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 453 | --list-all-components) printf '%s\n' $ALL_COMPONENTS; exit;; |
| 454 | --list-components) printf '%s\n' $SUPPORTED_COMPONENTS; exit;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 455 | --memory|-m) MEMORY=1;; |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 456 | --no-append-outcome) append_outcome=0;; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 457 | --no-armcc) no_armcc=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 458 | --no-force) FORCE=0;; |
| 459 | --no-keep-going) KEEP_GOING=0;; |
| 460 | --no-memory) MEMORY=0;; |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 461 | --no-quiet) QUIET=0;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 462 | --openssl) shift; OPENSSL="$1";; |
| 463 | --openssl-legacy) shift; OPENSSL_LEGACY="$1";; |
| 464 | --openssl-next) shift; OPENSSL_NEXT="$1";; |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 465 | --outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 466 | --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 467 | --quiet|-q) QUIET=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 468 | --random-seed) unset SEED;; |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 469 | --release-test|-r) SEED=$RELEASE_SEED;; |
Gilles Peskine | 80ddb99 | 2021-08-06 11:51:59 +0200 | [diff] [blame] | 470 | --restore) restore_first=1;; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 471 | --seed|-s) shift; SEED="$1";; |
| 472 | -*) |
| 473 | echo >&2 "Unknown option: $1" |
| 474 | echo >&2 "Run $0 --help for usage." |
| 475 | exit 120 |
| 476 | ;; |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 477 | *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 478 | esac |
| 479 | shift |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 480 | done |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 481 | |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 482 | # With no list of components, run everything. |
Gilles Peskine | 80ddb99 | 2021-08-06 11:51:59 +0200 | [diff] [blame] | 483 | if [ -z "$COMMAND_LINE_COMPONENTS" ] && [ $restore_first -eq 0 ]; then |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 484 | all_except=1 |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 485 | fi |
| 486 | |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 487 | # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. |
| 488 | # Ignore it if components are listed explicitly on the command line. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 489 | if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 490 | COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 491 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 492 | |
Gilles Peskine | bf66e2c | 2021-08-03 13:44:28 +0200 | [diff] [blame] | 493 | # Error out if an explicitly requested component doesn't exist. |
Gilles Peskine | b80f0d2 | 2020-03-28 21:37:59 +0100 | [diff] [blame] | 494 | if [ $all_except -eq 0 ]; then |
| 495 | unsupported=0 |
Gilles Peskine | 03af678 | 2021-08-06 11:35:17 +0200 | [diff] [blame] | 496 | # Temporarily disable wildcard expansion so that $COMMAND_LINE_COMPONENTS |
| 497 | # only does word splitting. |
Gilles Peskine | 1d475b6 | 2021-08-03 13:43:36 +0200 | [diff] [blame] | 498 | set -f |
Gilles Peskine | b80f0d2 | 2020-03-28 21:37:59 +0100 | [diff] [blame] | 499 | for component in $COMMAND_LINE_COMPONENTS; do |
Gilles Peskine | 1d475b6 | 2021-08-03 13:43:36 +0200 | [diff] [blame] | 500 | set +f |
Gilles Peskine | bf66e2c | 2021-08-03 13:44:28 +0200 | [diff] [blame] | 501 | # If the requested name includes a wildcard character, don't |
| 502 | # check it. Accept wildcard patterns that don't match anything. |
Gilles Peskine | b80f0d2 | 2020-03-28 21:37:59 +0100 | [diff] [blame] | 503 | case $component in |
| 504 | *[*?\[]*) continue;; |
| 505 | esac |
| 506 | case " $SUPPORTED_COMPONENTS " in |
| 507 | *" $component "*) :;; |
| 508 | *) |
| 509 | echo >&2 "Component $component was explicitly requested, but is not known or not supported." |
| 510 | unsupported=$((unsupported + 1));; |
| 511 | esac |
| 512 | done |
Gilles Peskine | 1d475b6 | 2021-08-03 13:43:36 +0200 | [diff] [blame] | 513 | set +f |
Gilles Peskine | b80f0d2 | 2020-03-28 21:37:59 +0100 | [diff] [blame] | 514 | if [ $unsupported -ne 0 ]; then |
| 515 | exit 2 |
| 516 | fi |
| 517 | fi |
| 518 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 519 | # Build the list of components to run. |
Gilles Peskine | a28db92 | 2019-01-10 00:05:18 +0100 | [diff] [blame] | 520 | RUN_COMPONENTS= |
| 521 | for component in $SUPPORTED_COMPONENTS; do |
| 522 | if is_component_included "$component"; [ $? -eq $all_except ]; then |
| 523 | RUN_COMPONENTS="$RUN_COMPONENTS $component" |
| 524 | fi |
| 525 | done |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 526 | |
| 527 | unset all_except |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 528 | unset no_armcc |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 529 | } |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 530 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 531 | pre_check_git () { |
| 532 | if [ $FORCE -eq 1 ]; then |
Gilles Peskine | 53190e6 | 2019-01-09 23:17:35 +0100 | [diff] [blame] | 533 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 534 | git checkout-index -f -q $CONFIG_H |
| 535 | cleanup |
| 536 | else |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 537 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 538 | if [ -d "$OUT_OF_SOURCE_DIR" ]; then |
| 539 | echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 |
| 540 | echo "You can either delete this directory manually, or force the test by rerunning" |
| 541 | echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" |
| 542 | exit 1 |
| 543 | fi |
| 544 | |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 545 | if ! git diff --quiet include/mbedtls/mbedtls_config.h; then |
| 546 | err_msg "Warning - the configuration file 'include/mbedtls/mbedtls_config.h' has been edited. " |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 547 | echo "You can either delete or preserve your work, or force the test by rerunning the" |
| 548 | echo "script as: $0 --force" |
| 549 | exit 1 |
| 550 | fi |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 551 | fi |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 552 | } |
| 553 | |
Gilles Peskine | 568f53a | 2021-07-12 18:16:01 +0200 | [diff] [blame] | 554 | pre_restore_files () { |
| 555 | # If the makefiles have been generated by a framework such as cmake, |
| 556 | # restore them from git. If the makefiles look like modifications from |
| 557 | # the ones checked into git, take care not to modify them. Whatever |
| 558 | # this function leaves behind is what the script will restore before |
| 559 | # each component. |
| 560 | case "$(head -n1 Makefile)" in |
| 561 | *[Gg]enerated*) |
| 562 | git update-index --no-skip-worktree Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
| 563 | git checkout -- Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile |
| 564 | ;; |
| 565 | esac |
| 566 | } |
| 567 | |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 568 | pre_back_up () { |
| 569 | for x in $files_to_back_up; do |
| 570 | cp -p "$x" "$x$backup_suffix" |
| 571 | done |
| 572 | } |
| 573 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 574 | pre_setup_keep_going () { |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 575 | failure_count=0 # Number of failed components |
| 576 | last_failure_status=0 # Last failure status in this component |
| 577 | |
Gilles Peskine | fec30cb | 2020-03-28 19:34:23 +0100 | [diff] [blame] | 578 | # See err_trap |
| 579 | previous_failure_status=0 |
| 580 | previous_failed_command= |
| 581 | previous_failure_funcall_depth=0 |
Gilles Peskine | a681c59 | 2020-03-28 21:27:40 +0100 | [diff] [blame] | 582 | unset report_failed_command |
Gilles Peskine | fec30cb | 2020-03-28 19:34:23 +0100 | [diff] [blame] | 583 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 584 | start_red= |
| 585 | end_color= |
| 586 | if [ -t 1 ]; then |
Gilles Peskine | 9736b9d | 2018-01-02 21:54:17 +0100 | [diff] [blame] | 587 | case "${TERM:-}" in |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 588 | *color*|cygwin|linux|rxvt*|screen|[Eex]term*) |
| 589 | start_red=$(printf '\033[31m') |
| 590 | end_color=$(printf '\033[0m') |
| 591 | ;; |
| 592 | esac |
| 593 | fi |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 594 | |
| 595 | # Keep a summary of failures in a file. We'll print it out at the end. |
| 596 | failure_summary_file=$PWD/all-sh-failures-$$.log |
| 597 | : >"$failure_summary_file" |
| 598 | |
| 599 | # Whether it makes sense to keep a component going after the specified |
| 600 | # command fails (test command) or not (configure or build). |
Gilles Peskine | 03af678 | 2021-08-06 11:35:17 +0200 | [diff] [blame] | 601 | # This function normally receives the failing simple command |
| 602 | # ($BASH_COMMAND) as an argument, but if $report_failed_command is set, |
| 603 | # this is passed instead. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 604 | # This doesn't have to be 100% accurate: all failures are recorded anyway. |
Gilles Peskine | c111e24 | 2021-08-02 23:29:53 +0200 | [diff] [blame] | 605 | # False positives result in running things that can't be expected to |
| 606 | # work. False negatives result in things not running after something else |
| 607 | # failed even though they might have given useful feedback. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 608 | can_keep_going_after_failure () { |
| 609 | case "$1" in |
| 610 | "msg "*) false;; |
Gilles Peskine | c111e24 | 2021-08-02 23:29:53 +0200 | [diff] [blame] | 611 | "cd "*) false;; |
| 612 | *make*[\ /]tests*) false;; # make tests, make CFLAGS=-I../tests, ... |
| 613 | *test*) true;; # make test, tests/stuff, env V=v tests/stuff, ... |
| 614 | *make*check*) true;; |
| 615 | "grep "*) true;; |
| 616 | "[ "*) true;; |
| 617 | "! "*) true;; |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 618 | *) false;; |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 619 | esac |
| 620 | } |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 621 | |
| 622 | # This function runs if there is any error in a component. |
| 623 | # It must either exit with a nonzero status, or set |
| 624 | # last_failure_status to a nonzero value. |
| 625 | err_trap () { |
| 626 | # Save $? (status of the failing command). This must be the very |
| 627 | # first thing, before $? is overridden. |
| 628 | last_failure_status=$? |
Gilles Peskine | a681c59 | 2020-03-28 21:27:40 +0100 | [diff] [blame] | 629 | failed_command=${report_failed_command-$BASH_COMMAND} |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 630 | |
Gilles Peskine | fec30cb | 2020-03-28 19:34:23 +0100 | [diff] [blame] | 631 | if [[ $last_failure_status -eq $previous_failure_status && |
| 632 | "$failed_command" == "$previous_failed_command" && |
| 633 | ${#FUNCNAME[@]} == $((previous_failure_funcall_depth - 1)) ]] |
| 634 | then |
| 635 | # The same command failed twice in a row, but this time one level |
| 636 | # less deep in the function call stack. This happens when the last |
| 637 | # command of a function returns a nonzero status, and the function |
| 638 | # returns that same status. Ignore the second failure. |
| 639 | previous_failure_funcall_depth=${#FUNCNAME[@]} |
| 640 | return |
| 641 | fi |
| 642 | previous_failure_status=$last_failure_status |
| 643 | previous_failed_command=$failed_command |
| 644 | previous_failure_funcall_depth=${#FUNCNAME[@]} |
| 645 | |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 646 | text="$current_section: $failed_command -> $last_failure_status" |
| 647 | echo "${start_red}^^^^$text^^^^${end_color}" >&2 |
| 648 | echo "$text" >>"$failure_summary_file" |
| 649 | |
| 650 | # If the command is fatal (configure or build command), stop this |
| 651 | # component. Otherwise (test command) keep the component running |
| 652 | # (run more tests from the same build). |
| 653 | if ! can_keep_going_after_failure "$failed_command"; then |
| 654 | exit $last_failure_status |
| 655 | fi |
| 656 | } |
| 657 | |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 658 | final_report () { |
| 659 | if [ $failure_count -gt 0 ]; then |
| 660 | echo |
| 661 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 662 | echo "${start_red}FAILED: $failure_count components${end_color}" |
| 663 | cat "$failure_summary_file" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 664 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
| 665 | elif [ -z "${1-}" ]; then |
| 666 | echo "SUCCESS :)" |
| 667 | fi |
| 668 | if [ -n "${1-}" ]; then |
| 669 | echo "Killed by SIG$1." |
| 670 | fi |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 671 | rm -f "$failure_summary_file" |
| 672 | if [ $failure_count -gt 0 ]; then |
| 673 | exit 1 |
| 674 | fi |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 675 | } |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 676 | } |
| 677 | |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 678 | # record_status() and if_build_succeeded() are kept temporarily for backward |
| 679 | # compatibility. Don't use them in new components. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 680 | record_status () { |
| 681 | "$@" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 682 | } |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 683 | if_build_succeeded () { |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 684 | "$@" |
Gilles Peskine | 7c65216 | 2017-12-11 00:01:40 +0100 | [diff] [blame] | 685 | } |
| 686 | |
Gilles Peskine | a681c59 | 2020-03-28 21:27:40 +0100 | [diff] [blame] | 687 | # '! true' does not trigger the ERR trap. Arrange to trigger it, with |
| 688 | # a reasonably informative error message (not just "$@"). |
| 689 | not () { |
| 690 | if "$@"; then |
| 691 | report_failed_command="! $*" |
| 692 | false |
| 693 | unset report_failed_command |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 694 | fi |
| 695 | } |
| 696 | |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 697 | pre_prepare_outcome_file () { |
| 698 | case "$MBEDTLS_TEST_OUTCOME_FILE" in |
| 699 | [!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";; |
| 700 | esac |
| 701 | if [ -n "$MBEDTLS_TEST_OUTCOME_FILE" ] && [ "$append_outcome" -eq 0 ]; then |
| 702 | rm -f "$MBEDTLS_TEST_OUTCOME_FILE" |
| 703 | fi |
| 704 | } |
| 705 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 706 | pre_print_configuration () { |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 707 | if [ $QUIET -eq 1 ]; then |
| 708 | return |
| 709 | fi |
| 710 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 711 | msg "info: $0 configuration" |
| 712 | echo "MEMORY: $MEMORY" |
| 713 | echo "FORCE: $FORCE" |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 714 | echo "MBEDTLS_TEST_OUTCOME_FILE: ${MBEDTLS_TEST_OUTCOME_FILE:-(none)}" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 715 | echo "SEED: ${SEED-"UNSET"}" |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 716 | echo |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 717 | echo "OPENSSL: $OPENSSL" |
| 718 | echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" |
| 719 | echo "OPENSSL_NEXT: $OPENSSL_NEXT" |
| 720 | echo "GNUTLS_CLI: $GNUTLS_CLI" |
| 721 | echo "GNUTLS_SERV: $GNUTLS_SERV" |
| 722 | echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" |
| 723 | echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" |
| 724 | echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" |
| 725 | echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" |
| 726 | } |
Andres AG | 7770ea8 | 2016-10-10 15:46:20 +0100 | [diff] [blame] | 727 | |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 728 | # Make sure the tools we need are available. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 729 | pre_check_tools () { |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 730 | # Build the list of variables to pass to output_env.sh. |
| 731 | set env |
SimonB | 2e23c82 | 2016-04-16 21:54:39 +0100 | [diff] [blame] | 732 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 733 | case " $RUN_COMPONENTS " in |
| 734 | # Require OpenSSL and GnuTLS if running any tests (as opposed to |
| 735 | # only doing builds). Not all tests run OpenSSL and GnuTLS, but this |
| 736 | # is a good enough approximation in practice. |
| 737 | *" test_"*) |
| 738 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh |
| 739 | # and ssl-opt.sh, we just export the variables they require. |
Manuel Pégourié-Gonnard | c572246 | 2022-12-19 11:42:12 +0100 | [diff] [blame] | 740 | export OPENSSL="$OPENSSL" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 741 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 742 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 743 | # Avoid passing --seed flag in every call to ssl-opt.sh |
| 744 | if [ -n "${SEED-}" ]; then |
| 745 | export SEED |
| 746 | fi |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 747 | set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" |
| 748 | set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" |
| 749 | set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" |
| 750 | set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 751 | check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \ |
| 752 | "$GNUTLS_CLI" "$GNUTLS_SERV" \ |
| 753 | "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" |
| 754 | ;; |
| 755 | esac |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 756 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 757 | case " $RUN_COMPONENTS " in |
| 758 | *_doxygen[_\ ]*) check_tools "doxygen" "dot";; |
| 759 | esac |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 760 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 761 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 762 | *_arm_none_eabi_gcc[_\ ]*) check_tools "${ARM_NONE_EABI_GCC_PREFIX}gcc";; |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 763 | esac |
Andres AG | d9eba4b | 2016-08-26 14:42:14 +0100 | [diff] [blame] | 764 | |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 765 | case " $RUN_COMPONENTS " in |
| 766 | *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; |
| 767 | esac |
| 768 | |
| 769 | case " $RUN_COMPONENTS " in |
| 770 | *" test_zeroize "*) check_tools "gdb";; |
| 771 | esac |
| 772 | |
| 773 | case " $RUN_COMPONENTS " in |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 774 | *_armcc*) |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 775 | ARMC5_CC="$ARMC5_BIN_DIR/armcc" |
| 776 | ARMC5_AR="$ARMC5_BIN_DIR/armar" |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 777 | ARMC5_FROMELF="$ARMC5_BIN_DIR/fromelf" |
Gilles Peskine | 8796426 | 2019-01-06 22:40:00 +0000 | [diff] [blame] | 778 | ARMC6_CC="$ARMC6_BIN_DIR/armclang" |
| 779 | ARMC6_AR="$ARMC6_BIN_DIR/armar" |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 780 | ARMC6_FROMELF="$ARMC6_BIN_DIR/fromelf" |
| 781 | check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC5_FROMELF" \ |
| 782 | "$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";; |
Gilles Peskine | 5331c6e | 2019-01-06 22:23:42 +0000 | [diff] [blame] | 783 | esac |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 784 | |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 785 | # past this point, no call to check_tool, only printing output |
| 786 | if [ $QUIET -eq 1 ]; then |
| 787 | return |
| 788 | fi |
| 789 | |
Gilles Peskine | cc9f0b9 | 2019-01-06 22:46:21 +0000 | [diff] [blame] | 790 | msg "info: output_env.sh" |
| 791 | case $RUN_COMPONENTS in |
| 792 | *_armcc*) |
| 793 | set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; |
| 794 | *) set "$@" RUN_ARMCC=0;; |
| 795 | esac |
| 796 | "$@" scripts/output_env.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 797 | } |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 798 | |
Gilles Peskine | 1570b59 | 2021-04-22 01:10:12 +0200 | [diff] [blame] | 799 | pre_generate_files() { |
Manuel Pégourié-Gonnard | 87db8a2 | 2021-06-18 13:30:14 +0200 | [diff] [blame] | 800 | # since make doesn't have proper dependencies, remove any possibly outdate |
| 801 | # file that might be around before generating fresh ones |
| 802 | make neat |
Gilles Peskine | 7238503 | 2021-07-08 19:07:07 +0200 | [diff] [blame] | 803 | if [ $QUIET -eq 1 ]; then |
Gilles Peskine | 7530163 | 2021-08-05 15:10:47 +0200 | [diff] [blame] | 804 | make generated_files >/dev/null |
Gilles Peskine | 7238503 | 2021-07-08 19:07:07 +0200 | [diff] [blame] | 805 | else |
| 806 | make generated_files |
| 807 | fi |
Gilles Peskine | 1570b59 | 2021-04-22 01:10:12 +0200 | [diff] [blame] | 808 | } |
| 809 | |
Manuel Pégourié-Gonnard | 27e1767 | 2023-05-25 09:39:08 +0200 | [diff] [blame] | 810 | ################################################################ |
| 811 | #### Helpers for components using libtestdriver1 |
| 812 | ################################################################ |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 813 | |
Manuel Pégourié-Gonnard | f5c5d97 | 2023-06-06 11:14:57 +0200 | [diff] [blame] | 814 | # How to use libtestdriver1 |
| 815 | # ------------------------- |
| 816 | # |
| 817 | # 1. Define the list algorithms and key types to accelerate, |
| 818 | # designated the same way as PSA_WANT_ macros but without PSA_WANT_. |
| 819 | # Examples: |
| 820 | # - loc_accel_list="ALG_JPAKE" |
| 821 | # - loc_accel_list="ALG_FFDH KEY_TYPE_DH_KEY_PAIR KEY_TYPE_DH_PUBLIC_KEY" |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 822 | # 2. Make configurations changes for the driver and/or main libraries. |
| 823 | # 2a. Call helper_libtestdriver1_adjust_config <base>, where the argument |
| 824 | # can be either "default" to start with the default config, or a name |
| 825 | # supported by scripts/config.py (for example, "full"). This selects |
Manuel Pégourié-Gonnard | 2336c8e | 2023-06-12 17:17:54 +0200 | [diff] [blame] | 826 | # the base to use, and makes common adjustments. |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 827 | # 2b. If desired, adjust the PSA_WANT symbols in psa/crypto_config.h. |
| 828 | # These changes affect both the driver and the main libraries. |
| 829 | # (Note: they need to have the same set of PSA_WANT symbols, as that |
| 830 | # determines the ABI between them.) |
| 831 | # 2c. Adjust MBEDTLS_ symbols in mbedtls_config.h. This only affects the |
| 832 | # main libraries. Typically, you want to disable the module(s) that are |
| 833 | # being accelerated. You may need to also disable modules that depend |
| 834 | # on them or options that are not supported with drivers. |
| 835 | # 2d. On top of psa/crypto_config.h, the driver library uses its own config |
| 836 | # file: tests/include/test/drivers/config_test_driver.h. You usually |
| 837 | # don't need to edit it: using loc_extra_list (see below) is preferred. |
| 838 | # However, when there's no PSA symbol for what you want to enable, |
| 839 | # calling scripts/config.py on this file remains the only option. |
| 840 | # 3. Build the driver library, then the main libraries, test, and programs. |
| 841 | # 3a. Call helper_libtestdriver1_make_drivers "$loc_accel_list". You may |
| 842 | # need to enable more algorithms here, typically hash algorithms when |
| 843 | # accelerating some signature algorithms (ECDSA, RSAv2). This is done |
| 844 | # by passing a 2nd argument listing the extra algorithms. |
| 845 | # Example: |
| 846 | # loc_extra_list="ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
| 847 | # helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list" |
| 848 | # 4b. Call helper_libtestdriver1_make_main "$loc_accel_list". Any |
| 849 | # additional arguments will be passed to make: this can be useful if |
| 850 | # you don't want to build everything when iterating during development. |
| 851 | # Example: |
| 852 | # helper_libtestdriver1_make_main "$loc_accel_list" -C tests test_suite_foo |
| 853 | # 4. Run the tests you want. |
Manuel Pégourié-Gonnard | f5c5d97 | 2023-06-06 11:14:57 +0200 | [diff] [blame] | 854 | |
Manuel Pégourié-Gonnard | 27e1767 | 2023-05-25 09:39:08 +0200 | [diff] [blame] | 855 | # Adjust the configuration - for both libtestdriver1 and main library, |
| 856 | # as they should have the same PSA_WANT macros. |
| 857 | helper_libtestdriver1_adjust_config() { |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 858 | BASE_CONFIG=$1 |
| 859 | # Select the base configuration |
| 860 | if [ "$BASE_CONFIG" != "default" ]; then |
| 861 | scripts/config.py "$BASE_CONFIG" |
| 862 | fi |
| 863 | |
| 864 | # Enable PSA-based config (necessary to use drivers) |
| 865 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 866 | |
Manuel Pégourié-Gonnard | 27e1767 | 2023-05-25 09:39:08 +0200 | [diff] [blame] | 867 | # Disable ALG_STREAM_CIPHER and ALG_ECB_NO_PADDING to avoid having |
| 868 | # partial support for cipher operations in the driver test library. |
| 869 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER |
| 870 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING |
Manuel Pégourié-Gonnard | 2336c8e | 2023-06-12 17:17:54 +0200 | [diff] [blame] | 871 | |
| 872 | # Dynamic secure element support is a deprecated feature and needs to be disabled here. |
| 873 | # This is done to have the same form of psa_key_attributes_s for libdriver and library. |
| 874 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
Manuel Pégourié-Gonnard | 27e1767 | 2023-05-25 09:39:08 +0200 | [diff] [blame] | 875 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 876 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 877 | # Build the drivers library libtestdriver1.a (with ASan). |
Manuel Pégourié-Gonnard | 31639e4 | 2023-05-25 10:07:31 +0200 | [diff] [blame] | 878 | # |
| 879 | # Parameters: |
| 880 | # 1. a space-separated list of things to accelerate; |
| 881 | # 2. optional: a space-separate list of things to also support. |
| 882 | # Here "things" are PSA_WANT_ symbols but with PSA_WANT_ removed. |
| 883 | helper_libtestdriver1_make_drivers() { |
| 884 | loc_accel_flags=$( echo "$1 ${2-}" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' ) |
| 885 | make -C tests libtestdriver1.a CFLAGS=" $ASAN_CFLAGS $loc_accel_flags" LDFLAGS="$ASAN_CFLAGS" |
| 886 | } |
| 887 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 888 | # Build the main libraries, programs and tests, |
| 889 | # linking to the drivers library (with ASan). |
| 890 | # |
| 891 | # Parameters: |
| 892 | # 1. a space-separated list of things to accelerate; |
| 893 | # *. remaining arguments if any are passed directly to make |
| 894 | # (examples: lib, -C tests test_suite_xxx, etc.) |
| 895 | # Here "things" are PSA_WANT_ symbols but with PSA_WANT_ removed. |
| 896 | helper_libtestdriver1_make_main() { |
| 897 | loc_accel_list=$1 |
| 898 | shift |
| 899 | |
| 900 | # we need flags both with and without the LIBTESTDRIVER1_ prefix |
| 901 | loc_accel_flags=$( echo "$loc_accel_list" | sed 's/[^ ]* */-DLIBTESTDRIVER1_MBEDTLS_PSA_ACCEL_&/g' ) |
| 902 | loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )" |
| 903 | make CFLAGS="$ASAN_CFLAGS -I../tests/include -I../tests -I../../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS" "$@" |
| 904 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 905 | |
| 906 | ################################################################ |
| 907 | #### Basic checks |
| 908 | ################################################################ |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 909 | |
| 910 | # |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 911 | # Test Suites to be executed |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 912 | # |
Manuel Pégourié-Gonnard | 3d404b4 | 2015-07-08 21:59:16 +0100 | [diff] [blame] | 913 | # The test ordering tries to optimize for the following criteria: |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 914 | # 1. Catch possible problems early, by running first tests that run quickly |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 915 | # and/or are more likely to fail than others (eg I use Clang most of the |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 916 | # time, so start with a GCC build). |
| 917 | # 2. Minimize total running time, by avoiding useless rebuilds |
Manuel Pégourié-Gonnard | 89d69b3 | 2014-11-20 13:48:53 +0100 | [diff] [blame] | 918 | # |
Manuel Pégourié-Gonnard | 259b08a | 2016-01-08 16:27:41 +0100 | [diff] [blame] | 919 | # Indicative running times are given for reference. |
| 920 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 921 | component_check_recursion () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 922 | msg "Check: recursion.pl" # < 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 923 | tests/scripts/recursion.pl library/*.c |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 924 | } |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 925 | |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 926 | component_check_generated_files () { |
| 927 | msg "Check: check-generated-files, files generated with make" # 2s |
| 928 | make generated_files |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 929 | tests/scripts/check-generated-files.sh |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 930 | |
| 931 | msg "Check: check-generated-files -u, files present" # 2s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 932 | tests/scripts/check-generated-files.sh -u |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 933 | # Check that the generated files are considered up to date. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 934 | tests/scripts/check-generated-files.sh |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 935 | |
| 936 | msg "Check: check-generated-files -u, files absent" # 2s |
| 937 | command make neat |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 938 | tests/scripts/check-generated-files.sh -u |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 939 | # Check that the generated files are considered up to date. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 940 | tests/scripts/check-generated-files.sh |
Gilles Peskine | 67debb6 | 2021-05-18 16:09:50 +0200 | [diff] [blame] | 941 | |
| 942 | # This component ends with the generated files present in the source tree. |
| 943 | # This is necessary for subsequent components! |
| 944 | } |
| 945 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 946 | component_check_doxy_blocks () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 947 | msg "Check: doxygen markup outside doxygen blocks" # < 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 948 | tests/scripts/check-doxy-blocks.pl |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 949 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 950 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 951 | component_check_files () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 952 | msg "Check: file sanity checks (permissions, encodings)" # < 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 953 | tests/scripts/check_files.py |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 954 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 955 | |
Gilles Peskine | 30e0bb4 | 2020-05-10 17:40:49 +0200 | [diff] [blame] | 956 | component_check_changelog () { |
| 957 | msg "Check: changelog entries" # < 1s |
| 958 | rm -f ChangeLog.new |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 959 | scripts/assemble_changelog.py -o ChangeLog.new |
Gilles Peskine | 30e0bb4 | 2020-05-10 17:40:49 +0200 | [diff] [blame] | 960 | if [ -e ChangeLog.new ]; then |
| 961 | # Show the diff for information. It isn't an error if the diff is |
| 962 | # non-empty. |
| 963 | diff -u ChangeLog ChangeLog.new || true |
| 964 | rm ChangeLog.new |
| 965 | fi |
| 966 | } |
| 967 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 968 | component_check_names () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 969 | msg "Check: declared and exported names (builds the library)" # < 3s |
Yuto Takano | c3a6f63 | 2021-09-24 18:02:56 +0100 | [diff] [blame] | 970 | tests/scripts/check_names.py -v |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 971 | } |
Darryl Green | a07039c | 2018-03-13 16:48:16 +0000 | [diff] [blame] | 972 | |
Gilles Peskine | 895868b | 2019-09-19 21:30:05 +0200 | [diff] [blame] | 973 | component_check_test_cases () { |
| 974 | msg "Check: test case descriptions" # < 1s |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 975 | if [ $QUIET -eq 1 ]; then |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 976 | opt='--quiet' |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 977 | else |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 978 | opt='' |
Manuel Pégourié-Gonnard | a911916 | 2020-06-02 11:51:40 +0200 | [diff] [blame] | 979 | fi |
Gilles Peskine | 031114d | 2022-12-15 14:46:31 +0100 | [diff] [blame] | 980 | tests/scripts/check_test_cases.py -q $opt |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 981 | unset opt |
Gilles Peskine | 895868b | 2019-09-19 21:30:05 +0200 | [diff] [blame] | 982 | } |
| 983 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 984 | component_check_doxygen_warnings () { |
Gilles Peskine | 600bb69 | 2019-09-19 21:29:11 +0200 | [diff] [blame] | 985 | msg "Check: doxygen warnings (builds the documentation)" # ~ 3s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 986 | tests/scripts/doxygen.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 987 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 988 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 989 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 990 | |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 991 | ################################################################ |
| 992 | #### Build and test many configurations and targets |
| 993 | ################################################################ |
| 994 | |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 995 | component_test_default_out_of_box () { |
| 996 | msg "build: make, default config (out-of-box)" # ~1min |
| 997 | make |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 998 | # Disable fancy stuff |
| 999 | unset MBEDTLS_TEST_OUTCOME_FILE |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 1000 | |
| 1001 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 1002 | make test |
| 1003 | |
| 1004 | msg "selftest: make, default config (out-of-box)" # ~10s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1005 | programs/test/selftest |
Gilles Peskine | 7832c9f | 2019-04-08 17:00:15 +0200 | [diff] [blame] | 1006 | } |
| 1007 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1008 | component_test_default_cmake_gcc_asan () { |
| 1009 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1010 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1011 | make |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 1012 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1013 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1014 | make test |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 1015 | |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 1016 | msg "test: selftest (ASan build)" # ~ 10s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1017 | programs/test/selftest |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 1018 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1019 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1020 | tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 1021 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1022 | msg "test: compat.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1023 | tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 1024 | |
| 1025 | msg "test: context-info.sh (ASan build)" # ~ 15 sec |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1026 | tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1027 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 1028 | |
Hanno Becker | 0163551 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 1029 | component_test_full_cmake_gcc_asan () { |
| 1030 | msg "build: full config, cmake, gcc, ASan" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1031 | scripts/config.py full |
Hanno Becker | 0163551 | 2019-02-26 14:27:09 +0000 | [diff] [blame] | 1032 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1033 | make |
| 1034 | |
| 1035 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 1036 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1037 | |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 1038 | msg "test: selftest (ASan build)" # ~ 10s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1039 | programs/test/selftest |
Gilles Peskine | 97bea01 | 2020-04-23 23:37:45 +0200 | [diff] [blame] | 1040 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1041 | msg "test: ssl-opt.sh (full config, ASan build)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1042 | tests/ssl-opt.sh |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1043 | |
| 1044 | msg "test: compat.sh (full config, ASan build)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1045 | tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 1046 | |
| 1047 | msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1048 | tests/context-info.sh |
Valerio Setti | 3322f61 | 2022-12-30 17:45:05 +0100 | [diff] [blame] | 1049 | |
Valerio Setti | 67419f0 | 2023-01-04 16:12:42 +0100 | [diff] [blame] | 1050 | msg "test: check direct ECP dependencies in TLS and X.509" |
Valerio Setti | 3322f61 | 2022-12-30 17:45:05 +0100 | [diff] [blame] | 1051 | docs/architecture/psa-migration/syms.sh full |
| 1052 | |
Valerio Setti | 67419f0 | 2023-01-04 16:12:42 +0100 | [diff] [blame] | 1053 | # TODO: replace "mbedtls_ecp_curve" with "mbedtls_ecp" also for |
| 1054 | # "full-tls-external" once Issue6839 is completed |
valerio | 0b04864 | 2023-04-20 13:28:39 +0200 | [diff] [blame] | 1055 | not grep mbedtls_ecp_curve full-libmbedtls-external |
| 1056 | not grep mbedtls_ecp full-libmbedx509-external |
Valerio Setti | 3322f61 | 2022-12-30 17:45:05 +0100 | [diff] [blame] | 1057 | |
valerio | 0b04864 | 2023-04-20 13:28:39 +0200 | [diff] [blame] | 1058 | rm full-libmbedtls-external \ |
| 1059 | full-libmbedtls-modules \ |
| 1060 | full-libmbedx509-external \ |
| 1061 | full-libmbedx509-modules |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1062 | } |
| 1063 | |
Ronald Cron | c3623db | 2020-10-29 10:51:32 +0100 | [diff] [blame] | 1064 | component_test_psa_crypto_key_id_encodes_owner () { |
Andrzej Kurek | 03e0146 | 2022-01-03 12:53:24 +0100 | [diff] [blame] | 1065 | msg "build: full config + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan" |
Ronald Cron | c3623db | 2020-10-29 10:51:32 +0100 | [diff] [blame] | 1066 | scripts/config.py full |
Ronald Cron | c3623db | 2020-10-29 10:51:32 +0100 | [diff] [blame] | 1067 | scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER |
| 1068 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1069 | make |
| 1070 | |
| 1071 | msg "test: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan" |
| 1072 | make test |
| 1073 | } |
| 1074 | |
Gilles Peskine | a354867 | 2021-06-17 11:37:52 +0200 | [diff] [blame] | 1075 | # check_renamed_symbols HEADER LIB |
| 1076 | # Check that if HEADER contains '#define MACRO ...' then MACRO is not a symbol |
| 1077 | # name is LIB. |
| 1078 | check_renamed_symbols () { |
| 1079 | ! nm "$2" | sed 's/.* //' | |
| 1080 | grep -x -F "$(sed -n 's/^ *# *define *\([A-Z_a-z][0-9A-Z_a-z]*\)..*/\1/p' "$1")" |
| 1081 | } |
| 1082 | |
Gilles Peskine | d1dcfd5 | 2021-06-15 18:37:38 +0200 | [diff] [blame] | 1083 | component_build_psa_crypto_spm () { |
Andrzej Kurek | 03e0146 | 2022-01-03 12:53:24 +0100 | [diff] [blame] | 1084 | msg "build: full config + PSA_CRYPTO_KEY_ID_ENCODES_OWNER + PSA_CRYPTO_SPM, make, gcc" |
Gilles Peskine | d1dcfd5 | 2021-06-15 18:37:38 +0200 | [diff] [blame] | 1085 | scripts/config.py full |
Gilles Peskine | d1dcfd5 | 2021-06-15 18:37:38 +0200 | [diff] [blame] | 1086 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS |
| 1087 | scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER |
| 1088 | scripts/config.py set MBEDTLS_PSA_CRYPTO_SPM |
| 1089 | # We can only compile, not link, since our test and sample programs |
| 1090 | # aren't equipped for the modified names used when MBEDTLS_PSA_CRYPTO_SPM |
| 1091 | # is active. |
| 1092 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' lib |
Gilles Peskine | a354867 | 2021-06-17 11:37:52 +0200 | [diff] [blame] | 1093 | |
| 1094 | # Check that if a symbol is renamed by crypto_spe.h, the non-renamed |
| 1095 | # version is not present. |
| 1096 | echo "Checking for renamed symbols in the library" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1097 | check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a |
Gilles Peskine | d1dcfd5 | 2021-06-15 18:37:38 +0200 | [diff] [blame] | 1098 | } |
| 1099 | |
Ronald Cron | 336678b | 2021-01-28 17:54:24 +0100 | [diff] [blame] | 1100 | component_test_psa_crypto_client () { |
| 1101 | msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make" |
| 1102 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 1103 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 1104 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT |
Raef Coles | b4568c5 | 2022-09-28 17:11:42 +0100 | [diff] [blame] | 1105 | scripts/config.py unset MBEDTLS_LMS_C |
| 1106 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
Ronald Cron | 336678b | 2021-01-28 17:54:24 +0100 | [diff] [blame] | 1107 | make |
| 1108 | |
| 1109 | msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT, make" |
| 1110 | make test |
| 1111 | } |
| 1112 | |
Jaeden Amero | 424fa93 | 2021-05-14 08:34:32 +0100 | [diff] [blame] | 1113 | component_test_psa_crypto_rsa_no_genprime() { |
| 1114 | msg "build: default config minus MBEDTLS_GENPRIME" |
| 1115 | scripts/config.py unset MBEDTLS_GENPRIME |
| 1116 | make |
| 1117 | |
| 1118 | msg "test: default config minus MBEDTLS_GENPRIME" |
| 1119 | make test |
| 1120 | } |
| 1121 | |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 1122 | component_test_ref_configs () { |
| 1123 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
Manuel Pégourié-Gonnard | 9327fb3 | 2021-09-09 11:46:25 +0200 | [diff] [blame] | 1124 | # test-ref-configs works by overwriting mbedtls_config.h; this makes cmake |
| 1125 | # want to re-generate generated files that depend on it, quite correctly. |
| 1126 | # However this doesn't work as the generation script expects a specific |
| 1127 | # format for mbedtls_config.h, which the other files don't follow. Also, |
| 1128 | # cmake can't know this, but re-generation is actually not necessary as |
David Horstmann | d64f4b2 | 2021-10-20 12:29:47 +0100 | [diff] [blame] | 1129 | # the generated files only depend on the list of available options, not |
Manuel Pégourié-Gonnard | 9327fb3 | 2021-09-09 11:46:25 +0200 | [diff] [blame] | 1130 | # whether they're on or off. So, disable cmake's (over-sensitive here) |
| 1131 | # dependency resolution for generated files and just rely on them being |
David Horstmann | a8d1406 | 2021-10-20 17:14:23 +0100 | [diff] [blame] | 1132 | # present (thanks to pre_generate_files) by turning GEN_FILES off. |
| 1133 | CC=gcc cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan . |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1134 | tests/scripts/test-ref-configs.pl |
Gilles Peskine | 782f411 | 2018-11-27 16:11:09 +0100 | [diff] [blame] | 1135 | } |
Manuel Pégourié-Gonnard | 57255b1 | 2014-06-09 11:21:49 +0200 | [diff] [blame] | 1136 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1137 | component_test_no_renegotiation () { |
| 1138 | msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1139 | scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1140 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1141 | make |
Simon Butcher | 3ea7f52 | 2016-03-07 23:22:10 +0000 | [diff] [blame] | 1142 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1143 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1144 | make test |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 1145 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1146 | msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1147 | tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1148 | } |
Hanno Becker | 134c2ab | 2017-10-12 15:29:50 +0100 | [diff] [blame] | 1149 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1150 | component_test_no_pem_no_fs () { |
| 1151 | msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)" |
| 1152 | scripts/config.py unset MBEDTLS_PEM_PARSE_C |
| 1153 | scripts/config.py unset MBEDTLS_FS_IO |
| 1154 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem |
| 1155 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS |
| 1156 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1157 | make |
| 1158 | |
| 1159 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1160 | make test |
| 1161 | |
| 1162 | msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1163 | tests/ssl-opt.sh |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1164 | } |
| 1165 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1166 | component_test_rsa_no_crt () { |
| 1167 | msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1168 | scripts/config.py set MBEDTLS_RSA_NO_CRT |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1169 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1170 | make |
Manuel Pégourié-Gonnard | 246978d | 2014-11-20 13:29:53 +0100 | [diff] [blame] | 1171 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1172 | msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1173 | make test |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1174 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1175 | msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1176 | tests/ssl-opt.sh -f RSA |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1177 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1178 | msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1179 | tests/compat.sh -t RSA |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 1180 | |
| 1181 | msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1182 | tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1183 | } |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1184 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1185 | component_test_no_ctr_drbg_classic () { |
| 1186 | msg "build: Full minus CTR_DRBG, classic crypto in TLS" |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 1187 | scripts/config.py full |
| 1188 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1189 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 1190 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 1191 | |
| 1192 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1193 | make |
| 1194 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1195 | msg "test: Full minus CTR_DRBG, classic crypto - main suites" |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 1196 | make test |
| 1197 | |
Gilles Peskine | ba74904 | 2021-01-13 20:02:03 +0100 | [diff] [blame] | 1198 | # In this configuration, the TLS test programs use HMAC_DRBG. |
| 1199 | # The SSL tests are slow, so run a small subset, just enough to get |
| 1200 | # confidence that the SSL code copes with HMAC_DRBG. |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1201 | msg "test: Full minus CTR_DRBG, classic crypto - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1202 | tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server' |
Gilles Peskine | ba74904 | 2021-01-13 20:02:03 +0100 | [diff] [blame] | 1203 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1204 | msg "test: Full minus CTR_DRBG, classic crypto - compat.sh (subset)" |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 1205 | tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 1206 | } |
| 1207 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1208 | component_test_no_ctr_drbg_use_psa () { |
| 1209 | msg "build: Full minus CTR_DRBG, PSA crypto in TLS" |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 1210 | scripts/config.py full |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1211 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 1212 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 1213 | |
| 1214 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1215 | make |
| 1216 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1217 | msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - main suites" |
| 1218 | make test |
| 1219 | |
| 1220 | # In this configuration, the TLS test programs use HMAC_DRBG. |
| 1221 | # The SSL tests are slow, so run a small subset, just enough to get |
| 1222 | # confidence that the SSL code copes with HMAC_DRBG. |
| 1223 | msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1224 | tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server' |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1225 | |
| 1226 | msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - compat.sh (subset)" |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 1227 | tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | component_test_no_hmac_drbg_classic () { |
| 1231 | msg "build: Full minus HMAC_DRBG, classic crypto in TLS" |
| 1232 | scripts/config.py full |
| 1233 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 1234 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 1235 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 1236 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1237 | |
| 1238 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1239 | make |
| 1240 | |
| 1241 | msg "test: Full minus HMAC_DRBG, classic crypto - main suites" |
Manuel Pégourié-Gonnard | 5b942dc | 2020-06-05 09:29:51 +0200 | [diff] [blame] | 1242 | make test |
| 1243 | |
Gilles Peskine | a222434 | 2020-11-19 22:14:34 +0100 | [diff] [blame] | 1244 | # Normally our ECDSA implementation uses deterministic ECDSA. But since |
| 1245 | # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used |
| 1246 | # instead. |
| 1247 | # Test SSL with non-deterministic ECDSA. Only test features that |
| 1248 | # might be affected by how ECDSA signature is performed. |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1249 | msg "test: Full minus HMAC_DRBG, classic crypto - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1250 | tests/ssl-opt.sh -f 'Default\|SSL async private: sign' |
Gilles Peskine | a222434 | 2020-11-19 22:14:34 +0100 | [diff] [blame] | 1251 | |
| 1252 | # To save time, only test one protocol version, since this part of |
| 1253 | # the protocol is identical in (D)TLS up to 1.2. |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1254 | msg "test: Full minus HMAC_DRBG, classic crypto - compat.sh (ECDSA)" |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 1255 | tests/compat.sh -m tls12 -t 'ECDSA' |
Manuel Pégourié-Gonnard | 817e368 | 2020-05-28 12:55:10 +0200 | [diff] [blame] | 1256 | } |
| 1257 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1258 | component_test_no_hmac_drbg_use_psa () { |
| 1259 | msg "build: Full minus HMAC_DRBG, PSA crypto in TLS" |
| 1260 | scripts/config.py full |
| 1261 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 1262 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
| 1263 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
| 1264 | |
| 1265 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1266 | make |
| 1267 | |
| 1268 | msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - main suites" |
| 1269 | make test |
| 1270 | |
| 1271 | # Normally our ECDSA implementation uses deterministic ECDSA. But since |
| 1272 | # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used |
| 1273 | # instead. |
| 1274 | # Test SSL with non-deterministic ECDSA. Only test features that |
| 1275 | # might be affected by how ECDSA signature is performed. |
| 1276 | msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1277 | tests/ssl-opt.sh -f 'Default\|SSL async private: sign' |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1278 | |
| 1279 | # To save time, only test one protocol version, since this part of |
| 1280 | # the protocol is identical in (D)TLS up to 1.2. |
| 1281 | msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - compat.sh (ECDSA)" |
Xiaofei Bai | 8b5c382 | 2021-12-02 08:43:35 +0000 | [diff] [blame] | 1282 | tests/compat.sh -m tls12 -t 'ECDSA' |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1283 | } |
| 1284 | |
| 1285 | component_test_psa_external_rng_no_drbg_classic () { |
| 1286 | msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto in TLS" |
| 1287 | scripts/config.py full |
| 1288 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 1289 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1290 | scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG |
Gilles Peskine | 38c12fd | 2021-02-08 21:02:53 +0100 | [diff] [blame] | 1291 | scripts/config.py unset MBEDTLS_ENTROPY_C |
| 1292 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1293 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1294 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 1295 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 1296 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
Gilles Peskine | 8eb2943 | 2021-02-03 20:07:11 +0100 | [diff] [blame] | 1297 | # When MBEDTLS_USE_PSA_CRYPTO is disabled and there is no DRBG, |
| 1298 | # the SSL test programs don't have an RNG and can't work. Explicitly |
| 1299 | # make them use the PSA RNG with -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG. |
| 1300 | make CFLAGS="$ASAN_CFLAGS -O2 -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1301 | |
| 1302 | msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - main suites" |
| 1303 | make test |
| 1304 | |
Gilles Peskine | 8eb2943 | 2021-02-03 20:07:11 +0100 | [diff] [blame] | 1305 | msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1306 | tests/ssl-opt.sh -f 'Default' |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1307 | } |
| 1308 | |
| 1309 | component_test_psa_external_rng_no_drbg_use_psa () { |
| 1310 | msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto in TLS" |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1311 | scripts/config.py full |
| 1312 | scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG |
Gilles Peskine | 38c12fd | 2021-02-08 21:02:53 +0100 | [diff] [blame] | 1313 | scripts/config.py unset MBEDTLS_ENTROPY_C |
| 1314 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1315 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1316 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 1317 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
| 1318 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1319 | make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1320 | |
Gilles Peskine | 2747d7d | 2021-02-03 14:56:51 +0100 | [diff] [blame] | 1321 | msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - main suites" |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1322 | make test |
| 1323 | |
Gilles Peskine | 8eb2943 | 2021-02-03 20:07:11 +0100 | [diff] [blame] | 1324 | msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - ssl-opt.sh (subset)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1325 | tests/ssl-opt.sh -f 'Default\|opaque' |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1326 | } |
| 1327 | |
Andrzej Kurek | 06969fc | 2023-04-12 10:34:50 -0400 | [diff] [blame] | 1328 | component_test_sw_inet_pton () { |
| 1329 | msg "build: default plus MBEDTLS_TEST_SW_INET_PTON" |
| 1330 | |
| 1331 | # MBEDTLS_TEST_HOOKS required for x509_crt_parse_cn_inet_pton |
| 1332 | scripts/config.py set MBEDTLS_TEST_HOOKS |
| 1333 | make CFLAGS="-DMBEDTLS_TEST_SW_INET_PTON" |
| 1334 | |
| 1335 | msg "test: default plus MBEDTLS_TEST_SW_INET_PTON" |
| 1336 | make test |
| 1337 | } |
| 1338 | |
Manuel Pégourié-Gonnard | b9b630d | 2023-02-16 19:07:31 +0100 | [diff] [blame] | 1339 | component_test_crypto_full_md_light_only () { |
| 1340 | msg "build: crypto_full with only the light subset of MD" |
Przemek Stekiel | fe2367a | 2022-04-28 15:44:18 +0200 | [diff] [blame] | 1341 | scripts/config.py crypto_full |
Manuel Pégourié-Gonnard | b9b630d | 2023-02-16 19:07:31 +0100 | [diff] [blame] | 1342 | # Disable MD |
Przemek Stekiel | fe2367a | 2022-04-28 15:44:18 +0200 | [diff] [blame] | 1343 | scripts/config.py unset MBEDTLS_MD_C |
Manuel Pégourié-Gonnard | 49e67f8 | 2023-03-16 11:39:20 +0100 | [diff] [blame] | 1344 | # Disable direct dependencies of MD_C |
Przemek Stekiel | fe2367a | 2022-04-28 15:44:18 +0200 | [diff] [blame] | 1345 | scripts/config.py unset MBEDTLS_HKDF_C |
| 1346 | scripts/config.py unset MBEDTLS_HMAC_DRBG_C |
Nick Child | 89e82e1 | 2022-11-09 10:36:10 -0600 | [diff] [blame] | 1347 | scripts/config.py unset MBEDTLS_PKCS7_C |
Manuel Pégourié-Gonnard | 49e67f8 | 2023-03-16 11:39:20 +0100 | [diff] [blame] | 1348 | # Disable indirect dependencies of MD_C |
Manuel Pégourié-Gonnard | b9b630d | 2023-02-16 19:07:31 +0100 | [diff] [blame] | 1349 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # needs HMAC_DRBG |
Manuel Pégourié-Gonnard | 49e67f8 | 2023-03-16 11:39:20 +0100 | [diff] [blame] | 1350 | # Disable things that would auto-enable MD_C |
| 1351 | scripts/config.py unset MBEDTLS_PKCS5_C |
| 1352 | |
Manuel Pégourié-Gonnard | 1b5ffc6 | 2023-03-14 10:11:20 +0100 | [diff] [blame] | 1353 | # Note: MD-light is auto-enabled in build_info.h by modules that need it, |
| 1354 | # which we haven't disabled, so no need to explicitly enable it. |
| 1355 | make CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" |
Przemek Stekiel | fe2367a | 2022-04-28 15:44:18 +0200 | [diff] [blame] | 1356 | |
Manuel Pégourié-Gonnard | 0d41521 | 2023-02-23 13:02:13 +0100 | [diff] [blame] | 1357 | # Make sure we don't have the HMAC functions, but the hashing functions |
Manuel Pégourié-Gonnard | b9b630d | 2023-02-16 19:07:31 +0100 | [diff] [blame] | 1358 | not grep mbedtls_md_hmac library/md.o |
Manuel Pégourié-Gonnard | 0d41521 | 2023-02-23 13:02:13 +0100 | [diff] [blame] | 1359 | grep mbedtls_md library/md.o |
Manuel Pégourié-Gonnard | b9b630d | 2023-02-16 19:07:31 +0100 | [diff] [blame] | 1360 | |
| 1361 | msg "test: crypto_full with only the light subset of MD" |
Przemek Stekiel | fe2367a | 2022-04-28 15:44:18 +0200 | [diff] [blame] | 1362 | make test |
| 1363 | } |
| 1364 | |
Przemek Stekiel | 10f3a60 | 2022-05-02 10:55:33 +0200 | [diff] [blame] | 1365 | component_test_full_no_cipher () { |
| 1366 | msg "build: full minus CIPHER" |
| 1367 | scripts/config.py full |
| 1368 | scripts/config.py unset MBEDTLS_CIPHER_C |
Przemek Stekiel | da5f483 | 2022-05-12 09:46:29 +0200 | [diff] [blame] | 1369 | # Direct dependencies |
| 1370 | scripts/config.py unset MBEDTLS_CCM_C |
Przemek Stekiel | 10f3a60 | 2022-05-02 10:55:33 +0200 | [diff] [blame] | 1371 | scripts/config.py unset MBEDTLS_CMAC_C |
Przemek Stekiel | da5f483 | 2022-05-12 09:46:29 +0200 | [diff] [blame] | 1372 | scripts/config.py unset MBEDTLS_GCM_C |
Przemek Stekiel | 10f3a60 | 2022-05-02 10:55:33 +0200 | [diff] [blame] | 1373 | scripts/config.py unset MBEDTLS_NIST_KW_C |
| 1374 | scripts/config.py unset MBEDTLS_PKCS12_C |
| 1375 | scripts/config.py unset MBEDTLS_PKCS5_C |
Przemek Stekiel | 10f3a60 | 2022-05-02 10:55:33 +0200 | [diff] [blame] | 1376 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 1377 | scripts/config.py unset MBEDTLS_SSL_TLS_C |
| 1378 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
Przemek Stekiel | da5f483 | 2022-05-12 09:46:29 +0200 | [diff] [blame] | 1379 | # Indirect dependencies |
| 1380 | scripts/config.py unset MBEDTLS_SSL_CLI_C |
Przemek Stekiel | 10f3a60 | 2022-05-02 10:55:33 +0200 | [diff] [blame] | 1381 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 1382 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Przemek Stekiel | 10f3a60 | 2022-05-02 10:55:33 +0200 | [diff] [blame] | 1383 | scripts/config.py unset MBEDTLS_SSL_DTLS_ANTI_REPLAY |
| 1384 | scripts/config.py unset MBEDTLS_SSL_DTLS_CONNECTION_ID |
Dave Rodgman | 1df7070 | 2022-10-26 17:08:54 +0100 | [diff] [blame] | 1385 | scripts/config.py unset MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT |
Przemek Stekiel | da5f483 | 2022-05-12 09:46:29 +0200 | [diff] [blame] | 1386 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 1387 | scripts/config.py unset MBEDTLS_SSL_SRV_C |
Przemek Stekiel | 10f3a60 | 2022-05-02 10:55:33 +0200 | [diff] [blame] | 1388 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Raef Coles | a7e03ad | 2022-09-28 09:32:48 +0100 | [diff] [blame] | 1389 | scripts/config.py unset MBEDTLS_LMS_C |
Raef Coles | 47bccb7 | 2022-09-28 12:00:20 +0100 | [diff] [blame] | 1390 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
Przemek Stekiel | 10f3a60 | 2022-05-02 10:55:33 +0200 | [diff] [blame] | 1391 | make |
| 1392 | |
| 1393 | msg "test: full minus CIPHER" |
| 1394 | make test |
| 1395 | } |
| 1396 | |
Przemek Stekiel | 179d748 | 2022-05-02 11:03:35 +0200 | [diff] [blame] | 1397 | component_test_crypto_full_no_cipher () { |
| 1398 | msg "build: crypto_full minus CIPHER" |
| 1399 | scripts/config.py crypto_full |
| 1400 | scripts/config.py unset MBEDTLS_CIPHER_C |
Przemek Stekiel | da5f483 | 2022-05-12 09:46:29 +0200 | [diff] [blame] | 1401 | # Direct dependencies |
| 1402 | scripts/config.py unset MBEDTLS_CCM_C |
Przemek Stekiel | 179d748 | 2022-05-02 11:03:35 +0200 | [diff] [blame] | 1403 | scripts/config.py unset MBEDTLS_CMAC_C |
Przemek Stekiel | da5f483 | 2022-05-12 09:46:29 +0200 | [diff] [blame] | 1404 | scripts/config.py unset MBEDTLS_GCM_C |
Przemek Stekiel | 179d748 | 2022-05-02 11:03:35 +0200 | [diff] [blame] | 1405 | scripts/config.py unset MBEDTLS_NIST_KW_C |
| 1406 | scripts/config.py unset MBEDTLS_PKCS12_C |
| 1407 | scripts/config.py unset MBEDTLS_PKCS5_C |
Przemek Stekiel | 179d748 | 2022-05-02 11:03:35 +0200 | [diff] [blame] | 1408 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
Przemek Stekiel | da5f483 | 2022-05-12 09:46:29 +0200 | [diff] [blame] | 1409 | # Indirect dependencies |
Przemek Stekiel | 179d748 | 2022-05-02 11:03:35 +0200 | [diff] [blame] | 1410 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 1411 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 1412 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Raef Coles | a7e03ad | 2022-09-28 09:32:48 +0100 | [diff] [blame] | 1413 | scripts/config.py unset MBEDTLS_LMS_C |
Raef Coles | 47bccb7 | 2022-09-28 12:00:20 +0100 | [diff] [blame] | 1414 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
Przemek Stekiel | 179d748 | 2022-05-02 11:03:35 +0200 | [diff] [blame] | 1415 | make |
| 1416 | |
| 1417 | msg "test: crypto_full minus CIPHER" |
| 1418 | make test |
| 1419 | } |
| 1420 | |
Valerio Setti | e1655b8 | 2023-01-03 15:35:25 +0100 | [diff] [blame] | 1421 | component_test_full_no_bignum () { |
| 1422 | msg "build: full minus bignum" |
| 1423 | scripts/config.py full |
| 1424 | scripts/config.py unset MBEDTLS_BIGNUM_C |
| 1425 | # Direct dependencies of bignum |
| 1426 | scripts/config.py unset MBEDTLS_ECP_C |
| 1427 | scripts/config.py unset MBEDTLS_RSA_C |
| 1428 | scripts/config.py unset MBEDTLS_DHM_C |
| 1429 | # Direct dependencies of ECP |
| 1430 | scripts/config.py unset MBEDTLS_ECDH_C |
| 1431 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 1432 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
| 1433 | scripts/config.py unset MBEDTLS_ECP_RESTARTABLE |
Valerio Setti | 22d0a79 | 2023-06-14 17:23:19 +0200 | [diff] [blame] | 1434 | # Disable what auto-enables ECP_LIGHT |
| 1435 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED |
| 1436 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_COMPRESSED |
Valerio Setti | e1655b8 | 2023-01-03 15:35:25 +0100 | [diff] [blame] | 1437 | # Indirect dependencies of ECP |
| 1438 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 1439 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 1440 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED |
| 1441 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 1442 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 1443 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED |
| 1444 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED |
| 1445 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED |
| 1446 | # Direct dependencies of DHM |
| 1447 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED |
| 1448 | # Direct dependencies of RSA |
| 1449 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED |
| 1450 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED |
| 1451 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED |
| 1452 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
| 1453 | # PK and its dependencies |
| 1454 | scripts/config.py unset MBEDTLS_PK_C |
| 1455 | scripts/config.py unset MBEDTLS_PK_PARSE_C |
| 1456 | scripts/config.py unset MBEDTLS_PK_WRITE_C |
| 1457 | scripts/config.py unset MBEDTLS_X509_USE_C |
| 1458 | scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C |
| 1459 | scripts/config.py unset MBEDTLS_X509_CRL_PARSE_C |
| 1460 | scripts/config.py unset MBEDTLS_X509_CSR_PARSE_C |
| 1461 | scripts/config.py unset MBEDTLS_X509_CREATE_C |
| 1462 | scripts/config.py unset MBEDTLS_X509_CRT_WRITE_C |
| 1463 | scripts/config.py unset MBEDTLS_X509_CSR_WRITE_C |
| 1464 | scripts/config.py unset MBEDTLS_PKCS7_C |
| 1465 | scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION |
| 1466 | scripts/config.py unset MBEDTLS_SSL_ASYNC_PRIVATE |
| 1467 | scripts/config.py unset MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK |
| 1468 | |
| 1469 | make |
| 1470 | |
| 1471 | msg "test: full minus bignum" |
| 1472 | make test |
| 1473 | } |
| 1474 | |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1475 | component_test_tls1_2_default_stream_cipher_only () { |
Przemek Stekiel | 11c362a | 2022-09-27 13:34:31 +0200 | [diff] [blame] | 1476 | msg "build: default with only stream cipher" |
| 1477 | |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1478 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C |
Przemek Stekiel | 11c362a | 2022-09-27 13:34:31 +0200 | [diff] [blame] | 1479 | scripts/config.py unset MBEDTLS_GCM_C |
| 1480 | scripts/config.py unset MBEDTLS_CCM_C |
| 1481 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1482 | # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
Przemek Stekiel | 11c362a | 2022-09-27 13:34:31 +0200 | [diff] [blame] | 1483 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1484 | # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
Przemek Stekiel | 11c362a | 2022-09-27 13:34:31 +0200 | [diff] [blame] | 1485 | scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1486 | # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
| 1487 | scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1488 | # Modules that depend on AEAD |
Przemek Stekiel | d582a01 | 2022-09-28 07:59:01 +0200 | [diff] [blame] | 1489 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
Przemek Stekiel | 52a428b | 2022-10-10 08:47:13 +0200 | [diff] [blame] | 1490 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
Przemek Stekiel | 11c362a | 2022-09-27 13:34:31 +0200 | [diff] [blame] | 1491 | |
Przemek Stekiel | 11c362a | 2022-09-27 13:34:31 +0200 | [diff] [blame] | 1492 | make |
| 1493 | |
| 1494 | msg "test: default with only stream cipher" |
| 1495 | make test |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1496 | |
| 1497 | # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite. |
Przemek Stekiel | 11c362a | 2022-09-27 13:34:31 +0200 | [diff] [blame] | 1498 | } |
| 1499 | |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1500 | component_test_tls1_2_default_stream_cipher_only_use_psa () { |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1501 | msg "build: default with only stream cipher use psa" |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1502 | |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1503 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1504 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C) |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1505 | scripts/config.py unset MBEDTLS_GCM_C |
| 1506 | scripts/config.py unset MBEDTLS_CCM_C |
| 1507 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1508 | # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1509 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1510 | # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1511 | scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1512 | # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
| 1513 | scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1514 | # Modules that depend on AEAD |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1515 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
Przemek Stekiel | 52a428b | 2022-10-10 08:47:13 +0200 | [diff] [blame] | 1516 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1517 | |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1518 | make |
| 1519 | |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1520 | msg "test: default with only stream cipher use psa" |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1521 | make test |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1522 | |
| 1523 | # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite. |
Przemek Stekiel | 9550c05 | 2022-09-28 09:51:55 +0200 | [diff] [blame] | 1524 | } |
Przemek Stekiel | 11c362a | 2022-09-27 13:34:31 +0200 | [diff] [blame] | 1525 | |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1526 | component_test_tls1_2_default_cbc_legacy_cipher_only () { |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1527 | msg "build: default with only CBC-legacy cipher" |
| 1528 | |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1529 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C) |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1530 | scripts/config.py unset MBEDTLS_GCM_C |
| 1531 | scripts/config.py unset MBEDTLS_CCM_C |
| 1532 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1533 | # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
| 1534 | scripts/config.py set MBEDTLS_CIPHER_MODE_CBC |
| 1535 | # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1536 | scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1537 | # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1538 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1539 | # Modules that depend on AEAD |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1540 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
Przemek Stekiel | 52a428b | 2022-10-10 08:47:13 +0200 | [diff] [blame] | 1541 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1542 | |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1543 | make |
| 1544 | |
| 1545 | msg "test: default with only CBC-legacy cipher" |
| 1546 | make test |
Przemek Stekiel | 48a6a66 | 2022-09-29 15:22:01 +0200 | [diff] [blame] | 1547 | |
| 1548 | msg "test: default with only CBC-legacy cipher - ssl-opt.sh (subset)" |
| 1549 | tests/ssl-opt.sh -f "TLS 1.2" |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1550 | } |
| 1551 | |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1552 | component_test_tls1_2_deafult_cbc_legacy_cipher_only_use_psa () { |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1553 | msg "build: default with only CBC-legacy cipher use psa" |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1554 | |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1555 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1556 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C) |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1557 | scripts/config.py unset MBEDTLS_GCM_C |
| 1558 | scripts/config.py unset MBEDTLS_CCM_C |
| 1559 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1560 | # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
| 1561 | scripts/config.py set MBEDTLS_CIPHER_MODE_CBC |
| 1562 | # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1563 | scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1564 | # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1565 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1566 | # Modules that depend on AEAD |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1567 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
Przemek Stekiel | 52a428b | 2022-10-10 08:47:13 +0200 | [diff] [blame] | 1568 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1569 | |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1570 | make |
| 1571 | |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1572 | msg "test: default with only CBC-legacy cipher use psa" |
| 1573 | make test |
Przemek Stekiel | 48a6a66 | 2022-09-29 15:22:01 +0200 | [diff] [blame] | 1574 | |
| 1575 | msg "test: default with only CBC-legacy cipher use psa - ssl-opt.sh (subset)" |
| 1576 | tests/ssl-opt.sh -f "TLS 1.2" |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1577 | } |
| 1578 | |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1579 | component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only () { |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1580 | msg "build: default with only CBC-legacy and CBC-EtM ciphers" |
| 1581 | |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1582 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C) |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1583 | scripts/config.py unset MBEDTLS_GCM_C |
| 1584 | scripts/config.py unset MBEDTLS_CCM_C |
| 1585 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1586 | # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
| 1587 | scripts/config.py set MBEDTLS_CIPHER_MODE_CBC |
| 1588 | # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
| 1589 | scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC |
| 1590 | # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1591 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1592 | # Modules that depend on AEAD |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1593 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
Przemek Stekiel | 52a428b | 2022-10-10 08:47:13 +0200 | [diff] [blame] | 1594 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1595 | |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1596 | make |
| 1597 | |
| 1598 | msg "test: default with only CBC-legacy and CBC-EtM ciphers" |
| 1599 | make test |
Przemek Stekiel | 48a6a66 | 2022-09-29 15:22:01 +0200 | [diff] [blame] | 1600 | |
| 1601 | msg "test: default with only CBC-legacy and CBC-EtM ciphers - ssl-opt.sh (subset)" |
| 1602 | tests/ssl-opt.sh -f "TLS 1.2" |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1603 | } |
| 1604 | |
Przemek Stekiel | 48a6a66 | 2022-09-29 15:22:01 +0200 | [diff] [blame] | 1605 | component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only_use_psa () { |
| 1606 | msg "build: default with only CBC-legacy and CBC-EtM ciphers use psa" |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1607 | |
| 1608 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1609 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C) |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1610 | scripts/config.py unset MBEDTLS_GCM_C |
| 1611 | scripts/config.py unset MBEDTLS_CCM_C |
| 1612 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
Przemek Stekiel | 68db0d2 | 2022-09-29 08:32:25 +0200 | [diff] [blame] | 1613 | # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
| 1614 | scripts/config.py set MBEDTLS_CIPHER_MODE_CBC |
| 1615 | # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
| 1616 | scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC |
| 1617 | # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1618 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
Przemek Stekiel | 6a5cc74 | 2022-10-03 09:04:16 +0200 | [diff] [blame] | 1619 | # Modules that depend on AEAD |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1620 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
Przemek Stekiel | 52a428b | 2022-10-10 08:47:13 +0200 | [diff] [blame] | 1621 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1622 | |
Przemek Stekiel | 0cc3466 | 2022-09-28 12:06:57 +0200 | [diff] [blame] | 1623 | make |
| 1624 | |
Przemek Stekiel | 48a6a66 | 2022-09-29 15:22:01 +0200 | [diff] [blame] | 1625 | msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa" |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1626 | make test |
Przemek Stekiel | 48a6a66 | 2022-09-29 15:22:01 +0200 | [diff] [blame] | 1627 | |
| 1628 | msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa - ssl-opt.sh (subset)" |
| 1629 | tests/ssl-opt.sh -f "TLS 1.2" |
Przemek Stekiel | b0de1c0 | 2022-09-28 10:23:22 +0200 | [diff] [blame] | 1630 | } |
| 1631 | |
Valerio Setti | 9f0ec53 | 2022-11-08 13:03:24 +0100 | [diff] [blame] | 1632 | # We're not aware of any other (open source) implementation of EC J-PAKE in TLS |
| 1633 | # that we could use for interop testing. However, we now have sort of two |
| 1634 | # implementations ourselves: one using PSA, the other not. At least test that |
| 1635 | # these two interoperate with each other. |
| 1636 | component_test_tls1_2_ecjpake_compatibility() { |
| 1637 | msg "build: TLS1.2 server+client w/ EC-JPAKE w/o USE_PSA" |
| 1638 | scripts/config.py set MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED |
| 1639 | make -C programs ssl/ssl_server2 ssl/ssl_client2 |
| 1640 | cp programs/ssl/ssl_server2 s2_no_use_psa |
| 1641 | cp programs/ssl/ssl_client2 c2_no_use_psa |
| 1642 | |
| 1643 | msg "build: TLS1.2 server+client w/ EC-JPAKE w/ USE_PSA" |
| 1644 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
| 1645 | make clean |
| 1646 | make -C programs ssl/ssl_server2 ssl/ssl_client2 |
| 1647 | make -C programs test/udp_proxy test/query_compile_time_config |
| 1648 | |
Valerio Setti | 70e0290 | 2022-12-02 16:21:56 +0100 | [diff] [blame] | 1649 | msg "test: server w/o USE_PSA - client w/ USE_PSA, text password" |
| 1650 | P_SRV=../s2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: working, TLS" |
| 1651 | msg "test: server w/o USE_PSA - client w/ USE_PSA, opaque password" |
| 1652 | P_SRV=../s2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: opaque password client only, working, TLS" |
| 1653 | msg "test: client w/o USE_PSA - server w/ USE_PSA, text password" |
| 1654 | P_CLI=../c2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: working, TLS" |
| 1655 | msg "test: client w/o USE_PSA - server w/ USE_PSA, opaque password" |
| 1656 | P_CLI=../c2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: opaque password server only, working, TLS" |
Valerio Setti | 9f0ec53 | 2022-11-08 13:03:24 +0100 | [diff] [blame] | 1657 | |
| 1658 | rm s2_no_use_psa c2_no_use_psa |
| 1659 | } |
| 1660 | |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1661 | component_test_psa_external_rng_use_psa_crypto () { |
| 1662 | msg "build: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG" |
| 1663 | scripts/config.py full |
| 1664 | scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG |
| 1665 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
| 1666 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 1667 | make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1668 | |
| 1669 | msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG" |
| 1670 | make test |
| 1671 | |
Gilles Peskine | ba74904 | 2021-01-13 20:02:03 +0100 | [diff] [blame] | 1672 | msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1673 | tests/ssl-opt.sh -f 'Default\|opaque' |
Gilles Peskine | c109b37 | 2020-11-23 17:39:04 +0100 | [diff] [blame] | 1674 | } |
| 1675 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1676 | component_test_everest () { |
| 1677 | msg "build: Everest ECDH context (ASan build)" # ~ 6 min |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1678 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 1679 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1680 | make |
| 1681 | |
| 1682 | msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1683 | make test |
| 1684 | |
| 1685 | msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1686 | tests/ssl-opt.sh -f ECDH |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1687 | |
| 1688 | msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 1689 | # Exclude some symmetric ciphers that are redundant here to gain time. |
Manuel Pégourié-Gonnard | 296787f | 2022-04-06 13:28:27 +0200 | [diff] [blame] | 1690 | tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA' |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1691 | } |
| 1692 | |
Gilles Peskine | d3beca9 | 2020-07-03 00:15:37 +0200 | [diff] [blame] | 1693 | component_test_everest_curve25519_only () { |
| 1694 | msg "build: Everest ECDH context, only Curve25519" # ~ 6 min |
Gilles Peskine | d3beca9 | 2020-07-03 00:15:37 +0200 | [diff] [blame] | 1695 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 1696 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 1697 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 1698 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
TRodziewicz | 7c1d41d | 2021-04-23 13:33:44 +0200 | [diff] [blame] | 1699 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
Gilles Peskine | d3beca9 | 2020-07-03 00:15:37 +0200 | [diff] [blame] | 1700 | # Disable all curves |
| 1701 | for c in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do |
| 1702 | scripts/config.py unset "$c" |
| 1703 | done |
| 1704 | scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED |
| 1705 | |
| 1706 | make CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
| 1707 | |
| 1708 | msg "test: Everest ECDH context, only Curve25519" # ~ 50s |
| 1709 | make test |
| 1710 | } |
| 1711 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1712 | component_test_small_ssl_out_content_len () { |
| 1713 | msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1714 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 1715 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1716 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1717 | make |
Hanno Becker | d5ba5ef | 2017-09-28 12:53:51 +0100 | [diff] [blame] | 1718 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1719 | msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1720 | tests/ssl-opt.sh -f "Max fragment\|Large packet" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1721 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1722 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1723 | component_test_small_ssl_in_content_len () { |
| 1724 | msg "build: small SSL_IN_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1725 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096 |
| 1726 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1727 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1728 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1729 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1730 | msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1731 | tests/ssl-opt.sh -f "Max fragment" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1732 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1733 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1734 | component_test_small_ssl_dtls_max_buffering () { |
| 1735 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1736 | scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1737 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1738 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 1739 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1740 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1741 | tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1742 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1743 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1744 | component_test_small_mbedtls_ssl_dtls_max_buffering () { |
| 1745 | msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1" |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 1746 | scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1747 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 1748 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1749 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1750 | msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1751 | tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1752 | } |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1753 | |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 1754 | component_test_psa_collect_statuses () { |
| 1755 | msg "build+test: psa_collect_statuses" # ~30s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1756 | scripts/config.py full |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1757 | tests/scripts/psa_collect_statuses.py |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 1758 | # Check that psa_crypto_init() succeeded at least once |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1759 | grep -q '^0:psa_crypto_init:' tests/statuses.log |
Gilles Peskine | 75cc771 | 2019-09-06 19:47:17 +0200 | [diff] [blame] | 1760 | rm -f tests/statuses.log |
| 1761 | } |
| 1762 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1763 | component_test_full_cmake_clang () { |
| 1764 | msg "build: cmake, full config, clang" # ~ 50s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1765 | scripts/config.py full |
Gilles Peskine | da6017c | 2022-10-30 21:02:40 +0100 | [diff] [blame] | 1766 | CC=clang CXX=clang cmake -D CMAKE_BUILD_TYPE:String=Release -D ENABLE_TESTING=On -D TEST_CPP=1 . |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1767 | make |
Hanno Becker | 2f5aa4c | 2018-08-24 14:43:44 +0100 | [diff] [blame] | 1768 | |
k-stachowiak | 0291cb7 | 2019-06-26 15:52:12 +0200 | [diff] [blame] | 1769 | msg "test: main suites (full config, clang)" # ~ 5s |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1770 | make test |
Manuel Pégourié-Gonnard | 3895f5a | 2014-03-27 14:44:04 +0100 | [diff] [blame] | 1771 | |
Gilles Peskine | da6017c | 2022-10-30 21:02:40 +0100 | [diff] [blame] | 1772 | msg "test: cpp_dummy_build (full config, clang)" # ~ 1s |
| 1773 | programs/test/cpp_dummy_build |
| 1774 | |
k-stachowiak | 0291cb7 | 2019-06-26 15:52:12 +0200 | [diff] [blame] | 1775 | msg "test: psa_constant_names (full config, clang)" # ~ 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1776 | tests/scripts/test_psa_constant_names.py |
Gilles Peskine | 69e8f7f | 2020-02-26 19:51:43 +0100 | [diff] [blame] | 1777 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1778 | msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1779 | tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 1780 | |
Manuel Pégourié-Gonnard | 296787f | 2022-04-06 13:28:27 +0200 | [diff] [blame] | 1781 | msg "test: compat.sh NULL (full config)" # ~ 2 min |
Manuel Pégourié-Gonnard | c572246 | 2022-12-19 11:42:12 +0100 | [diff] [blame] | 1782 | env OPENSSL="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL' |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 1783 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1784 | msg "test: compat.sh ARIA + ChachaPoly" |
Manuel Pégourié-Gonnard | c572246 | 2022-12-19 11:42:12 +0100 | [diff] [blame] | 1785 | env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1786 | } |
Manuel Pégourié-Gonnard | e73b263 | 2014-07-12 04:00:00 +0200 | [diff] [blame] | 1787 | |
Gilles Peskine | 0c67160 | 2022-11-29 16:01:41 +0100 | [diff] [blame] | 1788 | skip_suites_without_constant_flow () { |
| 1789 | # Skip the test suites that don't have any constant-flow annotations. |
| 1790 | # This will need to be adjusted if we ever start declaring things as |
| 1791 | # secret from macros or functions inside tests/include or tests/src. |
| 1792 | SKIP_TEST_SUITES=$( |
| 1793 | git -C tests/suites grep -L TEST_CF_ 'test_suite_*.function' | |
| 1794 | sed 's/test_suite_//; s/\.function$//' | |
| 1795 | tr '\n' ,) |
| 1796 | export SKIP_TEST_SUITES |
| 1797 | } |
| 1798 | |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 1799 | component_test_memsan_constant_flow () { |
Manuel Pégourié-Gonnard | 0b2112d | 2020-07-22 11:09:28 +0200 | [diff] [blame] | 1800 | # This tests both (1) accesses to undefined memory, and (2) branches or |
| 1801 | # memory access depending on secret values. To distinguish between those: |
| 1802 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist? |
| 1803 | # - or alternatively, change the build type to MemSanDbg, which enables |
| 1804 | # origin tracking and nicer stack traces (which are useful for debugging |
| 1805 | # anyway), and check if the origin was TEST_CF_SECRET() or something else. |
Neil Armstrong | 0ab7a23 | 2022-03-18 09:57:32 +0100 | [diff] [blame] | 1806 | msg "build: cmake MSan (clang), full config minus MBEDTLS_USE_PSA_CRYPTO with constant flow testing" |
| 1807 | scripts/config.py full |
| 1808 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN |
| 1809 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1810 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1811 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1812 | make |
| 1813 | |
| 1814 | msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO, Msan + constant flow)" |
| 1815 | make test |
| 1816 | } |
| 1817 | |
| 1818 | component_test_memsan_constant_flow_psa () { |
| 1819 | # This tests both (1) accesses to undefined memory, and (2) branches or |
| 1820 | # memory access depending on secret values. To distinguish between those: |
| 1821 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist? |
| 1822 | # - or alternatively, change the build type to MemSanDbg, which enables |
| 1823 | # origin tracking and nicer stack traces (which are useful for debugging |
| 1824 | # anyway), and check if the origin was TEST_CF_SECRET() or something else. |
Manuel Pégourié-Gonnard | 0b2112d | 2020-07-22 11:09:28 +0200 | [diff] [blame] | 1825 | msg "build: cmake MSan (clang), full config with constant flow testing" |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 1826 | scripts/config.py full |
| 1827 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN |
| 1828 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1829 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1830 | make |
| 1831 | |
Manuel Pégourié-Gonnard | 0b2112d | 2020-07-22 11:09:28 +0200 | [diff] [blame] | 1832 | msg "test: main suites (Msan + constant flow)" |
Manuel Pégourié-Gonnard | 6240def | 2020-07-10 09:35:54 +0200 | [diff] [blame] | 1833 | make test |
| 1834 | } |
| 1835 | |
Manuel Pégourié-Gonnard | 73afa37 | 2020-08-19 10:27:38 +0200 | [diff] [blame] | 1836 | component_test_valgrind_constant_flow () { |
| 1837 | # This tests both (1) everything that valgrind's memcheck usually checks |
| 1838 | # (heap buffer overflows, use of uninitialized memory, use-after-free, |
| 1839 | # etc.) and (2) branches or memory access depending on secret values, |
| 1840 | # which will be reported as uninitialized memory. To distinguish between |
| 1841 | # secret and actually uninitialized: |
| 1842 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist? |
| 1843 | # - or alternatively, build with debug info and manually run the offending |
| 1844 | # test suite with valgrind --track-origins=yes, then check if the origin |
| 1845 | # was TEST_CF_SECRET() or something else. |
Neil Armstrong | 0ab7a23 | 2022-03-18 09:57:32 +0100 | [diff] [blame] | 1846 | msg "build: cmake release GCC, full config minus MBEDTLS_USE_PSA_CRYPTO with constant flow testing" |
| 1847 | scripts/config.py full |
| 1848 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND |
| 1849 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Gilles Peskine | 0c67160 | 2022-11-29 16:01:41 +0100 | [diff] [blame] | 1850 | skip_suites_without_constant_flow |
Neil Armstrong | 0ab7a23 | 2022-03-18 09:57:32 +0100 | [diff] [blame] | 1851 | cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1852 | make |
| 1853 | |
| 1854 | # this only shows a summary of the results (how many of each type) |
| 1855 | # details are left in Testing/<date>/DynamicAnalysis.xml |
Gilles Peskine | 0c67160 | 2022-11-29 16:01:41 +0100 | [diff] [blame] | 1856 | msg "test: some suites (full minus MBEDTLS_USE_PSA_CRYPTO, valgrind + constant flow)" |
Neil Armstrong | 0ab7a23 | 2022-03-18 09:57:32 +0100 | [diff] [blame] | 1857 | make memcheck |
| 1858 | } |
| 1859 | |
| 1860 | component_test_valgrind_constant_flow_psa () { |
| 1861 | # This tests both (1) everything that valgrind's memcheck usually checks |
| 1862 | # (heap buffer overflows, use of uninitialized memory, use-after-free, |
| 1863 | # etc.) and (2) branches or memory access depending on secret values, |
| 1864 | # which will be reported as uninitialized memory. To distinguish between |
| 1865 | # secret and actually uninitialized: |
| 1866 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist? |
| 1867 | # - or alternatively, build with debug info and manually run the offending |
| 1868 | # test suite with valgrind --track-origins=yes, then check if the origin |
| 1869 | # was TEST_CF_SECRET() or something else. |
Manuel Pégourié-Gonnard | 73afa37 | 2020-08-19 10:27:38 +0200 | [diff] [blame] | 1870 | msg "build: cmake release GCC, full config with constant flow testing" |
| 1871 | scripts/config.py full |
| 1872 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND |
Gilles Peskine | 0c67160 | 2022-11-29 16:01:41 +0100 | [diff] [blame] | 1873 | skip_suites_without_constant_flow |
Manuel Pégourié-Gonnard | 73afa37 | 2020-08-19 10:27:38 +0200 | [diff] [blame] | 1874 | cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1875 | make |
| 1876 | |
| 1877 | # this only shows a summary of the results (how many of each type) |
| 1878 | # details are left in Testing/<date>/DynamicAnalysis.xml |
Gilles Peskine | 0c67160 | 2022-11-29 16:01:41 +0100 | [diff] [blame] | 1879 | msg "test: some suites (valgrind + constant flow)" |
Manuel Pégourié-Gonnard | 73afa37 | 2020-08-19 10:27:38 +0200 | [diff] [blame] | 1880 | make memcheck |
| 1881 | } |
| 1882 | |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1883 | component_test_default_no_deprecated () { |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1884 | # Test that removing the deprecated features from the default |
| 1885 | # configuration leaves something consistent. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1886 | msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s |
| 1887 | scripts/config.py set MBEDTLS_DEPRECATED_REMOVED |
| 1888 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1889 | |
| 1890 | msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s |
| 1891 | make test |
| 1892 | } |
| 1893 | |
| 1894 | component_test_full_no_deprecated () { |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1895 | msg "build: make, full_no_deprecated config" # ~ 30s |
| 1896 | scripts/config.py full_no_deprecated |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1897 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1898 | |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1899 | msg "test: make, full_no_deprecated config" # ~ 5s |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1900 | make test |
Valerio Setti | 41b5fb6 | 2023-01-09 12:20:45 +0100 | [diff] [blame] | 1901 | |
| 1902 | msg "test: ensure that X509 has no direct dependency on BIGNUM_C" |
| 1903 | not grep mbedtls_mpi library/libmbedx509.a |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1904 | } |
| 1905 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1906 | component_test_full_no_deprecated_deprecated_warning () { |
| 1907 | # Test that there is nothing deprecated in "full_no_deprecated". |
| 1908 | # A deprecated feature would trigger a warning (made fatal) from |
| 1909 | # MBEDTLS_DEPRECATED_WARNING. |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1910 | msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s |
| 1911 | scripts/config.py full_no_deprecated |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1912 | scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED |
| 1913 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
| 1914 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' |
| 1915 | |
Gilles Peskine | 30de2e8 | 2020-04-20 21:39:22 +0200 | [diff] [blame] | 1916 | msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1917 | make test |
| 1918 | } |
| 1919 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1920 | component_test_full_deprecated_warning () { |
| 1921 | # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes |
| 1922 | # with only certain whitelisted types of warnings. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1923 | msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 1924 | scripts/config.py full |
| 1925 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1926 | # Expect warnings from '#warning' directives in check_config.h. |
| 1927 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs |
Manuel Pégourié-Gonnard | 6b36892 | 2018-02-20 12:02:07 +0100 | [diff] [blame] | 1928 | |
Gilles Peskine | 8386ea2 | 2020-04-30 09:07:29 +0200 | [diff] [blame] | 1929 | msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s |
| 1930 | # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features. |
| 1931 | # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set. |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1932 | # Expect warnings from '#warning' directives in check_config.h and |
| 1933 | # from the use of deprecated functions in test suites. |
| 1934 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=deprecated-declarations -Wno-error=cpp -DMBEDTLS_TEST_DEPRECATED' tests |
Gilles Peskine | 841b14b | 2019-11-26 17:37:37 +0100 | [diff] [blame] | 1935 | |
Gilles Peskine | 1093d9f | 2020-04-13 01:03:21 +0200 | [diff] [blame] | 1936 | msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s |
| 1937 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 1938 | } |
Jaeden Amero | ed93bdc | 2018-11-02 16:57:24 +0000 | [diff] [blame] | 1939 | |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1940 | # Check that the specified libraries exist and are empty. |
| 1941 | are_empty_libraries () { |
| 1942 | nm "$@" >/dev/null 2>/dev/null |
| 1943 | ! nm "$@" 2>/dev/null | grep -v ':$' | grep . |
| 1944 | } |
| 1945 | |
| 1946 | component_build_crypto_default () { |
| 1947 | msg "build: make, crypto only" |
| 1948 | scripts/config.py crypto |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 1949 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1950 | are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1951 | } |
| 1952 | |
| 1953 | component_build_crypto_full () { |
| 1954 | msg "build: make, crypto only, full config" |
| 1955 | scripts/config.py crypto_full |
Gilles Peskine | 6bb3915 | 2020-02-03 11:59:20 +0100 | [diff] [blame] | 1956 | make CFLAGS='-O1 -Werror' |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1957 | are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1958 | } |
| 1959 | |
Gilles Peskine | fc4f11b | 2022-10-21 19:34:54 +0200 | [diff] [blame] | 1960 | component_test_crypto_for_psa_service () { |
Gilles Peskine | aef1ba6 | 2022-10-11 21:05:06 +0200 | [diff] [blame] | 1961 | msg "build: make, config for PSA crypto service" |
| 1962 | scripts/config.py crypto |
| 1963 | scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER |
| 1964 | # Disable things that are not needed for just cryptography, to |
| 1965 | # reach a configuration that would be typical for a PSA cryptography |
| 1966 | # service providing all implemented PSA algorithms. |
| 1967 | # System stuff |
| 1968 | scripts/config.py unset MBEDTLS_ERROR_C |
| 1969 | scripts/config.py unset MBEDTLS_TIMING_C |
Gilles Peskine | 78bffd1 | 2022-10-25 21:02:33 +0200 | [diff] [blame] | 1970 | scripts/config.py unset MBEDTLS_VERSION_FEATURES |
Gilles Peskine | aef1ba6 | 2022-10-11 21:05:06 +0200 | [diff] [blame] | 1971 | # Crypto stuff with no PSA interface |
| 1972 | scripts/config.py unset MBEDTLS_BASE64_C |
Gilles Peskine | 649e04e | 2022-10-25 21:05:57 +0200 | [diff] [blame] | 1973 | # Keep MBEDTLS_CIPHER_C because psa_crypto_cipher, CCM and GCM need it. |
Gilles Peskine | b06f071 | 2022-10-25 21:06:11 +0200 | [diff] [blame] | 1974 | scripts/config.py unset MBEDTLS_HKDF_C # PSA's HKDF is independent |
Gilles Peskine | 649e04e | 2022-10-25 21:05:57 +0200 | [diff] [blame] | 1975 | # Keep MBEDTLS_MD_C because deterministic ECDSA needs it for HMAC_DRBG. |
Gilles Peskine | aef1ba6 | 2022-10-11 21:05:06 +0200 | [diff] [blame] | 1976 | scripts/config.py unset MBEDTLS_NIST_KW_C |
| 1977 | scripts/config.py unset MBEDTLS_PEM_PARSE_C |
| 1978 | scripts/config.py unset MBEDTLS_PEM_WRITE_C |
| 1979 | scripts/config.py unset MBEDTLS_PKCS12_C |
| 1980 | scripts/config.py unset MBEDTLS_PKCS5_C |
Gilles Peskine | fcee740 | 2022-10-11 21:15:24 +0200 | [diff] [blame] | 1981 | # MBEDTLS_PK_PARSE_C and MBEDTLS_PK_WRITE_C are actually currently needed |
| 1982 | # in PSA code to work with RSA keys. We don't require users to set those: |
| 1983 | # they will be reenabled in build_info.h. |
Gilles Peskine | 1f10807 | 2022-10-25 21:02:56 +0200 | [diff] [blame] | 1984 | scripts/config.py unset MBEDTLS_PK_C |
Gilles Peskine | fcee740 | 2022-10-11 21:15:24 +0200 | [diff] [blame] | 1985 | scripts/config.py unset MBEDTLS_PK_PARSE_C |
Gilles Peskine | aef1ba6 | 2022-10-11 21:05:06 +0200 | [diff] [blame] | 1986 | scripts/config.py unset MBEDTLS_PK_WRITE_C |
Gilles Peskine | aef1ba6 | 2022-10-11 21:05:06 +0200 | [diff] [blame] | 1987 | make CFLAGS='-O1 -Werror' all test |
| 1988 | are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
| 1989 | } |
| 1990 | |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1991 | component_build_crypto_baremetal () { |
| 1992 | msg "build: make, crypto only, baremetal config" |
| 1993 | scripts/config.py crypto_baremetal |
David Horstmann | 61faf66 | 2021-11-30 11:40:54 +0000 | [diff] [blame] | 1994 | make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 1995 | are_empty_libraries library/libmbedx509.* library/libmbedtls.* |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 1996 | } |
Daniel Axtens | 446af20 | 2020-09-02 21:30:13 +1000 | [diff] [blame] | 1997 | support_build_crypto_baremetal () { |
Daniel Axtens | 814c813 | 2020-08-31 14:22:58 +1000 | [diff] [blame] | 1998 | support_build_baremetal "$@" |
| 1999 | } |
| 2000 | |
| 2001 | component_build_baremetal () { |
| 2002 | msg "build: make, baremetal config" |
| 2003 | scripts/config.py baremetal |
David Horstmann | 61faf66 | 2021-11-30 11:40:54 +0000 | [diff] [blame] | 2004 | make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/" |
Daniel Axtens | 814c813 | 2020-08-31 14:22:58 +1000 | [diff] [blame] | 2005 | } |
| 2006 | support_build_baremetal () { |
Daniel Axtens | 446af20 | 2020-09-02 21:30:13 +1000 | [diff] [blame] | 2007 | # Older Glibc versions include time.h from other headers such as stdlib.h, |
| 2008 | # which makes the no-time.h-in-baremetal check fail. Ubuntu 16.04 has this |
| 2009 | # problem, Ubuntu 18.04 is ok. |
| 2010 | ! grep -q -F time.h /usr/include/x86_64-linux-gnu/sys/types.h |
| 2011 | } |
Gilles Peskine | ec541fe | 2020-01-31 14:24:14 +0100 | [diff] [blame] | 2012 | |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2013 | # depends.py family of tests |
Andrzej Kurek | fcbd2ac | 2022-10-05 09:14:07 -0400 | [diff] [blame] | 2014 | component_test_depends_py_cipher_id () { |
| 2015 | msg "test/build: depends.py cipher_id (gcc)" |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2016 | tests/scripts/depends.py cipher_id --unset-use-psa |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2017 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 2018 | |
Andrzej Kurek | fcbd2ac | 2022-10-05 09:14:07 -0400 | [diff] [blame] | 2019 | component_test_depends_py_cipher_chaining () { |
| 2020 | msg "test/build: depends.py cipher_chaining (gcc)" |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2021 | tests/scripts/depends.py cipher_chaining --unset-use-psa |
John Durkop | c14be90 | 2020-08-20 06:16:41 -0700 | [diff] [blame] | 2022 | } |
| 2023 | |
Andrzej Kurek | fcbd2ac | 2022-10-05 09:14:07 -0400 | [diff] [blame] | 2024 | component_test_depends_py_cipher_padding () { |
| 2025 | msg "test/build: depends.py cipher_padding (gcc)" |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2026 | tests/scripts/depends.py cipher_padding --unset-use-psa |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2027 | } |
Jaeden Amero | acaabe7 | 2018-11-07 11:52:52 +0000 | [diff] [blame] | 2028 | |
Andrzej Kurek | fcbd2ac | 2022-10-05 09:14:07 -0400 | [diff] [blame] | 2029 | component_test_depends_py_curves () { |
| 2030 | msg "test/build: depends.py curves (gcc)" |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2031 | tests/scripts/depends.py curves --unset-use-psa |
John Durkop | 2ec2eaa | 2020-08-24 18:29:15 -0700 | [diff] [blame] | 2032 | } |
| 2033 | |
Andrzej Kurek | fcbd2ac | 2022-10-05 09:14:07 -0400 | [diff] [blame] | 2034 | component_test_depends_py_hashes () { |
| 2035 | msg "test/build: depends.py hashes (gcc)" |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2036 | tests/scripts/depends.py hashes --unset-use-psa |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2037 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 2038 | |
Andrzej Kurek | fcbd2ac | 2022-10-05 09:14:07 -0400 | [diff] [blame] | 2039 | component_test_depends_py_kex () { |
| 2040 | msg "test/build: depends.py kex (gcc)" |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2041 | tests/scripts/depends.py kex --unset-use-psa |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 2042 | } |
| 2043 | |
Andrzej Kurek | fcbd2ac | 2022-10-05 09:14:07 -0400 | [diff] [blame] | 2044 | component_test_depends_py_pkalgs () { |
| 2045 | msg "test/build: depends.py pkalgs (gcc)" |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2046 | tests/scripts/depends.py pkalgs --unset-use-psa |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2047 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 2048 | |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2049 | # PSA equivalents of the depends.py tests |
| 2050 | component_test_depends_py_cipher_id_psa () { |
| 2051 | msg "test/build: depends.py cipher_id (gcc) with MBEDTLS_USE_PSA_CRYPTO defined" |
| 2052 | tests/scripts/depends.py cipher_id |
| 2053 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 2054 | |
Andrzej Kurek | 7cb0077 | 2022-10-24 10:49:22 -0400 | [diff] [blame] | 2055 | component_test_depends_py_cipher_chaining_psa () { |
| 2056 | msg "test/build: depends.py cipher_chaining (gcc) with MBEDTLS_USE_PSA_CRYPTO defined" |
| 2057 | tests/scripts/depends.py cipher_chaining |
| 2058 | } |
| 2059 | |
| 2060 | component_test_depends_py_cipher_padding_psa () { |
| 2061 | msg "test/build: depends.py cipher_padding (gcc) with MBEDTLS_USE_PSA_CRYPTO defined" |
| 2062 | tests/scripts/depends.py cipher_padding |
| 2063 | } |
| 2064 | |
| 2065 | component_test_depends_py_curves_psa () { |
| 2066 | msg "test/build: depends.py curves (gcc) with MBEDTLS_USE_PSA_CRYPTO defined" |
| 2067 | tests/scripts/depends.py curves |
| 2068 | } |
| 2069 | |
| 2070 | component_test_depends_py_hashes_psa () { |
| 2071 | msg "test/build: depends.py hashes (gcc) with MBEDTLS_USE_PSA_CRYPTO defined" |
| 2072 | tests/scripts/depends.py hashes |
| 2073 | } |
| 2074 | |
| 2075 | component_test_depends_py_kex_psa () { |
| 2076 | msg "test/build: depends.py kex (gcc) with MBEDTLS_USE_PSA_CRYPTO defined" |
| 2077 | tests/scripts/depends.py kex |
| 2078 | } |
| 2079 | |
| 2080 | component_test_depends_py_pkalgs_psa () { |
| 2081 | msg "test/build: depends.py pkalgs (gcc) with MBEDTLS_USE_PSA_CRYPTO defined" |
Andrzej Kurek | fcbd2ac | 2022-10-05 09:14:07 -0400 | [diff] [blame] | 2082 | tests/scripts/depends.py pkalgs |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 2083 | } |
Manuel Pégourié-Gonnard | 655c0a8 | 2018-10-30 11:20:45 +0100 | [diff] [blame] | 2084 | |
Dave Rodgman | 1a034dc | 2023-01-20 13:18:05 +0000 | [diff] [blame] | 2085 | component_build_no_pk_rsa_alt_support () { |
| 2086 | msg "build: !MBEDTLS_PK_RSA_ALT_SUPPORT" # ~30s |
| 2087 | |
| 2088 | scripts/config.py full |
| 2089 | scripts/config.py unset MBEDTLS_PK_RSA_ALT_SUPPORT |
| 2090 | scripts/config.py set MBEDTLS_RSA_C |
| 2091 | scripts/config.py set MBEDTLS_X509_CRT_WRITE_C |
| 2092 | |
| 2093 | # Only compile - this is primarily to test for compile issues |
| 2094 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' |
| 2095 | } |
| 2096 | |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 2097 | component_build_module_alt () { |
| 2098 | msg "build: MBEDTLS_XXX_ALT" # ~30s |
| 2099 | scripts/config.py full |
Manuel Pégourié-Gonnard | a6e3d3e | 2022-12-06 12:10:33 +0100 | [diff] [blame] | 2100 | |
| 2101 | # Disable options that are incompatible with some ALT implementations: |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 2102 | # aesni.c and padlock.c reference mbedtls_aes_context fields directly. |
| 2103 | scripts/config.py unset MBEDTLS_AESNI_C |
| 2104 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Jerry Yu | e51eddc | 2023-01-11 14:16:08 +0800 | [diff] [blame] | 2105 | scripts/config.py unset MBEDTLS_AESCE_C |
Manuel Pégourié-Gonnard | a6e3d3e | 2022-12-06 12:10:33 +0100 | [diff] [blame] | 2106 | # MBEDTLS_ECP_RESTARTABLE is documented as incompatible. |
| 2107 | scripts/config.py unset MBEDTLS_ECP_RESTARTABLE |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 2108 | # You can only have one threading implementation: alt or pthread, not both. |
| 2109 | scripts/config.py unset MBEDTLS_THREADING_PTHREAD |
Gilles Peskine | 5c3f18d | 2021-05-31 21:21:12 +0200 | [diff] [blame] | 2110 | # The SpecifiedECDomain parsing code accesses mbedtls_ecp_group fields |
| 2111 | # directly and assumes the implementation works with partial groups. |
| 2112 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED |
Tom Cosgrove | f3ebd90 | 2022-02-20 22:25:31 +0000 | [diff] [blame] | 2113 | # MBEDTLS_SHA256_*ALT can't be used with MBEDTLS_SHA256_USE_A64_CRYPTO_* |
| 2114 | scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT |
| 2115 | scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY |
Tom Cosgrove | 87fbfb5 | 2022-03-15 10:51:52 +0000 | [diff] [blame] | 2116 | # MBEDTLS_SHA512_*ALT can't be used with MBEDTLS_SHA512_USE_A64_CRYPTO_* |
| 2117 | scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT |
| 2118 | scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY |
Manuel Pégourié-Gonnard | a6e3d3e | 2022-12-06 12:10:33 +0100 | [diff] [blame] | 2119 | |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 2120 | # Enable all MBEDTLS_XXX_ALT for whole modules. Do not enable |
| 2121 | # MBEDTLS_XXX_YYY_ALT which are for single functions. |
| 2122 | scripts/config.py set-all 'MBEDTLS_([A-Z0-9]*|NIST_KW)_ALT' |
Gilles Peskine | 1628a9c | 2021-05-31 22:09:58 +0200 | [diff] [blame] | 2123 | scripts/config.py unset MBEDTLS_DHM_ALT #incompatible with MBEDTLS_DEBUG_C |
Manuel Pégourié-Gonnard | a6e3d3e | 2022-12-06 12:10:33 +0100 | [diff] [blame] | 2124 | |
Gilles Peskine | 1628a9c | 2021-05-31 22:09:58 +0200 | [diff] [blame] | 2125 | # We can only compile, not link, since we don't have any implementations |
| 2126 | # suitable for testing with the dummy alt headers. |
| 2127 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' lib |
| 2128 | } |
| 2129 | |
| 2130 | component_build_dhm_alt () { |
| 2131 | msg "build: MBEDTLS_DHM_ALT" # ~30s |
| 2132 | scripts/config.py full |
| 2133 | scripts/config.py set MBEDTLS_DHM_ALT |
| 2134 | # debug.c currently references mbedtls_dhm_context fields directly. |
| 2135 | scripts/config.py unset MBEDTLS_DEBUG_C |
Gilles Peskine | cc73cc5 | 2021-05-25 09:04:46 +0200 | [diff] [blame] | 2136 | # We can only compile, not link, since we don't have any implementations |
| 2137 | # suitable for testing with the dummy alt headers. |
| 2138 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' lib |
| 2139 | } |
| 2140 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 2141 | component_test_no_use_psa_crypto_full_cmake_asan() { |
| 2142 | # full minus MBEDTLS_USE_PSA_CRYPTO: run the same set of tests as basic-build-test.sh |
Gilles Peskine | dc3a179 | 2019-09-03 11:42:04 +0200 | [diff] [blame] | 2143 | msg "build: cmake, full config minus MBEDTLS_USE_PSA_CRYPTO, ASan" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2144 | scripts/config.py full |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2145 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 2146 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | 6f135e1 | 2021-12-08 16:57:54 +0100 | [diff] [blame] | 2147 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2148 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
Gilles Peskine | dc6d838 | 2020-04-12 14:21:55 +0200 | [diff] [blame] | 2149 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 2150 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
Raef Coles | a7e03ad | 2022-09-28 09:32:48 +0100 | [diff] [blame] | 2151 | scripts/config.py unset MBEDTLS_LMS_C |
Raef Coles | 47bccb7 | 2022-09-28 12:00:20 +0100 | [diff] [blame] | 2152 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
Manuel Pégourié-Gonnard | d8167e8 | 2019-02-01 11:12:52 +0100 | [diff] [blame] | 2153 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 2154 | make |
Manuel Pégourié-Gonnard | 43be6cd | 2017-06-20 09:53:42 +0200 | [diff] [blame] | 2155 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 2156 | msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 2157 | make test |
Manuel Pégourié-Gonnard | 503a5ef | 2015-10-23 09:04:45 +0200 | [diff] [blame] | 2158 | |
Manuel Pégourié-Gonnard | 182a23b | 2022-12-07 10:38:43 +0100 | [diff] [blame] | 2159 | # Note: ssl-opt.sh has some test cases that depend on |
| 2160 | # MBEDTLS_ECP_RESTARTABLE && !MBEDTLS_USE_PSA_CRYPTO |
| 2161 | # This is the only component where those tests are not skipped. |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 2162 | msg "test: ssl-opt.sh (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2163 | tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 2164 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 2165 | msg "test: compat.sh default (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 2166 | tests/compat.sh |
Andrzej Kurek | 991f9fe | 2018-07-02 09:08:21 -0400 | [diff] [blame] | 2167 | |
Manuel Pégourié-Gonnard | 296787f | 2022-04-06 13:28:27 +0200 | [diff] [blame] | 2168 | msg "test: compat.sh NULL (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Manuel Pégourié-Gonnard | c572246 | 2022-12-19 11:42:12 +0100 | [diff] [blame] | 2169 | env OPENSSL="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -f 'NULL' |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 2170 | |
Manuel Pégourié-Gonnard | 971dea3 | 2019-02-01 12:38:40 +0100 | [diff] [blame] | 2171 | msg "test: compat.sh ARIA + ChachaPoly (full minus MBEDTLS_USE_PSA_CRYPTO)" |
Manuel Pégourié-Gonnard | c572246 | 2022-12-19 11:42:12 +0100 | [diff] [blame] | 2172 | env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
Andrzej Kurek | de5a007 | 2019-02-01 07:03:03 -0500 | [diff] [blame] | 2173 | } |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 2174 | |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2175 | component_test_psa_crypto_config_accel_ecdsa () { |
Valerio Setti | 5aab43f | 2023-03-29 10:42:07 +0200 | [diff] [blame] | 2176 | msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA" |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2177 | |
Manuel Pégourié-Gonnard | 200fd0f | 2022-12-27 13:03:10 +0100 | [diff] [blame] | 2178 | # Algorithms and key types to accelerate |
| 2179 | loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA KEY_TYPE_ECC_KEY_PAIR KEY_TYPE_ECC_PUBLIC_KEY" |
| 2180 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2181 | # Configure |
| 2182 | # --------- |
Manuel Pégourié-Gonnard | 200fd0f | 2022-12-27 13:03:10 +0100 | [diff] [blame] | 2183 | |
Manuel Pégourié-Gonnard | 8d645dc | 2023-06-15 09:07:10 +0200 | [diff] [blame] | 2184 | # Start from default config (no USE_PSA) + TLS 1.3 |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2185 | helper_libtestdriver1_adjust_config "default" |
Manuel Pégourié-Gonnard | 6d7db93 | 2022-12-28 09:48:01 +0100 | [diff] [blame] | 2186 | scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3 |
Manuel Pégourié-Gonnard | 200fd0f | 2022-12-27 13:03:10 +0100 | [diff] [blame] | 2187 | |
| 2188 | # Disable the module that's accelerated |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2189 | scripts/config.py unset MBEDTLS_ECDSA_C |
Manuel Pégourié-Gonnard | 200fd0f | 2022-12-27 13:03:10 +0100 | [diff] [blame] | 2190 | |
| 2191 | # Disable things that depend on it |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2192 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 2193 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 2194 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2195 | # Build |
| 2196 | # ----- |
| 2197 | |
| 2198 | # These hashes are needed for some ECDSA signature tests. |
| 2199 | loc_extra_list="ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
| 2200 | |
| 2201 | helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list" |
| 2202 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2203 | helper_libtestdriver1_make_main "$loc_accel_list" |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2204 | |
Manuel Pégourié-Gonnard | e3095e7 | 2022-12-28 10:09:53 +0100 | [diff] [blame] | 2205 | # Make sure this was not re-enabled by accident (additive config) |
Gilles Peskine | 827dbd9 | 2022-02-04 00:30:54 +0100 | [diff] [blame] | 2206 | not grep mbedtls_ecdsa_ library/ecdsa.o |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2207 | |
Manuel Pégourié-Gonnard | 200fd0f | 2022-12-27 13:03:10 +0100 | [diff] [blame] | 2208 | # Run the tests |
| 2209 | # ------------- |
| 2210 | |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2211 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA" |
| 2212 | make test |
| 2213 | } |
| 2214 | |
Valerio Setti | 44b178c | 2023-03-22 14:02:57 +0100 | [diff] [blame] | 2215 | component_test_psa_crypto_config_accel_ecdh () { |
Valerio Setti | 5aab43f | 2023-03-29 10:42:07 +0200 | [diff] [blame] | 2216 | msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDH" |
Manuel Pégourié-Gonnard | 171c45f | 2022-12-29 11:31:35 +0100 | [diff] [blame] | 2217 | |
| 2218 | # Algorithms and key types to accelerate |
Valerio Setti | 44b178c | 2023-03-22 14:02:57 +0100 | [diff] [blame] | 2219 | loc_accel_list="ALG_ECDH KEY_TYPE_ECC_KEY_PAIR KEY_TYPE_ECC_PUBLIC_KEY" |
Manuel Pégourié-Gonnard | 171c45f | 2022-12-29 11:31:35 +0100 | [diff] [blame] | 2220 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2221 | # Configure |
| 2222 | # --------- |
Manuel Pégourié-Gonnard | 171c45f | 2022-12-29 11:31:35 +0100 | [diff] [blame] | 2223 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2224 | # Start from default config (no TLS 1.3, no USE_PSA) |
| 2225 | helper_libtestdriver1_adjust_config "default" |
Manuel Pégourié-Gonnard | 171c45f | 2022-12-29 11:31:35 +0100 | [diff] [blame] | 2226 | |
Valerio Setti | 44b178c | 2023-03-22 14:02:57 +0100 | [diff] [blame] | 2227 | # Disable the module that's accelerated |
| 2228 | scripts/config.py unset MBEDTLS_ECDH_C |
| 2229 | |
| 2230 | # Disable things that depend on it |
| 2231 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 2232 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 2233 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 2234 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 2235 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED |
| 2236 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2237 | # Build |
| 2238 | # ----- |
| 2239 | |
| 2240 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
| 2241 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2242 | helper_libtestdriver1_make_main "$loc_accel_list" |
Manuel Pégourié-Gonnard | 171c45f | 2022-12-29 11:31:35 +0100 | [diff] [blame] | 2243 | |
Valerio Setti | 44b178c | 2023-03-22 14:02:57 +0100 | [diff] [blame] | 2244 | # Make sure this was not re-enabled by accident (additive config) |
| 2245 | not grep mbedtls_ecdh_ library/ecdh.o |
Manuel Pégourié-Gonnard | 171c45f | 2022-12-29 11:31:35 +0100 | [diff] [blame] | 2246 | |
| 2247 | # Run the tests |
| 2248 | # ------------- |
| 2249 | |
Valerio Setti | 44b178c | 2023-03-22 14:02:57 +0100 | [diff] [blame] | 2250 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDH" |
Manuel Pégourié-Gonnard | 171c45f | 2022-12-29 11:31:35 +0100 | [diff] [blame] | 2251 | make test |
Manuel Pégourié-Gonnard | 10e3963 | 2022-12-29 12:29:09 +0100 | [diff] [blame] | 2252 | } |
| 2253 | |
Przemek Stekiel | dccb202 | 2023-05-11 10:48:50 +0200 | [diff] [blame] | 2254 | component_test_psa_crypto_config_accel_ffdh () { |
| 2255 | msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated FFDH" |
| 2256 | |
| 2257 | # Algorithms and key types to accelerate |
| 2258 | loc_accel_list="ALG_FFDH KEY_TYPE_DH_KEY_PAIR KEY_TYPE_DH_PUBLIC_KEY" |
| 2259 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2260 | # Configure |
| 2261 | # --------- |
Przemek Stekiel | dccb202 | 2023-05-11 10:48:50 +0200 | [diff] [blame] | 2262 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2263 | # Start from default config (no TLS 1.3, no USE_PSA) |
| 2264 | helper_libtestdriver1_adjust_config "default" |
Przemek Stekiel | dccb202 | 2023-05-11 10:48:50 +0200 | [diff] [blame] | 2265 | |
| 2266 | # Disable the module that's accelerated |
| 2267 | scripts/config.py unset MBEDTLS_DHM_C |
| 2268 | |
| 2269 | # Disable things that depend on it |
| 2270 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED |
| 2271 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED |
| 2272 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2273 | # Build |
| 2274 | # ----- |
| 2275 | |
| 2276 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
| 2277 | |
Manuel Pégourié-Gonnard | 981732e | 2023-06-08 09:15:59 +0200 | [diff] [blame] | 2278 | helper_libtestdriver1_make_main "$loc_accel_list" |
Przemek Stekiel | dccb202 | 2023-05-11 10:48:50 +0200 | [diff] [blame] | 2279 | |
| 2280 | # Make sure this was not re-enabled by accident (additive config) |
| 2281 | not grep mbedtls_dhm_ library/dhm.o |
| 2282 | |
| 2283 | # Run the tests |
| 2284 | # ------------- |
| 2285 | |
| 2286 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated FFDH" |
| 2287 | make test |
| 2288 | } |
| 2289 | |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2290 | component_test_psa_crypto_config_accel_pake() { |
Valerio Setti | 5aab43f | 2023-03-29 10:42:07 +0200 | [diff] [blame] | 2291 | msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated PAKE" |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2292 | |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2293 | loc_accel_list="ALG_JPAKE" |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2294 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2295 | # Configure |
| 2296 | # --------- |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2297 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2298 | helper_libtestdriver1_adjust_config "full" |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2299 | |
Valerio Setti | 5aab43f | 2023-03-29 10:42:07 +0200 | [diff] [blame] | 2300 | # Make built-in fallback not available |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2301 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
| 2302 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED |
| 2303 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2304 | # Build |
| 2305 | # ----- |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2306 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2307 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2308 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2309 | helper_libtestdriver1_make_main "$loc_accel_list" |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2310 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2311 | # Make sure this was not re-enabled by accident (additive config) |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2312 | not grep mbedtls_ecjpake_init library/ecjpake.o |
| 2313 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2314 | # Run the tests |
| 2315 | # ------------- |
| 2316 | |
Valerio Setti | 4fa6d0b | 2023-03-27 09:38:51 +0200 | [diff] [blame] | 2317 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated PAKE" |
| 2318 | make test |
| 2319 | } |
| 2320 | |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2321 | # Auxiliary function to build config for all EC based algorithms (EC-JPAKE, |
| 2322 | # ECDH, ECDSA) with and without drivers. |
Valerio Setti | 5aab43f | 2023-03-29 10:42:07 +0200 | [diff] [blame] | 2323 | # The input parameter is a boolean value which indicates: |
| 2324 | # - 0 keep built-in EC algs, |
| 2325 | # - 1 exclude built-in EC algs (driver only). |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2326 | # |
| 2327 | # This is used by the two following components to ensure they always use the |
| 2328 | # same config, except for the use of driver or built-in EC algorithms: |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2329 | # - component_test_psa_crypto_config_accel_ecc_ecp_light_only; |
| 2330 | # - component_test_psa_crypto_config_reference_ecc_ecp_light_only. |
Valerio Setti | 44b178c | 2023-03-22 14:02:57 +0100 | [diff] [blame] | 2331 | # This supports comparing their test coverage with analyze_outcomes.py. |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2332 | config_psa_crypto_config_ecp_ligh_only () { |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2333 | DRIVER_ONLY="$1" |
| 2334 | # start with config full for maximum coverage (also enables USE_PSA) |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2335 | helper_libtestdriver1_adjust_config "full" |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2336 | if [ "$DRIVER_ONLY" -eq 1 ]; then |
| 2337 | # Disable modules that are accelerated |
| 2338 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 2339 | scripts/config.py unset MBEDTLS_ECDH_C |
| 2340 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
Valerio Setti | 29b395c | 2023-04-05 18:20:30 +0200 | [diff] [blame] | 2341 | scripts/config.py unset MBEDTLS_ECP_C |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2342 | fi |
| 2343 | |
| 2344 | # Restartable feature is not yet supported by PSA. Once it will in |
| 2345 | # the future, the following line could be removed (see issues |
| 2346 | # 6061, 6332 and following ones) |
| 2347 | scripts/config.py unset MBEDTLS_ECP_RESTARTABLE |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2348 | } |
| 2349 | |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2350 | # Keep in sync with component_test_psa_crypto_config_reference_ecc_ecp_light_only |
| 2351 | component_test_psa_crypto_config_accel_ecc_ecp_light_only () { |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2352 | msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated EC algs + USE_PSA" |
| 2353 | |
| 2354 | # Algorithms and key types to accelerate |
| 2355 | loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \ |
| 2356 | ALG_ECDH \ |
| 2357 | ALG_JPAKE \ |
| 2358 | KEY_TYPE_ECC_KEY_PAIR KEY_TYPE_ECC_PUBLIC_KEY" |
| 2359 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2360 | # Configure |
| 2361 | # --------- |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2362 | |
| 2363 | # Use the same config as reference, only without built-in EC algs |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2364 | config_psa_crypto_config_ecp_ligh_only 1 |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2365 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2366 | # Build |
| 2367 | # ----- |
| 2368 | |
| 2369 | # These hashes are needed for some ECDSA signature tests. |
| 2370 | loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
| 2371 | helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list" |
| 2372 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2373 | helper_libtestdriver1_make_main "$loc_accel_list" |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2374 | |
| 2375 | # Make sure any built-in EC alg was not re-enabled by accident (additive config) |
| 2376 | not grep mbedtls_ecdsa_ library/ecdsa.o |
| 2377 | not grep mbedtls_ecdh_ library/ecdh.o |
| 2378 | not grep mbedtls_ecjpake_ library/ecjpake.o |
Valerio Setti | 29b395c | 2023-04-05 18:20:30 +0200 | [diff] [blame] | 2379 | not grep mbedtls_ecp_mul library/ecp.o |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2380 | |
| 2381 | # Run the tests |
| 2382 | # ------------- |
| 2383 | |
| 2384 | msg "test suites: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated EC algs + USE_PSA" |
| 2385 | make test |
| 2386 | |
| 2387 | msg "ssl-opt: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated EC algs + USE_PSA" |
| 2388 | tests/ssl-opt.sh |
| 2389 | } |
| 2390 | |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2391 | # Keep in sync with component_test_psa_crypto_config_accel_ecc_ecp_light_only |
| 2392 | component_test_psa_crypto_config_reference_ecc_ecp_light_only () { |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2393 | msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with non-accelerated EC algs + USE_PSA" |
| 2394 | |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2395 | config_psa_crypto_config_ecp_ligh_only 0 |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 2396 | |
| 2397 | make |
| 2398 | |
| 2399 | msg "test suites: MBEDTLS_PSA_CRYPTO_CONFIG with non-accelerated EC algs + USE_PSA" |
| 2400 | make test |
| 2401 | |
| 2402 | msg "ssl-opt: MBEDTLS_PSA_CRYPTO_CONFIG with non-accelerated EC algs + USE_PSA" |
| 2403 | tests/ssl-opt.sh |
| 2404 | } |
| 2405 | |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2406 | # This helper function is used by: |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2407 | # - component_test_psa_crypto_config_accel_ecc_no_ecp_at_all() |
| 2408 | # - component_test_psa_crypto_config_reference_ecc_no_ecp_at_all() |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2409 | # to ensure that both tests use the same underlying configuration when testing |
| 2410 | # driver's coverage with analyze_outcomes.py. |
| 2411 | # |
| 2412 | # This functions accepts 1 boolean parameter as follows: |
| 2413 | # - 1: building with accelerated EC algorithms (ECDSA, ECDH, ECJPAKE), therefore |
| 2414 | # excluding their built-in implementation as well as ECP_C & ECP_LIGHT |
| 2415 | # - 0: include built-in implementation of EC algorithms. |
| 2416 | # |
| 2417 | # PK_C and RSA_C are always disabled to ensure there is no remaining dependency |
| 2418 | # on the ECP module. |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2419 | config_psa_crypto_no_ecp_at_all () { |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2420 | DRIVER_ONLY="$1" |
Valerio Setti | aafe900 | 2023-06-26 15:23:44 +0200 | [diff] [blame] | 2421 | # start with full config for maximum coverage (also enables USE_PSA) |
| 2422 | helper_libtestdriver1_adjust_config "full" |
| 2423 | |
| 2424 | # keep excluding TLS and key exchanges (this will be removed in #7749) |
| 2425 | # Note: key exchanges are not explicitly disabled here because they are |
| 2426 | # auto-disabled in build_info.h as long as the following symbols |
| 2427 | # are not enabled. |
| 2428 | scripts/config.py unset MBEDTLS_SSL_TLS_C |
| 2429 | scripts/config.py unset MBEDTLS_SSL_PROTO_DTLS |
| 2430 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_2 |
| 2431 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2432 | |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2433 | # enable support for drivers and configuring PSA-only algorithms |
| 2434 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 2435 | if [ "$DRIVER_ONLY" -eq 1 ]; then |
| 2436 | # Disable modules that are accelerated |
| 2437 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 2438 | scripts/config.py unset MBEDTLS_ECDH_C |
| 2439 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
| 2440 | # Disable ECP module (entirely) |
| 2441 | scripts/config.py unset MBEDTLS_ECP_C |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2442 | fi |
| 2443 | |
Valerio Setti | aecd32c | 2023-06-14 10:42:31 +0200 | [diff] [blame] | 2444 | # Disable all the features that auto-enable ECP_LIGHT (see build_info.h) |
| 2445 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 2446 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_COMPRESSED |
Valerio Setti | 4922ba1 | 2023-06-14 11:30:30 +0200 | [diff] [blame] | 2447 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE |
Valerio Setti | aecd32c | 2023-06-14 10:42:31 +0200 | [diff] [blame] | 2448 | |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2449 | # Restartable feature is not yet supported by PSA. Once it will in |
| 2450 | # the future, the following line could be removed (see issues |
| 2451 | # 6061, 6332 and following ones) |
| 2452 | scripts/config.py unset MBEDTLS_ECP_RESTARTABLE |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2453 | } |
| 2454 | |
| 2455 | # Build and test a configuration where driver accelerates all EC algs while |
| 2456 | # all support and dependencies from ECP and ECP_LIGHT are removed on the library |
| 2457 | # side. |
| 2458 | # |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2459 | # Keep in sync with component_test_psa_crypto_config_reference_ecc_no_ecp_at_all() |
| 2460 | component_test_psa_crypto_config_accel_ecc_no_ecp_at_all () { |
Valerio Setti | aafe900 | 2023-06-26 15:23:44 +0200 | [diff] [blame] | 2461 | msg "build: full + accelerated EC algs + USE_PSA - TLS - KEY_EXCHANGE - ECP" |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2462 | |
| 2463 | # Algorithms and key types to accelerate |
| 2464 | loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \ |
| 2465 | ALG_ECDH \ |
| 2466 | ALG_JPAKE \ |
| 2467 | KEY_TYPE_ECC_KEY_PAIR KEY_TYPE_ECC_PUBLIC_KEY" |
| 2468 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2469 | # Configure |
| 2470 | # --------- |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2471 | |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2472 | # Set common configurations between library's and driver's builds |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2473 | config_psa_crypto_no_ecp_at_all 1 |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2474 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2475 | # Build |
| 2476 | # ----- |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2477 | |
| 2478 | # Things we wanted supported in libtestdriver1, but not accelerated in the main library: |
| 2479 | # SHA-1 and all SHA-2 variants, as they are used by ECDSA deterministic. |
| 2480 | loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2481 | |
Manuel Pégourié-Gonnard | 31639e4 | 2023-05-25 10:07:31 +0200 | [diff] [blame] | 2482 | helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list" |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2483 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2484 | helper_libtestdriver1_make_main "$loc_accel_list" |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2485 | |
| 2486 | # Make sure any built-in EC alg was not re-enabled by accident (additive config) |
| 2487 | not grep mbedtls_ecdsa_ library/ecdsa.o |
| 2488 | not grep mbedtls_ecdh_ library/ecdh.o |
| 2489 | not grep mbedtls_ecjpake_ library/ecjpake.o |
| 2490 | # Also ensure that ECP or RSA modules were not re-enabled |
| 2491 | not grep mbedtls_ecp_ library/ecp.o |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2492 | |
| 2493 | # Run the tests |
| 2494 | # ------------- |
| 2495 | |
Valerio Setti | aafe900 | 2023-06-26 15:23:44 +0200 | [diff] [blame] | 2496 | msg "test: full + accelerated EC algs + USE_PSA - TLS - KEY_EXCHANGE - ECP" |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2497 | make test |
| 2498 | } |
| 2499 | |
| 2500 | # Reference function used for driver's coverage analysis in analyze_outcomes.py |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2501 | # in conjunction with component_test_psa_crypto_config_accel_ecc_no_ecp_at_all(). |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2502 | # Keep in sync with its accelerated counterpart. |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2503 | component_test_psa_crypto_config_reference_ecc_no_ecp_at_all () { |
Valerio Setti | aafe900 | 2023-06-26 15:23:44 +0200 | [diff] [blame] | 2504 | msg "build: full + non accelerated EC algs + USE_PSA - TLS - KEY_EXCHANGE" |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2505 | |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 2506 | config_psa_crypto_no_ecp_at_all 0 |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2507 | |
| 2508 | make |
| 2509 | |
Valerio Setti | aafe900 | 2023-06-26 15:23:44 +0200 | [diff] [blame] | 2510 | msg "test: crypto_full + non accelerated EC algs + USE_PSA - TLS - KEY_EXCHANGE" |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 2511 | make test |
| 2512 | } |
| 2513 | |
Valerio Setti | e4758aa | 2023-03-24 16:51:17 +0100 | [diff] [blame] | 2514 | # Helper function used in: |
| 2515 | # - component_test_psa_crypto_config_accel_all_curves_except_p192 |
| 2516 | # - component_test_psa_crypto_config_accel_all_curves_except_x25519 |
| 2517 | # to build and test with all accelerated curves a part from the specified one. |
| 2518 | psa_crypto_config_accel_all_curves_except_one () { |
| 2519 | BUILTIN_CURVE=$1 |
| 2520 | |
Valerio Setti | 1f1420d | 2023-03-28 10:35:45 +0200 | [diff] [blame] | 2521 | msg "build: PSA_CRYPTO_CONFIG + all accelerated EC algs (excl $BUILTIN_CURVE) + USE_PSA_CRYPTO" |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2522 | |
| 2523 | # Accelerate all EC algs (all EC curves are automatically accelerated as |
| 2524 | # well in the built-in version due to the "PSA_WANT_xxx" symbols in |
| 2525 | # "crypto_config.h") |
| 2526 | loc_accel_list="ALG_ECDH \ |
| 2527 | ALG_ECDSA ALG_DETERMINISTIC_ECDSA \ |
| 2528 | ALG_JPAKE \ |
| 2529 | KEY_TYPE_ECC_KEY_PAIR KEY_TYPE_ECC_PUBLIC_KEY" |
| 2530 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2531 | # Configure |
| 2532 | # --------- |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2533 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2534 | helper_libtestdriver1_adjust_config "full" |
Valerio Setti | 1a6d96f | 2023-03-24 14:10:24 +0100 | [diff] [blame] | 2535 | |
| 2536 | # restartable is not yet supported in PSA |
| 2537 | scripts/config.py unset MBEDTLS_ECP_RESTARTABLE |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2538 | |
| 2539 | # disable modules for which we have drivers |
| 2540 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 2541 | scripts/config.py unset MBEDTLS_ECDH_C |
| 2542 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
| 2543 | |
Valerio Setti | c6ecdad | 2023-04-03 08:26:35 +0200 | [diff] [blame] | 2544 | # Ensure also RSA and asssociated algs are disabled so that the size of |
| 2545 | # the public/private keys cannot be taken from there |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2546 | scripts/config.py unset MBEDTLS_RSA_C |
Valerio Setti | c6ecdad | 2023-04-03 08:26:35 +0200 | [diff] [blame] | 2547 | scripts/config.py unset MBEDTLS_PKCS1_V15 |
| 2548 | scripts/config.py unset MBEDTLS_PKCS1_V21 |
| 2549 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2550 | # Disable RSA on the PSA side too |
Valerio Setti | 01cc88a | 2023-06-15 11:53:08 +0200 | [diff] [blame] | 2551 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC |
Valerio Setti | ff7f861 | 2023-05-26 13:49:33 +0200 | [diff] [blame] | 2552 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT |
| 2553 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT |
| 2554 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2555 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY |
| 2556 | for ALG in $(sed -n 's/^#define \(PSA_WANT_ALG_RSA_[0-9A-Z_a-z]*\).*/\1/p' <"$CRYPTO_CONFIG_H"); do |
| 2557 | scripts/config.py -f include/psa/crypto_config.h unset $ALG |
| 2558 | done |
Valerio Setti | c6ecdad | 2023-04-03 08:26:35 +0200 | [diff] [blame] | 2559 | # Also disable key exchanges that depend on RSA |
Valerio Setti | 3ebecc9 | 2023-03-23 16:52:22 +0100 | [diff] [blame] | 2560 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED |
| 2561 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED |
| 2562 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED |
| 2563 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 2564 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2565 | |
Valerio Setti | ee97a1e | 2023-03-27 12:44:15 +0200 | [diff] [blame] | 2566 | # Explicitly disable all SW implementation for elliptic curves |
| 2567 | for CURVE in $(sed -n 's/#define \(MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED\).*/\1/p' <"$CONFIG_H"); do |
| 2568 | scripts/config.py unset "$CURVE" |
| 2569 | done |
| 2570 | # Just leave SW implementation for the specified curve for allowing to |
| 2571 | # build with ECP_C. |
Valerio Setti | e4758aa | 2023-03-24 16:51:17 +0100 | [diff] [blame] | 2572 | scripts/config.py set $BUILTIN_CURVE |
Valerio Setti | ee97a1e | 2023-03-27 12:44:15 +0200 | [diff] [blame] | 2573 | # Accelerate all curves listed in "crypto_config.h" (skipping the ones that |
Manuel Pégourié-Gonnard | f8930e2 | 2023-06-13 09:51:32 +0200 | [diff] [blame] | 2574 | # are commented out). |
| 2575 | # Note: Those are handled in a special way by the libtestdriver machinery, |
| 2576 | # so we only want to include them in the accel list when building the main |
| 2577 | # libraries, hence the use of a separate variable. |
| 2578 | loc_curve_list="" |
Valerio Setti | d0c644d | 2023-03-27 13:36:13 +0200 | [diff] [blame] | 2579 | for CURVE in $(sed -n 's/^#define PSA_WANT_\(ECC_[0-9A-Z_a-z]*\).*/\1/p' <"$CRYPTO_CONFIG_H"); do |
Manuel Pégourié-Gonnard | f8930e2 | 2023-06-13 09:51:32 +0200 | [diff] [blame] | 2580 | loc_curve_list="$loc_curve_list $CURVE" |
Valerio Setti | ee97a1e | 2023-03-27 12:44:15 +0200 | [diff] [blame] | 2581 | done |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2582 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2583 | # Build |
| 2584 | # ----- |
| 2585 | |
| 2586 | # These hashes are needed for some ECDSA signature tests. |
| 2587 | loc_extra_list="ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
| 2588 | helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list" |
| 2589 | |
Manuel Pégourié-Gonnard | f8930e2 | 2023-06-13 09:51:32 +0200 | [diff] [blame] | 2590 | # (See above regarding loc_curve_list.) |
| 2591 | helper_libtestdriver1_make_main "$loc_accel_list $loc_curve_list" |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2592 | |
| 2593 | # make sure excluded modules were not auto-re-enabled by accident |
| 2594 | not grep mbedtls_ecdh_ library/ecdh.o |
| 2595 | not grep mbedtls_ecdsa_ library/ecdsa.o |
| 2596 | not grep mbedtls_ecjpake_ library/ecjpake.o |
Valerio Setti | e4758aa | 2023-03-24 16:51:17 +0100 | [diff] [blame] | 2597 | if [ $BUILTIN_CURVE == "MBEDTLS_ECP_DP_SECP192R1_ENABLED" ]; then |
Valerio Setti | ee97a1e | 2023-03-27 12:44:15 +0200 | [diff] [blame] | 2598 | # The only built-in curve is Short Weierstrass, so ECP shouldn't have |
| 2599 | # support for Montgomery curves. Functions with mxz in their name |
| 2600 | # are specific to Montgomery curves. |
Valerio Setti | e4758aa | 2023-03-24 16:51:17 +0100 | [diff] [blame] | 2601 | not grep mxz library/ecp.o |
Valerio Setti | ee97a1e | 2023-03-27 12:44:15 +0200 | [diff] [blame] | 2602 | elif [ $BUILTIN_CURVE == "MBEDTLS_ECP_DP_CURVE25519_ENABLED" ]; then |
| 2603 | # The only built-in curve is Montgomery, so ECP shouldn't have |
| 2604 | # support for Short Weierstrass curves. Functions with mbedtls_ecp_muladd |
| 2605 | # in their name are specific to Short Weierstrass curves. |
Valerio Setti | e4758aa | 2023-03-24 16:51:17 +0100 | [diff] [blame] | 2606 | not grep mbedtls_ecp_muladd library/ecp.o |
Valerio Setti | ee97a1e | 2023-03-27 12:44:15 +0200 | [diff] [blame] | 2607 | else |
| 2608 | err_msg "Error: $BUILTIN_CURVE is not supported in psa_crypto_config_accel_all_curves_except_one()" |
| 2609 | exit 1 |
Valerio Setti | e4758aa | 2023-03-24 16:51:17 +0100 | [diff] [blame] | 2610 | fi |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2611 | |
| 2612 | # Run the tests |
| 2613 | # ------------- |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2614 | |
Valerio Setti | 1f1420d | 2023-03-28 10:35:45 +0200 | [diff] [blame] | 2615 | msg "test: PSA_CRYPTO_CONFIG + all accelerated EC algs (excl $BUILTIN_CURVE) + USE_PSA_CRYPTO" |
Valerio Setti | b7e9544 | 2023-03-21 11:52:33 +0100 | [diff] [blame] | 2616 | make test |
| 2617 | } |
| 2618 | |
Valerio Setti | e4758aa | 2023-03-24 16:51:17 +0100 | [diff] [blame] | 2619 | component_test_psa_crypto_config_accel_all_curves_except_p192 () { |
| 2620 | psa_crypto_config_accel_all_curves_except_one MBEDTLS_ECP_DP_SECP192R1_ENABLED |
| 2621 | } |
| 2622 | |
| 2623 | component_test_psa_crypto_config_accel_all_curves_except_x25519 () { |
| 2624 | psa_crypto_config_accel_all_curves_except_one MBEDTLS_ECP_DP_CURVE25519_ENABLED |
| 2625 | } |
| 2626 | |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2627 | component_test_psa_crypto_config_accel_rsa_signature () { |
| 2628 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature" |
| 2629 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2630 | loc_accel_list="ALG_RSA_PKCS1V15_SIGN ALG_RSA_PSS KEY_TYPE_RSA_KEY_PAIR KEY_TYPE_RSA_PUBLIC_KEY" |
| 2631 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2632 | # Configure |
| 2633 | # --------- |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2634 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2635 | # Start from default config (no TLS 1.3, no USE_PSA) |
| 2636 | helper_libtestdriver1_adjust_config "default" |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2637 | |
| 2638 | # It seems it is not possible to remove only the support for RSA signature |
| 2639 | # in the library. Thus we have to remove all RSA support (signature and |
| 2640 | # encryption/decryption). AS there is no driver support for asymmetric |
| 2641 | # encryption/decryption so far remove RSA encryption/decryption from the |
| 2642 | # application algorithm list. |
| 2643 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP |
| 2644 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 2645 | |
Manuel Pégourié-Gonnard | aed1d78 | 2023-06-12 17:22:24 +0200 | [diff] [blame] | 2646 | # Remove RSA support and its dependencies |
| 2647 | scripts/config.py unset MBEDTLS_RSA_C |
| 2648 | scripts/config.py unset MBEDTLS_PKCS1_V15 |
| 2649 | scripts/config.py unset MBEDTLS_PKCS1_V21 |
| 2650 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
| 2651 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED |
| 2652 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 2653 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 2654 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED |
| 2655 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED |
| 2656 | |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2657 | # Make sure both the library and the test library support the SHA hash |
| 2658 | # algorithms and only those ones (SHA256 is included by default). That way: |
| 2659 | # - the test library can compute the RSA signatures even in the case of a |
| 2660 | # composite RSA signature algorithm based on a SHA hash (no other hash |
| 2661 | # used in the unit tests). |
| 2662 | # - the dependency of RSA signature tests on PSA_WANT_ALG_SHA_xyz is |
| 2663 | # fulfilled as the hash SHA algorithm is supported by the library, and |
| 2664 | # thus the tests are run, not skipped. |
| 2665 | # - when testing a signature key with an algorithm wildcard built from |
| 2666 | # PSA_ALG_ANY_HASH as algorithm to test with the key, the chosen hash |
| 2667 | # algorithm based on the hashes supported by the library is also |
| 2668 | # supported by the test library. |
Manuel Pégourié-Gonnard | aed1d78 | 2023-06-12 17:22:24 +0200 | [diff] [blame] | 2669 | # Disable unwanted hashes here, we'll enable hashes we want in loc_extra_list. |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2670 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 2671 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160_C |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2672 | scripts/config.py unset MBEDTLS_MD5_C |
| 2673 | scripts/config.py unset MBEDTLS_RIPEMD160_C |
Przemek Stekiel | aa88e0b | 2022-11-15 13:21:14 +0100 | [diff] [blame] | 2674 | |
| 2675 | # We need PEM parsing in the test library as well to support the import |
| 2676 | # of PEM encoded RSA keys. |
| 2677 | scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_PEM_PARSE_C |
| 2678 | scripts/config.py -f tests/include/test/drivers/config_test_driver.h set MBEDTLS_BASE64_C |
| 2679 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2680 | # Build |
| 2681 | # ----- |
| 2682 | |
Przemek Stekiel | aa88e0b | 2022-11-15 13:21:14 +0100 | [diff] [blame] | 2683 | # These hashes are needed for some RSA-PSS signature tests. |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2684 | loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
| 2685 | helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list" |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2686 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2687 | helper_libtestdriver1_make_main "$loc_accel_list" |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2688 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2689 | # Make sure this was not re-enabled by accident (additive config) |
Gilles Peskine | 827dbd9 | 2022-02-04 00:30:54 +0100 | [diff] [blame] | 2690 | not grep mbedtls_rsa_rsassa_pkcs1_v15_sign library/rsa.o |
| 2691 | not grep mbedtls_rsa_rsassa_pss_sign_ext library/rsa.o |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2692 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2693 | # Run the tests |
| 2694 | # ------------- |
| 2695 | |
Ronald Cron | 403c15c | 2021-09-13 09:38:05 +0200 | [diff] [blame] | 2696 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature" |
| 2697 | make test |
| 2698 | } |
| 2699 | |
Valerio Setti | a1a0b1b | 2023-06-13 14:19:03 +0200 | [diff] [blame] | 2700 | # This is a temporary test to verify that full RSA support is present even when |
Valerio Setti | 01cc88a | 2023-06-15 11:53:08 +0200 | [diff] [blame] | 2701 | # only one single new symbols (PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) is defined. |
Valerio Setti | a1a0b1b | 2023-06-13 14:19:03 +0200 | [diff] [blame] | 2702 | component_test_new_psa_want_key_pair_symbol() { |
Valerio Setti | 01cc88a | 2023-06-15 11:53:08 +0200 | [diff] [blame] | 2703 | msg "Build: crypto config - MBEDTLS_RSA_C + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC" |
Valerio Setti | a1a0b1b | 2023-06-13 14:19:03 +0200 | [diff] [blame] | 2704 | |
Valerio Setti | 4590bc2 | 2023-06-13 15:39:23 +0200 | [diff] [blame] | 2705 | # Create a temporary output file unless there is already one set |
| 2706 | if [ "$MBEDTLS_TEST_OUTCOME_FILE" ]; then |
| 2707 | REMOVE_OUTCOME_ON_EXIT="no" |
| 2708 | else |
| 2709 | REMOVE_OUTCOME_ON_EXIT="yes" |
| 2710 | MBEDTLS_TEST_OUTCOME_FILE="$PWD/out.csv" |
| 2711 | export MBEDTLS_TEST_OUTCOME_FILE |
| 2712 | fi |
| 2713 | |
Valerio Setti | a1a0b1b | 2023-06-13 14:19:03 +0200 | [diff] [blame] | 2714 | # Start from crypto configuration |
| 2715 | scripts/config.py crypto |
| 2716 | |
| 2717 | # Remove RSA support and its dependencies |
| 2718 | scripts/config.py unset MBEDTLS_PKCS1_V15 |
| 2719 | scripts/config.py unset MBEDTLS_PKCS1_V21 |
| 2720 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED |
| 2721 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 2722 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 2723 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED |
| 2724 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED |
| 2725 | scripts/config.py unset MBEDTLS_RSA_C |
| 2726 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
| 2727 | |
| 2728 | # Enable PSA support |
| 2729 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 2730 | |
Valerio Setti | 01cc88a | 2023-06-15 11:53:08 +0200 | [diff] [blame] | 2731 | # Keep only PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC enabled in order to ensure |
Valerio Setti | a1a0b1b | 2023-06-13 14:19:03 +0200 | [diff] [blame] | 2732 | # that proper translations is done in crypto_legacy.h. |
| 2733 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT |
| 2734 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT |
| 2735 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE |
| 2736 | |
| 2737 | make |
| 2738 | |
Valerio Setti | 01cc88a | 2023-06-15 11:53:08 +0200 | [diff] [blame] | 2739 | msg "Test: crypto config - MBEDTLS_RSA_C + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC" |
Valerio Setti | 4590bc2 | 2023-06-13 15:39:23 +0200 | [diff] [blame] | 2740 | make test |
| 2741 | |
| 2742 | # Parse only 1 relevant line from the outcome file, i.e. a test which is |
| 2743 | # performing RSA signature. |
| 2744 | msg "Verify that 'RSA PKCS1 Sign #1 (SHA512, 1536 bits RSA)' is PASS" |
| 2745 | cat $MBEDTLS_TEST_OUTCOME_FILE | grep 'RSA PKCS1 Sign #1 (SHA512, 1536 bits RSA)' | grep -q "PASS" |
| 2746 | |
| 2747 | if [ "$REMOVE_OUTCOME_ON_EXIT" == "yes" ]; then |
| 2748 | rm $MBEDTLS_TEST_OUTCOME_FILE |
| 2749 | fi |
Valerio Setti | a1a0b1b | 2023-06-13 14:19:03 +0200 | [diff] [blame] | 2750 | } |
| 2751 | |
Ronald Cron | b231245 | 2021-05-08 14:32:59 +0200 | [diff] [blame] | 2752 | component_test_psa_crypto_config_accel_hash () { |
| 2753 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash" |
| 2754 | |
Ronald Cron | 27d4771 | 2021-12-07 09:54:36 +0100 | [diff] [blame] | 2755 | loc_accel_list="ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
Ronald Cron | b231245 | 2021-05-08 14:32:59 +0200 | [diff] [blame] | 2756 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2757 | # Configure |
| 2758 | # --------- |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2759 | |
| 2760 | # Start from default config (no TLS 1.3, no USE_PSA) |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2761 | helper_libtestdriver1_adjust_config "default" |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2762 | |
| 2763 | # Disable the things that are being accelerated |
Ronald Cron | b231245 | 2021-05-08 14:32:59 +0200 | [diff] [blame] | 2764 | scripts/config.py unset MBEDTLS_MD5_C |
| 2765 | scripts/config.py unset MBEDTLS_RIPEMD160_C |
| 2766 | scripts/config.py unset MBEDTLS_SHA1_C |
Manuel Pégourié-Gonnard | c584c27 | 2023-03-22 00:32:04 +0100 | [diff] [blame] | 2767 | scripts/config.py unset MBEDTLS_SHA224_C |
| 2768 | scripts/config.py unset MBEDTLS_SHA256_C |
Ronald Cron | b231245 | 2021-05-08 14:32:59 +0200 | [diff] [blame] | 2769 | scripts/config.py unset MBEDTLS_SHA384_C |
| 2770 | scripts/config.py unset MBEDTLS_SHA512_C |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2771 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2772 | # Build |
| 2773 | # ----- |
| 2774 | |
| 2775 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
| 2776 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2777 | helper_libtestdriver1_make_main "$loc_accel_list" |
Ronald Cron | b231245 | 2021-05-08 14:32:59 +0200 | [diff] [blame] | 2778 | |
Manuel Pégourié-Gonnard | c584c27 | 2023-03-22 00:32:04 +0100 | [diff] [blame] | 2779 | # There's a risk of something getting re-enabled via config_psa.h; |
| 2780 | # make sure it did not happen. Note: it's OK for MD_C to be enabled. |
| 2781 | not grep mbedtls_md5 library/md5.o |
| 2782 | not grep mbedtls_sha1 library/sha1.o |
| 2783 | not grep mbedtls_sha256 library/sha256.o |
| 2784 | not grep mbedtls_sha512 library/sha512.o |
| 2785 | not grep mbedtls_ripemd160 library/ripemd160.o |
Ronald Cron | b231245 | 2021-05-08 14:32:59 +0200 | [diff] [blame] | 2786 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2787 | # Run the tests |
| 2788 | # ------------- |
| 2789 | |
Ronald Cron | b231245 | 2021-05-08 14:32:59 +0200 | [diff] [blame] | 2790 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash" |
| 2791 | make test |
| 2792 | } |
| 2793 | |
Manuel Pégourié-Gonnard | 9b14639 | 2023-03-09 15:56:14 +0100 | [diff] [blame] | 2794 | component_test_psa_crypto_config_accel_hash_keep_builtins () { |
| 2795 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated+builtin hash" |
| 2796 | # This component ensures that all the test cases for |
| 2797 | # md_psa_dynamic_dispatch with legacy+driver in test_suite_md are run. |
| 2798 | |
Manuel Pégourié-Gonnard | 9b14639 | 2023-03-09 15:56:14 +0100 | [diff] [blame] | 2799 | loc_accel_list="ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
Manuel Pégourié-Gonnard | 9b14639 | 2023-03-09 15:56:14 +0100 | [diff] [blame] | 2800 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2801 | # Start from default config (no TLS 1.3, no USE_PSA) |
| 2802 | helper_libtestdriver1_adjust_config "default" |
Manuel Pégourié-Gonnard | 9b14639 | 2023-03-09 15:56:14 +0100 | [diff] [blame] | 2803 | |
Manuel Pégourié-Gonnard | 31639e4 | 2023-05-25 10:07:31 +0200 | [diff] [blame] | 2804 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
Manuel Pégourié-Gonnard | 9b14639 | 2023-03-09 15:56:14 +0100 | [diff] [blame] | 2805 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2806 | helper_libtestdriver1_make_main "$loc_accel_list" |
Manuel Pégourié-Gonnard | 9b14639 | 2023-03-09 15:56:14 +0100 | [diff] [blame] | 2807 | |
| 2808 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated+builtin hash" |
| 2809 | make test |
| 2810 | } |
| 2811 | |
Przemek Stekiel | aa88e0b | 2022-11-15 13:21:14 +0100 | [diff] [blame] | 2812 | # Auxiliary function to build config for hashes with and without drivers |
| 2813 | config_psa_crypto_hash_use_psa () { |
| 2814 | DRIVER_ONLY="$1" |
| 2815 | # start with config full for maximum coverage (also enables USE_PSA) |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2816 | helper_libtestdriver1_adjust_config "full" |
Przemek Stekiel | aa88e0b | 2022-11-15 13:21:14 +0100 | [diff] [blame] | 2817 | if [ "$DRIVER_ONLY" -eq 1 ]; then |
| 2818 | # disable the built-in implementation of hashes |
| 2819 | scripts/config.py unset MBEDTLS_MD5_C |
| 2820 | scripts/config.py unset MBEDTLS_RIPEMD160_C |
| 2821 | scripts/config.py unset MBEDTLS_SHA1_C |
| 2822 | scripts/config.py unset MBEDTLS_SHA224_C |
| 2823 | scripts/config.py unset MBEDTLS_SHA256_C # see external RNG below |
| 2824 | scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT |
| 2825 | scripts/config.py unset MBEDTLS_SHA384_C |
| 2826 | scripts/config.py unset MBEDTLS_SHA512_C |
| 2827 | scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT |
| 2828 | fi |
Przemek Stekiel | aa88e0b | 2022-11-15 13:21:14 +0100 | [diff] [blame] | 2829 | } |
| 2830 | |
Przemek Stekiel | 120ed8f | 2022-10-27 10:29:15 +0200 | [diff] [blame] | 2831 | # Note that component_test_psa_crypto_config_reference_hash_use_psa |
| 2832 | # is related to this component and both components need to be kept in sync. |
| 2833 | # For details please see comments for component_test_psa_crypto_config_reference_hash_use_psa. |
Manuel Pégourié-Gonnard | 525add6 | 2022-07-06 13:06:57 +0200 | [diff] [blame] | 2834 | component_test_psa_crypto_config_accel_hash_use_psa () { |
| 2835 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash and USE_PSA" |
| 2836 | |
Manuel Pégourié-Gonnard | 525add6 | 2022-07-06 13:06:57 +0200 | [diff] [blame] | 2837 | loc_accel_list="ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512" |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2838 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2839 | # Configure |
| 2840 | # --------- |
Manuel Pégourié-Gonnard | 525add6 | 2022-07-06 13:06:57 +0200 | [diff] [blame] | 2841 | |
Przemek Stekiel | aa88e0b | 2022-11-15 13:21:14 +0100 | [diff] [blame] | 2842 | config_psa_crypto_hash_use_psa 1 |
Manuel Pégourié-Gonnard | f0f63bc | 2022-07-08 19:12:33 +0200 | [diff] [blame] | 2843 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2844 | # Build |
| 2845 | # ----- |
| 2846 | |
| 2847 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
| 2848 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2849 | helper_libtestdriver1_make_main "$loc_accel_list" |
Manuel Pégourié-Gonnard | 525add6 | 2022-07-06 13:06:57 +0200 | [diff] [blame] | 2850 | |
Manuel Pégourié-Gonnard | f0f63bc | 2022-07-08 19:12:33 +0200 | [diff] [blame] | 2851 | # There's a risk of something getting re-enabled via config_psa.h; |
Manuel Pégourié-Gonnard | 49e67f8 | 2023-03-16 11:39:20 +0100 | [diff] [blame] | 2852 | # make sure it did not happen. Note: it's OK for MD_C to be enabled. |
Manuel Pégourié-Gonnard | f0f63bc | 2022-07-08 19:12:33 +0200 | [diff] [blame] | 2853 | not grep mbedtls_md5 library/md5.o |
| 2854 | not grep mbedtls_sha1 library/sha1.o |
Manuel Pégourié-Gonnard | 7b0825d | 2022-07-11 11:06:09 +0200 | [diff] [blame] | 2855 | not grep mbedtls_sha256 library/sha256.o |
Manuel Pégourié-Gonnard | f0f63bc | 2022-07-08 19:12:33 +0200 | [diff] [blame] | 2856 | not grep mbedtls_sha512 library/sha512.o |
| 2857 | not grep mbedtls_ripemd160 library/ripemd160.o |
| 2858 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2859 | # Run the tests |
| 2860 | # ------------- |
| 2861 | |
Manuel Pégourié-Gonnard | 525add6 | 2022-07-06 13:06:57 +0200 | [diff] [blame] | 2862 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash and USE_PSA" |
| 2863 | make test |
Andrzej Kurek | 07e3570 | 2022-09-05 15:39:23 -0400 | [diff] [blame] | 2864 | |
Manuel Pégourié-Gonnard | 30d9466 | 2022-11-29 12:37:53 +0100 | [diff] [blame] | 2865 | # This is mostly useful so that we can later compare outcome files with |
| 2866 | # the reference config in analyze_outcomes.py, to check that the |
| 2867 | # dependency declarations in ssl-opt.sh and in TLS code are correct. |
Przemek Stekiel | 5f6f32a | 2022-10-27 08:24:43 +0200 | [diff] [blame] | 2868 | msg "test: ssl-opt.sh, MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash and USE_PSA" |
| 2869 | tests/ssl-opt.sh |
Andrzej Kurek | 07e3570 | 2022-09-05 15:39:23 -0400 | [diff] [blame] | 2870 | |
Manuel Pégourié-Gonnard | 30d9466 | 2022-11-29 12:37:53 +0100 | [diff] [blame] | 2871 | # This is to make sure all ciphersuites are exercised, but we don't need |
| 2872 | # interop testing (besides, we already got some from ssl-opt.sh). |
| 2873 | msg "test: compat.sh, MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash and USE_PSA" |
| 2874 | tests/compat.sh -p mbedTLS -V YES |
Manuel Pégourié-Gonnard | 525add6 | 2022-07-06 13:06:57 +0200 | [diff] [blame] | 2875 | } |
| 2876 | |
Przemek Stekiel | 120ed8f | 2022-10-27 10:29:15 +0200 | [diff] [blame] | 2877 | # This component provides reference configuration for test_psa_crypto_config_accel_hash_use_psa |
| 2878 | # without accelerated hash. The outcome from both components are used by the analyze_outcomes.py |
| 2879 | # script to find regression in test coverage when accelerated hash is used (tests and ssl-opt). |
| 2880 | # Both components need to be kept in sync. |
Przemek Stekiel | 01df9dd | 2022-10-20 14:21:21 +0200 | [diff] [blame] | 2881 | component_test_psa_crypto_config_reference_hash_use_psa() { |
| 2882 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG without accelerated hash and USE_PSA" |
Przemek Stekiel | aa88e0b | 2022-11-15 13:21:14 +0100 | [diff] [blame] | 2883 | |
| 2884 | config_psa_crypto_hash_use_psa 0 |
Przemek Stekiel | 01df9dd | 2022-10-20 14:21:21 +0200 | [diff] [blame] | 2885 | |
Przemek Stekiel | ab0451b | 2022-10-24 11:29:35 +0200 | [diff] [blame] | 2886 | make |
| 2887 | |
Przemek Stekiel | 01df9dd | 2022-10-20 14:21:21 +0200 | [diff] [blame] | 2888 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG without accelerated hash and USE_PSA" |
| 2889 | make test |
| 2890 | |
Przemek Stekiel | 5f6f32a | 2022-10-27 08:24:43 +0200 | [diff] [blame] | 2891 | msg "test: ssl-opt.sh, MBEDTLS_PSA_CRYPTO_CONFIG without accelerated hash and USE_PSA" |
| 2892 | tests/ssl-opt.sh |
Ronald Cron | 3a8714d | 2021-10-18 11:26:01 +0200 | [diff] [blame] | 2893 | } |
Manuel Pégourié-Gonnard | 97ab2a3 | 2022-07-06 10:46:57 +0200 | [diff] [blame] | 2894 | |
John Durkop | 4377bf7 | 2020-10-23 01:26:57 -0700 | [diff] [blame] | 2895 | component_test_psa_crypto_config_accel_cipher () { |
| 2896 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated cipher" |
| 2897 | |
| 2898 | loc_accel_list="ALG_CBC_NO_PADDING ALG_CBC_PKCS7 ALG_CTR ALG_CFB ALG_OFB ALG_XTS KEY_TYPE_DES" |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2899 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2900 | # Configure |
| 2901 | # --------- |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2902 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2903 | # Start from the default config (no TLS 1.3, no USE_PSA) |
| 2904 | helper_libtestdriver1_adjust_config "default" |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2905 | |
Manuel Pégourié-Gonnard | 7ae342f | 2023-06-08 09:26:04 +0200 | [diff] [blame] | 2906 | # There is no intended accelerator support for ALG CMAC. Therefore, asking |
| 2907 | # for it in the build implies the inclusion of the Mbed TLS cipher |
| 2908 | # operations. As we want to test here with cipher operations solely |
| 2909 | # supported by accelerators, disabled this PSA configuration option. |
| 2910 | # (Note: the same applies to STREAM_CIPHER and ECB_NO_PADDING, which are |
| 2911 | # already disabled by helper_libtestdriver1_adjust_config above.) |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2912 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_CMAC |
| 2913 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2914 | # Disable the things that are being accelerated |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2915 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC |
| 2916 | scripts/config.py unset MBEDTLS_CIPHER_PADDING_PKCS7 |
| 2917 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CTR |
| 2918 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CFB |
| 2919 | scripts/config.py unset MBEDTLS_CIPHER_MODE_OFB |
| 2920 | scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS |
| 2921 | scripts/config.py unset MBEDTLS_DES_C |
| 2922 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2923 | # Build |
| 2924 | # ----- |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2925 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2926 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
| 2927 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2928 | helper_libtestdriver1_make_main "$loc_accel_list" |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2929 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2930 | # Make sure this was not re-enabled by accident (additive config) |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2931 | not grep mbedtls_des* library/des.o |
| 2932 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2933 | # Run the tests |
| 2934 | # ------------- |
| 2935 | |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 2936 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated cipher" |
| 2937 | make test |
| 2938 | } |
| 2939 | |
Przemek Stekiel | e290f2e | 2022-10-02 20:58:39 +0200 | [diff] [blame] | 2940 | component_test_psa_crypto_config_accel_aead () { |
| 2941 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD" |
| 2942 | |
Przemek Stekiel | ee1bb41 | 2022-10-11 11:52:25 +0200 | [diff] [blame] | 2943 | loc_accel_list="ALG_GCM ALG_CCM ALG_CHACHA20_POLY1305 KEY_TYPE_AES KEY_TYPE_CHACHA20 KEY_TYPE_ARIA KEY_TYPE_CAMELLIA" |
Przemek Stekiel | e290f2e | 2022-10-02 20:58:39 +0200 | [diff] [blame] | 2944 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2945 | # Configure |
| 2946 | # --------- |
Przemek Stekiel | e290f2e | 2022-10-02 20:58:39 +0200 | [diff] [blame] | 2947 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2948 | # Start from default config (no TLS 1.3, no USE_PSA) |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2949 | helper_libtestdriver1_adjust_config "default" |
Przemek Stekiel | e290f2e | 2022-10-02 20:58:39 +0200 | [diff] [blame] | 2950 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2951 | # Disable things that are being accelerated |
Przemek Stekiel | ee1bb41 | 2022-10-11 11:52:25 +0200 | [diff] [blame] | 2952 | scripts/config.py unset MBEDTLS_GCM_C |
| 2953 | scripts/config.py unset MBEDTLS_CCM_C |
| 2954 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
| 2955 | # Features that depend on AEAD |
| 2956 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
Przemek Stekiel | 072fad1 | 2022-10-13 09:59:52 +0200 | [diff] [blame] | 2957 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
Przemek Stekiel | e290f2e | 2022-10-02 20:58:39 +0200 | [diff] [blame] | 2958 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2959 | # Build |
| 2960 | # ----- |
Przemek Stekiel | e290f2e | 2022-10-02 20:58:39 +0200 | [diff] [blame] | 2961 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2962 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
| 2963 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2964 | helper_libtestdriver1_make_main "$loc_accel_list" |
Przemek Stekiel | e290f2e | 2022-10-02 20:58:39 +0200 | [diff] [blame] | 2965 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2966 | # Make sure this was not re-enabled by accident (additive config) |
Przemek Stekiel | ee1bb41 | 2022-10-11 11:52:25 +0200 | [diff] [blame] | 2967 | not grep mbedtls_ccm library/ccm.o |
| 2968 | not grep mbedtls_gcm library/gcm.o |
| 2969 | not grep mbedtls_chachapoly library/chachapoly.o |
| 2970 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2971 | # Run the tests |
| 2972 | # ------------- |
| 2973 | |
Przemek Stekiel | e290f2e | 2022-10-02 20:58:39 +0200 | [diff] [blame] | 2974 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD" |
| 2975 | make test |
| 2976 | } |
| 2977 | |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 2978 | component_test_psa_crypto_config_accel_pake() { |
| 2979 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated PAKE" |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 2980 | |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 2981 | loc_accel_list="ALG_JPAKE" |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 2982 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2983 | # Configure |
| 2984 | # --------- |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 2985 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2986 | helper_libtestdriver1_adjust_config "full" |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 2987 | |
| 2988 | # Make build-in fallback not available |
| 2989 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
| 2990 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED |
| 2991 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2992 | # Build |
| 2993 | # ----- |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 2994 | |
Manuel Pégourié-Gonnard | 8df87bf | 2023-06-12 17:09:38 +0200 | [diff] [blame] | 2995 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 2996 | |
Manuel Pégourié-Gonnard | 27dd73f | 2023-05-25 10:39:23 +0200 | [diff] [blame] | 2997 | helper_libtestdriver1_make_main "$loc_accel_list" |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 2998 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 2999 | # Make sure this was not re-enabled by accident (additive config) |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 3000 | not grep mbedtls_ecjpake_init library/ecjpake.o |
| 3001 | |
Manuel Pégourié-Gonnard | 239094d | 2023-05-31 12:51:50 +0200 | [diff] [blame] | 3002 | # Run the tests |
| 3003 | # ------------- |
| 3004 | |
Ronald Cron | e6e6b75 | 2023-01-16 16:56:51 +0100 | [diff] [blame] | 3005 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated PAKE" |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 3006 | make test |
| 3007 | } |
| 3008 | |
| 3009 | component_test_psa_crypto_config_chachapoly_disabled() { |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 3010 | # full minus MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305 |
John Durkop | 07cc04a | 2020-11-16 22:08:34 -0800 | [diff] [blame] | 3011 | msg "build: full minus MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305" |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 3012 | scripts/config.py full |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 3013 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 3014 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_GCM |
| 3015 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_CHACHA20_POLY1305 |
| 3016 | make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS" |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3017 | |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 3018 | msg "test: full minus MBEDTLS_CHACHAPOLY_C without PSA_WANT_ALG_GCM and PSA_WANT_ALG_CHACHA20_POLY1305" |
| 3019 | make test |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 3020 | } |
| 3021 | |
John Durkop | 9814fa2 | 2020-11-04 12:28:15 -0800 | [diff] [blame] | 3022 | # This should be renamed to test and updated once the accelerator ECDH code is in place and ready to test. |
John Durkop | f4c4cb0 | 2020-10-28 20:09:55 -0700 | [diff] [blame] | 3023 | component_build_psa_accel_alg_ecdh() { |
| 3024 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_ECDH |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3025 | # without MBEDTLS_ECDH_C |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3026 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C" |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3027 | scripts/config.py full |
| 3028 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3029 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3030 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3031 | scripts/config.py unset MBEDTLS_ECDH_C |
| 3032 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 3033 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 3034 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 3035 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 3036 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED |
| 3037 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3038 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3039 | } |
| 3040 | |
| 3041 | # This should be renamed to test and updated once the accelerator ECC key pair code is in place and ready to test. |
| 3042 | component_build_psa_accel_key_type_ecc_key_pair() { |
Valerio Setti | ff7f861 | 2023-05-26 13:49:33 +0200 | [diff] [blame] | 3043 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_xxx |
| 3044 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_xxx" |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3045 | scripts/config.py full |
| 3046 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3047 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3048 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
Valerio Setti | 01cc88a | 2023-06-15 11:53:08 +0200 | [diff] [blame] | 3049 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC 1 |
Valerio Setti | ff7f861 | 2023-05-26 13:49:33 +0200 | [diff] [blame] | 3050 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT 1 |
| 3051 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT 1 |
| 3052 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE 1 |
| 3053 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE 1 |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3054 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1 |
| 3055 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3056 | 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 Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3057 | } |
| 3058 | |
| 3059 | # This should be renamed to test and updated once the accelerator ECC public key code is in place and ready to test. |
| 3060 | component_build_psa_accel_key_type_ecc_public_key() { |
| 3061 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY |
| 3062 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY" |
| 3063 | scripts/config.py full |
| 3064 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3065 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3066 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3067 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY 1 |
Valerio Setti | 01cc88a | 2023-06-15 11:53:08 +0200 | [diff] [blame] | 3068 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC |
Valerio Setti | ff7f861 | 2023-05-26 13:49:33 +0200 | [diff] [blame] | 3069 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_IMPORT |
| 3070 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_EXPORT |
| 3071 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_GENERATE |
| 3072 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3073 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3074 | 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" |
| 3075 | } |
| 3076 | |
| 3077 | # This should be renamed to test and updated once the accelerator HMAC code is in place and ready to test. |
| 3078 | component_build_psa_accel_alg_hmac() { |
| 3079 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_HMAC |
| 3080 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_HMAC" |
| 3081 | scripts/config.py full |
| 3082 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3083 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3084 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3085 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3086 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3087 | } |
| 3088 | |
| 3089 | # This should be renamed to test and updated once the accelerator HKDF code is in place and ready to test. |
| 3090 | component_build_psa_accel_alg_hkdf() { |
| 3091 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_HKDF |
| 3092 | # without MBEDTLS_HKDF_C |
| 3093 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C" |
| 3094 | scripts/config.py full |
| 3095 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3096 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3097 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3098 | scripts/config.py unset MBEDTLS_HKDF_C |
Ronald Cron | 6f135e1 | 2021-12-08 16:57:54 +0100 | [diff] [blame] | 3099 | # Make sure to unset TLS1_3 since it requires HKDF_C and will not build properly without it. |
| 3100 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3101 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3102 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3103 | } |
| 3104 | |
| 3105 | # This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test. |
| 3106 | component_build_psa_accel_alg_md5() { |
| 3107 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_MD5 without other hashes |
| 3108 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_MD5 - other hashes" |
| 3109 | scripts/config.py full |
| 3110 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3111 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3112 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3113 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 3114 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 3115 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 3116 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 3117 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 3118 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
Andrzej Kurek | 4ba0e45 | 2022-09-14 12:47:26 -0400 | [diff] [blame] | 3119 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
Gilles Peskine | fa65237 | 2022-10-13 22:05:38 +0200 | [diff] [blame] | 3120 | scripts/config.py unset MBEDTLS_LMS_C |
| 3121 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3122 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3123 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3124 | } |
| 3125 | |
| 3126 | # This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test. |
| 3127 | component_build_psa_accel_alg_ripemd160() { |
| 3128 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RIPEMD160 without other hashes |
| 3129 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RIPEMD160 - other hashes" |
| 3130 | scripts/config.py full |
| 3131 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3132 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3133 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3134 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 3135 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 3136 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 3137 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 3138 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 3139 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
Andrzej Kurek | 4ba0e45 | 2022-09-14 12:47:26 -0400 | [diff] [blame] | 3140 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
Gilles Peskine | fa65237 | 2022-10-13 22:05:38 +0200 | [diff] [blame] | 3141 | scripts/config.py unset MBEDTLS_LMS_C |
| 3142 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3143 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3144 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3145 | } |
| 3146 | |
| 3147 | # This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test. |
| 3148 | component_build_psa_accel_alg_sha1() { |
| 3149 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_1 without other hashes |
| 3150 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_1 - other hashes" |
| 3151 | scripts/config.py full |
| 3152 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3153 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3154 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3155 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 3156 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 3157 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 3158 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 3159 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 3160 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
Andrzej Kurek | 4ba0e45 | 2022-09-14 12:47:26 -0400 | [diff] [blame] | 3161 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
Gilles Peskine | fa65237 | 2022-10-13 22:05:38 +0200 | [diff] [blame] | 3162 | scripts/config.py unset MBEDTLS_LMS_C |
| 3163 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3164 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3165 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3166 | } |
| 3167 | |
| 3168 | # This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test. |
| 3169 | component_build_psa_accel_alg_sha224() { |
| 3170 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_224 without other hashes |
| 3171 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_224 - other hashes" |
| 3172 | scripts/config.py full |
| 3173 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3174 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3175 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3176 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 3177 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 3178 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 3179 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 3180 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
Andrzej Kurek | 4ba0e45 | 2022-09-14 12:47:26 -0400 | [diff] [blame] | 3181 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3182 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3183 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3184 | } |
| 3185 | |
| 3186 | # This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test. |
| 3187 | component_build_psa_accel_alg_sha256() { |
| 3188 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_256 without other hashes |
| 3189 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_256 - other hashes" |
| 3190 | scripts/config.py full |
| 3191 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3192 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3193 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3194 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 3195 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 3196 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 3197 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 3198 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
| 3199 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_512 |
| 3200 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3201 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3202 | } |
| 3203 | |
| 3204 | # This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test. |
| 3205 | component_build_psa_accel_alg_sha384() { |
| 3206 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_384 without other hashes |
| 3207 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_384 - other hashes" |
| 3208 | scripts/config.py full |
| 3209 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3210 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3211 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3212 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 3213 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 3214 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 3215 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 3216 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
Andrzej Kurek | 4ba0e45 | 2022-09-14 12:47:26 -0400 | [diff] [blame] | 3217 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
Gilles Peskine | fa65237 | 2022-10-13 22:05:38 +0200 | [diff] [blame] | 3218 | scripts/config.py unset MBEDTLS_LMS_C |
| 3219 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3220 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3221 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3222 | } |
| 3223 | |
| 3224 | # This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test. |
| 3225 | component_build_psa_accel_alg_sha512() { |
| 3226 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_SHA_512 without other hashes |
| 3227 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_SHA_512 - other hashes" |
| 3228 | scripts/config.py full |
| 3229 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3230 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3231 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3232 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_MD5 |
| 3233 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RIPEMD160 |
| 3234 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_1 |
| 3235 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_224 |
| 3236 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_256 |
| 3237 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_SHA_384 |
Andrzej Kurek | 4ba0e45 | 2022-09-14 12:47:26 -0400 | [diff] [blame] | 3238 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
Gilles Peskine | fa65237 | 2022-10-13 22:05:38 +0200 | [diff] [blame] | 3239 | scripts/config.py unset MBEDTLS_LMS_C |
| 3240 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
John Durkop | 1b7ee05 | 2020-11-27 08:51:22 -0800 | [diff] [blame] | 3241 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3242 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3243 | } |
| 3244 | |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3245 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3246 | component_build_psa_accel_alg_rsa_pkcs1v15_crypt() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3247 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 3248 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3249 | scripts/config.py full |
| 3250 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3251 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3252 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3253 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1 |
John Durkop | 7fc75ea | 2020-11-03 19:05:36 -0800 | [diff] [blame] | 3254 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 3255 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP |
| 3256 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS |
John Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3257 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3258 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3259 | } |
| 3260 | |
| 3261 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3262 | component_build_psa_accel_alg_rsa_pkcs1v15_sign() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3263 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PKCS1V15_SIGN and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY |
| 3264 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PKCS1V15_SIGN + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 3265 | scripts/config.py full |
| 3266 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3267 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3268 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3269 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1 |
John Durkop | 7fc75ea | 2020-11-03 19:05:36 -0800 | [diff] [blame] | 3270 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 3271 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP |
| 3272 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3273 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3274 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3275 | } |
| 3276 | |
| 3277 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3278 | component_build_psa_accel_alg_rsa_oaep() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3279 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_OAEP and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY |
| 3280 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_OAEP + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 3281 | scripts/config.py full |
| 3282 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3283 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3284 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3285 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_OAEP 1 |
John Durkop | 7fc75ea | 2020-11-03 19:05:36 -0800 | [diff] [blame] | 3286 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 3287 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 3288 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PSS |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3289 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3290 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3291 | } |
| 3292 | |
| 3293 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3294 | component_build_psa_accel_alg_rsa_pss() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3295 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_ALG_RSA_PSS and PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY |
| 3296 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_ALG_RSA_PSS + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 3297 | scripts/config.py full |
| 3298 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3299 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3300 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3301 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1 |
John Durkop | 7fc75ea | 2020-11-03 19:05:36 -0800 | [diff] [blame] | 3302 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 3303 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 3304 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_RSA_OAEP |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3305 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3306 | make CC=gcc CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include -O2" LDFLAGS="$ASAN_CFLAGS" |
| 3307 | } |
| 3308 | |
| 3309 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3310 | component_build_psa_accel_key_type_rsa_key_pair() { |
Valerio Setti | ff7f861 | 2023-05-26 13:49:33 +0200 | [diff] [blame] | 3311 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_xxx and PSA_WANT_ALG_RSA_PSS |
| 3312 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_xxx + PSA_WANT_ALG_RSA_PSS" |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3313 | scripts/config.py full |
| 3314 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3315 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3316 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3317 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1 |
Valerio Setti | 01cc88a | 2023-06-15 11:53:08 +0200 | [diff] [blame] | 3318 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC 1 |
Valerio Setti | ff7f861 | 2023-05-26 13:49:33 +0200 | [diff] [blame] | 3319 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT 1 |
| 3320 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT 1 |
| 3321 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE 1 |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3322 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3323 | 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" |
| 3324 | } |
| 3325 | |
| 3326 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
John Durkop | 6ba40d1 | 2020-11-10 08:50:04 -0800 | [diff] [blame] | 3327 | component_build_psa_accel_key_type_rsa_public_key() { |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3328 | # full plus MBEDTLS_PSA_CRYPTO_CONFIG with PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY and PSA_WANT_ALG_RSA_PSS |
| 3329 | msg "build: full + MBEDTLS_PSA_CRYPTO_CONFIG + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + PSA_WANT_ALG_RSA_PSS" |
| 3330 | scripts/config.py full |
| 3331 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3332 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
Ronald Cron | f660655 | 2022-03-15 11:23:25 +0100 | [diff] [blame] | 3333 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
John Durkop | bd069d3 | 2020-10-31 22:14:03 -0700 | [diff] [blame] | 3334 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_ALG_RSA_PSS 1 |
| 3335 | scripts/config.py -f include/psa/crypto_config.h set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1 |
| 3336 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 3337 | 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 Durkop | d032195 | 2020-10-29 21:37:36 -0700 | [diff] [blame] | 3338 | } |
| 3339 | |
Dave Rodgman | c164c07 | 2023-06-28 09:43:23 +0100 | [diff] [blame] | 3340 | |
Dave Rodgman | 904c589 | 2023-06-28 17:36:02 +0100 | [diff] [blame] | 3341 | support_build_tfm_armcc () { |
Dave Rodgman | c164c07 | 2023-06-28 09:43:23 +0100 | [diff] [blame] | 3342 | armc6_cc="$ARMC6_BIN_DIR/armclang" |
| 3343 | (check_tools "$armc6_cc" > /dev/null 2>&1) |
| 3344 | } |
| 3345 | |
Dave Rodgman | 904c589 | 2023-06-28 17:36:02 +0100 | [diff] [blame] | 3346 | component_build_tfm_armcc() { |
| 3347 | # test the TF-M configuration can build cleanly with various warning flags enabled |
| 3348 | cp configs/tfm_mbedcrypto_config_profile_medium.h include/mbedtls/mbedtls_config.h |
| 3349 | cp configs/crypto_config_profile_medium.h include/psa/crypto_config.h |
Dave Rodgman | c164c07 | 2023-06-28 09:43:23 +0100 | [diff] [blame] | 3350 | |
Dave Rodgman | fb374e6 | 2023-06-29 11:58:16 +0100 | [diff] [blame^] | 3351 | msg "build: TF-M config, armclang armv7 thumb2" |
| 3352 | make clean |
| 3353 | armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused" |
| 3354 | } |
| 3355 | |
| 3356 | component_build_tfm() { |
| 3357 | # test the TF-M configuration can build cleanly with various warning flags enabled |
| 3358 | cp configs/tfm_mbedcrypto_config_profile_medium.h include/mbedtls/mbedtls_config.h |
| 3359 | cp configs/crypto_config_profile_medium.h include/psa/crypto_config.h |
| 3360 | |
Dave Rodgman | 904c589 | 2023-06-28 17:36:02 +0100 | [diff] [blame] | 3361 | msg "build: TF-M config, clang, armv8 thumb2" |
| 3362 | make lib CC="clang" CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32 -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused" |
Dave Rodgman | c164c07 | 2023-06-28 09:43:23 +0100 | [diff] [blame] | 3363 | |
Dave Rodgman | 904c589 | 2023-06-28 17:36:02 +0100 | [diff] [blame] | 3364 | msg "build: TF-M config, gcc native build" |
| 3365 | make clean |
| 3366 | make lib CC="gcc" CFLAGS="-Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wformat-signedness -Wformat-overflow=2 -Wformat-truncation -Wlogical-op" |
Dave Rodgman | c164c07 | 2023-06-28 09:43:23 +0100 | [diff] [blame] | 3367 | } |
| 3368 | |
Dave Rodgman | 6001fb2 | 2023-06-29 09:29:00 +0100 | [diff] [blame] | 3369 | component_build_aes_variations() { # ~45s |
Dave Rodgman | cd04020 | 2023-06-29 09:29:00 +0100 | [diff] [blame] | 3370 | # aes.o has many #if defined(...) guards that intersect in complex ways. |
| 3371 | # Test that all the combinations build cleanly. The most common issue is |
| 3372 | # unused variables/functions, so ensure -Wunused is set. |
| 3373 | |
Dave Rodgman | 6001fb2 | 2023-06-29 09:29:00 +0100 | [diff] [blame] | 3374 | msg "build: aes.o for all combinations of relevant config options" |
| 3375 | for a in set unset; do |
| 3376 | for b in set unset; do |
| 3377 | for c in set unset; do |
| 3378 | for d in set unset; do |
| 3379 | for e in set unset; do |
| 3380 | for f in set unset; do |
| 3381 | for g in set unset; do |
| 3382 | echo ./scripts/config.py $a MBEDTLS_AES_SETKEY_ENC_ALT |
| 3383 | echo ./scripts/config.py $b MBEDTLS_AES_DECRYPT_ALT |
| 3384 | echo ./scripts/config.py $c MBEDTLS_AES_ROM_TABLES |
| 3385 | echo ./scripts/config.py $d MBEDTLS_AES_ENCRYPT_ALT |
| 3386 | echo ./scripts/config.py $e MBEDTLS_AES_SETKEY_DEC_ALT |
| 3387 | echo ./scripts/config.py $f MBEDTLS_AES_FEWER_TABLES |
| 3388 | echo ./scripts/config.py $g MBEDTLS_PADLOCK_C |
| 3389 | |
| 3390 | ./scripts/config.py $a MBEDTLS_AES_SETKEY_ENC_ALT |
| 3391 | ./scripts/config.py $b MBEDTLS_AES_DECRYPT_ALT |
| 3392 | ./scripts/config.py $c MBEDTLS_AES_ROM_TABLES |
| 3393 | ./scripts/config.py $d MBEDTLS_AES_ENCRYPT_ALT |
| 3394 | ./scripts/config.py $e MBEDTLS_AES_SETKEY_DEC_ALT |
| 3395 | ./scripts/config.py $f MBEDTLS_AES_FEWER_TABLES |
| 3396 | ./scripts/config.py $g MBEDTLS_PADLOCK_C |
| 3397 | |
| 3398 | rm -f library/aes.o |
| 3399 | 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" |
| 3400 | done |
| 3401 | done |
| 3402 | done |
| 3403 | done |
| 3404 | done |
| 3405 | done |
| 3406 | done |
| 3407 | } |
| 3408 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3409 | component_test_no_platform () { |
| 3410 | # Full configuration build, without platform support, file IO and net sockets. |
| 3411 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 3412 | # IO, it should catch missing '#include <stdio.h>' |
| 3413 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3414 | scripts/config.py full |
| 3415 | scripts/config.py unset MBEDTLS_PLATFORM_C |
| 3416 | scripts/config.py unset MBEDTLS_NET_C |
| 3417 | scripts/config.py unset MBEDTLS_PLATFORM_MEMORY |
| 3418 | scripts/config.py unset MBEDTLS_PLATFORM_PRINTF_ALT |
| 3419 | scripts/config.py unset MBEDTLS_PLATFORM_FPRINTF_ALT |
| 3420 | scripts/config.py unset MBEDTLS_PLATFORM_SNPRINTF_ALT |
Gilles Peskine | ef843f2 | 2022-09-18 14:05:23 +0200 | [diff] [blame] | 3421 | scripts/config.py unset MBEDTLS_PLATFORM_VSNPRINTF_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3422 | scripts/config.py unset MBEDTLS_PLATFORM_TIME_ALT |
| 3423 | scripts/config.py unset MBEDTLS_PLATFORM_EXIT_ALT |
Gilles Peskine | 6497b5a | 2022-06-30 17:01:40 +0200 | [diff] [blame] | 3424 | scripts/config.py unset MBEDTLS_PLATFORM_SETBUF_ALT |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 3425 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3426 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 3427 | scripts/config.py unset MBEDTLS_FS_IO |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3428 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3429 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 3430 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3431 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 3432 | # to re-enable platform integration features otherwise disabled in C99 builds |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 3433 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs |
| 3434 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3435 | } |
Manuel Pégourié-Gonnard | a71780e | 2015-02-13 13:56:55 +0000 | [diff] [blame] | 3436 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3437 | component_build_no_std_function () { |
| 3438 | # catch compile bugs in _uninit functions |
| 3439 | msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3440 | scripts/config.py full |
| 3441 | scripts/config.py set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS |
| 3442 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
Gilles Peskine | 32e889d | 2020-04-12 23:43:28 +0200 | [diff] [blame] | 3443 | scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT |
Gilles Peskine | f4d2fd4 | 2021-10-08 11:45:47 +0200 | [diff] [blame] | 3444 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . |
Gilles Peskine | dbf7b7e | 2021-10-07 19:34:57 +0200 | [diff] [blame] | 3445 | make |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3446 | } |
Manuel Pégourié-Gonnard | dccb80b | 2015-06-03 10:20:33 +0100 | [diff] [blame] | 3447 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3448 | component_build_no_ssl_srv () { |
Ronald Cron | de1adee | 2022-03-07 16:20:30 +0100 | [diff] [blame] | 3449 | msg "build: full config except SSL server, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3450 | scripts/config.py full |
| 3451 | scripts/config.py unset MBEDTLS_SSL_SRV_C |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 3452 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3453 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 3454 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3455 | component_build_no_ssl_cli () { |
Ronald Cron | de1adee | 2022-03-07 16:20:30 +0100 | [diff] [blame] | 3456 | msg "build: full config except SSL client, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3457 | scripts/config.py full |
| 3458 | scripts/config.py unset MBEDTLS_SSL_CLI_C |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 3459 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1' |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3460 | } |
Manuel Pégourié-Gonnard | 66b8e95 | 2015-05-20 11:13:56 +0200 | [diff] [blame] | 3461 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3462 | component_build_no_sockets () { |
| 3463 | # Note, C99 compliance can also be tested with the sockets support disabled, |
| 3464 | # as that requires a POSIX platform (which isn't the same as C99). |
| 3465 | msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3466 | scripts/config.py full |
| 3467 | scripts/config.py unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. |
| 3468 | scripts/config.py set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux |
Gilles Peskine | 6ec0f0f | 2019-09-20 19:23:10 +0200 | [diff] [blame] | 3469 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -std=c99 -pedantic' lib |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3470 | } |
Manuel Pégourié-Gonnard | 009a264 | 2015-05-29 10:31:13 +0200 | [diff] [blame] | 3471 | |
Andrzej Kurek | 69f20aa | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 3472 | component_test_memory_buffer_allocator_backtrace () { |
| 3473 | msg "build: default config with memory buffer allocator and backtrace enabled" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3474 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 3475 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 3476 | scripts/config.py set MBEDTLS_MEMORY_BACKTRACE |
| 3477 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
Gilles Peskine | e7fc7ef | 2021-10-19 21:33:32 +0200 | [diff] [blame] | 3478 | CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . |
Andrzej Kurek | 69f20aa | 2019-09-05 09:27:47 -0400 | [diff] [blame] | 3479 | make |
| 3480 | |
| 3481 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 3482 | make test |
| 3483 | } |
| 3484 | |
| 3485 | component_test_memory_buffer_allocator () { |
| 3486 | msg "build: default config with memory buffer allocator" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3487 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 3488 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
Gilles Peskine | e7fc7ef | 2021-10-19 21:33:32 +0200 | [diff] [blame] | 3489 | CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . |
Hanno Becker | 0fb9ba2 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 3490 | make |
| 3491 | |
| 3492 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 3493 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 3494 | |
| 3495 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 3496 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3497 | tests/ssl-opt.sh -e '^DTLS proxy' |
Hanno Becker | 0fb9ba2 | 2019-02-26 14:34:13 +0000 | [diff] [blame] | 3498 | } |
| 3499 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3500 | component_test_no_max_fragment_length () { |
| 3501 | # Run max fragment length tests with MFL disabled |
| 3502 | msg "build: default config except MFL extension (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3503 | scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3504 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3505 | make |
Hanno Becker | 5175ac6 | 2017-09-18 15:36:25 +0100 | [diff] [blame] | 3506 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3507 | msg "test: ssl-opt.sh, MFL-related tests" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3508 | tests/ssl-opt.sh -f "Max fragment length" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3509 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 3510 | |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 3511 | component_test_asan_remove_peer_certificate () { |
| 3512 | msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3513 | scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 3514 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3515 | make |
| 3516 | |
| 3517 | msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
| 3518 | make test |
| 3519 | |
| 3520 | msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3521 | tests/ssl-opt.sh |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 3522 | |
| 3523 | msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3524 | tests/compat.sh |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 3525 | |
| 3526 | msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3527 | tests/context-info.sh |
Hanno Becker | 545ced4 | 2019-02-19 11:10:48 +0000 | [diff] [blame] | 3528 | } |
| 3529 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3530 | component_test_no_max_fragment_length_small_ssl_out_content_len () { |
| 3531 | msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3532 | scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 3533 | scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384 |
| 3534 | scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3535 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3536 | make |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 3537 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3538 | msg "test: MFL tests (disabled MFL extension case) & large packet tests" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3539 | tests/ssl-opt.sh -f "Max fragment length\|Large buffer" |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 3540 | |
| 3541 | msg "test: context-info.sh (disabled MFL extension case)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3542 | tests/context-info.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3543 | } |
Angus Gratton | c4dd073 | 2018-04-11 16:28:39 +1000 | [diff] [blame] | 3544 | |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 3545 | component_test_variable_ssl_in_out_buffer_len () { |
| 3546 | msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)" |
| 3547 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
| 3548 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3549 | make |
| 3550 | |
| 3551 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
| 3552 | make test |
| 3553 | |
| 3554 | msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3555 | tests/ssl-opt.sh |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 3556 | |
| 3557 | msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3558 | tests/compat.sh |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 3559 | } |
| 3560 | |
Manuel Pégourié-Gonnard | 6a543ba | 2022-11-25 11:30:10 +0100 | [diff] [blame] | 3561 | component_test_dtls_cid_legacy () { |
Hannes Tschofenig | df84bb3 | 2022-11-23 11:14:03 +0100 | [diff] [blame] | 3562 | msg "build: MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled (ASan build)" |
Hannes Tschofenig | fd6cca4 | 2021-10-12 09:22:33 +0200 | [diff] [blame] | 3563 | scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT 1 |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 3564 | |
| 3565 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3566 | make |
| 3567 | |
Hannes Tschofenig | df84bb3 | 2022-11-23 11:14:03 +0100 | [diff] [blame] | 3568 | msg "test: MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy)" |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 3569 | make test |
| 3570 | |
Hannes Tschofenig | df84bb3 | 2022-11-23 11:14:03 +0100 | [diff] [blame] | 3571 | msg "test: ssl-opt.sh, MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3572 | tests/ssl-opt.sh |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 3573 | |
Manuel Pégourié-Gonnard | 6a543ba | 2022-11-25 11:30:10 +0100 | [diff] [blame] | 3574 | msg "test: compat.sh, MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3575 | tests/compat.sh |
Darryl Green | aad82f9 | 2019-12-02 10:53:11 +0000 | [diff] [blame] | 3576 | } |
| 3577 | |
Piotr Nowicki | 0937ed2 | 2019-11-26 16:32:40 +0100 | [diff] [blame] | 3578 | component_test_ssl_alloc_buffer_and_mfl () { |
| 3579 | msg "build: default config with memory buffer allocator and MFL extension" |
| 3580 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 3581 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 3582 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
| 3583 | scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH |
| 3584 | scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH |
Gilles Peskine | e7fc7ef | 2021-10-19 21:33:32 +0200 | [diff] [blame] | 3585 | CC=gcc cmake -DCMAKE_BUILD_TYPE:String=Release . |
Piotr Nowicki | 0937ed2 | 2019-11-26 16:32:40 +0100 | [diff] [blame] | 3586 | make |
| 3587 | |
| 3588 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" |
| 3589 | make test |
| 3590 | |
| 3591 | msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3592 | tests/ssl-opt.sh -f "Handshake memory usage" |
Piotr Nowicki | 0937ed2 | 2019-11-26 16:32:40 +0100 | [diff] [blame] | 3593 | } |
| 3594 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 3595 | component_test_when_no_ciphersuites_have_mac () { |
| 3596 | msg "build: when no ciphersuites have MAC" |
| 3597 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 3598 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC |
TRodziewicz | 2add5c1 | 2021-04-28 16:50:20 +0200 | [diff] [blame] | 3599 | scripts/config.py unset MBEDTLS_CMAC_C |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 3600 | make |
| 3601 | |
| 3602 | msg "test: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
| 3603 | make test |
| 3604 | |
| 3605 | msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_MODES_USE_MAC" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3606 | tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM' |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 3607 | } |
| 3608 | |
Raoul Strackx | a4e8614 | 2020-06-15 17:03:13 +0200 | [diff] [blame] | 3609 | component_test_no_date_time () { |
| 3610 | msg "build: default config without MBEDTLS_HAVE_TIME_DATE" |
| 3611 | scripts/config.py unset MBEDTLS_HAVE_TIME_DATE |
Gilles Peskine | f4d2fd4 | 2021-10-08 11:45:47 +0200 | [diff] [blame] | 3612 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Check . |
Raoul Strackx | a4e8614 | 2020-06-15 17:03:13 +0200 | [diff] [blame] | 3613 | make |
| 3614 | |
| 3615 | msg "test: !MBEDTLS_HAVE_TIME_DATE - main suites" |
| 3616 | make test |
| 3617 | } |
| 3618 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3619 | component_test_platform_calloc_macro () { |
| 3620 | msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3621 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 3622 | scripts/config.py set MBEDTLS_PLATFORM_CALLOC_MACRO calloc |
| 3623 | scripts/config.py set MBEDTLS_PLATFORM_FREE_MACRO free |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3624 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3625 | make |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 3626 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3627 | msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" |
| 3628 | make test |
| 3629 | } |
Hanno Becker | e5fecec | 2018-10-11 11:02:52 +0100 | [diff] [blame] | 3630 | |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 3631 | component_test_malloc_0_null () { |
| 3632 | msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 3633 | scripts/config.py full |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 3634 | make CC=gcc CFLAGS="'-DMBEDTLS_CONFIG_FILE=\"$PWD/tests/configs/config-wrapper-malloc-0-null.h\"' $ASAN_CFLAGS -O" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 3635 | |
| 3636 | msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 3637 | make test |
| 3638 | |
| 3639 | msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" |
| 3640 | # Just the calloc selftest. "make test" ran the others as part of the |
| 3641 | # test suites. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3642 | programs/test/selftest calloc |
Gilles Peskine | 765d240 | 2020-02-11 18:26:34 +0100 | [diff] [blame] | 3643 | |
| 3644 | msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)" |
| 3645 | # Run a subset of the tests. The choice is a balance between coverage |
| 3646 | # and time (including time indirectly wasted due to flaky tests). |
| 3647 | # The current choice is to skip tests whose description includes |
| 3648 | # "proxy", which is an approximation of skipping tests that use the |
| 3649 | # UDP proxy, which tend to be slower and flakier. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3650 | tests/ssl-opt.sh -e 'proxy' |
Gilles Peskine | c4ef7a9 | 2019-09-17 19:04:38 +0200 | [diff] [blame] | 3651 | } |
| 3652 | |
Arto Kinnunen | 3eb50e7 | 2023-04-14 17:43:36 +0800 | [diff] [blame] | 3653 | component_test_aes_only_128_bit_keys () { |
Yanray Wang | 012b6bb | 2023-05-11 17:47:56 +0800 | [diff] [blame] | 3654 | msg "build: default config + AES_ONLY_128_BIT_KEY_LENGTH" |
Arto Kinnunen | 3eb50e7 | 2023-04-14 17:43:36 +0800 | [diff] [blame] | 3655 | scripts/config.py set MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH |
Arto Kinnunen | 3eb50e7 | 2023-04-14 17:43:36 +0800 | [diff] [blame] | 3656 | scripts/config.py unset MBEDTLS_PADLOCK_C |
| 3657 | |
| 3658 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
| 3659 | |
Yanray Wang | 012b6bb | 2023-05-11 17:47:56 +0800 | [diff] [blame] | 3660 | msg "test: default config + AES_ONLY_128_BIT_KEY_LENGTH" |
Arto Kinnunen | 3eb50e7 | 2023-04-14 17:43:36 +0800 | [diff] [blame] | 3661 | make test |
| 3662 | } |
| 3663 | |
Yanray Wang | 374c3ae | 2023-05-05 12:46:48 +0800 | [diff] [blame] | 3664 | component_test_no_ctr_drbg_aes_only_128_bit_keys () { |
Yanray Wang | 012b6bb | 2023-05-11 17:47:56 +0800 | [diff] [blame] | 3665 | msg "build: default config + AES_ONLY_128_BIT_KEY_LENGTH - CTR_DRBG_C" |
Yanray Wang | 374c3ae | 2023-05-05 12:46:48 +0800 | [diff] [blame] | 3666 | scripts/config.py set MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH |
| 3667 | scripts/config.py unset MBEDTLS_CTR_DRBG_C |
| 3668 | scripts/config.py unset MBEDTLS_PADLOCK_C |
| 3669 | |
Yanray Wang | 4292441 | 2023-06-14 17:10:13 +0800 | [diff] [blame] | 3670 | make CC=clang CFLAGS='-Werror -Wall -Wextra' |
Yanray Wang | 374c3ae | 2023-05-05 12:46:48 +0800 | [diff] [blame] | 3671 | |
Yanray Wang | 012b6bb | 2023-05-11 17:47:56 +0800 | [diff] [blame] | 3672 | msg "test: default config + AES_ONLY_128_BIT_KEY_LENGTH - CTR_DRBG_C" |
Yanray Wang | 374c3ae | 2023-05-05 12:46:48 +0800 | [diff] [blame] | 3673 | make test |
| 3674 | } |
| 3675 | |
Yanray Wang | 012b6bb | 2023-05-11 17:47:56 +0800 | [diff] [blame] | 3676 | component_test_aes_only_128_bit_keys_have_builtins () { |
| 3677 | msg "build: default config + AES_ONLY_128_BIT_KEY_LENGTH - AESNI_C - AESCE_C" |
| 3678 | scripts/config.py set MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH |
| 3679 | scripts/config.py unset MBEDTLS_PADLOCK_C |
| 3680 | scripts/config.py unset MBEDTLS_AESNI_C |
| 3681 | scripts/config.py unset MBEDTLS_AESCE_C |
| 3682 | |
| 3683 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
| 3684 | |
| 3685 | msg "test: default config + AES_ONLY_128_BIT_KEY_LENGTH - AESNI_C - AESCE_C" |
| 3686 | make test |
| 3687 | |
| 3688 | msg "selftest: default config + AES_ONLY_128_BIT_KEY_LENGTH - AESNI_C - AESCE_C" |
| 3689 | programs/test/selftest |
| 3690 | } |
| 3691 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3692 | component_test_aes_fewer_tables () { |
| 3693 | msg "build: default config with AES_FEWER_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3694 | scripts/config.py set MBEDTLS_AES_FEWER_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3695 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 3696 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3697 | msg "test: AES_FEWER_TABLES" |
| 3698 | make test |
| 3699 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 3700 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3701 | component_test_aes_rom_tables () { |
| 3702 | msg "build: default config with AES_ROM_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3703 | scripts/config.py set MBEDTLS_AES_ROM_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3704 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 3705 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3706 | msg "test: AES_ROM_TABLES" |
| 3707 | make test |
| 3708 | } |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 3709 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3710 | component_test_aes_fewer_tables_and_rom_tables () { |
| 3711 | msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3712 | scripts/config.py set MBEDTLS_AES_FEWER_TABLES |
| 3713 | scripts/config.py set MBEDTLS_AES_ROM_TABLES |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3714 | make CC=gcc CFLAGS='-Werror -Wall -Wextra' |
Hanno Becker | 83ebf78 | 2017-07-07 12:29:15 +0100 | [diff] [blame] | 3715 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3716 | msg "test: AES_FEWER_TABLES + AES_ROM_TABLES" |
| 3717 | make test |
| 3718 | } |
| 3719 | |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 3720 | component_test_ctr_drbg_aes_256_sha_256 () { |
| 3721 | msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 3722 | scripts/config.py full |
| 3723 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 3724 | scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256 |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 3725 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3726 | make |
| 3727 | |
| 3728 | msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
| 3729 | make test |
| 3730 | } |
| 3731 | |
| 3732 | component_test_ctr_drbg_aes_128_sha_512 () { |
| 3733 | msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 3734 | scripts/config.py full |
| 3735 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 3736 | scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 3737 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3738 | make |
| 3739 | |
| 3740 | msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)" |
| 3741 | make test |
| 3742 | } |
| 3743 | |
| 3744 | component_test_ctr_drbg_aes_128_sha_256 () { |
| 3745 | msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
Gilles Peskine | 3b46cd3 | 2020-02-18 17:56:33 +0100 | [diff] [blame] | 3746 | scripts/config.py full |
| 3747 | scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 3748 | scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY |
| 3749 | scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256 |
Gilles Peskine | 592f591 | 2019-10-07 18:49:32 +0200 | [diff] [blame] | 3750 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3751 | make |
| 3752 | |
| 3753 | msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)" |
| 3754 | make test |
| 3755 | } |
| 3756 | |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 3757 | component_test_se_default () { |
| 3758 | msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3759 | scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C |
Gilles Peskine | 004206c | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 3760 | make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS" |
Gilles Peskine | f96aefe | 2019-07-24 14:58:38 +0200 | [diff] [blame] | 3761 | |
| 3762 | msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C" |
| 3763 | make test |
| 3764 | } |
| 3765 | |
Steven Cooreman | d57203d | 2020-07-16 20:28:59 +0200 | [diff] [blame] | 3766 | component_test_psa_crypto_drivers () { |
Ronald Cron | 32a432a | 2023-03-28 09:19:04 +0200 | [diff] [blame] | 3767 | msg "build: full + MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS + test drivers" |
Steven Cooreman | 753f973 | 2021-03-15 11:38:44 +0100 | [diff] [blame] | 3768 | scripts/config.py full |
Steven Cooreman | 6801f08 | 2021-02-19 17:21:22 +0100 | [diff] [blame] | 3769 | scripts/config.py set MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS |
Gilles Peskine | 3587dfd | 2021-09-20 19:20:04 +0200 | [diff] [blame] | 3770 | loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL" |
| 3771 | loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" |
Ronald Cron | 17b3afc | 2020-12-10 18:17:09 +0100 | [diff] [blame] | 3772 | loc_cflags="${loc_cflags} -I../tests/include -O2" |
| 3773 | |
| 3774 | make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS" |
Steven Cooreman | d57203d | 2020-07-16 20:28:59 +0200 | [diff] [blame] | 3775 | |
Ronald Cron | 32a432a | 2023-03-28 09:19:04 +0200 | [diff] [blame] | 3776 | msg "test: full + MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS + test drivers" |
Steven Cooreman | d57203d | 2020-07-16 20:28:59 +0200 | [diff] [blame] | 3777 | make test |
| 3778 | } |
| 3779 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3780 | component_test_make_shared () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 3781 | msg "build/test: make shared" # ~ 40s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 3782 | make SHARED=1 all check |
Gilles Peskine | 56c0161 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 3783 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | ca14459 | 2021-11-04 12:52:14 +0100 | [diff] [blame] | 3784 | programs/test/dlopen_demo.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3785 | } |
Manuel Pégourié-Gonnard | 9b06abe | 2015-06-25 09:56:07 +0200 | [diff] [blame] | 3786 | |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 3787 | component_test_cmake_shared () { |
| 3788 | msg "build/test: cmake shared" # ~ 2min |
| 3789 | cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On . |
| 3790 | make |
Gilles Peskine | 56c0161 | 2019-07-03 20:43:32 +0200 | [diff] [blame] | 3791 | ldd programs/util/strerror | grep libmbedcrypto |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 3792 | make test |
Gilles Peskine | ca14459 | 2021-11-04 12:52:14 +0100 | [diff] [blame] | 3793 | programs/test/dlopen_demo.sh |
Gilles Peskine | cf74050 | 2019-07-03 20:43:05 +0200 | [diff] [blame] | 3794 | } |
| 3795 | |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 3796 | test_build_opt () { |
| 3797 | info=$1 cc=$2; shift 2 |
| 3798 | for opt in "$@"; do |
| 3799 | msg "build/test: $cc $opt, $info" # ~ 30s |
Gilles Peskine | e094a18 | 2020-04-14 20:08:41 +0200 | [diff] [blame] | 3800 | make CC="$cc" CFLAGS="$opt -std=c99 -pedantic -Wall -Wextra -Werror" |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 3801 | # We're confident enough in compilers to not run _all_ the tests, |
| 3802 | # but at least run the unit tests. In particular, runs with |
| 3803 | # optimizations use inline assembly whereas runs with -O0 |
| 3804 | # skip inline assembly. |
| 3805 | make test # ~30s |
| 3806 | make clean |
| 3807 | done |
| 3808 | } |
| 3809 | |
| 3810 | component_test_clang_opt () { |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 3811 | scripts/config.py full |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 3812 | test_build_opt 'full config' clang -O0 -Os -O2 |
| 3813 | } |
| 3814 | |
| 3815 | component_test_gcc_opt () { |
Manuel Pégourié-Gonnard | 68192fc | 2020-03-04 10:34:47 +0100 | [diff] [blame] | 3816 | scripts/config.py full |
Gilles Peskine | ec10bf1 | 2019-09-20 19:56:06 +0200 | [diff] [blame] | 3817 | test_build_opt 'full config' gcc -O0 -Os -O2 |
| 3818 | } |
| 3819 | |
Gilles Peskine | abf9b4d | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 3820 | component_build_mbedtls_config_file () { |
| 3821 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
Gilles Peskine | 2003c2f | 2022-04-07 20:55:57 +0200 | [diff] [blame] | 3822 | scripts/config.py -w full_config.h full |
Gilles Peskine | abf9b4d | 2019-07-03 20:42:16 +0200 | [diff] [blame] | 3823 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 3824 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
Gilles Peskine | 45e680e | 2022-04-13 23:23:21 +0200 | [diff] [blame] | 3825 | # Make sure this feature is enabled. We'll disable it in the next phase. |
Gilles Peskine | e10df77 | 2022-04-07 21:06:41 +0200 | [diff] [blame] | 3826 | programs/test/query_compile_time_config MBEDTLS_NIST_KW_C |
| 3827 | make clean |
| 3828 | |
| 3829 | msg "build: make with MBEDTLS_CONFIG_FILE + MBEDTLS_USER_CONFIG_FILE" |
| 3830 | # In the user config, disable one feature (for simplicity, pick a feature |
| 3831 | # that nothing else depends on). |
| 3832 | echo '#undef MBEDTLS_NIST_KW_C' >user_config.h |
| 3833 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"' -DMBEDTLS_USER_CONFIG_FILE='\"user_config.h\"'" |
| 3834 | not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C |
| 3835 | |
| 3836 | rm -f user_config.h full_config.h |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 3837 | } |
| 3838 | |
Gilles Peskine | 7d904e7 | 2022-04-07 21:59:14 +0200 | [diff] [blame] | 3839 | component_build_psa_config_file () { |
| 3840 | msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE" # ~40s |
| 3841 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 3842 | cp "$CRYPTO_CONFIG_H" psa_test_config.h |
| 3843 | echo '#error "MBEDTLS_PSA_CRYPTO_CONFIG_FILE is not working"' >"$CRYPTO_CONFIG_H" |
| 3844 | make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"'" |
Gilles Peskine | 45e680e | 2022-04-13 23:23:21 +0200 | [diff] [blame] | 3845 | # Make sure this feature is enabled. We'll disable it in the next phase. |
Gilles Peskine | 7d904e7 | 2022-04-07 21:59:14 +0200 | [diff] [blame] | 3846 | programs/test/query_compile_time_config MBEDTLS_CMAC_C |
| 3847 | make clean |
| 3848 | |
| 3849 | msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE + MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE" # ~40s |
| 3850 | # In the user config, disable one feature, which will reflect on the |
| 3851 | # mbedtls configuration so we can query it with query_compile_time_config. |
| 3852 | echo '#undef PSA_WANT_ALG_CMAC' >psa_user_config.h |
| 3853 | scripts/config.py unset MBEDTLS_CMAC_C |
| 3854 | make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"' -DMBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE='\"psa_user_config.h\"'" |
| 3855 | not programs/test/query_compile_time_config MBEDTLS_CMAC_C |
| 3856 | |
| 3857 | rm -f psa_test_config.h psa_user_config.h |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 3858 | } |
| 3859 | |
Gilles Peskine | df6e84a | 2023-02-22 22:09:51 +0100 | [diff] [blame] | 3860 | component_build_psa_alt_headers () { |
| 3861 | msg "build: make with PSA alt headers" # ~20s |
| 3862 | |
| 3863 | # Generate alternative versions of the substitutable headers with the |
| 3864 | # same content except different include guards. |
| 3865 | make -C tests include/alt-extra/psa/crypto_platform_alt.h include/alt-extra/psa/crypto_struct_alt.h |
| 3866 | |
| 3867 | # Build the library and some programs. |
| 3868 | # Don't build the fuzzers to avoid having to go through hoops to set |
| 3869 | # a correct include path for programs/fuzz/Makefile. |
| 3870 | make CFLAGS="-I ../tests/include/alt-extra -DMBEDTLS_PSA_CRYPTO_PLATFORM_FILE='\"psa/crypto_platform_alt.h\"' -DMBEDTLS_PSA_CRYPTO_STRUCT_FILE='\"psa/crypto_struct_alt.h\"'" lib |
| 3871 | make -C programs -o fuzz CFLAGS="-I ../tests/include/alt-extra -DMBEDTLS_PSA_CRYPTO_PLATFORM_FILE='\"psa/crypto_platform_alt.h\"' -DMBEDTLS_PSA_CRYPTO_STRUCT_FILE='\"psa/crypto_struct_alt.h\"'" |
| 3872 | |
| 3873 | # Check that we're getting the alternative include guards and not the |
| 3874 | # original include guards. |
| 3875 | programs/test/query_included_headers | grep -x PSA_CRYPTO_PLATFORM_ALT_H |
| 3876 | programs/test/query_included_headers | grep -x PSA_CRYPTO_STRUCT_ALT_H |
| 3877 | programs/test/query_included_headers | not grep -x PSA_CRYPTO_PLATFORM_H |
| 3878 | programs/test/query_included_headers | not grep -x PSA_CRYPTO_STRUCT_H |
| 3879 | } |
| 3880 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3881 | component_test_m32_o0 () { |
Gilles Peskine | 77f0535 | 2021-10-07 19:27:16 +0200 | [diff] [blame] | 3882 | # Build without optimization, so as to use portable C code (in a 32-bit |
| 3883 | # build) and not the i386-specific inline assembly. |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 3884 | msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3885 | scripts/config.py full |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 3886 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O0" LDFLAGS="-m32 $ASAN_CFLAGS" |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 3887 | |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 3888 | msg "test: i386, make, gcc -O0 (ASan build)" |
| 3889 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3890 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 3891 | support_test_m32_o0 () { |
| 3892 | case $(uname -m) in |
Pengyu Lv | c92df3b | 2022-10-21 10:50:26 +0000 | [diff] [blame] | 3893 | amd64|x86_64) true;; |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 3894 | *) false;; |
| 3895 | esac |
| 3896 | } |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 3897 | |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 3898 | component_test_m32_o2 () { |
| 3899 | # Build with optimization, to use the i386 specific inline assembly |
| 3900 | # and go faster for tests. |
| 3901 | msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3902 | scripts/config.py full |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 3903 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS" |
Simon Butcher | 8e6a22a | 2018-07-20 21:27:33 +0100 | [diff] [blame] | 3904 | |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 3905 | msg "test: i386, make, gcc -O2 (ASan build)" |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 3906 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 3907 | |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 3908 | msg "test ssl-opt.sh, i386, make, gcc-O2" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3909 | tests/ssl-opt.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3910 | } |
Gilles Peskine | cf52222 | 2021-10-07 19:25:29 +0200 | [diff] [blame] | 3911 | support_test_m32_o2 () { |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 3912 | support_test_m32_o0 "$@" |
| 3913 | } |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 3914 | |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 3915 | component_test_m32_everest () { |
| 3916 | msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3917 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
Gilles Peskine | 8fd5942 | 2019-10-21 17:11:33 +0200 | [diff] [blame] | 3918 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32 -O2" LDFLAGS="-m32 $ASAN_CFLAGS" |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 3919 | |
| 3920 | msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 3921 | make test |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 3922 | |
| 3923 | msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 3924 | tests/ssl-opt.sh -f ECDH |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 3925 | |
| 3926 | msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 3927 | # Exclude some symmetric ciphers that are redundant here to gain time. |
Manuel Pégourié-Gonnard | 296787f | 2022-04-06 13:28:27 +0200 | [diff] [blame] | 3928 | tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA' |
Gilles Peskine | 0c6b799 | 2019-04-12 20:29:48 +0200 | [diff] [blame] | 3929 | } |
| 3930 | support_test_m32_everest () { |
| 3931 | support_test_m32_o0 "$@" |
| 3932 | } |
| 3933 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3934 | component_test_mx32 () { |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 3935 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3936 | scripts/config.py full |
Gilles Peskine | 5d26e7c | 2019-06-07 14:50:09 +0200 | [diff] [blame] | 3937 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
Andres Amaya Garcia | f4fbdda | 2017-05-08 11:19:19 +0100 | [diff] [blame] | 3938 | |
| 3939 | msg "test: 64-bit ILP32, make, gcc" |
| 3940 | make test |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3941 | } |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 3942 | support_test_mx32 () { |
| 3943 | case $(uname -m) in |
| 3944 | amd64|x86_64) true;; |
| 3945 | *) false;; |
| 3946 | esac |
| 3947 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 3948 | |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 3949 | component_test_min_mpi_window_size () { |
| 3950 | msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3951 | scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1 |
Peter Kolbus | 60c6da2 | 2018-12-27 06:59:04 -0600 | [diff] [blame] | 3952 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 3953 | make |
| 3954 | |
| 3955 | msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s |
| 3956 | make test |
| 3957 | } |
| 3958 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3959 | component_test_have_int32 () { |
| 3960 | msg "build: gcc, force 32-bit bignum limbs" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3961 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 3962 | scripts/config.py unset MBEDTLS_AESNI_C |
| 3963 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Jerry Yu | e51eddc | 2023-01-11 14:16:08 +0800 | [diff] [blame] | 3964 | scripts/config.py unset MBEDTLS_AESCE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3965 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' |
Andres Amaya Garcia | 84e6ce8 | 2017-05-04 11:35:51 +0100 | [diff] [blame] | 3966 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3967 | msg "test: gcc, force 32-bit bignum limbs" |
| 3968 | make test |
| 3969 | } |
Andres Amaya Garcia | fe843a3 | 2017-07-20 13:21:34 +0100 | [diff] [blame] | 3970 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3971 | component_test_have_int64 () { |
| 3972 | msg "build: gcc, force 64-bit bignum limbs" |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3973 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 3974 | scripts/config.py unset MBEDTLS_AESNI_C |
| 3975 | scripts/config.py unset MBEDTLS_PADLOCK_C |
Jerry Yu | e51eddc | 2023-01-11 14:16:08 +0800 | [diff] [blame] | 3976 | scripts/config.py unset MBEDTLS_AESCE_C |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3977 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' |
Gilles Peskine | 14c3c06 | 2018-01-29 21:25:12 +0100 | [diff] [blame] | 3978 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3979 | msg "test: gcc, force 64-bit bignum limbs" |
| 3980 | make test |
| 3981 | } |
Manuel Pégourié-Gonnard | edb2dc9 | 2015-02-10 14:36:31 +0000 | [diff] [blame] | 3982 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3983 | component_test_no_udbl_division () { |
| 3984 | msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3985 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3986 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3987 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 3988 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3989 | msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s |
| 3990 | make test |
| 3991 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 3992 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3993 | component_test_no_64bit_multiplication () { |
| 3994 | msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3995 | scripts/config.py full |
Gilles Peskine | 3bdd412 | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 3996 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3997 | make CFLAGS='-Werror -O1' |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 3998 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 3999 | msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s |
| 4000 | make test |
| 4001 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 4002 | |
Gilles Peskine | 3809f5f | 2020-11-09 15:40:05 +0100 | [diff] [blame] | 4003 | component_test_no_strings () { |
| 4004 | msg "build: no strings" # ~10s |
| 4005 | scripts/config.py full |
| 4006 | # Disable options that activate a large amount of string constants. |
| 4007 | scripts/config.py unset MBEDTLS_DEBUG_C |
| 4008 | scripts/config.py unset MBEDTLS_ERROR_C |
| 4009 | scripts/config.py set MBEDTLS_ERROR_STRERROR_DUMMY |
| 4010 | scripts/config.py unset MBEDTLS_VERSION_FEATURES |
| 4011 | make CFLAGS='-Werror -Os' |
| 4012 | |
| 4013 | msg "test: no strings" # ~ 10s |
| 4014 | make test |
| 4015 | } |
| 4016 | |
Hanno Becker | c5722d1 | 2020-10-09 11:10:42 +0100 | [diff] [blame] | 4017 | component_test_no_x509_info () { |
| 4018 | msg "build: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s |
| 4019 | scripts/config.pl full |
| 4020 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 4021 | scripts/config.pl set MBEDTLS_X509_REMOVE_INFO |
Gilles Peskine | ff0aee0 | 2021-10-05 09:36:03 +0200 | [diff] [blame] | 4022 | make CFLAGS='-Werror -O2' |
Hanno Becker | c5722d1 | 2020-10-09 11:10:42 +0100 | [diff] [blame] | 4023 | |
| 4024 | msg "test: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s |
| 4025 | make test |
| 4026 | |
| 4027 | msg "test: ssl-opt.sh, full + MBEDTLS_X509_REMOVE_INFO" # ~ 1 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4028 | tests/ssl-opt.sh |
Hanno Becker | c5722d1 | 2020-10-09 11:10:42 +0100 | [diff] [blame] | 4029 | } |
| 4030 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4031 | component_build_arm_none_eabi_gcc () { |
Gilles Peskine | e36fe81 | 2021-09-01 20:00:33 +0200 | [diff] [blame] | 4032 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 4033 | scripts/config.py baremetal |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 4034 | 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 Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 4035 | |
Gilles Peskine | e36fe81 | 2021-09-01 20:00:33 +0200 | [diff] [blame] | 4036 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" |
Manuel Pégourié-Gonnard | a14b8f0 | 2023-03-28 12:49:39 +0200 | [diff] [blame] | 4037 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4038 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 4039 | |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 4040 | component_build_arm_linux_gnueabi_gcc_arm5vte () { |
Gilles Peskine | e36fe81 | 2021-09-01 20:00:33 +0200 | [diff] [blame] | 4041 | msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 4042 | scripts/config.py baremetal |
Gilles Peskine | 2c897d7 | 2019-08-09 16:05:05 +0200 | [diff] [blame] | 4043 | # Build for a target platform that's close to what Debian uses |
| 4044 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
Dave Rodgman | 017a199 | 2022-03-31 14:07:01 +0100 | [diff] [blame] | 4045 | # See https://github.com/Mbed-TLS/mbedtls/pull/2169 and comments. |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 4046 | # Build everything including programs, see for example |
Dave Rodgman | 017a199 | 2022-03-31 14:07:01 +0100 | [diff] [blame] | 4047 | # https://github.com/Mbed-TLS/mbedtls/pull/3449#issuecomment-675313720 |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 4048 | 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' |
| 4049 | |
Gilles Peskine | e36fe81 | 2021-09-01 20:00:33 +0200 | [diff] [blame] | 4050 | msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug" |
Manuel Pégourié-Gonnard | a14b8f0 | 2023-03-28 12:49:39 +0200 | [diff] [blame] | 4051 | ${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t library/*.o |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 4052 | } |
| 4053 | support_build_arm_linux_gnueabi_gcc_arm5vte () { |
| 4054 | type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1 |
| 4055 | } |
| 4056 | |
| 4057 | component_build_arm_none_eabi_gcc_arm5vte () { |
Gilles Peskine | e36fe81 | 2021-09-01 20:00:33 +0200 | [diff] [blame] | 4058 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s |
Manuel Pégourié-Gonnard | 3a6c769 | 2020-08-18 10:28:51 +0200 | [diff] [blame] | 4059 | scripts/config.py baremetal |
| 4060 | # This is an imperfect substitute for |
| 4061 | # component_build_arm_linux_gnueabi_gcc_arm5vte |
Manuel Pégourié-Gonnard | ae505ee | 2021-07-06 09:44:59 +0200 | [diff] [blame] | 4062 | # in case the gcc-arm-linux-gnueabi toolchain is not available |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 4063 | 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 Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 4064 | |
Gilles Peskine | e36fe81 | 2021-09-01 20:00:33 +0200 | [diff] [blame] | 4065 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug" |
Manuel Pégourié-Gonnard | a14b8f0 | 2023-03-28 12:49:39 +0200 | [diff] [blame] | 4066 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
Gilles Peskine | 93e4e03 | 2019-08-05 11:34:25 +0200 | [diff] [blame] | 4067 | } |
| 4068 | |
Gilles Peskine | 6e2fb86 | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 4069 | component_build_arm_none_eabi_gcc_m0plus () { |
Gilles Peskine | e36fe81 | 2021-09-01 20:00:33 +0200 | [diff] [blame] | 4070 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus, baremetal_size" # ~ 10s |
| 4071 | scripts/config.py baremetal_size |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 4072 | 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 Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 4073 | |
Gilles Peskine | e36fe81 | 2021-09-01 20:00:33 +0200 | [diff] [blame] | 4074 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size" |
Manuel Pégourié-Gonnard | a14b8f0 | 2023-03-28 12:49:39 +0200 | [diff] [blame] | 4075 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
Gilles Peskine | 6e2fb86 | 2020-04-30 23:00:53 +0200 | [diff] [blame] | 4076 | } |
| 4077 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4078 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 4079 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 4080 | scripts/config.py baremetal |
| 4081 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 4082 | 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 Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4083 | echo "Checking that software 64-bit division is not required" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4084 | not grep __aeabi_uldiv library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4085 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 4086 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4087 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
Gilles Peskine | 6d06134 | 2020-04-30 18:19:32 +0200 | [diff] [blame] | 4088 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 4089 | scripts/config.py baremetal |
| 4090 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
Gilles Peskine | aeedd74 | 2020-09-02 11:03:04 +0200 | [diff] [blame] | 4091 | 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 Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4092 | echo "Checking that software 64-bit multiplication is not required" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4093 | not grep __aeabi_lmul library/*.o |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4094 | } |
Manuel Pégourié-Gonnard | 2adb375 | 2018-06-07 10:51:44 +0200 | [diff] [blame] | 4095 | |
Dave Rodgman | 8c315f2 | 2023-06-02 10:26:24 -0400 | [diff] [blame] | 4096 | component_build_arm_clang_thumb () { |
| 4097 | # ~ 30s |
| 4098 | |
| 4099 | scripts/config.py baremetal |
| 4100 | |
| 4101 | msg "build: clang thumb 2, make" |
| 4102 | make clean |
| 4103 | make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -march=armv7-m -mthumb' lib |
| 4104 | |
| 4105 | # Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os |
| 4106 | msg "build: clang thumb 1 -O0, make" |
| 4107 | make clean |
| 4108 | make CC="clang" CFLAGS='-std=c99 -Werror -O0 --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib |
| 4109 | |
| 4110 | msg "build: clang thumb 1 -Os, make" |
| 4111 | make clean |
| 4112 | make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib |
| 4113 | } |
| 4114 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4115 | component_build_armcc () { |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 4116 | msg "build: ARM Compiler 5" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 4117 | scripts/config.py baremetal |
Tom Cosgrove | 87fbfb5 | 2022-03-15 10:51:52 +0000 | [diff] [blame] | 4118 | # armc[56] don't support SHA-512 intrinsics |
| 4119 | scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT |
Dave Rodgman | 2f386c5 | 2023-03-02 13:38:33 +0000 | [diff] [blame] | 4120 | |
Dave Rodgman | 0fddf82 | 2023-03-02 15:32:12 +0000 | [diff] [blame] | 4121 | # Stop armclang warning about feature detection for A64_CRYPTO. |
| 4122 | # With this enabled, the library does build correctly under armclang, |
| 4123 | # but in baremetal builds (as tested here), feature detection is |
| 4124 | # unavailable, and the user is notified via a #warning. So enabling |
| 4125 | # this feature would prevent us from building with -Werror on |
| 4126 | # armclang. Tracked in #7198. |
Dave Rodgman | 2f386c5 | 2023-03-02 13:38:33 +0000 | [diff] [blame] | 4127 | scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT |
| 4128 | |
Hanno Becker | f0762e9 | 2022-07-15 12:08:19 +0100 | [diff] [blame] | 4129 | scripts/config.py set MBEDTLS_HAVE_ASM |
Tom Cosgrove | 87fbfb5 | 2022-03-15 10:51:52 +0000 | [diff] [blame] | 4130 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 4131 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
Gilles Peskine | 18487f6 | 2020-04-30 23:11:54 +0200 | [diff] [blame] | 4132 | |
| 4133 | msg "size: ARM Compiler 5" |
| 4134 | "$ARMC5_FROMELF" -z library/*.o |
| 4135 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 4136 | make clean |
Andres AG | 87bb577 | 2016-09-27 15:05:15 +0100 | [diff] [blame] | 4137 | |
Dave Rodgman | b45d58b | 2023-06-02 13:54:00 -0400 | [diff] [blame] | 4138 | # Compile mostly with -O1 since some Arm inline assembly is disabled for -O0. |
Hanno Becker | f0762e9 | 2022-07-15 12:08:19 +0100 | [diff] [blame] | 4139 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 4140 | # ARM Compiler 6 - Target ARMv7-A |
Dave Rodgman | 03f7a6e | 2022-08-17 14:35:29 +0100 | [diff] [blame] | 4141 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 4142 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 4143 | # ARM Compiler 6 - Target ARMv7-M |
Dave Rodgman | 03f7a6e | 2022-08-17 14:35:29 +0100 | [diff] [blame] | 4144 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m" |
| 4145 | |
| 4146 | # ARM Compiler 6 - Target ARMv7-M+DSP |
| 4147 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m+dsp" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 4148 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 4149 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
Dave Rodgman | 03f7a6e | 2022-08-17 14:35:29 +0100 | [diff] [blame] | 4150 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8.2-a" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 4151 | |
Gilles Peskine | bca6ab9 | 2017-12-19 18:24:31 +0100 | [diff] [blame] | 4152 | # ARM Compiler 6 - Target ARMv8-M |
Dave Rodgman | 03f7a6e | 2022-08-17 14:35:29 +0100 | [diff] [blame] | 4153 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8-m.main" |
Simon Butcher | 940737f | 2017-07-23 13:42:36 +0200 | [diff] [blame] | 4154 | |
Tom Cosgrove | 6ec39ca | 2023-06-09 15:34:31 +0100 | [diff] [blame] | 4155 | # ARM Compiler 6 - Target ARMv8.2-A - AArch64 |
| 4156 | armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8.2-a+crypto" |
| 4157 | |
Dave Rodgman | b45d58b | 2023-06-02 13:54:00 -0400 | [diff] [blame] | 4158 | # ARM Compiler 6 - Target Cortex-M0 - no optimisation |
| 4159 | armc6_build_test "-O0 --target=arm-arm-none-eabi -mcpu=cortex-m0" |
| 4160 | |
Dave Rodgman | 99318e6 | 2023-05-24 12:27:42 +0100 | [diff] [blame] | 4161 | # ARM Compiler 6 - Target Cortex-M0 |
| 4162 | armc6_build_test "-Os --target=arm-arm-none-eabi -mcpu=cortex-m0" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4163 | } |
Tom Cosgrove | 6ec39ca | 2023-06-09 15:34:31 +0100 | [diff] [blame] | 4164 | |
Pengyu Lv | df07003 | 2023-02-24 16:03:31 +0800 | [diff] [blame] | 4165 | support_build_armcc () { |
Pengyu Lv | c6298ad | 2023-03-01 10:31:29 +0800 | [diff] [blame] | 4166 | armc5_cc="$ARMC5_BIN_DIR/armcc" |
| 4167 | armc6_cc="$ARMC6_BIN_DIR/armclang" |
| 4168 | (check_tools "$armc5_cc" "$armc6_cc" > /dev/null 2>&1) |
Pengyu Lv | df07003 | 2023-02-24 16:03:31 +0800 | [diff] [blame] | 4169 | } |
Manuel Pégourié-Gonnard | c5c5939 | 2015-02-10 17:38:54 +0100 | [diff] [blame] | 4170 | |
Jerry Yu | 81d5e1f | 2022-01-27 13:01:01 +0800 | [diff] [blame] | 4171 | component_test_tls13_only () { |
| 4172 | msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3, without MBEDTLS_SSL_PROTO_TLS1_2" |
Ronald Cron | c2e110f | 2022-11-22 09:01:46 +0100 | [diff] [blame] | 4173 | scripts/config.py set MBEDTLS_SSL_EARLY_DATA |
Jerry Yu | da5af22 | 2021-12-24 18:45:45 +0800 | [diff] [blame] | 4174 | make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'" |
| 4175 | |
Gilles Peskine | 4bb369c | 2022-10-29 17:44:19 +0200 | [diff] [blame] | 4176 | msg "test: TLS 1.3 only, all key exchange modes enabled" |
| 4177 | make test |
Jerry Yu | baa4934 | 2022-02-15 10:26:40 +0800 | [diff] [blame] | 4178 | |
Ronald Cron | c3f43b6 | 2022-10-17 17:35:32 +0200 | [diff] [blame] | 4179 | msg "ssl-opt.sh: TLS 1.3 only, all key exchange modes enabled" |
| 4180 | tests/ssl-opt.sh |
Jerry Yu | da5af22 | 2021-12-24 18:45:45 +0800 | [diff] [blame] | 4181 | } |
| 4182 | |
Ronald Cron | c3f43b6 | 2022-10-17 17:35:32 +0200 | [diff] [blame] | 4183 | component_test_tls13_only_psk () { |
| 4184 | msg "build: TLS 1.3 only from default, only PSK key exchange mode" |
| 4185 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED |
| 4186 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED |
| 4187 | scripts/config.py unset MBEDTLS_ECDH_C |
| 4188 | scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C |
| 4189 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
| 4190 | scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION |
| 4191 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 4192 | scripts/config.py unset MBEDTLS_PKCS1_V21 |
Dave Rodgman | 71565cf | 2022-11-11 10:37:38 +0000 | [diff] [blame] | 4193 | scripts/config.py unset MBEDTLS_PKCS7_C |
Ronald Cron | c2e110f | 2022-11-22 09:01:46 +0100 | [diff] [blame] | 4194 | scripts/config.py set MBEDTLS_SSL_EARLY_DATA |
Ronald Cron | e3dac4a | 2022-06-10 17:21:51 +0200 | [diff] [blame] | 4195 | make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'" |
| 4196 | |
Ronald Cron | c3f43b6 | 2022-10-17 17:35:32 +0200 | [diff] [blame] | 4197 | msg "test_suite_ssl: TLS 1.3 only, only PSK key exchange mode enabled" |
| 4198 | cd tests; ./test_suite_ssl; cd .. |
Ronald Cron | e3dac4a | 2022-06-10 17:21:51 +0200 | [diff] [blame] | 4199 | |
Ronald Cron | c3f43b6 | 2022-10-17 17:35:32 +0200 | [diff] [blame] | 4200 | msg "ssl-opt.sh: TLS 1.3 only, only PSK key exchange mode enabled" |
| 4201 | tests/ssl-opt.sh |
| 4202 | } |
| 4203 | |
| 4204 | component_test_tls13_only_ephemeral () { |
| 4205 | msg "build: TLS 1.3 only from default, only ephemeral key exchange mode" |
| 4206 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED |
| 4207 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED |
Xiaokang Qian | 2dbfeda | 2022-11-15 10:52:57 +0000 | [diff] [blame] | 4208 | scripts/config.py unset MBEDTLS_SSL_EARLY_DATA |
Ronald Cron | c3f43b6 | 2022-10-17 17:35:32 +0200 | [diff] [blame] | 4209 | make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'" |
| 4210 | |
| 4211 | msg "test_suite_ssl: TLS 1.3 only, only ephemeral key exchange mode" |
| 4212 | cd tests; ./test_suite_ssl; cd .. |
| 4213 | |
| 4214 | msg "ssl-opt.sh: TLS 1.3 only, only ephemeral key exchange mode" |
| 4215 | tests/ssl-opt.sh |
| 4216 | } |
| 4217 | |
| 4218 | component_test_tls13_only_psk_ephemeral () { |
| 4219 | msg "build: TLS 1.3 only from default, only PSK ephemeral key exchange mode" |
| 4220 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED |
| 4221 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED |
| 4222 | scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C |
| 4223 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
| 4224 | scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION |
| 4225 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 4226 | scripts/config.py unset MBEDTLS_PKCS1_V21 |
Dave Rodgman | 71565cf | 2022-11-11 10:37:38 +0000 | [diff] [blame] | 4227 | scripts/config.py unset MBEDTLS_PKCS7_C |
Ronald Cron | c2e110f | 2022-11-22 09:01:46 +0100 | [diff] [blame] | 4228 | scripts/config.py set MBEDTLS_SSL_EARLY_DATA |
Ronald Cron | c3f43b6 | 2022-10-17 17:35:32 +0200 | [diff] [blame] | 4229 | make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'" |
| 4230 | |
| 4231 | msg "test_suite_ssl: TLS 1.3 only, only PSK ephemeral key exchange mode" |
| 4232 | cd tests; ./test_suite_ssl; cd .. |
| 4233 | |
| 4234 | msg "ssl-opt.sh: TLS 1.3 only, only PSK ephemeral key exchange mode" |
| 4235 | tests/ssl-opt.sh |
| 4236 | } |
| 4237 | |
| 4238 | component_test_tls13_only_psk_all () { |
| 4239 | msg "build: TLS 1.3 only from default, without ephemeral key exchange mode" |
| 4240 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED |
| 4241 | scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C |
| 4242 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
| 4243 | scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION |
| 4244 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 4245 | scripts/config.py unset MBEDTLS_PKCS1_V21 |
Dave Rodgman | 71565cf | 2022-11-11 10:37:38 +0000 | [diff] [blame] | 4246 | scripts/config.py unset MBEDTLS_PKCS7_C |
Ronald Cron | c2e110f | 2022-11-22 09:01:46 +0100 | [diff] [blame] | 4247 | scripts/config.py set MBEDTLS_SSL_EARLY_DATA |
Ronald Cron | c3f43b6 | 2022-10-17 17:35:32 +0200 | [diff] [blame] | 4248 | make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'" |
| 4249 | |
| 4250 | msg "test_suite_ssl: TLS 1.3 only, PSK and PSK ephemeral key exchange modes" |
| 4251 | cd tests; ./test_suite_ssl; cd .. |
| 4252 | |
| 4253 | msg "ssl-opt.sh: TLS 1.3 only, PSK and PSK ephemeral key exchange modes" |
| 4254 | tests/ssl-opt.sh |
| 4255 | } |
| 4256 | |
| 4257 | component_test_tls13_only_ephemeral_all () { |
| 4258 | msg "build: TLS 1.3 only from default, without PSK key exchange mode" |
| 4259 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED |
Ronald Cron | c2e110f | 2022-11-22 09:01:46 +0100 | [diff] [blame] | 4260 | scripts/config.py set MBEDTLS_SSL_EARLY_DATA |
Ronald Cron | c3f43b6 | 2022-10-17 17:35:32 +0200 | [diff] [blame] | 4261 | make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'" |
| 4262 | |
| 4263 | msg "test_suite_ssl: TLS 1.3 only, ephemeral and PSK ephemeral key exchange modes" |
| 4264 | cd tests; ./test_suite_ssl; cd .. |
| 4265 | |
| 4266 | msg "ssl-opt.sh: TLS 1.3 only, ephemeral and PSK ephemeral key exchange modes" |
| 4267 | tests/ssl-opt.sh |
Ronald Cron | e3dac4a | 2022-06-10 17:21:51 +0200 | [diff] [blame] | 4268 | } |
| 4269 | |
Ronald Cron | 6f135e1 | 2021-12-08 16:57:54 +0100 | [diff] [blame] | 4270 | component_test_tls13 () { |
| 4271 | msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3 enabled, without padding" |
| 4272 | scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3 |
Ronald Cron | fdb0e3f | 2021-12-09 10:39:19 +0100 | [diff] [blame] | 4273 | scripts/config.py set MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE |
| 4274 | scripts/config.py set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 1 |
Ronald Cron | c2e110f | 2022-11-22 09:01:46 +0100 | [diff] [blame] | 4275 | scripts/config.py set MBEDTLS_SSL_EARLY_DATA |
Ronald Cron | fdb0e3f | 2021-12-09 10:39:19 +0100 | [diff] [blame] | 4276 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 4277 | make |
Ronald Cron | 6f135e1 | 2021-12-08 16:57:54 +0100 | [diff] [blame] | 4278 | msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3 enabled, without padding" |
Ronald Cron | fdb0e3f | 2021-12-09 10:39:19 +0100 | [diff] [blame] | 4279 | make test |
Ronald Cron | 6f135e1 | 2021-12-08 16:57:54 +0100 | [diff] [blame] | 4280 | msg "ssl-opt.sh (TLS 1.3)" |
Gilles Peskine | 827dbd9 | 2022-02-04 00:30:54 +0100 | [diff] [blame] | 4281 | tests/ssl-opt.sh |
Ronald Cron | fdb0e3f | 2021-12-09 10:39:19 +0100 | [diff] [blame] | 4282 | } |
| 4283 | |
Ronald Cron | 6f135e1 | 2021-12-08 16:57:54 +0100 | [diff] [blame] | 4284 | component_test_tls13_no_compatibility_mode () { |
| 4285 | msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3 enabled, without padding" |
| 4286 | scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3 |
Ronald Cron | fdb0e3f | 2021-12-09 10:39:19 +0100 | [diff] [blame] | 4287 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE |
| 4288 | scripts/config.py set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 1 |
Ronald Cron | c2e110f | 2022-11-22 09:01:46 +0100 | [diff] [blame] | 4289 | scripts/config.py set MBEDTLS_SSL_EARLY_DATA |
Hanno Becker | a711f6e | 2020-05-04 12:03:51 +0100 | [diff] [blame] | 4290 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 4291 | make |
Ronald Cron | 6f135e1 | 2021-12-08 16:57:54 +0100 | [diff] [blame] | 4292 | msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3 enabled, without padding" |
Hanno Becker | 6c53ecc | 2021-08-01 19:20:10 +0100 | [diff] [blame] | 4293 | make test |
Ronald Cron | 6f135e1 | 2021-12-08 16:57:54 +0100 | [diff] [blame] | 4294 | msg "ssl-opt.sh (TLS 1.3 no compatibility mode)" |
Gilles Peskine | 827dbd9 | 2022-02-04 00:30:54 +0100 | [diff] [blame] | 4295 | tests/ssl-opt.sh |
Hanno Becker | 6c53ecc | 2021-08-01 19:20:10 +0100 | [diff] [blame] | 4296 | } |
| 4297 | |
Jan Bruckner | 151f642 | 2023-02-10 12:45:19 +0100 | [diff] [blame] | 4298 | component_test_tls13_only_record_size_limit () { |
| 4299 | msg "build: TLS 1.3 only from default, record size limit extension enabled" |
| 4300 | scripts/config.py set MBEDTLS_SSL_RECORD_SIZE_LIMIT |
| 4301 | make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'" |
| 4302 | |
| 4303 | msg "test_suite_ssl: TLS 1.3 only, record size limit extension enabled" |
| 4304 | cd tests; ./test_suite_ssl; cd .. |
| 4305 | |
| 4306 | msg "ssl-opt.sh: (TLS 1.3 only, record size limit extension tests only)" |
| 4307 | # Both the server and the client will currently abort the handshake when they encounter the |
| 4308 | # record size limit extension. There is no way to prevent gnutls-cli from sending the extension |
| 4309 | # which makes all G_NEXT_CLI + P_SRV tests fail. Thus, run only the tests for the this extension. |
| 4310 | tests/ssl-opt.sh -f "Record Size Limit" |
| 4311 | } |
| 4312 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4313 | component_build_mingw () { |
| 4314 | msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 4315 | 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 Becker | e963efa | 2018-01-03 10:03:43 +0000 | [diff] [blame] | 4316 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4317 | # note Make tests only builds the tests, but doesn't run them |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 4318 | make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4319 | make WINDOWS_BUILD=1 clean |
Gilles Peskine | 2a458da | 2017-05-12 15:26:58 +0200 | [diff] [blame] | 4320 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4321 | msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s |
Andrzej Kurek | 232e8f9 | 2019-10-03 03:18:01 -0400 | [diff] [blame] | 4322 | 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 |
| 4323 | 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 Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4324 | make WINDOWS_BUILD=1 clean |
| 4325 | } |
Jaeden Amero | 117b8a4 | 2019-04-17 15:19:26 +0100 | [diff] [blame] | 4326 | support_build_mingw() { |
Pengyu Lv | 51b5f00 | 2023-02-24 15:38:52 +0800 | [diff] [blame] | 4327 | case $(i686-w64-mingw32-gcc -dumpversion 2>/dev/null) in |
| 4328 | [0-5]*|"") false;; |
Jaeden Amero | 117b8a4 | 2019-04-17 15:19:26 +0100 | [diff] [blame] | 4329 | *) true;; |
| 4330 | esac |
| 4331 | } |
Simon Butcher | 91aef33 | 2016-11-17 09:20:50 +0000 | [diff] [blame] | 4332 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4333 | component_test_memsan () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4334 | msg "build: MSan (clang)" # ~ 1 min 20s |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 4335 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4336 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 4337 | make |
Manuel Pégourié-Gonnard | 4a9dc2a | 2014-05-09 13:46:59 +0200 | [diff] [blame] | 4338 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4339 | msg "test: main suites (MSan)" # ~ 10s |
| 4340 | make test |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 4341 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4342 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4343 | tests/ssl-opt.sh |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 4344 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4345 | # Optional part(s) |
Manuel Pégourié-Gonnard | 9bda9b3 | 2014-11-20 13:10:22 +0100 | [diff] [blame] | 4346 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4347 | if [ "$MEMORY" -gt 0 ]; then |
| 4348 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4349 | tests/compat.sh |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4350 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4351 | } |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 4352 | |
Gilles Peskine | 69f190e | 2019-01-10 00:11:42 +0100 | [diff] [blame] | 4353 | component_test_valgrind () { |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4354 | msg "build: Release (clang)" |
Gilles Peskine | df3dd4c | 2022-11-29 16:45:30 +0100 | [diff] [blame] | 4355 | # default config, in particular without MBEDTLS_USE_PSA_CRYPTO |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4356 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 4357 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 4358 | |
Gilles Peskine | df3dd4c | 2022-11-29 16:45:30 +0100 | [diff] [blame] | 4359 | msg "test: main suites, Valgrind (default config)" |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4360 | make memcheck |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 4361 | |
Gilles Peskine | 636c26a | 2020-03-04 20:46:15 +0100 | [diff] [blame] | 4362 | # Optional parts (slow; currently broken on OS X because programs don't |
| 4363 | # seem to receive signals under valgrind on OS X). |
Gilles Peskine | df3dd4c | 2022-11-29 16:45:30 +0100 | [diff] [blame] | 4364 | # These optional parts don't run on the CI. |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4365 | if [ "$MEMORY" -gt 0 ]; then |
Gilles Peskine | df3dd4c | 2022-11-29 16:45:30 +0100 | [diff] [blame] | 4366 | msg "test: ssl-opt.sh --memcheck (default config)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4367 | tests/ssl-opt.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4368 | fi |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 4369 | |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4370 | if [ "$MEMORY" -gt 1 ]; then |
Gilles Peskine | df3dd4c | 2022-11-29 16:45:30 +0100 | [diff] [blame] | 4371 | msg "test: compat.sh --memcheck (default config)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4372 | tests/compat.sh --memcheck |
Gilles Peskine | 7ad603e | 2017-12-10 23:22:20 +0100 | [diff] [blame] | 4373 | fi |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 4374 | |
| 4375 | if [ "$MEMORY" -gt 0 ]; then |
Gilles Peskine | df3dd4c | 2022-11-29 16:45:30 +0100 | [diff] [blame] | 4376 | msg "test: context-info.sh --memcheck (default config)" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4377 | tests/context-info.sh --memcheck |
Piotr Nowicki | 9978e6e | 2020-04-07 16:07:05 +0200 | [diff] [blame] | 4378 | fi |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4379 | } |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 4380 | |
Gilles Peskine | df3dd4c | 2022-11-29 16:45:30 +0100 | [diff] [blame] | 4381 | component_test_valgrind_psa () { |
| 4382 | msg "build: Release, full (clang)" |
| 4383 | # full config, in particular with MBEDTLS_USE_PSA_CRYPTO |
| 4384 | scripts/config.py full |
| 4385 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 4386 | make |
| 4387 | |
| 4388 | msg "test: main suites, Valgrind (full config)" |
| 4389 | make memcheck |
| 4390 | } |
| 4391 | |
Paul Elliott | 62dc392 | 2021-11-25 17:29:40 +0000 | [diff] [blame] | 4392 | support_test_cmake_out_of_source () { |
| 4393 | distrib_id="" |
| 4394 | distrib_ver="" |
| 4395 | distrib_ver_minor="" |
| 4396 | distrib_ver_major="" |
| 4397 | |
| 4398 | # Attempt to parse lsb-release to find out distribution and version. If not |
| 4399 | # found this should fail safe (test is supported). |
| 4400 | if [[ -f /etc/lsb-release ]]; then |
| 4401 | |
| 4402 | while read -r lsb_line; do |
| 4403 | case "$lsb_line" in |
| 4404 | "DISTRIB_ID"*) distrib_id=${lsb_line/#DISTRIB_ID=};; |
| 4405 | "DISTRIB_RELEASE"*) distrib_ver=${lsb_line/#DISTRIB_RELEASE=};; |
| 4406 | esac |
| 4407 | done < /etc/lsb-release |
| 4408 | |
| 4409 | distrib_ver_major="${distrib_ver%%.*}" |
| 4410 | distrib_ver="${distrib_ver#*.}" |
| 4411 | distrib_ver_minor="${distrib_ver%%.*}" |
| 4412 | fi |
| 4413 | |
| 4414 | # Running the out of source CMake test on Ubuntu 16.04 using more than one |
| 4415 | # processor (as the CI does) can create a race condition whereby the build |
| 4416 | # fails to see a generated file, despite that file actually having been |
| 4417 | # generated. This problem appears to go away with 18.04 or newer, so make |
| 4418 | # the out of source tests unsupported on Ubuntu 16.04. |
| 4419 | [ "$distrib_id" != "Ubuntu" ] || [ "$distrib_ver_major" -gt 16 ] |
| 4420 | } |
| 4421 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4422 | component_test_cmake_out_of_source () { |
| 4423 | msg "build: cmake 'out-of-source' build" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4424 | MBEDTLS_ROOT_DIR="$PWD" |
| 4425 | mkdir "$OUT_OF_SOURCE_DIR" |
| 4426 | cd "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | dbf7b7e | 2021-10-07 19:34:57 +0200 | [diff] [blame] | 4427 | cmake -D CMAKE_BUILD_TYPE:String=Check "$MBEDTLS_ROOT_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4428 | make |
Manuel Pégourié-Gonnard | 392d3dd | 2015-01-26 14:03:56 +0000 | [diff] [blame] | 4429 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4430 | msg "test: cmake 'out-of-source' build" |
| 4431 | make test |
Gilles Peskine | a841c2a | 2022-04-16 11:31:25 +0200 | [diff] [blame] | 4432 | # Check that ssl-opt.sh can find the test programs. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4433 | # Also ensure that there are no error messages such as |
| 4434 | # "No such file or directory", which would indicate that some required |
| 4435 | # file is missing (ssl-opt.sh tolerates the absence of some files so |
| 4436 | # may exit with status 0 but emit errors). |
Gilles Peskine | a841c2a | 2022-04-16 11:31:25 +0200 | [diff] [blame] | 4437 | ./tests/ssl-opt.sh -f 'Default' >ssl-opt.out 2>ssl-opt.err |
Gilles Peskine | 7393ec5 | 2022-04-15 22:43:38 +0200 | [diff] [blame] | 4438 | grep PASS ssl-opt.out |
Gilles Peskine | f7e956c | 2020-03-28 18:56:09 +0100 | [diff] [blame] | 4439 | cat ssl-opt.err >&2 |
| 4440 | # If ssl-opt.err is non-empty, record an error and keep going. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4441 | [ ! -s ssl-opt.err ] |
Gilles Peskine | 7393ec5 | 2022-04-15 22:43:38 +0200 | [diff] [blame] | 4442 | rm ssl-opt.out ssl-opt.err |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4443 | cd "$MBEDTLS_ROOT_DIR" |
| 4444 | rm -rf "$OUT_OF_SOURCE_DIR" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4445 | } |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 4446 | |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 4447 | component_test_cmake_as_subdirectory () { |
| 4448 | msg "build: cmake 'as-subdirectory' build" |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 4449 | cd programs/test/cmake_subproject |
| 4450 | cmake . |
| 4451 | make |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4452 | ./cmake_subproject |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 4453 | } |
Gilles Peskine | a300099 | 2022-02-04 00:21:12 +0100 | [diff] [blame] | 4454 | support_test_cmake_as_subdirectory () { |
| 4455 | support_test_cmake_out_of_source |
Jaeden Amero | ab83fdf | 2019-06-20 17:38:22 +0100 | [diff] [blame] | 4456 | } |
| 4457 | |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 4458 | component_test_cmake_as_package () { |
| 4459 | msg "build: cmake 'as-package' build" |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 4460 | cd programs/test/cmake_package |
| 4461 | cmake . |
| 4462 | make |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4463 | ./cmake_package |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 4464 | } |
Gilles Peskine | a300099 | 2022-02-04 00:21:12 +0100 | [diff] [blame] | 4465 | support_test_cmake_as_package () { |
| 4466 | support_test_cmake_out_of_source |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 4467 | } |
| 4468 | |
| 4469 | component_test_cmake_as_package_install () { |
| 4470 | msg "build: cmake 'as-installed-package' build" |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 4471 | cd programs/test/cmake_package_install |
| 4472 | cmake . |
| 4473 | make |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4474 | ./cmake_package_install |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 4475 | } |
Gilles Peskine | a300099 | 2022-02-04 00:21:12 +0100 | [diff] [blame] | 4476 | support_test_cmake_as_package_install () { |
| 4477 | support_test_cmake_out_of_source |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 4478 | } |
| 4479 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4480 | component_test_zeroize () { |
| 4481 | # Test that the function mbedtls_platform_zeroize() is not optimized away by |
| 4482 | # different combinations of compilers and optimization flags by using an |
| 4483 | # auxiliary GDB script. Unfortunately, GDB does not return error values to the |
| 4484 | # system in all cases that the script fails, so we must manually search the |
| 4485 | # output to check whether the pass string is present and no failure strings |
| 4486 | # were printed. |
Andres AG | dc19221 | 2016-08-31 17:33:13 +0100 | [diff] [blame] | 4487 | |
Gilles Peskine | 4976e82 | 2019-01-06 19:52:22 +0000 | [diff] [blame] | 4488 | # Don't try to disable ASLR. We don't care about ASLR here. We do care |
| 4489 | # about a spurious message if Gdb tries and fails, so suppress that. |
| 4490 | gdb_disable_aslr= |
| 4491 | if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then |
| 4492 | gdb_disable_aslr='set disable-randomization off' |
| 4493 | fi |
| 4494 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4495 | for optimization_flag in -O2 -O3 -Ofast -Os; do |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 4496 | for compiler in clang gcc; do |
| 4497 | msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" |
| 4498 | make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4499 | gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log |
| 4500 | grep "The buffer was correctly zeroized" test_zeroize.log |
| 4501 | not grep -i "error" test_zeroize.log |
Gilles Peskine | 55f7c94 | 2019-01-09 22:28:21 +0100 | [diff] [blame] | 4502 | rm -f test_zeroize.log |
| 4503 | make clean |
| 4504 | done |
Andres Amaya Garcia | 2967381 | 2017-10-25 10:35:51 +0100 | [diff] [blame] | 4505 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4506 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 4507 | |
Bence Szépkúti | 80b31c5 | 2021-10-19 15:05:36 +0200 | [diff] [blame] | 4508 | component_test_psa_compliance () { |
| 4509 | msg "build: make, default config (out-of-box), libmbedcrypto.a only" |
Bence Szépkúti | ca9236b | 2021-10-25 19:29:07 +0200 | [diff] [blame] | 4510 | make -C library libmbedcrypto.a |
Bence Szépkúti | 80b31c5 | 2021-10-19 15:05:36 +0200 | [diff] [blame] | 4511 | |
| 4512 | msg "unit test: test_psa_compliance.py" |
| 4513 | ./tests/scripts/test_psa_compliance.py |
| 4514 | } |
| 4515 | |
| 4516 | support_test_psa_compliance () { |
Bence Szépkúti | ef0d02e | 2021-11-03 11:36:09 +0100 | [diff] [blame] | 4517 | # psa-compliance-tests only supports CMake >= 3.10.0 |
Bence Szépkúti | ca9236b | 2021-10-25 19:29:07 +0200 | [diff] [blame] | 4518 | ver="$(cmake --version)" |
| 4519 | ver="${ver#cmake version }" |
| 4520 | ver_major="${ver%%.*}" |
| 4521 | |
| 4522 | ver="${ver#*.}" |
| 4523 | ver_minor="${ver%%.*}" |
| 4524 | |
| 4525 | [ "$ver_major" -eq 3 ] && [ "$ver_minor" -ge 10 ] |
Bence Szépkúti | 80b31c5 | 2021-10-19 15:05:36 +0200 | [diff] [blame] | 4526 | } |
| 4527 | |
Gilles Peskine | c848d22 | 2022-12-09 12:23:35 +0100 | [diff] [blame] | 4528 | component_check_code_style () { |
| 4529 | msg "Check C code style" |
| 4530 | ./scripts/code_style.py |
David Horstmann | 92b5ac1 | 2022-11-10 18:30:52 +0000 | [diff] [blame] | 4531 | } |
| 4532 | |
Gilles Peskine | c848d22 | 2022-12-09 12:23:35 +0100 | [diff] [blame] | 4533 | support_check_code_style() { |
David Horstmann | 92b5ac1 | 2022-11-10 18:30:52 +0000 | [diff] [blame] | 4534 | case $(uncrustify --version) in |
| 4535 | *0.75.1*) true;; |
| 4536 | *) false;; |
| 4537 | esac |
| 4538 | } |
| 4539 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4540 | component_check_python_files () { |
| 4541 | msg "Lint: Python scripts" |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4542 | tests/scripts/check-python-files.sh |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4543 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 4544 | |
Joe Subbiani | d614c0b | 2021-07-29 11:18:29 +0100 | [diff] [blame] | 4545 | component_check_test_helpers () { |
| 4546 | msg "unit test: generate_test_code.py" |
Manuel Pégourié-Gonnard | dfb114a | 2020-06-02 11:40:08 +0200 | [diff] [blame] | 4547 | # unittest writes out mundane stuff like number or tests run on stderr. |
| 4548 | # Our convention is to reserve stderr for actual errors, and write |
| 4549 | # harmless info on stdout so it can be suppress with --quiet. |
Gilles Peskine | 1f0cdaf | 2021-07-08 18:41:16 +0200 | [diff] [blame] | 4550 | ./tests/scripts/test_generate_test_code.py 2>&1 |
Joe Subbiani | d614c0b | 2021-07-29 11:18:29 +0100 | [diff] [blame] | 4551 | |
Joe Subbiani | a25ffab | 2021-08-06 09:41:27 +0100 | [diff] [blame] | 4552 | msg "unit test: translate_ciphers.py" |
| 4553 | python3 -m unittest tests/scripts/translate_ciphers.py 2>&1 |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4554 | } |
Gilles Peskine | 192c72f | 2017-12-21 15:59:21 +0100 | [diff] [blame] | 4555 | |
| 4556 | ################################################################ |
| 4557 | #### Termination |
| 4558 | ################################################################ |
| 4559 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4560 | post_report () { |
| 4561 | msg "Done, cleaning up" |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 4562 | final_cleanup |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 4563 | |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4564 | final_report |
| 4565 | } |
| 4566 | |
| 4567 | |
| 4568 | |
| 4569 | ################################################################ |
| 4570 | #### Run all the things |
| 4571 | ################################################################ |
| 4572 | |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 4573 | # Function invoked by --error-test to test error reporting. |
| 4574 | pseudo_component_error_test () { |
Gilles Peskine | 88a7c2b | 2021-08-02 23:28:00 +0200 | [diff] [blame] | 4575 | msg "Testing error reporting $error_test_i" |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 4576 | if [ $KEEP_GOING -ne 0 ]; then |
| 4577 | echo "Expect three failing commands." |
| 4578 | fi |
Gilles Peskine | 88a7c2b | 2021-08-02 23:28:00 +0200 | [diff] [blame] | 4579 | # If the component doesn't run in a subshell, changing error_test_i to an |
| 4580 | # invalid integer will cause an error in the loop that runs this function. |
| 4581 | error_test_i=this_should_not_be_used_since_the_component_runs_in_a_subshell |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 4582 | # Expected error: 'grep non_existent /dev/null -> 1' |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 4583 | grep non_existent /dev/null |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 4584 | # Expected error: '! grep -q . tests/scripts/all.sh -> 1' |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 4585 | not grep -q . "$0" |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 4586 | # Expected error: 'make unknown_target -> 2' |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 4587 | make unknown_target |
| 4588 | false "this should not be executed" |
| 4589 | } |
| 4590 | |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 4591 | # Run one component and clean up afterwards. |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4592 | run_component () { |
Gilles Peskine | ffcdeff | 2018-12-04 12:49:28 +0100 | [diff] [blame] | 4593 | current_component="$1" |
Gilles Peskine | 9004a17 | 2019-09-16 15:20:36 +0200 | [diff] [blame] | 4594 | export MBEDTLS_TEST_CONFIGURATION="$current_component" |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 4595 | |
| 4596 | # Unconditionally create a seedfile that's sufficiently long. |
| 4597 | # Do this before each component, because a previous component may |
| 4598 | # have messed it up or shortened it. |
Gilles Peskine | 88a0745 | 2021-07-08 19:03:50 +0200 | [diff] [blame] | 4599 | local dd_cmd |
| 4600 | dd_cmd=(dd if=/dev/urandom of=./tests/seedfile bs=64 count=1) |
| 4601 | case $OSTYPE in |
Tom Cosgrove | 226aca1 | 2022-03-16 14:11:07 +0000 | [diff] [blame] | 4602 | linux*|freebsd*|openbsd*) dd_cmd+=(status=none) |
Gilles Peskine | 88a0745 | 2021-07-08 19:03:50 +0200 | [diff] [blame] | 4603 | esac |
| 4604 | "${dd_cmd[@]}" |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 4605 | |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 4606 | # Run the component in a subshell, with error trapping and output |
| 4607 | # redirection set up based on the relevant options. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 4608 | if [ $KEEP_GOING -eq 1 ]; then |
Gilles Peskine | ec13554 | 2021-08-02 23:14:03 +0200 | [diff] [blame] | 4609 | # We want to keep running if the subshell fails, so 'set -e' must |
| 4610 | # be off when the subshell runs. |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 4611 | set +e |
Manuel Pégourié-Gonnard | 2b2bdaa | 2020-06-02 11:28:07 +0200 | [diff] [blame] | 4612 | fi |
Gilles Peskine | ce266c4 | 2020-03-28 18:50:43 +0100 | [diff] [blame] | 4613 | ( |
| 4614 | if [ $QUIET -eq 1 ]; then |
| 4615 | # msg() will be silenced, so just print the component name here. |
| 4616 | echo "${current_component#component_}" |
| 4617 | exec >/dev/null |
| 4618 | fi |
| 4619 | if [ $KEEP_GOING -eq 1 ]; then |
| 4620 | # Keep "set -e" off, and run an ERR trap instead to record failures. |
| 4621 | set -E |
| 4622 | trap err_trap ERR |
| 4623 | fi |
| 4624 | # The next line is what runs the component |
| 4625 | "$@" |
| 4626 | if [ $KEEP_GOING -eq 1 ]; then |
| 4627 | trap - ERR |
| 4628 | exit $last_failure_status |
| 4629 | fi |
| 4630 | ) |
| 4631 | component_status=$? |
| 4632 | if [ $KEEP_GOING -eq 1 ]; then |
| 4633 | set -e |
| 4634 | if [ $component_status -ne 0 ]; then |
| 4635 | failure_count=$((failure_count + 1)) |
| 4636 | fi |
| 4637 | fi |
Gilles Peskine | 2ef377d | 2019-10-07 18:44:21 +0200 | [diff] [blame] | 4638 | |
| 4639 | # Restore the build tree to a clean state. |
Gilles Peskine | e48351a | 2018-11-27 16:06:30 +0100 | [diff] [blame] | 4640 | cleanup |
Manuel Pégourié-Gonnard | 304b099 | 2020-06-08 10:59:41 +0200 | [diff] [blame] | 4641 | unset current_component |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4642 | } |
| 4643 | |
| 4644 | # Preliminary setup |
| 4645 | pre_check_environment |
Tom Cosgrove | 730addc | 2023-06-09 14:20:18 +0100 | [diff] [blame] | 4646 | pre_parse_command_line_for_dirs "$@" |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4647 | pre_initialize_variables |
| 4648 | pre_parse_command_line "$@" |
Gilles Peskine | 348fb9a | 2018-11-27 17:04:29 +0100 | [diff] [blame] | 4649 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 4650 | pre_check_git |
Gilles Peskine | 568f53a | 2021-07-12 18:16:01 +0200 | [diff] [blame] | 4651 | pre_restore_files |
Gilles Peskine | f83eb82 | 2020-03-30 20:11:39 +0200 | [diff] [blame] | 4652 | pre_back_up |
Andrzej Kurek | eb50871 | 2019-02-14 07:18:59 -0500 | [diff] [blame] | 4653 | |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 4654 | build_status=0 |
| 4655 | if [ $KEEP_GOING -eq 1 ]; then |
| 4656 | pre_setup_keep_going |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4657 | fi |
Gilles Peskine | 67ffdaf | 2019-09-16 15:55:46 +0200 | [diff] [blame] | 4658 | pre_prepare_outcome_file |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 4659 | pre_print_configuration |
| 4660 | pre_check_tools |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 4661 | cleanup |
Gilles Peskine | 1570b59 | 2021-04-22 01:10:12 +0200 | [diff] [blame] | 4662 | pre_generate_files |
Manuel Pégourié-Gonnard | 80955ee | 2014-03-19 18:29:01 +0100 | [diff] [blame] | 4663 | |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 4664 | # Run the requested tests. |
Gilles Peskine | 88a7c2b | 2021-08-02 23:28:00 +0200 | [diff] [blame] | 4665 | for ((error_test_i=1; error_test_i <= error_test; error_test_i++)); do |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 4666 | run_component pseudo_component_error_test |
Gilles Peskine | 5d99682 | 2020-03-28 21:09:21 +0100 | [diff] [blame] | 4667 | done |
Gilles Peskine | 88a7c2b | 2021-08-02 23:28:00 +0200 | [diff] [blame] | 4668 | unset error_test_i |
Gilles Peskine | beb3a81 | 2019-01-06 22:11:25 +0000 | [diff] [blame] | 4669 | for component in $RUN_COMPONENTS; do |
| 4670 | run_component "component_$component" |
| 4671 | done |
Gilles Peskine | 8f07312 | 2018-11-27 15:58:47 +0100 | [diff] [blame] | 4672 | |
| 4673 | # We're done. |
Gilles Peskine | 878cf60 | 2019-01-06 20:50:38 +0000 | [diff] [blame] | 4674 | post_report |