fix(libSceLibreSsl): build the AES substitution table within the constexpr step limit #10562
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10562"
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 krishalivaibhav on 2026-10-24T10:11:29Z.
What
libSceLibreSsl/src/Aes.cppdid not compile with AppleClang:MakeSubstitution()builds the AES S-box at compile time and found each multiplicative inverse in GF(2^8) by trying all 255 candidates for each of the 256 values (about 65kMultiplycalls), which exceeds clang's constexpr step limit.The inverse is now computed directly as x^254 (6 square-and-multiply steps, then one square; 0 still maps to 0). This builds the same table: the existing
static_asserts on entries 0x00, 0x53 and 0xff still hold. No compiler flag is needed, and the code is the same on all platforms.Tested
macOS: Apple Silicon M2, macOS 27.2, AppleClang, x86_64 Release, on a local integration of
main(ca9543ea5) + the open macOS build PRs (#10419, #10366, #10369, #7631, #7804, #4630, #10552):Aes.cppcompiles (it failed before with the constexpr step limit);ninja libs -k 0no longer lists it.guest_libressl_aespasses.Linux/Windows: not built locally; CI will build them.
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🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:30:22Z.
Review: APPROVED
Reviewed the exponentiation chain: starting at
x, six rounds ofx = x²·aproducea^127, and the final square producesa^254; zero remains zero, as required for the AES inverse map. I compared the complete fast-generated 256-byte S-box against the prior exhaustive-search algorithm in a standalone GCC C++20 check; every entry matched, and the published static-assert entries passed. Hosted eligibility, conventions, intake, labels, and report pass; platform build jobs were skipped by eligibility. No correctness issue found.