1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-04-19 01:04:04 +03:00

2791 Commits

Author SHA1 Message Date
Gilles Peskine
74383ab137
Merge pull request #10132 from valeriosetti/issue157-3.6
[3.6] Make demo_common.sh usable on its own
2025-04-18 11:11:11 +00:00
Max Fillinger
6f7cf0e402 Use mbedtls_calloc, not regular calloc
Also fix the allocation size.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
a442aea2be Fix memory leak in example programs
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:49 +02:00
Max Fillinger
951b886801 Create MBEDTLS_SSL_KEYING_MATERIAL_EXPORT option
Add the option MBEDTLS_SSL_KEYING_MATERIAL_EXPORT to mbedtls_config.h
to control if the function mbedtls_ssl_export_keying_material() should
be available. By default, the option is disabled.

This is because the exporter for TLS 1.2 requires client_random and
server_random need to be stored after the handshake is complete.

Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:20:50 +02:00
Max Fillinger
7b52328f6c Remove TLS 1.2 Exporter if we don't have randbytes
The TLS-Exporter in TLS 1.2 requires client_random and server_random.
Unless MBEDTLS_SSL_CONTEXT_SERIALIZATION is defined, these aren't stored
after the handshake is completed.

Therefore, mbedtls_ssl_export_keying_material() exists only if either
MBEDTLS_SSL_CONTEXT_SERIALIZATION is defined or MBEDTLS_SSL_PROTO_TLS1_2
is *not* defined.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:50 +02:00
Max Fillinger
948e15d3b7 Fix typos in comments
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:50 +02:00
Max Fillinger
9359f4d703 Fix coding style
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:20:49 +02:00
Max Fillinger
77a447ba97 Actually set exporter defaults in ssl_client2
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
de3d5fdc83 Add TLS-Exporter options to ssl_client2
Prints out the exported key on the command line for testing purposes.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
90ed7f7f5e Add TLS-Exporter options to ssl_server2
The program prints out the derived symmetric key for testing purposes.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Valerio Setti
3302dc6510 programs: demo: do not source project_detection.sh directly
Let "demo_common.sh" do all that it's required for these script to
work properly.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-11 15:07:02 +02:00
Valerio Setti
5533cc8077 programs: demo: source project_detection.sh
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-10 14:15:41 +02:00
Minos Galanakis
05657d9dee Revert "Add auto-generated files"
This reverts commit 22098d41c6620ce07cf8a0134d37302355e1e5ef.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-23 13:09:30 +00:00
Minos Galanakis
22098d41c6 Add auto-generated files
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-20 09:33:09 +00:00
Minos Galanakis
7a95d16a31 Merge branch 'mbedtls-3.6-restricted' into mbedtls-3.6.3rc0-pr
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-18 16:28:26 +00:00
Minos Galanakis
dfc8e43614 Merge remote-tracking branch 'upstream/mbedtls-3.6' into pre-3.6.3-upstream-merge 2025-03-14 14:23:23 +00:00
Minos Galanakis
eec6eb9cd4 programs -> ssl_client2.c: Added option renego_delay to set record buffer depth.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-14 00:10:10 +00:00
Gilles Peskine
b6102b6ccf Fix Doxygen markup
Pacify `clang -Wdocumentation`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
Gilles Peskine
e0f1240cd5 Merge remote-tracking branch 'mbedtls-3.6' into tls-defragmentation-merge-3.6-20250303 2025-03-02 21:16:08 +01:00
Harry Ramsey
65e9bef19f Update documentation regarding test_zeroize
This commit updates the paths in documentation for test_zeroize since it
has been moved to MbedTLS Framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-20 14:51:26 +00:00
Harry Ramsey
4e1a12e13a Update path to demo_common.sh
This commit updates the path to demo_common.sh as it has been moved into
MbedTLS Framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-20 14:51:26 +00:00
Harry Ramsey
061e0f5466 Update paths for moved program files in CMakeLists
This commit fixes the paths of program files which were moved to the
MbedTLS Framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-20 14:51:26 +00:00
Harry Ramsey
dab817a4c6 Update include paths in C files
Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-20 14:51:26 +00:00
Harry Ramsey
a67f1338b6 Update paths for moved program files in makefiles
This commit updates the file paths necessary for dlopen_demo.sh,
metatest.c query_compile_time_config.c, query_config.h,
query_included_headers.c and zeroize.c.

This commit also adds a CFLAG to find header files now contained in the
framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-20 14:51:18 +00:00
Gilles Peskine
c52273d017 Add a note about badmac_seen's new name in ssl_context_info
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-18 14:11:25 +01:00
Harry Ramsey
0c6eb5d6e9 Move programs out of Mbed TLS
This commit moves demo_common.sh, dlopen_demo.sh, metatest.c
query_compile_time_config.c, query_config.h, query_included_headers.c,
zeroize.c and test_zeroize.gdb from MbedTLS into the MbedTLS framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-17 11:43:55 +00:00
Gilles Peskine
b3de9da6b0 mbedtls_ssl_set_hostname tests: baseline
Test the current behavior.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-13 21:24:01 +01:00
Gilles Peskine
2a8acc41b2 Make guards more consistent between X.509-has-certs and SSL-has-certs
Fix some build errors when MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED is false
but MBEDTLS_X509_CRT_PARSE_C is enabled. This is not a particularly useful
configuration, but for quick testing, it's convenient for it to work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-13 20:57:32 +01:00
Gilles Peskine
154269d25b Fix Doxygen markup
Pacify `clang -Wdocumentation`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-13 20:57:12 +01:00
David Horstmann
1d9b033067 Add SSL-related test includes to ssl programs
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
7d81e8a243 Add missing extra include path to fuzzer programs
The fuzzer needs both kinds of test helper so needs to include things
from both new and old locations.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
dcf42a0b53 Update references to test helpers
Replace:
* tests/src -> framework/tests/src
* tests/include -> framework/tests/include

Except for occurrences of:
* tests/src/test_helpers (since this only contains ssl_helpers.c)
* tests/src/test_certs.h
* tests/include/alt_dummy

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:40 +00:00
Paul Elliott
346d2f4e58
Merge pull request #9731 from gilles-peskine-arm/coverity-20241004-3.6
Backport 3.6: Fix edge cases of mbedtls_psa_raw_to_der and mbedtls_psa_der_to_raw
2024-11-06 19:02:54 +00:00
Bence Szépkúti
5544b280ed
Merge pull request #9118 from jetm/ssl-client2-get-req-host-3.6
Backport 3.6: ssl_client2: Add Host to HTTP GET request
2024-10-31 11:32:55 +00:00
Gilles Peskine
f7b62e063d Remove unreachable assignments
This is harmless, but we might as well remove the unreachable line. If we
ever add a break to the loop and we don't think of changing the surrounding
code, it would make more sense not to set exit_code to SUCCESS.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-28 10:09:18 +01:00
Gilles Peskine
62163142a0 dtls_server: allow unexpected messages during handshake
If MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE happens during the handshake, don't
show it as an "error". It might be an error, but it might also be a fact of
life if it happens during the second or more handshake: it can be a
duplicated packet or a close_notify alert from the previous connection,
which is hard to avoid and harmless.

Fixes #9652.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-01 12:50:05 +02:00
Gilles Peskine
ff85e91914 dtls_client: don't force the use of IPv6
Default to connecting to "localhost", like ssl_client1.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
3104685cc6 ssl_server: Allow the client to close the connection first
This is necessary when testing against OpenSSL 1.0.2g.

In the server, flush more often. Otherwise, when stdout is redirected to a
file, the server gets killed before it writes important information, such as
the logs that we expect in the test cases.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
9d104e9857 Test dtls_server
Test against both OpenSSL and GnuTLS.

Don't use a proxy. It's not particularly useful here, and would complicate
figuring out port numbers.

Clean up compile-time requirements dtls_server.c: any certificate-based key
exchange is ok, so don't insist on built-in RSA.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
2a0af359f1 Test ssl_fork_server
Test ssl_fork_server with both TLS 1.2 and TLS 1.3.
Test against both OpenSSL and GnuTLS.

In the server, flush more often. Otherwise, when stdout is redirected to a
file, the server gets killed before it writes important information, such as
the logs that we expect in the test cases.

In the server, only write output for 10 seconds, not 100. That's enough time
to start concurrent clients if desired. 100 seconds causes ssl-opt to take a
very long time when the client actually listens to the whole input (which
`gnutls-cli` does, but not `openssl s_client`).

Clean up compile-time requirements in ssl_fork_server.c: any certificate-based
key exchange is ok, so don't insist on built-in RSA.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
fab6099d4a Test ssl_pthread_server
Test ssl_pthread_server with both TLS 1.2 and TLS 1.3.
Test against both OpenSSL and GnuTLS.

In the server, flush more often. Otherwise, when stdout is redirected to a
file, the server gets killed before it writes important information, such as
the logs that we expect in the test cases.

Clean up compile-time requirements in ssl_pthread_server.c: any certificate-based
key exchange is ok, so don't insist on built-in RSA.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
37c374981c Test ssl_server
Test ssl_server with both TLS 1.2 and TLS 1.3.
Test against both OpenSSL and GnuTLS.

Clean up compile-time requirements in ssl_server.c: any certificate-based
key exchange is ok, so don't insist on built-in RSA.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
f8b373e869 Test dtls_client
Test against both OpenSSL and GnuTLS.

Don't use a proxy. It's not particularly useful here, and would complicate
figuring out port numbers.

Clean up compile-time requirements in dtls_client.c: any certificate-based
key exchange is ok, so don't insist on built-in RSA.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
e6b8250a94 Test ssl_client1
Test ssl_client1 with both TLS 1.2 and TLS 1.3.
Test against both OpenSSL and GnuTLS.

Clean up compile-time requirements in ssl_client1.c: any certificate-based
key exchange is ok, so don't insist on built-in RSA.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
dd51826b4e ssl_client1: Exit with an error status if the TLS connection failed
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 17:52:48 +02:00
Gilles Peskine
278b417752 Have make ssl-opt generate tls13-compat.sh
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 09:52:28 +02:00
Gilles Peskine
f0d2eb5828
Merge pull request #9603 from gilles-peskine-arm/test-ref-configs-go-away-3.6
Backport 3.6: Switch from test-ref-configs.pl to separate components
2024-09-24 13:00:54 +00:00
Gilles Peskine
b35ed4565a make: support "make ssl-opt" to just build what ssl-opt.sh needs
This also suffices for compat.sh.

Include the sample programs in this build. They aren't tested by ssl-opt.sh
yet, but they soon will be.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:47:04 +02:00
Gilles Peskine
7215b1e9c9 CMake: support "make ssl-opt" to just build what ssl-opt.sh needs
This also suffices for compat.sh.

Include the sample programs in this build. They aren't tested by ssl-opt.sh
yet, but they soon will be.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:46:58 +02:00
Gilles Peskine
bb47c7368b CMake: support "make programs"
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-19 18:46:52 +02:00