32229 Commits

Author SHA1 Message Date
Manuel Pégourié-Gonnard
73e2b056ca all.sh: extract repeated code to a function
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-09 12:54:05 +02:00
Manuel Pégourié-Gonnard
78c7592755 all.sh: group psasim helpers
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-09 12:54:04 +02:00
Manuel Pégourié-Gonnard
9896e08f5e all.sh: rm obsolete functions
The only occurrences found by git grep were the definitions and the
comment saying these are kept for backwards compatibility.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-09 12:54:04 +02:00
Manuel Pégourié-Gonnard
f7325865bb all.sh: first define functions, then call them.
Don't interleave defining functions with running some code.

The only exception is calling shopt, which needs to come first as it
affects how the following function definitions are parsed.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-09 12:54:04 +02:00
Harry Ramsey
0f6bc41a22 Update includes for each library file
Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-09 11:18:50 +01:00
Harry Ramsey
91c6d4f819 Add include for common.h
Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-09 11:18:50 +01:00
Harry Ramsey
84f868ec53 Move library/common.h to tf-psa-crypto/core directory
This commit moves common.h from library to tf-psa-crypto/core.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-09 11:18:50 +01:00
Harry Ramsey
f8983dc321 Remove common.h from tf-psa-crypto/core
This commit removes common.h from tf-psa-crypto/core directory.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-09 11:18:50 +01:00
Ronald Cron
e21e9c33c5
Merge pull request #9653 from Harry-Ramsey/revert-version-features-development
Revert move of version.h to tf-psa-crypto library
2024-10-09 08:05:38 +00: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
da8f42a357 Improve support for submodules in code_style.py
This commit improves support for submodules within code_style.py. A new
function get_submodule_hash retrieves the submodule hash at the time of
a commit allowing an appropriate diff to be seen.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-07 10:41:47 +01:00
Gilles Peskine
e589f5fcf1 Changelog entry for ECDSA conversion functions called with bits=0
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-07 11:28:09 +02:00
Gilles Peskine
1392017263 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-07 11:23:39 +02:00
Gilles Peskine
0dbad8573d Assert non-empty data when needed
Pacify Coverity about subtracting from the length, and give a signal to
human readers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-07 11:12:17 +02:00
Gilles Peskine
d6b6c1d4ac Initialize CCM context before doing anything fallible
Otherwise mbedtls_ccm_free() in cleanup could corrupt memory if a failure
happens.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-07 11:11:32 +02:00
Gilles Peskine
1ba7e24e14 mbedtls_ecdsa_raw_to_der and mbedtls_ecdsa_der_to_raw: reject bits==0
Cleanly reject bits == 0 when calling mbedtls_ecdsa_raw_to_der() and
mbedtls_ecdsa_der_to_raw(). This can plausibly happen when bits is
user-provided data that the calling application doesn't check.

Before this patch, there was typically-benign undefined behavior, such as
adding 0 to a null pointer or calling memcpy on a null pointer with a size
of 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-04 18:56:17 +02:00
Gilles Peskine
995702dbae Document errors for mbedtls_ecdsa_raw_to_der and mbedtls_ecdsa_der_to_raw
Document the return value of mbedtls_ecdsa_raw_to_der() and
mbedtls_ecdsa_der_to_raw().

Document that mbedtls_ecdsa_raw_to_der() has undefined behavior when the
output buffer parameter is null, even with a size of 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-04 18:35:01 +02:00
Gilles Peskine
d5a21cf2fd mbedtls_mpi_write_binary{,_le}: test 0-size output
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-04 18:09:00 +02:00
Gilles Peskine
2e26a65ae3 Modernize mpi_write_binary and mpi_write_binary_le
Use TEST_CALLOC instead of a fixed-size buffer, so that Asan/Valgrind builds
will detect a buffer overflow.

Honor output_size regardless of the value of the number.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-04 18:07:55 +02:00
Harry Ramsey
c19f8aea8a Update config.py crypto for version files
Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-04 13:37:42 +01:00
Harry Ramsey
d45763456e Remove version.c from .gitignore
This commit removes version.c from .gitignore as version 4.0 will not
include version generation.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-04 13:37:42 +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
Ronald Cron
0d10fedbeb
Merge pull request #9236 from ronald-cron-arm/config-file-split
Configuration file split proposal
2024-10-03 20:53:49 +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
Ronald Cron
45daa8d8c3 Convert config-split.md with Pandoc
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-03 09:38:27 +02:00
Ronald Cron
cbafe75f19 Fix hyperlink
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-03 09:33:25 +02:00
Ronald Cron
3ca3f151f5 Add missing backticks
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-03 09:29:36 +02:00
Ronald Cron
5f64611f6b Remove Mbed TLS feature support section
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-02 14:15:45 +02:00
Ronald Cron
e2b24d3461 Move MBEDTLS_USE_PSA_CRYPTO to "Builtin drivers" section
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-02 13:42:46 +02:00
Ronald Cron
da4522c2b8 Move MBEDTLS_ERROR_C to section "General configuration options"
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-02 13:42:34 +02:00
Manuel Pégourié-Gonnard
cb42f29c4e
Merge pull request #9662 from gilles-peskine-arm/dtls_server-allow_unexpected_message_on_second_handshake-dev
dtls_server: allow unexpected message on second handshake
2024-10-02 10:39:53 +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
Gilles Peskine
713127de4c 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-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
d2ca9a1b7e Add support to build only the tf-psa-crypto tree
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
e9e7b763ef TF-PSA-Crypto.cmake: Fix paths to tests scripts and C modules
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00
Ronald Cron
9c8472624d TF-PSA-Crypto.cmake: TF-PSA-Cryto-ify the file
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-01 15:32:01 +02:00