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