-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
20241017-wc-delete-methods #8089
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add delete APIs, matching recently added wc_AesNew, wc_curve25519_new, wc_ed25519_new, wc_HashNew, and wc_NewRsaKey: * wc_AesDelete() * wc_HashDelete() * wc_DeleteRsaKey() * wc_curve25519_delete() * wc_ed25519_delete() * remove handling in corresponding preexisting free APIs for recently added .isAllocated member -- this restores preexisting semantics; * add WC_NO_CONSTRUCTORS gate, and auto-activate it when NO_WOLFSSL_MEMORY && WOLFSSL_NO_MALLOC (unless preempted by XMALLOC_USER or XMALLOC_OVERRIDE); * exclude recently added .isAllocated members from wolfcrypt structs when defined(WC_NO_CONSTRUCTORS); * adjust wolfcrypt/test/test.c for consistency with the above, and fix cleanup codes/dynamics in several tests.
douzzer
force-pushed
the
20241017-wc-delete-methods
branch
from
October 17, 2024 23:48
2ad389e
to
984d16b
Compare
This modifies the new/free logic from #3166. |
… unneeded .isAllocated member from struct definitions, and add int *result_code argument to constructor prototypes; wolfssl/wolfcrypt/aes.h: add Aes.streamData_sz; src/tls13.c: fix devId passed to wc_HmacInit() in CreateCookieExt() and TlsCheckCookie(); src/keys.c: in SetKeys(), call wc_HmacInit() on hmacs only if newly allocated; wolfcrypt/src/aes.c: * in wc_Gmac(), wc_GmacVerify(), and AesSivCipher(), use wc_AesNew() and wc_AesDelete(); * in wc_AesInit(), zero the object on entry, and remove superseded piecemeal initializations to zero; * in wc_AesFree(), zero aes->streamData, and zero the entire object as final cleanup; wolfcrypt/src/curve25519.c: in wc_curve25519_free(), zero the entire object rather than zeroing piecemeal; wolfcrypt/test/test.c: * add fallback implementations (for old FIPS) of wc_HashNew(), wc_HashDelete(), wc_curve25519_new(), wc_curve25519_delete(), wc_ed25519_new(), and wc_ed25519_delete(); * update constructor calls throughout for new semantics; * refactor ed25519_test() for proper cleanup and error encoding.
douzzer
force-pushed
the
20241017-wc-delete-methods
branch
8 times, most recently
from
October 19, 2024 01:23
2c71a22
to
859f3a6
Compare
…shDelete, and wc_DeleteRsaKey to take two arguments, the first a required pointer to the object, the second an optional pointer to the pointer to be zeroed upon successful deletion, for the benefit of calling from C# without unsafe code. wrapper/CSharp/wolfSSL_CSharp/wolfCrypt.cs: update for new calling conventions around wc_AesNew, wc_curve25519_new, wc_ed25519_new, wc_HashNew, and wc_NewRsaKey, and the corresponding delete functions.
douzzer
force-pushed
the
20241017-wc-delete-methods
branch
from
October 19, 2024 02:14
859f3a6
to
996986d
Compare
philljj
approved these changes
Oct 19, 2024
@aidangarske please add documentation for these new API's. Thank you |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
refactor wolfcrypt constructors:
add delete APIs, matching recently added
wc_AesNew
,wc_curve25519_new
,wc_ed25519_new
,wc_HashNew
, andwc_NewRsaKey
:wc_AesDelete()
wc_HashDelete()
wc_DeleteRsaKey()
wc_curve25519_delete()
wc_ed25519_delete()
remove handling in corresponding preexisting free APIs for recently added
.isAllocated
member -- this restores preexisting semantics;add
WC_NO_CONSTRUCTORS
gate, and auto-activate it whenNO_WOLFSSL_MEMORY
&&WOLFSSL_NO_MALLOC
(unless preempted byXMALLOC_USER
orXMALLOC_OVERRIDE
);exclude recently added
.isAllocated
members from wolfcrypt structs whendefined(WC_NO_CONSTRUCTORS)
.tested with
wolfssl-multi-test.sh ... check-source-text quantum-safe-wolfssl-all-g++-latest-debug quantum-safe-wolfssl-all-cppcheck fortify-source-all-asm fortify-source-all-noasm clang-tidy-all-sp-all sanitizer-all-intelasm-c-fallback-fuzzer all-gcc-c99-asn-original cryptonly-opensslextra-gcc-c99 allcryptonly-no-malloc allcryptonly-no-malloc-no-wolf-memory allcryptonly-gcc-c89 quantum-safe-wolfssl-all-valgrind quantum-safe-wolfssl-all-smallstack-valgrind cppcheck-all-smallstack