765 Commits

Author SHA1 Message Date
Minos Galanakis
b70f0fd9a9 Merge branch 'development' into 'development-restricted'
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2024-03-19 22:24:40 +00:00
Ryan Everett
3de040f62d Use TEST_FAIL in threaded tests
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-14 17:50:06 +00:00
Ryan Everett
6c488709d6 Fix typo in thread_import_key
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-14 17:49:44 +00:00
Ryan Everett
50619991c8 Add test function for concurrently using the same persistent key
The thread functions can also be used in future tests for other key types
and other test scenarios

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-13 14:31:11 +00:00
Ryan Everett
73e4ea37f4 Add key_destroyable parameter to non-raw key agreement smoke tests
All current usages have this parameter set to 0 (this means the tests are unchanged).
Remove the GENERIC_ERROR return behaviour, in favour of returning the actual status.

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-13 14:31:11 +00:00
Ryan Everett
8163028fbd Add key_destroyable parameter to raw key agreement smoke tests
All current usages have this parameter set to 0 (meaning the behaviour
of these tests hasn't changed). We also now return the actual error code, not GENERIC_ERROR

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-12 17:01:09 +00:00
Ryan Everett
c1cc6686f0 Add key_destroyable parameter to key derivation smoke tests
All current usages have this parameter set to 0 (in this case the behaviour of
the test is unchanged)

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-12 17:01:09 +00:00
Ryan Everett
0a271fde76 Add key_destroyable parameter to mbedtls_test_psa_exercise_key
This will allow us to use this smoke test to ensure that key slot content reads are
only performed when we are registered to read a full slot. We will destroy the key
on another thread while the key is being exercised, and fail the test if an unexpected
error code is hit. Future commits will incrementally implement this new parameter.

All current usages of this function have this parameter set to 0, in which case
the new behaviour must be the same as the old behaviour

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-12 17:01:09 +00:00
David Horstmann
93fa4e1b87 Merge branch 'development' into buffer-sharing-merge 2024-03-12 15:05:06 +00:00
Ryan
3a1b786d5d Add a concurrent key generation test function
Split into n threads, each thread will repeatedly generate,
exercise and destroy a key.
Then join the threads, and ensure using PSA_DONE that no keys still exist.

Signed-off-by: Ryan Everett <ryan.everett@arm.com>
2024-03-06 16:45:36 +00:00
David Horstmann
a5175634b0
Merge branch 'development-restricted' into copying-pake
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-03-06 11:18:28 +00:00
Gilles Peskine
4c32b69f37 Ignore domain parameters in RSA key generation
Remove the ability to select a custom public exponent via domain parameters
in RSA key generation. The only way to select a custom public exponent is
now to pass custom production parameters to psa_generate_key_ext().

A subsequent commit will remove domain parameters altogether from the API,
thus this commit does not bother to update the documentation.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-26 08:50:38 +01:00
David Horstmann
cf3457ef26
Merge pull request #1132 from davidhorstmann-arm/copying-aead
Copy buffers in AEAD
2024-02-20 16:07:30 +00:00
Gilles Peskine
092ce51c47 Rename "key generation method" to "key production parameters"
"Key generation method" was misleading since it also applies to key
derivation. Change "key generation" to "key production", which we aren't
using yet and has roughly the right intuition. Change "method" to
"parameters" which there seems to be a slight preference for. Discussion
thread: https://github.com/Mbed-TLS/mbedtls/pull/8815#discussion_r1486524295

Identifiers renamed:
psa_key_generation_method_t → psa_key_production_parameters_t
psa_key_generation_method_s → psa_key_production_parameters_s
PSA_KEY_GENERATION_METHOD_INIT → PSA_KEY_PRODUCTION_PARAMETERS_INIT
method → params
method_data_length → params_data_length
default_method → default_production_parameters
psa_key_generation_method_is_default → psa_key_production_parameters_are_default
setup_key_generation_method → setup_key_production_parameters
key_generation_method_init → key_production_parameters_init

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-20 16:18:13 +01:00
Gilles Peskine
e7a7013910 Remove initialization function for variable-length struct
Assigning the return value of a function that returns a struct with a
flexible array member does not fill the flexible array member, which leaves
a gap in the initialization that could be surprising to programmers. Also,
this is a borderline case in ABI design which could cause interoperability
problems. So remove this function.

This gets rid of an annoying note from GCC about ABI compatibility on
(at least) x86_64.
```
In file included from include/psa/crypto.h:4820,
                 from <stdin>:1:
include/psa/crypto_struct.h: In function ‘psa_key_generation_method_init’:
include/psa/crypto_struct.h:244:1: note: the ABI of passing struct with a flexible array member has changed in GCC 4.4
  244 | {
      | ^
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-20 12:17:00 +01:00
Gilles Peskine
c81393b2ed generate/derive key ext: pass method_data_length rather than method_length
Instead of passing the size of the whole structure, just pass the data
length and let the implementation worry about adding the size of the
structure. The intent with passing the structure size was to allow
the client code in a client-server implementation to know nothing
about the structure and just copy the bytes to the server. But that was not
really a useful consideration since the application has to know the
structure layout, so it has to be available in the client implementation's
headers. Passing the method data length makes life simpler for everyone by
not having to worry about possible padding at the end of the structure, and
removes a potential error condition
(method_length < sizeof(psa_key_generation_method_t)).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-15 11:57:48 +01:00
Gilles Peskine
7a18f9645c psa_generate_key_ext: RSA: support custom public exponent
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-15 11:57:46 +01:00
Gilles Peskine
f0765fa06a Implement psa_generate_key_ext, psa_key_derivation_output_key_ext
Implement and unit-test the new functions psa_generate_key_ext() and
psa_key_derivation_output_key_ext(), only for the default method.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-15 11:19:27 +01:00
Gilles Peskine
1d25a0a810 Refactoring: extract rsa_test_e
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-02-15 11:19:27 +01:00
Gilles Peskine
f45589b492
Merge pull request #8198 from silabs-Kusumit/kdf_incorrect_initial_capacity
KDF incorrect initial capacity
2024-02-06 17:29:43 +00:00
David Horstmann
b8dc2453f1 Update buffer start and length in multipart test
This fixes a test failure in which the buffer was not properly filled.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-02-06 17:03:13 +00:00
David Horstmann
52402ec0fe Fix bug in PSA AEAD test
Resize buffer used to hold the nonce to twice the maximum nonce size.
Some test cases were requesting more than the maximum nonce size
without actually having backing space. This caused a buffer overflow
when PSA buffer-copying code was added.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-02-06 13:39:02 +00:00
Dave Rodgman
047c724c22 Merge remote-tracking branch 'restricted/development-restricted' into update-development-r
Conflicts:
	programs/Makefile
	tests/scripts/check-generated-files.sh
2024-01-26 12:42:51 +00:00
David Horstmann
433a58c170 Fix magic numbers in more J-PAKE tests
In the ecjpake_do_round(), fix a magic number that was causing buffer
size to be incorrectly advertised.

Followup of 'Fix magic number buffer length in J-PAKE tests' for what
seem to be duplicate tests.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-01-25 16:29:26 +00:00
Manuel Pégourié-Gonnard
34c6e8a770
Merge pull request #8700 from valeriosetti/issue8461
psa_asymmetric_encrypt() doesn't work with opaque driver
2024-01-22 08:43:08 +00:00
Valerio Setti
4860a6c7ac test_suite_psa_crypto: revert known failing checks for [en|de]cryption with opaque keys
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-01-15 16:30:12 +01:00
Valerio Setti
f202c2968b test_suite_psa_crypto: test asymmetric encryption/decryption also with opaque keys
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-01-15 10:42:37 +01:00
Kusumit Ghoderao
9ffd397e4c Increase input parameter type and buffer size
Signed-off-by: Kusumit Ghoderao <Kusumit.Ghoderao@silabs.com>
2024-01-10 21:49:09 +05:30
Valerio Setti
db6e02902d test_suite_psa_crypto: test also MBEDTLS_ECP_DP_MAX in ecc_conversion_functions_fail()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-01-09 13:41:52 +01:00
Valerio Setti
ac73952474 test_suite_psa_crypto: improve failing tests for EC conversion functions
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-01-09 13:41:52 +01:00
Valerio Setti
ad819679a5 test_suite_psa_crypto: explicitly check return values of conversion functions
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-01-09 13:41:52 +01:00
Valerio Setti
bf999cb22e test_suite_psa_crypto: add test functions and cases for ECC conversion functions
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-01-09 13:41:52 +01:00
Pengyu Lv
d90fbf7769 Adjuest checks in generate_key_rsa suite
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-12-08 17:30:33 +08:00
Pengyu Lv
9e976f3649 Conditionally check the attribute of generated RSA key
`psa_get_key_attributes` depends on some built-in
implementation of RSA. Guard the check with coresponding
macros.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-12-07 10:22:35 +08:00
Dave Rodgman
c7cc83cc44
Merge pull request #1119 from davidhorstmann-arm/psa-buffer-copy-fn
Implement buffer copying functions for PSA crypto
2023-11-24 10:46:38 +00:00
David Horstmann
7dd8205423 Remove extra blank line at end of file
(This causes code style checks to fail)

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-06 17:45:09 +00:00
David Horstmann
ad33ab376b Move buffer copy tests into new testsuite
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 20:01:37 +00:00
David Horstmann
86cdc7646d Switch to TEST_CALLOC_NONNULL()
This removes some gubbins related to making sure the buffer is not NULL
that was previously cluttering the test case.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:45:39 +00:00
David Horstmann
b8381513c1 Switch from ret to status as naming convention
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:31:35 +00:00
David Horstmann
8075c7faf7 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-03 19:28:08 +00:00
David Horstmann
ac12d2dc69 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-03 19:23:49 +00:00
David Horstmann
8995b50cf4 Remove superfluous comment
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-03 19:20:33 +00:00
David Horstmann
676cfdd0ea Replace compound-initializers with memset
This should eliminate some pedantic compiler warnings.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 20:47:04 +00:00
David Horstmann
8f77dc7f68 Refactor: move buffer pattern fills into helper
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:40:19 +00:00
David Horstmann
70fda48670 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-02 18:39:42 +00:00
David Horstmann
5b9c21756a Add test case for overlapping buffers
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:39:42 +00:00
David Horstmann
9700876520 Add testcases for psa_crypto_copy_and_free()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:39:37 +00:00
David Horstmann
0fee689e57 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-02 18:33:17 +00:00
David Horstmann
03b0472413 Zero-length test for psa_crypto_alloc_and_copy()
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:33:17 +00:00
David Horstmann
f06ac88284 Add extra testcases for buffer copying
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-11-02 18:33:17 +00:00