feat(libSceLibreSsl3): implement PKCS5_PBKDF2_HMAC #15624

Closed
user236404 wants to merge 1 commit from upstream-pr/15624 into main
user236404 commented 2026-11-03 22:16:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by user236404 on 2026-11-03T22:16:51Z.


What

Implements PKCS5_PBKDF2_HMAC (libSceLibreSsl3, NID vnwZHU5FvBQ), which threw NotImplemented_nid_no_patch as a parameterless placeholder. It now has LibreSSL's prototype int (const char* pass, int passlen, const unsigned char* salt, int saltlen, int iter, const EVP_MD* digest, int keylen, unsigned char* out) and follows LibreSSL 4.0.0 evp/evp_pbe.c (the version the 13.40 module reports; the function is unchanged from 2.5.4), using libSceLibreSsl's HMAC and digests.

  • A null digest returns 0 and queues EVP_R_MESSAGE_DIGEST_IS_NULL (0x06fff09f), as 4.0.0's EVP_MD_size does.
  • A null password, or a negative password length other than -1, returns 0 through HMAC_Init_ex, as in LibreSSL; -1 means strlen; an iteration count below 1 acts as 1; a key length of 0 returns 1 and writes nothing.
  • Inputs the reference overruns or loops on throw std::invalid_argument: a negative key length, a null output, a negative salt length, a null salt with a positive length, a digest size of 0 or over 64.
  • docs/dev/debt/libSceLibreSsl3.md: new entry (nothing checked on the console; the queued error has no file/line), the placeholder row removed and the count cut from 175 to 174.

Tested

Linux x86_64 (Ubuntu 24.04, GCC 13.3), full build with -DBUILD_TESTING=ON on 086c0686c8. Titles and console: not tested.

  • New guest_libressl3_pbkdf2 passes (0.2 s): RFC 7914 §11 vectors, Python hashlib.pbkdf2_hmac vectors for MD5, SHA-256, SHA-384 and SHA-512 (password longer than the block, partial last block, embedded NULs), -1 and 0 lengths, iteration counts 0 and -5, null and empty salt, the failure and throwing cases, no leaked allocations, and allocation failures returning 0.
  • guest_libressl_oracle (-DANYPS5_LIBRESSL_ORACLE=ON): 3000 random PKCS5_PBKDF2_HMAC cases against LibreSSL 2.5.4, 0 differ. The test still fails on 6 AES_set_*_key cases, which fail the same way on main.
  • Full ctest: 3816/3828 pass. The other failures are guest_libressl_oracle (above) and 11 socket tests that need IPv6, which the container does not have.
  • tools/check_conventions.py --base origin/main, tools/check_test_registration.py and core/libs/tests/test_public_headers.py pass.
  • tools/pr_overlap.py --branch claude/epic-tesla-2yue6y finds no open PR with the same exports; it reports textual overlap in docs/dev/debt/libSceLibreSsl3.md, core/libs/prx/libSceLibreSsl3/CMakeLists.txt, include/Api.hpp, AdditionalExports.cpp and core/libs/prx/libSceLibreSsl/tests/Oracle.cpp with #10557, #10960, #12315, #12945, #13266, #13285, #13546, #13547, #13877, #14366, #14889, #14890, #14992, #15031, #15045, #15119, #15289, #15303, #15449, #15472, #15514, #15544, #15591, #15599. It also lists shared helper names (Allocate, Release, Align, Realign, Reallocate, PosixAlign, not PKCS5) with #1384 and #15232. It could not compare #10461, #10631, #11146, #12754, #12928, #14212, #14483, #14499 and #14612 because they conflict with main; none of their diffs mention PKCS5_PBKDF2_HMAC or vnwZHU5FvBQ. Run with --repo boykopovar/AnyPS5 against main at 04a9eb4fa2, into which the branch still merges cleanly.

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: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5145350833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15624). Originally posted by [user236404](https://github.com/user236404) on 2026-11-03T22:16:51Z. --- ### What Implements `PKCS5_PBKDF2_HMAC` (libSceLibreSsl3, NID `vnwZHU5FvBQ`), which threw `NotImplemented_nid_no_patch` as a parameterless placeholder. It now has LibreSSL's prototype `int (const char* pass, int passlen, const unsigned char* salt, int saltlen, int iter, const EVP_MD* digest, int keylen, unsigned char* out)` and follows LibreSSL 4.0.0 `evp/evp_pbe.c` (the version the 13.40 module reports; the function is unchanged from 2.5.4), using libSceLibreSsl's HMAC and digests. - A null digest returns 0 and queues `EVP_R_MESSAGE_DIGEST_IS_NULL` (`0x06fff09f`), as 4.0.0's `EVP_MD_size` does. - A null password, or a negative password length other than -1, returns 0 through `HMAC_Init_ex`, as in LibreSSL; -1 means `strlen`; an iteration count below 1 acts as 1; a key length of 0 returns 1 and writes nothing. - Inputs the reference overruns or loops on throw `std::invalid_argument`: a negative key length, a null output, a negative salt length, a null salt with a positive length, a digest size of 0 or over 64. - `docs/dev/debt/libSceLibreSsl3.md`: new entry (nothing checked on the console; the queued error has no file/line), the placeholder row removed and the count cut from 175 to 174. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux x86_64 (Ubuntu 24.04, GCC 13.3), full build with `-DBUILD_TESTING=ON` on `086c0686c8`. Titles and console: not tested. - New `guest_libressl3_pbkdf2` passes (0.2 s): RFC 7914 §11 vectors, Python `hashlib.pbkdf2_hmac` vectors for MD5, SHA-256, SHA-384 and SHA-512 (password longer than the block, partial last block, embedded NULs), -1 and 0 lengths, iteration counts 0 and -5, null and empty salt, the failure and throwing cases, no leaked allocations, and allocation failures returning 0. - `guest_libressl_oracle` (`-DANYPS5_LIBRESSL_ORACLE=ON`): 3000 random `PKCS5_PBKDF2_HMAC` cases against LibreSSL 2.5.4, 0 differ. The test still fails on 6 `AES_set_*_key` cases, which fail the same way on `main`. - Full ctest: 3816/3828 pass. The other failures are `guest_libressl_oracle` (above) and 11 socket tests that need IPv6, which the container does not have. - `tools/check_conventions.py --base origin/main`, `tools/check_test_registration.py` and `core/libs/tests/test_public_headers.py` pass. - `tools/pr_overlap.py --branch claude/epic-tesla-2yue6y` finds no open PR with the same exports; it reports textual overlap in `docs/dev/debt/libSceLibreSsl3.md`, `core/libs/prx/libSceLibreSsl3/CMakeLists.txt`, `include/Api.hpp`, `AdditionalExports.cpp` and `core/libs/prx/libSceLibreSsl/tests/Oracle.cpp` with #10557, #10960, #12315, #12945, #13266, #13285, #13546, #13547, #13877, #14366, #14889, #14890, #14992, #15031, #15045, #15119, #15289, #15303, #15449, #15472, #15514, #15544, #15591, #15599. It also lists shared helper names (`Allocate`, `Release`, `Align`, `Realign`, `Reallocate`, `PosixAlign`, not PKCS5) with #1384 and #15232. It could not compare #10461, #10631, #11146, #12754, #12928, #14212, #14483, #14499 and #14612 because they conflict with `main`; none of their diffs mention `PKCS5_PBKDF2_HMAC` or `vnwZHU5FvBQ`. Run with `--repo boykopovar/AnyPS5` against `main` at `04a9eb4fa2`, into which the branch still merges cleanly. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes

Pull request closed

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!15624
No description provided.