David Horstmann
e9a88ab0d5
Use macros to manage buffer copies
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-12-11 17:58:56 +00:00
David Horstmann
e138dce329
Change to use test-hook-based approach
...
Since we are applying hooks transparently to all tests, we cannot setup
and teardown test hooks in the tests. Instead we must do this in the
test wrappers which are used to pre-poison and unpoison memory.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-12-11 17:58:56 +00:00
David Horstmann
c6977b4899
Copy input and output in psa_cipher_encrypt()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-12-11 17:58:56 +00:00
David Horstmann
372b8bb6c5
Add memory poisoning hooks
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-12-11 17:58:56 +00:00
Pengyu Lv
f75893bb36
Update comments
...
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com >
2023-12-08 17:40:00 +08:00
Pengyu Lv
e9efbc2aa5
Error out when get domain_parameters is not supported
...
From time being, domain_parameters could not be extracted
from driver. We need to return error to indicate this
situation. This is temporary and would be fixed after #6494 .
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com >
2023-12-08 17:30:26 +08:00
Valerio Setti
83e0de8481
crypto_extra: revert changes to mbedtls_psa_random_free()
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no >
2023-12-04 11:04:42 +01:00
Valerio Setti
402cfba4dc
psa: free RNG implementation before checking for remaining open key slots
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no >
2023-12-04 11:04:41 +01:00
Gilles Peskine
0457559323
Merge remote-tracking branch 'development' into development-restricted
2023-11-29 19:21:19 +01:00
Dave Rodgman
c94f8f1163
Merge pull request #8551 from daverodgman/sign-conversion-part1
...
Sign conversion part 1
2023-11-24 15:12:00 +00: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
9db14486da
Use initializers in alloc functions
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-23 15:50:37 +00:00
Dave Rodgman
e4a6f5a7ec
Use size_t cast for pointer subtractions
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com >
2023-11-21 17:09:46 +00:00
David Horstmann
89875a4f20
Rename "output_copy" -> "local_output"
...
This helps to prevent confusion as it avoids overloading the word
"copy" as both an action and an object.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-20 17:55:13 +00:00
David Horstmann
f1734054fa
Rename "input_copy" -> "local_input"
...
This helps to prevent confusion as it avoids overloading the word
"copy" as both an action and an object.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-20 17:54:57 +00:00
David Horstmann
2f307b4216
De-abbreviate "len" -> "length"
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-20 13:04:06 +00:00
David Horstmann
671f5f539e
Change psa_crypto_copy_output error code
...
When we are copying output, it makes sense to return
PSA_ERROR_BUFFER_TOO_SMALL since the buffer we are copying to is a user
output buffer.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-20 13:03:43 +00:00
Ryan Everett
975d411d92
Only set slot to OCCUPIED on successful key loading
...
Signed-off-by: Ryan Everett <ryan.everett@arm.com >
2023-11-16 13:37:51 +00:00
David Horstmann
c5cc1c3a92
Remove redundant NULL check
...
A NULL buffer with a non-zero length is an internal error, so just
check the length.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-15 18:11:26 +00:00
David Horstmann
777e74130f
Skip call to memcpy if buffer length is zero
...
This allows the copy functions to work when passed a (NULL, 0) buffer.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-15 17:38:46 +00:00
David Horstmann
1b7279a849
Make copy functions static-testable
...
This allows greater compiler optimisation.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-15 17:26:18 +00:00
David Horstmann
c335a4e186
Fix unintentional direct use of memcpy()
...
Change psa_crypto_output_copy_free() to use psa_crypto_copy_output()
rather than calling memcpy directly as was erroneously done previously.
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-15 16:00:28 +00:00
David Horstmann
9467ea343b
Add psa_crypto_output_copy_free() implementation
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-08 18:13:23 +00:00
David Horstmann
ba3c7d649c
Add implementation of psa_crypto_output_alloc()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-08 18:13:23 +00:00
David Horstmann
e6042ffc49
Add implementation of psa_crypto_input_copy_free()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-08 18:13:23 +00:00
David Horstmann
4ac788573b
Add psa_crypto_input_copy_alloc() implementation
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-08 15:22:27 +00:00
Ryan Everett
5567e3a34b
Make empty key slots explicit
...
Add new status field to key slots, and use it.
Signed-off-by: Ryan Everett <ryan.everett@arm.com >
2023-11-08 13:28:20 +00:00
David Horstmann
b3de69493c
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-06 17:45:09 +00:00
David Horstmann
49a7276c49
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-03 19:51:40 +00:00
Dave Rodgman
16799db69a
update headers
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com >
2023-11-02 19:47:20 +00:00
David Horstmann
72ab8ad44a
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-02 18:39:42 +00:00
David Horstmann
2b79cbaa17
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-02 18:39:42 +00:00
David Horstmann
f4bbb632cd
Add implementation of psa_crypto_copy_and_free()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-02 18:39:42 +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
83eef383c7
Add implementation of psa_crypto_alloc_and_copy()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-02 18:33:17 +00:00
David Horstmann
8978f5c32a
Add implementation of psa_crypto_copy_output()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-02 17:16:36 +00:00
David Horstmann
fde97394a0
Add implementation of psa_crypto_copy_input()
...
Signed-off-by: David Horstmann <david.horstmann@arm.com >
2023-11-02 17:15:35 +00:00
Valerio Setti
02a634decd
md: remove unnecessary inclusions of mbedtls/md.h
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no >
2023-10-11 13:15:58 +02:00
Dave Rodgman
0fc86b2ddf
Merge pull request #8075 from valeriosetti/issue8016
...
driver-only ECC: curve acceleration macros
2023-09-27 14:39:02 +00:00
Xiaokang Qian
fe9666b8c0
Change the extension type of the file psa_crypto_driver_wrapper
...
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com >
2023-09-26 09:09:20 +00:00
Xiaokang Qian
e9c39c42fd
Enable build of non-static psa wrapper functions
...
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com >
2023-09-26 09:09:20 +00:00
Thomas Daubney
7046468a02
Define the psa wrapper functions as static inline
...
This is a commit from Thomas Daubney.
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com >
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com >
2023-09-26 09:09:06 +00:00
Valerio Setti
c437faeaa1
psa_crypto: fix guards in mbedtls_ecc_group_to_psa()
...
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no >
2023-09-25 17:39:41 +02:00
Gilles Peskine
67c86e626b
Merge pull request #7961 from gilles-peskine-arm/psa_crypto_config-in-full
...
Enable MBEDTLS_PSA_CRYPTO_CONFIG in the full config
2023-09-18 08:13:12 +00:00
Gilles Peskine
0ddffb6de2
Merge pull request #7210 from sergio-nsk/patch-2
...
Fix llvm error: variable 'default_iv_length' and other may be used uninitialized
2023-09-13 16:38:55 +02:00
Dave Rodgman
1dab445804
Update guard for ecp
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com >
2023-09-02 10:56:44 +01:00
Dave Rodgman
4f47f3dac8
Covert PSA guards to MBEDTLS
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com >
2023-08-31 12:10:00 +01:00
Dave Rodgman
a9a53a05f0
Merge remote-tracking branch 'origin/development' into misc-code-size
2023-08-31 11:53:46 +01:00
Dave Rodgman
dea266f3f5
Use MBEDTLS_MD_LIGHT instead of MBEDTLS_MD_C
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com >
2023-08-31 11:52:43 +01:00
Dave Rodgman
8d706f6b59
Simplify camellia error conversion macros
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com >
2023-08-31 11:48:44 +01:00