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