Commit Graph

6583 Commits

Author SHA1 Message Date
Gilles Peskine
1309493225 Run part of ssl-opt.sh in full_no_deprecated
In particular, run the test case
"Authentication: hostname unset, client required, secure config, CA callback"

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-25 18:47:24 +01:00
Gilles Peskine
f086b8f0f1 mbedtls_ssl_set_hostname tests: add tests with CA callback
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-24 18:04:29 +01:00
Gilles Peskine
18b52ce40c Call mbedtls_ssl_set_hostname in the generic endpoint setup in unit tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-24 18:04:29 +01:00
Gilles Peskine
551756df7c Require calling mbedtls_ssl_set_hostname() for security
In a TLS client, when using certificate authentication, the client should
check that the certificate is valid for the server name that the client
expects. Otherwise, in most scenarios, a malicious server can impersonate
another server.

Normally, the application code should call mbedtls_ssl_set_hostname().
However, it's easy to forget. So raise an error if mandatory certificate
authentication is in effect and mbedtls_ssl_set_hostname() has not been
called. Raise the new error code
MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME, for easy
identification.

But don't raise the error if the backward compatibility option
MBEDTLS_SSL_CLI_ALLOW_WEAK_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME is
enabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-24 18:04:29 +01:00
Gilles Peskine
ae59c52322 Create configuration option to bypass the mbedtls_ssl_set_hostname check
Update generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-24 18:04:14 +01:00
Gilles Peskine
f33c45f84d Keep track of whether mbedtls_ssl_set_hostname() has been called
Use a special marker as ssl->hostname if mbedtls_ssl_set_hostname() has been
called with NULL. If mbedtls_ssl_set_hostname() has never been called, the
field is NULL, as before.

No behavior change apart from now emitting a different log message depending
on whether mbedtls_ssl_set_hostname() has been called with NULL or not at all.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-21 19:33:53 +01:00
Gilles Peskine
724a7bbd92 mbedtls_ssl_set_hostname tests: baseline
Test the current behavior.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-20 12:46:46 +01:00
Gilles Peskine
eac2e4daef Automate MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK dependency
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-20 12:38:22 +01:00
Gilles Peskine
e681a4e7e5 Fix copypasta
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-12-02 21:40:21 +01:00
Harry Ramsey
9d99e98503 Remove trailing whitespace
This commit removes trailing whitespace in test_suite_gcm.function.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-13 15:57:29 +00:00
Harry Ramsey
a1abbdb2b3 Add new line to end of test case files
This commit adds a new line to the end of test case files to pass
check_files.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-13 12:49:34 +00:00
Harry Ramsey
0cd29510f6 Add test cases for AES GCM input and output buffer overlap
This commit adds test cases for input and output buffer overlap. The
data for the test cases is a duplicate of existing encrypt/decrypt test
cases.

The two test functions gcm_<encrypt/decrypt>_input_output_buffer_overlap
are modified to use a single malloc buffer rounded to the nearest
128-bits/16-bytes for input and output.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-11-13 11:23:57 +00:00
Paul Elliott
89c68e206b Merge pull request #9736 from mpg/drop-armcc5-2.28
[2.28] Drop armcc5 support in all.sh
2024-10-30 12:29:32 +00:00
Gilles Peskine
89a87b5353 Merge pull request #9729 from paul-elliott-arm/fix_new_coverity_issues_2.28
[Backport 2.28] Fix new coverity issues
2024-10-29 14:58:39 +00:00
Manuel Pégourié-Gonnard
a674e988c9 Drop building with armcc5 in all.sh
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-29 11:52:49 +01:00
Bence Szépkúti
61da0ddb07 Add override arguments for new gcc targets
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:33:48 +01:00
Bence Szépkúti
b14dd763c3 Clarify GCC version requirement
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:33:09 +01:00
Bence Szépkúti
478730eed2 Split up the Thumb-1 test component
The Thumb-1 tests are by far the slowest, so split the -O0 and -Os tests
into their own components.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:32:41 +01:00
Bence Szépkúti
73d8640bd3 Remove superfluous invocations of make clean
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:31:55 +01:00
Bence Szépkúti
f92112d7be Update component speed estimates
The estimates are based on the most recent CI run.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:30:20 +01:00
Bence Szépkúti
a56b61c6ee Initialize result caching variables
This prevents interference from identically named environment variables.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:29:49 +01:00
Bence Szépkúti
63a10d0726 Use true/false in place of integers
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:29:20 +01:00
Bence Szépkúti
08c14d1412 Ignore missing temporary files during cleanup
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:29:06 +01:00
Bence Szépkúti
26822ab1b6 Fix copypasta in gcc_version
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:28:50 +01:00
Bence Szépkúti
915fa3e6c7 Add AArch64 default config test
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:28:18 +01:00
Bence Szépkúti
86aa780e5a Add Arm eabi default config tests
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 13:27:39 +01:00
Paul Elliott
417b8d92a1 Pair inits with declarations
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-25 12:47:23 +01:00
Paul Elliott
9488b8c513 Fix double free in case of test failure
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-25 12:00:05 +01:00
Paul Elliott
1348b6a861 Add missing check of return
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-25 11:59:59 +01:00
Paul Elliott
181564bb89 Fix tests where tests were done prior to init
Variables that are in any way destructed on exit should be initialised
prior to any tests that might jump to exit, to save potential
uninitialised memory accesses.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-25 11:59:11 +01:00
Gilles Peskine
bfe4fc6749 Use -O2 for build+test with earliest compilers
The compilation is slower but we get more potential warnings and running the
tests is faster.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 15:09:58 +02:00
Gilles Peskine
8214340bb0 Fix spurious * in regex
`grep mbedtls_des*` would pick up e.g. mbedtls_derive_xxx.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 15:09:48 +02:00
Gilles Peskine
c61187f508 Don't set LD to a path with a typo for mingw
Our makefiles don't use $(LD) so the typo was harmless.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-20 15:09:02 +02:00
Sergei Trofimovich
990a88cd53 tests: fix calloc() argument list (gcc-14 fix)
`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `mbedtls`:

    In file included from /build/mbedtls/tests/include/test/ssl_helpers.h:19,
                     from /build/mbedtls/tests/src/test_helpers/ssl_helpers.c:11:
    /build/mbedtls/tests/src/test_helpers/ssl_helpers.c: In function 'mbedtls_test_init_handshake_options':
    /build/mbedtls/tests/include/test/macros.h:128:46:
      error: 'calloc' sizes specified with 'sizeof' in the earlier argument
        and not in the later argument [-Werror=calloc-transposed-args]
      128 |             (pointer) = mbedtls_calloc(sizeof(*(pointer)),  \
          |                                              ^

Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
2024-09-02 22:09:13 +02:00
Manuel Pégourié-Gonnard
9f7cc4c14f Bump version to 2.28.9
Soversions unchanged.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-08-26 12:44:41 +02:00
Gilles Peskine
36548eefa4 Merge pull request #9256 from gilles-peskine-arm/psa-keystore-dynamic-backport-2.28
Backport 2.28: prepare for dynamically sized key store
2024-08-09 08:00:01 +00:00
Gilles Peskine
4c9d43fb18 Improve documentation in some tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-08 15:57:57 +02:00
Gilles Peskine
3a51fdc8c6 Improve full-key-store tests
Split the "many transient keys" test function in two: one that expects to
successfully create many keys, and one that expects to fill the key store.
This will make things easier when we add a dynamic key store where filling
the key store is not practical unless artificially limited.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-07 11:17:32 +02:00
Gilles Peskine
91773db331 Add a test for the built-in key range
Restricting the built-in key range would be an API break since applications
can hard-code a built-in key value and expect that it won't clash with
anything else. Make it harder to accidentally break the API.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-07 11:17:32 +02:00
Gilles Peskine
37a4fcc5b4 Prevent mbedtls_psa_register_se_key with volatile keys
mbedtls_psa_register_se_key() is not usable with volatile keys, since there
is no way to return the implementation-chosen key identifier which would be
needed to use the key. Document this limitation. Reject an attempt to create
such an unusable key. Fixes #9253.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-08-07 11:17:32 +02:00
Tomás González
a526528de3 tests/ssl_helpers: Check that message queue is popped
mbedtls_test_mock_tcp_recv_msg is currently popping a message
queue and does not check if this was done correctly.

This extra check makes the test more complete/robust.

Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2024-07-31 17:25:40 +01:00
Wenxing Hou
20e964f1c6 Fix some typo for include folder
Signed-off-by: Wenxing Hou <wenxing.hou@intel.com>
2024-07-12 11:43:33 +03:00
Gilles Peskine
a76a6ff8df Adjust TLS protocol cases for 2.28
TLS 1.3 is still experimental and partial, and SSL3 is obsolete, so we don't
expect much coverage about them, in particular we don't expect them to be
the sole supported version. TLS 1.0 and 1.1 exist and we expect good
coverage for them.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-07-01 11:32:33 +02:00
Gilles Peskine
93708fe126 Fix copypasta
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-28 19:16:25 +02:00
Gilles Peskine
b19fa4e6c7 Declare the new generated files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:12:34 +02:00
Gilles Peskine
d33c48b407 Add generated config tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:12:22 +02:00
Gilles Peskine
cfba2477e6 Remove some settings that don't exist in 2.28
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:11:59 +02:00
Gilles Peskine
744741bf2c Adjust generate_config_tests.py for 2.28
* Move to the correct location.
* Adjust the package name for auxiliary modules.
* Adjust the hack to import a module from scripts.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 20:05:10 +02:00
Gilles Peskine
ae27ca9e0a Anchor relative paths
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 19:52:12 +02:00
Gilles Peskine
14f91c9d89 New test suite to report configuration options
Add a test suite intended to report configuration options in the outcome
file: we're only interested in SKIP vs PASS.

Add a few test cases for some interesting combinations of options. The
selection here is just for illustration purposes, more will be added later.

A subsequent commit will automatically generate test cases for single options.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-06-26 19:49:59 +02:00