6354 Commits

Author SHA1 Message Date
David Horstmann
7a31ac02ab Switch from int to psa_status_t for test args
Remove unnecessary casts as well.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:50:09 +00:00
David Horstmann
818b39dbc3 Remove psa_crypto_ prefix from test functions
This ensures they have a different name to the functions they test.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:50:09 +00:00
David Horstmann
34342a2410 Remove superfluous comment
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:50:09 +00:00
David Horstmann
f38eb76b34 Replace compound-initializers with memset
This should eliminate some pedantic compiler warnings.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:50:08 +00:00
David Horstmann
121994f33e Refactor: move buffer pattern fills into helper
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:50:06 +00:00
David Horstmann
5e0b4f8b42 Add full round-trip tests for buffer copying
Test that a buffer pair can be created with psa_crypto_alloc_and_copy()
and destroyed with psa_crypto_copy_and_free() correctly.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:48:00 +00:00
David Horstmann
406d28ba87 Add test case for overlapping buffers
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:47:58 +00:00
David Horstmann
7131b8eecc Reject zero-lengths in psa_crypto_copy_and_free()
Zero-length buffers should be represented in the
psa_crypto_buffer_copy_t struct as NULL if it was created in
psa_crypto_alloc_and_copy(), so reject non-NULL zero-length buffers.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:44:18 +00:00
David Horstmann
0368d20d51 Reject NULL original_output with non-NULL output
If we have a copy buffer but no original to copy back to, there is not
much sensible we can do. The psa_crypto_buffer_copy_t state is invalid.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:44:18 +00:00
David Horstmann
9ecd53d1bb Add testcases for psa_crypto_copy_and_free()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:44:18 +00:00
David Horstmann
0e38180e1d Simplify zero-length buffers to always be NULL
Since it is implementation-dependent whether
malloc(0) returns NULL or a pointer, explicitly
represent zero-length buffers as NULL in the
buffer-copy struct, so as to have a uniform
behaviour.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:44:18 +00:00
David Horstmann
ea08ab775d Zero-length test for psa_crypto_alloc_and_copy()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:44:18 +00:00
David Horstmann
41966d7433 Add extra testcases for buffer copying
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:44:18 +00:00
David Horstmann
0684069e44 Add testcases for psa_crypto_alloc_and_copy()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:44:18 +00:00
David Horstmann
438cd4811a Add testcases for psa_crypto_copy_output()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:44:18 +00:00
David Horstmann
b0a01b18af Add testcases for psa_crypto_copy_input()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-22 14:39:37 +00:00
Dave Rodgman
b9c70581a0
Merge pull request #8222 from tgonzalezorlandoarm/tg/backport-psa-low-hash-mac-size
Backport 2.28: Start testing the PSA built-in drivers: hashes
2023-11-21 15:39:36 +00:00
Gilles Peskine
181844fa1f
Merge pull request #8491 from mschulz-at-hilscher/mbedtls-2.28
Backport 2.28: "CSR parsing with critical fields fails" #8377
2023-11-20 14:07:31 +00:00
Gilles Peskine
d4084fd899 Readability improvement
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:52 +01:00
Gilles Peskine
c41133b90d Add documentation
Explain the goals of metatests, how to write them, and how to read their
output.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:52 +01:00
Gilles Peskine
e38eb79e89 Add metatests for mutex usage
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
ee8af06887 Run metatests in selected components
Run metatests in some components, covering both GCC and Clang, with ASan,
MSan or neither.

Note that this commit does not cover constant-flow testing builds or Valgrind.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Gilles Peskine
6effdff76b Script to run all the metatests (with platform filtering)
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-16 15:56:23 +01:00
Tomás González
5fae560b4a Update new license headers
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-11-13 11:45:12 +00:00
Gilles Peskine
ac5fcd4540 Update license
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-08 19:19:18 +01:00
Gilles Peskine
bfc1844eb2
Merge pull request #8480 from yuhaoth/backports/7649/add-command-for-server9-bad-saltlen
Backports for #7649 : add command for server9-bad-saltlen
2023-11-08 19:04:27 +01:00
Dave Rodgman
79659cdf22
Merge pull request #8469 from daverodgman/mbedtls-2.28.6-pr
Mbedtls 2.28.6
2023-11-08 18:01:18 +00:00
Dave Rodgman
a645708949 Restore bump version
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-08 11:50:57 +00:00
Matthias Schulz
9a0ad5c427 Changed the test to reflect mbedTLS's current behavior.
Signed-off-by: Matthias Schulz <mschulz@hilscher.com>
2023-11-07 16:40:22 +01:00
Matthias Schulz
5240ab0c98 Backported test cases from https://github.com/Mbed-TLS/mbedtls/pull/8378
Signed-off-by: Matthias Schulz <mschulz@hilscher.com>
2023-11-07 16:21:49 +01:00
Dave Rodgman
d6d43ec8a5
Merge pull request #8485 from gilles-peskine-arm/check-files-license-2.28
Backport 2.28: Check copyright statements and SPDX license statements
2023-11-06 17:07:48 +00:00
Gilles Peskine
32ffbfd139 Pacify mypy
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-06 13:25:37 +01:00
Gilles Peskine
1b4f036dd4 Also complain if licenses are mentioned
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-06 13:25:37 +01:00
Gilles Peskine
15db6822a3 Check copyright statements and SPDX license identifier
Enforce a specific copyright statement and a specific SPDX license
identifier where they are present.

Binary files, third-party modules and a few other exceptions are not
checked.

There is currently no check that copyright statements and license
identifiers are present.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-06 13:25:37 +01:00
Gilles Peskine
5136156750 Sort imports
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-11-06 13:25:37 +01:00
Paul Elliott
8243ebf6b3
Merge pull request #8477 from paul-elliott-arm/full_no_platform_2_28
[Backport 2.28] Add build preset full_no_platform
2023-11-06 11:35:12 +00:00
Jerry Yu
0c835dbae3 move script to tests/scripts
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-11-06 10:06:03 +08:00
Jerry Yu
8c31148af0 fix wrong typo and indent issue
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-11-06 10:04:42 +08:00
Jerry Yu
dbb7b467d2 Add server9-bad-saltlen generate command
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
2023-11-06 10:04:42 +08:00
Paul Elliott
6805037a45 Add build preset full_no_platform
Add build preset as above, and utilise it in
all.sh:component_test_no_platform.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2023-11-03 19:24:56 +00:00
Dave Rodgman
7ff7965561 Update headers
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-03 12:04:52 +00:00
Dave Rodgman
1df57fcc0e
Merge pull request #8196 from tgonzalezorlandoarm/tg/check_test_cases
Backport 2.28: Make check_test_cases.py recognize test case name templates in ssl-opt.sh
2023-11-02 12:22:40 +00:00
Gilles Peskine
e25a619824 Remove dead code
Do explain why we don't test a smaller buffer in addition to testing the
nominal size and a larger buffer.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-10-31 09:32:36 +00:00
Tomás González
2bff1bfd47 New test suite for the low-level hash interface
Some basic test coverage for now:

* Nominal operation.
* Larger output buffer.
* Clone an operation and use it after the original operation stops.

Generate test data automatically. For the time being, only do that for
hashes that Python supports natively. Supporting all algorithms is future
work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-10-31 09:32:35 +00:00
Tomás González
734d22c03e Move PSA information and dependency automation into their own module
This will let us use these features from other modules (yet to be created).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-10-31 09:31:20 +00:00
Paul Elliott
f29cc32a06
Merge pull request #8390 from gilles-peskine-arm/20231017-misc-cleanup-2.28
Backport 2.28: Cleanups in test code
2023-10-30 18:07:47 +00:00
Tomás González
aaea3a3148 check_test_cases: Unify walk_compat_sh and walk_opt_sh into one
walk_compat_sh and walk_opt_sh are basically the same now, so:

 * Merge them into one function.
 * Use the --list-test-cases option for both of them.
 * Rename this merged function as collect_from_script which seems
   more appropriate as since it isn't iterating the script but
   calling it.

Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-10-30 14:23:57 +00:00
Tomás González
cbb2e45e96 ssl-opt: Introduce --list-test-cases option
Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
2023-10-30 14:23:56 +00:00
Gilles Peskine
e3d1c76818 Fix invocation with explicit .datax file
Don't chdir when invoking a test suite executable with an explicit .datax
file. The point of the chdir is to automatically find the .datax file (and
the relative location of the data_files directory) in typical cases. This
conflicts with the expectation that passing a relative path to a .datax file
will work.

(This is what I had originally intended, and what is documented in the
comment, but I forgot to add the argc check in the initial commit.)

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-10-25 17:47:42 +02:00
Gilles Peskine
290e008925 Define try_chdir everywhere
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-10-25 17:47:42 +02:00