Support for Curve25519 non-blocking cryptography (based on PR #5764) #9721
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add X25519 Non-Blocking Support
Description
This PR adds non-blocking (yield) support for X25519 (Curve25519) key generation and shared secret operations, similar to the existing
WC_ECC_NONBLOCKsupport for ECC operations.Changes
New Features:
WC_X25519_NONBLOCKconfiguration macro to enable non-blocking X25519 operationsx25519_nb_ctx_tcontext structure to track non-blocking operation statewc_curve25519_set_nonblock()API to configure non-blocking mode on a keywc_curve25519_make_key()- key generationwc_curve25519_shared_secret()- ECDH shared secret computationFiles Modified:
src/internal.c- Added X25519 non-blocking context allocation/deallocation in TLSAllocKey/FreeKeywolfcrypt/src/curve25519.c- Added non-blocking key generation and shared secret functionswolfcrypt/src/fe_low_mem.c- Addedcurve25519_nb()andfe_inv__distinct_nb()non-blocking implementationswolfcrypt/test/test.c- Addedx25519_nonblock_test()and async wait calls for X25519 operationswolfssl/wolfcrypt/curve25519.h- Addedx25519_nb_ctx_tstruct andwc_curve25519_set_nonblock()APIwolfssl/wolfcrypt/fe_operations.h- Added non-blocking function declarationsRequirements
CURVE25519_SMALL(enabled via--enable-curve25519=small)WC_X25519_NONBLOCKis used withoutCURVE25519_SMALLTesting
Build command:
Run tests:
Expected output should include:
Alternative build (with debugging output):
This will print iteration counts for non-blocking operations:
API Usage Example