blob: 83188aed109d8aaa1b73eb9f344f1fb1aee912f6 [file] [log] [blame]
Minos Galanakis77711192024-07-25 14:24:37 +01001# components-configuration-crypto.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 test components that are executed by all.sh
7
8################################################################
9#### Configuration Testing - Crypto
10################################################################
Minos Galanakis3ece57e2024-08-01 17:09:49 +010011
12component_test_psa_crypto_key_id_encodes_owner () {
13 msg "build: full config + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
14 scripts/config.py full
15 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
16 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
17 make
18
19 msg "test: full config - USE_PSA_CRYPTO + PSA_CRYPTO_KEY_ID_ENCODES_OWNER, cmake, gcc, ASan"
20 make test
21}
22
23component_test_psa_assume_exclusive_buffers () {
24 msg "build: full config + MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, cmake, gcc, ASan"
25 scripts/config.py full
26 scripts/config.py set MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS
27 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
28 make
29
30 msg "test: full config + MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERS, cmake, gcc, ASan"
31 make test
32}
33
34# check_renamed_symbols HEADER LIB
35# Check that if HEADER contains '#define MACRO ...' then MACRO is not a symbol
36# name in LIB.
37check_renamed_symbols () {
38 ! nm "$2" | sed 's/.* //' |
39 grep -x -F "$(sed -n 's/^ *# *define *\([A-Z_a-z][0-9A-Z_a-z]*\)..*/\1/p' "$1")"
40}
41
42component_build_psa_crypto_spm () {
43 msg "build: full config + PSA_CRYPTO_KEY_ID_ENCODES_OWNER + PSA_CRYPTO_SPM, make, gcc"
44 scripts/config.py full
45 scripts/config.py unset MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
46 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
47 scripts/config.py set MBEDTLS_PSA_CRYPTO_SPM
48 # We can only compile, not link, since our test and sample programs
49 # aren't equipped for the modified names used when MBEDTLS_PSA_CRYPTO_SPM
50 # is active.
51 make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' lib
52
53 # Check that if a symbol is renamed by crypto_spe.h, the non-renamed
54 # version is not present.
55 echo "Checking for renamed symbols in the library"
56 check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a
57}
58
Minos Galanakis0c0c3e12024-08-01 22:59:12 +010059# Get a list of library-wise undefined symbols and ensure that they only
60# belong to psa_xxx() functions and not to mbedtls_yyy() ones.
61# This function is a common helper used by both:
62# - component_test_default_psa_crypto_client_without_crypto_provider
63# - component_build_full_psa_crypto_client_without_crypto_provider.
64common_check_mbedtls_missing_symbols () {
65 nm library/libmbedcrypto.a | grep ' [TRrDC] ' | grep -Eo '(mbedtls_|psa_).*' | sort -u > sym_def.txt
66 nm library/libmbedcrypto.a | grep ' U ' | grep -Eo '(mbedtls_|psa_).*' | sort -u > sym_undef.txt
67 comm sym_def.txt sym_undef.txt -13 > linking_errors.txt
68 not grep mbedtls_ linking_errors.txt
69
70 rm sym_def.txt sym_undef.txt linking_errors.txt
71}
72
73component_test_default_psa_crypto_client_without_crypto_provider () {
74 msg "build: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT"
75
76 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
77 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
78 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C
79 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
80 scripts/config.py set MBEDTLS_PSA_CRYPTO_CLIENT
81 scripts/config.py unset MBEDTLS_LMS_C
82
83 make
84
85 msg "check missing symbols: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT"
86 common_check_mbedtls_missing_symbols
87
88 msg "test: default config - PSA_CRYPTO_C + PSA_CRYPTO_CLIENT"
89 make test
90}
91
92component_build_full_psa_crypto_client_without_crypto_provider () {
93 msg "build: full config - PSA_CRYPTO_C"
94
95 # Use full config which includes USE_PSA and CRYPTO_CLIENT.
96 scripts/config.py full
97
98 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
99 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
100 # Dynamic secure element support is a deprecated feature and it is not
101 # available when CRYPTO_C and PSA_CRYPTO_STORAGE_C are disabled.
102 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
103
104 # Since there is no crypto provider in this build it is not possible to
105 # build all the test executables and progrems due to missing PSA functions
106 # at link time. Therefore we will just build libraries and we'll check
107 # that symbols of interest are there.
108 make lib
109
110 msg "check missing symbols: full config - PSA_CRYPTO_C"
111
112 common_check_mbedtls_missing_symbols
113
114 # Ensure that desired functions are included into the build (extend the
115 # following list as required).
116 grep mbedtls_pk_get_psa_attributes library/libmbedcrypto.a
117 grep mbedtls_pk_import_into_psa library/libmbedcrypto.a
118 grep mbedtls_pk_copy_from_psa library/libmbedcrypto.a
119}
120
121component_test_psa_crypto_rsa_no_genprime () {
122 msg "build: default config minus MBEDTLS_GENPRIME"
123 scripts/config.py unset MBEDTLS_GENPRIME
124 make
125
126 msg "test: default config minus MBEDTLS_GENPRIME"
127 make test
128}
129
Minos Galanakis3ece57e2024-08-01 17:09:49 +0100130component_test_no_pem_no_fs () {
131 msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)"
132 scripts/config.py unset MBEDTLS_PEM_PARSE_C
133 scripts/config.py unset MBEDTLS_FS_IO
134 scripts/config.py unset MBEDTLS_PSA_ITS_FILE_C # requires a filesystem
135 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA ITS
136 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
137 make
138
139 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s
140 make test
141
142 msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min
143 tests/ssl-opt.sh
144}
145
146component_test_rsa_no_crt () {
147 msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
148 scripts/config.py set MBEDTLS_RSA_NO_CRT
149 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
150 make
151
152 msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
153 make test
154
155 msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
156 tests/ssl-opt.sh -f RSA
157
158 msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
159 tests/compat.sh -t RSA
160
161 msg "test: RSA_NO_CRT - RSA-related part of context-info.sh (ASan build)" # ~ 15 sec
162 tests/context-info.sh
163}
164
Gilles Peskine4d347aa2024-09-19 18:55:08 +0200165component_test_config_no_entropy () {
166 msg "build: configs/config-no-entropy.h"
167 cp configs/config-no-entropy.h "$CONFIG_H"
168 # test-ref-configs works by overwriting mbedtls_config.h; this makes cmake
169 # want to re-generate generated files that depend on it, quite correctly.
170 # However this doesn't work as the generation script expects a specific
171 # format for mbedtls_config.h, which the other files don't follow. Also,
172 # cmake can't know this, but re-generation is actually not necessary as
173 # the generated files only depend on the list of available options, not
174 # whether they're on or off. So, disable cmake's (over-sensitive here)
175 # dependency resolution for generated files and just rely on them being
176 # present (thanks to pre_generate_files) by turning GEN_FILES off.
177 CC=$ASAN_CC cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan .
178 make
179
180 msg "test: configs/config-no-entropy.h - unit tests"
181 make test
182}
183
Minos Galanakis3ece57e2024-08-01 17:09:49 +0100184component_test_no_ctr_drbg_classic () {
185 msg "build: Full minus CTR_DRBG, classic crypto in TLS"
186 scripts/config.py full
187 scripts/config.py unset MBEDTLS_CTR_DRBG_C
188 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
189 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
190
191 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
192 make
193
194 msg "test: Full minus CTR_DRBG, classic crypto - main suites"
195 make test
196
197 # In this configuration, the TLS test programs use HMAC_DRBG.
198 # The SSL tests are slow, so run a small subset, just enough to get
199 # confidence that the SSL code copes with HMAC_DRBG.
200 msg "test: Full minus CTR_DRBG, classic crypto - ssl-opt.sh (subset)"
201 tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
202
203 msg "test: Full minus CTR_DRBG, classic crypto - compat.sh (subset)"
204 tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL
205}
206
207component_test_no_ctr_drbg_use_psa () {
208 msg "build: Full minus CTR_DRBG, PSA crypto in TLS"
209 scripts/config.py full
210 scripts/config.py unset MBEDTLS_CTR_DRBG_C
211 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
212
213 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
214 make
215
216 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - main suites"
217 make test
218
219 # In this configuration, the TLS test programs use HMAC_DRBG.
220 # The SSL tests are slow, so run a small subset, just enough to get
221 # confidence that the SSL code copes with HMAC_DRBG.
222 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
223 tests/ssl-opt.sh -f 'Default\|SSL async private.*delay=\|tickets enabled on server'
224
225 msg "test: Full minus CTR_DRBG, USE_PSA_CRYPTO - compat.sh (subset)"
226 tests/compat.sh -m tls12 -t 'ECDSA PSK' -V NO -p OpenSSL
227}
228
229component_test_no_hmac_drbg_classic () {
230 msg "build: Full minus HMAC_DRBG, classic crypto in TLS"
231 scripts/config.py full
232 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
233 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
234 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
235 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
236
237 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
238 make
239
240 msg "test: Full minus HMAC_DRBG, classic crypto - main suites"
241 make test
242
243 # Normally our ECDSA implementation uses deterministic ECDSA. But since
244 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
245 # instead.
246 # Test SSL with non-deterministic ECDSA. Only test features that
247 # might be affected by how ECDSA signature is performed.
248 msg "test: Full minus HMAC_DRBG, classic crypto - ssl-opt.sh (subset)"
249 tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
250
251 # To save time, only test one protocol version, since this part of
252 # the protocol is identical in (D)TLS up to 1.2.
253 msg "test: Full minus HMAC_DRBG, classic crypto - compat.sh (ECDSA)"
254 tests/compat.sh -m tls12 -t 'ECDSA'
255}
256
257component_test_no_hmac_drbg_use_psa () {
258 msg "build: Full minus HMAC_DRBG, PSA crypto in TLS"
259 scripts/config.py full
260 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
261 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
262 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
263
264 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
265 make
266
267 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - main suites"
268 make test
269
270 # Normally our ECDSA implementation uses deterministic ECDSA. But since
271 # HMAC_DRBG is disabled in this configuration, randomized ECDSA is used
272 # instead.
273 # Test SSL with non-deterministic ECDSA. Only test features that
274 # might be affected by how ECDSA signature is performed.
275 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - ssl-opt.sh (subset)"
276 tests/ssl-opt.sh -f 'Default\|SSL async private: sign'
277
278 # To save time, only test one protocol version, since this part of
279 # the protocol is identical in (D)TLS up to 1.2.
280 msg "test: Full minus HMAC_DRBG, USE_PSA_CRYPTO - compat.sh (ECDSA)"
281 tests/compat.sh -m tls12 -t 'ECDSA'
282}
283
284component_test_psa_external_rng_no_drbg_classic () {
285 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto in TLS"
286 scripts/config.py full
287 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
288 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
289 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
290 scripts/config.py unset MBEDTLS_ENTROPY_C
291 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
292 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
293 scripts/config.py unset MBEDTLS_CTR_DRBG_C
294 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
295 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
296 # When MBEDTLS_USE_PSA_CRYPTO is disabled and there is no DRBG,
297 # the SSL test programs don't have an RNG and can't work. Explicitly
298 # make them use the PSA RNG with -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG.
299 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DMBEDTLS_TEST_USE_PSA_CRYPTO_RNG" LDFLAGS="$ASAN_CFLAGS"
300
301 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - main suites"
302 make test
303
304 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, classic crypto - ssl-opt.sh (subset)"
305 tests/ssl-opt.sh -f 'Default'
306}
307
308component_test_psa_external_rng_no_drbg_use_psa () {
309 msg "build: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto in TLS"
310 scripts/config.py full
311 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
312 scripts/config.py unset MBEDTLS_ENTROPY_C
313 scripts/config.py unset MBEDTLS_ENTROPY_NV_SEED
314 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
315 scripts/config.py unset MBEDTLS_CTR_DRBG_C
316 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
317 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
318 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
319
320 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - main suites"
321 make test
322
323 msg "test: PSA_CRYPTO_EXTERNAL_RNG minus *_DRBG, PSA crypto - ssl-opt.sh (subset)"
324 tests/ssl-opt.sh -f 'Default\|opaque'
325}
326
327component_test_psa_external_rng_use_psa_crypto () {
328 msg "build: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
329 scripts/config.py full
330 scripts/config.py set MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
331 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
332 scripts/config.py unset MBEDTLS_CTR_DRBG_C
333 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
334
335 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
336 make test
337
338 msg "test: full + PSA_CRYPTO_EXTERNAL_RNG + USE_PSA_CRYPTO minus CTR_DRBG"
339 tests/ssl-opt.sh -f 'Default\|opaque'
340}
341
342component_test_psa_inject_entropy () {
343 msg "build: full + MBEDTLS_PSA_INJECT_ENTROPY"
344 scripts/config.py full
345 scripts/config.py set MBEDTLS_PSA_INJECT_ENTROPY
346 scripts/config.py set MBEDTLS_ENTROPY_NV_SEED
347 scripts/config.py set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
348 scripts/config.py unset MBEDTLS_PLATFORM_NV_SEED_ALT
349 scripts/config.py unset MBEDTLS_PLATFORM_STD_NV_SEED_READ
350 scripts/config.py unset MBEDTLS_PLATFORM_STD_NV_SEED_WRITE
351 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'" LDFLAGS="$ASAN_CFLAGS"
352
353 msg "test: full + MBEDTLS_PSA_INJECT_ENTROPY"
354 make test
355}
356
357component_full_no_pkparse_pkwrite () {
358 msg "build: full without pkparse and pkwrite"
359
360 scripts/config.py crypto_full
361 scripts/config.py unset MBEDTLS_PK_PARSE_C
362 scripts/config.py unset MBEDTLS_PK_WRITE_C
363
364 make CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
365
366 # Ensure that PK_[PARSE|WRITE]_C were not re-enabled accidentally (additive config).
367 not grep mbedtls_pk_parse_key library/pkparse.o
368 not grep mbedtls_pk_write_key_der library/pkwrite.o
369
370 msg "test: full without pkparse and pkwrite"
371 make test
372}
373
374component_test_crypto_full_md_light_only () {
375 msg "build: crypto_full with only the light subset of MD"
376 scripts/config.py crypto_full
377 scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG
378 # Disable MD
379 scripts/config.py unset MBEDTLS_MD_C
380 # Disable direct dependencies of MD_C
381 scripts/config.py unset MBEDTLS_HKDF_C
382 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
383 scripts/config.py unset MBEDTLS_PKCS7_C
384 # Disable indirect dependencies of MD_C
385 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # needs HMAC_DRBG
386 # Disable things that would auto-enable MD_C
387 scripts/config.py unset MBEDTLS_PKCS5_C
388
389 # Note: MD-light is auto-enabled in build_info.h by modules that need it,
390 # which we haven't disabled, so no need to explicitly enable it.
391 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
392
393 # Make sure we don't have the HMAC functions, but the hashing functions
394 not grep mbedtls_md_hmac library/md.o
395 grep mbedtls_md library/md.o
396
397 msg "test: crypto_full with only the light subset of MD"
398 make test
399}
400
Minos Galanakis0c0c3e12024-08-01 22:59:12 +0100401component_test_full_no_cipher_no_psa_crypto () {
402 msg "build: full no CIPHER no PSA_CRYPTO_C"
403 scripts/config.py full
404 scripts/config.py unset MBEDTLS_CIPHER_C
405 # Don't pull in cipher via PSA mechanisms
406 # (currently ignored anyway because we completely disable PSA)
407 scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG
408 # Disable features that depend on CIPHER_C
409 scripts/config.py unset MBEDTLS_CMAC_C
410 scripts/config.py unset MBEDTLS_NIST_KW_C
411 scripts/config.py unset MBEDTLS_PSA_CRYPTO_C
412 scripts/config.py unset MBEDTLS_PSA_CRYPTO_CLIENT
413 scripts/config.py unset MBEDTLS_SSL_TLS_C
414 scripts/config.py unset MBEDTLS_SSL_TICKET_C
415 # Disable features that depend on PSA_CRYPTO_C
416 scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C
417 scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C
418 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
419 scripts/config.py unset MBEDTLS_LMS_C
420 scripts/config.py unset MBEDTLS_LMS_PRIVATE
421
422 msg "test: full no CIPHER no PSA_CRYPTO_C"
423 make test
424}
425
426# This is a common configurator and test function that is used in:
427# - component_test_full_no_cipher_with_psa_crypto
428# - component_test_full_no_cipher_with_psa_crypto_config
429# It accepts 2 input parameters:
430# - $1: boolean value which basically reflects status of MBEDTLS_PSA_CRYPTO_CONFIG
431# - $2: a text string which describes the test component
432common_test_full_no_cipher_with_psa_crypto () {
433 USE_CRYPTO_CONFIG="$1"
434 COMPONENT_DESCRIPTION="$2"
435
436 msg "build: $COMPONENT_DESCRIPTION"
437
438 scripts/config.py full
439 scripts/config.py unset MBEDTLS_CIPHER_C
440
441 if [ "$USE_CRYPTO_CONFIG" -eq 1 ]; then
442 # The built-in implementation of the following algs/key-types depends
443 # on CIPHER_C so we disable them.
444 # This does not hold for KEY_TYPE_CHACHA20 and ALG_CHACHA20_POLY1305
445 # so we keep them enabled.
446 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CCM_STAR_NO_TAG
447 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CMAC
448 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_NO_PADDING
449 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CBC_PKCS7
450 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CFB
451 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_CTR
452 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_ECB_NO_PADDING
453 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_OFB
454 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128
455 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_ALG_STREAM_CIPHER
456 scripts/config.py -f $CRYPTO_CONFIG_H unset PSA_WANT_KEY_TYPE_DES
457 else
458 # Don't pull in cipher via PSA mechanisms
459 scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG
460 # Disable cipher modes/keys that make PSA depend on CIPHER_C.
461 # Keep CHACHA20 and CHACHAPOLY enabled since they do not depend on CIPHER_C.
462 scripts/config.py unset-all MBEDTLS_CIPHER_MODE
463 fi
464 # The following modules directly depends on CIPHER_C
465 scripts/config.py unset MBEDTLS_CMAC_C
466 scripts/config.py unset MBEDTLS_NIST_KW_C
467
468 make
469
470 # Ensure that CIPHER_C was not re-enabled
471 not grep mbedtls_cipher_init library/cipher.o
472
473 msg "test: $COMPONENT_DESCRIPTION"
474 make test
475}
476
477component_test_full_no_cipher_with_psa_crypto () {
478 common_test_full_no_cipher_with_psa_crypto 0 "full no CIPHER no CRYPTO_CONFIG"
479}
480
481component_test_full_no_cipher_with_psa_crypto_config () {
482 common_test_full_no_cipher_with_psa_crypto 1 "full no CIPHER"
483}
484
Minos Galanakis3ece57e2024-08-01 17:09:49 +0100485component_test_full_no_ccm () {
486 msg "build: full no PSA_WANT_ALG_CCM"
487
488 # Full config enables:
489 # - USE_PSA_CRYPTO so that TLS code dispatches cipher/AEAD to PSA
490 # - CRYPTO_CONFIG so that PSA_WANT config symbols are evaluated
491 scripts/config.py full
492
493 # Disable PSA_WANT_ALG_CCM so that CCM is not supported in PSA. CCM_C is still
494 # enabled, but not used from TLS since USE_PSA is set.
495 # This is helpful to ensure that TLS tests below have proper dependencies.
496 #
497 # Note: also PSA_WANT_ALG_CCM_STAR_NO_TAG is enabled, but it does not cause
498 # PSA_WANT_ALG_CCM to be re-enabled.
499 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CCM
500
501 make
502
503 msg "test: full no PSA_WANT_ALG_CCM"
504 make test
505}
506
507component_test_full_no_ccm_star_no_tag () {
508 msg "build: full no PSA_WANT_ALG_CCM_STAR_NO_TAG"
509
510 # Full config enables CRYPTO_CONFIG so that PSA_WANT config symbols are evaluated
511 scripts/config.py full
512
513 # Disable CCM_STAR_NO_TAG, which is the target of this test, as well as all
514 # other components that enable MBEDTLS_PSA_BUILTIN_CIPHER internal symbol.
515 # This basically disables all unauthenticated ciphers on the PSA side, while
516 # keeping AEADs enabled.
517 #
518 # Note: PSA_WANT_ALG_CCM is enabled, but it does not cause
519 # PSA_WANT_ALG_CCM_STAR_NO_TAG to be re-enabled.
520 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CCM_STAR_NO_TAG
521 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_STREAM_CIPHER
522 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CTR
523 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CFB
524 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_OFB
525 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_ECB_NO_PADDING
526 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CBC_NO_PADDING
527 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CBC_PKCS7
528
529 make
530
531 # Ensure MBEDTLS_PSA_BUILTIN_CIPHER was not enabled
532 not grep mbedtls_psa_cipher library/psa_crypto_cipher.o
533
534 msg "test: full no PSA_WANT_ALG_CCM_STAR_NO_TAG"
535 make test
536}
537
Minos Galanakis0c0c3e12024-08-01 22:59:12 +0100538component_test_full_no_bignum () {
539 msg "build: full minus bignum"
540 scripts/config.py full
541 scripts/config.py unset MBEDTLS_BIGNUM_C
542 # Direct dependencies of bignum
543 scripts/config.py unset MBEDTLS_ECP_C
544 scripts/config.py unset MBEDTLS_RSA_C
545 scripts/config.py unset MBEDTLS_DHM_C
546 # Direct dependencies of ECP
547 scripts/config.py unset MBEDTLS_ECDH_C
548 scripts/config.py unset MBEDTLS_ECDSA_C
549 scripts/config.py unset MBEDTLS_ECJPAKE_C
550 scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
551 # Disable what auto-enables ECP_LIGHT
552 scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED
553 scripts/config.py unset MBEDTLS_PK_PARSE_EC_COMPRESSED
554 # Indirect dependencies of ECP
555 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
556 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
557 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
558 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
559 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
560 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
561 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
562 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
563 # Direct dependencies of DHM
564 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
565 # Direct dependencies of RSA
566 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
567 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
568 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
569 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
570 # PK and its dependencies
571 scripts/config.py unset MBEDTLS_PK_C
572 scripts/config.py unset MBEDTLS_PK_PARSE_C
573 scripts/config.py unset MBEDTLS_PK_WRITE_C
574 scripts/config.py unset MBEDTLS_X509_USE_C
575 scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
576 scripts/config.py unset MBEDTLS_X509_CRL_PARSE_C
577 scripts/config.py unset MBEDTLS_X509_CSR_PARSE_C
578 scripts/config.py unset MBEDTLS_X509_CREATE_C
579 scripts/config.py unset MBEDTLS_X509_CRT_WRITE_C
580 scripts/config.py unset MBEDTLS_X509_CSR_WRITE_C
581 scripts/config.py unset MBEDTLS_PKCS7_C
582 scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
583 scripts/config.py unset MBEDTLS_SSL_ASYNC_PRIVATE
584 scripts/config.py unset MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK
585
586 make
587
588 msg "test: full minus bignum"
589 make test
590}
591
592component_build_dhm_alt () {
593 msg "build: MBEDTLS_DHM_ALT" # ~30s
594 scripts/config.py full
595 scripts/config.py set MBEDTLS_DHM_ALT
596 # debug.c currently references mbedtls_dhm_context fields directly.
597 scripts/config.py unset MBEDTLS_DEBUG_C
598 # We can only compile, not link, since we don't have any implementations
599 # suitable for testing with the dummy alt headers.
600 make CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' lib
601}
602
Minos Galanakis3ece57e2024-08-01 17:09:49 +0100603component_test_everest () {
604 msg "build: Everest ECDH context (ASan build)" # ~ 6 min
605 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
606 CC=clang cmake -D CMAKE_BUILD_TYPE:String=Asan .
607 make
608
609 msg "test: Everest ECDH context - main suites (inc. selftests) (ASan build)" # ~ 50s
610 make test
611
612 msg "test: metatests (clang, ASan)"
613 tests/scripts/run-metatests.sh any asan poison
614
615 msg "test: Everest ECDH context - ECDH-related part of ssl-opt.sh (ASan build)" # ~ 5s
616 tests/ssl-opt.sh -f ECDH
617
618 msg "test: Everest ECDH context - compat.sh with some ECDH ciphersuites (ASan build)" # ~ 3 min
619 # Exclude some symmetric ciphers that are redundant here to gain time.
620 tests/compat.sh -f ECDH -V NO -e 'ARIA\|CAMELLIA\|CHACHA'
621}
622
623component_test_everest_curve25519_only () {
624 msg "build: Everest ECDH context, only Curve25519" # ~ 6 min
625 scripts/config.py set MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED
626 scripts/config.py unset MBEDTLS_ECDSA_C
627 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
628 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
629 scripts/config.py unset MBEDTLS_ECJPAKE_C
630 # Disable all curves
631 scripts/config.py unset-all "MBEDTLS_ECP_DP_[0-9A-Z_a-z]*_ENABLED"
632 scripts/config.py set MBEDTLS_ECP_DP_CURVE25519_ENABLED
633
634 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
635
636 msg "test: Everest ECDH context, only Curve25519" # ~ 50s
637 make test
638}
639
640component_test_psa_collect_statuses () {
641 msg "build+test: psa_collect_statuses" # ~30s
642 scripts/config.py full
643 tests/scripts/psa_collect_statuses.py
644 # Check that psa_crypto_init() succeeded at least once
645 grep -q '^0:psa_crypto_init:' tests/statuses.log
646 rm -f tests/statuses.log
647}
648
649# Check that the specified libraries exist and are empty.
650are_empty_libraries () {
651 nm "$@" >/dev/null 2>/dev/null
652 ! nm "$@" 2>/dev/null | grep -v ':$' | grep .
653}
654
655component_build_crypto_default () {
656 msg "build: make, crypto only"
657 scripts/config.py crypto
658 make CFLAGS='-O1 -Werror'
659 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
660}
661
662component_build_crypto_full () {
663 msg "build: make, crypto only, full config"
664 scripts/config.py crypto_full
665 make CFLAGS='-O1 -Werror'
666 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
667}
668
669component_test_crypto_for_psa_service () {
670 msg "build: make, config for PSA crypto service"
671 scripts/config.py crypto
672 scripts/config.py set MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
673 # Disable things that are not needed for just cryptography, to
674 # reach a configuration that would be typical for a PSA cryptography
675 # service providing all implemented PSA algorithms.
676 # System stuff
677 scripts/config.py unset MBEDTLS_ERROR_C
678 scripts/config.py unset MBEDTLS_TIMING_C
679 scripts/config.py unset MBEDTLS_VERSION_FEATURES
680 # Crypto stuff with no PSA interface
681 scripts/config.py unset MBEDTLS_BASE64_C
682 # Keep MBEDTLS_CIPHER_C because psa_crypto_cipher, CCM and GCM need it.
683 scripts/config.py unset MBEDTLS_HKDF_C # PSA's HKDF is independent
684 # Keep MBEDTLS_MD_C because deterministic ECDSA needs it for HMAC_DRBG.
685 scripts/config.py unset MBEDTLS_NIST_KW_C
686 scripts/config.py unset MBEDTLS_PEM_PARSE_C
687 scripts/config.py unset MBEDTLS_PEM_WRITE_C
688 scripts/config.py unset MBEDTLS_PKCS12_C
689 scripts/config.py unset MBEDTLS_PKCS5_C
690 # MBEDTLS_PK_PARSE_C and MBEDTLS_PK_WRITE_C are actually currently needed
691 # in PSA code to work with RSA keys. We don't require users to set those:
692 # they will be reenabled in build_info.h.
693 scripts/config.py unset MBEDTLS_PK_C
694 scripts/config.py unset MBEDTLS_PK_PARSE_C
695 scripts/config.py unset MBEDTLS_PK_WRITE_C
696 make CFLAGS='-O1 -Werror' all test
697 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
698}
699
700component_build_crypto_baremetal () {
701 msg "build: make, crypto only, baremetal config"
702 scripts/config.py crypto_baremetal
703 make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
704 are_empty_libraries library/libmbedx509.* library/libmbedtls.*
705}
706
707support_build_crypto_baremetal () {
708 support_build_baremetal "$@"
709}
710
711# depends.py family of tests
712component_test_depends_py_cipher_id () {
713 msg "test/build: depends.py cipher_id (gcc)"
714 tests/scripts/depends.py cipher_id --unset-use-psa
715}
716
717component_test_depends_py_cipher_chaining () {
718 msg "test/build: depends.py cipher_chaining (gcc)"
719 tests/scripts/depends.py cipher_chaining --unset-use-psa
720}
721
722component_test_depends_py_cipher_padding () {
723 msg "test/build: depends.py cipher_padding (gcc)"
724 tests/scripts/depends.py cipher_padding --unset-use-psa
725}
726
727component_test_depends_py_curves () {
728 msg "test/build: depends.py curves (gcc)"
729 tests/scripts/depends.py curves --unset-use-psa
730}
731
732component_test_depends_py_hashes () {
733 msg "test/build: depends.py hashes (gcc)"
734 tests/scripts/depends.py hashes --unset-use-psa
735}
736
737component_test_depends_py_pkalgs () {
738 msg "test/build: depends.py pkalgs (gcc)"
739 tests/scripts/depends.py pkalgs --unset-use-psa
740}
741
742# PSA equivalents of the depends.py tests
743component_test_depends_py_cipher_id_psa () {
744 msg "test/build: depends.py cipher_id (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
745 tests/scripts/depends.py cipher_id
746}
747
748component_test_depends_py_cipher_chaining_psa () {
749 msg "test/build: depends.py cipher_chaining (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
750 tests/scripts/depends.py cipher_chaining
751}
752
753component_test_depends_py_cipher_padding_psa () {
754 msg "test/build: depends.py cipher_padding (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
755 tests/scripts/depends.py cipher_padding
756}
757
758component_test_depends_py_curves_psa () {
759 msg "test/build: depends.py curves (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
760 tests/scripts/depends.py curves
761}
762
763component_test_depends_py_hashes_psa () {
764 msg "test/build: depends.py hashes (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
765 tests/scripts/depends.py hashes
766}
767
768component_test_depends_py_pkalgs_psa () {
769 msg "test/build: depends.py pkalgs (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
770 tests/scripts/depends.py pkalgs
771}
772
773component_test_psa_crypto_config_ffdh_2048_only () {
774 msg "build: full config - only DH 2048"
775
776 scripts/config.py full
777
778 # Disable all DH groups other than 2048.
779 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_DH_RFC7919_3072
780 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_DH_RFC7919_4096
781 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_DH_RFC7919_6144
782 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_DH_RFC7919_8192
783
784 make CFLAGS="$ASAN_CFLAGS -Werror" LDFLAGS="$ASAN_CFLAGS"
785
786 msg "test: full config - only DH 2048"
787 make test
788
789 msg "ssl-opt: full config - only DH 2048"
790 tests/ssl-opt.sh -f "ffdh"
791}
792
793component_build_no_pk_rsa_alt_support () {
794 msg "build: !MBEDTLS_PK_RSA_ALT_SUPPORT" # ~30s
795
796 scripts/config.py full
797 scripts/config.py unset MBEDTLS_PK_RSA_ALT_SUPPORT
798 scripts/config.py set MBEDTLS_RSA_C
799 scripts/config.py set MBEDTLS_X509_CRT_WRITE_C
800
801 # Only compile - this is primarily to test for compile issues
802 make CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy'
803}
804
805component_build_module_alt () {
806 msg "build: MBEDTLS_XXX_ALT" # ~30s
807 scripts/config.py full
808
809 # Disable options that are incompatible with some ALT implementations:
810 # aesni.c and padlock.c reference mbedtls_aes_context fields directly.
811 scripts/config.py unset MBEDTLS_AESNI_C
812 scripts/config.py unset MBEDTLS_PADLOCK_C
813 scripts/config.py unset MBEDTLS_AESCE_C
814 # MBEDTLS_ECP_RESTARTABLE is documented as incompatible.
815 scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
816 # You can only have one threading implementation: alt or pthread, not both.
817 scripts/config.py unset MBEDTLS_THREADING_PTHREAD
818 # The SpecifiedECDomain parsing code accesses mbedtls_ecp_group fields
819 # directly and assumes the implementation works with partial groups.
820 scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED
821 # MBEDTLS_SHA256_*ALT can't be used with MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_*
822 scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
823 scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY
824 # MBEDTLS_SHA512_*ALT can't be used with MBEDTLS_SHA512_USE_A64_CRYPTO_*
825 scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT
826 scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY
827
828 # Enable all MBEDTLS_XXX_ALT for whole modules. Do not enable
829 # MBEDTLS_XXX_YYY_ALT which are for single functions.
830 scripts/config.py set-all 'MBEDTLS_([A-Z0-9]*|NIST_KW)_ALT'
831 scripts/config.py unset MBEDTLS_DHM_ALT #incompatible with MBEDTLS_DEBUG_C
832
833 # We can only compile, not link, since we don't have any implementations
834 # suitable for testing with the dummy alt headers.
835 make CFLAGS='-Werror -Wall -Wextra -I../tests/include/alt-dummy' lib
836}
837
838component_test_psa_crypto_config_accel_ecdsa () {
839 msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
840
841 # Algorithms and key types to accelerate
842 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \
843 $(helper_get_psa_key_type_list "ECC") \
844 $(helper_get_psa_curve_list)"
845
846 # Configure
847 # ---------
848
849 # Start from default config (no USE_PSA) + TLS 1.3
850 helper_libtestdriver1_adjust_config "default"
851
852 # Disable the module that's accelerated
853 scripts/config.py unset MBEDTLS_ECDSA_C
854
855 # Disable things that depend on it
856 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
857 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
858
859 # Build
860 # -----
861
862 # These hashes are needed for some ECDSA signature tests.
863 loc_extra_list="ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
864 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
865
866 helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list"
867
868 helper_libtestdriver1_make_main "$loc_accel_list"
869
870 # Make sure this was not re-enabled by accident (additive config)
871 not grep mbedtls_ecdsa_ library/ecdsa.o
872
873 # Run the tests
874 # -------------
875
876 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
877 make test
878}
879
880component_test_psa_crypto_config_accel_ecdh () {
881 msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDH"
882
883 # Algorithms and key types to accelerate
884 loc_accel_list="ALG_ECDH \
885 $(helper_get_psa_key_type_list "ECC") \
886 $(helper_get_psa_curve_list)"
887
888 # Configure
889 # ---------
890
891 # Start from default config (no USE_PSA)
892 helper_libtestdriver1_adjust_config "default"
893
894 # Disable the module that's accelerated
895 scripts/config.py unset MBEDTLS_ECDH_C
896
897 # Disable things that depend on it
898 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
899 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
900 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
901 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
902 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
903
904 # Build
905 # -----
906
907 helper_libtestdriver1_make_drivers "$loc_accel_list"
908
909 helper_libtestdriver1_make_main "$loc_accel_list"
910
911 # Make sure this was not re-enabled by accident (additive config)
912 not grep mbedtls_ecdh_ library/ecdh.o
913
914 # Run the tests
915 # -------------
916
917 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDH"
918 make test
919}
920
921component_test_psa_crypto_config_accel_ffdh () {
922 msg "build: full with accelerated FFDH"
923
924 # Algorithms and key types to accelerate
925 loc_accel_list="ALG_FFDH \
926 $(helper_get_psa_key_type_list "DH") \
927 $(helper_get_psa_dh_group_list)"
928
929 # Configure
930 # ---------
931
932 # start with full (USE_PSA and TLS 1.3)
933 helper_libtestdriver1_adjust_config "full"
934
935 # Disable the module that's accelerated
936 scripts/config.py unset MBEDTLS_DHM_C
937
938 # Disable things that depend on it
939 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
940 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
941
942 # Build
943 # -----
944
945 helper_libtestdriver1_make_drivers "$loc_accel_list"
946
947 helper_libtestdriver1_make_main "$loc_accel_list"
948
949 # Make sure this was not re-enabled by accident (additive config)
950 not grep mbedtls_dhm_ library/dhm.o
951
952 # Run the tests
953 # -------------
954
955 msg "test: full with accelerated FFDH"
956 make test
957
958 msg "ssl-opt: full with accelerated FFDH alg"
959 tests/ssl-opt.sh -f "ffdh"
960}
961
962component_test_psa_crypto_config_reference_ffdh () {
963 msg "build: full with non-accelerated FFDH"
964
965 # Start with full (USE_PSA and TLS 1.3)
966 helper_libtestdriver1_adjust_config "full"
967
968 # Disable things that are not supported
969 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
970 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
971 make
972
973 msg "test suites: full with non-accelerated FFDH alg"
974 make test
975
976 msg "ssl-opt: full with non-accelerated FFDH alg"
977 tests/ssl-opt.sh -f "ffdh"
978}
979
980component_test_psa_crypto_config_accel_pake () {
981 msg "build: full with accelerated PAKE"
982
983 loc_accel_list="ALG_JPAKE \
984 $(helper_get_psa_key_type_list "ECC") \
985 $(helper_get_psa_curve_list)"
986
987 # Configure
988 # ---------
989
990 helper_libtestdriver1_adjust_config "full"
991
992 # Make built-in fallback not available
993 scripts/config.py unset MBEDTLS_ECJPAKE_C
994 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
995
996 # Build
997 # -----
998
999 helper_libtestdriver1_make_drivers "$loc_accel_list"
1000
1001 helper_libtestdriver1_make_main "$loc_accel_list"
1002
1003 # Make sure this was not re-enabled by accident (additive config)
1004 not grep mbedtls_ecjpake_init library/ecjpake.o
1005
1006 # Run the tests
1007 # -------------
1008
1009 msg "test: full with accelerated PAKE"
1010 make test
1011}
1012
1013component_test_psa_crypto_config_accel_ecc_some_key_types () {
1014 msg "build: full with accelerated EC algs and some key types"
1015
1016 # Algorithms and key types to accelerate
1017 # For key types, use an explicitly list to omit GENERATE (and DERIVE)
1018 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \
1019 ALG_ECDH \
1020 ALG_JPAKE \
1021 KEY_TYPE_ECC_PUBLIC_KEY \
1022 KEY_TYPE_ECC_KEY_PAIR_BASIC \
1023 KEY_TYPE_ECC_KEY_PAIR_IMPORT \
1024 KEY_TYPE_ECC_KEY_PAIR_EXPORT \
1025 $(helper_get_psa_curve_list)"
1026
1027 # Configure
1028 # ---------
1029
1030 # start with config full for maximum coverage (also enables USE_PSA)
1031 helper_libtestdriver1_adjust_config "full"
1032
1033 # Disable modules that are accelerated - some will be re-enabled
1034 scripts/config.py unset MBEDTLS_ECDSA_C
1035 scripts/config.py unset MBEDTLS_ECDH_C
1036 scripts/config.py unset MBEDTLS_ECJPAKE_C
1037 scripts/config.py unset MBEDTLS_ECP_C
1038
1039 # Disable all curves - those that aren't accelerated should be re-enabled
1040 helper_disable_builtin_curves
1041
1042 # Restartable feature is not yet supported by PSA. Once it will in
1043 # the future, the following line could be removed (see issues
1044 # 6061, 6332 and following ones)
1045 scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
1046
1047 # this is not supported by the driver API yet
1048 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE
1049
1050 # Build
1051 # -----
1052
1053 # These hashes are needed for some ECDSA signature tests.
1054 loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
1055 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
1056 helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list"
1057
1058 helper_libtestdriver1_make_main "$loc_accel_list"
1059
1060 # ECP should be re-enabled but not the others
1061 not grep mbedtls_ecdh_ library/ecdh.o
1062 not grep mbedtls_ecdsa library/ecdsa.o
1063 not grep mbedtls_ecjpake library/ecjpake.o
1064 grep mbedtls_ecp library/ecp.o
1065
1066 # Run the tests
1067 # -------------
1068
1069 msg "test suites: full with accelerated EC algs and some key types"
1070 make test
1071}
1072
1073# Run tests with only (non-)Weierstrass accelerated
1074# Common code used in:
1075# - component_test_psa_crypto_config_accel_ecc_weierstrass_curves
1076# - component_test_psa_crypto_config_accel_ecc_non_weierstrass_curves
1077common_test_psa_crypto_config_accel_ecc_some_curves () {
1078 weierstrass=$1
1079 if [ $weierstrass -eq 1 ]; then
1080 desc="Weierstrass"
1081 else
1082 desc="non-Weierstrass"
1083 fi
1084
1085 msg "build: crypto_full minus PK with accelerated EC algs and $desc curves"
1086
1087 # Note: Curves are handled in a special way by the libtestdriver machinery,
1088 # so we only want to include them in the accel list when building the main
1089 # libraries, hence the use of a separate variable.
1090 # Note: the following loop is a modified version of
1091 # helper_get_psa_curve_list that only keeps Weierstrass families.
1092 loc_weierstrass_list=""
1093 loc_non_weierstrass_list=""
1094 for item in $(sed -n 's/^#define PSA_WANT_\(ECC_[0-9A-Z_a-z]*\).*/\1/p' <"$CRYPTO_CONFIG_H"); do
1095 case $item in
1096 ECC_BRAINPOOL*|ECC_SECP*)
1097 loc_weierstrass_list="$loc_weierstrass_list $item"
1098 ;;
1099 *)
1100 loc_non_weierstrass_list="$loc_non_weierstrass_list $item"
1101 ;;
1102 esac
1103 done
1104 if [ $weierstrass -eq 1 ]; then
1105 loc_curve_list=$loc_weierstrass_list
1106 else
1107 loc_curve_list=$loc_non_weierstrass_list
1108 fi
1109
1110 # Algorithms and key types to accelerate
1111 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \
1112 ALG_ECDH \
1113 ALG_JPAKE \
1114 $(helper_get_psa_key_type_list "ECC") \
1115 $loc_curve_list"
1116
1117 # Configure
1118 # ---------
1119
1120 # Start with config crypto_full and remove PK_C:
1121 # that's what's supported now, see docs/driver-only-builds.md.
1122 helper_libtestdriver1_adjust_config "crypto_full"
1123 scripts/config.py unset MBEDTLS_PK_C
1124 scripts/config.py unset MBEDTLS_PK_PARSE_C
1125 scripts/config.py unset MBEDTLS_PK_WRITE_C
1126
1127 # Disable modules that are accelerated - some will be re-enabled
1128 scripts/config.py unset MBEDTLS_ECDSA_C
1129 scripts/config.py unset MBEDTLS_ECDH_C
1130 scripts/config.py unset MBEDTLS_ECJPAKE_C
1131 scripts/config.py unset MBEDTLS_ECP_C
1132
1133 # Disable all curves - those that aren't accelerated should be re-enabled
1134 helper_disable_builtin_curves
1135
1136 # Restartable feature is not yet supported by PSA. Once it will in
1137 # the future, the following line could be removed (see issues
1138 # 6061, 6332 and following ones)
1139 scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
1140
1141 # this is not supported by the driver API yet
1142 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE
1143
1144 # Build
1145 # -----
1146
1147 # These hashes are needed for some ECDSA signature tests.
1148 loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
1149 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
1150 helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list"
1151
1152 helper_libtestdriver1_make_main "$loc_accel_list"
1153
1154 # We expect ECDH to be re-enabled for the missing curves
1155 grep mbedtls_ecdh_ library/ecdh.o
1156 # We expect ECP to be re-enabled, however the parts specific to the
1157 # families of curves that are accelerated should be ommited.
1158 # - functions with mxz in the name are specific to Montgomery curves
1159 # - ecp_muladd is specific to Weierstrass curves
1160 ##nm library/ecp.o | tee ecp.syms
1161 if [ $weierstrass -eq 1 ]; then
1162 not grep mbedtls_ecp_muladd library/ecp.o
1163 grep mxz library/ecp.o
1164 else
1165 grep mbedtls_ecp_muladd library/ecp.o
1166 not grep mxz library/ecp.o
1167 fi
1168 # We expect ECDSA and ECJPAKE to be re-enabled only when
1169 # Weierstrass curves are not accelerated
1170 if [ $weierstrass -eq 1 ]; then
1171 not grep mbedtls_ecdsa library/ecdsa.o
1172 not grep mbedtls_ecjpake library/ecjpake.o
1173 else
1174 grep mbedtls_ecdsa library/ecdsa.o
1175 grep mbedtls_ecjpake library/ecjpake.o
1176 fi
1177
1178 # Run the tests
1179 # -------------
1180
1181 msg "test suites: crypto_full minus PK with accelerated EC algs and $desc curves"
1182 make test
1183}
1184
1185component_test_psa_crypto_config_accel_ecc_weierstrass_curves () {
1186 common_test_psa_crypto_config_accel_ecc_some_curves 1
1187}
1188
1189component_test_psa_crypto_config_accel_ecc_non_weierstrass_curves () {
1190 common_test_psa_crypto_config_accel_ecc_some_curves 0
1191}
1192
1193# Auxiliary function to build config for all EC based algorithms (EC-JPAKE,
1194# ECDH, ECDSA) with and without drivers.
1195# The input parameter is a boolean value which indicates:
1196# - 0 keep built-in EC algs,
1197# - 1 exclude built-in EC algs (driver only).
1198#
1199# This is used by the two following components to ensure they always use the
1200# same config, except for the use of driver or built-in EC algorithms:
1201# - component_test_psa_crypto_config_accel_ecc_ecp_light_only;
1202# - component_test_psa_crypto_config_reference_ecc_ecp_light_only.
1203# This supports comparing their test coverage with analyze_outcomes.py.
1204config_psa_crypto_config_ecp_light_only () {
1205 driver_only="$1"
1206 # start with config full for maximum coverage (also enables USE_PSA)
1207 helper_libtestdriver1_adjust_config "full"
1208 if [ "$driver_only" -eq 1 ]; then
1209 # Disable modules that are accelerated
1210 scripts/config.py unset MBEDTLS_ECDSA_C
1211 scripts/config.py unset MBEDTLS_ECDH_C
1212 scripts/config.py unset MBEDTLS_ECJPAKE_C
1213 scripts/config.py unset MBEDTLS_ECP_C
1214 fi
1215
1216 # Restartable feature is not yet supported by PSA. Once it will in
1217 # the future, the following line could be removed (see issues
1218 # 6061, 6332 and following ones)
1219 scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
1220}
1221
1222# Keep in sync with component_test_psa_crypto_config_reference_ecc_ecp_light_only
1223component_test_psa_crypto_config_accel_ecc_ecp_light_only () {
1224 msg "build: full with accelerated EC algs"
1225
1226 # Algorithms and key types to accelerate
1227 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \
1228 ALG_ECDH \
1229 ALG_JPAKE \
1230 $(helper_get_psa_key_type_list "ECC") \
1231 $(helper_get_psa_curve_list)"
1232
1233 # Configure
1234 # ---------
1235
1236 # Use the same config as reference, only without built-in EC algs
1237 config_psa_crypto_config_ecp_light_only 1
1238
1239 # Do not disable builtin curves because that support is required for:
1240 # - MBEDTLS_PK_PARSE_EC_EXTENDED
1241 # - MBEDTLS_PK_PARSE_EC_COMPRESSED
1242
1243 # Build
1244 # -----
1245
1246 # These hashes are needed for some ECDSA signature tests.
1247 loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
1248 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
1249 helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list"
1250
1251 helper_libtestdriver1_make_main "$loc_accel_list"
1252
1253 # Make sure any built-in EC alg was not re-enabled by accident (additive config)
1254 not grep mbedtls_ecdsa_ library/ecdsa.o
1255 not grep mbedtls_ecdh_ library/ecdh.o
1256 not grep mbedtls_ecjpake_ library/ecjpake.o
1257 not grep mbedtls_ecp_mul library/ecp.o
1258
1259 # Run the tests
1260 # -------------
1261
1262 msg "test suites: full with accelerated EC algs"
1263 make test
1264
1265 msg "ssl-opt: full with accelerated EC algs"
1266 tests/ssl-opt.sh
1267}
1268
1269# Keep in sync with component_test_psa_crypto_config_accel_ecc_ecp_light_only
1270component_test_psa_crypto_config_reference_ecc_ecp_light_only () {
1271 msg "build: MBEDTLS_PSA_CRYPTO_CONFIG with non-accelerated EC algs"
1272
1273 config_psa_crypto_config_ecp_light_only 0
1274
1275 make
1276
1277 msg "test suites: full with non-accelerated EC algs"
1278 make test
1279
1280 msg "ssl-opt: full with non-accelerated EC algs"
1281 tests/ssl-opt.sh
1282}
1283
1284# This helper function is used by:
1285# - component_test_psa_crypto_config_accel_ecc_no_ecp_at_all()
1286# - component_test_psa_crypto_config_reference_ecc_no_ecp_at_all()
1287# to ensure that both tests use the same underlying configuration when testing
1288# driver's coverage with analyze_outcomes.py.
1289#
1290# This functions accepts 1 boolean parameter as follows:
1291# - 1: building with accelerated EC algorithms (ECDSA, ECDH, ECJPAKE), therefore
1292# excluding their built-in implementation as well as ECP_C & ECP_LIGHT
1293# - 0: include built-in implementation of EC algorithms.
1294#
1295# PK_C and RSA_C are always disabled to ensure there is no remaining dependency
1296# on the ECP module.
1297config_psa_crypto_no_ecp_at_all () {
1298 driver_only="$1"
1299 # start with full config for maximum coverage (also enables USE_PSA)
1300 helper_libtestdriver1_adjust_config "full"
1301
1302 if [ "$driver_only" -eq 1 ]; then
1303 # Disable modules that are accelerated
1304 scripts/config.py unset MBEDTLS_ECDSA_C
1305 scripts/config.py unset MBEDTLS_ECDH_C
1306 scripts/config.py unset MBEDTLS_ECJPAKE_C
1307 # Disable ECP module (entirely)
1308 scripts/config.py unset MBEDTLS_ECP_C
1309 fi
1310
1311 # Disable all the features that auto-enable ECP_LIGHT (see build_info.h)
1312 scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED
1313 scripts/config.py unset MBEDTLS_PK_PARSE_EC_COMPRESSED
1314 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE
1315
1316 # Restartable feature is not yet supported by PSA. Once it will in
1317 # the future, the following line could be removed (see issues
1318 # 6061, 6332 and following ones)
1319 scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
1320}
1321
1322# Build and test a configuration where driver accelerates all EC algs while
1323# all support and dependencies from ECP and ECP_LIGHT are removed on the library
1324# side.
1325#
1326# Keep in sync with component_test_psa_crypto_config_reference_ecc_no_ecp_at_all()
1327component_test_psa_crypto_config_accel_ecc_no_ecp_at_all () {
1328 msg "build: full + accelerated EC algs - ECP"
1329
1330 # Algorithms and key types to accelerate
1331 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \
1332 ALG_ECDH \
1333 ALG_JPAKE \
1334 $(helper_get_psa_key_type_list "ECC") \
1335 $(helper_get_psa_curve_list)"
1336
1337 # Configure
1338 # ---------
1339
1340 # Set common configurations between library's and driver's builds
1341 config_psa_crypto_no_ecp_at_all 1
1342 # Disable all the builtin curves. All the required algs are accelerated.
1343 helper_disable_builtin_curves
1344
1345 # Build
1346 # -----
1347
1348 # Things we wanted supported in libtestdriver1, but not accelerated in the main library:
1349 # SHA-1 and all SHA-2/3 variants, as they are used by ECDSA deterministic.
1350 loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
1351 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
1352
1353 helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list"
1354
1355 helper_libtestdriver1_make_main "$loc_accel_list"
1356
1357 # Make sure any built-in EC alg was not re-enabled by accident (additive config)
1358 not grep mbedtls_ecdsa_ library/ecdsa.o
1359 not grep mbedtls_ecdh_ library/ecdh.o
1360 not grep mbedtls_ecjpake_ library/ecjpake.o
1361 # Also ensure that ECP module was not re-enabled
1362 not grep mbedtls_ecp_ library/ecp.o
1363
1364 # Run the tests
1365 # -------------
1366
1367 msg "test: full + accelerated EC algs - ECP"
1368 make test
1369
1370 msg "ssl-opt: full + accelerated EC algs - ECP"
1371 tests/ssl-opt.sh
1372}
1373
1374# Reference function used for driver's coverage analysis in analyze_outcomes.py
1375# in conjunction with component_test_psa_crypto_config_accel_ecc_no_ecp_at_all().
1376# Keep in sync with its accelerated counterpart.
1377component_test_psa_crypto_config_reference_ecc_no_ecp_at_all () {
1378 msg "build: full + non accelerated EC algs"
1379
1380 config_psa_crypto_no_ecp_at_all 0
1381
1382 make
1383
1384 msg "test: full + non accelerated EC algs"
1385 make test
1386
1387 msg "ssl-opt: full + non accelerated EC algs"
1388 tests/ssl-opt.sh
1389}
1390
1391# This is a common configuration helper used directly from:
1392# - common_test_psa_crypto_config_accel_ecc_ffdh_no_bignum
1393# - common_test_psa_crypto_config_reference_ecc_ffdh_no_bignum
1394# and indirectly from:
1395# - component_test_psa_crypto_config_accel_ecc_no_bignum
1396# - accelerate all EC algs, disable RSA and FFDH
1397# - component_test_psa_crypto_config_reference_ecc_no_bignum
1398# - this is the reference component of the above
1399# - it still disables RSA and FFDH, but it uses builtin EC algs
1400# - component_test_psa_crypto_config_accel_ecc_ffdh_no_bignum
1401# - accelerate all EC and FFDH algs, disable only RSA
1402# - component_test_psa_crypto_config_reference_ecc_ffdh_no_bignum
1403# - this is the reference component of the above
1404# - it still disables RSA, but it uses builtin EC and FFDH algs
1405#
1406# This function accepts 2 parameters:
1407# $1: a boolean value which states if we are testing an accelerated scenario
1408# or not.
1409# $2: a string value which states which components are tested. Allowed values
1410# are "ECC" or "ECC_DH".
1411config_psa_crypto_config_accel_ecc_ffdh_no_bignum () {
1412 driver_only="$1"
1413 test_target="$2"
1414 # start with full config for maximum coverage (also enables USE_PSA)
1415 helper_libtestdriver1_adjust_config "full"
1416
1417 if [ "$driver_only" -eq 1 ]; then
1418 # Disable modules that are accelerated
1419 scripts/config.py unset MBEDTLS_ECDSA_C
1420 scripts/config.py unset MBEDTLS_ECDH_C
1421 scripts/config.py unset MBEDTLS_ECJPAKE_C
1422 # Disable ECP module (entirely)
1423 scripts/config.py unset MBEDTLS_ECP_C
1424 # Also disable bignum
1425 scripts/config.py unset MBEDTLS_BIGNUM_C
1426 fi
1427
1428 # Disable all the features that auto-enable ECP_LIGHT (see build_info.h)
1429 scripts/config.py unset MBEDTLS_PK_PARSE_EC_EXTENDED
1430 scripts/config.py unset MBEDTLS_PK_PARSE_EC_COMPRESSED
1431 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_DERIVE
1432
1433 # RSA support is intentionally disabled on this test because RSA_C depends
1434 # on BIGNUM_C.
1435 scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_KEY_TYPE_RSA_[0-9A-Z_a-z]*"
1436 scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_ALG_RSA_[0-9A-Z_a-z]*"
1437 scripts/config.py unset MBEDTLS_RSA_C
1438 scripts/config.py unset MBEDTLS_PKCS1_V15
1439 scripts/config.py unset MBEDTLS_PKCS1_V21
1440 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
1441 # Also disable key exchanges that depend on RSA
1442 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
1443 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
1444 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
1445 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
1446 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
1447
1448 if [ "$test_target" = "ECC" ]; then
1449 # When testing ECC only, we disable FFDH support, both from builtin and
1450 # PSA sides, and also disable the key exchanges that depend on DHM.
1451 scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_FFDH
1452 scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_KEY_TYPE_DH_[0-9A-Z_a-z]*"
1453 scripts/config.py -f "$CRYPTO_CONFIG_H" unset-all "PSA_WANT_DH_RFC7919_[0-9]*"
1454 scripts/config.py unset MBEDTLS_DHM_C
1455 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
1456 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
1457 else
1458 # When testing ECC and DH instead, we disable DHM and depending key
1459 # exchanges only in the accelerated build
1460 if [ "$driver_only" -eq 1 ]; then
1461 scripts/config.py unset MBEDTLS_DHM_C
1462 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
1463 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
1464 fi
1465 fi
1466
1467 # Restartable feature is not yet supported by PSA. Once it will in
1468 # the future, the following line could be removed (see issues
1469 # 6061, 6332 and following ones)
1470 scripts/config.py unset MBEDTLS_ECP_RESTARTABLE
1471}
1472
1473# Common helper used by:
1474# - component_test_psa_crypto_config_accel_ecc_no_bignum
1475# - component_test_psa_crypto_config_accel_ecc_ffdh_no_bignum
1476#
1477# The goal is to build and test accelerating either:
1478# - ECC only or
1479# - both ECC and FFDH
1480#
1481# It is meant to be used in conjunction with
1482# common_test_psa_crypto_config_reference_ecc_ffdh_no_bignum() for drivers
1483# coverage analysis in the "analyze_outcomes.py" script.
1484common_test_psa_crypto_config_accel_ecc_ffdh_no_bignum () {
1485 test_target="$1"
1486
1487 # This is an internal helper to simplify text message handling
1488 if [ "$test_target" = "ECC_DH" ]; then
1489 accel_text="ECC/FFDH"
1490 removed_text="ECP - DH"
1491 else
1492 accel_text="ECC"
1493 removed_text="ECP"
1494 fi
1495
1496 msg "build: full + accelerated $accel_text algs + USE_PSA - $removed_text - BIGNUM"
1497
1498 # By default we accelerate all EC keys/algs
1499 loc_accel_list="ALG_ECDSA ALG_DETERMINISTIC_ECDSA \
1500 ALG_ECDH \
1501 ALG_JPAKE \
1502 $(helper_get_psa_key_type_list "ECC") \
1503 $(helper_get_psa_curve_list)"
1504 # Optionally we can also add DH to the list of accelerated items
1505 if [ "$test_target" = "ECC_DH" ]; then
1506 loc_accel_list="$loc_accel_list \
1507 ALG_FFDH \
1508 $(helper_get_psa_key_type_list "DH") \
1509 $(helper_get_psa_dh_group_list)"
1510 fi
1511
1512 # Configure
1513 # ---------
1514
1515 # Set common configurations between library's and driver's builds
1516 config_psa_crypto_config_accel_ecc_ffdh_no_bignum 1 "$test_target"
1517 # Disable all the builtin curves. All the required algs are accelerated.
1518 helper_disable_builtin_curves
1519
1520 # Build
1521 # -----
1522
1523 # Things we wanted supported in libtestdriver1, but not accelerated in the main library:
1524 # SHA-1 and all SHA-2/3 variants, as they are used by ECDSA deterministic.
1525 loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
1526 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
1527
1528 helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list"
1529
1530 helper_libtestdriver1_make_main "$loc_accel_list"
1531
1532 # Make sure any built-in EC alg was not re-enabled by accident (additive config)
1533 not grep mbedtls_ecdsa_ library/ecdsa.o
1534 not grep mbedtls_ecdh_ library/ecdh.o
1535 not grep mbedtls_ecjpake_ library/ecjpake.o
1536 # Also ensure that ECP, RSA, [DHM] or BIGNUM modules were not re-enabled
1537 not grep mbedtls_ecp_ library/ecp.o
1538 not grep mbedtls_rsa_ library/rsa.o
1539 not grep mbedtls_mpi_ library/bignum.o
1540 not grep mbedtls_dhm_ library/dhm.o
1541
1542 # Run the tests
1543 # -------------
1544
1545 msg "test suites: full + accelerated $accel_text algs + USE_PSA - $removed_text - DHM - BIGNUM"
1546
1547 make test
1548
1549 msg "ssl-opt: full + accelerated $accel_text algs + USE_PSA - $removed_text - BIGNUM"
1550 tests/ssl-opt.sh
1551}
1552
1553# Common helper used by:
1554# - component_test_psa_crypto_config_reference_ecc_no_bignum
1555# - component_test_psa_crypto_config_reference_ecc_ffdh_no_bignum
1556#
1557# The goal is to build and test a reference scenario (i.e. with builtin
1558# components) compared to the ones used in
1559# common_test_psa_crypto_config_accel_ecc_ffdh_no_bignum() above.
1560#
1561# It is meant to be used in conjunction with
1562# common_test_psa_crypto_config_accel_ecc_ffdh_no_bignum() for drivers'
1563# coverage analysis in "analyze_outcomes.py" script.
1564common_test_psa_crypto_config_reference_ecc_ffdh_no_bignum () {
1565 test_target="$1"
1566
1567 # This is an internal helper to simplify text message handling
1568 if [ "$test_target" = "ECC_DH" ]; then
1569 accel_text="ECC/FFDH"
1570 else
1571 accel_text="ECC"
1572 fi
1573
1574 msg "build: full + non accelerated $accel_text algs + USE_PSA"
1575
1576 config_psa_crypto_config_accel_ecc_ffdh_no_bignum 0 "$test_target"
1577
1578 make
1579
1580 msg "test suites: full + non accelerated EC algs + USE_PSA"
1581 make test
1582
1583 msg "ssl-opt: full + non accelerated $accel_text algs + USE_PSA"
1584 tests/ssl-opt.sh
1585}
1586
1587component_test_psa_crypto_config_accel_ecc_no_bignum () {
1588 common_test_psa_crypto_config_accel_ecc_ffdh_no_bignum "ECC"
1589}
1590
1591component_test_psa_crypto_config_reference_ecc_no_bignum () {
1592 common_test_psa_crypto_config_reference_ecc_ffdh_no_bignum "ECC"
1593}
1594
1595component_test_psa_crypto_config_accel_ecc_ffdh_no_bignum () {
1596 common_test_psa_crypto_config_accel_ecc_ffdh_no_bignum "ECC_DH"
1597}
1598
1599component_test_psa_crypto_config_reference_ecc_ffdh_no_bignum () {
1600 common_test_psa_crypto_config_reference_ecc_ffdh_no_bignum "ECC_DH"
1601}
1602
1603# Helper for setting common configurations between:
1604# - component_test_tfm_config_p256m_driver_accel_ec()
1605# - component_test_tfm_config()
1606common_tfm_config () {
1607 # Enable TF-M config
1608 cp configs/config-tfm.h "$CONFIG_H"
1609 echo "#undef MBEDTLS_PSA_CRYPTO_CONFIG_FILE" >> "$CONFIG_H"
1610 cp configs/ext/crypto_config_profile_medium.h "$CRYPTO_CONFIG_H"
1611
1612 # Other config adjustment to make the tests pass.
1613 # This should probably be adopted upstream.
1614 #
1615 # - USE_PSA_CRYPTO for PK_HAVE_ECC_KEYS
1616 echo "#define MBEDTLS_USE_PSA_CRYPTO" >> "$CONFIG_H"
1617
1618 # Config adjustment for better test coverage in our environment.
1619 # This is not needed just to build and pass tests.
1620 #
1621 # Enable filesystem I/O for the benefit of PK parse/write tests.
1622 echo "#define MBEDTLS_FS_IO" >> "$CONFIG_H"
1623}
1624
1625# Keep this in sync with component_test_tfm_config() as they are both meant
1626# to be used in analyze_outcomes.py for driver's coverage analysis.
1627component_test_tfm_config_p256m_driver_accel_ec () {
1628 msg "build: TF-M config + p256m driver + accel ECDH(E)/ECDSA"
1629
1630 common_tfm_config
1631
1632 # Build crypto library
1633 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -I../tests/include/spe" LDFLAGS="$ASAN_CFLAGS"
1634
1635 # Make sure any built-in EC alg was not re-enabled by accident (additive config)
1636 not grep mbedtls_ecdsa_ library/ecdsa.o
1637 not grep mbedtls_ecdh_ library/ecdh.o
1638 not grep mbedtls_ecjpake_ library/ecjpake.o
1639 # Also ensure that ECP, RSA, DHM or BIGNUM modules were not re-enabled
1640 not grep mbedtls_ecp_ library/ecp.o
1641 not grep mbedtls_rsa_ library/rsa.o
1642 not grep mbedtls_dhm_ library/dhm.o
1643 not grep mbedtls_mpi_ library/bignum.o
1644 # Check that p256m was built
1645 grep -q p256_ecdsa_ library/libmbedcrypto.a
1646
1647 # In "config-tfm.h" we disabled CIPHER_C tweaking TF-M's configuration
1648 # files, so we want to ensure that it has not be re-enabled accidentally.
1649 not grep mbedtls_cipher library/cipher.o
1650
1651 # Run the tests
1652 msg "test: TF-M config + p256m driver + accel ECDH(E)/ECDSA"
1653 make test
1654}
1655
1656# Keep this in sync with component_test_tfm_config_p256m_driver_accel_ec() as
1657# they are both meant to be used in analyze_outcomes.py for driver's coverage
1658# analysis.
1659component_test_tfm_config () {
1660 common_tfm_config
1661
1662 # Disable P256M driver, which is on by default, so that analyze_outcomes
1663 # can compare this test with test_tfm_config_p256m_driver_accel_ec
1664 echo "#undef MBEDTLS_PSA_P256M_DRIVER_ENABLED" >> "$CONFIG_H"
1665
1666 msg "build: TF-M config"
1667 make CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' tests
1668
1669 # Check that p256m was not built
1670 not grep p256_ecdsa_ library/libmbedcrypto.a
1671
1672 # In "config-tfm.h" we disabled CIPHER_C tweaking TF-M's configuration
1673 # files, so we want to ensure that it has not be re-enabled accidentally.
1674 not grep mbedtls_cipher library/cipher.o
1675
1676 msg "test: TF-M config"
1677 make test
1678}
1679
1680# This is an helper used by:
1681# - component_test_psa_ecc_key_pair_no_derive
1682# - component_test_psa_ecc_key_pair_no_generate
1683# The goal is to test with all PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_yyy symbols
1684# enabled, but one. Input arguments are as follows:
1685# - $1 is the key type under test, i.e. ECC/RSA/DH
1686# - $2 is the key option to be unset (i.e. generate, derive, etc)
1687build_and_test_psa_want_key_pair_partial () {
1688 key_type=$1
1689 unset_option=$2
1690 disabled_psa_want="PSA_WANT_KEY_TYPE_${key_type}_KEY_PAIR_${unset_option}"
1691
1692 msg "build: full - MBEDTLS_USE_PSA_CRYPTO - ${disabled_psa_want}"
1693 scripts/config.py full
1694 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1695 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
1696
1697 # All the PSA_WANT_KEY_TYPE_xxx_KEY_PAIR_yyy are enabled by default in
1698 # crypto_config.h so we just disable the one we don't want.
1699 scripts/config.py -f "$CRYPTO_CONFIG_H" unset "$disabled_psa_want"
1700
1701 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
1702
1703 msg "test: full - MBEDTLS_USE_PSA_CRYPTO - ${disabled_psa_want}"
1704 make test
1705}
1706
1707component_test_psa_ecc_key_pair_no_derive () {
1708 build_and_test_psa_want_key_pair_partial "ECC" "DERIVE"
1709}
1710
1711component_test_psa_ecc_key_pair_no_generate () {
1712 build_and_test_psa_want_key_pair_partial "ECC" "GENERATE"
1713}
1714
1715config_psa_crypto_accel_rsa () {
1716 driver_only=$1
1717
1718 # Start from crypto_full config (no X.509, no TLS)
1719 helper_libtestdriver1_adjust_config "crypto_full"
1720
1721 if [ "$driver_only" -eq 1 ]; then
1722 # Remove RSA support and its dependencies
1723 scripts/config.py unset MBEDTLS_RSA_C
1724 scripts/config.py unset MBEDTLS_PKCS1_V15
1725 scripts/config.py unset MBEDTLS_PKCS1_V21
1726
1727 # We need PEM parsing in the test library as well to support the import
1728 # of PEM encoded RSA keys.
1729 scripts/config.py -f "$CONFIG_TEST_DRIVER_H" set MBEDTLS_PEM_PARSE_C
1730 scripts/config.py -f "$CONFIG_TEST_DRIVER_H" set MBEDTLS_BASE64_C
1731 fi
1732}
1733
1734component_test_psa_crypto_config_accel_rsa_crypto () {
1735 msg "build: crypto_full with accelerated RSA"
1736
1737 loc_accel_list="ALG_RSA_OAEP ALG_RSA_PSS \
1738 ALG_RSA_PKCS1V15_CRYPT ALG_RSA_PKCS1V15_SIGN \
1739 KEY_TYPE_RSA_PUBLIC_KEY \
1740 KEY_TYPE_RSA_KEY_PAIR_BASIC \
1741 KEY_TYPE_RSA_KEY_PAIR_GENERATE \
1742 KEY_TYPE_RSA_KEY_PAIR_IMPORT \
1743 KEY_TYPE_RSA_KEY_PAIR_EXPORT"
1744
1745 # Configure
1746 # ---------
1747
1748 config_psa_crypto_accel_rsa 1
1749
1750 # Build
1751 # -----
1752
1753 # These hashes are needed for unit tests.
1754 loc_extra_list="ALG_SHA_1 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
1755 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512 ALG_MD5"
1756 helper_libtestdriver1_make_drivers "$loc_accel_list" "$loc_extra_list"
1757
1758 helper_libtestdriver1_make_main "$loc_accel_list"
1759
1760 # Make sure this was not re-enabled by accident (additive config)
1761 not grep mbedtls_rsa library/rsa.o
1762
1763 # Run the tests
1764 # -------------
1765
1766 msg "test: crypto_full with accelerated RSA"
1767 make test
1768}
1769
1770component_test_psa_crypto_config_reference_rsa_crypto () {
1771 msg "build: crypto_full with non-accelerated RSA"
1772
1773 # Configure
1774 # ---------
1775 config_psa_crypto_accel_rsa 0
1776
1777 # Build
1778 # -----
1779 make
1780
1781 # Run the tests
1782 # -------------
1783 msg "test: crypto_full with non-accelerated RSA"
1784 make test
1785}
1786
1787# This is a temporary test to verify that full RSA support is present even when
1788# only one single new symbols (PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC) is defined.
1789component_test_new_psa_want_key_pair_symbol () {
1790 msg "Build: crypto config - MBEDTLS_RSA_C + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC"
1791
1792 # Create a temporary output file unless there is already one set
1793 if [ "$MBEDTLS_TEST_OUTCOME_FILE" ]; then
1794 REMOVE_OUTCOME_ON_EXIT="no"
1795 else
1796 REMOVE_OUTCOME_ON_EXIT="yes"
1797 MBEDTLS_TEST_OUTCOME_FILE="$PWD/out.csv"
1798 export MBEDTLS_TEST_OUTCOME_FILE
1799 fi
1800
1801 # Start from crypto configuration
1802 scripts/config.py crypto
1803
1804 # Remove RSA support and its dependencies
1805 scripts/config.py unset MBEDTLS_PKCS1_V15
1806 scripts/config.py unset MBEDTLS_PKCS1_V21
1807 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
1808 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
1809 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
1810 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
1811 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
1812 scripts/config.py unset MBEDTLS_RSA_C
1813 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
1814
1815 # Enable PSA support
1816 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
1817
1818 # Keep only PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC enabled in order to ensure
1819 # that proper translations is done in crypto_legacy.h.
1820 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT
1821 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT
1822 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE
1823
1824 make
1825
1826 msg "Test: crypto config - MBEDTLS_RSA_C + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC"
1827 make test
1828
1829 # Parse only 1 relevant line from the outcome file, i.e. a test which is
1830 # performing RSA signature.
1831 msg "Verify that 'RSA PKCS1 Sign #1 (SHA512, 1536 bits RSA)' is PASS"
1832 cat $MBEDTLS_TEST_OUTCOME_FILE | grep 'RSA PKCS1 Sign #1 (SHA512, 1536 bits RSA)' | grep -q "PASS"
1833
1834 if [ "$REMOVE_OUTCOME_ON_EXIT" == "yes" ]; then
1835 rm $MBEDTLS_TEST_OUTCOME_FILE
1836 fi
1837}
1838
1839component_test_psa_crypto_config_accel_hash () {
1840 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
1841
1842 loc_accel_list="ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 \
1843 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
1844 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
1845
1846 # Configure
1847 # ---------
1848
1849 # Start from default config (no USE_PSA)
1850 helper_libtestdriver1_adjust_config "default"
1851
1852 # Disable the things that are being accelerated
1853 scripts/config.py unset MBEDTLS_MD5_C
1854 scripts/config.py unset MBEDTLS_RIPEMD160_C
1855 scripts/config.py unset MBEDTLS_SHA1_C
1856 scripts/config.py unset MBEDTLS_SHA224_C
1857 scripts/config.py unset MBEDTLS_SHA256_C
1858 scripts/config.py unset MBEDTLS_SHA384_C
1859 scripts/config.py unset MBEDTLS_SHA512_C
1860 scripts/config.py unset MBEDTLS_SHA3_C
1861
1862 # Build
1863 # -----
1864
1865 helper_libtestdriver1_make_drivers "$loc_accel_list"
1866
1867 helper_libtestdriver1_make_main "$loc_accel_list"
1868
1869 # There's a risk of something getting re-enabled via config_psa.h;
1870 # make sure it did not happen. Note: it's OK for MD_C to be enabled.
1871 not grep mbedtls_md5 library/md5.o
1872 not grep mbedtls_sha1 library/sha1.o
1873 not grep mbedtls_sha256 library/sha256.o
1874 not grep mbedtls_sha512 library/sha512.o
1875 not grep mbedtls_ripemd160 library/ripemd160.o
1876
1877 # Run the tests
1878 # -------------
1879
1880 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
1881 make test
1882}
1883
Minos Galanakis5f6d2e32024-08-01 23:19:50 +01001884component_test_psa_crypto_config_accel_hash_keep_builtins () {
1885 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated+builtin hash"
1886 # This component ensures that all the test cases for
1887 # md_psa_dynamic_dispatch with legacy+driver in test_suite_md are run.
1888
1889 loc_accel_list="ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 \
1890 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
1891 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
1892
1893 # Start from default config (no USE_PSA)
1894 helper_libtestdriver1_adjust_config "default"
1895
1896 helper_libtestdriver1_make_drivers "$loc_accel_list"
1897
1898 helper_libtestdriver1_make_main "$loc_accel_list"
1899
1900 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated+builtin hash"
1901 make test
1902}
1903
1904# This should be renamed to test and updated once the accelerator ECDH code is in place and ready to test.
1905component_build_psa_accel_alg_ecdh () {
1906 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_ECDH without MBEDTLS_ECDH_C"
1907 scripts/config.py full
1908 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1909 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
1910 scripts/config.py unset MBEDTLS_ECDH_C
1911 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
1912 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
1913 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
1914 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
1915 scripts/config.py unset MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
1916 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1917 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_ECDH -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
1918}
1919
1920# This should be renamed to test and updated once the accelerator HMAC code is in place and ready to test.
1921component_build_psa_accel_alg_hmac () {
1922 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HMAC"
1923 scripts/config.py full
1924 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1925 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
1926 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1927 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HMAC -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
1928}
1929
1930# This should be renamed to test and updated once the accelerator HKDF code is in place and ready to test.
1931component_build_psa_accel_alg_hkdf () {
1932 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_HKDF without MBEDTLS_HKDF_C"
1933 scripts/config.py full
1934 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1935 scripts/config.py unset MBEDTLS_HKDF_C
1936 # Make sure to unset TLS1_3 since it requires HKDF_C and will not build properly without it.
1937 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
1938 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1939 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_HKDF -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
1940}
1941
1942# This should be renamed to test and updated once the accelerator MD5 code is in place and ready to test.
1943component_build_psa_accel_alg_md5 () {
1944 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_MD5 - other hashes"
1945 scripts/config.py full
1946 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1947 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
1948 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160
1949 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1
1950 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224
1951 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256
1952 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384
1953 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512
1954 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS
1955 scripts/config.py unset MBEDTLS_LMS_C
1956 scripts/config.py unset MBEDTLS_LMS_PRIVATE
1957 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1958 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_MD5 -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
1959}
1960
1961# This should be renamed to test and updated once the accelerator RIPEMD160 code is in place and ready to test.
1962component_build_psa_accel_alg_ripemd160 () {
1963 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RIPEMD160 - other hashes"
1964 scripts/config.py full
1965 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1966 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
1967 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5
1968 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1
1969 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224
1970 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256
1971 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384
1972 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512
1973 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS
1974 scripts/config.py unset MBEDTLS_LMS_C
1975 scripts/config.py unset MBEDTLS_LMS_PRIVATE
1976 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1977 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RIPEMD160 -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
1978}
1979
1980# This should be renamed to test and updated once the accelerator SHA1 code is in place and ready to test.
1981component_build_psa_accel_alg_sha1 () {
1982 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_1 - other hashes"
1983 scripts/config.py full
1984 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
1985 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
1986 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5
1987 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160
1988 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224
1989 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256
1990 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384
1991 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512
1992 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS
1993 scripts/config.py unset MBEDTLS_LMS_C
1994 scripts/config.py unset MBEDTLS_LMS_PRIVATE
1995 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
1996 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_1 -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
1997}
1998
1999# This should be renamed to test and updated once the accelerator SHA224 code is in place and ready to test.
2000component_build_psa_accel_alg_sha224 () {
2001 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_224 - other hashes"
2002 scripts/config.py full
2003 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2004 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2005 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5
2006 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160
2007 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1
2008 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384
2009 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512
2010 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS
2011 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2012 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_224 -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
2013}
2014
2015# This should be renamed to test and updated once the accelerator SHA256 code is in place and ready to test.
2016component_build_psa_accel_alg_sha256 () {
2017 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_256 - other hashes"
2018 scripts/config.py full
2019 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2020 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2021 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5
2022 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160
2023 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1
2024 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224
2025 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384
2026 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_512
2027 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2028 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_256 -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
2029}
2030
2031# This should be renamed to test and updated once the accelerator SHA384 code is in place and ready to test.
2032component_build_psa_accel_alg_sha384 () {
2033 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_384 - other hashes"
2034 scripts/config.py full
2035 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2036 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2037 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5
2038 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160
2039 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1
2040 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224
2041 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256
2042 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS
2043 scripts/config.py unset MBEDTLS_LMS_C
2044 scripts/config.py unset MBEDTLS_LMS_PRIVATE
2045 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2046 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_384 -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
2047}
2048
2049# This should be renamed to test and updated once the accelerator SHA512 code is in place and ready to test.
2050component_build_psa_accel_alg_sha512 () {
2051 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_SHA_512 - other hashes"
2052 scripts/config.py full
2053 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2054 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2055 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_MD5
2056 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RIPEMD160
2057 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_1
2058 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_224
2059 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_256
2060 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_SHA_384
2061 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_TLS12_ECJPAKE_TO_PMS
2062 scripts/config.py unset MBEDTLS_LMS_C
2063 scripts/config.py unset MBEDTLS_LMS_PRIVATE
2064 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2065 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_SHA_512 -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
2066}
2067
2068# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
2069component_build_psa_accel_alg_rsa_pkcs1v15_crypt () {
2070 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PKCS1V15_CRYPT + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
2071 scripts/config.py full
2072 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2073 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2074 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PKCS1V15_CRYPT 1
2075 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2076 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP
2077 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS
2078 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2079 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_CRYPT -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
2080}
2081
2082# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
2083component_build_psa_accel_alg_rsa_pkcs1v15_sign () {
2084 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PKCS1V15_SIGN + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
2085 scripts/config.py full
2086 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2087 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2088 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PKCS1V15_SIGN 1
2089 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2090 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP
2091 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS
2092 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2093 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PKCS1V15_SIGN -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
2094}
2095
2096# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
2097component_build_psa_accel_alg_rsa_oaep () {
2098 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_OAEP + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
2099 scripts/config.py full
2100 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2101 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2102 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_OAEP 1
2103 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2104 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2105 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PSS
2106 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2107 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_OAEP -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
2108}
2109
2110# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
2111component_build_psa_accel_alg_rsa_pss () {
2112 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_ALG_RSA_PSS + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY"
2113 scripts/config.py full
2114 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2115 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2116 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1
2117 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_CRYPT
2118 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_PKCS1V15_SIGN
2119 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_RSA_OAEP
2120 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2121 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_PSA_ACCEL_ALG_RSA_PSS -I../tests/include" LDFLAGS="$ASAN_CFLAGS"
2122}
2123
2124# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
2125component_build_psa_accel_key_type_rsa_key_pair () {
2126 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_xxx + PSA_WANT_ALG_RSA_PSS"
2127 scripts/config.py full
2128 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2129 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2130 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1
2131 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC 1
2132 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_IMPORT 1
2133 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_EXPORT 1
2134 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_GENERATE 1
2135 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2136 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"
2137}
2138
2139# This should be renamed to test and updated once the accelerator RSA code is in place and ready to test.
2140component_build_psa_accel_key_type_rsa_public_key () {
2141 msg "build: full - MBEDTLS_USE_PSA_CRYPTO + PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY + PSA_WANT_ALG_RSA_PSS"
2142 scripts/config.py full
2143 scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO
2144 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
2145 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_ALG_RSA_PSS 1
2146 scripts/config.py -f "$CRYPTO_CONFIG_H" set PSA_WANT_KEY_TYPE_RSA_PUBLIC_KEY 1
2147 # Need to define the correct symbol and include the test driver header path in order to build with the test driver
2148 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"
2149}
2150
Minos Galanakis3ece57e2024-08-01 17:09:49 +01002151# Auxiliary function to build config for hashes with and without drivers
2152config_psa_crypto_hash_use_psa () {
2153 driver_only="$1"
2154 # start with config full for maximum coverage (also enables USE_PSA)
2155 helper_libtestdriver1_adjust_config "full"
2156 if [ "$driver_only" -eq 1 ]; then
2157 # disable the built-in implementation of hashes
2158 scripts/config.py unset MBEDTLS_MD5_C
2159 scripts/config.py unset MBEDTLS_RIPEMD160_C
2160 scripts/config.py unset MBEDTLS_SHA1_C
2161 scripts/config.py unset MBEDTLS_SHA224_C
2162 scripts/config.py unset MBEDTLS_SHA256_C # see external RNG below
2163 scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
2164 scripts/config.py unset MBEDTLS_SHA384_C
2165 scripts/config.py unset MBEDTLS_SHA512_C
2166 scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT
2167 scripts/config.py unset MBEDTLS_SHA3_C
2168 fi
2169}
2170
2171# Note that component_test_psa_crypto_config_reference_hash_use_psa
2172# is related to this component and both components need to be kept in sync.
2173# For details please see comments for component_test_psa_crypto_config_reference_hash_use_psa.
2174component_test_psa_crypto_config_accel_hash_use_psa () {
2175 msg "test: full with accelerated hashes"
2176
2177 loc_accel_list="ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 \
2178 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
2179 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
2180
2181 # Configure
2182 # ---------
2183
2184 config_psa_crypto_hash_use_psa 1
2185
2186 # Build
2187 # -----
2188
2189 helper_libtestdriver1_make_drivers "$loc_accel_list"
2190
2191 helper_libtestdriver1_make_main "$loc_accel_list"
2192
2193 # There's a risk of something getting re-enabled via config_psa.h;
2194 # make sure it did not happen. Note: it's OK for MD_C to be enabled.
2195 not grep mbedtls_md5 library/md5.o
2196 not grep mbedtls_sha1 library/sha1.o
2197 not grep mbedtls_sha256 library/sha256.o
2198 not grep mbedtls_sha512 library/sha512.o
2199 not grep mbedtls_ripemd160 library/ripemd160.o
2200
2201 # Run the tests
2202 # -------------
2203
2204 msg "test: full with accelerated hashes"
2205 make test
2206
2207 # This is mostly useful so that we can later compare outcome files with
2208 # the reference config in analyze_outcomes.py, to check that the
2209 # dependency declarations in ssl-opt.sh and in TLS code are correct.
2210 msg "test: ssl-opt.sh, full with accelerated hashes"
2211 tests/ssl-opt.sh
2212
2213 # This is to make sure all ciphersuites are exercised, but we don't need
2214 # interop testing (besides, we already got some from ssl-opt.sh).
2215 msg "test: compat.sh, full with accelerated hashes"
2216 tests/compat.sh -p mbedTLS -V YES
2217}
2218
2219# This component provides reference configuration for test_psa_crypto_config_accel_hash_use_psa
2220# without accelerated hash. The outcome from both components are used by the analyze_outcomes.py
2221# script to find regression in test coverage when accelerated hash is used (tests and ssl-opt).
2222# Both components need to be kept in sync.
2223component_test_psa_crypto_config_reference_hash_use_psa () {
2224 msg "test: full without accelerated hashes"
2225
2226 config_psa_crypto_hash_use_psa 0
2227
2228 make
2229
2230 msg "test: full without accelerated hashes"
2231 make test
2232
2233 msg "test: ssl-opt.sh, full without accelerated hashes"
2234 tests/ssl-opt.sh
2235}
2236
2237# Auxiliary function to build config for hashes with and without drivers
2238config_psa_crypto_hmac_use_psa () {
2239 driver_only="$1"
2240 # start with config full for maximum coverage (also enables USE_PSA)
2241 helper_libtestdriver1_adjust_config "full"
2242
2243 if [ "$driver_only" -eq 1 ]; then
2244 # Disable MD_C in order to disable the builtin support for HMAC. MD_LIGHT
2245 # is still enabled though (for ENTROPY_C among others).
2246 scripts/config.py unset MBEDTLS_MD_C
2247 # Disable also the builtin hashes since they are supported by the driver
2248 # and MD module is able to perform PSA dispathing.
2249 scripts/config.py unset-all MBEDTLS_SHA
2250 scripts/config.py unset MBEDTLS_MD5_C
2251 scripts/config.py unset MBEDTLS_RIPEMD160_C
2252 fi
2253
2254 # Direct dependencies of MD_C. We disable them also in the reference
2255 # component to work with the same set of features.
2256 scripts/config.py unset MBEDTLS_PKCS7_C
2257 scripts/config.py unset MBEDTLS_PKCS5_C
2258 scripts/config.py unset MBEDTLS_HMAC_DRBG_C
2259 scripts/config.py unset MBEDTLS_HKDF_C
2260 # Dependencies of HMAC_DRBG
2261 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC
2262 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_DETERMINISTIC_ECDSA
2263}
2264
2265component_test_psa_crypto_config_accel_hmac () {
2266 msg "test: full with accelerated hmac"
2267
2268 loc_accel_list="ALG_HMAC KEY_TYPE_HMAC \
2269 ALG_MD5 ALG_RIPEMD160 ALG_SHA_1 \
2270 ALG_SHA_224 ALG_SHA_256 ALG_SHA_384 ALG_SHA_512 \
2271 ALG_SHA3_224 ALG_SHA3_256 ALG_SHA3_384 ALG_SHA3_512"
2272
2273 # Configure
2274 # ---------
2275
2276 config_psa_crypto_hmac_use_psa 1
2277
2278 # Build
2279 # -----
2280
2281 helper_libtestdriver1_make_drivers "$loc_accel_list"
2282
2283 helper_libtestdriver1_make_main "$loc_accel_list"
2284
2285 # Ensure that built-in support for HMAC is disabled.
2286 not grep mbedtls_md_hmac library/md.o
2287
2288 # Run the tests
2289 # -------------
2290
2291 msg "test: full with accelerated hmac"
2292 make test
2293}
2294
2295component_test_psa_crypto_config_reference_hmac () {
2296 msg "test: full without accelerated hmac"
2297
2298 config_psa_crypto_hmac_use_psa 0
2299
2300 make
2301
2302 msg "test: full without accelerated hmac"
2303 make test
2304}
2305
2306component_test_psa_crypto_config_accel_des () {
2307 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated DES"
2308
2309 # Albeit this components aims at accelerating DES which should only support
2310 # CBC and ECB modes, we need to accelerate more than that otherwise DES_C
2311 # would automatically be re-enabled by "config_adjust_legacy_from_psa.c"
2312 loc_accel_list="ALG_ECB_NO_PADDING ALG_CBC_NO_PADDING ALG_CBC_PKCS7 \
2313 ALG_CTR ALG_CFB ALG_OFB ALG_XTS ALG_CMAC \
2314 KEY_TYPE_DES"
2315
2316 # Note: we cannot accelerate all ciphers' key types otherwise we would also
2317 # have to either disable CCM/GCM or accelerate them, but that's out of scope
2318 # of this component. This limitation will be addressed by #8598.
2319
2320 # Configure
2321 # ---------
2322
2323 # Start from the full config
2324 helper_libtestdriver1_adjust_config "full"
2325
2326 # Disable the things that are being accelerated
2327 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2328 scripts/config.py unset MBEDTLS_CIPHER_PADDING_PKCS7
2329 scripts/config.py unset MBEDTLS_CIPHER_MODE_CTR
2330 scripts/config.py unset MBEDTLS_CIPHER_MODE_CFB
2331 scripts/config.py unset MBEDTLS_CIPHER_MODE_OFB
2332 scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
2333 scripts/config.py unset MBEDTLS_DES_C
2334 scripts/config.py unset MBEDTLS_CMAC_C
2335
2336 # Build
2337 # -----
2338
2339 helper_libtestdriver1_make_drivers "$loc_accel_list"
2340
2341 helper_libtestdriver1_make_main "$loc_accel_list"
2342
2343 # Make sure this was not re-enabled by accident (additive config)
2344 not grep mbedtls_des* library/des.o
2345
2346 # Run the tests
2347 # -------------
2348
2349 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated DES"
2350 make test
2351}
2352
2353component_test_psa_crypto_config_accel_aead () {
2354 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD"
2355
2356 loc_accel_list="ALG_GCM ALG_CCM ALG_CHACHA20_POLY1305 \
2357 KEY_TYPE_AES KEY_TYPE_CHACHA20 KEY_TYPE_ARIA KEY_TYPE_CAMELLIA"
2358
2359 # Configure
2360 # ---------
2361
2362 # Start from full config
2363 helper_libtestdriver1_adjust_config "full"
2364
2365 # Disable things that are being accelerated
2366 scripts/config.py unset MBEDTLS_GCM_C
2367 scripts/config.py unset MBEDTLS_CCM_C
2368 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2369
2370 # Disable CCM_STAR_NO_TAG because this re-enables CCM_C.
2371 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CCM_STAR_NO_TAG
2372
2373 # Build
2374 # -----
2375
2376 helper_libtestdriver1_make_drivers "$loc_accel_list"
2377
2378 helper_libtestdriver1_make_main "$loc_accel_list"
2379
2380 # Make sure this was not re-enabled by accident (additive config)
2381 not grep mbedtls_ccm library/ccm.o
2382 not grep mbedtls_gcm library/gcm.o
2383 not grep mbedtls_chachapoly library/chachapoly.o
2384
2385 # Run the tests
2386 # -------------
2387
2388 msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated AEAD"
2389 make test
2390}
2391
2392# This is a common configuration function used in:
2393# - component_test_psa_crypto_config_accel_cipher_aead_cmac
2394# - component_test_psa_crypto_config_reference_cipher_aead_cmac
2395common_psa_crypto_config_accel_cipher_aead_cmac () {
2396 # Start from the full config
2397 helper_libtestdriver1_adjust_config "full"
2398
2399 scripts/config.py unset MBEDTLS_NIST_KW_C
2400}
2401
2402# The 2 following test components, i.e.
2403# - component_test_psa_crypto_config_accel_cipher_aead_cmac
2404# - component_test_psa_crypto_config_reference_cipher_aead_cmac
2405# are meant to be used together in analyze_outcomes.py script in order to test
2406# driver's coverage for ciphers and AEADs.
2407component_test_psa_crypto_config_accel_cipher_aead_cmac () {
2408 msg "build: full config with accelerated cipher inc. AEAD and CMAC"
2409
2410 loc_accel_list="ALG_ECB_NO_PADDING ALG_CBC_NO_PADDING ALG_CBC_PKCS7 ALG_CTR ALG_CFB \
2411 ALG_OFB ALG_XTS ALG_STREAM_CIPHER ALG_CCM_STAR_NO_TAG \
2412 ALG_GCM ALG_CCM ALG_CHACHA20_POLY1305 ALG_CMAC \
2413 KEY_TYPE_DES KEY_TYPE_AES KEY_TYPE_ARIA KEY_TYPE_CHACHA20 KEY_TYPE_CAMELLIA"
2414
2415 # Configure
2416 # ---------
2417
2418 common_psa_crypto_config_accel_cipher_aead_cmac
2419
2420 # Disable the things that are being accelerated
2421 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2422 scripts/config.py unset MBEDTLS_CIPHER_PADDING_PKCS7
2423 scripts/config.py unset MBEDTLS_CIPHER_MODE_CTR
2424 scripts/config.py unset MBEDTLS_CIPHER_MODE_CFB
2425 scripts/config.py unset MBEDTLS_CIPHER_MODE_OFB
2426 scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
2427 scripts/config.py unset MBEDTLS_GCM_C
2428 scripts/config.py unset MBEDTLS_CCM_C
2429 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2430 scripts/config.py unset MBEDTLS_CMAC_C
2431 scripts/config.py unset MBEDTLS_DES_C
2432 scripts/config.py unset MBEDTLS_AES_C
2433 scripts/config.py unset MBEDTLS_ARIA_C
2434 scripts/config.py unset MBEDTLS_CHACHA20_C
2435 scripts/config.py unset MBEDTLS_CAMELLIA_C
2436
2437 # Disable CIPHER_C entirely as all ciphers/AEADs are accelerated and PSA
2438 # does not depend on it.
2439 scripts/config.py unset MBEDTLS_CIPHER_C
2440
2441 # Build
2442 # -----
2443
2444 helper_libtestdriver1_make_drivers "$loc_accel_list"
2445
2446 helper_libtestdriver1_make_main "$loc_accel_list"
2447
2448 # Make sure this was not re-enabled by accident (additive config)
2449 not grep mbedtls_cipher library/cipher.o
2450 not grep mbedtls_des library/des.o
2451 not grep mbedtls_aes library/aes.o
2452 not grep mbedtls_aria library/aria.o
2453 not grep mbedtls_camellia library/camellia.o
2454 not grep mbedtls_ccm library/ccm.o
2455 not grep mbedtls_gcm library/gcm.o
2456 not grep mbedtls_chachapoly library/chachapoly.o
2457 not grep mbedtls_cmac library/cmac.o
2458
2459 # Run the tests
2460 # -------------
2461
2462 msg "test: full config with accelerated cipher inc. AEAD and CMAC"
2463 make test
2464
2465 msg "ssl-opt: full config with accelerated cipher inc. AEAD and CMAC"
2466 tests/ssl-opt.sh
2467
2468 msg "compat.sh: full config with accelerated cipher inc. AEAD and CMAC"
2469 tests/compat.sh -V NO -p mbedTLS
2470}
2471
2472component_test_psa_crypto_config_reference_cipher_aead_cmac () {
2473 msg "build: full config with non-accelerated cipher inc. AEAD and CMAC"
2474 common_psa_crypto_config_accel_cipher_aead_cmac
2475
2476 make
2477
2478 msg "test: full config with non-accelerated cipher inc. AEAD and CMAC"
2479 make test
2480
2481 msg "ssl-opt: full config with non-accelerated cipher inc. AEAD and CMAC"
2482 tests/ssl-opt.sh
2483
2484 msg "compat.sh: full config with non-accelerated cipher inc. AEAD and CMAC"
2485 tests/compat.sh -V NO -p mbedTLS
2486}
2487
2488common_block_cipher_dispatch () {
2489 TEST_WITH_DRIVER="$1"
2490
2491 # Start from the full config
2492 helper_libtestdriver1_adjust_config "full"
2493
2494 if [ "$TEST_WITH_DRIVER" -eq 1 ]; then
2495 # Disable key types that are accelerated (there is no legacy equivalent
2496 # symbol for ECB)
2497 scripts/config.py unset MBEDTLS_AES_C
2498 scripts/config.py unset MBEDTLS_ARIA_C
2499 scripts/config.py unset MBEDTLS_CAMELLIA_C
2500 fi
2501
2502 # Disable cipher's modes that, when not accelerated, cause
2503 # legacy key types to be re-enabled in "config_adjust_legacy_from_psa.h".
2504 # Keep this also in the reference component in order to skip the same tests
2505 # that were skipped in the accelerated one.
2506 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CTR
2507 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CFB
2508 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_OFB
2509 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CBC_NO_PADDING
2510 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CBC_PKCS7
2511 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CMAC
2512 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CCM_STAR_NO_TAG
2513 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128
2514
2515 # Disable direct dependency on AES_C
2516 scripts/config.py unset MBEDTLS_NIST_KW_C
2517
2518 # Prevent the cipher module from using deprecated PSA path. The reason is
2519 # that otherwise there will be tests relying on "aes_info" (defined in
2520 # "cipher_wrap.c") whose functions are not available when AES_C is
2521 # not defined. ARIA and Camellia are not a problem in this case because
2522 # the PSA path is not tested for these key types.
2523 scripts/config.py set MBEDTLS_DEPRECATED_REMOVED
2524}
2525
Gilles Peskine9dc903a2024-06-21 11:25:01 +02002526component_test_full_block_cipher_psa_dispatch_static_keystore () {
2527 msg "build: full + PSA dispatch in block_cipher with static keystore"
2528 # Check that the static key store works well when CTR_DRBG uses a
2529 # PSA key for AES.
2530 scripts/config.py unset MBEDTLS_PSA_KEY_STORE_DYNAMIC
2531
2532 loc_accel_list="ALG_ECB_NO_PADDING \
2533 KEY_TYPE_AES KEY_TYPE_ARIA KEY_TYPE_CAMELLIA"
2534
2535 # Configure
2536 # ---------
2537
2538 common_block_cipher_dispatch 1
2539
2540 # Build
2541 # -----
2542
2543 helper_libtestdriver1_make_drivers "$loc_accel_list"
2544
2545 helper_libtestdriver1_make_main "$loc_accel_list"
2546
2547 # Make sure disabled components were not re-enabled by accident (additive
2548 # config)
2549 not grep mbedtls_aes_ library/aes.o
2550 not grep mbedtls_aria_ library/aria.o
2551 not grep mbedtls_camellia_ library/camellia.o
2552
2553 # Run the tests
2554 # -------------
2555
2556 msg "test: full + PSA dispatch in block_cipher with static keystore"
2557 make test
2558}
2559
Minos Galanakis3ece57e2024-08-01 17:09:49 +01002560component_test_full_block_cipher_psa_dispatch () {
2561 msg "build: full + PSA dispatch in block_cipher"
2562
2563 loc_accel_list="ALG_ECB_NO_PADDING \
2564 KEY_TYPE_AES KEY_TYPE_ARIA KEY_TYPE_CAMELLIA"
2565
2566 # Configure
2567 # ---------
2568
2569 common_block_cipher_dispatch 1
2570
2571 # Build
2572 # -----
2573
2574 helper_libtestdriver1_make_drivers "$loc_accel_list"
2575
2576 helper_libtestdriver1_make_main "$loc_accel_list"
2577
2578 # Make sure disabled components were not re-enabled by accident (additive
2579 # config)
2580 not grep mbedtls_aes_ library/aes.o
2581 not grep mbedtls_aria_ library/aria.o
2582 not grep mbedtls_camellia_ library/camellia.o
2583
2584 # Run the tests
2585 # -------------
2586
2587 msg "test: full + PSA dispatch in block_cipher"
2588 make test
2589}
2590
2591# This is the reference component of component_test_full_block_cipher_psa_dispatch
2592component_test_full_block_cipher_legacy_dispatch () {
2593 msg "build: full + legacy dispatch in block_cipher"
2594
2595 common_block_cipher_dispatch 0
2596
2597 make
2598
2599 msg "test: full + legacy dispatch in block_cipher"
2600 make test
2601}
2602
2603component_test_aead_chachapoly_disabled () {
2604 msg "build: full minus CHACHAPOLY"
2605 scripts/config.py full
2606 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2607 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CHACHA20_POLY1305
2608 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
2609
2610 msg "test: full minus CHACHAPOLY"
2611 make test
2612}
2613
2614component_test_aead_only_ccm () {
2615 msg "build: full minus CHACHAPOLY and GCM"
2616 scripts/config.py full
2617 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
2618 scripts/config.py unset MBEDTLS_GCM_C
2619 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CHACHA20_POLY1305
2620 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_GCM
2621 make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
2622
2623 msg "test: full minus CHACHAPOLY and GCM"
2624 make test
2625}
2626
2627component_test_ccm_aes_sha256 () {
2628 msg "build: CCM + AES + SHA256 configuration"
2629
2630 cp "$CONFIG_TEST_DRIVER_H" "$CONFIG_H"
2631 cp configs/crypto-config-ccm-aes-sha256.h "$CRYPTO_CONFIG_H"
2632
2633 make
2634
2635 msg "test: CCM + AES + SHA256 configuration"
2636 make test
2637}
2638
2639# Test that the given .o file builds with all (valid) combinations of the given options.
2640#
2641# Syntax: build_test_config_combos FILE VALIDATOR_FUNCTION OPT1 OPT2 ...
2642#
2643# The validator function is the name of a function to validate the combination of options.
2644# It may be "" if all combinations are valid.
2645# It receives a string containing a combination of options, as passed to the compiler,
2646# e.g. "-DOPT1 -DOPT2 ...". It must return 0 iff the combination is valid, non-zero if invalid.
2647build_test_config_combos () {
2648 file=$1
2649 shift
2650 validate_options=$1
2651 shift
2652 options=("$@")
2653
2654 # clear all of the options so that they can be overridden on the clang commandline
2655 for opt in "${options[@]}"; do
2656 ./scripts/config.py unset ${opt}
2657 done
2658
2659 # enter the directory containing the target file & strip the dir from the filename
2660 cd $(dirname ${file})
2661 file=$(basename ${file})
2662
2663 # The most common issue is unused variables/functions, so ensure -Wunused is set.
2664 warning_flags="-Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused"
2665
2666 # Extract the command generated by the Makefile to build the target file.
2667 # This ensures that we have any include paths, macro definitions, etc
2668 # that may be applied by make.
2669 # Add -fsyntax-only as we only want a syntax check and don't need to generate a file.
2670 compile_cmd="clang \$(LOCAL_CFLAGS) ${warning_flags} -fsyntax-only -c"
2671
2672 makefile=$(TMPDIR=. mktemp)
2673 deps=""
2674
2675 len=${#options[@]}
2676 source_file=${file%.o}.c
2677
2678 targets=0
2679 echo 'include Makefile' >${makefile}
2680
2681 for ((i = 0; i < $((2**${len})); i++)); do
2682 # generate each of 2^n combinations of options
2683 # each bit of $i is used to determine if options[i] will be set or not
2684 target="t"
2685 clang_args=""
2686 for ((j = 0; j < ${len}; j++)); do
2687 if (((i >> j) & 1)); then
2688 opt=-D${options[$j]}
2689 clang_args="${clang_args} ${opt}"
2690 target="${target}${opt}"
2691 fi
2692 done
2693
2694 # if combination is not known to be invalid, add it to the makefile
2695 if [[ -z $validate_options ]] || $validate_options "${clang_args}"; then
2696 cmd="${compile_cmd} ${clang_args}"
2697 echo "${target}: ${source_file}; $cmd ${source_file}" >> ${makefile}
2698
2699 deps="${deps} ${target}"
2700 ((++targets))
2701 fi
2702 done
2703
2704 echo "build_test_config_combos: ${deps}" >> ${makefile}
2705
2706 # execute all of the commands via Make (probably in parallel)
2707 make -s -f ${makefile} build_test_config_combos
2708 echo "$targets targets checked"
2709
2710 # clean up the temporary makefile
2711 rm ${makefile}
2712}
2713
2714validate_aes_config_variations () {
2715 if [[ "$1" == *"MBEDTLS_AES_USE_HARDWARE_ONLY"* ]]; then
2716 if [[ "$1" == *"MBEDTLS_PADLOCK_C"* ]]; then
2717 return 1
2718 fi
2719 if [[ !(("$HOSTTYPE" == "aarch64" && "$1" != *"MBEDTLS_AESCE_C"*) || \
2720 ("$HOSTTYPE" == "x86_64" && "$1" != *"MBEDTLS_AESNI_C"*)) ]]; then
2721 return 1
2722 fi
2723 fi
2724 return 0
2725}
2726
2727component_build_aes_variations () {
2728 # 18s - around 90ms per clang invocation on M1 Pro
2729 #
2730 # aes.o has many #if defined(...) guards that intersect in complex ways.
2731 # Test that all the combinations build cleanly.
2732
2733 MBEDTLS_ROOT_DIR="$PWD"
2734 msg "build: aes.o for all combinations of relevant config options"
2735
2736 build_test_config_combos library/aes.o validate_aes_config_variations \
2737 "MBEDTLS_AES_SETKEY_ENC_ALT" "MBEDTLS_AES_DECRYPT_ALT" \
2738 "MBEDTLS_AES_ROM_TABLES" "MBEDTLS_AES_ENCRYPT_ALT" "MBEDTLS_AES_SETKEY_DEC_ALT" \
2739 "MBEDTLS_AES_FEWER_TABLES" "MBEDTLS_PADLOCK_C" "MBEDTLS_AES_USE_HARDWARE_ONLY" \
2740 "MBEDTLS_AESNI_C" "MBEDTLS_AESCE_C" "MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH"
2741
2742 cd "$MBEDTLS_ROOT_DIR"
2743 msg "build: aes.o for all combinations of relevant config options + BLOCK_CIPHER_NO_DECRYPT"
2744
2745 # MBEDTLS_BLOCK_CIPHER_NO_DECRYPT is incompatible with ECB in PSA, CBC/XTS/NIST_KW/DES,
2746 # manually set or unset those configurations to check
2747 # MBEDTLS_BLOCK_CIPHER_NO_DECRYPT with various combinations in aes.o.
2748 scripts/config.py set MBEDTLS_BLOCK_CIPHER_NO_DECRYPT
2749 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2750 scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
2751 scripts/config.py unset MBEDTLS_DES_C
2752 scripts/config.py unset MBEDTLS_NIST_KW_C
2753 build_test_config_combos library/aes.o validate_aes_config_variations \
2754 "MBEDTLS_AES_SETKEY_ENC_ALT" "MBEDTLS_AES_DECRYPT_ALT" \
2755 "MBEDTLS_AES_ROM_TABLES" "MBEDTLS_AES_ENCRYPT_ALT" "MBEDTLS_AES_SETKEY_DEC_ALT" \
2756 "MBEDTLS_AES_FEWER_TABLES" "MBEDTLS_PADLOCK_C" "MBEDTLS_AES_USE_HARDWARE_ONLY" \
2757 "MBEDTLS_AESNI_C" "MBEDTLS_AESCE_C" "MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH"
2758}
2759
2760component_test_sha3_variations () {
2761 msg "sha3 loop unroll variations"
2762
2763 # define minimal config sufficient to test SHA3
2764 cat > include/mbedtls/mbedtls_config.h << END
2765 #define MBEDTLS_SELF_TEST
2766 #define MBEDTLS_SHA3_C
2767END
2768
2769 msg "all loops unrolled"
2770 make clean
2771 make -C tests test_suite_shax CFLAGS="-DMBEDTLS_SHA3_THETA_UNROLL=1 -DMBEDTLS_SHA3_PI_UNROLL=1 -DMBEDTLS_SHA3_CHI_UNROLL=1 -DMBEDTLS_SHA3_RHO_UNROLL=1"
2772 ./tests/test_suite_shax
2773
2774 msg "all loops rolled up"
2775 make clean
2776 make -C tests test_suite_shax CFLAGS="-DMBEDTLS_SHA3_THETA_UNROLL=0 -DMBEDTLS_SHA3_PI_UNROLL=0 -DMBEDTLS_SHA3_CHI_UNROLL=0 -DMBEDTLS_SHA3_RHO_UNROLL=0"
2777 ./tests/test_suite_shax
2778}
2779
2780# For timebeing, no aarch64 gcc available in CI and no arm64 CI node.
2781component_build_aes_aesce_armcc () {
2782 msg "Build: AESCE test on arm64 platform without plain C."
2783 scripts/config.py baremetal
2784
2785 # armc[56] don't support SHA-512 intrinsics
2786 scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT
2787
2788 # Stop armclang warning about feature detection for A64_CRYPTO.
2789 # With this enabled, the library does build correctly under armclang,
2790 # but in baremetal builds (as tested here), feature detection is
2791 # unavailable, and the user is notified via a #warning. So enabling
2792 # this feature would prevent us from building with -Werror on
2793 # armclang. Tracked in #7198.
2794 scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
2795 scripts/config.py set MBEDTLS_HAVE_ASM
2796
2797 msg "AESCE, build with default configuration."
2798 scripts/config.py set MBEDTLS_AESCE_C
2799 scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
2800 armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8-a+crypto"
2801
2802 msg "AESCE, build AESCE only"
2803 scripts/config.py set MBEDTLS_AESCE_C
2804 scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
2805 armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8-a+crypto"
2806}
2807
2808support_build_aes_aesce_armcc () {
2809 support_build_armcc
2810}
2811
2812component_test_aes_only_128_bit_keys () {
2813 msg "build: default config + AES_ONLY_128_BIT_KEY_LENGTH"
2814 scripts/config.py set MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH
2815 scripts/config.py unset MBEDTLS_PADLOCK_C
2816
2817 make CFLAGS='-O2 -Werror -Wall -Wextra'
2818
2819 msg "test: default config + AES_ONLY_128_BIT_KEY_LENGTH"
2820 make test
2821}
2822
2823component_test_no_ctr_drbg_aes_only_128_bit_keys () {
2824 msg "build: default config + AES_ONLY_128_BIT_KEY_LENGTH - CTR_DRBG_C"
2825 scripts/config.py set MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH
2826 scripts/config.py unset MBEDTLS_CTR_DRBG_C
2827 scripts/config.py unset MBEDTLS_PADLOCK_C
2828
2829 make CC=clang CFLAGS='-Werror -Wall -Wextra'
2830
2831 msg "test: default config + AES_ONLY_128_BIT_KEY_LENGTH - CTR_DRBG_C"
2832 make test
2833}
2834
2835component_test_aes_only_128_bit_keys_have_builtins () {
2836 msg "build: default config + AES_ONLY_128_BIT_KEY_LENGTH - AESNI_C - AESCE_C"
2837 scripts/config.py set MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH
2838 scripts/config.py unset MBEDTLS_PADLOCK_C
2839 scripts/config.py unset MBEDTLS_AESNI_C
2840 scripts/config.py unset MBEDTLS_AESCE_C
2841
2842 make CFLAGS='-O2 -Werror -Wall -Wextra'
2843
2844 msg "test: default config + AES_ONLY_128_BIT_KEY_LENGTH - AESNI_C - AESCE_C"
2845 make test
2846
2847 msg "selftest: default config + AES_ONLY_128_BIT_KEY_LENGTH - AESNI_C - AESCE_C"
2848 programs/test/selftest
2849}
2850
2851component_test_gcm_largetable () {
2852 msg "build: default config + GCM_LARGE_TABLE - AESNI_C - AESCE_C"
2853 scripts/config.py set MBEDTLS_GCM_LARGE_TABLE
2854 scripts/config.py unset MBEDTLS_PADLOCK_C
2855 scripts/config.py unset MBEDTLS_AESNI_C
2856 scripts/config.py unset MBEDTLS_AESCE_C
2857
2858 make CFLAGS='-O2 -Werror -Wall -Wextra'
2859
2860 msg "test: default config - GCM_LARGE_TABLE - AESNI_C - AESCE_C"
2861 make test
2862}
2863
2864component_test_aes_fewer_tables () {
2865 msg "build: default config with AES_FEWER_TABLES enabled"
2866 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
2867 make CFLAGS='-O2 -Werror -Wall -Wextra'
2868
2869 msg "test: AES_FEWER_TABLES"
2870 make test
2871}
2872
2873component_test_aes_rom_tables () {
2874 msg "build: default config with AES_ROM_TABLES enabled"
2875 scripts/config.py set MBEDTLS_AES_ROM_TABLES
2876 make CFLAGS='-O2 -Werror -Wall -Wextra'
2877
2878 msg "test: AES_ROM_TABLES"
2879 make test
2880}
2881
2882component_test_aes_fewer_tables_and_rom_tables () {
2883 msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled"
2884 scripts/config.py set MBEDTLS_AES_FEWER_TABLES
2885 scripts/config.py set MBEDTLS_AES_ROM_TABLES
2886 make CFLAGS='-O2 -Werror -Wall -Wextra'
2887
2888 msg "test: AES_FEWER_TABLES + AES_ROM_TABLES"
2889 make test
2890}
2891
2892# helper for common_block_cipher_no_decrypt() which:
2893# - enable/disable the list of config options passed from -s/-u respectively.
2894# - build
2895# - test for tests_suite_xxx
2896# - selftest
2897#
2898# Usage: helper_block_cipher_no_decrypt_build_test
2899# [-s set_opts] [-u unset_opts] [-c cflags] [-l ldflags] [option [...]]
2900# Options: -s set_opts the list of config options to enable
2901# -u unset_opts the list of config options to disable
2902# -c cflags the list of options passed to CFLAGS
2903# -l ldflags the list of options passed to LDFLAGS
2904helper_block_cipher_no_decrypt_build_test () {
2905 while [ $# -gt 0 ]; do
2906 case "$1" in
2907 -s)
2908 shift; local set_opts="$1";;
2909 -u)
2910 shift; local unset_opts="$1";;
2911 -c)
2912 shift; local cflags="-Werror -Wall -Wextra $1";;
2913 -l)
2914 shift; local ldflags="$1";;
2915 esac
2916 shift
2917 done
2918 set_opts="${set_opts:-}"
2919 unset_opts="${unset_opts:-}"
2920 cflags="${cflags:-}"
2921 ldflags="${ldflags:-}"
2922
2923 [ -n "$set_opts" ] && echo "Enabling: $set_opts" && scripts/config.py set-all $set_opts
2924 [ -n "$unset_opts" ] && echo "Disabling: $unset_opts" && scripts/config.py unset-all $unset_opts
2925
2926 msg "build: default config + BLOCK_CIPHER_NO_DECRYPT${set_opts:+ + $set_opts}${unset_opts:+ - $unset_opts} with $cflags${ldflags:+, $ldflags}"
2927 make clean
2928 make CFLAGS="-O2 $cflags" LDFLAGS="$ldflags"
2929
2930 # Make sure we don't have mbedtls_xxx_setkey_dec in AES/ARIA/CAMELLIA
2931 not grep mbedtls_aes_setkey_dec library/aes.o
2932 not grep mbedtls_aria_setkey_dec library/aria.o
2933 not grep mbedtls_camellia_setkey_dec library/camellia.o
2934 # Make sure we don't have mbedtls_internal_aes_decrypt in AES
2935 not grep mbedtls_internal_aes_decrypt library/aes.o
2936 # Make sure we don't have mbedtls_aesni_inverse_key in AESNI
2937 not grep mbedtls_aesni_inverse_key library/aesni.o
2938
2939 msg "test: default config + BLOCK_CIPHER_NO_DECRYPT${set_opts:+ + $set_opts}${unset_opts:+ - $unset_opts} with $cflags${ldflags:+, $ldflags}"
2940 make test
2941
2942 msg "selftest: default config + BLOCK_CIPHER_NO_DECRYPT${set_opts:+ + $set_opts}${unset_opts:+ - $unset_opts} with $cflags${ldflags:+, $ldflags}"
2943 programs/test/selftest
2944}
2945
2946# This is a common configuration function used in:
2947# - component_test_block_cipher_no_decrypt_aesni_legacy()
2948# - component_test_block_cipher_no_decrypt_aesni_use_psa()
2949# in order to test BLOCK_CIPHER_NO_DECRYPT with AESNI intrinsics,
2950# AESNI assembly and AES C implementation on x86_64 and with AESNI intrinsics
2951# on x86.
2952common_block_cipher_no_decrypt () {
2953 # test AESNI intrinsics
2954 helper_block_cipher_no_decrypt_build_test \
2955 -s "MBEDTLS_AESNI_C" \
2956 -c "-mpclmul -msse2 -maes"
2957
2958 # test AESNI assembly
2959 helper_block_cipher_no_decrypt_build_test \
2960 -s "MBEDTLS_AESNI_C" \
2961 -c "-mno-pclmul -mno-sse2 -mno-aes"
2962
2963 # test AES C implementation
2964 helper_block_cipher_no_decrypt_build_test \
2965 -u "MBEDTLS_AESNI_C"
2966
2967 # test AESNI intrinsics for i386 target
2968 helper_block_cipher_no_decrypt_build_test \
2969 -s "MBEDTLS_AESNI_C" \
2970 -c "-m32 -mpclmul -msse2 -maes" \
2971 -l "-m32"
2972}
2973
2974# This is a configuration function used in component_test_block_cipher_no_decrypt_xxx:
2975# usage: 0: no PSA crypto configuration
2976# 1: use PSA crypto configuration
2977config_block_cipher_no_decrypt () {
2978 use_psa=$1
2979
2980 scripts/config.py set MBEDTLS_BLOCK_CIPHER_NO_DECRYPT
2981 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
2982 scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
2983 scripts/config.py unset MBEDTLS_DES_C
2984 scripts/config.py unset MBEDTLS_NIST_KW_C
2985
2986 if [ "$use_psa" -eq 1 ]; then
2987 # Enable support for cryptographic mechanisms through the PSA API.
2988 # Note: XTS, KW are not yet supported via the PSA API in Mbed TLS.
2989 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
2990 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CBC_NO_PADDING
2991 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_CBC_PKCS7
2992 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_ALG_ECB_NO_PADDING
2993 scripts/config.py -f "$CRYPTO_CONFIG_H" unset PSA_WANT_KEY_TYPE_DES
2994 fi
2995}
2996
2997component_test_block_cipher_no_decrypt_aesni () {
2998 # This consistently causes an llvm crash on clang 3.8, so use gcc
2999 export CC=gcc
3000 config_block_cipher_no_decrypt 0
3001 common_block_cipher_no_decrypt
3002}
3003
3004component_test_block_cipher_no_decrypt_aesni_use_psa () {
3005 # This consistently causes an llvm crash on clang 3.8, so use gcc
3006 export CC=gcc
3007 config_block_cipher_no_decrypt 1
3008 common_block_cipher_no_decrypt
3009}
3010
3011support_test_block_cipher_no_decrypt_aesce_armcc () {
3012 support_build_armcc
3013}
3014
3015component_test_block_cipher_no_decrypt_aesce_armcc () {
3016 scripts/config.py baremetal
3017
3018 # armc[56] don't support SHA-512 intrinsics
3019 scripts/config.py unset MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT
3020
3021 # Stop armclang warning about feature detection for A64_CRYPTO.
3022 # With this enabled, the library does build correctly under armclang,
3023 # but in baremetal builds (as tested here), feature detection is
3024 # unavailable, and the user is notified via a #warning. So enabling
3025 # this feature would prevent us from building with -Werror on
3026 # armclang. Tracked in #7198.
3027 scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT
3028 scripts/config.py set MBEDTLS_HAVE_ASM
3029
3030 config_block_cipher_no_decrypt 1
3031
3032 # test AESCE baremetal build
3033 scripts/config.py set MBEDTLS_AESCE_C
3034 msg "build: default config + BLOCK_CIPHER_NO_DECRYPT with AESCE"
3035 armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8-a+crypto -Werror -Wall -Wextra"
3036
3037 # Make sure we don't have mbedtls_xxx_setkey_dec in AES/ARIA/CAMELLIA
3038 not grep mbedtls_aes_setkey_dec library/aes.o
3039 not grep mbedtls_aria_setkey_dec library/aria.o
3040 not grep mbedtls_camellia_setkey_dec library/camellia.o
3041 # Make sure we don't have mbedtls_internal_aes_decrypt in AES
3042 not grep mbedtls_internal_aes_decrypt library/aes.o
3043 # Make sure we don't have mbedtls_aesce_inverse_key and aesce_decrypt_block in AESCE
3044 not grep mbedtls_aesce_inverse_key library/aesce.o
3045 not grep aesce_decrypt_block library/aesce.o
3046}
3047
3048component_test_ctr_drbg_aes_256_sha_256 () {
3049 msg "build: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
3050 scripts/config.py full
3051 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
3052 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
3053 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
3054 make
3055
3056 msg "test: full + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
3057 make test
3058}
3059
3060component_test_ctr_drbg_aes_128_sha_512 () {
3061 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
3062 scripts/config.py full
3063 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
3064 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
3065 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
3066 make
3067
3068 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY (ASan build)"
3069 make test
3070}
3071
3072component_test_ctr_drbg_aes_128_sha_256 () {
3073 msg "build: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
3074 scripts/config.py full
3075 scripts/config.py unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
3076 scripts/config.py set MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
3077 scripts/config.py set MBEDTLS_ENTROPY_FORCE_SHA256
3078 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
3079 make
3080
3081 msg "test: full + MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + MBEDTLS_ENTROPY_FORCE_SHA256 (ASan build)"
3082 make test
3083}
3084
3085component_test_se_default () {
3086 msg "build: default config + MBEDTLS_PSA_CRYPTO_SE_C"
3087 scripts/config.py set MBEDTLS_PSA_CRYPTO_SE_C
3088 make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS"
3089
3090 msg "test: default config + MBEDTLS_PSA_CRYPTO_SE_C"
3091 make test
3092}
3093
Gilles Peskine9dc903a2024-06-21 11:25:01 +02003094component_test_full_static_keystore () {
3095 msg "build: full config - MBEDTLS_PSA_KEY_STORE_DYNAMIC"
3096 scripts/config.py full
3097 scripts/config.py unset MBEDTLS_PSA_KEY_STORE_DYNAMIC
3098 make CC=clang CFLAGS="$ASAN_CFLAGS -Os" LDFLAGS="$ASAN_CFLAGS"
3099
3100 msg "test: full config - MBEDTLS_PSA_KEY_STORE_DYNAMIC"
3101 make test
3102}
3103
Minos Galanakis3ece57e2024-08-01 17:09:49 +01003104component_test_psa_crypto_drivers () {
3105 msg "build: full + test drivers dispatching to builtins"
3106 scripts/config.py full
3107 scripts/config.py unset MBEDTLS_PSA_CRYPTO_CONFIG
3108 loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST_ALL"
3109 loc_cflags="${loc_cflags} '-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/user-config-for-test.h\"'"
3110 loc_cflags="${loc_cflags} -I../tests/include -O2"
3111
3112 make CC=$ASAN_CC CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS"
3113
3114 msg "test: full + test drivers dispatching to builtins"
3115 make test
3116}
3117
3118component_build_psa_config_file () {
3119 msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE" # ~40s
3120 scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
3121 cp "$CRYPTO_CONFIG_H" psa_test_config.h
3122 echo '#error "MBEDTLS_PSA_CRYPTO_CONFIG_FILE is not working"' >"$CRYPTO_CONFIG_H"
3123 make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"'"
3124 # Make sure this feature is enabled. We'll disable it in the next phase.
3125 programs/test/query_compile_time_config MBEDTLS_CMAC_C
3126 make clean
3127
3128 msg "build: make with MBEDTLS_PSA_CRYPTO_CONFIG_FILE + MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE" # ~40s
3129 # In the user config, disable one feature and its dependencies, which will
3130 # reflect on the mbedtls configuration so we can query it with
3131 # query_compile_time_config.
3132 echo '#undef PSA_WANT_ALG_CMAC' >psa_user_config.h
3133 echo '#undef PSA_WANT_ALG_PBKDF2_AES_CMAC_PRF_128' >> psa_user_config.h
3134 scripts/config.py unset MBEDTLS_CMAC_C
3135 make CFLAGS="-I '$PWD' -DMBEDTLS_PSA_CRYPTO_CONFIG_FILE='\"psa_test_config.h\"' -DMBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE='\"psa_user_config.h\"'"
3136 not programs/test/query_compile_time_config MBEDTLS_CMAC_C
3137
3138 rm -f psa_test_config.h psa_user_config.h
3139}
3140
3141component_build_psa_alt_headers () {
3142 msg "build: make with PSA alt headers" # ~20s
3143
3144 # Generate alternative versions of the substitutable headers with the
3145 # same content except different include guards.
3146 make -C tests include/alt-extra/psa/crypto_platform_alt.h include/alt-extra/psa/crypto_struct_alt.h
3147
3148 # Build the library and some programs.
3149 # Don't build the fuzzers to avoid having to go through hoops to set
3150 # a correct include path for programs/fuzz/Makefile.
3151 make CFLAGS="-I ../tests/include/alt-extra -DMBEDTLS_PSA_CRYPTO_PLATFORM_FILE='\"psa/crypto_platform_alt.h\"' -DMBEDTLS_PSA_CRYPTO_STRUCT_FILE='\"psa/crypto_struct_alt.h\"'" lib
3152 make -C programs -o fuzz CFLAGS="-I ../tests/include/alt-extra -DMBEDTLS_PSA_CRYPTO_PLATFORM_FILE='\"psa/crypto_platform_alt.h\"' -DMBEDTLS_PSA_CRYPTO_STRUCT_FILE='\"psa/crypto_struct_alt.h\"'"
3153
3154 # Check that we're getting the alternative include guards and not the
3155 # original include guards.
3156 programs/test/query_included_headers | grep -x PSA_CRYPTO_PLATFORM_ALT_H
3157 programs/test/query_included_headers | grep -x PSA_CRYPTO_STRUCT_ALT_H
3158 programs/test/query_included_headers | not grep -x PSA_CRYPTO_PLATFORM_H
3159 programs/test/query_included_headers | not grep -x PSA_CRYPTO_STRUCT_H
3160}
3161
3162component_test_min_mpi_window_size () {
3163 msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s
3164 scripts/config.py set MBEDTLS_MPI_WINDOW_SIZE 1
3165 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
3166 make
3167
3168 msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s
3169 make test
3170}