Commit graph

11319 commits

Author SHA1 Message Date
Valerio Setti
ed7d6af670 pk_wrap: optimize code for ECDSA verify
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Valerio Setti
4657f10bdb pk_wrap: optimize code for ECDSA sign
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-29 14:33:26 +02:00
Paul Elliott
92a55bf5ea
Merge pull request #7793 from minosgalanakis/ecp/6025_fast_reduction_dispatch
[Bignum] Fast reduction dispatch
2023-06-28 17:38:37 +01:00
Janos Follath
c439c678e3
Merge pull request #7719 from davidhorstmann-arm/second-jpake-state-machine-rework
Change J-PAKE internal state machine
2023-06-28 08:59:23 +01:00
Tom Cosgrove
db041cc82f
Merge pull request #7665 from AndrzejKurek/optimize-error-translation-code-size
Optimize error translation code size
2023-06-28 08:09:00 +01:00
Dave Rodgman
28e2ca51a9 Docs improvement
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 15:25:38 +01:00
Dave Rodgman
9f4fd28eff
Merge pull request #7808 from daverodgman/fix-ct-compile-warning
Fix for arm64_32 (aka ILP32) on Clang
2023-06-27 15:23:14 +01:00
Minos Galanakis
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
David Horstmann
246ec5a35e Replace unnecessary '>=' with '=='
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-27 10:33:06 +01:00
Dave Rodgman
8c5fae2610 Add explanatory comment
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 09:43:55 +01:00
Dave Rodgman
9e868be13a Fix clang warning from -Wasm-operand-widths
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-27 09:27:27 +01:00
Minos Galanakis
53a16b3fb5 bignum_mod_raw: Updated documentation for mpi_mod_raw_mul
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-26 20:06:36 +01:00
Valerio Setti
8c3404f3e0 x509: update ECP_LIGHT dependencies to PK_HAVE_ECC_KEYS
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-26 15:49:48 +02:00
Minos Galanakis
8eb6104256 bignum_mod_raw: Fixed a documentation typo.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-26 10:03:19 +01:00
Minos Galanakis
c7408a432e bignum_mod_raw: Adjusted OPT_RED limb size requirements for mod_raw_mul().
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-25 21:14:44 +01:00
Minos Galanakis
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
Dave Rodgman
4e5c63d652
Improve documentation in bn_mul.h
Co-authored-by: Tom Cosgrove <tom.cosgrove@arm.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-23 15:17:37 +01:00
Minos Galanakis
7b1093240c bignum_mod_raw: Updated documentation for mbedtls_mpi_mod_raw_mul
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-22 16:52:20 +01:00
Minos Galanakis
2ed8fb7e4f ecp_mod_raw: Enabled fast reduction.
This patch modifies `mbedtls_mpi_mod_raw_mul`
to utilise fast-reduction when available.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2023-06-22 16:35:30 +01:00
Paul Elliott
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
David Horstmann
57727cd3fc Explain the sequence of mbedtls_psa_pake_ calls
Add a comment showing the order in which the mbedtls_psa_pake_xyz()
functions may be called.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
88d25f0075 Remove unnecessary checks in psa_jpake_prologue()
These checks are not needed as long as the state is intact.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
e5b374adaf Remove comment explaining the state machine
The explanation of the dispatch layer's state machine should not be in
the file containing the software implementation and a better
understanding can be had by reading the dispatch layer's code.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
74a3d8c99c Simplify logic of driver step conversion
Take advantage of the contiguous nature of XYZ_KEY_SHARE, XYZ_ZK_PUBLIC
and XYZ_ZK_PROOF to simplify the conversion code.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
5d878f6c5f Tweak wording for clarity
"inputs this round" -> "inputs for this round"

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
1b54faed67 Remove unnecessary initialization of state
The psa_jpake_computation_stage_t is already initialized in
psa_pake_setup(), so does not need initializing again in
psa_pake_complete_inputs().

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
16f0151887 Use memset for initialization
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
024e5c5f2e Rename struct member mode to io_mode
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
00ad6bfabe Rename function_mode to io_mode
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
5da9560178 Properly namespace enum values within PSA_JPAKE_
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
David Horstmann
e7f21e65b6 Change J-PAKE internal state machine
Keep track of the J-PAKE internal state in a more intuitive way.
Specifically, replace the current state with a struct of 5 fields:

* The round of J-PAKE we are currently in, FIRST or SECOND
* The 'mode' we are currently working in, INPUT or OUTPUT
* The number of inputs so far this round
* The number of outputs so far this round
* The PAKE step we are expecting, KEY_SHARE, ZK_PUBLIC or ZK_PROOF

This should improve the readability of the state-transformation code.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-06-22 15:22:35 +01:00
Manuel Pégourié-Gonnard
e25c43bd66
Merge pull request #7791 from valeriosetti/issue7406
driver-only ECC: TLS: avoid use of mbedtls_ecp_write_key() (with USE_PSA)
2023-06-22 11:13:44 +02:00
Minos Galanakis
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
Manuel Pégourié-Gonnard
2fb9d00f6d
Merge pull request #7682 from valeriosetti/issue7453
driver-only ECC: ECPf.PK testing
2023-06-22 09:45:57 +02:00
Valerio Setti
6835b4a6ed tls: always zeroize buffer on exit
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-22 09:06:31 +02:00
Valerio Setti
3589a4c644 tls: keep buffer declaration in a single line
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2023-06-22 09:02:44 +02:00
Dave Rodgman
e6c9996d04 Work around updating pointers from ILP32
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 21:16:23 +01:00
Dave Rodgman
5b5dd011d1 code style
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 16:36:47 +01:00
Dave Rodgman
b5b6939fc2 Remove redundant checks in constant_time.c
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 16:36:42 +01:00
Dave Rodgman
0400ae2f9b Fix pointer constraint in bn_mul.h
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 16:31:52 +01:00
Dave Rodgman
c54f25e26c code style
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 13:39:30 +01:00
Dave Rodgman
63e89b46f8 Use UINTPTR_MAX not SIZE_MAX
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 11:58:54 +01:00
Dave Rodgman
85842b8edb Be strict about pointer size in mbedtls_get_unaligned_volatile_uint32
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 11:22:09 +01:00
Bence Szépkúti
f2154a6e10
Merge pull request #7686 from DemiMarie/do-while
Add a do-while loop around macros.
2023-06-21 11:31:41 +02:00
Dave Rodgman
b67db9140e Separate ILP32 and normal-aarch64 code paths
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 09:15:27 +01:00
Dave Rodgman
04cb9ac59e Fix for arm64_32 (aka ILP32) on Clang (attempt 2)
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-21 07:32:22 +01:00
Dave Rodgman
b19f584f2c Fix for arm64_32 (aka ILP32) on Clang
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
2023-06-20 23:01:43 +01:00
Gilles Peskine
a3a0025e18
Merge pull request #7806 from paul-elliott-arm/fix_32bit_builds
[Bignum] Fix 32 bit unreachable code build failure
2023-06-20 22:13:06 +02:00
Gilles Peskine
5faccf038b
Merge pull request #7805 from paul-elliott-arm/fix_retval
Pacify clang15 warnings about empty \retval
2023-06-20 22:12:51 +02:00
Paul Elliott
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