56 Commits

Author SHA1 Message Date
Tom Cosgrove
150b88c9d2
Merge pull request #9280 from valeriosetti/psasim-reset-slots-on-disconnection
psasim-server: add function to reset operations slots
2024-06-19 11:10:52 +01:00
Tom Cosgrove
125440d344
Merge pull request #9278 from valeriosetti/fix-psasim-logs
psa_sim: improve log prints
2024-06-19 11:03:05 +01:00
Ronald Cron
de0d7e6cd0
Merge pull request #9247 from ronald-cron-arm/move-psa-headers
Move PSA headers to a new tf-psa-crypto directory
2024-06-18 18:48:24 +00:00
Tom Cosgrove
a60d9223d6 Update psa_sim_serialise.pl to create the psa_sim_serialise.c we want
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-18 13:22:21 +01:00
Tom Cosgrove
37610024e9 Update psa_sim_generate.pl to create the psa_sim_crypto_client.c we want
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-18 14:10:55 +02:00
Valerio Setti
2eb8cc7d9d psa_sim: improve log prints
- always print ERROR and FATAL messages because they should never
  occur, but when they do it's important to see them immediately;
- keep INFO prints under DEBUG guard;
- set client's PRINT as INFO message because otherwise it will
  mess test_suites's output;
- change some error messages from INFO to ERROR because that's
  what they are.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-06-18 14:10:54 +02:00
Tom Cosgrove
2468896857 Have psa_sim_serialise.pl generate psa_sim_serialize_reset()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-18 12:32:57 +01:00
Tom Cosgrove
aaf7e859a4 Have psa_sim_generate.pl add psa_crypto_close() to psa_sim_crypto_server.c
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-18 12:31:57 +01:00
Valerio Setti
2fd9572f27 psasim-server: add function to reset operations slots
When the client disconnects the server can clean operations slots
so that upcoming clients will not hit the maximum slot limit
(at least it's very unlikely to happen for normal clients).

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-06-18 11:00:17 +02:00
Valerio Setti
2687e4797d psa_sim: make server ping time much faster
Reduce server's ping time for messages from 50ms to 1us because
otherwise tests suites will take forever to execute.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-06-18 10:37:30 +02:00
Ronald Cron
c7e9e367bb Adjust build systems
Adjust build systems such as we can build
Mbed TLS in the default and full configuration.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-06-13 09:02:24 +02:00
Tom Cosgrove
0fe5b8d4a3 Add support for and run (a copy of) the PSA aead_demo program under PSA sim
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-11 17:26:17 +01:00
Tom Cosgrove
98760124b8 Make it possible to pass arguments to PSA sim psa_client
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-11 17:21:15 +01:00
Tom Cosgrove
b923b473e7 Have PSA sim client wrappers say which call fails, if one does
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-11 17:19:31 +01:00
Valerio Setti
f98635c360 psasim: build server library and binary before client's ones
This allows to keep the same CONFIG_H while building the Mbed TLS
library and the application (no matter if it's client or server).

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-06-11 14:26:42 +01:00
Valerio Setti
75129e2ce3 psa_sim_crypto_[client/server]: check if CRYPTO_C is enabled
CRYPTO_C must or must-not be enabled on client and server
sides as follows:

- if it's enabled while building the client side it's a failure;
- it it's NOT enabled while building the server it's a failure.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-06-11 14:26:36 +01:00
Tom Cosgrove
51b2c86852 Use our own copy of programs/psa/psa_hash.c in the PSA simulator tests
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-11 14:26:03 +01:00
Tom Cosgrove
5ddd6591c3 Revert "Correctly build client-side code that's to be run under the PSA crypto sim"
This reverts commit e7a2230df7e9468f3a276edabe20a0705a492940.

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-11 14:26:03 +01:00
Tom Cosgrove
f252f61611 psa_sim_serialise.pl now creates the updated .c file
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-10 15:50:53 +01:00
Tom Cosgrove
db87a44898 psa_sim_serialise.pl now creates the updated .h file
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-10 15:50:13 +01:00
Tom Cosgrove
0d0415e6e0 Move the comment block in psa_sim_serialise.c back to where it belongs
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-10 15:49:02 +01:00
Tom Cosgrove
9ab19695b5 Make psa_sim_generate.pl output the new type of server wrapper we want
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-10 14:24:28 +01:00
Tom Cosgrove
517f4a1b4d Store operation_ts on PSA sim server side; only send handle to client
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-10 14:08:04 +01:00
Tom Cosgrove
d6048a459c We want the PSA hash code if MBEDTLS_PSA_CRYPTO_CLIENT && !MBEDTLS_PSA_CRYPTO_C
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-10 14:07:26 +01:00
Tom Cosgrove
e7a2230df7 Correctly build client-side code that's to be run under the PSA crypto sim
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-06-10 14:07:26 +01:00
Tom Cosgrove
0ca70d51d7 Add missing licences
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-30 11:12:22 +01:00
Tom Cosgrove
8bfb758e87 PSA crypto sim's server wrappers need to free deseraliased buffers when they're no longer needed
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 22:48:45 +01:00
Tom Cosgrove
ca0c147354 Mark temporary PSA crypto sim Perl scripts as executable
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 16:52:38 +01:00
Tom Cosgrove
e2f0e3012a Extend PSA crypto simulator tests to run psa_hash.c under the simulator
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 15:19:27 +01:00
Tom Cosgrove
61ee59f041 Add the rest of the psa_hash_xxx() functions to the simulator
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 15:19:27 +01:00
Tom Cosgrove
39f8b09f5b Add PSA crypto sim serialisation functions needed for the remaining PSA hash APIs
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 15:19:27 +01:00
Tom Cosgrove
3ebb880f90 Hook the new psa_sim_crypto_{client,server} into the build and tests
- smoke test client.c becomes a trivial call to psa_crypto_init()
- server.c now uses psa_sim_crypto_server.c's psa_crypto_call()
- Makefile is updated to build all the modules, and allow a different MAIN
- all.sh's test_psasim now tests the simulation of psa_hash_compute() too

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 15:19:10 +01:00
Tom Cosgrove
a4952f9450 The PSA sim logs aren't very many lines, so show them during tests
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 12:39:40 +01:00
Tom Cosgrove
54b4ccdbf8 Add PSA crypto sim client and server implementations of psa_hash_compute()
A Perl script that creates them is also included as reference. This is not the
final script (that will be in Python) but a proof-of-concept to show that
creaation client and server wrappers can be scripted.

It is not hooked into the build: it must be run manually. It is not part of the
deliverables for this PR.

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 10:27:01 +01:00
Tom Cosgrove
e68fb72d8c Add PSA crypto sim serialisation functions for rest of types needed for psa_hash_compute()
Still not used

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 10:04:14 +01:00
Tom Cosgrove
2fc5687b21 Add PSA crypto sim serialisation functions for basic types
Not hooked into the build yet

Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 10:03:06 +01:00
Tom Cosgrove
92024566fb Fix code style in psa_ff_server.c
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-29 09:58:56 +01:00
Tom Cosgrove
38f6c86724 Remove unnecessary blank lines at top of functions in psa_ff_server.c
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
9919543f5c Only print PSA crypto sim server messages when DEBUG defined
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
f69445ccaf Fix sending a response of more than 184 bytes in psa_ff_server.c:psa_write()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
bdc4c2d750 Fix PSA sim test awk script by removing extra $
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
0a57a253cc Fix psa_ff_server.c to calculate the amount of data from client correctly
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Tom Cosgrove
b7e5f31e2a Replace final sprintf() with snprintf() in psa_ff_server.c
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2024-05-28 14:31:48 +03:00
Valerio Setti
1f3c99c774 psa_autogen.py: improve management of output files
While at this, fix also Makefile so that "make clean" does not
complain if some of the files to be cancelled do not exist.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-16 16:13:38 +02:00
Valerio Setti
87d99fbd6c psasim: create a seedfile to be used for the crypto server
This allows to re-enable MBEDTLS_ENTROPY_NV_SEED since the
seedfile is correctly found in the "test" folder at runtime.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-14 10:57:35 +02:00
Valerio Setti
dce6b85af8 psa_ff_client: fix typos and useless blank lines
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-05-14 10:43:14 +02: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
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