Repository navigation
fix(libSceLibreSsl): build the AES substitution table within the constexpr step limit - #10562
Conversation
…texpr step limit The table searched all 255 candidates for each inverse, which exceeds the constexpr step limit of AppleClang. The inverse is now computed as x^254 in GF(2^8), which gives the same table. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the exponentiation chain: starting at x, six rounds of x = x²·a produce a^127, and the final square produces a^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.
Tested at
|
| build | guest_libressl_aes |
|
|---|---|---|
| Without this PR | Aes.cpp:51:16: error: constexpr variable 'Substitution' must be initialized by a constant expression (note: constexpr evaluation hit maximum step limit), so libSceLibreSsl does not build |
not built |
| With this PR | builds | Passes |
The other five guest_libressl* tests pass with this PR as well.
AI-assisted: yes (Claude Code applied the PR, built both ways, ran the tests and wrote this report).
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
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(ca9543e) + 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