Repository navigation
Conversation
Allocate the zeroed HMAC_CTX block from the guest heap and release a context that no HMAC call has used, as LibreSSL 3.8.4 does. A used context throws, as releasing it needs the digest cleanup that main lacks. A guest test covers the allocation, the null free and the allocation failure.
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.
What
Implements
HMAC_CTX_newandHMAC_CTX_free(libSceLibreSsl3 NIDsLcxutSyn11oandYAxGqtnKQFY), which threwNotImplemented_nid_no_patchas parameterless placeholders. Their declarations ininclude/Api.hppbecomevoid* HMAC_CTX_new()andvoid HMAC_CTX_free(void* context), and the placeholders leaveAdditionalExports.cpp;docs/dev/debt/libSceLibreSsl3.mdgoes from 176 to 174 additional exports (50 to 48 named) and loses their two table rows.HMAC_CTX_newreturns a zeroed 304-byte block from the guest heap, thesizeof(HMAC_CTX)of LibreSSL 3.8.4 (HMAC_MAX_MD_CBLOCK144, 48-byteEVP_MD_CTXmembers), or null if the allocation fails, ascallocfollowed byHMAC_CTX_initdoes inhmac.c.HMAC_CTX_free(NULL)returns. A context in the stateHMAC_CTX_newleft it (its first 152 bytes zero, which covers the pointer and the three contexts of the 3.8.4 layout and of 40-byte ones) is released. Any other context throwsNotImplemented_nid_no_patch, since releasing it isHMAC_CTX_cleanup, which needsEVP_MD_CTX_cleanupand the digest callbacks that main does not have.PKCS5_PBKDF2_HMAC(needsHMAC_Init_ex,HMAC_Update,HMAC_Finaland a digest object),EVP_MD_block_size(theEVP_MDlayout differs between LibreSSL 2.5.4, which the legacy provider uses, and 3.8.4:block_sizeis at offset 100 in one and 64 in the other, and nothing on main creates anEVP_MD) andEVP_sha512_256. They stay throwing placeholders.The behaviour is not measured on a PS5; the debt file entry states this and the layout caveat.
New guest test
guest_libressl3_hmac_context(registered in the library'sCMakeLists.txt) checks thecalloc(1, 304)allocation and its zeroed contents, release through the guestfree, the null free, a failed allocation, and that a context with any of its first 152 bytes set throws without being freed while a context with only its key area set is released.Tested
Linux x86_64, GCC 14.2 (g++ extracted from Debian trixie packages),
-DBUILD_TESTING=ON, full configure with all submodules. Hardware and titles: not tested.libSceLibreSsl3and the LibreSSL3 test executables.ctest -R "libressl3|crypto_memcmp"passes all 10 tests,guest_libressl3_hmac_contextin under 0.01 s.core/libs/tests/test_public_headers.py --audit-onlypasses (one declaration per export).tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.tools/pr_overlap.py --branch feat/libressl3-hmac-ctxfinds no PR with the same exports or new files. It reports textual overlap indocs/dev/debt/libSceLibreSsl3.mdwith feat(libSceLibreSsl3): implement RSA_get0_factors and RSA_get0_crt_params boykopovar/AnyPS5#14366, feat(libressl3): implement EVP_PKEY_bits boykopovar/AnyPS5#14409, feat(libressl3): implement ASN1_TIME_diff boykopovar/AnyPS5#14464, feat(libressl3): implement ASN.1 object header parsing boykopovar/AnyPS5#14465, feat(libSceLibreSsl3): implement SSL_CIPHER_get_id boykopovar/AnyPS5#14483, feat(libSceLibreSsl3): implement EVP_PKEY_get0_EC_KEY boykopovar/AnyPS5#14499, feat(libSceLibreSsl3): implement AES_unwrap_key boykopovar/AnyPS5#14612, feat(libSceLibreSsl3): implement ASN.1 value mutation and octet lifetime boykopovar/AnyPS5#14889 and feat(libSceLibreSsl3): implement custom BIO methods and field accessors boykopovar/AnyPS5#14890 (alsoCMakeLists.txtline 7 for feat(libSceLibreSsl3): implement custom BIO methods and field accessors boykopovar/AnyPS5#14890), and could not compare feat(libressl3): report OpenSSL version strings boykopovar/AnyPS5#9970, feat(libSceLibreSsl3): implement ASN1_OBJECT_free boykopovar/AnyPS5#10461, feat(libSceLibreSsl3): implement OBJ_cmp boykopovar/AnyPS5#10631, feat(libSceLibreSsl3): implement the SSL_CTX, SSL, SSL_SESSION and X509 retains, the SSL_CTX version bounds, SSL_get_client_random and X509_get_version boykopovar/AnyPS5#12754 and docs(debt): separate entries with blank lines and drop derived export totals boykopovar/AnyPS5#14212 because they conflict withmain; none of them implementsHMAC_CTX_neworHMAC_CTX_free.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)