Commit Graph

6993 Commits

Author SHA1 Message Date
Ronald Cron
a2dbe66770 tests: psa: driver: mac: Remove opaque entry points in library
Opaque test entry points will be implemented only in
test code.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-11-30 13:24:47 +01:00
Ronald Cron
f8f425d95d psa: Remove psa_key_slot_is_external()
Remove psa_key_slot_is_external() that is not used anymore.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-11-25 17:40:58 +01:00
Ronald Cron
41e8006fa2 psa: Remove buggy report of RSA public exponent for opaque keys
The report of RSA public exponent for opaque keys is not
supported. Do not attempt to compute the RSA public
exponent of an RSA opaque key associated to a driver
implementing the new driver interface when
MBEDTLS_PSA_CRYPTO_SE_C is disabled.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-11-25 17:40:58 +01:00
Ronald Cron
0518f61e1a psa: Fix slot number key attribute
Slot number key attribute is specific of dynamically
registered drivers and should thus not be computed/
returned in case of keys associated to drivers
implementing the new unified driver interface.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-11-25 17:40:58 +01:00
Ronald Cron
8a0466a052 Clarify psa_get_and_lock_transparent_key_slot_with_policy() purpose
Clarify the purpose of
psa_get_and_lock_transparent_key_slot_with_policy() and
define it even when MBEDTLS_PSA_CRYPTO_SE_C is disabled
for the purpose of static drivers.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-11-25 17:40:58 +01:00
Gilles Peskine
3107b337e1
Merge pull request #5154 from gabor-mezei-arm/3649_bp2x_move_constant_time_functions_into_separate_module
[Backport 2.x] Move constant-time functions into a separate module
2021-11-24 19:33:03 +01:00
Gilles Peskine
989a4e9388
Merge pull request #5132 from openluopworld/origin/development_2.x
Backport 2.x: Fix GCM calculation with very long IV
2021-11-22 22:22:47 +01:00
Bence Szépkúti
358e0ea464 Indicate nonce sizes invalid for ChaCha20-Poly1305
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2021-11-17 14:03:08 +01:00
Dave Rodgman
021e724936 Improve PSA error return code
psa_key_derivation_output_key: prioritize BAD_STATE over NOT_PERMITTED

If psa_key_derivation_output_key() is called on an operation which hasn't been
set up or which has been aborted, return PSA_ERROR_BAD_STATE. Only return
PSA_ERROR_NOT_PERMITTED if the operation state is ok for
psa_key_derivation_input_bytes() or psa_key_derivation_output_bytes() but not
ok to output a key.

Ideally psa_key_derivation_output_key() would return PSA_ERROR_NOT_PERMITTED
only when psa_key_derivation_output_bytes() is possible, but this is clumsier
to implement.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2021-11-17 10:02:48 +00:00
Gabor Mezei
2dcccbfc19
Fix function name in debug message
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-16 13:34:05 +01:00
Gabor Mezei
dbe0f892b3
Fix documentation and comments
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:33:19 +01:00
Gabor Mezei
c0ae1cf45a
Rename internal header constant_time.h to constant_time_internal.h
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:33:19 +01:00
Gabor Mezei
18a44949d0
Rename constant-time functions to have mbedtls_ct prefix
Rename functions to better suite with the module name.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:32:01 +01:00
Gabor Mezei
da20651b73
Fix documentation
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:54 +01:00
Gabor Mezei
61bf64fbd0
Bind functions' availability for config options
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:54 +01:00
Gabor Mezei
e24dea8225
Move mbedtls_cf_memcmp to a new public header
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:54 +01:00
Gabor Mezei
6e0e990544
Add macro guard for header file
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:53 +01:00
Gabor Mezei
2b35880d41
Bind functions' availability for config options
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:53 +01:00
Gabor Mezei
4e2de62fef
Remove unused function
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:53 +01:00
Gabor Mezei
fd8a42d914
Make functions static
These functions are only used as an auxiliary function for constant-time functions.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:53 +01:00
Gabor Mezei
4b4e4d8880
Update documentation and comments
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:53 +01:00
Gabor Mezei
91deea7765
Rename and reorder function parameters
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:53 +01:00
Gabor Mezei
150bdee126
Use condition for not sensitive data
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:53 +01:00
Gabor Mezei
3c38b6e9e1
Move implementation specific comment
This comment is about how the functions are implemented, not about their
public interface, so it doesn't belong in the header file.
It applies to everything in constant_time.c so moved there.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:52 +01:00
Gabor Mezei
2c5ed2244b
Make mbedtls_cf_size_mask_lt function static
The mbedtls_cf_size_mask_lt is solely used as an auxiliary function
for mbedtls_cf_size_mask_ge.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:52 +01:00
gabor-mezei-arm
d5a392aa2c
Fix missing includes
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:52 +01:00
gabor-mezei-arm
7e6a1eaf8f
Add documentation for the functions
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:52 +01:00
gabor-mezei-arm
1ffd0ccf02
Unify equality checker functions return value
The equality checker functions always return 0 or 1 value,
thus the type of return value can be the same dispite of the
size of the parameters.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:52 +01:00
gabor-mezei-arm
60febd5d8a
Propagate usage of mask generation functions
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:52 +01:00
gabor-mezei-arm
2f2c0bead3
Unify mask generation functions
Generate all-bits 0 or all bits 1 mask from a value instead of from a bit.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:51 +01:00
gabor-mezei-arm
5e4882498e
Unify function parameters
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:51 +01:00
gabor-mezei-arm
378e7eb5cc
Unify memcmp functions
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:51 +01:00
gabor-mezei-arm
04087dffcd
Typo: Unify indentation of function parameters
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:51 +01:00
gabor-mezei-arm
f52941ef73
Move mbedtls_cf_rsaes_pkcs1_v15_unpadding function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:51 +01:00
gabor-mezei-arm
c2aee6fc0b
Move the constant-time part of mbedtls_rsa_rsaes_pkcs1_v15_decrypt to a function
Tne unpadding part of `mbedtls_rsa_rsaes_pkcs1_v15_decrypt` function is
contant-time therefore it moved to a separate function to be prepared
for moving to the contant-time module.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:04:51 +01:00
gabor-mezei-arm
bc3a288b2c
Create mbedtls_cf_size_if function
Add a constant-time function with size_t parameter for choosing
between two integer values, like the ?: ternary operator.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:03:04 +01:00
gabor-mezei-arm
b10301d2fc
Move mbedtls_mpi_lt_mpi_ct function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:02:38 +01:00
gabor-mezei-arm
58fc8a65ab Move mbedtls_mpi_safe_cond_swap function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:01:08 +01:00
gabor-mezei-arm
b8caeeed5c Move mbedtls_mpi_safe_cond_assign function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 11:00:14 +01:00
gabor-mezei-arm
6e4ace6b40
Delete ssl_invasive.h due to duplicated function declarations
All function declaration provided by ssl_invasive.h is needed only for
testing purposes and all of them are provided by constant_time.h as well.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:59:05 +01:00
gabor-mezei-arm
cb4317b723
Move mbedtls_cf_hmac function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:59:04 +01:00
gabor-mezei-arm
0f7b9e43e9
Move mbedtls_cf_memcpy_offset function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:59:04 +01:00
gabor-mezei-arm
ee06febbb4
Move mbedtls_cf_memcpy_if_eq function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:59:04 +01:00
gabor-mezei-arm
7b23c0b46d
Move mbedtls_cf_mem_move_to_left function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:59:04 +01:00
gabor-mezei-arm
043192d209 Move mbedtls_cf_mpi_uint_cond_assign function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:55:56 +01:00
gabor-mezei-arm
5cec8b44a8
Move mbedtls_cf_cond_select_sign function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:54:20 +01:00
gabor-mezei-arm
7533253125
Move mbedtls_cf_uint_if function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:52:42 +01:00
gabor-mezei-arm
097d4f555e
Move mbedtls_cf_mpi_uint_lt function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:52:01 +01:00
gabor-mezei-arm
17da4f2a4e
Remove module dependency
Elinimate macros defined by modules locally in the functions that are
moving to the new constant-time module.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:04:59 +01:00
gabor-mezei-arm
9d7bf09333
Move mbedtls_cf_size_gt function to the constant-time module
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2021-11-11 10:04:49 +01:00