Skip to content

Commit 9721c52

Browse files
committed
fe_operations: error on CURVE25519_SMALL/ED25519_SMALL + x64 asm
The small (reduced-C) curve25519/ed25519 code and the Intel x64 assembly both define the same fe_/sc_/curve25519 symbols. A user_settings.h that keeps CURVE25519_SMALL/ED25519_SMALL while USE_INTEL_SPEEDUP selects the x64 assembly (as happens with --enable-usersettings, which does not run configure's implementation selection) links with duplicate symbols that are hard to diagnose. Detect the incompatible combination at compile time via a clear #error keyed on CURVED25519_X64 (the single source of truth for 'x64 25519 asm active'), so it fails fast instead. NO_CURVED25519_X64 remains the escape hatch to keep the small implementation.
1 parent 0a0e084 commit 9721c52

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

wolfssl/wolfcrypt/fe_operations.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@
4040
#define CURVED25519_ASM_64BIT
4141
#define CURVED25519_ASM
4242
#endif
43+
44+
/* The small (reduced-C) curve25519/ed25519 code and the Intel x64 assembly
45+
* both provide the same fe_, sc_ and curve25519 symbols, so selecting both
46+
* (for example a user_settings.h that keeps CURVE25519_SMALL/ED25519_SMALL
47+
* while USE_INTEL_SPEEDUP enables the x64 assembly) produces duplicate-symbol
48+
* link errors that are hard to diagnose. Detect the incompatible combination
49+
* at compile time with a clear message instead. To keep the small
50+
* implementation define NO_CURVED25519_X64; to use the assembly drop
51+
* CURVE25519_SMALL / ED25519_SMALL. */
52+
#if defined(CURVED25519_X64) && \
53+
(defined(CURVE25519_SMALL) || defined(ED25519_SMALL))
54+
#error "CURVE25519_SMALL/ED25519_SMALL are incompatible with the Intel x64 curve25519/ed25519 assembly (CURVED25519_X64); define NO_CURVED25519_X64 to keep the small implementation, or remove the SMALL settings to use the assembly"
55+
#endif
56+
4357
#if defined(WOLFSSL_ARMASM)
4458
#ifdef __aarch64__
4559
#define CURVED25519_ASM_64BIT

0 commit comments

Comments
 (0)