Skip to content

Commit

Permalink
Merge pull request #7170 from AndrzejKurek/mpi-window-size-2.28
Browse files Browse the repository at this point in the history
[Backport 2.28] Reduce the default MBEDTLS_ECP_WINDOW_SIZE value to 2
  • Loading branch information
daverodgman authored Feb 27, 2023
2 parents b361e04 + 6e9385b commit 7a5168e
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 7a5168e

Please sign in to comment.