Skip to content

Commit e6d86b4

Browse files
authored
Merge pull request #10832 from padelsbach/curve25519-cryptocb-only
Add crypto callback only mode for curve25519
2 parents 1cfa98a + 4c7cbf5 commit e6d86b4

10 files changed

Lines changed: 203 additions & 21 deletions

File tree

.github/workflows/cryptocb-only.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,12 @@ jobs:
114114
{"name": "ed25519-no-curve25519",
115115
"comment": "Same as ed25519 but with curve25519 off. curve25519 is the only other user of the ge/fe math, so without it the strip is complete and nothing must pull the math back in. The ed25519 entry above keeps curve25519 enabled, which leaves fe_operations.c compiled and would hide such a regression at link time.",
116116
"configure": ["--disable-curve25519", "CPPFLAGS=-DWOLF_CRYPTO_CB_ONLY_ED25519"]},
117+
{"name": "curve25519",
118+
"comment": "WOLF_CRYPTO_CB_ONLY_CURVE25519: strips software X25519 (keygen/shared-secret); swdev provides the software path via cryptocb. Nonblock and async X25519 have no callback path and are left disabled.",
119+
"configure": ["CPPFLAGS=-DWOLF_CRYPTO_CB_ONLY_CURVE25519"]},
117120
{"name": "all",
118-
"comment": "All six ONLY_* macros at once: every supported software primitive is stripped and dispatched through cryptocb. Catches any cross-algorithm call that a single-strip entry would still resolve via the remaining software paths.",
119-
"configure": ["CPPFLAGS=-DWOLF_CRYPTO_CB_ONLY_ECC -DWOLF_CRYPTO_CB_ONLY_RSA -DWOLF_CRYPTO_CB_ONLY_SHA256 -DWOLF_CRYPTO_CB_ONLY_SHA512 -DWOLF_CRYPTO_CB_ONLY_AES -DWOLF_CRYPTO_CB_ONLY_ED25519"]}
121+
"comment": "All seven ONLY_* macros at once: every supported software primitive is stripped and dispatched through cryptocb. Catches any cross-algorithm call that a single-strip entry would still resolve via the remaining software paths.",
122+
"configure": ["CPPFLAGS=-DWOLF_CRYPTO_CB_ONLY_ECC -DWOLF_CRYPTO_CB_ONLY_RSA -DWOLF_CRYPTO_CB_ONLY_SHA256 -DWOLF_CRYPTO_CB_ONLY_SHA512 -DWOLF_CRYPTO_CB_ONLY_AES -DWOLF_CRYPTO_CB_ONLY_ED25519 -DWOLF_CRYPTO_CB_ONLY_CURVE25519"]}
120123
]}
121124
EOF
122125
.github/scripts/parallel-make-check.py \

tests/api.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30819,7 +30819,8 @@ static int test_SSL_CIPHER_get_current_kx(void)
3081930819
(!defined(WOLF_CRYPTO_CB_ONLY_SHA256) && !defined(WOLF_CRYPTO_CB_ONLY_AES) && \
3082030820
!defined(WOLF_CRYPTO_CB_ONLY_ECC) && !defined(WOLF_CRYPTO_CB_ONLY_RSA) && \
3082130821
!defined(WOLF_CRYPTO_CB_ONLY_SHA512) && \
30822-
!defined(WOLF_CRYPTO_CB_ONLY_ED25519))
30822+
!defined(WOLF_CRYPTO_CB_ONLY_ED25519) && \
30823+
!defined(WOLF_CRYPTO_CB_ONLY_CURVE25519))
3082330824

3082430825
static int load_pem_key_file_as_der(const char* privKeyFile, DerBuffer** pDer,
3082530826
int* keyFormat)
@@ -31924,7 +31925,8 @@ static int test_wc_CryptoCb(void)
3192431925
(!defined(WOLF_CRYPTO_CB_ONLY_SHA256) && !defined(WOLF_CRYPTO_CB_ONLY_AES) && \
3192531926
!defined(WOLF_CRYPTO_CB_ONLY_ECC) && !defined(WOLF_CRYPTO_CB_ONLY_RSA) && \
3192631927
!defined(WOLF_CRYPTO_CB_ONLY_SHA512) && \
31927-
!defined(WOLF_CRYPTO_CB_ONLY_ED25519))
31928+
!defined(WOLF_CRYPTO_CB_ONLY_ED25519) && \
31929+
!defined(WOLF_CRYPTO_CB_ONLY_CURVE25519))
3192831930
#if defined(HAVE_IO_TESTS_DEPENDENCIES) && \
3192931931
(!defined(NO_RSA) || defined(HAVE_ECC) || defined(HAVE_ED25519))
3193031932
int tlsVer;
@@ -38315,15 +38317,13 @@ TEST_CASE testCases[] = {
3831538317
/* Can't memory test as client/server Asserts in thread. */
3831638318
TEST_DECL(test_prioritize_psk),
3831738319

38318-
/* test_wc_CryptoCb_registry is defined only inside the
38319-
* WOLF_CRYPTO_CB + HAVE_IO_TESTS_DEPENDENCIES block below; register it under
38320-
* the same condition so it is neither undeclared (when absent) nor
38321-
* defined-but-unused. */
38320+
/* Must match the guard on the definition of test_wc_CryptoCb_registry. */
3832238321
#if defined(WOLF_CRYPTO_CB) && defined(HAVE_IO_TESTS_DEPENDENCIES) && \
3832338322
(!defined(WOLF_CRYPTO_CB_ONLY_SHA256) && !defined(WOLF_CRYPTO_CB_ONLY_AES) && \
3832438323
!defined(WOLF_CRYPTO_CB_ONLY_ECC) && !defined(WOLF_CRYPTO_CB_ONLY_RSA) && \
3832538324
!defined(WOLF_CRYPTO_CB_ONLY_SHA512) && \
38326-
!defined(WOLF_CRYPTO_CB_ONLY_ED25519))
38325+
!defined(WOLF_CRYPTO_CB_ONLY_ED25519) && \
38326+
!defined(WOLF_CRYPTO_CB_ONLY_CURVE25519))
3832738327
/* Can't memory test as client/server hangs. */
3832838328
TEST_DECL(test_wc_CryptoCb_registry),
3832938329
#endif

tests/swdev/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The switches it supports are:
1616
| `WOLF_CRYPTO_CB_ONLY_SHA512` | software SHA-512 | SHA-512 via CryptoCb |
1717
| `WOLF_CRYPTO_CB_ONLY_AES` | software AES | AES via CryptoCb |
1818
| `WOLF_CRYPTO_CB_ONLY_ED25519` | software Ed25519 | Ed25519 via CryptoCb |
19+
| `WOLF_CRYPTO_CB_ONLY_CURVE25519` | software X25519 | X25519 via CryptoCb |
1920

2021
When a test program calls e.g. `wc_AesCbcEncrypt()` against a libwolfssl
2122
built with `-DWOLF_CRYPTO_CB_ONLY_AES`, the software AES path is gone;
@@ -57,7 +58,7 @@ internal copy of the AES code, and returns the result.
5758
| wc_SwDev_Callback(devId, info, ctx) |
5859
| - swdev_ensure_init() lazy wolfCrypt_Init |
5960
| - switch (info->algo_type): |
60-
| PK -> RSA / ECC / Ed25519 software impl |
61+
| PK -> RSA/ECC/Ed25519/X25519 software impl |
6162
| HASH -> SHA-256 software impl |
6263
| CIPHER -> AES (CBC/CTR/ECB/GCM/CCM) software impl |
6364
| |
@@ -72,7 +73,8 @@ internal copy of the AES code, and returns the result.
7273
The whole mechanism rests on compiling the wolfcrypt sources twice:
7374

7475
1. **libwolfssl** is built normally with the user's `_ONLY_*` flags
75-
set, so its software RSA/ECC/SHA-256/SHA-512/AES/Ed25519 paths are gone.
76+
set, so its software RSA/ECC/SHA-256/SHA-512/AES/Ed25519/X25519 paths
77+
are gone.
7678
2. **swdev** recompiles the same source set under
7779
`tests/swdev/user_settings.h`, which `#undef`s every `_ONLY_*`
7880
macro. swdev therefore contains the full software implementations.

tests/swdev/swdev.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#ifdef HAVE_ED25519
4444
#include <wolfssl/wolfcrypt/ed25519.h>
4545
#endif
46+
#ifdef HAVE_CURVE25519
47+
#include <wolfssl/wolfcrypt/curve25519.h>
48+
#endif
4649

4750
static int swdev_initialized = 0;
4851

@@ -318,6 +321,23 @@ static int swdev_ed25519_check_key(wc_CryptoInfo* info)
318321
}
319322
#endif /* HAVE_ED25519 */
320323

324+
#ifdef HAVE_CURVE25519
325+
static int swdev_curve25519_keygen(wc_CryptoInfo* info)
326+
{
327+
return wc_curve25519_make_key(info->pk.curve25519kg.rng,
328+
info->pk.curve25519kg.size, info->pk.curve25519kg.key);
329+
}
330+
331+
#ifdef HAVE_CURVE25519_SHARED_SECRET
332+
static int swdev_curve25519(wc_CryptoInfo* info)
333+
{
334+
return wc_curve25519_shared_secret_ex(info->pk.curve25519.private_key,
335+
info->pk.curve25519.public_key, info->pk.curve25519.out,
336+
info->pk.curve25519.outlen, info->pk.curve25519.endian);
337+
}
338+
#endif /* HAVE_CURVE25519_SHARED_SECRET */
339+
#endif /* HAVE_CURVE25519 */
340+
321341
#ifndef NO_SHA256
322342
/* Copy hash state between caller's wc_Sha256 and swdev's shadow, leaving
323343
* admin fields (heap, devId, devCtx, W, async, HW ctx) per-side. */
@@ -913,7 +933,8 @@ WC_SWDEV_EXPORT int wc_SwDev_Callback(int devId, wc_CryptoInfo* info,
913933
return ret;
914934

915935
switch (info->algo_type) {
916-
#if !defined(NO_RSA) || defined(HAVE_ECC) || defined(HAVE_ED25519)
936+
#if !defined(NO_RSA) || defined(HAVE_ECC) || defined(HAVE_ED25519) || \
937+
defined(HAVE_CURVE25519)
917938
case WC_ALGO_TYPE_PK:
918939
switch (info->pk.type) {
919940
#ifndef NO_RSA
@@ -964,6 +985,14 @@ WC_SWDEV_EXPORT int wc_SwDev_Callback(int devId, wc_CryptoInfo* info,
964985
case WC_PK_TYPE_ED25519_CHECK_KEY:
965986
return swdev_ed25519_check_key(info);
966987
#endif /* HAVE_ED25519 */
988+
#ifdef HAVE_CURVE25519
989+
case WC_PK_TYPE_CURVE25519_KEYGEN:
990+
return swdev_curve25519_keygen(info);
991+
#ifdef HAVE_CURVE25519_SHARED_SECRET
992+
case WC_PK_TYPE_CURVE25519:
993+
return swdev_curve25519(info);
994+
#endif
995+
#endif /* HAVE_CURVE25519 */
967996
default:
968997
return CRYPTOCB_UNAVAILABLE;
969998
}

tests/swdev/user_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#undef WOLF_CRYPTO_CB_ONLY_SHA512
2929
#undef WOLF_CRYPTO_CB_ONLY_AES
3030
#undef WOLF_CRYPTO_CB_ONLY_ED25519
31+
#undef WOLF_CRYPTO_CB_ONLY_CURVE25519
3132

3233
#ifndef WOLF_CRYPTO_CB
3334
#error "wc_swdev requires the main build to define WOLF_CRYPTO_CB"

wolfcrypt/src/cryptocb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Crypto Callback Build Options:
6565
* WOLF_CRYPTO_CB_ONLY_SHA512: Use only callbacks for SHA-512 default: off
6666
* WOLF_CRYPTO_CB_ONLY_AES: Use only callbacks for AES default: off
6767
* WOLF_CRYPTO_CB_ONLY_ED25519: Use only callbacks for Ed25519 default: off
68+
* WOLF_CRYPTO_CB_ONLY_CURVE25519: Use only callbacks for X25519 default: off
6869
*/
6970

7071
#include <wolfssl/wolfcrypt/libwolfssl_sources.h>

wolfcrypt/src/curve25519.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,21 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
563563
return BAD_FUNC_ARG;
564564

565565
#ifdef WOLF_CRYPTO_CB
566-
if (key->devId != INVALID_DEVID) {
566+
#ifndef WOLF_CRYPTO_CB_FIND
567+
if (key->devId != INVALID_DEVID)
568+
#endif
569+
{
567570
ret = wc_CryptoCb_Curve25519Gen(rng, keysize, key);
568571
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
569572
return ret;
570573
/* fall-through when unavailable */
571574
}
572575
#endif
573576

577+
#ifdef WOLF_CRYPTO_CB_ONLY_CURVE25519
578+
/* software path stripped; callback is the only provider */
579+
return NO_VALID_DEVID;
580+
#else
574581
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_X25519) && \
575582
defined(WOLFSSL_ASYNC_CRYPT_SW)
576583
if (key->asyncDev.marker == WOLFSSL_ASYNC_MARKER_X25519) {
@@ -616,6 +623,7 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
616623
#endif /* !WOLFSSL_SE050 */
617624

618625
return ret;
626+
#endif /* WOLF_CRYPTO_CB_ONLY_CURVE25519 */
619627
}
620628

621629
#ifdef HAVE_CURVE25519_SHARED_SECRET
@@ -722,7 +730,10 @@ int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
722730
#endif
723731

724732
#ifdef WOLF_CRYPTO_CB
725-
if (private_key->devId != INVALID_DEVID) {
733+
#ifndef WOLF_CRYPTO_CB_FIND
734+
if (private_key->devId != INVALID_DEVID)
735+
#endif
736+
{
726737
ret = wc_CryptoCb_Curve25519(private_key, public_key, out, outlen,
727738
endian);
728739
if (ret != WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
@@ -731,6 +742,10 @@ int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
731742
}
732743
#endif
733744

745+
#ifdef WOLF_CRYPTO_CB_ONLY_CURVE25519
746+
/* software path stripped; callback is the only provider */
747+
return NO_VALID_DEVID;
748+
#else
734749
#ifdef WC_X25519_NONBLOCK
735750

736751
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_X25519) && \
@@ -816,6 +831,7 @@ int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
816831
}
817832

818833
return ret;
834+
#endif /* WOLF_CRYPTO_CB_ONLY_CURVE25519 */
819835
}
820836

821837
#endif /* HAVE_CURVE25519_SHARED_SECRET */

wolfcrypt/test/test.c

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,8 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
31973197
TEST_PASS("FLATTEN ALT NAMES test passed!\n");
31983198
#endif
31993199

3200-
#ifdef HAVE_CURVE25519
3200+
#if defined(HAVE_CURVE25519) && \
3201+
(!defined(WOLF_CRYPTO_CB_ONLY_CURVE25519) || defined(WOLFSSL_SWDEV))
32013202
if ( (ret = curve25519_test()) != 0)
32023203
TEST_FAIL("CURVE25519 test failed!\n", ret);
32033204
else
@@ -76942,6 +76943,88 @@ static wc_test_ret_t ed25519_onlycb_test(myCryptoDevCtx *ctx)
7694276943
}
7694376944
#endif /* WOLF_CRYPTO_CB_ONLY_ED25519 */
7694476945

76946+
#ifdef WOLF_CRYPTO_CB_ONLY_CURVE25519
76947+
/* Exercise Curve25519 dispatch under CB_ONLY_CURVE25519: cb-handled then
76948+
* cb-delegated. */
76949+
static wc_test_ret_t curve25519_onlycb_test(myCryptoDevCtx *ctx)
76950+
{
76951+
wc_test_ret_t ret = 0;
76952+
curve25519_key key;
76953+
#if defined(HAVE_CURVE25519_SHARED_SECRET) && \
76954+
defined(HAVE_CURVE25519_KEY_IMPORT)
76955+
curve25519_key pubKey;
76956+
const byte priv[CURVE25519_KEYSIZE] = {1};
76957+
const byte pub[CURVE25519_KEYSIZE] = {9};
76958+
byte out[CURVE25519_KEYSIZE];
76959+
word32 outLen = (word32)sizeof(out);
76960+
#endif
76961+
WC_RNG rng;
76962+
76963+
ret = wc_curve25519_init_ex(&key, HEAP_HINT, devId);
76964+
if (ret != 0)
76965+
return WC_TEST_RET_ENC_EC(ret);
76966+
76967+
ret = wc_InitRng(&rng);
76968+
if (ret != 0) {
76969+
wc_curve25519_free(&key);
76970+
return WC_TEST_RET_ENC_EC(ret);
76971+
}
76972+
76973+
/* cb handles the op, expects 0(success) */
76974+
ctx->exampleVar = 99;
76975+
ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key);
76976+
if (ret != 0)
76977+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb);
76978+
76979+
/* cb delegates to software, expects NO_VALID_DEVID(failure) */
76980+
ctx->exampleVar = 1;
76981+
ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key);
76982+
if (ret != WC_NO_ERR_TRACE(NO_VALID_DEVID)) {
76983+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb);
76984+
} else {
76985+
ret = 0;
76986+
}
76987+
76988+
#if defined(HAVE_CURVE25519_SHARED_SECRET) && \
76989+
defined(HAVE_CURVE25519_KEY_IMPORT)
76990+
ret = wc_curve25519_init_ex(&pubKey, HEAP_HINT, devId);
76991+
if (ret != 0)
76992+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb);
76993+
76994+
ret = wc_curve25519_import_private(priv, sizeof(priv), &key);
76995+
if (ret != 0)
76996+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb_pub);
76997+
ret = wc_curve25519_import_public(pub, sizeof(pub), &pubKey);
76998+
if (ret != 0)
76999+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb_pub);
77000+
77001+
/* cb handles the op, expects 0(success) */
77002+
ctx->exampleVar = 99;
77003+
ret = wc_curve25519_shared_secret(&key, &pubKey, out, &outLen);
77004+
if (ret != 0)
77005+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb_pub);
77006+
77007+
/* cb delegates to software, expects NO_VALID_DEVID(failure) */
77008+
ctx->exampleVar = 1;
77009+
ret = wc_curve25519_shared_secret(&key, &pubKey, out, &outLen);
77010+
if (ret != WC_NO_ERR_TRACE(NO_VALID_DEVID)) {
77011+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), exit_onlycb_pub);
77012+
} else {
77013+
ret = 0;
77014+
}
77015+
77016+
exit_onlycb_pub:
77017+
wc_curve25519_free(&pubKey);
77018+
#endif /* HAVE_CURVE25519_SHARED_SECRET && HAVE_CURVE25519_KEY_IMPORT */
77019+
77020+
exit_onlycb:
77021+
wc_FreeRng(&rng);
77022+
wc_curve25519_free(&key);
77023+
(void)ctx;
77024+
return ret;
77025+
}
77026+
#endif /* WOLF_CRYPTO_CB_ONLY_CURVE25519 */
77027+
7694577028
#if defined(HAVE_ECC) && !defined(WOLFSSL_NO_MALLOC) && \
7694677029
defined(HAVE_ECC_KEY_EXPORT)
7694777030
/* Serialize pub to X9.63 uncompressed (0x04 || X || Y) using the curve size
@@ -77337,6 +77420,15 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
7733777420
if (info->pk.type == WC_PK_TYPE_CURVE25519_KEYGEN) {
7733877421
/* set devId to invalid, so software is used */
7733977422
info->pk.curve25519kg.key->devId = INVALID_DEVID;
77423+
#if defined(WOLF_CRYPTO_CB_ONLY_CURVE25519)
77424+
#ifdef DEBUG_WOLFSSL
77425+
printf("CryptoDevCb: exampleVar %d\n", myCtx->exampleVar);
77426+
#endif
77427+
if (myCtx->exampleVar == 99) {
77428+
info->pk.curve25519kg.key->devId = devIdArg;
77429+
return 0;
77430+
}
77431+
#endif
7734077432

7734177433
ret = wc_curve25519_make_key(info->pk.curve25519kg.rng,
7734277434
info->pk.curve25519kg.size, info->pk.curve25519kg.key);
@@ -77347,6 +77439,15 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
7734777439
else if (info->pk.type == WC_PK_TYPE_CURVE25519) {
7734877440
/* set devId to invalid, so software is used */
7734977441
info->pk.curve25519.private_key->devId = INVALID_DEVID;
77442+
#if defined(WOLF_CRYPTO_CB_ONLY_CURVE25519)
77443+
#ifdef DEBUG_WOLFSSL
77444+
printf("CryptoDevCb: exampleVar %d\n", myCtx->exampleVar);
77445+
#endif
77446+
if (myCtx->exampleVar == 99) {
77447+
info->pk.curve25519.private_key->devId = devIdArg;
77448+
return 0;
77449+
}
77450+
#endif
7735077451

7735177452
ret = wc_curve25519_shared_secret_ex(
7735277453
info->pk.curve25519.private_key, info->pk.curve25519.public_key,
@@ -79654,10 +79755,17 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cryptocb_test(void)
7965479755
ret = ed25519_onlycb_test(&myCtx);
7965579756
PRIVATE_KEY_LOCK();
7965679757
#endif
79657-
#ifdef HAVE_CURVE25519
79758+
#if defined(HAVE_CURVE25519) && \
79759+
(!defined(WOLF_CRYPTO_CB_ONLY_CURVE25519) || defined(WOLFSSL_SWDEV))
7965879760
if (ret == 0)
7965979761
ret = curve25519_test();
7966079762
#endif
79763+
#if defined(WOLF_CRYPTO_CB_ONLY_CURVE25519) && !defined(WOLFSSL_SWDEV)
79764+
PRIVATE_KEY_UNLOCK();
79765+
if (ret == 0)
79766+
ret = curve25519_onlycb_test(&myCtx);
79767+
PRIVATE_KEY_LOCK();
79768+
#endif
7966179769
#if !defined(NO_AES) && !defined(WOLF_CRYPTO_CB_ONLY_AES)
7966279770
/* CB_ONLY_AES skips these (aes_onlycb_test covers that path). */
7966379771
#ifdef HAVE_AESGCM

wolfssl/wolfcrypt/fe_operations.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@
6363
#define CURVED25519_ASM
6464
#endif
6565

66-
/* curve25519 shares the ed25519 field math, and borrows the group math
67-
* on some builds.
68-
* For WOLF_CRYPTO_CB_ONLY_ED25519 to strip the fe/ge modules, ensure that
69-
* curve25519 is disabled. */
66+
/* curve25519 always uses its own field math, but on some builds it borrows
67+
* ed25519's group math via WOLFSSL_CURVE25519_USE_ED25519 below. Under
68+
* WOLF_CRYPTO_CB_ONLY_ED25519 ed25519's group math is removed. */
7069
#if (defined(CURVED25519_ASM_64BIT) || defined(HAVE_ED25519)) && \
7170
!defined(WOLFSSL_CURVE25519_BLINDING) && \
7271
!defined(WOLFSSL_CURVE25519_NOT_USE_ED25519) && \
73-
(!defined(WOLF_CRYPTO_CB_ONLY_ED25519) || defined(HAVE_CURVE25519))
72+
(!defined(WOLF_CRYPTO_CB_ONLY_ED25519) || \
73+
(defined(HAVE_CURVE25519) && \
74+
!defined(WOLF_CRYPTO_CB_ONLY_CURVE25519)))
7475
#undef WOLFSSL_CURVE25519_USE_ED25519
7576
#define WOLFSSL_CURVE25519_USE_ED25519
7677
#endif

0 commit comments

Comments
 (0)