8e8e6b9be3
Merge pull request #7934 from AgathiyanB/move-declarations-to-top
...
Move declarations to top of functions
2023-07-19 15:25:27 +01:00
b8f18850c6
Align ECP_MPI_INIT parameter order with mbedtls_mpi struct order
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com >
2023-07-18 13:53:07 +02:00
ec4c91ecc1
Move declaration in ecp_mod_koblitz to top
...
Signed-off-by: Agathiyan Bragadeesh <agathiyan.bragadeesh2@arm.com >
2023-07-17 12:21:06 +01:00
84eaefa43e
Use designated initializers for mbedtls_mpi
...
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com >
2023-07-11 16:02:46 +01:00
053022fe24
Reduce the size of mbedtls_mpi
...
Reduce the size of mbedtls_mpi from 3 words to 2 on most architectures.
This also reduces the code size significantly in bignum.o and ecp_curves.o,
with negligible variations in other modules.
This removes the ability to set MBEDTLS_MPI_MAX_LIMBS to a value >=65536,
but we don't support customizing this value anyway (it's always 10000).
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com >
2023-06-29 19:33:44 +02:00
c4e4958326
ecp_curves: Adjusted expected_width inputs to use BITS_TO_LIMBS
macro.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-06-27 14:07:07 +01:00
25d998b3b9
ecp_curves: Fixed modp pointers on mbedtls_ecp_modulus_setup
.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-06-25 21:08:58 +01:00
3048c8c906
Merge pull request #7725 from minosgalanakis/ecp/7268_add_optimised_reduction_setup_3
...
[Bignum] Add optimised reduction setup
2023-06-22 16:30:39 +01:00
2a03fd3b7b
bignum_mod: Added a typedef for OPT_RED function pointer.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-06-22 09:14:28 +01:00
215ed131cf
Fix 32 bit unreachable code build failure
...
Given the size of ciL is set dependant on MBEDTLS_HAVE_INT32 /
MBEDTLS_HAVE_INT64, clang rightfully reports this as unreachable code in
32 bit builds. Fix this by using #define guards instead.
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-06-20 17:55:15 +01:00
de87461c23
ecp_curves: Updated the optimised reduction function pointer.
...
This patch modifies the `mbedtls_mpi_opt_red_struct` to use an
mpi_uint * pointer and size_t limps arguments.
The methods interacting with this pointer have been updated
accordingly:
- mbedtls_mpi_mod_optred_modulus_setup
- mbedtls_ecp_modulus_setup
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-06-16 13:48:47 +01:00
65210952ec
ecp_curves: Updated mbedtls_ecp_modulus_setup
to use optimised reduction.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-06-16 13:48:47 +01:00
1d3e332986
ecp_curves: Updated input argument for mbedtls_ecp_modulus_setup
.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-06-16 13:48:47 +01:00
88e16dfa2a
bignum_mod: Refactored mbedtls_mpi_mod_modulus_setup()
...
This patch removes the `int_rep` input parameter for modular
setup, aiming to align it with the optred variant.
Test and test-suite helper functions have been updated
accordingly.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-06-16 13:48:47 +01:00
a2e48f751b
Split out mbedtls_ecp_mod_p448_raw()
...
Switch testing over to using the generic raw functions.
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-06-15 17:16:38 +01:00
b4df176610
Merge pull request #7637 from paul-elliott-arm/fixed_ecp_mod_p448
...
[Bignum] Fixed width for ecp mod p448
2023-06-15 17:12:02 +01:00
bed9ac7b2d
Optimise final 2 rounds
...
Final two rounds logic could be significantly simplified.
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-06-14 19:20:33 +01:00
b8f7305b02
Replace sizeof(mbedtls_mpi_uint) with ciL define
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-06-14 17:52:42 +01:00
3646dc78bc
Fix coding style issue
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-06-14 08:51:08 +01:00
436f2ad37c
Three round solution
...
Attempt to fix failing test by dealing with overflow with three rounds,
instead of previous subtract modulus solution. Also optimise out shifts
by using memcpy / memmove instead. Remove final sub to return canonical
result, as this is not required here.
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-06-13 17:39:44 +01:00
fcdd0477b3
Replace loop zeroise with memset
...
Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com >
2023-06-08 10:03:53 +00:00
035e5fc885
Add comments to 448 optimised reduction
...
Signed-off-by: Janos Follath <janos.follath@arm.com >
2023-06-08 09:44:30 +00:00
805a0a2d06
Merge pull request #7591 from minosgalanakis/ecp/6028_xtract_fast_reduction_curve25519
...
[Bignum] Implement fast reduction curve25519
2023-06-01 17:43:35 +01:00
edc97680d5
Fix output width of mbedtls_ecp_mod_p448() to 448 bits
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-05-25 17:37:58 +01:00
981d8b6fc7
Merge pull request #7566 from paul-elliott-arm/core_ecp_mod_p448
...
[Bignum] Convert ecp_mod_p448 over to using core functions
2023-05-25 17:11:57 +01:00
7050662a48
Correct comment header block
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-05-24 17:31:57 +01:00
e72bf2da3d
ecp_curves: Adjusted the expected limb size for ecp_mod_p255()
.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-05-24 15:13:42 +01:00
3b6bf105d1
Fix missed renames from N to X
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-05-23 17:51:52 +01:00
ec00b500b5
ecp_curves: Adjusted input checking for ecp_mod_p255
.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-05-23 17:31:01 +01:00
d6beda7af9
ecp_curves: Extended documentation for CURVE25519.
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-05-23 09:57:09 +01:00
47249fd9ec
ecp_curves: Added documentation for mbedtls_ecp_mod_p255_raw
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-05-23 09:57:09 +01:00
31f0b452c7
ecp_curves: Reintroduced input checking for
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-05-23 09:57:09 +01:00
65c386ee3d
ecp_curves: Switched to dynamic memory for
...
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-05-23 09:57:09 +01:00
2daa374ea8
ecp_curves: Minor refactoring of mbedtls_ecp_mod_p255_raw()
...
* Fixed whitespace issues.
* Renamed variables to align with bignum conventions.
* Updated alignment on test input data.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-05-23 09:57:09 +01:00
d0292c2aca
ecp_curves: Refactored mbedtls_ecp_mod_p255
.
...
This patch introduces following methods, as implemented in the
design prototype, and updates them to utilise the _core methods
available for multiplication and addition.
* `mbedtls_ecp_mod_p255()`
* `mbedtls_ecp_mod_p255_raw()`
An entry has been exposed in the `ecp_invasive.h` header
to facilitate testing.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com >
2023-05-22 22:22:32 +01:00
d56e6e008b
Add input parameter length check for the Koblitz reduction
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-17 17:51:19 +02:00
c05f51ded9
Convert comments over to X rather than N
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-05-17 14:29:44 +01:00
6b1f7f101f
Use const where appropriate
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-05-16 17:51:48 +01:00
235c1947fb
Group memory allocations earlier
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-05-16 17:51:48 +01:00
34b08e5005
Convert over to using X, X_limbs
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-05-16 17:51:48 +01:00
4fa8334bae
Convert curve 448 to use ecp core functions
...
Signed-off-by: Paul Elliott <paul.elliott@arm.com >
2023-05-16 17:51:48 +01:00
caac83c517
Fix comment
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-16 17:41:26 +02:00
03558b847e
Add _raw
function to P256K1
...
Modified the testing to use the generic fast reduction test function.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-16 17:30:03 +02:00
e42bb6294e
Add _raw
function to P224K1
...
Modified the testing to use the generic fast reduction test function.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-16 17:30:03 +02:00
dacfe56370
Add _raw
function to P192K1
...
Modified the testing to use the generic fast reduction test function.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-16 17:29:57 +02:00
a274041190
Fix comment
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-15 14:50:17 +02:00
b6653f3e27
Update comments
...
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-12 12:34:12 +02:00
dcaf99ebb8
Add another round in the Koblitz reduction
...
The addition can result in an overflow so another round is needed
in the reduction.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-12 12:34:05 +02:00
481a6a8edb
Merge pull request #7482 from gabor-mezei-arm/6029_use_core_api_in_ecp_mod_koblitz
...
[Bignum] Use core API in ecp_mod_koblitz()
2023-05-10 17:24:46 +01:00
908f40014c
Determine special cases in-place in the common Koblitz function
...
Remove parameter used by the special cases and check for special cases in-place.
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com >
2023-05-05 16:31:19 +02:00