blob: 380334cb7eb2d79c344d03e2f86406c2bf2cc257 [file] [log] [blame]
Minos Galanakis77711192024-07-25 14:24:37 +01001# components-configuration-tls.sh
2#
3# Copyright The Mbed TLS Contributors
4# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
5
6# This file contains test components that are executed by all.sh
7
8################################################################
9#### Configuration Testing - TLS
10################################################################
Minos Galanakis5b4386c2024-08-01 17:12:24 +010011
12component_test_no_renegotiation () {
13 msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
14 scripts/config.py unset MBEDTLS_SSL_RENEGOTIATION
15 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
16 make
17
18 msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
19 make test
20
21 msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
22 tests/ssl-opt.sh
23}
24
25component_test_tls1_2_default_stream_cipher_only () {
26 msg "build: default with only stream cipher"
27
28 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C
29 scripts/config.py unset MBEDTLS_GCM_C
30 scripts/config.py unset MBEDTLS_CCM_C
31 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
32 #Disable TLS 1.3 (as no AEAD)
33 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
34 # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
35 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
36 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
37 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
38 # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
39 scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
40 # Modules that depend on AEAD
41 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
42 scripts/config.py unset MBEDTLS_SSL_TICKET_C
43
44 make
45
46 msg "test: default with only stream cipher"
47 make test
48
49 # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
50}
51
Minos Galanakis85347d12024-08-01 22:45:10 +010052component_test_tls1_2_default_stream_cipher_only_use_psa () {
53 msg "build: default with only stream cipher use psa"
54
55 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
56 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
57 scripts/config.py unset MBEDTLS_GCM_C
58 scripts/config.py unset MBEDTLS_CCM_C
59 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
60 #Disable TLS 1.3 (as no AEAD)
61 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
62 # Disable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
63 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
64 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
65 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
66 # Enable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
67 scripts/config.py set MBEDTLS_CIPHER_NULL_CIPHER
68 # Modules that depend on AEAD
69 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
70 scripts/config.py unset MBEDTLS_SSL_TICKET_C
71
72 make
73
74 msg "test: default with only stream cipher use psa"
75 make test
76
77 # Not running ssl-opt.sh because most tests require a non-NULL ciphersuite.
78}
79
Minos Galanakis5b4386c2024-08-01 17:12:24 +010080component_test_tls1_2_default_cbc_legacy_cipher_only () {
81 msg "build: default with only CBC-legacy cipher"
82
83 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
84 scripts/config.py unset MBEDTLS_GCM_C
85 scripts/config.py unset MBEDTLS_CCM_C
86 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
87 #Disable TLS 1.3 (as no AEAD)
88 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
89 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
90 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
91 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
92 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
93 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
94 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
95 # Modules that depend on AEAD
96 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
97 scripts/config.py unset MBEDTLS_SSL_TICKET_C
98
99 make
100
101 msg "test: default with only CBC-legacy cipher"
102 make test
103
104 msg "test: default with only CBC-legacy cipher - ssl-opt.sh (subset)"
105 tests/ssl-opt.sh -f "TLS 1.2"
106}
107
Minos Galanakis4ca7b142024-08-05 12:20:21 +0100108component_test_tls1_2_default_cbc_legacy_cipher_only_use_psa () {
Minos Galanakis85347d12024-08-01 22:45:10 +0100109 msg "build: default with only CBC-legacy cipher use psa"
110
111 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
112 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
113 scripts/config.py unset MBEDTLS_GCM_C
114 scripts/config.py unset MBEDTLS_CCM_C
115 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
116 #Disable TLS 1.3 (as no AEAD)
117 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
118 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
119 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
120 # Disable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
121 scripts/config.py unset MBEDTLS_SSL_ENCRYPT_THEN_MAC
122 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
123 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
124 # Modules that depend on AEAD
125 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
126 scripts/config.py unset MBEDTLS_SSL_TICKET_C
127
128 make
129
130 msg "test: default with only CBC-legacy cipher use psa"
131 make test
132
133 msg "test: default with only CBC-legacy cipher use psa - ssl-opt.sh (subset)"
134 tests/ssl-opt.sh -f "TLS 1.2"
135}
136
Minos Galanakis5b4386c2024-08-01 17:12:24 +0100137component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only () {
138 msg "build: default with only CBC-legacy and CBC-EtM ciphers"
139
140 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
141 scripts/config.py unset MBEDTLS_GCM_C
142 scripts/config.py unset MBEDTLS_CCM_C
143 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
144 #Disable TLS 1.3 (as no AEAD)
145 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
146 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
147 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
148 # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
149 scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
150 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
151 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
152 # Modules that depend on AEAD
153 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
154 scripts/config.py unset MBEDTLS_SSL_TICKET_C
155
156 make
157
158 msg "test: default with only CBC-legacy and CBC-EtM ciphers"
159 make test
160
161 msg "test: default with only CBC-legacy and CBC-EtM ciphers - ssl-opt.sh (subset)"
162 tests/ssl-opt.sh -f "TLS 1.2"
163}
164
Minos Galanakis85347d12024-08-01 22:45:10 +0100165component_test_tls1_2_default_cbc_legacy_cbc_etm_cipher_only_use_psa () {
166 msg "build: default with only CBC-legacy and CBC-EtM ciphers use psa"
167
168 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
169 # Disable AEAD (controlled by the presence of one of GCM_C, CCM_C, CHACHAPOLY_C)
170 scripts/config.py unset MBEDTLS_GCM_C
171 scripts/config.py unset MBEDTLS_CCM_C
172 scripts/config.py unset MBEDTLS_CHACHAPOLY_C
173 #Disable TLS 1.3 (as no AEAD)
174 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
175 # Enable CBC-legacy (controlled by MBEDTLS_CIPHER_MODE_CBC plus at least one block cipher (AES, ARIA, Camellia, DES))
176 scripts/config.py set MBEDTLS_CIPHER_MODE_CBC
177 # Enable CBC-EtM (controlled by the same as CBC-legacy plus MBEDTLS_SSL_ENCRYPT_THEN_MAC)
178 scripts/config.py set MBEDTLS_SSL_ENCRYPT_THEN_MAC
179 # Disable stream (currently that's just the NULL pseudo-cipher (controlled by MBEDTLS_CIPHER_NULL_CIPHER))
180 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
181 # Modules that depend on AEAD
182 scripts/config.py unset MBEDTLS_SSL_CONTEXT_SERIALIZATION
183 scripts/config.py unset MBEDTLS_SSL_TICKET_C
184
185 make
186
187 msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa"
188 make test
189
190 msg "test: default with only CBC-legacy and CBC-EtM ciphers use psa - ssl-opt.sh (subset)"
191 tests/ssl-opt.sh -f "TLS 1.2"
192}
193
Minos Galanakis5b4386c2024-08-01 17:12:24 +0100194# We're not aware of any other (open source) implementation of EC J-PAKE in TLS
195# that we could use for interop testing. However, we now have sort of two
196# implementations ourselves: one using PSA, the other not. At least test that
197# these two interoperate with each other.
198component_test_tls1_2_ecjpake_compatibility () {
199 msg "build: TLS1.2 server+client w/ EC-JPAKE w/o USE_PSA"
200 scripts/config.py set MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
201 # Explicitly make lib first to avoid a race condition:
202 # https://github.com/Mbed-TLS/mbedtls/issues/8229
203 make lib
204 make -C programs ssl/ssl_server2 ssl/ssl_client2
205 cp programs/ssl/ssl_server2 s2_no_use_psa
206 cp programs/ssl/ssl_client2 c2_no_use_psa
207
208 msg "build: TLS1.2 server+client w/ EC-JPAKE w/ USE_PSA"
209 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
210 make clean
211 make lib
212 make -C programs ssl/ssl_server2 ssl/ssl_client2
213 make -C programs test/udp_proxy test/query_compile_time_config
214
215 msg "test: server w/o USE_PSA - client w/ USE_PSA, text password"
216 P_SRV=../s2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: working, TLS"
217 msg "test: server w/o USE_PSA - client w/ USE_PSA, opaque password"
218 P_SRV=../s2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: opaque password client only, working, TLS"
219 msg "test: client w/o USE_PSA - server w/ USE_PSA, text password"
220 P_CLI=../c2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: working, TLS"
221 msg "test: client w/o USE_PSA - server w/ USE_PSA, opaque password"
222 P_CLI=../c2_no_use_psa tests/ssl-opt.sh -f "ECJPAKE: opaque password server only, working, TLS"
223
224 rm s2_no_use_psa c2_no_use_psa
225}
226
Gilles Peskinef3d50192024-09-14 11:10:05 +0200227component_test_tls1_2_ccm_psk_legacy () {
228 msg "build: configs/config-ccm-psk-tls1_2.h"
229 cp configs/config-ccm-psk-tls1_2.h "$CONFIG_H"
230 # test-ref-configs works by overwriting mbedtls_config.h; this makes cmake
231 # want to re-generate generated files that depend on it, quite correctly.
232 # However this doesn't work as the generation script expects a specific
233 # format for mbedtls_config.h, which the other files don't follow. Also,
234 # cmake can't know this, but re-generation is actually not necessary as
235 # the generated files only depend on the list of available options, not
236 # whether they're on or off. So, disable cmake's (over-sensitive here)
237 # dependency resolution for generated files and just rely on them being
238 # present (thanks to pre_generate_files) by turning GEN_FILES off.
239 CC=$ASAN_CC cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan .
240 make
241
242 msg "test: configs/config-ccm-psk-tls1_2.h - unit tests"
243 make test
244
245 msg "test: configs/config-ccm-psk-tls1_2.h - compat.sh"
246 tests/compat.sh -m tls12 -f '^TLS_PSK_WITH_AES_..._CCM_8'
247}
248
249component_test_tls1_2_ccm_psk_psa () {
250 msg "build: configs/config-ccm-psk-tls1_2.h + USE_PSA_CRYPTO"
251 cp configs/config-ccm-psk-tls1_2.h "$CONFIG_H"
252 scripts/config.py set MBEDTLS_PSA_CRYPTO_C
253 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
254 # test-ref-configs works by overwriting mbedtls_config.h; this makes cmake
255 # want to re-generate generated files that depend on it, quite correctly.
256 # However this doesn't work as the generation script expects a specific
257 # format for mbedtls_config.h, which the other files don't follow. Also,
258 # cmake can't know this, but re-generation is actually not necessary as
259 # the generated files only depend on the list of available options, not
260 # whether they're on or off. So, disable cmake's (over-sensitive here)
261 # dependency resolution for generated files and just rely on them being
262 # present (thanks to pre_generate_files) by turning GEN_FILES off.
263 CC=$ASAN_CC cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan .
264 make
265
266 msg "test: configs/config-ccm-psk-tls1_2.h + USE_PSA_CRYPTO - unit tests"
267 make test
268
269 msg "test: configs/config-ccm-psk-tls1_2.h + USE_PSA_CRYPTO - compat.sh"
270 tests/compat.sh -m tls12 -f '^TLS_PSK_WITH_AES_..._CCM_8'
271}
272
Gilles Peskine99292372024-09-14 11:19:31 +0200273component_test_tls1_2_ccm_psk_dtls_legacy () {
274 msg "build: configs/config-ccm-psk-dtls1_2.h"
275 cp configs/config-ccm-psk-dtls1_2.h "$CONFIG_H"
276 # test-ref-configs works by overwriting mbedtls_config.h; this makes cmake
277 # want to re-generate generated files that depend on it, quite correctly.
278 # However this doesn't work as the generation script expects a specific
279 # format for mbedtls_config.h, which the other files don't follow. Also,
280 # cmake can't know this, but re-generation is actually not necessary as
281 # the generated files only depend on the list of available options, not
282 # whether they're on or off. So, disable cmake's (over-sensitive here)
283 # dependency resolution for generated files and just rely on them being
284 # present (thanks to pre_generate_files) by turning GEN_FILES off.
285 CC=$ASAN_CC cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan .
286 make
287
288 msg "test: configs/config-ccm-psk-dtls1_2.h - unit tests"
289 make test
290
291 msg "test: configs/config-ccm-psk-dtls1_2.h - compat.sh"
292 tests/compat.sh -m dtls12 -f '^TLS_PSK_WITH_AES_..._CCM_8'
293
294 msg "build: configs/config-ccm-psk-dtls1_2.h + DEBUG"
295 MBEDTLS_TEST_CONFIGURATION="$MBEDTLS_TEST_CONFIGURATION+DEBUG"
296 make clean
297 scripts/config.py set MBEDTLS_DEBUG_C
298 scripts/config.py set MBEDTLS_ERROR_C
299 make ssl-opt
300
301 msg "test: configs/config-ccm-psk-dtls1_2.h + DEBUG - ssl-opt.sh"
302 tests/ssl-opt.sh
303}
304
305component_test_tls1_2_ccm_psk_dtls_psa () {
306 msg "build: configs/config-ccm-psk-dtls1_2.h + USE_PSA_CRYPTO"
307 cp configs/config-ccm-psk-dtls1_2.h "$CONFIG_H"
308 scripts/config.py set MBEDTLS_PSA_CRYPTO_C
309 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
310 # test-ref-configs works by overwriting mbedtls_config.h; this makes cmake
311 # want to re-generate generated files that depend on it, quite correctly.
312 # However this doesn't work as the generation script expects a specific
313 # format for mbedtls_config.h, which the other files don't follow. Also,
314 # cmake can't know this, but re-generation is actually not necessary as
315 # the generated files only depend on the list of available options, not
316 # whether they're on or off. So, disable cmake's (over-sensitive here)
317 # dependency resolution for generated files and just rely on them being
318 # present (thanks to pre_generate_files) by turning GEN_FILES off.
319 CC=$ASAN_CC cmake -D GEN_FILES=Off -D CMAKE_BUILD_TYPE:String=Asan .
320 make
321
322 msg "test: configs/config-ccm-psk-dtls1_2.h + USE_PSA_CRYPTO - unit tests"
323 make test
324
325 msg "test: configs/config-ccm-psk-dtls1_2.h + USE_PSA_CRYPTO - compat.sh"
326 tests/compat.sh -m dtls12 -f '^TLS_PSK_WITH_AES_..._CCM_8'
327
328 msg "build: configs/config-ccm-psk-dtls1_2.h + USE_PSA_CRYPTO + DEBUG"
329 MBEDTLS_TEST_CONFIGURATION="$MBEDTLS_TEST_CONFIGURATION+DEBUG"
330 make clean
331 scripts/config.py set MBEDTLS_DEBUG_C
332 scripts/config.py set MBEDTLS_ERROR_C
333 make ssl-opt
334
335 msg "test: configs/config-ccm-psk-dtls1_2.h + USE_PSA_CRYPTO + DEBUG - ssl-opt.sh"
336 tests/ssl-opt.sh
337}
338
Minos Galanakis5b4386c2024-08-01 17:12:24 +0100339component_test_small_ssl_out_content_len () {
340 msg "build: small SSL_OUT_CONTENT_LEN (ASan build)"
341 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
342 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
343 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
344 make
345
346 msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests"
347 tests/ssl-opt.sh -f "Max fragment\|Large packet"
348}
349
350component_test_small_ssl_in_content_len () {
351 msg "build: small SSL_IN_CONTENT_LEN (ASan build)"
352 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 4096
353 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 16384
354 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
355 make
356
357 msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests"
358 tests/ssl-opt.sh -f "Max fragment"
359}
360
361component_test_small_ssl_dtls_max_buffering () {
362 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0"
363 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000
364 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
365 make
366
367 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test"
368 tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg"
369}
370
371component_test_small_mbedtls_ssl_dtls_max_buffering () {
372 msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1"
373 scripts/config.py set MBEDTLS_SSL_DTLS_MAX_BUFFERING 190
374 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
375 make
376
377 msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test"
378 tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket"
379}
380
381component_test_depends_py_kex () {
382 msg "test/build: depends.py kex (gcc)"
383 tests/scripts/depends.py kex --unset-use-psa
384}
385
386component_test_depends_py_kex_psa () {
387 msg "test/build: depends.py kex (gcc) with MBEDTLS_USE_PSA_CRYPTO defined"
388 tests/scripts/depends.py kex
389}
390
391# Common helper for component_full_without_ecdhe_ecdsa() and
392# component_full_without_ecdhe_ecdsa_and_tls13() which:
393# - starts from the "full" configuration minus the list of symbols passed in
394# as 1st parameter
395# - build
396# - test only TLS (i.e. test_suite_tls and ssl-opt)
397build_full_minus_something_and_test_tls () {
398 symbols_to_disable="$1"
399
400 msg "build: full minus something, test TLS"
401
402 scripts/config.py full
403 for sym in $symbols_to_disable; do
404 echo "Disabling $sym"
405 scripts/config.py unset $sym
406 done
407
408 make
409
410 msg "test: full minus something, test TLS"
411 ( cd tests; ./test_suite_ssl )
412
413 msg "ssl-opt: full minus something, test TLS"
414 tests/ssl-opt.sh
415}
416
417component_full_without_ecdhe_ecdsa () {
418 build_full_minus_something_and_test_tls "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED"
419}
420
421component_full_without_ecdhe_ecdsa_and_tls13 () {
422 build_full_minus_something_and_test_tls "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
423 MBEDTLS_SSL_PROTO_TLS1_3"
424}
425
426component_build_no_ssl_srv () {
427 msg "build: full config except SSL server, make, gcc" # ~ 30s
428 scripts/config.py full
429 scripts/config.py unset MBEDTLS_SSL_SRV_C
Minos Galanakis83222b82024-08-06 12:06:51 +0100430 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -Wmissing-prototypes'
Minos Galanakis5b4386c2024-08-01 17:12:24 +0100431}
432
433component_build_no_ssl_cli () {
434 msg "build: full config except SSL client, make, gcc" # ~ 30s
435 scripts/config.py full
436 scripts/config.py unset MBEDTLS_SSL_CLI_C
Minos Galanakis83222b82024-08-06 12:06:51 +0100437 make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -Wmissing-prototypes'
Minos Galanakis5b4386c2024-08-01 17:12:24 +0100438}
439
440component_test_no_max_fragment_length () {
441 # Run max fragment length tests with MFL disabled
442 msg "build: default config except MFL extension (ASan build)" # ~ 30s
443 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
444 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
445 make
446
447 msg "test: ssl-opt.sh, MFL-related tests"
448 tests/ssl-opt.sh -f "Max fragment length"
449}
450
451component_test_asan_remove_peer_certificate () {
452 msg "build: default config with MBEDTLS_SSL_KEEP_PEER_CERTIFICATE disabled (ASan build)"
453 scripts/config.py unset MBEDTLS_SSL_KEEP_PEER_CERTIFICATE
454 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
455 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
456 make
457
458 msg "test: !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
459 make test
460
461 msg "test: ssl-opt.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
462 tests/ssl-opt.sh
463
464 msg "test: compat.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
465 tests/compat.sh
466
467 msg "test: context-info.sh, !MBEDTLS_SSL_KEEP_PEER_CERTIFICATE"
468 tests/context-info.sh
469}
470
471component_test_no_max_fragment_length_small_ssl_out_content_len () {
472 msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)"
473 scripts/config.py unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
474 scripts/config.py set MBEDTLS_SSL_IN_CONTENT_LEN 16384
475 scripts/config.py set MBEDTLS_SSL_OUT_CONTENT_LEN 4096
476 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
477 make
478
479 msg "test: MFL tests (disabled MFL extension case) & large packet tests"
480 tests/ssl-opt.sh -f "Max fragment length\|Large buffer"
481
482 msg "test: context-info.sh (disabled MFL extension case)"
483 tests/context-info.sh
484}
485
486component_test_variable_ssl_in_out_buffer_len () {
487 msg "build: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled (ASan build)"
488 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
489 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
490 make
491
492 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
493 make test
494
495 msg "test: ssl-opt.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
496 tests/ssl-opt.sh
497
498 msg "test: compat.sh, MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH enabled"
499 tests/compat.sh
500}
501
502component_test_dtls_cid_legacy () {
503 msg "build: MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled (ASan build)"
504 scripts/config.py set MBEDTLS_SSL_DTLS_CONNECTION_ID_COMPAT 1
505
506 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
507 make
508
509 msg "test: MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy)"
510 make test
511
512 msg "test: ssl-opt.sh, MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled"
513 tests/ssl-opt.sh
514
515 msg "test: compat.sh, MBEDTLS_SSL_DTLS_CONNECTION_ID (legacy) enabled"
516 tests/compat.sh
517}
518
519component_test_ssl_alloc_buffer_and_mfl () {
520 msg "build: default config with memory buffer allocator and MFL extension"
521 scripts/config.py set MBEDTLS_MEMORY_BUFFER_ALLOC_C
522 scripts/config.py set MBEDTLS_PLATFORM_MEMORY
523 scripts/config.py set MBEDTLS_MEMORY_DEBUG
524 scripts/config.py set MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
525 scripts/config.py set MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
526 cmake -DCMAKE_BUILD_TYPE:String=Release .
527 make
528
529 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
530 make test
531
532 msg "test: MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH, MBEDTLS_MEMORY_BUFFER_ALLOC_C, MBEDTLS_MEMORY_DEBUG and MBEDTLS_SSL_MAX_FRAGMENT_LENGTH"
533 tests/ssl-opt.sh -f "Handshake memory usage"
534}
535
536component_test_when_no_ciphersuites_have_mac () {
537 msg "build: when no ciphersuites have MAC"
538 scripts/config.py unset MBEDTLS_CIPHER_NULL_CIPHER
539 scripts/config.py unset MBEDTLS_CIPHER_MODE_CBC
540 scripts/config.py unset MBEDTLS_CMAC_C
541 make
542
543 msg "test: !MBEDTLS_SSL_SOME_SUITES_USE_MAC"
544 make test
545
546 msg "test ssl-opt.sh: !MBEDTLS_SSL_SOME_SUITES_USE_MAC"
547 tests/ssl-opt.sh -f 'Default\|EtM' -e 'without EtM'
548}
549
550component_test_tls12_only () {
551 msg "build: default config without MBEDTLS_SSL_PROTO_TLS1_3, cmake, gcc, ASan"
552 scripts/config.py unset MBEDTLS_SSL_PROTO_TLS1_3
553 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
554 make
555
556 msg "test: main suites (inc. selftests) (ASan build)"
557 make test
558
559 msg "test: ssl-opt.sh (ASan build)"
560 tests/ssl-opt.sh
561
562 msg "test: compat.sh (ASan build)"
563 tests/compat.sh
564}
565
566component_test_tls13_only () {
567 msg "build: default config without MBEDTLS_SSL_PROTO_TLS1_2"
568 scripts/config.py set MBEDTLS_SSL_EARLY_DATA
569 scripts/config.py set MBEDTLS_SSL_RECORD_SIZE_LIMIT
570 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
571
572 msg "test: TLS 1.3 only, all key exchange modes enabled"
573 make test
574
575 msg "ssl-opt.sh: TLS 1.3 only, all key exchange modes enabled"
576 tests/ssl-opt.sh
577}
578
579component_test_tls13_only_psk () {
580 msg "build: TLS 1.3 only from default, only PSK key exchange mode"
581 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
582 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
583 scripts/config.py unset MBEDTLS_ECDH_C
584 scripts/config.py unset MBEDTLS_DHM_C
585 scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
586 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
587 scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
588 scripts/config.py unset MBEDTLS_ECDSA_C
589 scripts/config.py unset MBEDTLS_PKCS1_V21
590 scripts/config.py unset MBEDTLS_PKCS7_C
591 scripts/config.py set MBEDTLS_SSL_EARLY_DATA
592 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
593
594 msg "test_suite_ssl: TLS 1.3 only, only PSK key exchange mode enabled"
595 cd tests; ./test_suite_ssl; cd ..
596
597 msg "ssl-opt.sh: TLS 1.3 only, only PSK key exchange mode enabled"
598 tests/ssl-opt.sh
599}
600
601component_test_tls13_only_ephemeral () {
602 msg "build: TLS 1.3 only from default, only ephemeral key exchange mode"
603 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
604 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
605 scripts/config.py unset MBEDTLS_SSL_EARLY_DATA
606 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
607
608 msg "test_suite_ssl: TLS 1.3 only, only ephemeral key exchange mode"
609 cd tests; ./test_suite_ssl; cd ..
610
611 msg "ssl-opt.sh: TLS 1.3 only, only ephemeral key exchange mode"
612 tests/ssl-opt.sh
613}
614
615component_test_tls13_only_ephemeral_ffdh () {
616 msg "build: TLS 1.3 only from default, only ephemeral ffdh key exchange mode"
617 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
618 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
619 scripts/config.py unset MBEDTLS_SSL_EARLY_DATA
620 scripts/config.py unset MBEDTLS_ECDH_C
621
622 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
623
624 msg "test_suite_ssl: TLS 1.3 only, only ephemeral ffdh key exchange mode"
625 cd tests; ./test_suite_ssl; cd ..
626
627 msg "ssl-opt.sh: TLS 1.3 only, only ephemeral ffdh key exchange mode"
628 tests/ssl-opt.sh
629}
630
631component_test_tls13_only_psk_ephemeral () {
632 msg "build: TLS 1.3 only from default, only PSK ephemeral key exchange mode"
633 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
634 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
635 scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
636 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
637 scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
638 scripts/config.py unset MBEDTLS_ECDSA_C
639 scripts/config.py unset MBEDTLS_PKCS1_V21
640 scripts/config.py unset MBEDTLS_PKCS7_C
641 scripts/config.py set MBEDTLS_SSL_EARLY_DATA
642 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
643
644 msg "test_suite_ssl: TLS 1.3 only, only PSK ephemeral key exchange mode"
645 cd tests; ./test_suite_ssl; cd ..
646
647 msg "ssl-opt.sh: TLS 1.3 only, only PSK ephemeral key exchange mode"
648 tests/ssl-opt.sh
649}
650
651component_test_tls13_only_psk_ephemeral_ffdh () {
652 msg "build: TLS 1.3 only from default, only PSK ephemeral ffdh key exchange mode"
653 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
654 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
655 scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
656 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
657 scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
658 scripts/config.py unset MBEDTLS_ECDSA_C
659 scripts/config.py unset MBEDTLS_PKCS1_V21
660 scripts/config.py unset MBEDTLS_PKCS7_C
661 scripts/config.py set MBEDTLS_SSL_EARLY_DATA
662 scripts/config.py unset MBEDTLS_ECDH_C
663 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
664
665 msg "test_suite_ssl: TLS 1.3 only, only PSK ephemeral ffdh key exchange mode"
666 cd tests; ./test_suite_ssl; cd ..
667
668 msg "ssl-opt.sh: TLS 1.3 only, only PSK ephemeral ffdh key exchange mode"
669 tests/ssl-opt.sh
670}
671
672component_test_tls13_only_psk_all () {
673 msg "build: TLS 1.3 only from default, without ephemeral key exchange mode"
674 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
675 scripts/config.py unset MBEDTLS_X509_CRT_PARSE_C
676 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
677 scripts/config.py unset MBEDTLS_SSL_SERVER_NAME_INDICATION
678 scripts/config.py unset MBEDTLS_ECDSA_C
679 scripts/config.py unset MBEDTLS_PKCS1_V21
680 scripts/config.py unset MBEDTLS_PKCS7_C
681 scripts/config.py set MBEDTLS_SSL_EARLY_DATA
682 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
683
684 msg "test_suite_ssl: TLS 1.3 only, PSK and PSK ephemeral key exchange modes"
685 cd tests; ./test_suite_ssl; cd ..
686
687 msg "ssl-opt.sh: TLS 1.3 only, PSK and PSK ephemeral key exchange modes"
688 tests/ssl-opt.sh
689}
690
691component_test_tls13_only_ephemeral_all () {
692 msg "build: TLS 1.3 only from default, without PSK key exchange mode"
693 scripts/config.py unset MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
694 scripts/config.py set MBEDTLS_SSL_EARLY_DATA
695 make CFLAGS="'-DMBEDTLS_USER_CONFIG_FILE=\"../tests/configs/tls13-only.h\"'"
696
697 msg "test_suite_ssl: TLS 1.3 only, ephemeral and PSK ephemeral key exchange modes"
698 cd tests; ./test_suite_ssl; cd ..
699
700 msg "ssl-opt.sh: TLS 1.3 only, ephemeral and PSK ephemeral key exchange modes"
701 tests/ssl-opt.sh
702}
703
704component_test_tls13_no_padding () {
705 msg "build: default config plus early data minus padding"
706 scripts/config.py set MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 1
707 scripts/config.py set MBEDTLS_SSL_EARLY_DATA
708 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
709 make
710 msg "test: default config plus early data minus padding"
711 make test
712 msg "ssl-opt.sh (TLS 1.3 no padding)"
713 tests/ssl-opt.sh
714}
715
716component_test_tls13_no_compatibility_mode () {
717 msg "build: default config plus early data minus middlebox compatibility mode"
718 scripts/config.py unset MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE
719 scripts/config.py set MBEDTLS_SSL_EARLY_DATA
720 CC=$ASAN_CC cmake -D CMAKE_BUILD_TYPE:String=Asan .
721 make
722 msg "test: default config plus early data minus middlebox compatibility mode"
723 make test
724 msg "ssl-opt.sh (TLS 1.3 no compatibility mode)"
725 tests/ssl-opt.sh
726}
727
728component_test_full_minus_session_tickets () {
729 msg "build: full config without session tickets"
730 scripts/config.py full
731 scripts/config.py unset MBEDTLS_SSL_SESSION_TICKETS
732 scripts/config.py unset MBEDTLS_SSL_EARLY_DATA
733 CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
734 make
735 msg "test: full config without session tickets"
736 make test
737 msg "ssl-opt.sh (full config without session tickets)"
738 tests/ssl-opt.sh
739}