11470 Commits

Author SHA1 Message Date
Valerio Setti
a621fd9df3 gitignore: ignore test_keys.h and test_certs.h
These files are automatically generated at build time so they
do not need to be tracked.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-13 11:13:36 +02:00
Gilles Peskine
2cdc8f7aa5
Merge pull request #9122 from davidhorstmann-arm/fix-fuzzing-build-failures
Move some test data generation to main CMakeLists.txt (/ fix fuzzing build failures)
2024-05-12 18:56:11 +00:00
David Horstmann
cbea7d6e67 Add note explaining component purpose
We are testing that we don't break OSS-Fuzz, primarily.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-10 15:37:57 +01:00
Valerio Setti
c98f8ab5f7 crypto-client: allow debug build of libraries and test binaries
Add DEBUG=1 in test_psasim() to helpers and final make to build
the libraries and the final binaries with debug symbols
enabled.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-10 15:53:40 +02:00
David Horstmann
041ed42555 Add all.sh component for programs without tests
Check that we can build under CMake with ENABLE_TESTING=OFF but
ENABLE_PROGRAMS=ON.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-10 14:37:48 +01:00
David Horstmann
1238b37573 Move test generated files to main CMakeLists.txt
Move the generation of tests/src/test_certs.h and tests/src/test_keys.h
to the main CMakeLists.txt. This is required because these files are
needed both by tests and programs, whereas tests/CMakeLists.txt is only
included when ENABLE_TESTING is on.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-05-10 14:23:16 +01:00
Tom Cosgrove
9b5768782e
Merge pull request #9104 from valeriosetti/issue8962
Add a component to all.sh to build and run psasim
2024-05-10 12:45:04 +00:00
Valerio Setti
237a64ef07 crypto-client: remove log files on "make clean"
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-10 12:32:10 +02:00
Valerio Setti
400168cd1a crypto-client: fix the SID
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-10 12:31:41 +02:00
Valerio Setti
cd89c1ffc8 crypto-client: simplify build of mbedtls static libraries
Instead of copying the entire library & include folders twice
to build libraries for client and server:

- change the main config file (mbedtls_config.h)
- build in the root library folder
- move the generated library in the psasim folder
- use those library for linking the client/server binaries

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-10 11:23:30 +02:00
Valerio Setti
66fb1c17ff crypto-client: reorganize source files/folders
The goal is to keep psasim as simple as possible:

- do not build a separate lib for psa-ff; build those source
  files as part of server or client
- do not have lot of different makefiles: just 1 that does all
  we need
- do not have several subfolders for headers: only 1 is enough
  for this kind of project

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-10 07:59:22 +02:00
Valerio Setti
dde9579fab all.sh: crypto-client: keep NV_SEED disabled in the server lib
This is necessary because otherwise the library is not able to
find the seedfile at runtime and it fails the initialization.
However since this test runs on a standard PC we can rely on
platform entropy as source of entropy.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-10 05:22:33 +02:00
Valerio Setti
655b9793c0 crypto-client test: implement the first IPC call for psa_crypto_init()
This commit implements the first useful IPC communication between
the client and the server. The implemented command is simple,
psa_crypto_init(), and its return value is sent back to the client.

Note: the newly added file psa_functions_codes.h is temporary
and it's probably the one that needs to be automatically
generated by a python script to support all crypto functions.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-10 05:22:23 +02:00
Thomas Daubney
67338c050a Restore toggling of MBEDTLS_CIPHER_MODE_CBC
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-05-09 15:21:14 +01:00
Valerio Setti
4362aaef7f crypto-client test: ensure that client/server are linked against proper MbedTLS libraries
Ensure that both server and client can call mbedtls_version_get_string_full()
to verify that they are linked against proper libraries.

Note: each side (client/server) performs the call against its own
MbedTLS library. There is no IPC communication involved in this
test. Client/server communication will come later.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-09 09:23:46 +02:00
Valerio Setti
d1b6ef1959 crypto-client test: add mechanism to build crypto library for client and server
It includes changes to:
- tests/Makefile: build the library for client and server in different
  folders. It mimica the libtestdriver1 behavior (without functions
  renaming though).
- tests/scripts/all.sh: helper function to build for client and
  server with some default configuration for each of them.
- crypto_spe.h: this is dummy file taken from the already existing
  tests. It's just meant to pacify the compiler, not to provide
  something useful. It will likely be changed in the future.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-09 07:31:54 +02:00
Manuel Pégourié-Gonnard
0e7aaae1fd
Merge pull request #9017 from valeriosetti/issue9010
Improve generate_test_keys.py
2024-05-07 11:59:54 +00:00
Valerio Setti
a8ccddce68 generate_test_keys: move code for arrays and LUT generation to a separate function
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 12:35:40 +02:00
Valerio Setti
aabdca6950 check-generated-files: move check for generate_test_cert_macros.py
This test should only be performed when in MbedTLS repo and not
in tf-psa-crypto one.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 11:15:12 +02:00
Valerio Setti
3fcaf6cc8a generate_test_[keys/cert_macros]: minor fixes
- remove new line at beginning of test_keys.h
- add footer at the end of both generated files

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:41:47 +02:00
Valerio Setti
cc403cb6ec generate_test_keys: move output file writing to a separate function
This helps removing the previous pylint exception.

Also use "with" statement for opening the file in order to
ensure that all the content is flushed to the file before
exiting.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-07 10:41:46 +02:00
Valerio Setti
d9e4251278 all.sh: add test component to build and test psasim
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-06 15:59:51 +02:00
Tom Cosgrove
4491ceafd9
Merge pull request #9097 from valeriosetti/moving-psasim
[crypto_client_test] Moving psasim from the framework repo to the mbedtls one
2024-05-05 16:10:39 +00:00
Valerio Setti
dc64163ad4 generate_test_keys: sort keys before processing them
Without this fix keys could be listed differently on Ubuntu 16
between different runs therefore causing
check_generated_files() to fail.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-03 18:22:01 +02:00
Valerio Setti
4f4ade9c34 psa-client-server: move psasim from framework repo to the mbedtls one
This is a temporary fix that will be reverted once the framework
repository will have CI checks.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-03 17:28:04 +02:00
Minos Galanakis
c16048887e Added work directory for the psa client/server testing epic
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2024-05-03 15:55:12 +01:00
Ronald Cron
7661aa0e20 Do not use --recurse-submodules
On the CI, the git version when running on
Ubuntu 16.04 is 2.7 and it does not support
the "--recurse-submodules" option of
"git ls-files" thus do not use it.

Another argument to not use it is that
when TF-PSA-Crypto will be a submodule of
mbedtls we will not want check_files.py to
check the TF-PSA-Crypto files as well.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-03 16:25:07 +02:00
Valerio Setti
d74d2ab9db check-generated-files: add test_certs.h file to the list of checked items
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-03 15:51:21 +02:00
Valerio Setti
5f37b25862 generate_test_cert_macros: minor fixes
- use build_tree to get the project root path
- remove "if True" in an "if" statement

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-03 15:51:11 +02:00
Valerio Setti
7f6eabd9b1 generated_test_keys: minor fixes
- rewrite output file (do not append)
- remove useless "os" import
- move pylint for main() function

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-03 15:33:18 +02:00
Andre Goddard Rosa
043aa9e2a2 Add check ensuring output is set to the least-harmful value in error cases
With the robustness fix:
`PASSED (125 suites, 26639 tests run)`

Without the robustness fix:
`FAILED (125 suites, 26639 tests run)`

Signed-off-by: Andre Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Andre Goddard Rosa <agoddardrosa@roku.com>
2024-05-02 09:51:49 -05:00
Valerio Setti
19f5566843 generate_test_keys: remove left-over variable
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-02 16:11:26 +02:00
Valerio Setti
132d446c18 tests/CMakeLists: fix indentation
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-02 16:11:17 +02:00
Ronald Cron
1e05debd60 Extend basic checks of files to framework files
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-05-02 15:53:28 +02:00
Valerio Setti
5ce51b153c generate_test_keys: do not quit script if output file already exists
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-02 14:40:03 +02:00
Thomas Daubney
1ca1f3d62f Restore Mbed TLS style AEAD options for now
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2024-05-02 09:48:29 +01:00
Manuel Pégourié-Gonnard
898066b851
Merge pull request #9049 from gilles-peskine-arm/test-dependencies-20240314-development
Fix some test case dependencies (PEM_C)
2024-05-02 08:00:25 +00:00
Gilles Peskine
ff3b8211ff Driver-only FFDH is not good enough for DHE support in TLS 1.2
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-30 16:20:20 +02:00
Gilles Peskine
6191f4aeb5 Add seme missing dependencies on renegotiation support
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-30 16:20:20 +02:00
Gilles Peskine
dd782f4197 Default NEXT versions to be the base executables
This allows many tests to pass with the system openssl and gnutls-*. As
before, not all test cases will pass due to differences between versions and
build options.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-30 16:20:20 +02:00
Gilles Peskine
01fde2c3cc Force some test cases to use TLS 1.2
Some OpenSSL or GnuTLS interoperability test cases fail if the other
implementation is recent enough to support TLS 1.3. Force those test cases
to use TLS 1.2 so that the script works with more recent $OPENSSL or
$GNUTLS_CLI or $GNUTLS_SERV than our official CI versions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-30 16:20:20 +02:00
Gilles Peskine
3b81ea1e9c Add some missing dependencies on crypto features
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-04-30 16:20:20 +02:00
Valerio Setti
0ddab0ecee generate_test_keys: add missing flush at the end of script
Ensure that all the data is actually written to the output file.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-30 10:37:39 +02:00
Valerio Setti
c21147efe7 test_suite_pk: use explicit key bit size instead of RSA_KEY_SIZE
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:38:37 +02:00
Valerio Setti
84dc3297fb generate_test_keys: use build_tree to guess the MbedTLS root path
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:33:48 +02:00
Valerio Setti
f27d407332 generate_test_cert_macros: minor fixes
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
fb418166b5 cmake: relocate custom commands for test_certs.h and test_keys.h generation
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
455fb4e803 generate_test_cert_macros: embed input args
- Embed input arguments inside the script so as to simplify the
  calls in Makefiles/CMakeLists.
- add a new "--list-dependencies" command line option to print
  out the list of dependencies.
- Modify tests/Makefile accordinlgy.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
34f280538c tests/Makefile: minor fix: specify Python binary to be used
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00
Valerio Setti
96daf67701 fix "make generated_files" for test_keys.h and test_certs.h
This also add the check in tests/scripts/check-generated-files.sh

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-04-29 17:16:41 +02:00