feat(libSceLibreSsl3): implement AES_unwrap_key #14612
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14612"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-11-01T16:23:30Z.
What
AES_unwrap_key(JvoQz7GYOMo) in libSceLibreSsl3 was a throwing stub. This implements it as the RFC 3394 key unwrap from LibreSSL 4.0.0aes.c(3.8.4aes_wrap.chas the same body), on top of libSceLibreSsl'sAES_decrypt. The prototype is the one in that version'saes.h.inlen - 8output bytes and returns 0; success returnsinlen - 8.ivuses the default A6 IV.out == inworks, as upstream.The name only comes from the NID hash (
tools/nid_names.py), so the debt entry says that and that nothing is checked on a console. The inventory row goes away. After merging main, the remaining inventory has 163 exports: 153 named and 10 known only by NID.AES_wrap_keystays anunknownrow; I left it alone. I don't know of a title that calls this; it's coverage.Tested
November 6 integration against
0fbe14c15361c420c65bc22cf2c3dc14cbda81d1:e7e69c303ffc.e7e69c303ffcpasses hosted Windows, conventions, and portability checks. Current-head CI is pending.Current-main integration at
f12bb19a681f, November 5:mainatc4469b60daf23b849292256a65670a7a6b5527d4without rewriting history. Resolved the shared inventory counters after the RSA getter changes.ec9250fb3a6a.November 5 update at
ec9250fb3a6a, based onmainat4180951e90e6898c8eca3635d850cf4569305299:CRYPTO_memcmp_nid_postfix. The pinned LibreSSL source usesmemcmp; this change accepts the review's hardening request.guest_libressl3_aes,guest_libressl_aes, andguest_crypto_memcmp: 3/3 pass.Earlier November 1 results (before this update), Ubuntu 24.04 on WSL2, GCC 13.3, Release build:
guest_libressl3_aes: aborts onmain(the stub throwsAES_unwrap_key_nid_postfix not implemented), passes with the fix.inlen - 8bytes are written or zeroed. All vectors match host OpenSSL 3.0.13 (cryptography41.0.7).> 0xffbranch, zeroing extent, check order, ...), all caught.ctest3155/3157; the 2 failures areguest_socket_optionsandguest_socket_read_write, which fail the same way onmainon this WSL box (loopback).python3 tools/check_conventions.py --base origin/main: pass.Overlap refreshed November 6 at 09:43 UTC: 1,855 open PRs across 19 complete REST pages. Checked all 44 PRs sharing the target paths, reusing unchanged head evidence. No other PR changes
AES_unwrap_keyor its test file. #15854 implements AES wrap and #16255 implements CCM in separate files. Shared inventory lines describe distinct exports.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T16:40:30Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The unwrap integrity check uses
std::memcmp, which does not promise content-independent timing, while the reference implementation uses a timing-safe comparison.What I ran
Head:
23f2e489b43510c463975afaaae14a0a419af32b; base:f2d874c1fdccf781c0fa5d86619bb5dd8894b958(main). Stack preview merged cleanly. Environment: Debian 12, Python 3.11.2, GCC 12.2.0. No build or C++ tests were run.I read all six changed files, checked the CMake test registration and verified that the new declaration and definition compute to NID
JvoQz7GYOMo.Results
Precheck check table (verbatim)
The precheck could not find the workspace-only ABI and test-quality scripts in its detached snapshot. I ran both manually against this exact head. The ABI audit passed with no findings; manual inspection confirms the test registration despite the heuristic warning.
Negative control
Not run: the C++ tests require a built executable. The PR includes RFC 3394 vectors and an integrity-failure test, but I did not execute them.
Findings
Blocking
Use a timing-safe integrity comparison.
Aes.cppcallsstd::memcmp(block, iv, 8)to decide whether unwrap integrity succeeded.memcmpprovides no content-independent timing guarantee. The LibreSSL 4.0.0 implementation cited by this PR compares the integrity block withtimingsafe_memcmp; this repository already hasCRYPTO_memcmp_nid_postfix, which accumulates differences over the full buffer. Use a constant-time comparison here to avoid data-dependent timing during key unwrap.Non-blocking
None.
Sources
Not verified
I did not build or execute the C++ tests, measure timing behavior, or verify this implementation against a PS5. Hosted checks were queued when checked.
To get this to a good state
Replace the integrity
memcmpwith the existing constant-time comparison (or an equivalent), then I will rerun the precheck and AES tests on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T16:55:12Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes still requested
The new head adds the requested source notice and volatile output clearing, but the unwrap integrity decision still uses
std::memcmpand remains data-dependent.What I ran
Re-checked head
503817973caec18f4dee7d5e10639723671e4613against basef2d874c1fdccf781c0fa5d86619bb5dd8894b958; the merge preview is clean. Environment: Debian GNU/Linux 12, Python 3.11.2, Git 2.39.5. No build or C++ tests were run.I also reviewed the change from the previously reviewed head
23f2e489b43510c463975afaaae14a0a419af32b: it only changes the license notice and integrity-failure output clearing. The four hosted checks are queued.Results
std::memcmpremainsCommands and unedited output
git diff --check f2d874c1fdccf781c0fa5d86619bb5dd8894b958 503817973caec18f4dee7d5e10639723671e4613:Precheck report:
diff_checkfailed with the output above;conventions_and_pr_templatepassed with stdout:The precheck's ABI and test-quality helper invocations could not run because those helper files are not present in its fetched PR snapshot. Its stack check passed and reported a clean merge preview against
f2d874c1fdccf781c0fa5d86619bb5dd8894b958.GitHub reported
eligibility,library-portability,report, andconventionsas queued on head503817973caec18f4dee7d5e10639723671e4613.Negative control
Not run: the AES C++ test requires an exact-head build. No timing measurement or negative control was performed.
Findings
Blocking
AES_unwrap_key_nid_postfixstill compares the recovered integrity block with the IV usingstd::memcmp. This function validates key material, andmemcmpmay stop at the first differing byte; use the existingCRYPTO_memcmp_nid_postfixhelper (or another content-independent comparison) so the integrity decision does not depend on the mismatch position.Non-blocking
The added OpenSSL notice preserves a trailing space from the pinned source, so
git diff --checkreports it. The repository convention check passed; preserve the required notice verbatim unless maintainers confirm that whitespace normalization is acceptable.Sources
CRYPTO_memcmp_nid_postfiximplementation at the baseNot verified
The C++ build and AES tests, timing behavior, Windows behavior, and console behavior were not independently verified.
To get this to a good state
Replace the integrity
memcmpwith the existing constant-time comparison while preserving the source notice. I will rerun the precheck and AES tests on the updated head; the test run requires a build.