Janos Follath
8786dd79f7
Disable optionally safe test hook in threading builds
...
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-20 10:21:54 +01:00
Janos Follath
a11269187e
Fix optionally safe hooks declarations
...
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-20 09:56:16 +01:00
Janos Follath
2c62441f96
Fix mpi_core_exp_mod documentation
...
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-15 15:53:07 +01:00
Janos Follath
e0842aa751
Add tests for optionally safe codepaths
...
The new test hooks allow to check whether there was an unsafe call of an
optionally safe function in the codepath. For the sake of simplicity the
MBEDTLS_MPI_IS_* macros are reused for signalling safe/unsafe codepaths
here too.
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 08:40:31 +01:00
Janos Follath
020b9ab004
Use actual exponent size for window calculation
...
The allocated size can be significantly larger than the actual size. In
the unsafe case we can use the actual size and gain some performance.
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 07:53:20 +01:00
Janos Follath
a5fc8f342a
Move _public parameters next to their target
...
It is easier to read if the parameter controlling constant timeness with
respect to a parameter is next to that parameter.
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-13 07:41:05 +01:00
Janos Follath
bb3f295e40
Move mixed security code to small local functions
...
The complexity of having functions whose security properties depend on a
runtime argument can be dangerous. Limit risk by isolating such code in
small functions with limited scope.
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-12 20:03:06 +01:00
Janos Follath
38ff70e169
Make _optionally_safe functions internal
...
The complexity of having functions whose security properties depend on a
runtime argument can be dangerous. Limit misuse by making any such
functions local.
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-08-12 20:03:06 +01:00
Manuel Pégourié-Gonnard
75ed58723e
Add optionally unsafe variant of exp_mod for perf
...
Attempt to partially solve the performance regression in 3.6.0 without
adding too much code size.
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-06-18 12:52:45 +02:00
Janos Follath
23dc8b5fd8
Fix code style
...
Co-authored-by: Dave Rodgman <dave.rodgman@arm.com>
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-03-11 10:39:57 +00:00
Janos Follath
adb9d2d822
Remove volatile from declaration
...
Use of volatile is more an internal implementation detail (ensuring
const-time) than part of the contract (the caller doesn't care about
volatile as such).
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-03-11 10:03:05 +00:00
Janos Follath
d6df0a5dac
Fix use of volatile
...
We need the pointer, A, to be volatile, to ensure the reads happen. bits
does not need to be volatile.
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-03-11 09:40:03 +00:00
Janos Follath
30f49f19cc
Hinder unwanted optimisations
...
We want this function to be constant time. Make it less likely that the
compiler optimises it.
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-03-08 16:29:54 +00:00
Janos Follath
aec1a868fe
Use mbedtls_ct_condition_t in mpi_core_check_zero
...
Signed-off-by: Janos Follath <janos.follath@arm.com>
2024-02-21 11:24:20 +00:00
Dave Rodgman
16799db69a
update headers
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-11-02 19:47:20 +00:00
Dave Rodgman
85061b97b5
Improve sanity checking of MBEDTLS_HAVE_INTxx
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-06 08:41:05 +01:00
Dave Rodgman
b7b8c09c81
Update bignum_core.c
...
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-05 20:35:19 +01:00
Dave Rodgman
7e1e7be8fc
Simplify fixes for unreachable code
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-05 18:15:31 +01:00
Dave Rodgman
cfa722324c
Fix warnings about unreachable code
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-09-05 16:53:33 +01:00
Manuel Pégourié-Gonnard
54da1a69a2
Merge pull request #7578 from daverodgman/safer-ct5
...
Improve constant-time interface
2023-08-10 16:57:39 +00:00
Dave Rodgman
98ddc01a7c
Rename ...if0 to ...else_0
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 12:11:31 +01:00
Dave Rodgman
b7825ceb3e
Rename uint->bool operators to reflect input types
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-10 11:58:18 +01:00
Dave Rodgman
4883f109a0
Reduce code size for exp_mod_get_window_size
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-09 20:42:54 +01:00
Dave Rodgman
c98f8d996a
Merge branch 'development' into safer-ct5
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-08-07 11:47:35 +01:00
Agathiyan Bragadeesh
5058a5b5ad
Remove trailing whitespace bignum_core
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-17 15:23:52 +01:00
Agathiyan Bragadeesh
e55a1e1cf4
Refactor preprocessing for arm none
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-17 15:00:19 +01:00
Agathiyan Bragadeesh
271a95331e
Remove tautology in mbedtls_mpi_core_clz
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com>
2023-07-14 14:07:18 +01:00
Dave Rodgman
3b25c40f52
Fix RSA perf regression
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-26 12:42:48 +01:00
Dave Rodgman
fd492ab1be
Use new CT interface in mbedtls_mpi_core_random
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-26 12:42:48 +01:00
Dave Rodgman
b59b73e2bc
Use new CT interface in mbedtls_mpi_core_add_if
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-26 12:42:48 +01:00
Dave Rodgman
8ac9a1df24
Use new CT interface in mbedtls_mpi_core_lt_ct
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-26 12:42:48 +01:00
Dave Rodgman
231a516682
Remove not-needed mbedtls_ct_mpi_uint_cond_assign
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-26 12:42:48 +01:00
Dave Rodgman
fd7fab4073
Update mbedtls_mpi_core_uint_le_mpi to new CT interface
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-26 12:42:48 +01:00
Dave Rodgman
cd2e38b906
Update mbedtls_mpi_safe_cond_(assign|swap) to use new CT interface
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-26 12:42:48 +01:00
Dave Rodgman
7d4f019810
Move some bignum functions out of constant_time module
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-05-26 12:42:48 +01:00
Paul Elliott
f0806bee66
Merge pull request #7489 from minosgalanakis/ecp/7246_xtrack_core_shift_l
...
[Bignum]: Introduce left shift from prototype
2023-05-16 17:13:19 +01:00
Minos Galanakis
b89440394f
bignum_core: Removed input checking for mbedtls_mpi_core_shift_l
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-05-04 14:40:40 +01:00
Dave Rodgman
914347bfa3
Don't explicitly inline mbedtls_mpi_core_clz
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-04-27 14:20:30 +01:00
Dave Rodgman
3b29364d61
Fix VS2022 build error
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-04-26 21:53:30 +01:00
Dave Rodgman
2e863ecde9
Remove unnecessary if to save 16 bytes
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-04-25 17:40:49 +01:00
Minos Galanakis
ec09e25251
bignum_core: Aligned xxx_core_shift_l
to xxx_core_shift_r
...
This patch modifies the left-shift implementation to closely
align in interface and behaviour to the existing right-shift
method.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-25 12:23:34 +01:00
Minos Galanakis
ad808dd5f1
bignum_core: Extracted mbedtls_mpi_shift_l from prototype
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-25 12:23:33 +01:00
Dave Rodgman
0f16d560aa
Fix documentation
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-04-24 12:53:45 +01:00
Dave Rodgman
bbf881053d
Document undefined case. Clarify test code.
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-04-21 12:54:40 +01:00
Dave Rodgman
880a6b34c2
Further size optimisation
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-04-20 11:52:55 +01:00
Dave Rodgman
fe8a8cd100
Size/perf optimisation for mbedtls_mpi_core_clz
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-04-19 17:59:12 +01:00
Minos Galanakis
00bd8925a7
bignum: Removed merge scaffolding.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-04-05 16:13:11 +01:00
Tom Cosgrove
6af26f3838
Tidy up, remove MPI_CORE(), apply the naming convention, and use the new mbedtls_mpi_core_mul()
...
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-31 16:16:00 +02:00
Hanno Becker
4ae890bbd0
Extract MPI_CORE(mul) from the prototype
...
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2023-03-31 16:10:34 +02:00
Gilles Peskine
449bd8303e
Switch to the new code style
...
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:50:10 +01:00