Skip to content

Commit c161cbd

Browse files
committed
Xtensa: mitigate potential non-CT assembly output
Compilers for Xtensa have been seen to produce non-constant time code. Force small code size builds for X25519, Ed25519, X448 and Ed448.
1 parent 9d546ac commit c161cbd

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ NO_WOLFSSL_AUTOSAR_CRYPTO
428428
NO_WOLFSSL_AUTOSAR_CSM
429429
NO_WOLFSSL_BASE64_DECODE
430430
NO_WOLFSSL_BN_CTX
431+
NO_WOLFSSL_CURVE25519_BLINDING
431432
NO_WOLFSSL_MSG_EX
432433
NO_WOLFSSL_RENESAS_FSPSM_AES
433434
NO_WOLFSSL_RENESAS_FSPSM_HASH
@@ -1078,6 +1079,7 @@ __svr4__
10781079
__thumb__
10791080
__ti__
10801081
__x86_64__
1082+
__xtensa__
10811083
byte
10821084
configTICK_RATE_HZ
10831085
fallthrough

wolfssl/wolfcrypt/settings.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,6 +2708,22 @@ extern void uITRON4_free(void *p) ;
27082708
#endif
27092709
#endif
27102710

2711+
#if defined(__xtensa__)
2712+
/* Compilers for Xtensa have been seen to compile C code into
2713+
* non-constant time assembly code. The small implementation is not known
2714+
* to have these issues. */
2715+
#undef CURVE25519_SMALL
2716+
#define CURVE25519_SMALL
2717+
#undef ED25519_SMALL
2718+
#define ED25519_SMALL
2719+
#undef CURVE448_SMALL
2720+
#define CURVE448_SMALL
2721+
#undef ED448_SMALL
2722+
#define ED448_SMALL
2723+
#warning "Contact wolfSSL support for a fast implementation that is " \
2724+
"constant time"
2725+
#endif
2726+
27112727
#if defined(NO_WC_SSIZE_TYPE) || defined(ssize_t)
27122728
/* ssize_t comes from system headers or user_settings.h */
27132729
#elif defined(WC_SSIZE_TYPE)

0 commit comments

Comments
 (0)