feat(libSceLibreSsl3): implement AES_wrap_key #15854

Closed
fishingpvalues wants to merge 1 commit from upstream-pr/15854 into main
fishingpvalues commented 2026-11-04 19:49:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fishingpvalues on 2026-11-04T19:49:44Z.


What

Implements AES_wrap_key (GjO5Ap3E-t4), previously exported only as Unknown_GjO5Ap3E_minus_t4, following RFC 3394:

  • uses the default IV A6A6A6A6A6A6A6A6 when iv is null, six rounds and the 64-bit counter XORed into the A block, matching OpenSSL's AES_wrap_key;
  • encrypts each 16-byte block through libSceLibreSsl's AES_encrypt, so no AES implementation is duplicated;
  • returns inlen + 8 and writes A | R[1..n];
  • returns -1 for an input below 16 bytes or not a multiple of 8, as OpenSSL does, and throws for a null key, input or output where OpenSSL dereferences it.

The Unknown_* stub and its APS5_EXPORT alias leave AdditionalExports.cpp; the real signature is declared once in include/Api.hpp; the code is in new src/AesWrap.cpp with new tests/AesWrap.cpp registered as guest_libressl3_aes_wrap.

docs/dev/debt/libSceLibreSsl3.md loses the NID-only row (139 to 138 callable exports, 129 named and 10 to 9 NID-only) and gains one Functional entry for the unverified PS5 ABI, custom-IV handling and console behaviour. The branch was rebased onto current main 4ab649f4d8; the inventory counts were recalculated on that base.

Tested

Linux x86-64 (CachyOS, GCC 16.2.1), Release, BUILD_TESTING=ON, base main 4ab649f4d8:

  • guest_libressl3_aes_wrap checks the RFC 3394 128-bit known-answer vector (1FA68B0A…71D2CFE5), first verifies the parent AES-128 ECB vector (69C4E0D8…70B4C55A), and covers the short and non-multiple-of-8 rejections and the null-output throw.
  • ctest --test-dir build -R '^guest_libressl3_aes_wrap$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • python3 tools/pr_overlap.py --branch pr-15854 --jobs 4: exit 2 only because it cannot confirm shared AdditionalExports.cpp/Api.hpp/debt files from conflicting PR heads; it reports no same exports.
  • Not run: Windows, a console, or a title.

Checklist

  • Based on current main; no other open PR implements this export
  • 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)
  • No notes, investigation .md files or images added to the repository
  • 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:5160594618 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15854). Originally posted by [fishingpvalues](https://github.com/fishingpvalues) on 2026-11-04T19:49:44Z. --- ### What Implements `AES_wrap_key` (`GjO5Ap3E-t4`), previously exported only as `Unknown_GjO5Ap3E_minus_t4`, following [RFC 3394](https://www.rfc-editor.org/rfc/rfc3394): - uses the default IV `A6A6A6A6A6A6A6A6` when `iv` is null, six rounds and the 64-bit counter XORed into the A block, matching OpenSSL's `AES_wrap_key`; - encrypts each 16-byte block through libSceLibreSsl's `AES_encrypt`, so no AES implementation is duplicated; - returns `inlen + 8` and writes `A | R[1..n]`; - returns -1 for an input below 16 bytes or not a multiple of 8, as OpenSSL does, and throws for a null key, input or output where OpenSSL dereferences it. The `Unknown_*` stub and its `APS5_EXPORT` alias leave `AdditionalExports.cpp`; the real signature is declared once in `include/Api.hpp`; the code is in new `src/AesWrap.cpp` with new `tests/AesWrap.cpp` registered as `guest_libressl3_aes_wrap`. `docs/dev/debt/libSceLibreSsl3.md` loses the NID-only row (139 to 138 callable exports, 129 named and 10 to 9 NID-only) and gains one Functional entry for the unverified PS5 ABI, custom-IV handling and console behaviour. The branch was rebased onto current `main` `4ab649f4d8`; the inventory counts were recalculated on that base. ### Tested Linux x86-64 (CachyOS, GCC 16.2.1), Release, `BUILD_TESTING=ON`, base `main` `4ab649f4d8`: - `guest_libressl3_aes_wrap` checks the RFC 3394 128-bit known-answer vector (`1FA68B0A…71D2CFE5`), first verifies the parent AES-128 ECB vector (`69C4E0D8…70B4C55A`), and covers the short and non-multiple-of-8 rejections and the null-output throw. - `ctest --test-dir build -R '^guest_libressl3_aes_wrap$' --output-on-failure`: 1/1 passed. - `python3 tools/check_conventions.py --base origin/main`: passed. - `python3 tools/pr_overlap.py --branch pr-15854 --jobs 4`: exit 2 only because it cannot confirm shared `AdditionalExports.cpp`/`Api.hpp`/debt files from conflicting PR heads; it reports no same exports. - Not run: Windows, a console, or a title. ### Checklist - [x] Based on current `main`; no other open PR implements this export - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`) - [x] No notes, investigation `.md` files or images added to the repository - [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!15854
No description provided.