Repository navigation
feat(libSceLibreSsl3): implement BIO_up_ref - #12945
EagleBearerYS wants to merge 3 commits into
Conversation
…s, the SSL_CTX version bounds, SSL_get_client_random and X509_get_version SSL_up_ref, SSL_SESSION_up_ref and X509_up_ref add one to the reference count of a caller-owned object through the retain helper of EVP_PKEY_up_ref, now shared in Reference.hpp, which SSL_CTX_up_ref also uses. SSL_CTX_set_min_proto_version and SSL_CTX_set_max_proto_version clamp the requested bound to the method range and convert DTLS versions; the SSL_CTX fields they use extend LibreSsl3SslCtx in Key.hpp. SSL_get_client_random copies up to 32 bytes of the SSL3 client random, and X509_get_version reads cert_info->version with the ASN1_INTEGER_get rules, queueing its ASN.1 errors. Behaviour and object layouts follow LibreSSL 4.0.0 (ce488b78e0bd): ssl_lib.c, ssl_sess.c, ssl_versions.c, ssl_local.h, x_all.c, x509_set.c, x509_local.h and a_int.c. No upstream source is copied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BIO_up_ref adds one to the reference count of a caller-owned BIO through the shared retain in Reference.hpp and returns 1 when the new count is above 1, as CRYPTO_add(...) > 1 does. LibreSsl3Bio in Key.hpp is the 112-byte BIO with its counter at offset 80. Behaviour and layout follow LibreSSL 4.0.0 (ce488b78e0bd): bio_lib.c L198-L202 and bio_local.h. No upstream source is copied.
Progress report (bb04a4f → 219770a)📈 System libraries: 46.55% (+0.06%, +9 implemented functions) ✅ 9 implemented
Changed libraries (implemented exports)
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Windows run of this head (
AI-assisted: yes (Claude Code). |
|
@EagleBearerYS a heads-up, since this branch carries #12754's commits. #12754 conflicted with To restack: AI-assisted: yes (Claude Code). |
What
BIO_up_refinlibSceLibreSsl3was a bare stub. It now does what LibreSSL 4.0.0 does (bio_lib.cL198-L202): it raises the BIO'sreferencesby one and returns 1 when the new count is above 1, asCRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1does.Retain_nid_no_patchininclude/Reference.hppas it is.LibreSsl3Bio, withreferencesat offset 80, from LibreSSL 4.0.0'sbio_local.h(struct bio_st, LP64).static_asserts hold the size and the offset.INT32_MAX, throw without changing memory, where LibreSSL dereferences or overflows.BIO_up_refdoesn't appear in an issue or discussion.Overlap: #12580 and #12582 (PrivacyOnion) append their retains and test cases after
SSL_CTX_up_reftoo, insrc/Key.cppandGuestLibreSsl3KeyReference.cpp. Whichever merges second keeps both and recounts the debt line, which already conflicts between #12754 and them. If one of them lands before #12754, #12754 is rebased, and this branch restacks on it.ASN1_STRING_get0_dataits signature inExport.cppandApi.hpp, on the line next to this PR'sBIO_up_ref. The clash is textual only. This PR goes after it (Depends on) and keeps both when it mergesmain.git merge-tree, each merged ontomainfirst: their conflicting hunks are the same with feat(libSceLibreSsl3): implement the SSL, SSL_SESSION and X509 retains, the SSL_CTX version bounds, SSL_get_client_random and X509_get_version #12754 alone, so their order follows feat(libSceLibreSsl3): implement the SSL, SSL_SESSION and X509 retains, the SSL_CTX version bounds, SSL_get_client_random and X509_get_version #12754's. feat(libSceLibreSsl3): implement ASN1_OBJECT_free #10461, feat(libSceLibreSsl3): implement the RSA, DH and DSA get0 key and parameter accessors #10490, feat(libSceLibreSsl3): implement OBJ_cmp #10631 and feat(libSceLibreSsl3): complete callable declarations and parent forwarding #12369 touch only the debt file. feat(libressl3): report OpenSSL version strings #9970 conflicts withmainalready. It sharesCMakeLists.txtwith feat(libSceLibreSsl3): implement the SSL, SSL_SESSION and X509 retains, the SSL_CTX version bounds, SSL_get_client_random and X509_get_version #12754, and the debt file, where whichever lands second recounts.Tested
guest_libressl3_key_referencegains abiocase. It sits with theCheckKeycases (EVP_PKEY,EC_KEY,SSL_CTX) inGuestLibreSsl3KeyReference.cpp, sinceBIO_up_refsits with their retains insrc/Key.cpp; feat(libSceLibreSsl3): implement the SSL, SSL_SESSION and X509 retains, the SSL_CTX version bounds, SSL_get_client_random and X509_get_version #12754'sCheckRetaincases are inGuestLibreSsl3Ssl.cpp. It covers:INT32_MAX - 1, with the result;No case asserts a throw.
Red: with the body put back to
main'sNotImplemented_nid_no_patch(the signature kept), thebiocase aborts withBIO_up_ref_nid_postfix not implemented. The other cases still pass.Green, Linux (Ubuntu 24.04, GCC 13.3, Release, CI's flags):
ctest -R "libressl3|crypto_memcmp" --repeat until-fail:10: 5 tests, 10 of 10 each, 0 skipped;ctest -R "libressl|crypto_memcmp"once: 34 tests, 34 passed, 0 skipped.Checks:
check_conventions.pyandcheck_test_registration.pypass. MinGW-w64-fsyntax-only -Wall -Wextra: no errors or warnings.GitHub, ×10 on both runners (run 40895956237), compared against feat(libSceLibreSsl3): implement the SSL, SSL_SESSION and X509 retains, the SSL_CTX version bounds, SSL_get_client_random and X509_get_version #12754's head:
guest_libressl3_key_referencepassed 10 of 10 on Linux and on Windows, 0 skipped.APS5_SKIP_TIMING_TESTS=1, pass: 171 and 291 tests on Linux, 199 and 314 on Windows.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)Export.cppandApi.hpp; this PR goes after it and keeps both when it mergesmain)