Merged
Conversation
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.
2ad389e to
984d16b
Compare
Contributor
|
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.
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.
859f3a6 to
996986d
Compare
philljj
approved these changes
Oct 19, 2024
Member
|
@aidangarske please add documentation for these new API's. Thank you |
This file contains hidden or 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
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
.isAllocatedmember -- this restores preexisting semantics;add
WC_NO_CONSTRUCTORSgate, and auto-activate it whenNO_WOLFSSL_MEMORY&&WOLFSSL_NO_MALLOC(unless preempted byXMALLOC_USERorXMALLOC_OVERRIDE);exclude recently added
.isAllocatedmembers 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