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