11850 Commits

Author SHA1 Message Date
Harry Ramsey
8b3f513c0a Fix linking error for mbedtls_test_hook_error_add
This commit fixes a linking error with psa_sim_crypto_server.c where
mbedtls_test_hook_error_add was undefined.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-21 14:49:57 +01:00
Harry Ramsey
b791a88c33 Fix test case dependency
This commit fixes the error test suite to depend on MBEDTLS_ERROR_C
rather than MBEDTLS_ERRORCOMMON_C.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-21 12:07:27 +01:00
Harry Ramsey
bef54c5003 Remove unnecessary if defined
This commit removes unnecessary if defined for multiple files as they
are already guarded.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-21 12:00:24 +01:00
Harry Ramsey
924dca9d39 Move mbedtls_test_hook_error_add from error.c to helpers.c
This commit moves mbedtls_test_hook_error_add from error.c to helpers.c.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 15:16:05 +01:00
Harry Ramsey
8b4b15269a Fix test scripts for split error files
This commit fixes failing tests to do with generated files and code
styles.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
bd77a35b95 Move tests for error.c from tf-psa-crypto to Mbed TLS
This commit moves the test functions and test data from tf-psa-crypto to
Mbed TLS.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
David Horstmann
13d2939563
Merge pull request #9673 from eleuzi01/issue-54-fw
Move TLS auxiliary test scripts to the framework
2024-10-17 17:15:46 +00:00
Gilles Peskine
e1f37c58a2
Merge pull request #9566 from gilles-peskine-arm/error-codes-4.0-enforce-add-macro
Error codes: enforce add macro
2024-10-16 17:28:04 +00:00
Gilles Peskine
8085f51108 Use MBEDTLS_ERROR_ADD instead of explicit addition: enforcement
Reject direct additions of error constants (regex-based approximation).

Fix the lone straggler.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 11:52:27 +02:00
Gilles Peskine
ed6feae513 Use MBEDTLS_ERROR_ADD instead of explicit addition: simple cases
Replace obvious additions of an `MBEDTLS_ERR_xxx` constant by a call to
`MBEDTLS_ERROR_ADD`.

Skip `case` statements since `MBEDTLS_ERROR_ADD(pp_constant)` is not a
preprocessor constant.

This commit does not replace additions split over lines. Those will be
handled in a subsequent commit.

```
git ls-files '*.h' '*.c' '*.function' '*.data' |
xargs perl -i -pe '
    next if /\bcase\b/;
    s/\b(MBEDTLS_ERR_\w+)\s*\+\s*(\w+)\b/MBEDTLS_ERROR_ADD($1, $2)/g;
    s/\b(\w+)\s*\+\s*(MBEDTLS_ERR_\w+)\b/MBEDTLS_ERROR_ADD($1, $2)/g'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 11:52:24 +02:00
Ronald Cron
ede04b34d1 Remove unnecessary -O2 compilation flag
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-16 10:47:15 +02:00
Ronald Cron
a0afbfb2a4 Fix/Add documentation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-15 17:09:36 +02:00
Ronald Cron
67cc6a73aa Use config_adjust_test_accelerators.h
Use config_adjust_test_accelerators.h
to adjust the configuration needed for
test_psa_crypto_drivers all.sh component
with PSA_CRYPTO_CONFIG enabled.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-15 17:09:36 +02:00
Ronald Cron
db11561352 Introduce config_adjust_test_accelerators.h
As we move to PSA_CRYPTO_CONFIG always on,
the way to configure the build with both
the builtin drivers and the transparent test
drivers (that are wrappers around the
builtin drivers) cannot be done through the
MBEDTLS_USER_CONFIG_FILE mechanism anymore.

With this mechanism and PSA_CRYPTO_CONFIG
enabled, the PSA_ACCEL_ macros are defined
before including config_adjust_legacy_from_psa.h
and the builtin implementations are removed.

Thus, we will rather define the PSA_ACCEL_
just after the inclusion of
config_adjust_legacy_from_psa.h through the
dedicated config_adjust_test_accelerators.h
header introduced by this commit.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-15 17:09:36 +02:00
Elena Uziunaite
9669eeabcf Adjust file path for translate_ciphers.py
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-10-15 11:45:15 +01:00
Elena Uziunaite
b74c3eaf87 Adjust file path for generate_tls13_compat_tests.py
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-10-15 11:45:05 +01:00
Elena Uziunaite
09fee364a3 Adjust file path for generate_ssl_debug_helpers.py
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-10-15 11:43:51 +01:00
Elena Uziunaite
2df289290f Move some files to framework repository
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-10-15 11:41:39 +01:00
Gilles Peskine
80352ac58c
Merge pull request #9668 from gilles-peskine-arm/analyze_outcome-split-dev
Split check_test_cases.py and outcome_analysis.py
2024-10-10 13:45:49 +00:00
Gilles Peskine
96db2ccedd Default to allowing partial test coverage
Currently, many test cases are not executed. A follow-up pull request will
take care of that. In the meantime, continue allowing partial test coverage.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 14:12:59 +02:00
Gilles Peskine
9f85399e7b Move test case analysis modules to framework repository
Move `collect_test_cases.py` (split from `check_test_cases.py`),
`check_test_cases.py`, and `outcome_analysis.py` (split from
`analyze_outcomes.py`) to the framework repository.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-09 14:12:05 +02:00
Gilles Peskine
3146772575 Adjust paths for impending moves to the framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-08 19:37:23 +02:00
Harry Ramsey
d617283187 Fix failing psasim tests
This commit fixes failing psasim tests by ensuring that
MBEDTLS_VERSION_C is defined before attempting to access version
information.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-07 14:50:00 +01:00
Harry Ramsey
f7e7acc9c1 Move version tests from tf-psa-crypto/test/suite to test/suites
This commit reverts the moves the test for version from
tf-psa-crypto/test/suite to test/suites.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-04 13:37:42 +01:00
Harry Ramsey
468c0aede9 Revert move of version.h to tf-psa-crypto libray
This commit moves version.h back into /include/mbedtls from
tf-psa-crypto/drivers/builtin/include. This commit also changes the
necessary build files and scripts to generate version_features.c

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-04 13:37:42 +01:00
Ronald Cron
467edcd64a
Merge pull request #9445 from ronald-cron-arm/tf-psa-crypto-cmake-build
Add crypto only CMake build system
2024-10-03 20:56:00 +00:00
Gilles Peskine
082eadef4e Separate code and data of outcome analysis
Place the code of outcome analysis (auxiliary functions, tasks, command line
entry point) into a separate module, which will be moved to the
version-independent framework repository so that it can be shared between
maintained branches. Keep the branch-specific list of driver components and
ignore lists in the per-repository script.

We keep the executable script at `tests/scripts/analyze_outcomes.py`. It's
simpler that way, because that path is hard-coded in CI scripts.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:42:37 +02:00
Gilles Peskine
e41cde57c3 Pass KNOWN_TASKS as an argument to main
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:36:09 +02:00
Gilles Peskine
005dca6ad8 Typecheck main
Always have tasks_list be a list, not potentially some fancier iterable.

Bypass mypy's somewhat legitimate complaint about REFERENCE and DRIVER in
task_class: they could potentially be instance attributes, but we rely on
them being class attributes. Python does normally guarantee their existence
as class attributes (unless a derived class explicitly deletes them), but
they could be overridden by an instance attribute; that's just something
we don't do, so the class attribute's value is legitimate. We can't
expect mypy to know that, so work around its complaint.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:31:38 +02:00
Gilles Peskine
ad02d44e01 Don't reuse a variable name inside a function
Use different names for task name, a task class and a task instance. The
interpreter doesn't care, but it's less confusing for both humans and type
checkers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:28:28 +02:00
Gilles Peskine
9d78e87b49 Missing NotImplementedError in abstract method
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 18:18:33 +02:00
Gilles Peskine
49c77dd0e4 Remove sample ignore list elements for coverage
The ignore list for coverage only has two test cases out of ~10000 that are
currently reported as not executed. This is a drop in the sea and not
useful. Remove them so that the class can be used generically. A follow-up
will construct a comprehensive ignore list.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 17:40:55 +02:00
Gilles Peskine
9f930e0f9e Create a module to split branch-independent code out of analyze_outcomes.py
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 17:38:32 +02:00
Gilles Peskine
c8c83d0303 Split test case collection from checks
Move the test case collection code out of check_test_cases.py and into its
own module. This allows outcome analysis to depend only on the new module
and not on check_test_cases.py.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 17:35:52 +02:00
Gilles Peskine
1e5dbd3c7c Create a module to split test case collection from checks
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-03 17:23:53 +02:00
Gilles Peskine
38d4c91b06
Merge pull request #9594 from gilles-peskine-arm/analyze_outcomes-classes-development
analyze_outcomes.py refactoring: change stringly typed data to classes
2024-10-03 10:38:04 +00:00
Gilles Peskine
13b4954597 Remove "error" allowance in dtls_server
Now that dtls_server doesn't print "error" when it receives stray messages
while it's waiting for a second handshake, have the tests fail if "error" is
printed for some other reason.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-02 11:09:20 +02:00
Minos Galanakis
393f9a1dde test_psa_compliance: Use the pre-built library
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2024-10-01 15:32:01 +02:00
Minos Galanakis
308c737572 Add all.sh component
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
b6254f5b97 cmake: Add MBEDTLS_FRAMEWORK_DIR
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
69c489c25a Move PSA drivers to drivers/builtin/src
They were mistakenly moved to the
core directory from the library
directory.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
7d5419b6f1 Move test_suite_constant_time_hmac back to mbedtls
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Gilles Peskine
46771295f2
Merge pull request #9558 from gilles-peskine-arm/run-test-suites-on-subproject
Run test suites on subproject
2024-09-28 08:31:30 +00:00
Gilles Peskine
0930b331c0 Don't use the "allow list" terminology any longer
What was formerly called an allow list is now an ignore table.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-27 18:28:29 +02:00
David Horstmann
1a09caa8a8
Merge pull request #9638 from gilles-peskine-arm/ssl-opt-sample-programs-dev
Test sample programs in ssl-opt.sh
2024-09-26 14:33:11 +00:00
David Horstmann
b268d270ed
Merge pull request #9413 from sezrab/split_numeric_string_conversions_oid-development
Split numeric string conversions out of the OID module
2024-09-26 12:50:37 +00:00
Gilles Peskine
f88f6d6b83 Stop testing without PSA
Stop testing configurations without PSA (MBEDTLS_PSA_CRYPTO_C or at least
MBEDTLS_PSA_CRYPTO_CLIENT). No future release from this branch will support
such configurations, and we can no longer build the SSL sample programs
without psa_crypto_init.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-26 10:21:39 +02:00
Gilles Peskine
465837b24d Disable session tickets for ssl_client1 when using TLS 1.3
TLS 1.3 session tickets require additional handling in the client.
https://github.com/Mbed-TLS/mbedtls/issues/8749

Disable session tickets for ssl_client1 when using TLS 1.3
until https://github.com/Mbed-TLS/mbedtls/issues/6640 is resolved
and (if relevant) implemented in ssl_client1.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 21:26:02 +02:00
Gilles Peskine
f9ad8303f1 Skip ssl_server in config-suite-b
When building with `configs/config-suite-b.h`, the SSL I/O buffer size is
1024 bytes. Experimentally, this isn't quite enough for the test certificate
that we use: the server aborts the handshake with
`MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL` raised from
`mbedtls_ssl_write_certificate()`. State an ad hoc minimum output buffer
size to skip testing `ssl_server` in `config-suite-b`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 18:05:18 +02:00
Gilles Peskine
e13ff09aff Use OPENSSL_NEXT for a test case that uses IPv6 when available
dtls_client connects to "localhost", which is usually IPv6 on modern
systems. On our CI, $OPENSSL is OpenSSL 1.0.2g which doesn't support IPv6.
Pitching dtls_client against $OPENSSL works on the CI at the moment, but
only because the CI runs in Docker with default network settings which has
IPv6 disabled. This would stop working if we changed the CI's Docker setup,
and the test case is likely to fail on a developer machine. So switch the
test case to using $OPENSSL_NEXT (which is a version of OpenSSL that has
IPv6 support).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-09-25 18:05:17 +02:00