Minos Galanakis | 7771119 | 2024-07-25 14:24:37 +0100 | [diff] [blame] | 1 | # components.sh |
| 2 | # |
| 3 | # Copyright The Mbed TLS Contributors |
| 4 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 5 | |
| 6 | # This file contains the test components that are executed by all.sh |
| 7 | |
| 8 | # The functions below are named as follows: |
| 9 | # * component_XXX: independent components. They can be run in any order. |
| 10 | # * component_check_XXX: quick tests that aren't worth parallelizing. |
| 11 | # * component_build_XXX: build things but don't run them. |
| 12 | # * component_test_XXX: build and test. |
| 13 | # * component_release_XXX: tests that the CI should skip during PR testing. |
| 14 | # * support_XXX: if support_XXX exists and returns false then |
| 15 | # component_XXX is not run by default. |
| 16 | |
| 17 | # Each component must start by invoking `msg` with a short informative message. |
| 18 | # |
| 19 | # Warning: due to the way bash detects errors, the failure of a command |
| 20 | # inside 'if' or '!' is not detected. Use the 'not' function instead of '!'. |
| 21 | # |
| 22 | # Each component is executed in a separate shell process. The component |
| 23 | # fails if any command in it returns a non-zero status. |
| 24 | # |
| 25 | # The framework in all.sh performs some cleanup tasks after each component. |
| 26 | # This means that components can assume that the working directory is in a |
| 27 | # cleaned-up state, and don't need to perform the cleanup themselves. |
| 28 | # * Run `make clean`. |
| 29 | # * Restore `include/mbedtls/mbedtls_config.h` from a backup made before running |
| 30 | # the component. |
| 31 | # * Check out `Makefile`, `library/Makefile`, `programs/Makefile`, |
| 32 | # `tests/Makefile` and `programs/fuzz/Makefile` from git. |
| 33 | # This cleans up after an in-tree use of CMake. |
| 34 | # |
| 35 | # The tests are roughly in order from fastest to slowest. This doesn't |
| 36 | # have to be exact, but in general you should add slower tests towards |
| 37 | # the end and fast checks near the beginning. |
| 38 | |
| 39 | |
| 40 | ################################################################ |
| 41 | #### Build and test many configurations and targets |
| 42 | ################################################################ |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 43 | |
| 44 | ################################################################ |
| 45 | #### Basic checks |
| 46 | ################################################################ |
| 47 | |
| 48 | # |
| 49 | # Test Suites to be executed |
| 50 | # |
| 51 | # The test ordering tries to optimize for the following criteria: |
| 52 | # 1. Catch possible problems early, by running first tests that run quickly |
| 53 | # and/or are more likely to fail than others (eg I use Clang most of the |
| 54 | # time, so start with a GCC build). |
| 55 | # 2. Minimize total running time, by avoiding useless rebuilds |
| 56 | # |
| 57 | # Indicative running times are given for reference. |
| 58 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 59 | ################################################################ |
| 60 | #### Build and test many configurations and targets |
| 61 | ################################################################ |
| 62 | |
| 63 | component_test_default_out_of_box () { |
| 64 | msg "build: make, default config (out-of-box)" # ~1min |
| 65 | make |
| 66 | # Disable fancy stuff |
| 67 | unset MBEDTLS_TEST_OUTCOME_FILE |
| 68 | |
| 69 | msg "test: main suites make, default config (out-of-box)" # ~10s |
| 70 | make test |
| 71 | |
| 72 | msg "selftest: make, default config (out-of-box)" # ~10s |
| 73 | programs/test/selftest |
| 74 | |
| 75 | msg "program demos: make, default config (out-of-box)" # ~10s |
| 76 | tests/scripts/run_demos.py |
| 77 | } |
| 78 | |
| 79 | component_test_default_cmake_gcc_asan () { |
| 80 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
| 81 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 82 | make |
| 83 | |
| 84 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 85 | make test |
| 86 | |
| 87 | msg "program demos (ASan build)" # ~10s |
| 88 | tests/scripts/run_demos.py |
| 89 | |
| 90 | msg "test: selftest (ASan build)" # ~ 10s |
| 91 | programs/test/selftest |
| 92 | |
| 93 | msg "test: metatests (GCC, ASan build)" |
| 94 | tests/scripts/run-metatests.sh any asan poison |
| 95 | |
| 96 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
| 97 | tests/ssl-opt.sh |
| 98 | |
| 99 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 100 | tests/compat.sh |
| 101 | |
| 102 | msg "test: context-info.sh (ASan build)" # ~ 15 sec |
| 103 | tests/context-info.sh |
| 104 | } |
| 105 | |
| 106 | component_test_default_cmake_gcc_asan_new_bignum () { |
| 107 | msg "build: cmake, gcc, ASan" # ~ 1 min 50s |
| 108 | scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT |
| 109 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 110 | make |
| 111 | |
| 112 | msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s |
| 113 | make test |
| 114 | |
| 115 | msg "test: selftest (ASan build)" # ~ 10s |
| 116 | programs/test/selftest |
| 117 | |
| 118 | msg "test: ssl-opt.sh (ASan build)" # ~ 1 min |
| 119 | tests/ssl-opt.sh |
| 120 | |
| 121 | msg "test: compat.sh (ASan build)" # ~ 6 min |
| 122 | tests/compat.sh |
| 123 | |
| 124 | msg "test: context-info.sh (ASan build)" # ~ 15 sec |
| 125 | tests/context-info.sh |
| 126 | } |
| 127 | |
| 128 | component_test_full_cmake_gcc_asan () { |
| 129 | msg "build: full config, cmake, gcc, ASan" |
| 130 | scripts/config.py full |
| 131 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 132 | make |
| 133 | |
| 134 | msg "test: main suites (inc. selftests) (full config, ASan build)" |
| 135 | make test |
| 136 | |
| 137 | msg "test: selftest (full config, ASan build)" # ~ 10s |
| 138 | programs/test/selftest |
| 139 | |
| 140 | msg "test: ssl-opt.sh (full config, ASan build)" |
| 141 | tests/ssl-opt.sh |
| 142 | |
| 143 | # Note: the next two invocations cover all compat.sh test cases. |
| 144 | # We should use the same here and in basic-build-test.sh. |
| 145 | msg "test: compat.sh: default version (full config, ASan build)" |
| 146 | tests/compat.sh -e 'ARIA\|CHACHA' |
| 147 | |
| 148 | msg "test: compat.sh: next: ARIA, Chacha (full config, ASan build)" |
| 149 | env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 150 | |
| 151 | msg "test: context-info.sh (full config, ASan build)" # ~ 15 sec |
| 152 | tests/context-info.sh |
| 153 | } |
| 154 | |
| 155 | |
| 156 | component_test_full_cmake_gcc_asan_new_bignum () { |
| 157 | msg "build: full config, cmake, gcc, ASan" |
| 158 | scripts/config.py full |
| 159 | scripts/config.py set MBEDTLS_ECP_WITH_MPI_UINT |
| 160 | CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 161 | make |
| 162 | |
| 163 | msg "test: main suites (inc. selftests) (full config, new bignum, ASan)" |
| 164 | make test |
| 165 | |
| 166 | msg "test: selftest (full config, new bignum, ASan)" # ~ 10s |
| 167 | programs/test/selftest |
| 168 | |
| 169 | msg "test: ssl-opt.sh (full config, new bignum, ASan)" |
| 170 | tests/ssl-opt.sh |
| 171 | |
| 172 | # Note: the next two invocations cover all compat.sh test cases. |
| 173 | # We should use the same here and in basic-build-test.sh. |
| 174 | msg "test: compat.sh: default version (full config, new bignum, ASan)" |
| 175 | tests/compat.sh -e 'ARIA\|CHACHA' |
| 176 | |
| 177 | msg "test: compat.sh: next: ARIA, Chacha (full config, new bignum, ASan)" |
| 178 | env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 179 | |
| 180 | msg "test: context-info.sh (full config, new bignum, ASan)" # ~ 15 sec |
| 181 | tests/context-info.sh |
| 182 | } |
| 183 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 184 | # Get a list of library-wise undefined symbols and ensure that they only |
| 185 | # belong to psa_xxx() functions and not to mbedtls_yyy() ones. |
| 186 | # This function is a common helper used by both: |
| 187 | # - component_test_default_psa_crypto_client_without_crypto_provider |
| 188 | # - component_build_full_psa_crypto_client_without_crypto_provider. |
| 189 | common_check_mbedtls_missing_symbols () { |
| 190 | nm library/libmbedcrypto.a | grep ' [TRrDC] ' | grep -Eo '(mbedtls_|psa_).*' | sort -u > sym_def.txt |
| 191 | nm library/libmbedcrypto.a | grep ' U ' | grep -Eo '(mbedtls_|psa_).*' | sort -u > sym_undef.txt |
| 192 | comm sym_def.txt sym_undef.txt -13 > linking_errors.txt |
| 193 | not grep mbedtls_ linking_errors.txt |
| 194 | |
| 195 | rm sym_def.txt sym_undef.txt linking_errors.txt |
| 196 | } |
| 197 | |
| 198 | component_test_default_psa_crypto_client_without_crypto_provider () { |
| 199 | msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT" |
| 200 | |
| 201 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 202 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 203 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
| 204 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 205 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT |
| 206 | scripts/config.py unset MBEDTLS_LMS_C |
| 207 | |
| 208 | make |
| 209 | |
| 210 | msg "check missing symbols: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT" |
| 211 | common_check_mbedtls_missing_symbols |
| 212 | |
| 213 | msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT" |
| 214 | make test |
| 215 | } |
| 216 | |
| 217 | component_build_full_psa_crypto_client_without_crypto_provider () { |
| 218 | msg "build: full config - PSA_CRYPTO_C" |
| 219 | |
| 220 | # Use full config which includes USE_PSA and CRYPTO_CLIENT. |
| 221 | scripts/config.py full |
| 222 | |
| 223 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 224 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 225 | # Dynamic secure element support is a deprecated feature and it is not |
| 226 | # available when CRYPTO_C and PSA_CRYPTO_STORAGE_C are disabled. |
| 227 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 228 | |
| 229 | # Since there is no crypto provider in this build it is not possible to |
| 230 | # build all the test executables and progrems due to missing PSA functions |
| 231 | # at link time. Therefore we will just build libraries and we'll check |
| 232 | # that symbols of interest are there. |
| 233 | make lib |
| 234 | |
| 235 | msg "check missing symbols: full config - PSA_CRYPTO_C" |
| 236 | |
| 237 | common_check_mbedtls_missing_symbols |
| 238 | |
| 239 | # Ensure that desired functions are included into the build (extend the |
| 240 | # following list as required). |
| 241 | grep mbedtls_pk_get_psa_attributes library/libmbedcrypto.a |
| 242 | grep mbedtls_pk_import_into_psa library/libmbedcrypto.a |
| 243 | grep mbedtls_pk_copy_from_psa library/libmbedcrypto.a |
| 244 | } |
| 245 | |
| 246 | component_test_psa_crypto_rsa_no_genprime () { |
| 247 | msg "build: default config minus MBEDTLS_GENPRIME" |
| 248 | scripts/config.py unset MBEDTLS_GENPRIME |
| 249 | make |
| 250 | |
| 251 | msg "test: default config minus MBEDTLS_GENPRIME" |
| 252 | make test |
| 253 | } |
| 254 | |
| 255 | component_test_ref_configs () { |
| 256 | msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s |
| 257 | # test-ref-configs works by overwriting mbedtls_config.h; this makes cmake |
| 258 | # want to re-generate generated files that depend on it, quite correctly. |
| 259 | # However this doesn't work as the generation script expects a specific |
| 260 | # format for mbedtls_config.h, which the other files don't follow. Also, |
| 261 | # cmake can't know this, but re-generation is actually not necessary as |
| 262 | # the generated files only depend on the list of available options, not |
| 263 | # whether they're on or off. So, disable cmake's (over-sensitive here) |
| 264 | # dependency resolution for generated files and just rely on them being |
| 265 | # present (thanks to pre_generate_files) by turning GEN_FILES off. |
| 266 | CC=$ASAN_CC cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan . |
| 267 | tests/scripts/test-ref-configs.pl |
| 268 | } |
| 269 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 270 | component_test_sw_inet_pton () { |
| 271 | msg "build: default plus MBEDTLS_TEST_SW_INET_PTON" |
| 272 | |
| 273 | # MBEDTLS_TEST_HOOKS required for x509_crt_parse_cn_inet_pton |
| 274 | scripts/config.py set MBEDTLS_TEST_HOOKS |
| 275 | make CFLAGS="-DMBEDTLS_TEST_SW_INET_PTON" |
| 276 | |
| 277 | msg "test: default plus MBEDTLS_TEST_SW_INET_PTON" |
| 278 | make test |
| 279 | } |
| 280 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 281 | component_test_full_no_cipher_no_psa_crypto () { |
| 282 | msg "build: full no CIPHER no PSA_CRYPTO_C" |
| 283 | scripts/config.py full |
| 284 | scripts/config.py unset MBEDTLS_CIPHER_C |
| 285 | # Don't pull in cipher via PSA mechanisms |
| 286 | # (currently ignored anyway because we completely disable PSA) |
| 287 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG |
| 288 | # Disable features that depend on CIPHER_C |
| 289 | scripts/config.py unset MBEDTLS_CMAC_C |
| 290 | scripts/config.py unset MBEDTLS_NIST_KW_C |
| 291 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 292 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_CLIENT |
| 293 | scripts/config.py unset MBEDTLS_SSL_TLS_C |
| 294 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
| 295 | # Disable features that depend on PSA_CRYPTO_C |
| 296 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 297 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 298 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 299 | scripts/config.py unset MBEDTLS_LMS_C |
| 300 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 301 | |
| 302 | msg "test: full no CIPHER no PSA_CRYPTO_C" |
| 303 | make test |
| 304 | } |
| 305 | |
| 306 | # This is a common configurator and test function that is used in: |
| 307 | # - component_test_full_no_cipher_with_psa_crypto |
| 308 | # - component_test_full_no_cipher_with_psa_crypto_config |
| 309 | # It accepts 2 input parameters: |
| 310 | # - $1: boolean value which basically reflects status of MBEDTLS_PSA_CRYPTO_CONFIG |
| 311 | # - $2: a text string which describes the test component |
| 312 | common_test_full_no_cipher_with_psa_crypto () { |
| 313 | USE_CRYPTO_CONFIG="$1" |
| 314 | COMPONENT_DESCRIPTION="$2" |
| 315 | |
| 316 | msg "build: $COMPONENT_DESCRIPTION" |
| 317 | |
| 318 | scripts/config.py full |
| 319 | scripts/config.py unset MBEDTLS_CIPHER_C |
| 320 | |
| 321 | if [ "$USE_CRYPTO_CONFIG" -eq 1 ]; then |
| 322 | # The built-in implementation of the following algs/key-types depends |
| 323 | # on CIPHER_C so we disable them. |
| 324 | # This does not hold for KEY_TYPE_CHACHA20 and ALG_CHACHA20_POLY1305 |
| 325 | # so we keep them enabled. |
| 326 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM_STAR_NO_TAG |
| 327 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CMAC |
| 328 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_NO_PADDING |
| 329 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_PKCS7 |
| 330 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CFB |
| 331 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CTR |
| 332 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_ECB_NO_PADDING |
| 333 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_OFB |
| 334 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128 |
| 335 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_STREAM_CIPHER |
| 336 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_KEY_TYPE_DES |
| 337 | else |
| 338 | # Don't pull in cipher via PSA mechanisms |
| 339 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG |
| 340 | # Disable cipher modes/keys that make PSA depend on CIPHER_C. |
| 341 | # Keep CHACHA20 and CHACHAPOLY enabled since they do not depend on CIPHER_C. |
| 342 | scripts/config.py unset-all MBEDTLS_CIPHER_MODE |
| 343 | fi |
| 344 | # The following modules directly depends on CIPHER_C |
| 345 | scripts/config.py unset MBEDTLS_CMAC_C |
| 346 | scripts/config.py unset MBEDTLS_NIST_KW_C |
| 347 | |
| 348 | make |
| 349 | |
| 350 | # Ensure that CIPHER_C was not re-enabled |
| 351 | not grep mbedtls_cipher_init library/cipher.o |
| 352 | |
| 353 | msg "test: $COMPONENT_DESCRIPTION" |
| 354 | make test |
| 355 | } |
| 356 | |
| 357 | component_test_full_no_cipher_with_psa_crypto () { |
| 358 | common_test_full_no_cipher_with_psa_crypto 0 "full no CIPHER no CRYPTO_CONFIG" |
| 359 | } |
| 360 | |
| 361 | component_test_full_no_cipher_with_psa_crypto_config () { |
| 362 | common_test_full_no_cipher_with_psa_crypto 1 "full no CIPHER" |
| 363 | } |
| 364 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 365 | component_test_full_no_bignum () { |
| 366 | msg "build: full minus bignum" |
| 367 | scripts/config.py full |
| 368 | scripts/config.py unset MBEDTLS_BIGNUM_C |
| 369 | # Direct dependencies of bignum |
| 370 | scripts/config.py unset MBEDTLS_ECP_C |
| 371 | scripts/config.py unset MBEDTLS_RSA_C |
| 372 | scripts/config.py unset MBEDTLS_DHM_C |
| 373 | # Direct dependencies of ECP |
| 374 | scripts/config.py unset MBEDTLS_ECDH_C |
| 375 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 376 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
| 377 | scripts/config.py unset MBEDTLS_ECP_RESTARTABLE |
| 378 | # Disable what auto-enables ECP_LIGHT |
| 379 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED |
| 380 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_COMPRESSED |
| 381 | # Indirect dependencies of ECP |
| 382 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 383 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 384 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED |
| 385 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 386 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 387 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED |
| 388 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED |
| 389 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED |
| 390 | # Direct dependencies of DHM |
| 391 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED |
| 392 | # Direct dependencies of RSA |
| 393 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED |
| 394 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED |
| 395 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED |
| 396 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
| 397 | # PK and its dependencies |
| 398 | scripts/config.py unset MBEDTLS_PK_C |
| 399 | scripts/config.py unset MBEDTLS_PK_PARSE_C |
| 400 | scripts/config.py unset MBEDTLS_PK_WRITE_C |
| 401 | scripts/config.py unset MBEDTLS_X509_USE_C |
| 402 | scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C |
| 403 | scripts/config.py unset MBEDTLS_X509_CRL_PARSE_C |
| 404 | scripts/config.py unset MBEDTLS_X509_CSR_PARSE_C |
| 405 | scripts/config.py unset MBEDTLS_X509_CREATE_C |
| 406 | scripts/config.py unset MBEDTLS_X509_CRT_WRITE_C |
| 407 | scripts/config.py unset MBEDTLS_X509_CSR_WRITE_C |
| 408 | scripts/config.py unset MBEDTLS_PKCS7_C |
| 409 | scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION |
| 410 | scripts/config.py unset MBEDTLS_SSL_ASYNC_PRIVATE |
| 411 | scripts/config.py unset MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK |
| 412 | |
| 413 | make |
| 414 | |
| 415 | msg "test: full minus bignum" |
| 416 | make test |
| 417 | } |
| 418 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 419 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 420 | |
| 421 | component_test_tls1_2_default_stream_cipher_only_use_psa () { |
| 422 | msg "build: default with only stream cipher use psa" |
| 423 | |
| 424 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
| 425 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C) |
| 426 | scripts/config.py unset MBEDTLS_GCM_C |
| 427 | scripts/config.py unset MBEDTLS_CCM_C |
| 428 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
| 429 | #Disable TLS 1.3 (as no AEAD) |
| 430 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 431 | # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
| 432 | scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC |
| 433 | # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
| 434 | scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC |
| 435 | # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
| 436 | scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER |
| 437 | # Modules that depend on AEAD |
| 438 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
| 439 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
| 440 | |
| 441 | make |
| 442 | |
| 443 | msg "test: default with only stream cipher use psa" |
| 444 | make test |
| 445 | |
| 446 | # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite. |
| 447 | } |
| 448 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 449 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 450 | |
| 451 | component_test_tls1_2_deafult_cbc_legacy_cipher_only_use_psa () { |
| 452 | msg "build: default with only CBC-legacy cipher use psa" |
| 453 | |
| 454 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
| 455 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C) |
| 456 | scripts/config.py unset MBEDTLS_GCM_C |
| 457 | scripts/config.py unset MBEDTLS_CCM_C |
| 458 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
| 459 | #Disable TLS 1.3 (as no AEAD) |
| 460 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 461 | # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
| 462 | scripts/config.py set MBEDTLS_CIPHER_MODE_CBC |
| 463 | # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
| 464 | scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC |
| 465 | # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
| 466 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
| 467 | # Modules that depend on AEAD |
| 468 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
| 469 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
| 470 | |
| 471 | make |
| 472 | |
| 473 | msg "test: default with only CBC-legacy cipher use psa" |
| 474 | make test |
| 475 | |
| 476 | msg "test: default with only CBC-legacy cipher use psa - ssl-opt.sh (subset)" |
| 477 | tests/ssl-opt.sh -f "TLS 1.2" |
| 478 | } |
| 479 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 480 | component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only_use_psa () { |
| 481 | msg "build: default with only CBC-legacy and CBC-EtM ciphers use psa" |
| 482 | |
| 483 | scripts/config.py set MBEDTLS_USE_PSA_CRYPTO |
| 484 | # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C) |
| 485 | scripts/config.py unset MBEDTLS_GCM_C |
| 486 | scripts/config.py unset MBEDTLS_CCM_C |
| 487 | scripts/config.py unset MBEDTLS_CHACHAPOLY_C |
| 488 | #Disable TLS 1.3 (as no AEAD) |
| 489 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 490 | # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES)) |
| 491 | scripts/config.py set MBEDTLS_CIPHER_MODE_CBC |
| 492 | # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC) |
| 493 | scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC |
| 494 | # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER)) |
| 495 | scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER |
| 496 | # Modules that depend on AEAD |
| 497 | scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION |
| 498 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
| 499 | |
| 500 | make |
| 501 | |
| 502 | msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa" |
| 503 | make test |
| 504 | |
| 505 | msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa - ssl-opt.sh (subset)" |
| 506 | tests/ssl-opt.sh -f "TLS 1.2" |
| 507 | } |
| 508 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 509 | component_test_full_cmake_clang () { |
| 510 | msg "build: cmake, full config, clang" # ~ 50s |
| 511 | scripts/config.py full |
| 512 | CC=clang CXX=clang cmake -D CMAKE_BUILD_TYPE:String=Release -D ENABLE_TESTING=On -D TEST_CPP=1 . |
| 513 | make |
| 514 | |
| 515 | msg "test: main suites (full config, clang)" # ~ 5s |
| 516 | make test |
| 517 | |
| 518 | msg "test: cpp_dummy_build (full config, clang)" # ~ 1s |
| 519 | programs/test/cpp_dummy_build |
| 520 | |
| 521 | msg "test: metatests (clang)" |
| 522 | tests/scripts/run-metatests.sh any pthread |
| 523 | |
| 524 | msg "program demos (full config, clang)" # ~10s |
| 525 | tests/scripts/run_demos.py |
| 526 | |
| 527 | msg "test: psa_constant_names (full config, clang)" # ~ 1s |
| 528 | tests/scripts/test_psa_constant_names.py |
| 529 | |
| 530 | msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s |
| 531 | tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private' |
| 532 | } |
| 533 | |
| 534 | skip_suites_without_constant_flow () { |
| 535 | # Skip the test suites that don't have any constant-flow annotations. |
| 536 | # This will need to be adjusted if we ever start declaring things as |
| 537 | # secret from macros or functions inside tests/include or tests/src. |
| 538 | SKIP_TEST_SUITES=$( |
| 539 | git -C tests/suites grep -L TEST_CF_ 'test_suite_*.function' | |
| 540 | sed 's/test_suite_//; s/\.function$//' | |
| 541 | tr '\n' ,) |
| 542 | export SKIP_TEST_SUITES |
| 543 | } |
| 544 | |
| 545 | skip_all_except_given_suite () { |
| 546 | # Skip all but the given test suite |
| 547 | SKIP_TEST_SUITES=$( |
| 548 | ls -1 tests/suites/test_suite_*.function | |
| 549 | grep -v $1.function | |
| 550 | sed 's/tests.suites.test_suite_//; s/\.function$//' | |
| 551 | tr '\n' ,) |
| 552 | export SKIP_TEST_SUITES |
| 553 | } |
| 554 | |
| 555 | component_test_memsan_constant_flow () { |
| 556 | # This tests both (1) accesses to undefined memory, and (2) branches or |
| 557 | # memory access depending on secret values. To distinguish between those: |
| 558 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist? |
| 559 | # - or alternatively, change the build type to MemSanDbg, which enables |
| 560 | # origin tracking and nicer stack traces (which are useful for debugging |
| 561 | # anyway), and check if the origin was TEST_CF_SECRET() or something else. |
| 562 | msg "build: cmake MSan (clang), full config minus MBEDTLS_USE_PSA_CRYPTO with constant flow testing" |
| 563 | scripts/config.py full |
| 564 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN |
| 565 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 566 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 567 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 568 | make |
| 569 | |
| 570 | msg "test: main suites (full minus MBEDTLS_USE_PSA_CRYPTO, Msan + constant flow)" |
| 571 | make test |
| 572 | } |
| 573 | |
| 574 | component_test_memsan_constant_flow_psa () { |
| 575 | # This tests both (1) accesses to undefined memory, and (2) branches or |
| 576 | # memory access depending on secret values. To distinguish between those: |
| 577 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN - does the failure persist? |
| 578 | # - or alternatively, change the build type to MemSanDbg, which enables |
| 579 | # origin tracking and nicer stack traces (which are useful for debugging |
| 580 | # anyway), and check if the origin was TEST_CF_SECRET() or something else. |
| 581 | msg "build: cmake MSan (clang), full config with constant flow testing" |
| 582 | scripts/config.py full |
| 583 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN |
| 584 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 585 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 586 | make |
| 587 | |
| 588 | msg "test: main suites (Msan + constant flow)" |
| 589 | make test |
| 590 | } |
| 591 | |
| 592 | component_release_test_valgrind_constant_flow () { |
| 593 | # This tests both (1) everything that valgrind's memcheck usually checks |
| 594 | # (heap buffer overflows, use of uninitialized memory, use-after-free, |
| 595 | # etc.) and (2) branches or memory access depending on secret values, |
| 596 | # which will be reported as uninitialized memory. To distinguish between |
| 597 | # secret and actually uninitialized: |
| 598 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist? |
| 599 | # - or alternatively, build with debug info and manually run the offending |
| 600 | # test suite with valgrind --track-origins=yes, then check if the origin |
| 601 | # was TEST_CF_SECRET() or something else. |
| 602 | msg "build: cmake release GCC, full config minus MBEDTLS_USE_PSA_CRYPTO with constant flow testing" |
| 603 | scripts/config.py full |
| 604 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND |
| 605 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 606 | skip_suites_without_constant_flow |
| 607 | cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 608 | make |
| 609 | |
| 610 | # this only shows a summary of the results (how many of each type) |
| 611 | # details are left in Testing/<date>/DynamicAnalysis.xml |
| 612 | msg "test: some suites (full minus MBEDTLS_USE_PSA_CRYPTO, valgrind + constant flow)" |
| 613 | make memcheck |
| 614 | |
| 615 | # Test asm path in constant time module - by default, it will test the plain C |
| 616 | # path under Valgrind or Memsan. Running only the constant_time tests is fast (<1s) |
| 617 | msg "test: valgrind asm constant_time" |
| 618 | scripts/config.py --force set MBEDTLS_TEST_CONSTANT_FLOW_ASM |
| 619 | skip_all_except_given_suite test_suite_constant_time |
| 620 | cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 621 | make clean |
| 622 | make |
| 623 | make memcheck |
| 624 | } |
| 625 | |
| 626 | component_release_test_valgrind_constant_flow_psa () { |
| 627 | # This tests both (1) everything that valgrind's memcheck usually checks |
| 628 | # (heap buffer overflows, use of uninitialized memory, use-after-free, |
| 629 | # etc.) and (2) branches or memory access depending on secret values, |
| 630 | # which will be reported as uninitialized memory. To distinguish between |
| 631 | # secret and actually uninitialized: |
| 632 | # - unset MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND - does the failure persist? |
| 633 | # - or alternatively, build with debug info and manually run the offending |
| 634 | # test suite with valgrind --track-origins=yes, then check if the origin |
| 635 | # was TEST_CF_SECRET() or something else. |
| 636 | msg "build: cmake release GCC, full config with constant flow testing" |
| 637 | scripts/config.py full |
| 638 | scripts/config.py set MBEDTLS_TEST_CONSTANT_FLOW_VALGRIND |
| 639 | skip_suites_without_constant_flow |
| 640 | cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 641 | make |
| 642 | |
| 643 | # this only shows a summary of the results (how many of each type) |
| 644 | # details are left in Testing/<date>/DynamicAnalysis.xml |
| 645 | msg "test: some suites (valgrind + constant flow)" |
| 646 | make memcheck |
| 647 | } |
| 648 | |
| 649 | component_test_tsan () { |
| 650 | msg "build: TSan (clang)" |
| 651 | scripts/config.py full |
| 652 | scripts/config.py set MBEDTLS_THREADING_C |
| 653 | scripts/config.py set MBEDTLS_THREADING_PTHREAD |
| 654 | # Self-tests do not currently use multiple threads. |
| 655 | scripts/config.py unset MBEDTLS_SELF_TEST |
| 656 | |
| 657 | # The deprecated MBEDTLS_PSA_CRYPTO_SE_C interface is not thread safe. |
| 658 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 659 | |
| 660 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=TSan . |
| 661 | make |
| 662 | |
| 663 | msg "test: main suites (TSan)" |
| 664 | make test |
| 665 | } |
| 666 | |
| 667 | component_test_default_no_deprecated () { |
| 668 | # Test that removing the deprecated features from the default |
| 669 | # configuration leaves something consistent. |
| 670 | msg "build: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 30s |
| 671 | scripts/config.py set MBEDTLS_DEPRECATED_REMOVED |
| 672 | make CFLAGS='-O -Werror -Wall -Wextra' |
| 673 | |
| 674 | msg "test: make, default + MBEDTLS_DEPRECATED_REMOVED" # ~ 5s |
| 675 | make test |
| 676 | } |
| 677 | |
| 678 | component_test_full_no_deprecated () { |
| 679 | msg "build: make, full_no_deprecated config" # ~ 30s |
| 680 | scripts/config.py full_no_deprecated |
| 681 | make CFLAGS='-O -Werror -Wall -Wextra' |
| 682 | |
| 683 | msg "test: make, full_no_deprecated config" # ~ 5s |
| 684 | make test |
| 685 | |
| 686 | msg "test: ensure that X509 has no direct dependency on BIGNUM_C" |
| 687 | not grep mbedtls_mpi library/libmbedx509.a |
| 688 | } |
| 689 | |
| 690 | component_test_full_no_deprecated_deprecated_warning () { |
| 691 | # Test that there is nothing deprecated in "full_no_deprecated". |
| 692 | # A deprecated feature would trigger a warning (made fatal) from |
| 693 | # MBEDTLS_DEPRECATED_WARNING. |
| 694 | msg "build: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 30s |
| 695 | scripts/config.py full_no_deprecated |
| 696 | scripts/config.py unset MBEDTLS_DEPRECATED_REMOVED |
| 697 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
| 698 | make CFLAGS='-O -Werror -Wall -Wextra' |
| 699 | |
| 700 | msg "test: make, full_no_deprecated config, MBEDTLS_DEPRECATED_WARNING" # ~ 5s |
| 701 | make test |
| 702 | } |
| 703 | |
| 704 | component_test_full_deprecated_warning () { |
| 705 | # Test that when MBEDTLS_DEPRECATED_WARNING is enabled, the build passes |
| 706 | # with only certain whitelisted types of warnings. |
| 707 | msg "build: make, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s |
| 708 | scripts/config.py full |
| 709 | scripts/config.py set MBEDTLS_DEPRECATED_WARNING |
| 710 | # Expect warnings from '#warning' directives in check_config.h. |
| 711 | # Note that gcc is required to allow the use of -Wno-error=cpp, which allows us to |
| 712 | # display #warning messages without them being treated as errors. |
| 713 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=cpp' lib programs |
| 714 | |
| 715 | msg "build: make tests, full config + MBEDTLS_DEPRECATED_WARNING, expect warnings" # ~ 30s |
| 716 | # Set MBEDTLS_TEST_DEPRECATED to enable tests for deprecated features. |
| 717 | # By default those are disabled when MBEDTLS_DEPRECATED_WARNING is set. |
| 718 | # Expect warnings from '#warning' directives in check_config.h and |
| 719 | # from the use of deprecated functions in test suites. |
| 720 | make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=deprecated-declarations -Wno-error=cpp -DMBEDTLS_TEST_DEPRECATED' tests |
| 721 | |
| 722 | msg "test: full config + MBEDTLS_TEST_DEPRECATED" # ~ 30s |
| 723 | make test |
| 724 | |
| 725 | msg "program demos: full config + MBEDTLS_TEST_DEPRECATED" # ~10s |
| 726 | tests/scripts/run_demos.py |
| 727 | } |
| 728 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 729 | component_build_baremetal () { |
| 730 | msg "build: make, baremetal config" |
| 731 | scripts/config.py baremetal |
| 732 | make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/" |
| 733 | } |
| 734 | support_build_baremetal () { |
| 735 | # Older Glibc versions include time.h from other headers such as stdlib.h, |
| 736 | # which makes the no-time.h-in-baremetal check fail. Ubuntu 16.04 has this |
| 737 | # problem, Ubuntu 18.04 is ok. |
| 738 | ! grep -q -F time.h /usr/include/x86_64-linux-gnu/sys/types.h |
| 739 | } |
| 740 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 741 | component_build_dhm_alt () { |
| 742 | msg "build: MBEDTLS_DHM_ALT" # ~30s |
| 743 | scripts/config.py full |
| 744 | scripts/config.py set MBEDTLS_DHM_ALT |
| 745 | # debug.c currently references mbedtls_dhm_context fields directly. |
| 746 | scripts/config.py unset MBEDTLS_DEBUG_C |
| 747 | # We can only compile, not link, since we don't have any implementations |
| 748 | # suitable for testing with the dummy alt headers. |
| 749 | make CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' lib |
| 750 | } |
| 751 | |
| 752 | component_test_no_psa_crypto_full_cmake_asan () { |
| 753 | # full minus MBEDTLS_PSA_CRYPTO_C: run the same set of tests as basic-build-test.sh |
| 754 | msg "build: cmake, full config minus PSA crypto, ASan" |
| 755 | scripts/config.py full |
| 756 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 757 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_CLIENT |
| 758 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 759 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 760 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
| 761 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 762 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 763 | scripts/config.py unset MBEDTLS_LMS_C |
| 764 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 765 | CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan . |
| 766 | make |
| 767 | |
| 768 | msg "test: main suites (full minus PSA crypto)" |
| 769 | make test |
| 770 | |
| 771 | # Note: ssl-opt.sh has some test cases that depend on |
| 772 | # MBEDTLS_ECP_RESTARTABLE && !MBEDTLS_USE_PSA_CRYPTO |
| 773 | # This is the only component where those tests are not skipped. |
| 774 | msg "test: ssl-opt.sh (full minus PSA crypto)" |
| 775 | tests/ssl-opt.sh |
| 776 | |
| 777 | # Note: the next two invocations cover all compat.sh test cases. |
| 778 | # We should use the same here and in basic-build-test.sh. |
| 779 | msg "test: compat.sh: default version (full minus PSA crypto)" |
| 780 | tests/compat.sh -e 'ARIA\|CHACHA' |
| 781 | |
| 782 | msg "test: compat.sh: next: ARIA, Chacha (full minus PSA crypto)" |
| 783 | env OPENSSL="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 784 | } |
| 785 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 786 | component_test_psa_crypto_config_accel_hash_keep_builtins () { |
| 787 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated+builtin hash" |
| 788 | # This component ensures that all the test cases for |
| 789 | # md_psa_dynamic_dispatch with legacy+driver in test_suite_md are run. |
| 790 | |
| 791 | loc_accel_list="ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 \ |
| 792 | ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \ |
| 793 | ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512" |
| 794 | |
| 795 | # Start from default config (no USE_PSA) |
| 796 | helper_libtestdriver1_adjust_config "default" |
| 797 | |
| 798 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
| 799 | |
| 800 | helper_libtestdriver1_make_main "$loc_accel_list" |
| 801 | |
| 802 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated+builtin hash" |
| 803 | make test |
| 804 | } |
| 805 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 806 | # This should be renamed to test and updated once the accelerator ECDH code is in place and ready to test. |
| 807 | component_build_psa_accel_alg_ecdh () { |
| 808 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C" |
| 809 | scripts/config.py full |
| 810 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 811 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 812 | scripts/config.py unset MBEDTLS_ECDH_C |
| 813 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 814 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 815 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 816 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 817 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED |
| 818 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 819 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 820 | } |
| 821 | |
| 822 | # This should be renamed to test and updated once the accelerator HMAC code is in place and ready to test. |
| 823 | component_build_psa_accel_alg_hmac () { |
| 824 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HMAC" |
| 825 | scripts/config.py full |
| 826 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 827 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 828 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 829 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 830 | } |
| 831 | |
| 832 | # This should be renamed to test and updated once the accelerator HKDF code is in place and ready to test. |
| 833 | component_build_psa_accel_alg_hkdf () { |
| 834 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C" |
| 835 | scripts/config.py full |
| 836 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 837 | scripts/config.py unset MBEDTLS_HKDF_C |
| 838 | # Make sure to unset TLS1_3 since it requires HKDF_C and will not build properly without it. |
| 839 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 840 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 841 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 842 | } |
| 843 | |
| 844 | # This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test. |
| 845 | component_build_psa_accel_alg_md5 () { |
| 846 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD5 - other hashes" |
| 847 | scripts/config.py full |
| 848 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 849 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 850 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 851 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 852 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 853 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 854 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 855 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 856 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 857 | scripts/config.py unset MBEDTLS_LMS_C |
| 858 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 859 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 860 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 861 | } |
| 862 | |
| 863 | # This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test. |
| 864 | component_build_psa_accel_alg_ripemd160 () { |
| 865 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RIPEMD160 - other hashes" |
| 866 | scripts/config.py full |
| 867 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 868 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 869 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 870 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 871 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 872 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 873 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 874 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 875 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 876 | scripts/config.py unset MBEDTLS_LMS_C |
| 877 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 878 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 879 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 880 | } |
| 881 | |
| 882 | # This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test. |
| 883 | component_build_psa_accel_alg_sha1 () { |
| 884 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_1 - other hashes" |
| 885 | scripts/config.py full |
| 886 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 887 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 888 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 889 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 890 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 891 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 892 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 893 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 894 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 895 | scripts/config.py unset MBEDTLS_LMS_C |
| 896 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 897 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 898 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 899 | } |
| 900 | |
| 901 | # This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test. |
| 902 | component_build_psa_accel_alg_sha224 () { |
| 903 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_224 - other hashes" |
| 904 | scripts/config.py full |
| 905 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 906 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 907 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 908 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 909 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 910 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 911 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 912 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 913 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 914 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 915 | } |
| 916 | |
| 917 | # This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test. |
| 918 | component_build_psa_accel_alg_sha256 () { |
| 919 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_256 - other hashes" |
| 920 | scripts/config.py full |
| 921 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 922 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 923 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 924 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 925 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 926 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 927 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 928 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 929 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 930 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 931 | } |
| 932 | |
| 933 | # This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test. |
| 934 | component_build_psa_accel_alg_sha384 () { |
| 935 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_384 - other hashes" |
| 936 | scripts/config.py full |
| 937 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 938 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 939 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 940 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 941 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 942 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 943 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 944 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 945 | scripts/config.py unset MBEDTLS_LMS_C |
| 946 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 947 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 948 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 949 | } |
| 950 | |
| 951 | # This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test. |
| 952 | component_build_psa_accel_alg_sha512 () { |
| 953 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_512 - other hashes" |
| 954 | scripts/config.py full |
| 955 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 956 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 957 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 958 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 959 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 960 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 961 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 962 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 963 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 964 | scripts/config.py unset MBEDTLS_LMS_C |
| 965 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 966 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 967 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 968 | } |
| 969 | |
| 970 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 971 | component_build_psa_accel_alg_rsa_pkcs1v15_crypt () { |
| 972 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 973 | scripts/config.py full |
| 974 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 975 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 976 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1 |
| 977 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 978 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP |
| 979 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS |
| 980 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 981 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 982 | } |
| 983 | |
| 984 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 985 | component_build_psa_accel_alg_rsa_pkcs1v15_sign () { |
| 986 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PKCS1V15_SIGN + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 987 | scripts/config.py full |
| 988 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 989 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 990 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1 |
| 991 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 992 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP |
| 993 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS |
| 994 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 995 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 996 | } |
| 997 | |
| 998 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 999 | component_build_psa_accel_alg_rsa_oaep () { |
| 1000 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_OAEP + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 1001 | scripts/config.py full |
| 1002 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1003 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 1004 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_OAEP 1 |
| 1005 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 1006 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 1007 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS |
| 1008 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1009 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 1010 | } |
| 1011 | |
| 1012 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 1013 | component_build_psa_accel_alg_rsa_pss () { |
| 1014 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PSS + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 1015 | scripts/config.py full |
| 1016 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1017 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 1018 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1 |
| 1019 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 1020 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 1021 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP |
| 1022 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1023 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 1024 | } |
| 1025 | |
| 1026 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 1027 | component_build_psa_accel_key_type_rsa_key_pair () { |
| 1028 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_xxx + PSA_WANT_ALG_RSA_PSS" |
| 1029 | scripts/config.py full |
| 1030 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1031 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 1032 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1 |
| 1033 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC 1 |
| 1034 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT 1 |
| 1035 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT 1 |
| 1036 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE 1 |
| 1037 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1038 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_KEY_PAIR -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 1039 | } |
| 1040 | |
| 1041 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 1042 | component_build_psa_accel_key_type_rsa_public_key () { |
| 1043 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + PSA_WANT_ALG_RSA_PSS" |
| 1044 | scripts/config.py full |
| 1045 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 1046 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 1047 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1 |
| 1048 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1 |
| 1049 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 1050 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_KEY_TYPE_RSA_PUBLIC_KEY -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 1051 | } |
| 1052 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1053 | component_build_tfm () { |
| 1054 | # Check that the TF-M configuration can build cleanly with various |
| 1055 | # warning flags enabled. We don't build or run tests, since the |
| 1056 | # TF-M configuration needs a TF-M platform. A tweaked version of |
| 1057 | # the configuration that works on mainstream platforms is in |
| 1058 | # configs/config-tfm.h, tested via test-ref-configs.pl. |
| 1059 | cp configs/config-tfm.h "$CONFIG_H" |
| 1060 | |
| 1061 | msg "build: TF-M config, clang, armv7-m thumb2" |
| 1062 | make lib CC="clang" CFLAGS="--target=arm-linux-gnueabihf -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 -I../tests/include/spe" |
| 1063 | |
| 1064 | msg "build: TF-M config, gcc native build" |
| 1065 | make clean |
| 1066 | make lib CC="gcc" CFLAGS="-Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wformat-signedness -Wlogical-op -I../tests/include/spe" |
| 1067 | } |
| 1068 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1069 | component_test_no_platform () { |
| 1070 | # Full configuration build, without platform support, file IO and net sockets. |
| 1071 | # This should catch missing mbedtls_printf definitions, and by disabling file |
| 1072 | # IO, it should catch missing '#include <stdio.h>' |
| 1073 | msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s |
| 1074 | scripts/config.py full_no_platform |
| 1075 | scripts/config.py unset MBEDTLS_PLATFORM_C |
| 1076 | scripts/config.py unset MBEDTLS_NET_C |
| 1077 | scripts/config.py unset MBEDTLS_FS_IO |
| 1078 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 1079 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 1080 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
| 1081 | scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED |
| 1082 | # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, |
| 1083 | # to re-enable platform integration features otherwise disabled in C99 builds |
| 1084 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -Os -D_DEFAULT_SOURCE' lib programs |
| 1085 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' test |
| 1086 | } |
| 1087 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1088 | component_test_memory_buffer_allocator_backtrace () { |
| 1089 | msg "build: default config with memory buffer allocator and backtrace enabled" |
| 1090 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1091 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1092 | scripts/config.py set MBEDTLS_MEMORY_BACKTRACE |
| 1093 | scripts/config.py set MBEDTLS_MEMORY_DEBUG |
| 1094 | cmake -DCMAKE_BUILD_TYPE:String=Release . |
| 1095 | make |
| 1096 | |
| 1097 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE" |
| 1098 | make test |
| 1099 | } |
| 1100 | |
| 1101 | component_test_memory_buffer_allocator () { |
| 1102 | msg "build: default config with memory buffer allocator" |
| 1103 | scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C |
| 1104 | scripts/config.py set MBEDTLS_PLATFORM_MEMORY |
| 1105 | cmake -DCMAKE_BUILD_TYPE:String=Release . |
| 1106 | make |
| 1107 | |
| 1108 | msg "test: MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1109 | make test |
| 1110 | |
| 1111 | msg "test: ssl-opt.sh, MBEDTLS_MEMORY_BUFFER_ALLOC_C" |
| 1112 | # MBEDTLS_MEMORY_BUFFER_ALLOC is slow. Skip tests that tend to time out. |
| 1113 | tests/ssl-opt.sh -e '^DTLS proxy' |
| 1114 | } |
| 1115 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1116 | component_test_malloc_0_null () { |
| 1117 | msg "build: malloc(0) returns NULL (ASan+UBSan build)" |
| 1118 | scripts/config.py full |
| 1119 | make CC=$ASAN_CC CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"$PWD/tests/configs/user-config-malloc-0-null.h\"' $ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" |
| 1120 | |
| 1121 | msg "test: malloc(0) returns NULL (ASan+UBSan build)" |
| 1122 | make test |
| 1123 | |
| 1124 | msg "selftest: malloc(0) returns NULL (ASan+UBSan build)" |
| 1125 | # Just the calloc selftest. "make test" ran the others as part of the |
| 1126 | # test suites. |
| 1127 | programs/test/selftest calloc |
| 1128 | |
| 1129 | msg "test ssl-opt.sh: malloc(0) returns NULL (ASan+UBSan build)" |
| 1130 | # Run a subset of the tests. The choice is a balance between coverage |
| 1131 | # and time (including time indirectly wasted due to flaky tests). |
| 1132 | # The current choice is to skip tests whose description includes |
| 1133 | # "proxy", which is an approximation of skipping tests that use the |
| 1134 | # UDP proxy, which tend to be slower and flakier. |
| 1135 | tests/ssl-opt.sh -e 'proxy' |
| 1136 | } |
| 1137 | |
| 1138 | support_test_aesni () { |
| 1139 | # Check that gcc targets x86_64 (we can build AESNI), and check for |
| 1140 | # AESNI support on the host (we can run AESNI). |
| 1141 | # |
| 1142 | # The name of this function is possibly slightly misleading, but needs to align |
| 1143 | # with the name of the corresponding test, component_test_aesni. |
| 1144 | # |
| 1145 | # In principle 32-bit x86 can support AESNI, but our implementation does not |
| 1146 | # support 32-bit x86, so we check for x86-64. |
| 1147 | # We can only grep /proc/cpuinfo on Linux, so this also checks for Linux |
| 1148 | (gcc -v 2>&1 | grep Target | grep -q x86_64) && |
| 1149 | [[ "$HOSTTYPE" == "x86_64" && "$OSTYPE" == "linux-gnu" ]] && |
| 1150 | (lscpu | grep -qw aes) |
| 1151 | } |
| 1152 | |
| 1153 | component_test_aesni () { # ~ 60s |
| 1154 | # This tests the two AESNI implementations (intrinsics and assembly), and also the plain C |
| 1155 | # fallback. It also tests the logic that is used to select which implementation(s) to build. |
| 1156 | # |
| 1157 | # This test does not require the host to have support for AESNI (if it doesn't, the run-time |
| 1158 | # AESNI detection will fallback to the plain C implementation, so the tests will instead |
| 1159 | # exercise the plain C impl). |
| 1160 | |
| 1161 | msg "build: default config with different AES implementations" |
| 1162 | scripts/config.py set MBEDTLS_AESNI_C |
| 1163 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1164 | scripts/config.py set MBEDTLS_HAVE_ASM |
| 1165 | |
| 1166 | # test the intrinsics implementation |
| 1167 | msg "AES tests, test intrinsics" |
| 1168 | make clean |
| 1169 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mpclmul -msse2 -maes' |
| 1170 | # check that we built intrinsics - this should be used by default when supported by the compiler |
| 1171 | ./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics" |
| 1172 | |
| 1173 | # test the asm implementation |
| 1174 | msg "AES tests, test assembly" |
| 1175 | make clean |
| 1176 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mno-pclmul -mno-sse2 -mno-aes' |
| 1177 | # check that we built assembly - this should be built if the compiler does not support intrinsics |
| 1178 | ./programs/test/selftest aes | grep "AESNI code" | grep -q "assembly" |
| 1179 | |
| 1180 | # test the plain C implementation |
| 1181 | scripts/config.py unset MBEDTLS_AESNI_C |
| 1182 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1183 | msg "AES tests, plain C" |
| 1184 | make clean |
| 1185 | make CC=gcc CFLAGS='-O2 -Werror' |
| 1186 | # check that there is no AESNI code present |
| 1187 | ./programs/test/selftest aes | not grep -q "AESNI code" |
| 1188 | not grep -q "AES note: using AESNI" ./programs/test/selftest |
| 1189 | grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 1190 | |
| 1191 | # test the intrinsics implementation |
| 1192 | scripts/config.py set MBEDTLS_AESNI_C |
| 1193 | scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1194 | msg "AES tests, test AESNI only" |
| 1195 | make clean |
| 1196 | make CC=gcc CFLAGS='-Werror -Wall -Wextra -mpclmul -msse2 -maes' |
| 1197 | ./programs/test/selftest aes | grep -q "AES note: using AESNI" |
| 1198 | ./programs/test/selftest aes | not grep -q "AES note: built-in implementation." |
| 1199 | grep -q "AES note: using AESNI" ./programs/test/selftest |
| 1200 | not grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 1201 | } |
| 1202 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1203 | support_test_aesni_m32 () { |
| 1204 | support_test_m32_no_asm && (lscpu | grep -qw aes) |
| 1205 | } |
| 1206 | |
| 1207 | component_test_aesni_m32 () { # ~ 60s |
| 1208 | # This tests are duplicated from component_test_aesni for i386 target |
| 1209 | # |
| 1210 | # AESNI intrinsic code supports i386 and assembly code does not support it. |
| 1211 | |
| 1212 | msg "build: default config with different AES implementations" |
| 1213 | scripts/config.py set MBEDTLS_AESNI_C |
| 1214 | scripts/config.py set MBEDTLS_PADLOCK_C |
| 1215 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1216 | scripts/config.py set MBEDTLS_HAVE_ASM |
| 1217 | |
| 1218 | # test the intrinsics implementation with gcc |
| 1219 | msg "AES tests, test intrinsics (gcc)" |
| 1220 | make clean |
| 1221 | make CC=gcc CFLAGS='-m32 -Werror -Wall -Wextra' LDFLAGS='-m32' |
| 1222 | # check that we built intrinsics - this should be used by default when supported by the compiler |
| 1223 | ./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics" |
| 1224 | grep -q "AES note: using AESNI" ./programs/test/selftest |
| 1225 | grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 1226 | grep -q "AES note: using VIA Padlock" ./programs/test/selftest |
| 1227 | grep -q mbedtls_aesni_has_support ./programs/test/selftest |
| 1228 | |
| 1229 | scripts/config.py set MBEDTLS_AESNI_C |
| 1230 | scripts/config.py unset MBEDTLS_PADLOCK_C |
| 1231 | scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1232 | msg "AES tests, test AESNI only" |
| 1233 | make clean |
| 1234 | make CC=gcc CFLAGS='-m32 -Werror -Wall -Wextra -mpclmul -msse2 -maes' LDFLAGS='-m32' |
| 1235 | ./programs/test/selftest aes | grep -q "AES note: using AESNI" |
| 1236 | ./programs/test/selftest aes | not grep -q "AES note: built-in implementation." |
| 1237 | grep -q "AES note: using AESNI" ./programs/test/selftest |
| 1238 | not grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 1239 | not grep -q "AES note: using VIA Padlock" ./programs/test/selftest |
| 1240 | not grep -q mbedtls_aesni_has_support ./programs/test/selftest |
| 1241 | } |
| 1242 | |
| 1243 | support_test_aesni_m32_clang () { |
| 1244 | # clang >= 4 is required to build with target attributes |
| 1245 | support_test_aesni_m32 && [[ $(clang_version) -ge 4 ]] |
| 1246 | } |
| 1247 | |
| 1248 | component_test_aesni_m32_clang () { |
| 1249 | |
| 1250 | scripts/config.py set MBEDTLS_AESNI_C |
| 1251 | scripts/config.py set MBEDTLS_PADLOCK_C |
| 1252 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1253 | scripts/config.py set MBEDTLS_HAVE_ASM |
| 1254 | |
| 1255 | # test the intrinsics implementation with clang |
| 1256 | msg "AES tests, test intrinsics (clang)" |
| 1257 | make clean |
| 1258 | make CC=clang CFLAGS='-m32 -Werror -Wall -Wextra' LDFLAGS='-m32' |
| 1259 | # check that we built intrinsics - this should be used by default when supported by the compiler |
| 1260 | ./programs/test/selftest aes | grep "AESNI code" | grep -q "intrinsics" |
| 1261 | grep -q "AES note: using AESNI" ./programs/test/selftest |
| 1262 | grep -q "AES note: built-in implementation." ./programs/test/selftest |
| 1263 | grep -q "AES note: using VIA Padlock" ./programs/test/selftest |
| 1264 | grep -q mbedtls_aesni_has_support ./programs/test/selftest |
| 1265 | } |
| 1266 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1267 | support_build_aes_armce () { |
| 1268 | # clang >= 11 is required to build with AES extensions |
| 1269 | [[ $(clang_version) -ge 11 ]] |
| 1270 | } |
| 1271 | |
| 1272 | component_build_aes_armce () { |
| 1273 | # Test variations of AES with Armv8 crypto extensions |
| 1274 | scripts/config.py set MBEDTLS_AESCE_C |
| 1275 | scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1276 | |
| 1277 | msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, aarch64" |
| 1278 | make -B library/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto" |
| 1279 | |
| 1280 | msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, arm" |
| 1281 | make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm" |
| 1282 | |
| 1283 | msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, thumb" |
| 1284 | make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb" |
| 1285 | |
| 1286 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1287 | |
| 1288 | msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, aarch64" |
| 1289 | make -B library/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto" |
| 1290 | |
| 1291 | msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, arm" |
| 1292 | make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm" |
| 1293 | |
| 1294 | msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, thumb" |
| 1295 | make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb" |
| 1296 | |
| 1297 | # test for presence of AES instructions |
| 1298 | scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1299 | msg "clang, test A32 crypto instructions built" |
| 1300 | make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S" |
| 1301 | grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' library/aesce.o |
| 1302 | msg "clang, test T32 crypto instructions built" |
| 1303 | make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S" |
| 1304 | grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' library/aesce.o |
| 1305 | msg "clang, test aarch64 crypto instructions built" |
| 1306 | make -B library/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S" |
| 1307 | grep -E 'aes[a-z]+\s*[qv]' library/aesce.o |
| 1308 | |
| 1309 | # test for absence of AES instructions |
| 1310 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1311 | scripts/config.py unset MBEDTLS_AESCE_C |
| 1312 | msg "clang, test A32 crypto instructions not built" |
| 1313 | make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S" |
| 1314 | not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' library/aesce.o |
| 1315 | msg "clang, test T32 crypto instructions not built" |
| 1316 | make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S" |
| 1317 | not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' library/aesce.o |
| 1318 | msg "clang, test aarch64 crypto instructions not built" |
| 1319 | make -B library/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S" |
| 1320 | not grep -E 'aes[a-z]+\s*[qv]' library/aesce.o |
| 1321 | } |
| 1322 | |
| 1323 | support_build_sha_armce () { |
| 1324 | # clang >= 4 is required to build with SHA extensions |
| 1325 | [[ $(clang_version) -ge 4 ]] |
| 1326 | } |
| 1327 | |
| 1328 | component_build_sha_armce () { |
| 1329 | scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT |
| 1330 | |
| 1331 | |
| 1332 | # Test variations of SHA256 Armv8 crypto extensions |
| 1333 | scripts/config.py set MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY |
| 1334 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, aarch64" |
| 1335 | make -B library/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a" |
| 1336 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, arm" |
| 1337 | make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm" |
| 1338 | scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY |
| 1339 | |
| 1340 | |
| 1341 | # test the deprecated form of the config option |
| 1342 | scripts/config.py set MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY |
| 1343 | msg "MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY clang, thumb" |
| 1344 | make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb" |
| 1345 | scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY |
| 1346 | |
| 1347 | scripts/config.py set MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT |
| 1348 | msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT clang, aarch64" |
| 1349 | make -B library/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a" |
| 1350 | scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT |
| 1351 | |
| 1352 | |
| 1353 | # test the deprecated form of the config option |
| 1354 | scripts/config.py set MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT |
| 1355 | msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, arm" |
| 1356 | make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -std=c99" |
| 1357 | msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, thumb" |
| 1358 | make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb" |
| 1359 | scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT |
| 1360 | |
| 1361 | |
| 1362 | # examine the disassembly for presence of SHA instructions |
| 1363 | for opt in MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT; do |
| 1364 | scripts/config.py set ${opt} |
| 1365 | msg "${opt} clang, test A32 crypto instructions built" |
| 1366 | make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S" |
| 1367 | grep -E 'sha256[a-z0-9]+.32\s+[qv]' library/sha256.o |
| 1368 | |
| 1369 | msg "${opt} clang, test T32 crypto instructions built" |
| 1370 | make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S" |
| 1371 | grep -E 'sha256[a-z0-9]+.32\s+[qv]' library/sha256.o |
| 1372 | |
| 1373 | msg "${opt} clang, test aarch64 crypto instructions built" |
| 1374 | make -B library/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S" |
| 1375 | grep -E 'sha256[a-z0-9]+\s+[qv]' library/sha256.o |
| 1376 | scripts/config.py unset ${opt} |
| 1377 | done |
| 1378 | |
| 1379 | |
| 1380 | # examine the disassembly for absence of SHA instructions |
| 1381 | msg "clang, test A32 crypto instructions not built" |
| 1382 | make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S" |
| 1383 | not grep -E 'sha256[a-z0-9]+.32\s+[qv]' library/sha256.o |
| 1384 | |
| 1385 | msg "clang, test T32 crypto instructions not built" |
| 1386 | make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S" |
| 1387 | not grep -E 'sha256[a-z0-9]+.32\s+[qv]' library/sha256.o |
| 1388 | |
| 1389 | msg "clang, test aarch64 crypto instructions not built" |
| 1390 | make -B library/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S" |
| 1391 | not grep -E 'sha256[a-z0-9]+\s+[qv]' library/sha256.o |
| 1392 | } |
| 1393 | |
| 1394 | # For timebeing, no VIA Padlock platform available. |
| 1395 | component_build_aes_via_padlock () { |
| 1396 | |
| 1397 | msg "AES:VIA PadLock, build with default configuration." |
| 1398 | scripts/config.py unset MBEDTLS_AESNI_C |
| 1399 | scripts/config.py set MBEDTLS_PADLOCK_C |
| 1400 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 1401 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS" |
| 1402 | grep -q mbedtls_padlock_has_support ./programs/test/selftest |
| 1403 | |
| 1404 | } |
| 1405 | |
| 1406 | support_build_aes_via_padlock_only () { |
| 1407 | ( [ "$MBEDTLS_TEST_PLATFORM" == "Linux-x86_64" ] || \ |
| 1408 | [ "$MBEDTLS_TEST_PLATFORM" == "Linux-amd64" ] ) && \ |
| 1409 | [ "`dpkg --print-foreign-architectures`" == "i386" ] |
| 1410 | } |
| 1411 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1412 | component_build_mbedtls_config_file () { |
| 1413 | msg "build: make with MBEDTLS_CONFIG_FILE" # ~40s |
| 1414 | scripts/config.py -w full_config.h full |
| 1415 | echo '#error "MBEDTLS_CONFIG_FILE is not working"' >"$CONFIG_H" |
| 1416 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"'" |
| 1417 | # Make sure this feature is enabled. We'll disable it in the next phase. |
| 1418 | programs/test/query_compile_time_config MBEDTLS_NIST_KW_C |
| 1419 | make clean |
| 1420 | |
| 1421 | msg "build: make with MBEDTLS_CONFIG_FILE + MBEDTLS_USER_CONFIG_FILE" |
| 1422 | # In the user config, disable one feature (for simplicity, pick a feature |
| 1423 | # that nothing else depends on). |
| 1424 | echo '#undef MBEDTLS_NIST_KW_C' >user_config.h |
| 1425 | make CFLAGS="-I '$PWD' -DMBEDTLS_CONFIG_FILE='\"full_config.h\"' -DMBEDTLS_USER_CONFIG_FILE='\"user_config.h\"'" |
| 1426 | not programs/test/query_compile_time_config MBEDTLS_NIST_KW_C |
| 1427 | |
| 1428 | rm -f user_config.h full_config.h |
| 1429 | } |
| 1430 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1431 | component_test_m32_no_asm () { |
| 1432 | # Build without assembly, so as to use portable C code (in a 32-bit |
| 1433 | # build) and not the i386-specific inline assembly. |
| 1434 | # |
| 1435 | # Note that we require gcc, because clang Asan builds fail to link for |
| 1436 | # this target (cannot find libclang_rt.lsan-i386.a - this is a known clang issue). |
| 1437 | msg "build: i386, make, gcc, no asm (ASan build)" # ~ 30s |
| 1438 | scripts/config.py full |
| 1439 | scripts/config.py unset MBEDTLS_HAVE_ASM |
| 1440 | scripts/config.py unset MBEDTLS_PADLOCK_C |
| 1441 | scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32 |
| 1442 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS" |
| 1443 | |
| 1444 | msg "test: i386, make, gcc, no asm (ASan build)" |
| 1445 | make test |
| 1446 | } |
| 1447 | support_test_m32_no_asm () { |
| 1448 | case $(uname -m) in |
| 1449 | amd64|x86_64) true;; |
| 1450 | *) false;; |
| 1451 | esac |
| 1452 | } |
| 1453 | |
| 1454 | component_test_m32_o2 () { |
| 1455 | # Build with optimization, to use the i386 specific inline assembly |
| 1456 | # and go faster for tests. |
| 1457 | msg "build: i386, make, gcc -O2 (ASan build)" # ~ 30s |
| 1458 | scripts/config.py full |
| 1459 | scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32 |
| 1460 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS" |
| 1461 | |
| 1462 | msg "test: i386, make, gcc -O2 (ASan build)" |
| 1463 | make test |
| 1464 | |
| 1465 | msg "test ssl-opt.sh, i386, make, gcc-O2" |
| 1466 | tests/ssl-opt.sh |
| 1467 | } |
| 1468 | support_test_m32_o2 () { |
| 1469 | support_test_m32_no_asm "$@" |
| 1470 | } |
| 1471 | |
| 1472 | component_test_m32_everest () { |
| 1473 | msg "build: i386, Everest ECDH context (ASan build)" # ~ 6 min |
| 1474 | scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED |
| 1475 | scripts/config.py unset MBEDTLS_AESNI_C # AESNI for 32-bit is tested in test_aesni_m32 |
| 1476 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS" |
| 1477 | |
| 1478 | msg "test: i386, Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s |
| 1479 | make test |
| 1480 | |
| 1481 | msg "test: i386, Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s |
| 1482 | tests/ssl-opt.sh -f ECDH |
| 1483 | |
| 1484 | msg "test: i386, Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min |
| 1485 | # Exclude some symmetric ciphers that are redundant here to gain time. |
| 1486 | tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA' |
| 1487 | } |
| 1488 | support_test_m32_everest () { |
| 1489 | support_test_m32_no_asm "$@" |
| 1490 | } |
| 1491 | |
| 1492 | component_test_mx32 () { |
| 1493 | msg "build: 64-bit ILP32, make, gcc" # ~ 30s |
| 1494 | scripts/config.py full |
| 1495 | make CC=gcc CFLAGS='-O2 -Werror -Wall -Wextra -mx32' LDFLAGS='-mx32' |
| 1496 | |
| 1497 | msg "test: 64-bit ILP32, make, gcc" |
| 1498 | make test |
| 1499 | } |
| 1500 | support_test_mx32 () { |
| 1501 | case $(uname -m) in |
| 1502 | amd64|x86_64) true;; |
| 1503 | *) false;; |
| 1504 | esac |
| 1505 | } |
| 1506 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1507 | component_test_no_strings () { |
| 1508 | msg "build: no strings" # ~10s |
| 1509 | scripts/config.py full |
| 1510 | # Disable options that activate a large amount of string constants. |
| 1511 | scripts/config.py unset MBEDTLS_DEBUG_C |
| 1512 | scripts/config.py unset MBEDTLS_ERROR_C |
| 1513 | scripts/config.py set MBEDTLS_ERROR_STRERROR_DUMMY |
| 1514 | scripts/config.py unset MBEDTLS_VERSION_FEATURES |
| 1515 | make CFLAGS='-Werror -Os' |
| 1516 | |
| 1517 | msg "test: no strings" # ~ 10s |
| 1518 | make test |
| 1519 | } |
| 1520 | |
| 1521 | component_test_no_x509_info () { |
| 1522 | msg "build: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s |
| 1523 | scripts/config.pl full |
| 1524 | scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests |
| 1525 | scripts/config.pl set MBEDTLS_X509_REMOVE_INFO |
| 1526 | make CFLAGS='-Werror -O2' |
| 1527 | |
| 1528 | msg "test: full + MBEDTLS_X509_REMOVE_INFO" # ~ 10s |
| 1529 | make test |
| 1530 | |
| 1531 | msg "test: ssl-opt.sh, full + MBEDTLS_X509_REMOVE_INFO" # ~ 1 min |
| 1532 | tests/ssl-opt.sh |
| 1533 | } |
| 1534 | |
| 1535 | component_build_arm_none_eabi_gcc () { |
| 1536 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" # ~ 10s |
| 1537 | scripts/config.py baremetal |
| 1538 | 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 |
| 1539 | |
| 1540 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug" |
| 1541 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
| 1542 | } |
| 1543 | |
| 1544 | component_build_arm_linux_gnueabi_gcc_arm5vte () { |
| 1545 | msg "build: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s |
| 1546 | scripts/config.py baremetal |
| 1547 | # Build for a target platform that's close to what Debian uses |
| 1548 | # for its "armel" distribution (https://wiki.debian.org/ArmEabiPort). |
| 1549 | # See https://github.com/Mbed-TLS/mbedtls/pull/2169 and comments. |
| 1550 | # Build everything including programs, see for example |
| 1551 | # https://github.com/Mbed-TLS/mbedtls/pull/3449#issuecomment-675313720 |
| 1552 | 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' |
| 1553 | |
| 1554 | msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug" |
| 1555 | ${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t library/*.o |
| 1556 | } |
| 1557 | support_build_arm_linux_gnueabi_gcc_arm5vte () { |
| 1558 | type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1 |
| 1559 | } |
| 1560 | |
| 1561 | component_build_arm_none_eabi_gcc_arm5vte () { |
| 1562 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=arm5vte, baremetal+debug" # ~ 10s |
| 1563 | scripts/config.py baremetal |
| 1564 | # This is an imperfect substitute for |
| 1565 | # component_build_arm_linux_gnueabi_gcc_arm5vte |
| 1566 | # in case the gcc-arm-linux-gnueabi toolchain is not available |
| 1567 | 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 |
| 1568 | |
| 1569 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug" |
| 1570 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
| 1571 | } |
| 1572 | |
| 1573 | component_build_arm_none_eabi_gcc_m0plus () { |
| 1574 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus, baremetal_size" # ~ 10s |
| 1575 | scripts/config.py baremetal_size |
| 1576 | 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 |
| 1577 | |
| 1578 | msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size" |
| 1579 | ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o |
| 1580 | for lib in library/*.a; do |
| 1581 | echo "$lib:" |
| 1582 | ${ARM_NONE_EABI_GCC_PREFIX}size -t $lib | grep TOTALS |
| 1583 | done |
| 1584 | } |
| 1585 | |
| 1586 | component_build_arm_none_eabi_gcc_no_udbl_division () { |
| 1587 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s |
| 1588 | scripts/config.py baremetal |
| 1589 | scripts/config.py set MBEDTLS_NO_UDBL_DIVISION |
| 1590 | 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 |
| 1591 | echo "Checking that software 64-bit division is not required" |
| 1592 | not grep __aeabi_uldiv library/*.o |
| 1593 | } |
| 1594 | |
| 1595 | component_build_arm_none_eabi_gcc_no_64bit_multiplication () { |
| 1596 | msg "build: ${ARM_NONE_EABI_GCC_PREFIX}gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s |
| 1597 | scripts/config.py baremetal |
| 1598 | scripts/config.py set MBEDTLS_NO_64BIT_MULTIPLICATION |
| 1599 | 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 |
| 1600 | echo "Checking that software 64-bit multiplication is not required" |
| 1601 | not grep __aeabi_lmul library/*.o |
| 1602 | } |
| 1603 | |
| 1604 | component_build_arm_clang_thumb () { |
| 1605 | # ~ 30s |
| 1606 | |
| 1607 | scripts/config.py baremetal |
| 1608 | |
| 1609 | msg "build: clang thumb 2, make" |
| 1610 | make clean |
| 1611 | make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -march=armv7-m -mthumb' lib |
| 1612 | |
| 1613 | # Some Thumb 1 asm is sensitive to optimisation level, so test both -O0 and -Os |
| 1614 | msg "build: clang thumb 1 -O0, make" |
| 1615 | make clean |
| 1616 | make CC="clang" CFLAGS='-std=c99 -Werror -O0 --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib |
| 1617 | |
| 1618 | msg "build: clang thumb 1 -Os, make" |
| 1619 | make clean |
| 1620 | make CC="clang" CFLAGS='-std=c99 -Werror -Os --target=arm-linux-gnueabihf -mcpu=arm1136j-s -mthumb' lib |
| 1621 | } |
| 1622 | |
| 1623 | component_build_armcc () { |
| 1624 | msg "build: ARM Compiler 5" |
| 1625 | scripts/config.py baremetal |
| 1626 | # armc[56] don't support SHA-512 intrinsics |
| 1627 | scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT |
| 1628 | |
| 1629 | # older versions of armcc/armclang don't support AESCE_C on 32-bit Arm |
| 1630 | scripts/config.py unset MBEDTLS_AESCE_C |
| 1631 | |
| 1632 | # Stop armclang warning about feature detection for A64_CRYPTO. |
| 1633 | # With this enabled, the library does build correctly under armclang, |
| 1634 | # but in baremetal builds (as tested here), feature detection is |
| 1635 | # unavailable, and the user is notified via a #warning. So enabling |
| 1636 | # this feature would prevent us from building with -Werror on |
| 1637 | # armclang. Tracked in #7198. |
| 1638 | scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT |
| 1639 | |
| 1640 | scripts/config.py set MBEDTLS_HAVE_ASM |
| 1641 | |
| 1642 | make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib |
| 1643 | |
| 1644 | msg "size: ARM Compiler 5" |
| 1645 | "$ARMC5_FROMELF" -z library/*.o |
| 1646 | |
| 1647 | # Compile mostly with -O1 since some Arm inline assembly is disabled for -O0. |
| 1648 | |
| 1649 | # ARM Compiler 6 - Target ARMv7-A |
| 1650 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-a" |
| 1651 | |
| 1652 | # ARM Compiler 6 - Target ARMv7-M |
| 1653 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m" |
| 1654 | |
| 1655 | # ARM Compiler 6 - Target ARMv7-M+DSP |
| 1656 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv7-m+dsp" |
| 1657 | |
| 1658 | # ARM Compiler 6 - Target ARMv8-A - AArch32 |
| 1659 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8.2-a" |
| 1660 | |
| 1661 | # ARM Compiler 6 - Target ARMv8-M |
| 1662 | armc6_build_test "-O1 --target=arm-arm-none-eabi -march=armv8-m.main" |
| 1663 | |
| 1664 | # ARM Compiler 6 - Target Cortex-M0 - no optimisation |
| 1665 | armc6_build_test "-O0 --target=arm-arm-none-eabi -mcpu=cortex-m0" |
| 1666 | |
| 1667 | # ARM Compiler 6 - Target Cortex-M0 |
| 1668 | armc6_build_test "-Os --target=arm-arm-none-eabi -mcpu=cortex-m0" |
| 1669 | |
| 1670 | # ARM Compiler 6 - Target ARMv8.2-A - AArch64 |
| 1671 | # |
| 1672 | # Re-enable MBEDTLS_AESCE_C as this should be supported by the version of armclang |
| 1673 | # that we have in our CI |
| 1674 | scripts/config.py set MBEDTLS_AESCE_C |
| 1675 | armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8.2-a+crypto" |
| 1676 | } |
| 1677 | |
| 1678 | support_build_armcc () { |
| 1679 | armc5_cc="$ARMC5_BIN_DIR/armcc" |
| 1680 | armc6_cc="$ARMC6_BIN_DIR/armclang" |
| 1681 | (check_tools "$armc5_cc" "$armc6_cc" > /dev/null 2>&1) |
| 1682 | } |
| 1683 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 1684 | component_test_memsan () { |
| 1685 | msg "build: MSan (clang)" # ~ 1 min 20s |
| 1686 | scripts/config.py unset MBEDTLS_AESNI_C # memsan doesn't grok asm |
| 1687 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . |
| 1688 | make |
| 1689 | |
| 1690 | msg "test: main suites (MSan)" # ~ 10s |
| 1691 | make test |
| 1692 | |
| 1693 | msg "test: metatests (MSan)" |
| 1694 | tests/scripts/run-metatests.sh any msan |
| 1695 | |
| 1696 | msg "program demos (MSan)" # ~20s |
| 1697 | tests/scripts/run_demos.py |
| 1698 | |
| 1699 | msg "test: ssl-opt.sh (MSan)" # ~ 1 min |
| 1700 | tests/ssl-opt.sh |
| 1701 | |
| 1702 | # Optional part(s) |
| 1703 | |
| 1704 | if [ "$MEMORY" -gt 0 ]; then |
| 1705 | msg "test: compat.sh (MSan)" # ~ 6 min 20s |
| 1706 | tests/compat.sh |
| 1707 | fi |
| 1708 | } |
| 1709 | |
| 1710 | component_release_test_valgrind () { |
| 1711 | msg "build: Release (clang)" |
| 1712 | # default config, in particular without MBEDTLS_USE_PSA_CRYPTO |
| 1713 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1714 | make |
| 1715 | |
| 1716 | msg "test: main suites, Valgrind (default config)" |
| 1717 | make memcheck |
| 1718 | |
| 1719 | # Optional parts (slow; currently broken on OS X because programs don't |
| 1720 | # seem to receive signals under valgrind on OS X). |
| 1721 | # These optional parts don't run on the CI. |
| 1722 | if [ "$MEMORY" -gt 0 ]; then |
| 1723 | msg "test: ssl-opt.sh --memcheck (default config)" |
| 1724 | tests/ssl-opt.sh --memcheck |
| 1725 | fi |
| 1726 | |
| 1727 | if [ "$MEMORY" -gt 1 ]; then |
| 1728 | msg "test: compat.sh --memcheck (default config)" |
| 1729 | tests/compat.sh --memcheck |
| 1730 | fi |
| 1731 | |
| 1732 | if [ "$MEMORY" -gt 0 ]; then |
| 1733 | msg "test: context-info.sh --memcheck (default config)" |
| 1734 | tests/context-info.sh --memcheck |
| 1735 | fi |
| 1736 | } |
| 1737 | |
| 1738 | component_release_test_valgrind_psa () { |
| 1739 | msg "build: Release, full (clang)" |
| 1740 | # full config, in particular with MBEDTLS_USE_PSA_CRYPTO |
| 1741 | scripts/config.py full |
| 1742 | CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . |
| 1743 | make |
| 1744 | |
| 1745 | msg "test: main suites, Valgrind (full config)" |
| 1746 | make memcheck |
| 1747 | } |
| 1748 | |
Minos Galanakis | 5b4386c | 2024-08-01 17:12:24 +0100 | [diff] [blame^] | 1749 | |