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 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 63 | # Get a list of library-wise undefined symbols and ensure that they only |
| 64 | # belong to psa_xxx() functions and not to mbedtls_yyy() ones. |
| 65 | # This function is a common helper used by both: |
| 66 | # - component_test_default_psa_crypto_client_without_crypto_provider |
| 67 | # - component_build_full_psa_crypto_client_without_crypto_provider. |
| 68 | common_check_mbedtls_missing_symbols () { |
| 69 | nm library/libmbedcrypto.a | grep ' [TRrDC] ' | grep -Eo '(mbedtls_|psa_).*' | sort -u > sym_def.txt |
| 70 | nm library/libmbedcrypto.a | grep ' U ' | grep -Eo '(mbedtls_|psa_).*' | sort -u > sym_undef.txt |
| 71 | comm sym_def.txt sym_undef.txt -13 > linking_errors.txt |
| 72 | not grep mbedtls_ linking_errors.txt |
| 73 | |
| 74 | rm sym_def.txt sym_undef.txt linking_errors.txt |
| 75 | } |
| 76 | |
| 77 | component_test_default_psa_crypto_client_without_crypto_provider () { |
| 78 | msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT" |
| 79 | |
| 80 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 81 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 82 | scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C |
| 83 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 84 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT |
| 85 | scripts/config.py unset MBEDTLS_LMS_C |
| 86 | |
| 87 | make |
| 88 | |
| 89 | msg "check missing symbols: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT" |
| 90 | common_check_mbedtls_missing_symbols |
| 91 | |
| 92 | msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT" |
| 93 | make test |
| 94 | } |
| 95 | |
| 96 | component_build_full_psa_crypto_client_without_crypto_provider () { |
| 97 | msg "build: full config - PSA_CRYPTO_C" |
| 98 | |
| 99 | # Use full config which includes USE_PSA and CRYPTO_CLIENT. |
| 100 | scripts/config.py full |
| 101 | |
| 102 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 103 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 104 | # Dynamic secure element support is a deprecated feature and it is not |
| 105 | # available when CRYPTO_C and PSA_CRYPTO_STORAGE_C are disabled. |
| 106 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 107 | |
| 108 | # Since there is no crypto provider in this build it is not possible to |
| 109 | # build all the test executables and progrems due to missing PSA functions |
| 110 | # at link time. Therefore we will just build libraries and we'll check |
| 111 | # that symbols of interest are there. |
| 112 | make lib |
| 113 | |
| 114 | msg "check missing symbols: full config - PSA_CRYPTO_C" |
| 115 | |
| 116 | common_check_mbedtls_missing_symbols |
| 117 | |
| 118 | # Ensure that desired functions are included into the build (extend the |
| 119 | # following list as required). |
| 120 | grep mbedtls_pk_get_psa_attributes library/libmbedcrypto.a |
| 121 | grep mbedtls_pk_import_into_psa library/libmbedcrypto.a |
| 122 | grep mbedtls_pk_copy_from_psa library/libmbedcrypto.a |
| 123 | } |
| 124 | |
| 125 | component_test_psa_crypto_rsa_no_genprime () { |
| 126 | msg "build: default config minus MBEDTLS_GENPRIME" |
| 127 | scripts/config.py unset MBEDTLS_GENPRIME |
| 128 | make |
| 129 | |
| 130 | msg "test: default config minus MBEDTLS_GENPRIME" |
| 131 | make test |
| 132 | } |
| 133 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 134 | component_test_full_no_cipher_no_psa_crypto () { |
| 135 | msg "build: full no CIPHER no PSA_CRYPTO_C" |
| 136 | scripts/config.py full |
| 137 | scripts/config.py unset MBEDTLS_CIPHER_C |
| 138 | # Don't pull in cipher via PSA mechanisms |
| 139 | # (currently ignored anyway because we completely disable PSA) |
| 140 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG |
| 141 | # Disable features that depend on CIPHER_C |
| 142 | scripts/config.py unset MBEDTLS_CMAC_C |
| 143 | scripts/config.py unset MBEDTLS_NIST_KW_C |
| 144 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_C |
| 145 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_CLIENT |
| 146 | scripts/config.py unset MBEDTLS_SSL_TLS_C |
| 147 | scripts/config.py unset MBEDTLS_SSL_TICKET_C |
| 148 | # Disable features that depend on PSA_CRYPTO_C |
| 149 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C |
| 150 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C |
| 151 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 152 | scripts/config.py unset MBEDTLS_LMS_C |
| 153 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 154 | |
| 155 | msg "test: full no CIPHER no PSA_CRYPTO_C" |
| 156 | make test |
| 157 | } |
| 158 | |
| 159 | # This is a common configurator and test function that is used in: |
| 160 | # - component_test_full_no_cipher_with_psa_crypto |
| 161 | # - component_test_full_no_cipher_with_psa_crypto_config |
| 162 | # It accepts 2 input parameters: |
| 163 | # - $1: boolean value which basically reflects status of MBEDTLS_PSA_CRYPTO_CONFIG |
| 164 | # - $2: a text string which describes the test component |
| 165 | common_test_full_no_cipher_with_psa_crypto () { |
| 166 | USE_CRYPTO_CONFIG="$1" |
| 167 | COMPONENT_DESCRIPTION="$2" |
| 168 | |
| 169 | msg "build: $COMPONENT_DESCRIPTION" |
| 170 | |
| 171 | scripts/config.py full |
| 172 | scripts/config.py unset MBEDTLS_CIPHER_C |
| 173 | |
| 174 | if [ "$USE_CRYPTO_CONFIG" -eq 1 ]; then |
| 175 | # The built-in implementation of the following algs/key-types depends |
| 176 | # on CIPHER_C so we disable them. |
| 177 | # This does not hold for KEY_TYPE_CHACHA20 and ALG_CHACHA20_POLY1305 |
| 178 | # so we keep them enabled. |
| 179 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM_STAR_NO_TAG |
| 180 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CMAC |
| 181 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_NO_PADDING |
| 182 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_PKCS7 |
| 183 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CFB |
| 184 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CTR |
| 185 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_ECB_NO_PADDING |
| 186 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_OFB |
| 187 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128 |
| 188 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_STREAM_CIPHER |
| 189 | scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_KEY_TYPE_DES |
| 190 | else |
| 191 | # Don't pull in cipher via PSA mechanisms |
| 192 | scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG |
| 193 | # Disable cipher modes/keys that make PSA depend on CIPHER_C. |
| 194 | # Keep CHACHA20 and CHACHAPOLY enabled since they do not depend on CIPHER_C. |
| 195 | scripts/config.py unset-all MBEDTLS_CIPHER_MODE |
| 196 | fi |
| 197 | # The following modules directly depends on CIPHER_C |
| 198 | scripts/config.py unset MBEDTLS_CMAC_C |
| 199 | scripts/config.py unset MBEDTLS_NIST_KW_C |
| 200 | |
| 201 | make |
| 202 | |
| 203 | # Ensure that CIPHER_C was not re-enabled |
| 204 | not grep mbedtls_cipher_init library/cipher.o |
| 205 | |
| 206 | msg "test: $COMPONENT_DESCRIPTION" |
| 207 | make test |
| 208 | } |
| 209 | |
| 210 | component_test_full_no_cipher_with_psa_crypto () { |
| 211 | common_test_full_no_cipher_with_psa_crypto 0 "full no CIPHER no CRYPTO_CONFIG" |
| 212 | } |
| 213 | |
| 214 | component_test_full_no_cipher_with_psa_crypto_config () { |
| 215 | common_test_full_no_cipher_with_psa_crypto 1 "full no CIPHER" |
| 216 | } |
| 217 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 218 | component_test_full_no_bignum () { |
| 219 | msg "build: full minus bignum" |
| 220 | scripts/config.py full |
| 221 | scripts/config.py unset MBEDTLS_BIGNUM_C |
| 222 | # Direct dependencies of bignum |
| 223 | scripts/config.py unset MBEDTLS_ECP_C |
| 224 | scripts/config.py unset MBEDTLS_RSA_C |
| 225 | scripts/config.py unset MBEDTLS_DHM_C |
| 226 | # Direct dependencies of ECP |
| 227 | scripts/config.py unset MBEDTLS_ECDH_C |
| 228 | scripts/config.py unset MBEDTLS_ECDSA_C |
| 229 | scripts/config.py unset MBEDTLS_ECJPAKE_C |
| 230 | scripts/config.py unset MBEDTLS_ECP_RESTARTABLE |
| 231 | # Disable what auto-enables ECP_LIGHT |
| 232 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED |
| 233 | scripts/config.py unset MBEDTLS_PK_PARSE_EC_COMPRESSED |
| 234 | # Indirect dependencies of ECP |
| 235 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 236 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 237 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED |
| 238 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 239 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 240 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED |
| 241 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED |
| 242 | scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED |
| 243 | # Direct dependencies of DHM |
| 244 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED |
| 245 | # Direct dependencies of RSA |
| 246 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED |
| 247 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED |
| 248 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED |
| 249 | scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT |
| 250 | # PK and its dependencies |
| 251 | scripts/config.py unset MBEDTLS_PK_C |
| 252 | scripts/config.py unset MBEDTLS_PK_PARSE_C |
| 253 | scripts/config.py unset MBEDTLS_PK_WRITE_C |
| 254 | scripts/config.py unset MBEDTLS_X509_USE_C |
| 255 | scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C |
| 256 | scripts/config.py unset MBEDTLS_X509_CRL_PARSE_C |
| 257 | scripts/config.py unset MBEDTLS_X509_CSR_PARSE_C |
| 258 | scripts/config.py unset MBEDTLS_X509_CREATE_C |
| 259 | scripts/config.py unset MBEDTLS_X509_CRT_WRITE_C |
| 260 | scripts/config.py unset MBEDTLS_X509_CSR_WRITE_C |
| 261 | scripts/config.py unset MBEDTLS_PKCS7_C |
| 262 | scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION |
| 263 | scripts/config.py unset MBEDTLS_SSL_ASYNC_PRIVATE |
| 264 | scripts/config.py unset MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK |
| 265 | |
| 266 | make |
| 267 | |
| 268 | msg "test: full minus bignum" |
| 269 | make test |
| 270 | } |
| 271 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 272 | component_build_dhm_alt () { |
| 273 | msg "build: MBEDTLS_DHM_ALT" # ~30s |
| 274 | scripts/config.py full |
| 275 | scripts/config.py set MBEDTLS_DHM_ALT |
| 276 | # debug.c currently references mbedtls_dhm_context fields directly. |
| 277 | scripts/config.py unset MBEDTLS_DEBUG_C |
| 278 | # We can only compile, not link, since we don't have any implementations |
| 279 | # suitable for testing with the dummy alt headers. |
| 280 | make CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' lib |
| 281 | } |
| 282 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 283 | component_test_psa_crypto_config_accel_hash_keep_builtins () { |
| 284 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated+builtin hash" |
| 285 | # This component ensures that all the test cases for |
| 286 | # md_psa_dynamic_dispatch with legacy+driver in test_suite_md are run. |
| 287 | |
| 288 | loc_accel_list="ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 \ |
| 289 | ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \ |
| 290 | ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512" |
| 291 | |
| 292 | # Start from default config (no USE_PSA) |
| 293 | helper_libtestdriver1_adjust_config "default" |
| 294 | |
| 295 | helper_libtestdriver1_make_drivers "$loc_accel_list" |
| 296 | |
| 297 | helper_libtestdriver1_make_main "$loc_accel_list" |
| 298 | |
| 299 | msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated+builtin hash" |
| 300 | make test |
| 301 | } |
| 302 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 303 | # This should be renamed to test and updated once the accelerator ECDH code is in place and ready to test. |
| 304 | component_build_psa_accel_alg_ecdh () { |
| 305 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C" |
| 306 | scripts/config.py full |
| 307 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 308 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 309 | scripts/config.py unset MBEDTLS_ECDH_C |
| 310 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED |
| 311 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED |
| 312 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED |
| 313 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED |
| 314 | scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED |
| 315 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 316 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 317 | } |
| 318 | |
| 319 | # This should be renamed to test and updated once the accelerator HMAC code is in place and ready to test. |
| 320 | component_build_psa_accel_alg_hmac () { |
| 321 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HMAC" |
| 322 | scripts/config.py full |
| 323 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 324 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 325 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 326 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 327 | } |
| 328 | |
| 329 | # This should be renamed to test and updated once the accelerator HKDF code is in place and ready to test. |
| 330 | component_build_psa_accel_alg_hkdf () { |
| 331 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C" |
| 332 | scripts/config.py full |
| 333 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 334 | scripts/config.py unset MBEDTLS_HKDF_C |
| 335 | # Make sure to unset TLS1_3 since it requires HKDF_C and will not build properly without it. |
| 336 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 337 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 338 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 339 | } |
| 340 | |
| 341 | # This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test. |
| 342 | component_build_psa_accel_alg_md5 () { |
| 343 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD5 - other hashes" |
| 344 | scripts/config.py full |
| 345 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 346 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 347 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 348 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 349 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 350 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 351 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 352 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 353 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 354 | scripts/config.py unset MBEDTLS_LMS_C |
| 355 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 356 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 357 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 358 | } |
| 359 | |
| 360 | # This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test. |
| 361 | component_build_psa_accel_alg_ripemd160 () { |
| 362 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RIPEMD160 - other hashes" |
| 363 | scripts/config.py full |
| 364 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 365 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 366 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 367 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 368 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 369 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 370 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 371 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 372 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 373 | scripts/config.py unset MBEDTLS_LMS_C |
| 374 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 375 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 376 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 377 | } |
| 378 | |
| 379 | # This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test. |
| 380 | component_build_psa_accel_alg_sha1 () { |
| 381 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_1 - other hashes" |
| 382 | scripts/config.py full |
| 383 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 384 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 385 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 386 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 387 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 388 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 389 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 390 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 391 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 392 | scripts/config.py unset MBEDTLS_LMS_C |
| 393 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 394 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 395 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 396 | } |
| 397 | |
| 398 | # This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test. |
| 399 | component_build_psa_accel_alg_sha224 () { |
| 400 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_224 - other hashes" |
| 401 | scripts/config.py full |
| 402 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 403 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 404 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 405 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 406 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 407 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 408 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 409 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 410 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 411 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 412 | } |
| 413 | |
| 414 | # This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test. |
| 415 | component_build_psa_accel_alg_sha256 () { |
| 416 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_256 - other hashes" |
| 417 | scripts/config.py full |
| 418 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 419 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 420 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 421 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 422 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 423 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 424 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 425 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512 |
| 426 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 427 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 428 | } |
| 429 | |
| 430 | # This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test. |
| 431 | component_build_psa_accel_alg_sha384 () { |
| 432 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_384 - other hashes" |
| 433 | scripts/config.py full |
| 434 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 435 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 436 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 437 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 438 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 439 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 440 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 441 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 442 | scripts/config.py unset MBEDTLS_LMS_C |
| 443 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 444 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 445 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 446 | } |
| 447 | |
| 448 | # This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test. |
| 449 | component_build_psa_accel_alg_sha512 () { |
| 450 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_512 - other hashes" |
| 451 | scripts/config.py full |
| 452 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 453 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 454 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5 |
| 455 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160 |
| 456 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1 |
| 457 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224 |
| 458 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256 |
| 459 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384 |
| 460 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS |
| 461 | scripts/config.py unset MBEDTLS_LMS_C |
| 462 | scripts/config.py unset MBEDTLS_LMS_PRIVATE |
| 463 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 464 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 465 | } |
| 466 | |
| 467 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 468 | component_build_psa_accel_alg_rsa_pkcs1v15_crypt () { |
| 469 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 470 | scripts/config.py full |
| 471 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 472 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 473 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1 |
| 474 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 475 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP |
| 476 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS |
| 477 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 478 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 479 | } |
| 480 | |
| 481 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 482 | component_build_psa_accel_alg_rsa_pkcs1v15_sign () { |
| 483 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PKCS1V15_SIGN + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 484 | scripts/config.py full |
| 485 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 486 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 487 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1 |
| 488 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 489 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP |
| 490 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS |
| 491 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 492 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 493 | } |
| 494 | |
| 495 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 496 | component_build_psa_accel_alg_rsa_oaep () { |
| 497 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_OAEP + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 498 | scripts/config.py full |
| 499 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 500 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 501 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_OAEP 1 |
| 502 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 503 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 504 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS |
| 505 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 506 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 507 | } |
| 508 | |
| 509 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 510 | component_build_psa_accel_alg_rsa_pss () { |
| 511 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PSS + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY" |
| 512 | scripts/config.py full |
| 513 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 514 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 515 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1 |
| 516 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT |
| 517 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN |
| 518 | scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP |
| 519 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 520 | make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include" LDFLAGS="$ASAN_CFLAGS" |
| 521 | } |
| 522 | |
| 523 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 524 | component_build_psa_accel_key_type_rsa_key_pair () { |
| 525 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_xxx + PSA_WANT_ALG_RSA_PSS" |
| 526 | scripts/config.py full |
| 527 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 528 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 529 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1 |
| 530 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC 1 |
| 531 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT 1 |
| 532 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT 1 |
| 533 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE 1 |
| 534 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 535 | 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" |
| 536 | } |
| 537 | |
| 538 | # This should be renamed to test and updated once the accelerator RSA code is in place and ready to test. |
| 539 | component_build_psa_accel_key_type_rsa_public_key () { |
| 540 | msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + PSA_WANT_ALG_RSA_PSS" |
| 541 | scripts/config.py full |
| 542 | scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO |
| 543 | scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3 |
| 544 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1 |
| 545 | scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1 |
| 546 | # Need to define the correct symbol and include the test driver header path in order to build with the test driver |
| 547 | 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" |
| 548 | } |
| 549 | |
Minos Galanakis | f7d1cb0 | 2024-07-30 17:25:31 +0100 | [diff] [blame] | 550 | # For timebeing, no VIA Padlock platform available. |
| 551 | component_build_aes_via_padlock () { |
| 552 | |
| 553 | msg "AES:VIA PadLock, build with default configuration." |
| 554 | scripts/config.py unset MBEDTLS_AESNI_C |
| 555 | scripts/config.py set MBEDTLS_PADLOCK_C |
| 556 | scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY |
| 557 | make CC=gcc CFLAGS="$ASAN_CFLAGS -m32" LDFLAGS="-m32 $ASAN_CFLAGS" |
| 558 | grep -q mbedtls_padlock_has_support ./programs/test/selftest |
| 559 | |
| 560 | } |
| 561 | |
| 562 | support_build_aes_via_padlock_only () { |
| 563 | ( [ "$MBEDTLS_TEST_PLATFORM" == "Linux-x86_64" ] || \ |
| 564 | [ "$MBEDTLS_TEST_PLATFORM" == "Linux-amd64" ] ) && \ |
| 565 | [ "`dpkg --print-foreign-architectures`" == "i386" ] |
| 566 | } |
| 567 | |