feat(libSceLibreSsl): implement DES_set_key, DES_ecb_encrypt and DES_set_odd_parity #9047

Merged
VakzOs merged 3 commits from upstream-pr/9047 into main 2026-10-23 10:38:53 +00:00
VakzOs commented 2026-10-21 10:46:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by VakzOs on 2026-10-21T10:46:54Z.


What

Implements three libSceLibreSsl exports that were throwing NotImplemented: DES_set_key, DES_ecb_encrypt and DES_set_odd_parity.

  • The DES block cipher and the odd-parity helper come from mbedtls (mbedtls_des_*, mbedtls_des_key_set_parity), which is already a submodule built for libSceSsl, so no cipher code is added; libSceLibreSsl now links mbedcrypto
  • DES_set_key follows LibreSSL's des_key.c with DES_check_key off, its default (the variable is not in the PS5 export inventory): no parity or weak-key check, returns 0
  • DES_ecb_encrypt encrypts for any nonzero enc, as LibreSSL's DES_encrypt1 does

Gap, recorded in the debt entry: the 128-byte DES_key_schedule stores the 8-byte key followed by zeros instead of LibreSSL's precomputed subkeys, and the subkeys are derived on each DES_ecb_encrypt call. Null pointers throw where LibreSSL faults. The pending-exports count goes from 399 to 396.

The new core/libs/prx/libSceLibreSsl/CMakeLists.txt overlaps with the one added by #9025, #9033 and #9041; whichever is merged later only needs to merge the test and mbedcrypto lines.

Tested

Linux (Ubuntu, GCC), full build: guest_libressl_des checks the classic vectors (133457799BBCDFF1 / 0123456789ABCDEF → 85E813540F0AB405, 0E329232EA6D0D73 / 8787878787878787 → 0) and the SP 800-17 vector 0101010101010101 / 8000000000000000 → 95F8A5E5DD31D900, both directions, in-place decryption, a nonzero enc other than 1, all 256 parity bytes, the unchecked weak and bad-parity keys, and null pointers. The test fails when encryption and decryption are swapped. libSceLibreSsl.prx patches its NIDs. tools/check_conventions.py --base origin/main passes. tools/pr_overlap.py cannot reach the GitHub API from my environment; I checked every open PR branch by hand right before opening: only #8747 (the declarations) touches these exports.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4950317539 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9047). Originally posted by [VakzOs](https://github.com/VakzOs) on 2026-10-21T10:46:54Z. --- ### What Implements three libSceLibreSsl exports that were throwing `NotImplemented`: `DES_set_key`, `DES_ecb_encrypt` and `DES_set_odd_parity`. - The DES block cipher and the odd-parity helper come from mbedtls (`mbedtls_des_*`, `mbedtls_des_key_set_parity`), which is already a submodule built for libSceSsl, so no cipher code is added; `libSceLibreSsl` now links `mbedcrypto` - `DES_set_key` follows LibreSSL's `des_key.c` with `DES_check_key` off, its default (the variable is not in the PS5 export inventory): no parity or weak-key check, returns 0 - `DES_ecb_encrypt` encrypts for any nonzero `enc`, as LibreSSL's `DES_encrypt1` does Gap, recorded in the debt entry: the 128-byte `DES_key_schedule` stores the 8-byte key followed by zeros instead of LibreSSL's precomputed subkeys, and the subkeys are derived on each `DES_ecb_encrypt` call. Null pointers throw where LibreSSL faults. The pending-exports count goes from 399 to 396. The new `core/libs/prx/libSceLibreSsl/CMakeLists.txt` overlaps with the one added by #9025, #9033 and #9041; whichever is merged later only needs to merge the test and `mbedcrypto` lines. ### Tested Linux (Ubuntu, GCC), full build: `guest_libressl_des` checks the classic vectors (133457799BBCDFF1 / 0123456789ABCDEF → 85E813540F0AB405, 0E329232EA6D0D73 / 8787878787878787 → 0) and the SP 800-17 vector 0101010101010101 / 8000000000000000 → 95F8A5E5DD31D900, both directions, in-place decryption, a nonzero `enc` other than 1, all 256 parity bytes, the unchecked weak and bad-parity keys, and null pointers. The test fails when encryption and decryption are swapped. `libSceLibreSsl.prx` patches its NIDs. `tools/check_conventions.py --base origin/main` passes. `tools/pr_overlap.py` cannot reach the GitHub API from my environment; I checked every open PR branch by hand right before opening: only #8747 (the declarations) touches these exports. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
clairtonmichel commented 2026-10-21 10:55:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by clairtonmichel on 2026-10-21T10:55:52Z.


Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5):

  • Built cleanly with zero errors.
  • Ran the guest_libressl_des test suite: 100% passed successfully (1/1 green in 0.01s).
  • DES block cipher exports (DES_set_key, DES_ecb_encrypt, and DES_set_odd_parity) behave correctly. Ready to merge!
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6314229119 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9047#issuecomment-6314229119). Originally posted by [clairtonmichel](https://github.com/clairtonmichel) on 2026-10-21T10:55:52Z. --- Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (Fedora Linux, Mesa 26.2.5): - Built cleanly with zero errors. - Ran the `guest_libressl_des` test suite: **100% passed successfully (1/1 green in 0.01s)**. - DES block cipher exports (`DES_set_key`, `DES_ecb_encrypt`, and `DES_set_odd_parity`) behave correctly. Ready to merge!
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!9047
No description provided.