Skip to content

Commit

Permalink
Reduce the default MBEDTLS_ECP_WINDOW_SIZE value to 2
Browse files Browse the repository at this point in the history
As tested in #6790,
after introducing side-channel counter-measures to bignum,
the performance of RSA decryption in correlation to the
MBEDTLS_ECP_WINDOW_SIZE has changed.
The default value of 2 has been chosen as it provides best
or close-to-best results for tests on Cortex-M4 and Intel i7.
Signed-off-by: Andrzej Kurek <[email protected]>
  • Loading branch information
Andrzej Kurek committed Feb 24, 2023
1 parent 4dcc08c commit 6e9385b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.d/mpi-window-perf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Changes
* Changed the default MBEDTLS_ECP_WINDOW_SIZE from 6 to 2.
As tested in issue 6790, the correlation between this define and
RSA decryption performance has changed lately due to security fixes.
To fix the performance degradation when using default values the
window was reduced from 6 to 2, a value that gives the best or close
to best results when tested on Cortex-M4 and Intel i7.
4 changes: 2 additions & 2 deletions include/mbedtls/bignum.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@

#if !defined(MBEDTLS_MPI_WINDOW_SIZE)
/*
* Maximum window size used for modular exponentiation. Default: 6
* Maximum window size used for modular exponentiation. Default: 2
* Minimum value: 1. Maximum value: 6.
*
* Result is an array of ( 2 ** MBEDTLS_MPI_WINDOW_SIZE ) MPIs used
* for the sliding window calculation. (So 64 by default)
*
* Reduction in size, reduces speed.
*/
#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum window size used. */
#define MBEDTLS_MPI_WINDOW_SIZE 2 /**< Maximum window size used. */
#endif /* !MBEDTLS_MPI_WINDOW_SIZE */

#if !defined(MBEDTLS_MPI_MAX_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion include/mbedtls/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3749,7 +3749,7 @@
* comment in the specific module. */

/* MPI / BIGNUM options */
//#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum window size used. */
//#define MBEDTLS_MPI_WINDOW_SIZE 2 /**< Maximum window size used. */
//#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */

/* CTR_DRBG options */
Expand Down

0 comments on commit 6e9385b

Please sign in to comment.