Skip to content

Commit abb08f1

Browse files
Merge pull request #10024 from gilles-peskine-arm/tls-defragmentation-merge-3.6-20250303
[tls-defragmentation/3.6] Update main branch
2 parents b55fd70 + e0f1240 commit abb08f1

23 files changed

+76
-964
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ endif()
6161

6262
# Set the project root directory.
6363
set(MBEDTLS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
64+
set(MBEDTLS_FRAMEWORK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/framework)
6465

6566
option(ENABLE_PROGRAMS "Build Mbed TLS programs." ON)
6667

SECURITY.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,22 @@ Policy](https://github.com/hacl-star/hacl-star/blob/main/SECURITY.md).)
144144

145145
The Everest variant is only used when `MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED`
146146
configuration option is defined. This option is off by default.
147+
148+
#### Formatting of X.509 certificates and certificate signing requests
149+
150+
When parsing X.509 certificates and certificate signing requests (CSRs),
151+
Mbed TLS does not check that they are strictly compliant with X.509 and other
152+
relevant standards. In the case of signed certificates, the signing party is
153+
assumed to have performed this validation (and the certificate is trusted to
154+
be correctly formatted as long as the signature is correct).
155+
Similarly, CSRs are implicitly trusted by Mbed TLS to be standards-compliant.
156+
157+
**Warning!** Mbed TLS must not be used to sign untrusted CSRs unless extra
158+
validation is performed separately to ensure that they are compliant to the
159+
relevant specifications. This makes Mbed TLS on its own unsuitable for use in
160+
a Certificate Authority (CA).
161+
162+
However, Mbed TLS aims to protect against memory corruption and other
163+
undefined behavior when parsing certificates and CSRs. If a CSR or signed
164+
certificate causes undefined behavior when it is parsed by Mbed TLS, that
165+
is considered a security vulnerability.

docs/architecture/testing/invasive-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ This section lists some strategies that are currently used for invasive testing,
275275
276276
Goal: test that `mbedtls_platform_zeroize` does wipe the memory buffer.
277277
278-
Solution ([debugger](#debugger-based-testing)): implemented in `tests/scripts/test_zeroize.gdb`.
278+
Solution ([debugger](#debugger-based-testing)): implemented in `framework/tests/programs/test_zeroize.gdb`.
279279
280280
Rationale: this cannot be tested by adding C code, because the danger is that the compiler optimizes the zeroization away, and any C code that observes the zeroization would cause the compiler not to optimize it away.
281281

programs/Makefile

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
MBEDTLS_TEST_PATH = ../tests
2+
FRAMEWORK = ${MBEDTLS_PATH}/framework
23
include ../scripts/common.make
34

45
ifeq ($(shell uname -s),Linux)
@@ -24,6 +25,8 @@ else
2425
BUILD_DLOPEN =
2526
endif
2627

28+
LOCAL_CFLAGS += -I$(FRAMEWORK)/tests/programs
29+
2730
## The following assignment is the list of base names of applications that
2831
## will be built on Windows. Extra Linux/Unix/POSIX-only applications can
2932
## be declared by appending with `APPS += ...` afterwards.
@@ -298,7 +301,7 @@ ssl/ssl_client1$(EXEXT): ssl/ssl_client1.c $(DEP)
298301

299302
SSL_TEST_OBJECTS = test/query_config.o ssl/ssl_test_lib.o
300303
SSL_TEST_DEPS = $(SSL_TEST_OBJECTS) \
301-
test/query_config.h \
304+
$(FRAMEWORK)/tests/programs/query_config.h \
302305
ssl/ssl_test_lib.h \
303306
ssl/ssl_test_common_source.c \
304307
$(DEP)
@@ -319,7 +322,7 @@ ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c $(SSL_TEST_DEPS)
319322
echo " CC ssl/ssl_server2.c"
320323
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c $(SSL_TEST_OBJECTS) $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
321324

322-
ssl/ssl_context_info$(EXEXT): ssl/ssl_context_info.c test/query_config.o test/query_config.h $(DEP)
325+
ssl/ssl_context_info$(EXEXT): ssl/ssl_context_info.c test/query_config.o $(FRAMEWORK)/tests/programs/query_config.h $(DEP)
323326
echo " CC ssl/ssl_context_info.c"
324327
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_context_info.c test/query_config.o $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
325328

@@ -360,17 +363,17 @@ test/dlopen$(EXEXT): test/dlopen.c $(DEP)
360363
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/dlopen.c $(LDFLAGS) $(DLOPEN_LDFLAGS) -o $@
361364
endif
362365

363-
test/metatest$(EXEXT): test/metatest.c $(DEP)
364-
echo " CC test/metatest.c"
365-
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -I ../library test/metatest.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
366+
test/metatest$(EXEXT): $(FRAMEWORK)/tests/programs/metatest.c $(DEP)
367+
echo " CC $(FRAMEWORK)/tests/programs/metatest.c"
368+
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -I ../library $(FRAMEWORK)/tests/programs/metatest.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
366369

367-
test/query_config.o: test/query_config.c test/query_config.h $(DEP)
368-
echo " CC test/query_config.c"
370+
test/query_config.o: test/query_config.c $(FRAMEWORK)/tests/programs/query_config.h $(DEP)
371+
echo " CC $(FRAMEWORK)/tests/programs/query_config.c"
369372
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c test/query_config.c -o $@
370373

371-
test/query_included_headers$(EXEXT): test/query_included_headers.c $(DEP)
372-
echo " CC test/query_included_headers.c"
373-
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/query_included_headers.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
374+
test/query_included_headers$(EXEXT): $(FRAMEWORK)/tests/programs/query_included_headers.c $(DEP)
375+
echo " CC $(FRAMEWORK)/tests/programs/query_included_headers.c"
376+
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $(FRAMEWORK)/tests/programs/query_included_headers.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
374377

375378
test/selftest$(EXEXT): test/selftest.c $(DEP)
376379
echo " CC test/selftest.c"
@@ -380,13 +383,13 @@ test/udp_proxy$(EXEXT): test/udp_proxy.c $(DEP)
380383
echo " CC test/udp_proxy.c"
381384
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/udp_proxy.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
382385

383-
test/zeroize$(EXEXT): test/zeroize.c $(DEP)
384-
echo " CC test/zeroize.c"
385-
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/zeroize.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
386+
test/zeroize$(EXEXT): $(FRAMEWORK)/tests/programs/zeroize.c $(DEP)
387+
echo " CC $(FRAMEWORK)/tests/programs/zeroize.c"
388+
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $(FRAMEWORK)/tests/programs/zeroize.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
386389

387-
test/query_compile_time_config$(EXEXT): test/query_compile_time_config.c test/query_config.o test/query_config.h $(DEP)
388-
echo " CC test/query_compile_time_config.c"
389-
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/query_compile_time_config.c test/query_config.o $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
390+
test/query_compile_time_config$(EXEXT): $(FRAMEWORK)/tests/programs/query_compile_time_config.c test/query_config.o $(FRAMEWORK)/tests/programs/query_config.h $(DEP)
391+
echo " CC $(FRAMEWORK)/tests/programs/query_compile_time_config.c"
392+
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $(FRAMEWORK)/tests/programs/query_compile_time_config.c test/query_config.o $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
390393

391394
util/pem2der$(EXEXT): util/pem2der.c $(DEP)
392395
echo " CC util/pem2der.c"

programs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This subdirectory mostly contains sample programs that illustrate specific featu
5353

5454
## Random number generator (RNG) examples
5555

56-
* [`random/gen_entropy.c`](random/gen_entropy.c): shows how to use the default entropy sources to generate random data.
56+
* [`random/gen_entropy.c`](random/gen_entropy.c): shows how to use the default entropy sources to generate random data.
5757
Note: most applications should only use the entropy generator to seed a cryptographic pseudorandom generator, as illustrated by `random/gen_random_ctr_drbg.c`.
5858

5959
* [`random/gen_random_ctr_drbg.c`](random/gen_random_ctr_drbg.c): shows how to use the default entropy sources to seed a pseudorandom generator, and how to use the resulting random generator to generate random data.
@@ -96,7 +96,7 @@ In addition to providing options for testing client-side features, the `ssl_clie
9696

9797
* [`test/udp_proxy.c`](test/udp_proxy.c): a UDP proxy that can inject certain failures (delay, duplicate, drop). Useful for testing DTLS.
9898

99-
* [`test/zeroize.c`](test/zeroize.c): a test program for `mbedtls_platform_zeroize`, used by [`tests/scripts/test_zeroize.gdb`](tests/scripts/test_zeroize.gdb).
99+
* [`test/zeroize.c`](../framework/tests/programs/zeroize.c): a test program for `mbedtls_platform_zeroize`, used by [`test_zeroize.gdb`](../framework/tests/programs/test_zeroize.gdb).
100100

101101
## Development utilities
102102

programs/demo_common.sh

Lines changed: 0 additions & 137 deletions
This file was deleted.

programs/psa/key_ladder_demo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright The Mbed TLS Contributors
44
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
55

6-
. "${0%/*}/../demo_common.sh"
6+
. "${0%/*}/../../framework/scripts/demo_common.sh"
77

88
msg <<'EOF'
99
This script demonstrates the use of the PSA cryptography interface to

programs/psa/psa_hash_demo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright The Mbed TLS Contributors
44
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
55

6-
. "${0%/*}/../demo_common.sh"
6+
. "${0%/*}/../../framework/scripts/demo_common.sh"
77

88
msg <<'EOF'
99
This program demonstrates the use of the PSA cryptography interface to

programs/ssl/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,19 @@ foreach(exe IN LISTS executables)
3535
if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
3636
list(APPEND extra_sources
3737
ssl_test_lib.c
38-
${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.h
38+
${MBEDTLS_FRAMEWORK_DIR}/tests/programs/query_config.h
3939
${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c)
4040
endif()
4141
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
4242
${extra_sources})
4343
target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT})
44-
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include
44+
target_include_directories(${exe} PRIVATE ${MBEDTLS_FRAMEWORK_DIR}/tests/programs
45+
${MBEDTLS_FRAMEWORK_DIR}/tests/include
4546
${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
4647
if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
4748
if(GEN_FILES)
4849
add_dependencies(${exe} generate_query_config_c)
4950
endif()
50-
target_include_directories(${exe}
51-
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../test)
5251
endif()
5352
endforeach()
5453

0 commit comments

Comments
 (0)