3bc1316ceb
Add testcase for psa_crypto_output_copy_free()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
953cd5b372
Add implementation of psa_crypto_output_alloc()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
1acf7afa83
Add testcase for psa_crypto_output_copy_alloc()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
b80367e3b4
Add function prototypes for psa_crypto_output fns
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
fa2d75d30a
Add implementation of psa_crypto_input_copy_free()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
6790a6d36f
Add testcase for psa_crypto_input_copy_free()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
8d9d4fe20d
Add psa_crypto_input_copy_alloc() implementation
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
89299c476c
Add testcase for psa_crypto_input_copy_alloc()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
f0ec6e87b1
Add prototypes for psa_crypto_input_copy API
...
This includes:
* The psa_crypto_input_copy_t struct
* psa_crypto_input_copy_alloc()
* psa_crypto_input_copy_free()
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
cbdec9e470
Remove psa_crypto_alloc_and_copy() API
...
This tied input and output buffers together in
awkward pairs, which made the API more difficult
to use.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:59:17 +00:00
93e08c6db6
Move buffer copy tests into new testsuite
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:56:46 +00:00
8684ad548f
Switch error code to more appropriate value
...
Since we are internal rather than user-facing,
PSA_ERROR_CORRUPTION_DETECTED makes more sense than
PSA_ERROR_BUFFER_TOO_SMALL. Whilst it really is a buffer that is too
small, this error code is intended to indicate that a user-supplied
buffer is too small, not an internal one.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:50:09 +00:00
89b4caab53
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-22 14:50:09 +00:00
113f2d46b0
Switch from ret to status as naming convention
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:50:09 +00:00
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
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
34342a2410
Remove superfluous comment
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:50:09 +00:00
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
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
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
406d28ba87
Add test case for overlapping buffers
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:47:58 +00:00
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
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
5847b70829
Add implementation of psa_crypto_copy_and_free()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:44:18 +00:00
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
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
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
41966d7433
Add extra testcases for buffer copying
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:44:18 +00:00
cc4dfa6892
Add implementation of psa_crypto_alloc_and_copy()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:44:18 +00:00
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
a707a6f56d
Add buffers struct and prototypes for alloc API
...
Add function prototypes for psa_crypto_alloc_and_copy() and
psa_crypto_alloc_and_free(), along with the necessary state struct.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:44:18 +00:00
2bd296e890
Add implementation of psa_crypto_copy_output()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:44:18 +00:00
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
957f980379
Add implementation of psa_crypto_copy_input()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:44:16 +00:00
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
1cc21c31a9
Add function prototypes for copying functions
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-22 14:37:17 +00:00
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
feb98ccada
Merge pull request #8497 from ronald-cron-arm/remove-cocci-files-2.28
...
[Backport 2.28] Remove unused *.cocci files
2023-11-20 14:07:36 +00:00
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
167ecbaa90
Fix indentation causing code style failure
...
Signed-off-by: Ryan Everett <ryan.everett@arm.com >
2023-11-20 12:16:18 +00:00
04a8d02f31
Merge pull request #8543 from gilles-peskine-arm/metatest-create-2.28
...
Backport 2.28: Create a metatest program
2023-11-20 10:16:39 +00:00
68a85e24fc
Fix secure element key error handling
...
Signed-off-by: Ryan Everett <ryan.everett@arm.com >
2023-11-16 16:44:13 +00:00
e00255c41c
Improve explanations of what bad thing a metatest does
...
Especially clarify the situation with respect to mutex usage.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-11-16 15:56:52 +01:00
96c87c4e7b
Uniformly use MBEDTLS_THREADING_C guards
...
Since the code compiles with MBEDTLS_THREADING_C, not just with
MBEDTLS_THREADING_PTHREAD, use MBEDTLS_THREADING_C as the guard. The runtime
behavior is only as desired under certain conditions that imply
MBEDTLS_THREADING_PTHREAD, but that's fine: no metatest is expected to pass
in all scenarios, only under specific build- and run-time conditions.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-11-16 15:56:52 +01:00
d4084fd899
Readability improvement
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-11-16 15:56:52 +01:00
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
efc57cabd0
Uninitialized read: make the pointer non-volatile rather than the buffer
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-11-16 15:56:52 +01:00
226f1bc080
More consistent usage of volatile
...
Fix MSVC warning C4090.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-11-16 15:56:52 +01:00
53833516bf
Strengthen against possible compiler optimizations
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-11-16 15:56:52 +01:00
2c04f57ffc
programs/test/metatest indirectly includes library/common.h
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-11-16 15:56:50 +01:00