feat(libSceLibreSsl): implement the EVP message digest and HMAC functions #9448

Merged
HQasper merged 7 commits from upstream-pr/9448 into main 2026-11-02 16:12:30 +00:00
HQasper commented 2026-10-21 22:25:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-21T22:25:16Z.


What

All libSceLibreSsl exports outside the open PRs still throw. This implements the 20 EVP message digest and HMAC exports, which is what code built on LibreSSL normally calls instead of the raw SHA256_* functions: EVP_md5, EVP_sha256, EVP_sha384, EVP_sha512, EVP_MD_size, EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_DigestInit_ex, EVP_DigestUpdate, EVP_DigestFinal_ex, EVP_Digest, HMAC_CTX_init, HMAC_CTX_cleanup, HMAC_Init, HMAC_Init_ex, HMAC_Update, HMAC_Final and HMAC.

  • Which LibreSSL. The firmware 13.40 measurements that main already cites for X509_verify_cert_error_string identify LibreSSL 2.5.4, while the module's export table also has SSL_get0_param and X509_VERIFY_PARAM_set1_host, which the Symbols.list of 2.5.4 and 2.6.3 lack and 2.7.2's has. It also has HMAC_CTX_init/HMAC_CTX_cleanup, which 3.4.1 has and 3.5.2 dropped when HMAC_CTX became opaque. The functions follow 2.5.4's digest.c and hmac.c, and src/Evp.cpp starts with the copyright notices, licence conditions and disclaimers of both files, verbatim from that commit. Up to 3.4.1, hmac.c only gains new functions, digest.c only changes malloc to calloc for the digest data and drops a null check before ENGINE_finish, and the EVP_MD, EVP_MD_CTX and HMAC_CTX structures do not change, so the behaviour is the same for either reading.
  • Layouts. The public EVP_MD (120 bytes), EVP_MD_CTX (48) and HMAC_CTX (288) follow evp.h and hmac.h and are checked with static_assert on size and field offsets. The unsigned long flags are a 64-bit field, so the layout also holds on Windows. A context the title allocates, copies or reads (for example through the HMAC_size macro, which reads ctx->md) stays valid.
  • Public header. include/Api.hpp declared the 20 functions with the unknown no-parameter signature. It now holds the three layouts (EvpMd, EvpMdContext, HmacContext) and the real signatures, and Evp.cpp and the test include it instead of local declarations, as was done for the ERR and OCSP functions.
  • Behaviour.
    • The context flags ONESHOT, CLEANED, REUSE and NO_INIT work as in digest.c. Digest data is reused when a context is initialised again with the same digest, freed and replaced when the digest changes, zeroed after EVP_DigestFinal_ex, and zeroed and freed by EVP_MD_CTX_cleanup, which then clears the context.
    • When allocating the digest data fails, EVP_DigestInit_ex returns 0 and leaves the context without a digest, update function or data, so calling it again allocates again. LibreSSL keeps the digest with null data there, and a retry with the same digest runs its init on a null pointer. The context copy inside HMAC_Init_ex and HMAC_Final does the same when its allocation fails.
    • HMAC_Init_ex hashes keys longer than the block size and stores a key of exactly the block size unhashed, as hmac.c does (block < len). It re-initialises with the stored key when called without key or digest, and returns 0 when the digest changes without a key, for a negative key length and when no digest was ever set. HMAC_Update and HMAC_Final return 0 without a digest. HMAC_Init clears the context first when both key and digest are given. HMAC with a null output buffer returns a static buffer. HMAC_CTX_cleanup zeroes all 288 bytes.
    • All digest work goes through the EVP_MD function table, so an EVP_MD the title defines itself also works.
  • The EVP_MD tables carry LibreSSL's NIDs, public key types, flags (0 for MD5, EVP_MD_FLAG_PKEY_METHOD_SIGNATURE | EVP_MD_FLAG_DIGALGID_ABSENT = 0xc for SHA-256, SHA-384 and SHA-512), block sizes and context sizes from m_md5.c and m_sha1.c. sign and verify (RSA_sign, RSA_verify in LibreSSL) are null because RSA_sign and RSA_verify still throw.
  • Digest data and EVP_MD_CTX_create contexts come from the guest heap (malloc, calloc and free of libc), as LibreSSL uses the module's own libc.
  • Paths that need unimplemented parts throw through NotImplemented_nid_no_patch: an ENGINE argument, and a context that holds an ENGINE or an EVP_PKEY_CTX. Null contexts, EVP_DigestInit_ex without a type on a context that already has a digest, and an update or final on a context without a digest throw std::invalid_argument; LibreSSL does not check these and would crash.
  • Failures return 0 as in LibreSSL but add nothing to the error queue. main now has the queue and LibreSslPutError_nid_no_patch, but no libSceLibreSsl export publishes to it yet; publishing LibreSSL's codes here (for example ERR_R_MALLOC_FAILURE from EVP_DigestInit_ex) is left for a follow-up and recorded in the debt entry.
  • The debt file gets an entry for these functions (including the allocation-failure difference), and the pending-export count goes from 292 to 272, matching the 272 stubs left in Export.cpp.

Tested

Which head each run covers: everything under Linux is on the current head 4a465be92 (on main 0836dfdf4, 2026-10-31). The Windows run is on the earlier head b2583e3cf1 and has not been repeated since.

Linux (Ubuntu 24.04 container, GCC 13.3, Release, BUILD_TESTING=ON; on 4a465be92; earlier rounds on f6b83d96e, 81733adac, 2b3f66e92, ca3740481, 5994190d7, b2583e3cf, 42d887da8, b55c473a9, 092935662, 6f2687c6a, db69a66cd and 334de4dec):

  • New guest_libressl_evp: passed. For MD5, SHA-256, SHA-384 and SHA-512 it checks:

    • the EVP_MD fields (NID, public key type, size, flags, block and context size, required key types, function pointers), with flags 0 for MD5 and 0xc for SHA-256, SHA-384 and SHA-512;
    • EVP_DigestInit_ex/Update/Final_ex and EVP_Digest on the empty string, abc and a 1000-byte message, fed in chunks of 1, block - 1, block, block + 1 and 1000 bytes;
    • the RFC 4231 test cases 1 to 4, 6 and 7 for HMAC (also with MD5), including the 131-byte keys that get hashed, over the same chunk sizes;
    • HMAC with keys of exactly the block size: a 64-byte key with SHA-256 and a 128-byte key with SHA-512 over the 1000-byte message in chunks of 1, the key size and 1000 bytes, checking the MAC, that key_length equals the block size and that the key is stored unhashed, plus the one-shot HMAC;
    • the HMAC_CTX fields (md, key_length, the key and its zero padding), re-initialisation without key and digest, HMAC_Init, and the one-shot HMAC with and without an output buffer;
    • the context after Final and cleanup, the reuse of digest data, the NO_INIT flag, a title-defined EVP_MD, a digest size over 64 returning 0, the HMAC refusals listed above and the invalid-argument throws (null contexts, an update or final without a digest, EVP_DigestInit_ex without a type on a context that has one). The ENGINE and EVP_PKEY_CTX paths are not asserted, as they throw only because that support is missing;
    • allocation failures, through a test allocator registered with ApplicationHeapRegister_nid_no_patch that fails a chosen allocation and counts live blocks: EVP_DigestInit_ex on a new context and when switching digest, EVP_MD_CTX_create, EVP_Digest, HMAC_Init_ex failing at each of its three allocations with a 4-byte and a 131-byte key, and HMAC. Each returns 0 or null, frees what it allocated and leaves no context with a digest but no data (an update or final on a context left without a digest throws), and the same call again gives the right digest or MAC. No block is left allocated at the end of the test.

    Expected values were computed with Python hashlib and hmac; the SHA-2 HMAC values match RFC 4231. The block-size key MACs, the stored key length and key, and the flags of all four tables were also produced by LibreSSL 2.5.4's own hmac.c, digest.c, m_sha1.c, m_md5.c, sha256.c, sha512.c and md5_dgst.c (commit 2e2c61206, built with a small host harness) and match. With the inner pad changed to 0x37, the key padding left out, the NO_INIT early return removed or the context clearing in HMAC_Init removed, the test fails. It also fails when a key of exactly the block size is hashed (block <= len), when EVP_MD_FLAG_DIGALGID_ABSENT is dropped from SHA-256 or set on MD5, and with the previous EVP_DigestInit_ex order (digest set before the allocation) or the previous context copy (digest kept when its allocation fails).

  • All other libSceLibreSsl and libSceLibreSsl3 tests on main passed: guest_libressl_digest, guest_libressl_des, guest_libressl_x509_errors, guest_libressl_runtime, guest_libressl_aes, guest_libressl_asn1, guest_libressl_asn1_allocator, guest_libressl_ex_data, guest_libressl_error, guest_libressl_ocsp, guest_libressl_stack, guest_libressl_ui, guest_libressl_rsa, guest_libressl_x509_store, guest_libressl_x509_store_allocator, guest_libressl_x509_store_context, guest_libressl_x509_lookup, guest_libressl_x509_lookup_allocator, guest_libressl_x509_verify_param, guest_libressl_x509_verify_param_allocator, guest_libressl_pkey_type, guest_libressl_cipher, guest_libressl_alert, guest_libressl_version, guest_libressl_crypto_locks, guest_libressl_object_text, guest_libressl_object_allocation, guest_libressl_protocol, guest_libressl_protocol_nid, guest_libressl3_digest, guest_libressl3_digest_context, guest_libressl3_asn1, guest_libressl3_cipher, guest_libressl3_key_reference, guest_libressl3_stack, guest_libressl3_x509_verify_param and guest_crypto_memcmp (39/39 together with guest_libressl_evp and patched_libraries). Their sources include the changed include/Api.hpp. The opt-in guest_libressl_oracle (ANYPS5_LIBRESSL_ORACLE) was not enabled; it compares the AES, digest, DES parity and error-string exports, not these functions.

  • patched_libraries: passed. libSceLibreSsl.prx exports the same 394 _nid_postfix names as on main.

  • python3 tools/check_conventions.py --base upstream/main: passed.

  • The mutants above (block <= len, the SHA-256 flags, the EVP_DigestInit_ex order and the HMAC_Init_ex context copy) were rerun on 4a465be92 and each makes guest_libressl_evp fail.

  • MinGW-w64 13.2 (x86_64-w64-mingw32-g++-posix -std=gnu++20 -fsyntax-only with the UCRT defines) compiles every libSceLibreSsl and libSceLibreSsl3 source and LibreSSL test except the opt-in oracle test on 4a465be92 without errors.

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r7, the toolchain of the CI Windows job), CMake 4.3.1, Ninja 1.13.2, Release, BUILD_TESTING=ON, configured as in CI (cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, submodules with git submodule update --init --recursive --depth 1):

  • On b2583e3cf (2026-10-25): libSceLibreSsl, libSceLibreSsl3, the LibreSSL test executables, guest_crypto_memcmp_tests and patched_libraries_tests built with no warning in any libSceLibreSsl file; Evp.cpp, Export.cpp and GuestLibreSslEvp.cpp also compile without warnings with -Wall -Wextra. tools/check_test_registration.py passed. The same 14 tests as on Linux passed. The unpatched libSceLibreSsl.prx exports the same 394 _nid_postfix names as the Linux build, including the 20, and guest_libressl_evp_tests.exe imports exactly these 20 from it. With a key of exactly the block size hashed (block <= len), guest_libressl_evp fails on Windows as well.

  • Earlier rounds: guest_libressl_evp and the digest tests passed on f6b83d96e and 81733adac.

  • Not rerun on Windows since b2583e3cf1. Since then the rebases (onto c7b4878fa, 750cf6cf4, 04fefebe9, 3679074dd, 409fe6419, d4de5943f and 0836dfdf4) only changed the conflicting lines next to main's new code in CMakeLists.txt, include/Api.hpp, Export.cpp (stubs next to main's OBJ_cleanup and OBJ_create changes) and the debt file, plus the debt entry's wording about RSA_sign and RSA_verify; the third review only prepended the licence comment to Evp.cpp and removed five assertions from GuestLibreSslEvp.cpp; the code in both is otherwise the same as on b2583e3cf1. The MinGW-w64 syntax check above is the only Windows-toolchain check on 4a465be92.

  • Not tested: any title or homebrew (no title using libSceLibreSsl is known).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: #10960 (its mixed EVP test is built only once src/Evp.cpp exists and uses EvpMd and EvpMdContext)
  • GPUs tested: n/a
  • AI-assisted: yes

Duplicate and overlap check

  • Checked against upstream main 0836dfdf4 and all 1694 open pull requests (heads fetched on 2026-10-31, 20:31 UTC). No other open PR adds, changes or removes any of the 20 functions: the diffs of all open PRs were searched for the EVP_md5/sha256/sha384/sha512, EVP_MD_size, EVP_MD_CTX_*, EVP_Digest* and HMAC* names and for EvpMd, EvpMdContext, HmacContext and HmacMaxBlock. On main, the digest, DES, X509 error string, RAND/CRYPTO, AES, error queue, OCSP string, cipher, ASN.1, CRYPTO locking, version, TLS alert, stack, UI_METHOD, RSA, X509_STORE_CTX, EVP_PKEY_type, ex_data, object text, protocol selection, X509_STORE, X509_LOOKUP, X509_VERIFY_PARAM, B250-2 and OBJ_create work, the LibreSSL oracle test and the libSceLibreSsl3 forwarding, stack, cipher, digest-context and X509_VERIFY_PARAM work changed libSceLibreSsl since its export stubs were added; none of it touches these functions. libSceLibreSsl3 now forwards its copies of these exports to libSceLibreSsl by name, and its tests pass on this head.
  • #10395 (EC groups and keys, head 9074d90b9) implements different functions but conflicts with this branch in the add_library source list and test block of CMakeLists.txt, the declarations after LibreSslX509StoreContext in include/Api.hpp and the debt count and neighbouring entries. Agreed order with its author: this PR lands first, #10395 records Depends on: #9448 and rebases after it. Both heads merged locally with both sides kept (Evp.cpp then Ec.cpp, both test blocks, both declaration blocks, count 263 = the stubs left) pass all 40 LibreSSL tests incl. guest_libressl_evp and guest_libressl_ec and check_conventions.py on Linux.
  • #10960 (libSceLibreSsl3 EVP digest contexts) uses EvpMd and EvpMdContext from this PR and builds its mixed libSceLibreSsl/libSceLibreSsl3 test only when src/Evp.cpp exists. Its current head conflicts with main on its own; on its merge with b55c473a9 (an earlier head with the same code) guest_libressl3_evp, guest_libressl3_mixed_evp and the other libSceLibreSsl3 tests passed.
  • #11175 carries an older head of this PR (b2583e3cf) through a merge of #11151; #11151's current head no longer contains it.
  • This branch merges cleanly with main. 66 other open PRs change libSceLibreSsl or libSceLibreSsl3: 15 already conflict with main (among them #9446 and #10960) and 14 merge cleanly with this branch. The other 37 (among them #10395 and #10834) merge with main but conflict with this branch, nearly all in the debt count or neighbouring entries and most also in the CMakeLists.txt registration lines or the declarations in include/Api.hpp; #10834, #11128, #11176 and #13760 also conflict in Export.cpp next to the stubs removed here. None of them implements one of the 20 (#13831 only names PKCS5_PBKDF2_HMAC in libSceLibreSsl3); as the LibreSSL PRs do with each other, whichever merges later needs a small rebase.
  • #9571 lists the EVP/HMAC work in its debt entry as needing separate error-publication integration; that is the follow-up named above.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4959183636 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9448). Originally posted by [HQasper](https://github.com/HQasper) on 2026-10-21T22:25:16Z. --- ### What All libSceLibreSsl exports outside the open PRs still throw. This implements the 20 EVP message digest and HMAC exports, which is what code built on LibreSSL normally calls instead of the raw `SHA256_*` functions: `EVP_md5`, `EVP_sha256`, `EVP_sha384`, `EVP_sha512`, `EVP_MD_size`, `EVP_MD_CTX_init`, `EVP_MD_CTX_create`, `EVP_MD_CTX_cleanup`, `EVP_MD_CTX_destroy`, `EVP_DigestInit_ex`, `EVP_DigestUpdate`, `EVP_DigestFinal_ex`, `EVP_Digest`, `HMAC_CTX_init`, `HMAC_CTX_cleanup`, `HMAC_Init`, `HMAC_Init_ex`, `HMAC_Update`, `HMAC_Final` and `HMAC`. - **Which LibreSSL.** The firmware 13.40 measurements that `main` already cites for `X509_verify_cert_error_string` identify LibreSSL 2.5.4, while the module's export table also has `SSL_get0_param` and `X509_VERIFY_PARAM_set1_host`, which the Symbols.list of 2.5.4 and 2.6.3 lack and 2.7.2's [has](https://github.com/libressl/openbsd/blob/33642eab10736c25267a123df5d66f93615e1323/src/lib/libssl/Symbols.list#L185). It also has `HMAC_CTX_init`/`HMAC_CTX_cleanup`, which 3.4.1 [has](https://github.com/libressl/openbsd/blob/078b3d1df8ca2011c1605cd40418c58fa0f5b143/src/lib/libcrypto/Symbols.list#L1830) and 3.5.2 dropped when `HMAC_CTX` became opaque. The functions follow 2.5.4's [digest.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/digest.c) and [hmac.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/hmac/hmac.c), and `src/Evp.cpp` starts with the copyright notices, licence conditions and disclaimers of both files, verbatim from that commit. Up to 3.4.1, `hmac.c` only gains new functions, `digest.c` only changes `malloc` to `calloc` for the digest data and drops a null check before `ENGINE_finish`, and the `EVP_MD`, `EVP_MD_CTX` and `HMAC_CTX` structures do not change, so the behaviour is the same for either reading. - **Layouts.** The public `EVP_MD` (120 bytes), `EVP_MD_CTX` (48) and `HMAC_CTX` (288) follow [evp.h](https://github.com/libressl/openbsd/blob/078b3d1df8ca2011c1605cd40418c58fa0f5b143/src/lib/libcrypto/evp/evp.h#L166-L270) and [hmac.h](https://github.com/libressl/openbsd/blob/078b3d1df8ca2011c1605cd40418c58fa0f5b143/src/lib/libcrypto/hmac/hmac.h#L75-L82) and are checked with `static_assert` on size and field offsets. The `unsigned long` flags are a 64-bit field, so the layout also holds on Windows. A context the title allocates, copies or reads (for example through the `HMAC_size` macro, which reads `ctx->md`) stays valid. - **Public header.** `include/Api.hpp` declared the 20 functions with the unknown no-parameter signature. It now holds the three layouts (`EvpMd`, `EvpMdContext`, `HmacContext`) and the real signatures, and `Evp.cpp` and the test include it instead of local declarations, as was done for the `ERR` and OCSP functions. - **Behaviour.** - The context flags `ONESHOT`, `CLEANED`, `REUSE` and `NO_INIT` work as in `digest.c`. Digest data is reused when a context is initialised again with the same digest, freed and replaced when the digest changes, zeroed after `EVP_DigestFinal_ex`, and zeroed and freed by `EVP_MD_CTX_cleanup`, which then clears the context. - When allocating the digest data fails, `EVP_DigestInit_ex` returns 0 and leaves the context without a digest, update function or data, so calling it again allocates again. LibreSSL keeps the digest with null data there, and a retry with the same digest runs its init on a null pointer. The context copy inside `HMAC_Init_ex` and `HMAC_Final` does the same when its allocation fails. - `HMAC_Init_ex` hashes keys longer than the block size and stores a key of exactly the block size unhashed, as `hmac.c` does (`block < len`). It re-initialises with the stored key when called without key or digest, and returns 0 when the digest changes without a key, for a negative key length and when no digest was ever set. `HMAC_Update` and `HMAC_Final` return 0 without a digest. `HMAC_Init` clears the context first when both key and digest are given. `HMAC` with a null output buffer returns a static buffer. `HMAC_CTX_cleanup` zeroes all 288 bytes. - All digest work goes through the `EVP_MD` function table, so an `EVP_MD` the title defines itself also works. - The `EVP_MD` tables carry LibreSSL's NIDs, public key types, flags (0 for MD5, `EVP_MD_FLAG_PKEY_METHOD_SIGNATURE | EVP_MD_FLAG_DIGALGID_ABSENT` = 0xc for SHA-256, SHA-384 and SHA-512), block sizes and context sizes from `m_md5.c` and `m_sha1.c`. `sign` and `verify` (`RSA_sign`, `RSA_verify` in LibreSSL) are null because `RSA_sign` and `RSA_verify` still throw. - Digest data and `EVP_MD_CTX_create` contexts come from the guest heap (`malloc`, `calloc` and `free` of libc), as LibreSSL uses the module's own libc. - Paths that need unimplemented parts throw through `NotImplemented_nid_no_patch`: an `ENGINE` argument, and a context that holds an `ENGINE` or an `EVP_PKEY_CTX`. Null contexts, `EVP_DigestInit_ex` without a type on a context that already has a digest, and an update or final on a context without a digest throw `std::invalid_argument`; LibreSSL does not check these and would crash. - Failures return 0 as in LibreSSL but add nothing to the error queue. `main` now has the queue and `LibreSslPutError_nid_no_patch`, but no libSceLibreSsl export publishes to it yet; publishing LibreSSL's codes here (for example `ERR_R_MALLOC_FAILURE` from `EVP_DigestInit_ex`) is left for a follow-up and recorded in the debt entry. - The debt file gets an entry for these functions (including the allocation-failure difference), and the pending-export count goes from 292 to 272, matching the 272 stubs left in `Export.cpp`. ### Tested Which head each run covers: everything under Linux is on the current head 4a465be92 (on `main` 0836dfdf4, 2026-10-31). The Windows run is on the earlier head b2583e3cf1 and has not been repeated since. Linux (Ubuntu 24.04 container, GCC 13.3, Release, `BUILD_TESTING=ON`; on 4a465be92; earlier rounds on f6b83d96e, 81733adac, 2b3f66e92, ca3740481, 5994190d7, b2583e3cf, 42d887da8, b55c473a9, 092935662, 6f2687c6a, db69a66cd and 334de4dec): - New `guest_libressl_evp`: passed. For MD5, SHA-256, SHA-384 and SHA-512 it checks: - the `EVP_MD` fields (NID, public key type, size, flags, block and context size, required key types, function pointers), with flags 0 for MD5 and 0xc for SHA-256, SHA-384 and SHA-512; - `EVP_DigestInit_ex`/`Update`/`Final_ex` and `EVP_Digest` on the empty string, `abc` and a 1000-byte message, fed in chunks of 1, block - 1, block, block + 1 and 1000 bytes; - the RFC 4231 test cases 1 to 4, 6 and 7 for HMAC (also with MD5), including the 131-byte keys that get hashed, over the same chunk sizes; - HMAC with keys of exactly the block size: a 64-byte key with SHA-256 and a 128-byte key with SHA-512 over the 1000-byte message in chunks of 1, the key size and 1000 bytes, checking the MAC, that `key_length` equals the block size and that the key is stored unhashed, plus the one-shot `HMAC`; - the `HMAC_CTX` fields (`md`, `key_length`, the key and its zero padding), re-initialisation without key and digest, `HMAC_Init`, and the one-shot `HMAC` with and without an output buffer; - the context after `Final` and `cleanup`, the reuse of digest data, the `NO_INIT` flag, a title-defined `EVP_MD`, a digest size over 64 returning 0, the HMAC refusals listed above and the invalid-argument throws (null contexts, an update or final without a digest, `EVP_DigestInit_ex` without a type on a context that has one). The `ENGINE` and `EVP_PKEY_CTX` paths are not asserted, as they throw only because that support is missing; - allocation failures, through a test allocator registered with `ApplicationHeapRegister_nid_no_patch` that fails a chosen allocation and counts live blocks: `EVP_DigestInit_ex` on a new context and when switching digest, `EVP_MD_CTX_create`, `EVP_Digest`, `HMAC_Init_ex` failing at each of its three allocations with a 4-byte and a 131-byte key, and `HMAC`. Each returns 0 or null, frees what it allocated and leaves no context with a digest but no data (an update or final on a context left without a digest throws), and the same call again gives the right digest or MAC. No block is left allocated at the end of the test. Expected values were computed with Python `hashlib` and `hmac`; the SHA-2 HMAC values match RFC 4231. The block-size key MACs, the stored key length and key, and the flags of all four tables were also produced by LibreSSL 2.5.4's own `hmac.c`, `digest.c`, `m_sha1.c`, `m_md5.c`, `sha256.c`, `sha512.c` and `md5_dgst.c` (commit 2e2c61206, built with a small host harness) and match. With the inner pad changed to 0x37, the key padding left out, the `NO_INIT` early return removed or the context clearing in `HMAC_Init` removed, the test fails. It also fails when a key of exactly the block size is hashed (`block <= len`), when `EVP_MD_FLAG_DIGALGID_ABSENT` is dropped from SHA-256 or set on MD5, and with the previous `EVP_DigestInit_ex` order (digest set before the allocation) or the previous context copy (digest kept when its allocation fails). - All other libSceLibreSsl and libSceLibreSsl3 tests on `main` passed: `guest_libressl_digest`, `guest_libressl_des`, `guest_libressl_x509_errors`, `guest_libressl_runtime`, `guest_libressl_aes`, `guest_libressl_asn1`, `guest_libressl_asn1_allocator`, `guest_libressl_ex_data`, `guest_libressl_error`, `guest_libressl_ocsp`, `guest_libressl_stack`, `guest_libressl_ui`, `guest_libressl_rsa`, `guest_libressl_x509_store`, `guest_libressl_x509_store_allocator`, `guest_libressl_x509_store_context`, `guest_libressl_x509_lookup`, `guest_libressl_x509_lookup_allocator`, `guest_libressl_x509_verify_param`, `guest_libressl_x509_verify_param_allocator`, `guest_libressl_pkey_type`, `guest_libressl_cipher`, `guest_libressl_alert`, `guest_libressl_version`, `guest_libressl_crypto_locks`, `guest_libressl_object_text`, `guest_libressl_object_allocation`, `guest_libressl_protocol`, `guest_libressl_protocol_nid`, `guest_libressl3_digest`, `guest_libressl3_digest_context`, `guest_libressl3_asn1`, `guest_libressl3_cipher`, `guest_libressl3_key_reference`, `guest_libressl3_stack`, `guest_libressl3_x509_verify_param` and `guest_crypto_memcmp` (39/39 together with `guest_libressl_evp` and `patched_libraries`). Their sources include the changed `include/Api.hpp`. The opt-in `guest_libressl_oracle` (`ANYPS5_LIBRESSL_ORACLE`) was not enabled; it compares the AES, digest, DES parity and error-string exports, not these functions. - `patched_libraries`: passed. `libSceLibreSsl.prx` exports the same 394 `_nid_postfix` names as on `main`. - `python3 tools/check_conventions.py --base upstream/main`: passed. - The mutants above (`block <= len`, the SHA-256 flags, the `EVP_DigestInit_ex` order and the `HMAC_Init_ex` context copy) were rerun on 4a465be92 and each makes `guest_libressl_evp` fail. - MinGW-w64 13.2 (`x86_64-w64-mingw32-g++-posix -std=gnu++20 -fsyntax-only` with the UCRT defines) compiles every libSceLibreSsl and libSceLibreSsl3 source and LibreSSL test except the opt-in oracle test on 4a465be92 without errors. Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (`x86_64-ucrt-posix-seh`, r7, the toolchain of the CI Windows job), CMake 4.3.1, Ninja 1.13.2, Release, `BUILD_TESTING=ON`, configured as in CI (`cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++`, submodules with `git submodule update --init --recursive --depth 1`): - On b2583e3cf (2026-10-25): `libSceLibreSsl`, `libSceLibreSsl3`, the LibreSSL test executables, `guest_crypto_memcmp_tests` and `patched_libraries_tests` built with no warning in any libSceLibreSsl file; `Evp.cpp`, `Export.cpp` and `GuestLibreSslEvp.cpp` also compile without warnings with `-Wall -Wextra`. `tools/check_test_registration.py` passed. The same 14 tests as on Linux passed. The unpatched `libSceLibreSsl.prx` exports the same 394 `_nid_postfix` names as the Linux build, including the 20, and `guest_libressl_evp_tests.exe` imports exactly these 20 from it. With a key of exactly the block size hashed (`block <= len`), `guest_libressl_evp` fails on Windows as well. - Earlier rounds: `guest_libressl_evp` and the digest tests passed on f6b83d96e and 81733adac. - Not rerun on Windows since b2583e3cf1. Since then the rebases (onto c7b4878fa, 750cf6cf4, 04fefebe9, 3679074dd, 409fe6419, d4de5943f and 0836dfdf4) only changed the conflicting lines next to `main`'s new code in `CMakeLists.txt`, `include/Api.hpp`, `Export.cpp` (stubs next to `main`'s `OBJ_cleanup` and `OBJ_create` changes) and the debt file, plus the debt entry's wording about `RSA_sign` and `RSA_verify`; the third review only prepended the licence comment to `Evp.cpp` and removed five assertions from `GuestLibreSslEvp.cpp`; the code in both is otherwise the same as on b2583e3cf1. The MinGW-w64 syntax check above is the only Windows-toolchain check on 4a465be92. - Not tested: any title or homebrew (no title using libSceLibreSsl is known). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: #10960 (its mixed EVP test is built only once `src/Evp.cpp` exists and uses `EvpMd` and `EvpMdContext`) - [x] GPUs tested: n/a - [x] AI-assisted: yes ### Duplicate and overlap check - Checked against upstream `main` 0836dfdf4 and all 1694 open pull requests (heads fetched on 2026-10-31, 20:31 UTC). No other open PR adds, changes or removes any of the 20 functions: the diffs of all open PRs were searched for the `EVP_md5`/`sha256`/`sha384`/`sha512`, `EVP_MD_size`, `EVP_MD_CTX_*`, `EVP_Digest*` and `HMAC*` names and for `EvpMd`, `EvpMdContext`, `HmacContext` and `HmacMaxBlock`. On `main`, the digest, DES, X509 error string, RAND/CRYPTO, AES, error queue, OCSP string, cipher, ASN.1, CRYPTO locking, version, TLS alert, stack, UI_METHOD, RSA, X509_STORE_CTX, EVP_PKEY_type, ex_data, object text, protocol selection, X509_STORE, X509_LOOKUP, X509_VERIFY_PARAM, B250-2 and OBJ_create work, the LibreSSL oracle test and the libSceLibreSsl3 forwarding, stack, cipher, digest-context and X509_VERIFY_PARAM work changed libSceLibreSsl since its export stubs were added; none of it touches these functions. libSceLibreSsl3 now forwards its copies of these exports to libSceLibreSsl by name, and its tests pass on this head. - #10395 (EC groups and keys, head 9074d90b9) implements different functions but conflicts with this branch in the `add_library` source list and test block of `CMakeLists.txt`, the declarations after `LibreSslX509StoreContext` in `include/Api.hpp` and the debt count and neighbouring entries. Agreed order with its author: this PR lands first, #10395 records Depends on: #9448 and rebases after it. Both heads merged locally with both sides kept (`Evp.cpp` then `Ec.cpp`, both test blocks, both declaration blocks, count 263 = the stubs left) pass all 40 LibreSSL tests incl. `guest_libressl_evp` and `guest_libressl_ec` and `check_conventions.py` on Linux. - #10960 (libSceLibreSsl3 EVP digest contexts) uses `EvpMd` and `EvpMdContext` from this PR and builds its mixed libSceLibreSsl/libSceLibreSsl3 test only when `src/Evp.cpp` exists. Its current head conflicts with `main` on its own; on its merge with b55c473a9 (an earlier head with the same code) `guest_libressl3_evp`, `guest_libressl3_mixed_evp` and the other libSceLibreSsl3 tests passed. - #11175 carries an older head of this PR (b2583e3cf) through a merge of #11151; #11151's current head no longer contains it. - This branch merges cleanly with `main`. 66 other open PRs change libSceLibreSsl or libSceLibreSsl3: 15 already conflict with `main` (among them #9446 and #10960) and 14 merge cleanly with this branch. The other 37 (among them #10395 and #10834) merge with `main` but conflict with this branch, nearly all in the debt count or neighbouring entries and most also in the `CMakeLists.txt` registration lines or the declarations in `include/Api.hpp`; #10834, #11128, #11176 and #13760 also conflict in `Export.cpp` next to the stubs removed here. None of them implements one of the 20 (#13831 only names `PKCS5_PBKDF2_HMAC` in libSceLibreSsl3); as the LibreSSL PRs do with each other, whichever merges later needs a small rebase. - #9571 lists the EVP/HMAC work in its debt entry as needing separate error-publication integration; that is the follow-up named above.
MarcZX10 commented 2026-10-22 04:36:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:36:48Z.

Review: CHANGES_REQUESTED


The test coverage is unusually thorough: digest/HMAC vectors include chunk boundaries and RFC 4231 cases, context layouts and reuse are checked, and Linux plus MinGW runs are reported. I found one failure-path defect in DigestInit: when malloc_nid_postfix returns null, it returns 0 after assigning context.digest = type, but leaves context.mdData null. A retry with the same digest skips allocation because context.digest == type and then calls type->init(&context) with null mdData; this can crash. Please leave the context retryable (or otherwise fail explicitly without publishing a partially initialized digest) and add coverage for allocator failure/retry if the test harness allows it.

The branch is also based on a6dcea927, 47 commits behind current main (110a18ba01); the described checks and overlap scan used the earlier base/open-PR snapshot. Please update/rebase and rerun conventions, overlap/debt and focused digest/HMAC tests on current main, preserving the declared #9025 dependency and the CMake/debt merge coordination with #9033/#9041/#9047. Hosted full Linux/Windows product jobs are skipped; the author-reported local Linux and Windows tests are useful but not hosted validation. I did not run local crypto tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609316249 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9448#pullrequestreview-5609316249). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:36:48Z. **Review:** CHANGES_REQUESTED --- The test coverage is unusually thorough: digest/HMAC vectors include chunk boundaries and RFC 4231 cases, context layouts and reuse are checked, and Linux plus MinGW runs are reported. I found one failure-path defect in `DigestInit`: when `malloc_nid_postfix` returns null, it returns 0 after assigning `context.digest = type`, but leaves `context.mdData` null. A retry with the same digest skips allocation because `context.digest == type` and then calls `type->init(&context)` with null `mdData`; this can crash. Please leave the context retryable (or otherwise fail explicitly without publishing a partially initialized digest) and add coverage for allocator failure/retry if the test harness allows it. The branch is also based on `a6dcea927`, 47 commits behind current main (`110a18ba01`); the described checks and overlap scan used the earlier base/open-PR snapshot. Please update/rebase and rerun conventions, overlap/debt and focused digest/HMAC tests on current main, preserving the declared #9025 dependency and the CMake/debt merge coordination with #9033/#9041/#9047. Hosted full Linux/Windows product jobs are skipped; the author-reported local Linux and Windows tests are useful but not hosted validation. I did not run local crypto tests.
HQasper commented 2026-10-22 11:27:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-22T11:27:07Z.


@MarcZX10 Thanks, fixed in f6b83d96e.

  • EVP_DigestInit_ex now allocates the digest data before it stores the digest. When the allocation fails it returns 0 and leaves digest, update and md_data null, so a retry with the same digest allocates again instead of running init on a null pointer. The context copy used by HMAC_Init_ex and HMAC_Final clears digest and update the same way when its allocation fails. The debt entry records this as a difference from LibreSSL, which keeps the digest.
  • guest_libressl_evp now registers a test allocator that fails a chosen allocation and counts live blocks. It covers failure and retry for EVP_DigestInit_ex (new context and digest switch), EVP_MD_CTX_create, EVP_Digest, HMAC_Init_ex failing at each of its three allocations (4-byte key and 131-byte key) and HMAC, and checks that nothing is left allocated. With either old path restored, the test fails.
  • Rebased onto main 4777caca3 (includes 110a18ba01), still stacked on #9025 at 52a439bc7. Conventions, guest_libressl_evp, guest_libressl_digest and patched_libraries pass on Linux. I rescanned all 1237 open PRs: no other PR touches these 20 functions. The conflicts with #9033, #9041, #9047, #9446 and #9529 are still only the add_library/test block in the CMakeLists and the debt count line, the same places as #9025's; #9571 conflicts only in the debt file and #9535/#9536 not at all. The description is updated. Windows has not been re-run on the new head yet.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339604076 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9448#issuecomment-6339604076). Originally posted by [HQasper](https://github.com/HQasper) on 2026-10-22T11:27:07Z. --- @MarcZX10 Thanks, fixed in f6b83d96e. - `EVP_DigestInit_ex` now allocates the digest data before it stores the digest. When the allocation fails it returns 0 and leaves `digest`, `update` and `md_data` null, so a retry with the same digest allocates again instead of running `init` on a null pointer. The context copy used by `HMAC_Init_ex` and `HMAC_Final` clears `digest` and `update` the same way when its allocation fails. The debt entry records this as a difference from LibreSSL, which keeps the digest. - `guest_libressl_evp` now registers a test allocator that fails a chosen allocation and counts live blocks. It covers failure and retry for `EVP_DigestInit_ex` (new context and digest switch), `EVP_MD_CTX_create`, `EVP_Digest`, `HMAC_Init_ex` failing at each of its three allocations (4-byte key and 131-byte key) and `HMAC`, and checks that nothing is left allocated. With either old path restored, the test fails. - Rebased onto `main` 4777caca3 (includes 110a18ba01), still stacked on #9025 at 52a439bc7. Conventions, `guest_libressl_evp`, `guest_libressl_digest` and `patched_libraries` pass on Linux. I rescanned all 1237 open PRs: no other PR touches these 20 functions. The conflicts with #9033, #9041, #9047, #9446 and #9529 are still only the `add_library`/test block in the CMakeLists and the debt count line, the same places as #9025's; #9571 conflicts only in the debt file and #9535/#9536 not at all. The description is updated. Windows has not been re-run on the new head yet.
HQasper commented 2026-10-22 12:59:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-22T12:59:12Z.


Rebased onto main 4777caca3 (includes 110a18ba01), still stacked on #9025 at 52a439bc7. The conventions check passes, and guest_libressl_evp, guest_libressl_digest and patched_libraries pass on Linux and on Windows (MinGW-w64 GCC 15.2.0). I rescanned all 1237 open PRs: no other PR touches these 20 functions. The conflicts with #9033, #9041, #9047, #9446 and #9529 are still only the add_library/test block in the CMakeLists and the debt count line, the same places as #9025's; #9571 conflicts only in the debt file and #9535/#9536 not at all. The description is updated.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341349352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9448#issuecomment-6341349352). Originally posted by [HQasper](https://github.com/HQasper) on 2026-10-22T12:59:12Z. --- Rebased onto main 4777caca3 (includes 110a18ba01), still stacked on #9025 at 52a439bc7. The conventions check passes, and guest_libressl_evp, guest_libressl_digest and patched_libraries pass on Linux and on Windows (MinGW-w64 GCC 15.2.0). I rescanned all 1237 open PRs: no other PR touches these 20 functions. The conflicts with #9033, #9041, #9047, #9446 and #9529 are still only the add_library/test block in the CMakeLists and the debt count line, the same places as #9025's; #9571 conflicts only in the debt file and #9535/#9536 not at all. The description is updated.
ahmadmuj commented 2026-10-25 18:13:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:13:05Z.

Review: APPROVED


Checked head 5994190d7094 merged locally onto main 7a25f87620 (PR base 2fade7ef4e). The rebase only conflicts in the CMakeLists add_library/test block and the debt file; I kept both sides and set the pending count to 325, which matches the stubs left in Export.cpp.

What I ran (Linux, GCC 13.3, Release):

  • guest_libressl_evp, guest_libressl_digest, guest_libressl_error and guest_libressl_cipher on the merged tree: pass. The new test on main's stubs aborts at EVP_md5_nid_postfix not implemented.
  • check_conventions.py --base origin/main on the merged tree: pass.
  • Built the official LibreSSL 2.5.4 tarball (SHA256 checked) and compiled a probe against its headers: EVP_MD 120, EVP_MD_CTX 48, HMAC_CTX 288, and every field offset matches your static_asserts. At runtime the md5/sha256/sha384/sha512 tables match 2.5.4's (NIDs, flags 0 and 0xc, required key types, block and ctx sizes). Only sign/verify differ (null vs RSA_sign/RSA_verify), which the debt entry already says.
  • Differential against 2.5.4's libcrypto, about 38k checks: random messages and chunk splits, context reuse and digest switches, HMAC keys of 0, block-1, block, block+1 and over-block bytes, NULL keys, negative lengths, md change without a key, re-init with NULL key and md, and legacy HMAC_Init. Digests, MACs, return values and context state (flags, key_length, all 128 key bytes) all match. A deliberate wrong-digest run of the harness fails every case, so the comparison works.
  • Read 2.5.4 digest.c and hmac.c next to Evp.cpp. The alloc-failure retry from the earlier review is fixed, and the other differences are throws on paths where 2.5.4 would crash, or are in the debt entry.

Looks good to me. Two small test suggestions, since the differential covers these but guest_libressl_evp doesn't:

  • No HMAC key is exactly the block size (the keys are 4, 20, 25 and 131 bytes). I changed block < length to block <= length in HmacInit and the test still passes. A 64-byte key with SHA-256 or a 128-byte key with SHA-512 would catch it.
  • The EVP_MD flags at offset 16 aren't asserted, so an EVP_sha256 table with flags 0 passes. Checking 0 for MD5 and 0xc for the SHA-2 tables would pin it.

Not checked: anything on a console or with a title. I called the host exports directly, not through the loader.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644582693 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9448#pullrequestreview-5644582693). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T18:13:05Z. **Review:** APPROVED --- Checked head 5994190d7094 merged locally onto main 7a25f87620a9 (PR base 2fade7ef4e57). The rebase only conflicts in the CMakeLists add_library/test block and the debt file; I kept both sides and set the pending count to 325, which matches the stubs left in Export.cpp. What I ran (Linux, GCC 13.3, Release): - `guest_libressl_evp`, `guest_libressl_digest`, `guest_libressl_error` and `guest_libressl_cipher` on the merged tree: pass. The new test on main's stubs aborts at `EVP_md5_nid_postfix not implemented`. - `check_conventions.py --base origin/main` on the merged tree: pass. - Built the official LibreSSL 2.5.4 tarball (SHA256 checked) and compiled a probe against its headers: `EVP_MD` 120, `EVP_MD_CTX` 48, `HMAC_CTX` 288, and every field offset matches your static_asserts. At runtime the md5/sha256/sha384/sha512 tables match 2.5.4's (NIDs, flags 0 and 0xc, required key types, block and ctx sizes). Only `sign`/`verify` differ (null vs `RSA_sign`/`RSA_verify`), which the debt entry already says. - Differential against 2.5.4's libcrypto, about 38k checks: random messages and chunk splits, context reuse and digest switches, HMAC keys of 0, block-1, block, block+1 and over-block bytes, NULL keys, negative lengths, md change without a key, re-init with NULL key and md, and legacy `HMAC_Init`. Digests, MACs, return values and context state (flags, `key_length`, all 128 key bytes) all match. A deliberate wrong-digest run of the harness fails every case, so the comparison works. - Read 2.5.4 `digest.c` and `hmac.c` next to Evp.cpp. The alloc-failure retry from the earlier review is fixed, and the other differences are throws on paths where 2.5.4 would crash, or are in the debt entry. Looks good to me. Two small test suggestions, since the differential covers these but `guest_libressl_evp` doesn't: - No HMAC key is exactly the block size (the keys are 4, 20, 25 and 131 bytes). I changed `block < length` to `block <= length` in `HmacInit` and the test still passes. A 64-byte key with SHA-256 or a 128-byte key with SHA-512 would catch it. - The `EVP_MD` flags at offset 16 aren't asserted, so an `EVP_sha256` table with flags 0 passes. Checking 0 for MD5 and 0xc for the SHA-2 tables would pin it. Not checked: anything on a console or with a title. I called the host exports directly, not through the loader.
ahmadmuj commented 2026-10-26 06:01:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-26T06:01:46Z.

Review: APPROVED


Re-checked head b2583e3cf1 (base ae7d59258e) since my approval on 5994190d70. Merged locally onto main 14c99b52ac: no conflicts.

What I ran (Linux, GCC 13.3, Release):

  • guest_libressl_evp, guest_libressl_digest, guest_libressl_error and guest_libressl_cipher on the merged tree: pass. public_headers* (65 tests): pass. check_conventions.py --base origin/main: pass.
  • The two new tests catch what they're meant to. Changing block < length to block <= length in the HMAC key setup (Evp.cpp:224) now fails at the block-size key MAC (test line 367). Setting SHA-256's flags to 0 (Evp.cpp:80) fails at the flags check (line 211). Both pass again after reverting.
  • The new expected MACs (64-byte key with SHA-256, 128-byte key with SHA-512) match Python hmac and LibreSSL 2.5.4's HMAC(). Flags 0 for MD5 and 0xc for SHA-2 match 2.5.4 m_md5.c and m_sha1.c.
  • Reran the differential against 2.5.4's libcrypto on this head: about 38k checks, output identical to the run on 5994190, 0 behaviour mismatches (only the known null sign/verify). A field probe of the Api.hpp structs against 2.5.4 evp.h/hmac.h: all 27 offsets and sizes match (120, 48, 288).

The 411c71d refactor: the struct block moves to Api.hpp unchanged and the static_asserts stay in Evp.cpp. The function bodies only gain static_casts. The 20 declarations match the 2.5.4 prototypes, and none of the 20 is left as a stub in Export.cpp. The debt count goes from 342 to 322, which matches.

MarcZX10's two points from 10-22 (the DigestInit retry after a failed alloc, and the rebase) both look fixed on this head.

Not checked: anything on a console or with a title. I called the host exports directly, not through the loader.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5647968143 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9448#pullrequestreview-5647968143). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-26T06:01:46Z. **Review:** APPROVED --- Re-checked head b2583e3cf11c (base ae7d59258ea7) since my approval on 5994190d70. Merged locally onto main 14c99b52ace3: no conflicts. What I ran (Linux, GCC 13.3, Release): - `guest_libressl_evp`, `guest_libressl_digest`, `guest_libressl_error` and `guest_libressl_cipher` on the merged tree: pass. `public_headers*` (65 tests): pass. `check_conventions.py --base origin/main`: pass. - The two new tests catch what they're meant to. Changing `block < length` to `block <= length` in the HMAC key setup (Evp.cpp:224) now fails at the block-size key MAC (test line 367). Setting SHA-256's flags to 0 (Evp.cpp:80) fails at the flags check (line 211). Both pass again after reverting. - The new expected MACs (64-byte key with SHA-256, 128-byte key with SHA-512) match Python `hmac` and LibreSSL 2.5.4's `HMAC()`. Flags 0 for MD5 and 0xc for SHA-2 match 2.5.4 `m_md5.c` and `m_sha1.c`. - Reran the differential against 2.5.4's libcrypto on this head: about 38k checks, output identical to the run on 5994190, 0 behaviour mismatches (only the known null `sign`/`verify`). A field probe of the `Api.hpp` structs against 2.5.4 `evp.h`/`hmac.h`: all 27 offsets and sizes match (120, 48, 288). The `411c71d` refactor: the struct block moves to `Api.hpp` unchanged and the static_asserts stay in Evp.cpp. The function bodies only gain `static_cast`s. The 20 declarations match the 2.5.4 prototypes, and none of the 20 is left as a stub in Export.cpp. The debt count goes from 342 to 322, which matches. MarcZX10's two points from 10-22 (the DigestInit retry after a failed alloc, and the rebase) both look fixed on this head. Not checked: anything on a console or with a title. I called the host exports directly, not through the loader.
MarcZX10 commented 2026-10-29 23:03:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T23:03:56Z.

Review: APPROVED


Re-checked — new head, looks good

The allocation-failure retry defect is fixed on head 6f2687c6a22fe382e5a1df3636cbe9d032450d6b, and the current LibreSSL PR order is now recorded with #9448 first and #10395 depending on it.

What I ran

Reviewed head 6f2687c6a22fe382e5a1df3636cbe9d032450d6b against PR base 7a225bb303c1a452057000f32b70b56486625fd6; the merge preview against current main dc38224141e0b6096007b876b4c42fc9144d11b8 is clean. I inspected the six changed files and the updated dependency declaration on #10395. Local checks ran in the Linux workspace; no compiler or build was invoked.

git diff --check refs/remotes/upstream/main...refs/review/pr-9448-current
python3 tools/check_conventions.py --base refs/remotes/upstream/main --head refs/review/pr-9448-current
git merge-tree --write-tree refs/remotes/upstream/main refs/review/pr-9448-current
gh run view 40968760074 --repo boykopovar/AnyPS5 --json headSha,event,displayTitle,status,conclusion
gh pr checks 9448 --repo boykopovar/AnyPS5

Results

Check Result
Diff check Passed; no output
Repository conventions Passed
Merge preview with current main Clean; tree 1a2a3d33b7f74c53a96b87d1fbf85e091191c99e
Hosted Windows workflow Passed on exact head 6f2687c6a22fe382e5a1df3636cbe9d032450d6b
Hosted Linux and specialized jobs Skipped by workflow
Focused LibreSSL tests Author reports 35/35 on this exact head and 36/36 on a local combined merge with #10395; not independently run here
MinGW syntax check Author reports it passed on this exact head; not independently run here
Unedited local check output
All conventions checks passed.
1a2a3d33b7f74c53a96b87d1fbf85e091191c99e

Findings

Blocking

None found in the reviewed update. The retry path now clears the digest state when allocation fails, and the added test covers failure followed by successful retry. The conflict with current main is resolved, and #10395 now records Depends on: #9448.

Non-blocking

The Linux test suite and combined #10395 run are author-reported rather than independently rerun. The hosted workflow skipped Linux and the specialized jobs.

Sources

Not verified

I did not run a local LibreSSL build or tests, Windows tests, a console test, or the combined #9448/#10395 test suite. The Windows hosted job passed on the exact reviewed head; the Linux and combined-suite results above are author-reported.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5706096324 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9448#pullrequestreview-5706096324). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T23:03:56Z. **Review:** APPROVED --- # Re-checked — new head, looks good The allocation-failure retry defect is fixed on head `6f2687c6a22fe382e5a1df3636cbe9d032450d6b`, and the current LibreSSL PR order is now recorded with #9448 first and #10395 depending on it. ## What I ran Reviewed head `6f2687c6a22fe382e5a1df3636cbe9d032450d6b` against PR base `7a225bb303c1a452057000f32b70b56486625fd6`; the merge preview against current `main` `dc38224141e0b6096007b876b4c42fc9144d11b8` is clean. I inspected the six changed files and the updated dependency declaration on #10395. Local checks ran in the Linux workspace; no compiler or build was invoked. ```sh git diff --check refs/remotes/upstream/main...refs/review/pr-9448-current python3 tools/check_conventions.py --base refs/remotes/upstream/main --head refs/review/pr-9448-current git merge-tree --write-tree refs/remotes/upstream/main refs/review/pr-9448-current gh run view 40968760074 --repo boykopovar/AnyPS5 --json headSha,event,displayTitle,status,conclusion gh pr checks 9448 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Diff check | Passed; no output | | Repository conventions | Passed | | Merge preview with current `main` | Clean; tree `1a2a3d33b7f74c53a96b87d1fbf85e091191c99e` | | Hosted Windows workflow | Passed on exact head `6f2687c6a22fe382e5a1df3636cbe9d032450d6b` | | Hosted Linux and specialized jobs | Skipped by workflow | | Focused LibreSSL tests | Author reports 35/35 on this exact head and 36/36 on a local combined merge with #10395; not independently run here | | MinGW syntax check | Author reports it passed on this exact head; not independently run here | <details> <summary>Unedited local check output</summary> ```text All conventions checks passed. 1a2a3d33b7f74c53a96b87d1fbf85e091191c99e ``` </details> ## Findings ### Blocking None found in the reviewed update. The retry path now clears the digest state when allocation fails, and the added test covers failure followed by successful retry. The conflict with current `main` is resolved, and #10395 now records `Depends on: #9448`. ### Non-blocking The Linux test suite and combined #10395 run are author-reported rather than independently rerun. The hosted workflow skipped Linux and the specialized jobs. ## Sources - [Updated digest implementation at this head](https://github.com/boykopovar/AnyPS5/blob/6f2687c6a22fe382e5a1df3636cbe9d032450d6b/core/libs/prx/libSceLibreSsl/src/Evp.cpp) - [Allocation-failure retry coverage at this head](https://github.com/boykopovar/AnyPS5/blob/6f2687c6a22fe382e5a1df3636cbe9d032450d6b/core/libs/tests/GuestLibreSslEvp.cpp) - [Dependency declaration on #10395](https://github.com/boykopovar/AnyPS5/pull/10395) ## Not verified I did not run a local LibreSSL build or tests, Windows tests, a console test, or the combined #9448/#10395 test suite. The Windows hosted job passed on the exact reviewed head; the Linux and combined-suite results above are author-reported.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9448
No description provided.