|
40 | 40 | #define CURVED25519_ASM_64BIT |
41 | 41 | #define CURVED25519_ASM |
42 | 42 | #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 | + |
43 | 57 | #if defined(WOLFSSL_ARMASM) |
44 | 58 | #ifdef __aarch64__ |
45 | 59 | #define CURVED25519_ASM_64BIT |
@@ -112,6 +126,13 @@ WOLFSSL_LOCAL int curve25519_nb(byte * q, const byte * n, const byte * p, |
112 | 126 | WOLFSSL_LOCAL void fe_init(void); |
113 | 127 |
|
114 | 128 | WOLFSSL_LOCAL int curve25519(byte * q, const byte * n, const byte * p); |
| 129 | +#if defined(CURVED25519_X64) || (defined(WOLFSSL_ARMASM) && defined(__aarch64__)) |
| 130 | +/* Fixed-base scalar multiply provided by the x64/aarch64 assembly |
| 131 | + * (fe_x25519_asm.S, armv8-curve25519); declared here as no other header |
| 132 | + * prototypes it, which otherwise breaks a strict C (implicit-declaration) |
| 133 | + * build of curve25519.c. */ |
| 134 | +WOLFSSL_LOCAL int curve25519_base(byte * q, const byte * n); |
| 135 | +#endif |
115 | 136 | #ifdef WOLFSSL_CURVE25519_BLINDING |
116 | 137 | WOLFSSL_LOCAL int curve25519_blind(byte* q, const byte* n, const byte* mask, |
117 | 138 | const byte* p, const byte* rz); |
|
0 commit comments