feat(libSceLibreSsl): implement the EVP cipher calls on the cipher context #10834

Merged
EagleBearerYS merged 20 commits from upstream-pr/10834 into main 2026-11-05 11:04:00 +00:00
EagleBearerYS commented 2026-10-25 03:37:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-25T03:37:07Z.


What

Implements 22 EVP cipher exports of libSceLibreSsl on the cipher-context object from #10488, following LibreSSL 2.5.4 (libressl/openbsd 2e2c612066aa, the version in the firmware 13.40 measurements):

  • EVP_CIPHER_CTX_cleanup, EVP_CIPHER_CTX_free, EVP_CIPHER_CTX_ctrl (evp_enc.c)
  • EVP_CipherInit_ex, EVP_EncryptInit_ex, EVP_DecryptInit_ex, EVP_CipherUpdate, EVP_EncryptUpdate, EVP_DecryptUpdate, EVP_CipherFinal_ex, EVP_EncryptFinal_ex, EVP_DecryptFinal_ex: buffering, PKCS padding and its checks, EVP_CIPH_NO_PADDING, IV setup per mode, and the custom-cipher path, called through the descriptor's function pointers (evp_enc.c)
  • EVP_aes_{128,192,256}_cfb8 and EVP_aes_{128,192,256}_ctr on the AES from #9033 (e_aes.c, cfb128.c, ctr128.c; NIST SP 800-38A)
  • EVP_aes_{128,192,256}_gcm: GHASH and GCTR from gcm128.c, aes_gcm_ctrl (IV length, tag, fixed and generated IVs, TLS AAD, copy) and the TLS record path (e_aes.c; NIST SP 800-38D). Both tag checks compare every byte in constant time, as LibreSSL does with timingsafe_memcmp
  • EVP_cleanup: nothing in this module can fill the tables LibreSSL's names.c clears yet, so it returns; the debt entry says when that changes

include/Api.hpp declares the 22 exports once, with their real signatures, as main asks since #10706. It holds LibreSSL's 88-byte EVP_CIPHER next to #10488's 168-byte EVP_CIPHER_CTX, whose cipher field this PR types as const LibreSslEvpCipher*; the layout is unchanged. include/Evp.hpp keeps the internal constants and the layout checks. Failures queue no error code, a non-null ENGINE throws, and inputs LibreSSL would dereference or overrun throw; the five new entries in docs/dev/debt/libSceLibreSsl.md list them.

Built on #10488, which has merged. Its four commits are alvaroelpob's, unchanged, and are on main now, so this PR's diff over main is its own commits.

Related: #10450 (EVP_CIPHER_block_size, merged; since f30dd4849a it takes this PR's LibreSslEvpCipher), #9571 (CMAC and the CBC descriptors over the same EVP_CIPHER layout).

Tested

  • d8ee395e44, these six commits rebased onto #10488's 6b1e364fc2. In each commit, its exports move from (void) stubs to their real signatures in include/Api.hpp, and include/Aes.hpp is dropped, since main's Api.hpp has AesKey and the AES_* calls. The test calls the exports with their public types through #10488's Context() helper; its checks and their messages are unchanged.
    • Per commit: each of the six commits builds with CI's flags on a Linux machine, and ctest -R '^(guest_libressl|public_headers)' passes at every one: 73 run, 73 pass. That's the eight LibreSSL tests, public_headers and its 64 compile batches.
    • CI's Linux job, mirrored at the head: 2,213 tests, 2,118 pass, 90 skip and 5 fail. The five are that machine's IPv6 tests.
    • On GitHub's runners (run): the eight ^guest_libressl tests and public_headers pass 10 runs in a row, 9 run, 9 pass, 0 skip, 0 fail on Linux and on Windows. The libc and libkernel suites pass on both (144 and 207 tests on Linux, 171 and 223 on Windows), run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • At 8f269fb332, the previous head, on #10488's earlier head (run): the ^guest_libressl tests, 10 runs in a row. Linux: 7 run, 7 pass, 0 skip, 0 fail. Windows: 7 run, 7 pass, 0 skip, 0 fail. The libc and libkernel suites pass on both (123 and 204 tests on Linux, 150 and 217 on Windows), run with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • 8f269fb332 makes GcmFinish and the TLS decrypt path compare the tag in constant time, and guest_libressl_evp_cipher_ctx now flips each byte of the tag in turn, for every GCM vector's EVP_DecryptFinal_ex and for a TLS record, and requires each to be rejected.
    • Those cases also pass with 3b5f90d2a7's std::memcmp, which finds every difference too, so they check that the new compare reads every tag byte. The timing itself isn't tested.
  • Earlier, at 3b5f90d2a7 (run 40154572248), with #10488's head as the comparison arm: guest_libressl_evp_cipher_ctx, guest_libressl_aes, guest_libressl_digest, guest_libressl_des, guest_libressl_runtime, guest_libressl_x509_errors and guest_libressl3_digest pass 10 of 10 on Linux and on Windows, 0 skipped. #10488's own code doesn't build against the new tests. The libc and libkernel suites pass on both.
  • Linux x86-64 (Ubuntu 24.04, gcc 13.3.0, wild 0.10.0), no title. guest_libressl_evp_cipher_ctx gains 17 cases:
    • SP 800-38A CFB8 (F.3.7–F.3.12) and CTR (F.5.1–F.5.6) for AES-128/192/256, through EVP_Encrypt*, EVP_Decrypt* and EVP_Cipher*;
    • GCM test cases 1–8, 13 and 14, with the IV length and tag set and read through EVP_CIPHER_CTX_ctrl, including wrong and truncated tags;
    • GCM TLS records, EVP_CTRL_COPY, and the ctrl error returns;
    • padding on and off, held-back blocks and bad padding, with a test-defined block cipher;
    • the Init mode and IV handling, and the custom-cipher and stream paths.
  • Each commit's new cases fail against the code before it and pass with it. CI-configured build, then ctest as an unprivileged user: 2,054 tests, 1,961 passed, 88 skipped and 5 failed. The five need IPv6, which the test machine lacks: guest_net_buffer_validation, guest_socket_options, guest_socket_stream_options, guest_socket_address_length and guest_tcp.
  • 820d1c0fe7, merges of #10488's b188b78b5f and of main 7e4f6e0440 (run). Dean Galvin's merge of main into #10488 and main's #10484 add lines next to this PR's in the LibreSSL debt file; the merges keep both sides. The first also sets the pending-exports count to what is left: Export.cpp now has 320 NotImplemented exports, the base's 342 less this PR's 22. The guest_libressl tests and public_headers pass 10 runs in a row. Linux: 12 run, 12 pass, 0 skip, 0 fail. Windows: 12 run, 12 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 5e9371dcb8, this PR's six commits rebased onto #10488's 9a3cb4ef57 (run), after alvaroelpob rebased #10488 onto main ae7d59258e. The code is unchanged; only the lines around it moved, where main changed the LibreSSL debt file and the add_library source list. A seventh commit sets the pending-exports count to 317, the NotImplemented exports left in Export.cpp: #10488's 339 less this PR's 22. The guest_libressl tests and public_headers pass 10 runs in a row. Linux: 13 run, 13 pass, 0 skip, 0 fail. Windows: 13 run, 13 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • Firmware 13.42's libSceLibreSsl.sprx, run by BunnyFl (comment): the module's own code, in an emulator (Unicorn) and natively on x86-64 for the AES calls, gave identical results in four runs each, and they agree with the EVP_CIPHER and EVP_CIPHER_CTX layouts here.
    • All nine AES descriptors match: NIDs, block size, IV and key lengths, flags, ctx_size, and which hooks are set.
    • The EVP_CIPHER_CTX offsets match through EVP_EncryptInit_ex and EVP_EncryptUpdate with AES-128 CTR, and through a padded AES-128 CBC decrypt.
    • #10488's EVP_CIPHER_CTX_set_padding sets and clears bit 0x100 of the word at 112, changes no other byte, and returns 1.
    • The firmware 13.40 console measurements covered only the 168-byte init.
  • d5e55453be, a merge of main 5e90e7569d (run). main's 9a848d0b99 implements the TLS alert descriptions and lowers the pending-export count in docs/dev/debt/libSceLibreSsl.md from 342 to 341, on the line this PR sets. The merge keeps main's change and sets the count to 316, the NotImplemented_nid_no_patch exports left in the merged Export.cpp. Nothing else conflicted, #10488's four commits are unchanged, and this PR's other changed lines are the same. The 13 guest_libressl tests pass 10 runs in a row. Linux: 13 run, 13 pass, 0 skip, 0 fail. Windows: 13 run, 13 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (145 and 210) and on Windows (174 and 231). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • b8d832765e and f129b2fde7, following the rule that tests don't require a placeholder to throw, and a merge of main 84e91df418 (run). b8d832765e drops the cipher-context test's two checks that required EVP_CIPHER_CTX_cleanup with an ENGINE set, and EVP_EncryptInit_ex given one, to throw. The calls still refuse an ENGINE, as the debt entry says, and the null-pointer, malformed-context and invalid-length checks stay. f129b2fde7 merges main, whose #9745 (SSLeay) lowers the pending-export count in docs/dev/debt/libSceLibreSsl.md to 340, on the line this PR sets; the merge keeps it and sets 315, the NotImplemented_nid_no_patch exports left in the merged Export.cpp. Nothing else conflicted, #10488's four commits are unchanged, and this PR's other changed lines are the same. The guest_libressl tests with the tests for the files the merge changes, 23 of them, pass 10 runs in a row. Linux: 23 run, 23 pass, 0 skip, 0 fail. Windows: 23 run, 23 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (145 and 211) and on Windows (174 and 232). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 2b7040e434, this PR's eight commits rebased onto #10488's 10f8980dd5 (run), after alvaroelpob rebased #10488 onto main 4c7d275bef. The code is unchanged, and the two merges of main drop out with the rebase. Three places took the new base's lines around this PR's:
    • include/Api.hpp: main's stack, UI, RSA and X509 store-context structs now sit above this PR's LibreSslEvpCipher. Both are kept.
    • The add_library line: this PR still adds one file, src/EvpAes.cpp, now to main's longer source list.
    • The pending-export count in docs/dev/debt/libSceLibreSsl.md is now 274. That's the number of NotImplemented_nid_no_patch calls left in the rebased Export.cpp; the same count gives the line's 296 on #10488's head and 299 on main.
    • The ^guest_libressl tests and public_headers ran 10 times with no failure. Linux: 34 run, 34 pass, 0 skip, 0 fail. Windows: 34 run, 34 pass, 0 skip, 0 fail. The libc and libkernel suites run 191 and 291 tests on Linux and 220 and 314 on Windows, with 0 failed. They ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • bc39d79482, this PR's eight commits rebased onto #10488's ea1a21792f (run), after alvaroelpob rebased #10488 onto main da026c7065.
    • git range-diff: six commits are unchanged, the first changes only in a context line of the debt file, where #10488's X509 store-context entry moved, and the seventh only in the pending-export count.
    • The count is now 268, the NotImplemented_nid_no_patch calls left in the rebased Export.cpp: 290 on #10488's new head, less this PR's 22.
    • It merges cleanly with main, so no merge was needed, and the count holds on the merged tree.
    • ×10: the ^guest_libressl tests, public_headers and its 64 compile batches. Linux: 99 run, 99 pass, 0 skip, 0 fail. Windows: 99 run, 99 pass, 0 skip, 0 fail. The libc and libkernel suites run 198 and 307 tests on Linux and 225 and 327 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 0c989744ea, a merge of main c12e7e61a1 (run), which brings JaceTheBlu's #13562 (OBJ_create and OBJ_cleanup). #10488's head ea1a21792f is still this branch's base.
    • The one conflict was the pending-exports count in docs/dev/debt/libSceLibreSsl.md: main reads 292 after #13562, and the merged Export.cpp has 267 calls left that go through NotImplemented_nid_no_patch, so the entry now says 267. CMakeLists.txt, Export.cpp and Api.hpp merged without conflicts.
    • One sentence beyond keeping both sides: this PR's EVP_cleanup entry listed OBJ_create and OBJ_cleanup among the calls that aren't implemented, which #13562 made untrue. It now says that OPENSSL_add_all_algorithms_noconf, SSL_library_init, CONF_modules_load_file, OPENSSL_load_builtin_modules and PKCS12_PBE_add aren't implemented and that no cipher or digest can be registered under an OBJ_create NID to defer OBJ_cleanup. So EVP_cleanup still has nothing to clear: in LibreSSL 2.5.4 (2e2c612066, evp/names.c and objects/obj_dat.c), EVP_cleanup calls OBJ_cleanup only after EVP_add_cipher or EVP_add_digest has registered such a NID, and neither exists here. The merge commit's message names it.
    • This PR's other changed lines are the same.
    • ×10: ^guest_libressl and public_headers. Linux: 35 run, 35 pass, 0 skip, 0 fail. Windows: 35 run, 35 pass, 0 skip, 0 fail. The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 85e42b7647, a merge of main 0a148be963 (run), which brings #13760 (GENERAL_NAME_free and GENERAL_NAMES_free) and #13820 (SHA-384 and SHA-512 initialization buffers).
    • The one conflict was docs/dev/debt/libSceLibreSsl.md, where the merge keeps both sides' entries. The pending-exports count is recounted on the merged tree: main's line was 2 above its own total (292 against 290 calls left in its Export.cpp), so this PR's 267 is now 265, the NotImplemented_nid_no_patch calls left in the merged Export.cpp.
    • ×10: ^guest_libressl and public_headers. Linux: 39 run, 39 pass, 0 skip, 0 fail. Windows: 39 run, 39 pass, 0 skip, 0 fail. The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 9f70186b52: this PR's eight commits restacked onto #10488's 16d0e81b02, then one docs commit (run), after alvaroelpob rebased #10488 onto main cf79276fee.
    • git range-diff: six commits are unchanged. The first changes only in a context line of the debt file, the PKCS12_PBE_add entry that main's #13562 rewrote. The seventh changes only in the pending-exports count and a context line, the Digest entry that #13820 extended.
    • The count is 265, the NotImplemented_nid_no_patch calls left in the restacked Export.cpp: 287 on #10488's new head, less this PR's 22.
    • 9f70186b52 ("docs(libSceLibreSsl): update the EVP_cleanup entry for OBJ_create and OBJ_cleanup") carries 0c989744ea's EVP_cleanup sentence (above) into the restacked commits, since that sentence was in the merge commit. After it, the debt file is the same as at 85e42b7647, and git diff 85e42b7647 9f70186b52 over core/libs/prx/libSceLibreSsl and the debt file is empty. The two earlier merges of main are no longer in the branch's history.
    • It merges cleanly with main bbe8cf31c1, so no merge was needed.
    • ×10: ^guest_libressl and public_headers. Linux: 39 run, 39 pass, 0 skip, 0 fail. Windows: 39 run, 39 pass, 0 skip, 0 fail. The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 8ea13cc9ea: merges of main 88e804b0a7 (ba51e03631) and 24238c4cb1 (8ea13cc9ea), with a recount between them (64b0d96659) (run, on 8ea13cc9ea).
    • ba51e03631 brings Felipebmaitan's #9535 (error queues) and atharvjairath's #10078 (X509_EXTENSION getters). Two conflicts, both resolved by keeping both sides: in Export.cpp, #9535 removes the ERR_error_string stubs next to the EVP_CIPHER_CTX stubs this PR removes, and the pending-exports count line in docs/dev/debt/libSceLibreSsl.md.
    • 64b0d96659 sets the count to 259, the NotImplemented_nid_no_patch calls left in the merged Export.cpp (#9535 and #10078 implement three each).
    • 8ea13cc9ea brings alvaroelpob's #10488 as it merged on main, which this branch already carried. After the first merge, GitHub reported the branch as conflicting: with #10488 merged on main, the branch had two merge bases, and with either one alone the merge conflicts. This merge leaves one. It merged without conflicts, the count stays 259, and this PR's changed lines over main are the same as they were over #10488's head.
    • ×10: the ^guest_libressl tests, with guest_libressl_evp_cipher_ctx and public_headers. Linux: 44 run, 44 pass, 0 skip, 0 fail. Windows: 44 run, 44 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 0143584d76, a merge of main b28bb77217 (run), which brings HQasper's #9448 (the EVP message digest and HMAC functions).
    • Four conflicting files, all resolved by keeping both sides:
      • the add_library source list in CMakeLists.txt, where #9448 adds src/Evp.cpp and this PR src/EvpAes.cpp;
      • Export.cpp, where #9448 removes its digest and HMAC stubs next to the cipher stubs this PR removes;
      • include/Api.hpp, where #9448 adds its digest and HMAC types next to this PR's LibreSslEvpCipher, and each side gives its own exports their real signatures in the same declaration lists;
      • docs/dev/debt/libSceLibreSsl.md, which keeps #9448's new entry.
    • The count is 239, the NotImplemented_nid_no_patch calls left in the merged Export.cpp: main's 261, which its line now matches, less this PR's 22.
    • This PR's other changed lines over main are the same, and it merges cleanly with main a4eca2a056.
    • ×10: the ^guest_libressl tests, with guest_libressl_evp_cipher_ctx and public_headers. Linux: 46 run, 46 pass, 0 skip, 0 fail. Windows: 46 run, 46 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (217 and 319) and on Windows (244 and 340). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • 319b7072de, a merge of main 4f41f4c375 (run), which brings Felipebmaitan's #9571 (CMAC with the AES-CBC ciphers).
    • The conflicts, each resolved by keeping both sides:
      • CMakeLists.txt's add_library source list: the union of both sides' sources, each once;
      • Export.cpp: this PR's removal of the CFB8, CTR, GCM and EVP_cleanup stubs, and main's removal of the CBC stubs;
      • include/Api.hpp: main's ERR signatures and CBC getters, and this PR's context, CFB8, CTR, GCM and EVP_cleanup declarations;
      • docs/dev/debt/libSceLibreSsl.md: the merged Export.cpp has 209 NotImplemented exports, so the pending-exports entry now says 209 (this PR said 239, main 231).
    • The two cipher types: main's CBC getters return its LibreSslCipher (Cmac.hpp), and this PR's EVP_CipherInit_ex takes its LibreSslEvpCipher. Their fields match in order and size, as do main's LibreSslCipherContext and this PR's LibreSslEvpCipherCtx (main asserts 168 bytes, with iv at 40, flags at 112 and cipherData at 120). 8a9ab924f9's test passes main's EVP_aes_128_cbc() through this PR's context (see below).
    • No function is in both PRs, and this PR's other lines are unchanged.
    • ×10: every ^guest_libressl test. Linux: 51 run, 51 pass, 0 skip, 0 fail. Windows: 51 run, 51 pass, 0 skip, 0 fail. The libc and libkernel suites run 300 and 322 tests on Linux and 327 and 342 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
    • AMD: TechLevelZero's AMD bot ran this head merged onto main 4f41f4c: AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8; report): 1,147 passed, 6 failed, none new (4 also fail on main, 2 unstable on main), 6 skipped, with no new validation IDs (551 tests on the GPU).
  • 6e3ccd8ff3, debt corrections (docs only), for XairRrR's review. The EVP context entry no longer gives ERR_get_error and ERR_peek_error as the reason no error is queued, the EVP_cleanup entry says PKCS12_PBE_add is empty as in LibreSSL 2.5.4, and the CMAC entry says that, of the EVP cipher exports, only EVP_CIPHER_block_size still throws.
    • AMD: TechLevelZero's AMD bot ran this head merged onto main 4f41f4c: AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8; report): 1,147 passed, 6 failed, none new (4 also fail on main, 2 unstable on main), 6 skipped, with no new validation IDs (551 tests on the GPU).
  • 8a9ab924f9, a CBC round trip (test-only, GuestLibreSslEvpCipherCtx.cpp), for the same review's point 4. main's EVP_aes_128_cbc() descriptor goes through this PR's EVP_EncryptInit_ex and EVP_DecryptInit_ex, Update and Final with the CBC-AES128 vectors of NIST SP 800-38A F.2.1 and F.2.2: encryption and decryption without padding, and a round trip with PKCS#7 padding, in chunks of 1, 7, 16 and 64 bytes. It covers code that already works, so it has no red.
    • ×10 (run): every ^guest_libressl test. Linux: 51 run, 51 pass, 0 skip, 0 fail. Windows: 51 run, 51 pass, 0 skip, 0 fail. The libc and libkernel suites run 300 and 322 tests on Linux and 327 and 342 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • da37daf69f, a merge of main 9ab6a281ea (run), which brings MatteoSid's #10395 (EC groups and keys).
    • The conflicts, each resolved by keeping both sides:
      • CMakeLists.txt's add_library source list: main adds src/Ec.cpp and this PR src/EvpAes.cpp, and the line keeps both;
      • docs/dev/debt/libSceLibreSsl.md: the merged Export.cpp has 200 NotImplemented exports, so the pending-exports entry now says 200 (this PR said 209, main 222).
    • No function is in both PRs, and this PR's other lines are unchanged.
    • ×10: every ^guest_libressl test, with public_headers. Linux: 54 run, 54 pass, 0 skip, 0 fail. Windows: 54 run, 54 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 327 tests on Linux and 335 and 354 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • c83992150b, a merge of main b611e634f7 (run), which brings LordVersA's #11662 (SSL_library_init).
    • The conflict: the pending-exports count in docs/dev/debt/libSceLibreSsl.md, which both sides changed. The merged Export.cpp had 199 NotImplemented exports, so the entry said 199 (this PR said 200, main 221). No function is in both PRs, and this PR's other lines are unchanged.
    • ×10: every ^guest_libressl test, with public_headers. Linux: 54 run, 54 pass, 0 skip, 0 fail. Windows: 54 run, 54 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • f30dd4849a, a merge of main d63781e9ce (run), which brings alvaroelpob's #10450 (EVP_CIPHER_block_size).
    • The conflicts:
      • include/Api.hpp: #10450 adds its own LibreSslEvpCipher, with this PR's 13 fields in the same order but its function pointers as void*. The merge keeps this PR's typed definition, since EvpCipherCtx.cpp calls through those pointers, and declares EVP_CIPHER_block_size with main's const LibreSslEvpCipher*. main's EvpCipher.cpp reads only blockSize, and its layout checks (88 bytes, blockSize at 4, init at 24, contextSize at 48) hold for the typed struct.
      • Export.cpp: both sides' stub removals are kept, so no EVP cipher stub is left.
      • CMakeLists.txt's add_library source list: main adds src/EvpCipher.cpp and this PR src/EvpAes.cpp, and the line keeps both.
      • docs/dev/debt/libSceLibreSsl.md: main's EVP_CIPHER_block_size entry and this PR's five are kept. The merged Export.cpp had 198 NotImplemented exports, so the pending-exports entry said 198 (this PR said 199, main 220).
    • Two debt sentences that main made untrue are corrected, as the merge commit's message says. The CMAC entry drops "Of the EVP cipher exports, only EVP_CIPHER_block_size still throws" (#10450). The EVP_cleanup entry no longer lists SSL_library_init (#11662) among the calls that aren't implemented: it now says SSL_library_init returns 1 without adding a cipher or digest, so EVP_cleanup still has nothing to clear.
    • ×10: every ^guest_libressl test (now including #10450's guest_libressl_evp_cipher) and public_headers. Linux: 55 run, 55 pass, 0 skip, 0 fail. Windows: 55 run, 55 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • db6537d1c7, a merge of main 9f9e420709 (run), which brings alvaroelpob's #10448 (OCSP_response_status, OCSP_single_get0_status).
    • The conflicts:
      • include/Api.hpp, where #10448 adds four OCSP structs right after main's copy of LibreSslEvpCipher. The merge keeps the four structs and this PR's single typed definition.
      • CMakeLists.txt's add_library source list, where main adds src/OcspResponse.cpp and this PR src/EvpAes.cpp. The line keeps both.
      • docs/dev/debt/libSceLibreSsl.md, which keeps #10448's OCSP entry beside this PR's five. The merged Export.cpp has 196 NotImplemented exports, so the pending-exports entry now says 196 (this PR said 198, main 218).
    • No function is in both PRs, and this PR's other lines are unchanged.
    • ×10: every ^guest_libressl test (now including #10448's guest_libressl_ocsp_response) and public_headers. Linux: 56 run, 56 pass, 0 skip, 0 fail. Windows: 56 run, 56 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.

Checklist

  • Based on current main; no other open PR implements the same functions (#10488, which this PR was built on, has merged; no other open PR implements these 22)
  • 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; #10488, which this PR was built on, has merged. Any order with our #10878 and #10915, which set the same pending-exports count line in docs/dev/debt/libSceLibreSsl.md: whichever merges later recounts it in a main merge
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5001522006 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10834). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-25T03:37:07Z. --- ### What Implements 22 EVP cipher exports of libSceLibreSsl on the cipher-context object from #10488, following LibreSSL 2.5.4 (libressl/openbsd 2e2c612066aa, the version in the firmware 13.40 measurements): - `EVP_CIPHER_CTX_cleanup`, `EVP_CIPHER_CTX_free`, `EVP_CIPHER_CTX_ctrl` (evp_enc.c) - `EVP_CipherInit_ex`, `EVP_EncryptInit_ex`, `EVP_DecryptInit_ex`, `EVP_CipherUpdate`, `EVP_EncryptUpdate`, `EVP_DecryptUpdate`, `EVP_CipherFinal_ex`, `EVP_EncryptFinal_ex`, `EVP_DecryptFinal_ex`: buffering, PKCS padding and its checks, `EVP_CIPH_NO_PADDING`, IV setup per mode, and the custom-cipher path, called through the descriptor's function pointers (evp_enc.c) - `EVP_aes_{128,192,256}_cfb8` and `EVP_aes_{128,192,256}_ctr` on the AES from #9033 (e_aes.c, cfb128.c, ctr128.c; NIST SP 800-38A) - `EVP_aes_{128,192,256}_gcm`: GHASH and GCTR from gcm128.c, `aes_gcm_ctrl` (IV length, tag, fixed and generated IVs, TLS AAD, copy) and the TLS record path (e_aes.c; NIST SP 800-38D). Both tag checks compare every byte in constant time, as LibreSSL does with `timingsafe_memcmp` - `EVP_cleanup`: nothing in this module can fill the tables LibreSSL's names.c clears yet, so it returns; the debt entry says when that changes `include/Api.hpp` declares the 22 exports once, with their real signatures, as `main` asks since #10706. It holds LibreSSL's 88-byte `EVP_CIPHER` next to #10488's 168-byte `EVP_CIPHER_CTX`, whose `cipher` field this PR types as `const LibreSslEvpCipher*`; the layout is unchanged. `include/Evp.hpp` keeps the internal constants and the layout checks. Failures queue no error code, a non-null `ENGINE` throws, and inputs LibreSSL would dereference or overrun throw; the five new entries in `docs/dev/debt/libSceLibreSsl.md` list them. **Built on #10488**, which has merged. Its four commits are alvaroelpob's, unchanged, and are on `main` now, so this PR's diff over `main` is its own commits. Related: #10450 (`EVP_CIPHER_block_size`, merged; since f30dd4849a it takes this PR's `LibreSslEvpCipher`), #9571 (CMAC and the CBC descriptors over the same `EVP_CIPHER` layout). ### Tested - **d8ee395e44, these six commits rebased onto #10488's 6b1e364fc2.** In each commit, its exports move from `(void)` stubs to their real signatures in `include/Api.hpp`, and `include/Aes.hpp` is dropped, since `main`'s `Api.hpp` has `AesKey` and the `AES_*` calls. The test calls the exports with their public types through #10488's `Context()` helper; its checks and their messages are unchanged. - **Per commit:** each of the six commits builds with CI's flags on a Linux machine, and `ctest -R '^(guest_libressl|public_headers)'` passes at every one: 73 run, 73 pass. That's the eight LibreSSL tests, `public_headers` and its 64 compile batches. - **CI's Linux job, mirrored at the head:** 2,213 tests, 2,118 pass, 90 skip and 5 fail. The five are that machine's IPv6 tests. - **On GitHub's runners** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40169227907)): the eight `^guest_libressl` tests and `public_headers` pass 10 runs in a row, 9 run, 9 pass, 0 skip, 0 fail on Linux and on Windows. The libc and libkernel suites pass on both (144 and 207 tests on Linux, 171 and 223 on Windows), run with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **At 8f269fb332**, the previous head, on #10488's earlier head ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40159763558)): the `^guest_libressl` tests, 10 runs in a row. Linux: 7 run, 7 pass, 0 skip, 0 fail. Windows: 7 run, 7 pass, 0 skip, 0 fail. The libc and libkernel suites pass on both (123 and 204 tests on Linux, 150 and 217 on Windows), run with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - 8f269fb332 makes `GcmFinish` and the TLS decrypt path compare the tag in constant time, and `guest_libressl_evp_cipher_ctx` now flips each byte of the tag in turn, for every GCM vector's `EVP_DecryptFinal_ex` and for a TLS record, and requires each to be rejected. - Those cases also pass with 3b5f90d2a7's `std::memcmp`, which finds every difference too, so they check that the new compare reads every tag byte. The timing itself isn't tested. - **Earlier, at 3b5f90d2a7** ([run 40154572248](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40154572248)), with #10488's head as the comparison arm: `guest_libressl_evp_cipher_ctx`, `guest_libressl_aes`, `guest_libressl_digest`, `guest_libressl_des`, `guest_libressl_runtime`, `guest_libressl_x509_errors` and `guest_libressl3_digest` pass 10 of 10 on Linux and on Windows, 0 skipped. #10488's own code doesn't build against the new tests. The libc and libkernel suites pass on both. - Linux x86-64 (Ubuntu 24.04, gcc 13.3.0, wild 0.10.0), no title. `guest_libressl_evp_cipher_ctx` gains 17 cases: - SP 800-38A CFB8 (F.3.7–F.3.12) and CTR (F.5.1–F.5.6) for AES-128/192/256, through `EVP_Encrypt*`, `EVP_Decrypt*` and `EVP_Cipher*`; - GCM test cases 1–8, 13 and 14, with the IV length and tag set and read through `EVP_CIPHER_CTX_ctrl`, including wrong and truncated tags; - GCM TLS records, `EVP_CTRL_COPY`, and the ctrl error returns; - padding on and off, held-back blocks and bad padding, with a test-defined block cipher; - the Init mode and IV handling, and the custom-cipher and stream paths. - Each commit's new cases fail against the code before it and pass with it. CI-configured build, then `ctest` as an unprivileged user: 2,054 tests, 1,961 passed, 88 skipped and 5 failed. The five need IPv6, which the test machine lacks: `guest_net_buffer_validation`, `guest_socket_options`, `guest_socket_stream_options`, `guest_socket_address_length` and `guest_tcp`. - **820d1c0fe7, merges of #10488's b188b78b5f and of `main` 7e4f6e0440** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40215673533)). Dean Galvin's merge of `main` into #10488 and `main`'s #10484 add lines next to this PR's in the LibreSSL debt file; the merges keep both sides. The first also sets the pending-exports count to what is left: `Export.cpp` now has 320 `NotImplemented` exports, the base's 342 less this PR's 22. The `guest_libressl` tests and `public_headers` pass 10 runs in a row. Linux: 12 run, 12 pass, 0 skip, 0 fail. Windows: 12 run, 12 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **5e9371dcb8, this PR's six commits rebased onto #10488's 9a3cb4ef57** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40232660358)), after alvaroelpob rebased #10488 onto `main` ae7d59258e. The code is unchanged; only the lines around it moved, where `main` changed the LibreSSL debt file and the `add_library` source list. A seventh commit sets the pending-exports count to 317, the `NotImplemented` exports left in `Export.cpp`: #10488's 339 less this PR's 22. The `guest_libressl` tests and `public_headers` pass 10 runs in a row. Linux: 13 run, 13 pass, 0 skip, 0 fail. Windows: 13 run, 13 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **Firmware 13.42's `libSceLibreSsl.sprx`, run by BunnyFl** ([comment](https://github.com/boykopovar/AnyPS5/pull/10834#issuecomment-6402988063)): the module's own code, in an emulator (Unicorn) and natively on x86-64 for the AES calls, gave identical results in four runs each, and they agree with the `EVP_CIPHER` and `EVP_CIPHER_CTX` layouts here. - All nine AES descriptors match: NIDs, block size, IV and key lengths, flags, `ctx_size`, and which hooks are set. - The `EVP_CIPHER_CTX` offsets match through `EVP_EncryptInit_ex` and `EVP_EncryptUpdate` with AES-128 CTR, and through a padded AES-128 CBC decrypt. - #10488's `EVP_CIPHER_CTX_set_padding` sets and clears bit 0x100 of the word at 112, changes no other byte, and returns 1. - The firmware 13.40 console measurements covered only the 168-byte init. - **d5e55453be, a merge of `main` 5e90e7569d** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40321300521)). `main`'s 9a848d0b99 implements the TLS alert descriptions and lowers the pending-export count in `docs/dev/debt/libSceLibreSsl.md` from 342 to 341, on the line this PR sets. The merge keeps `main`'s change and sets the count to 316, the `NotImplemented_nid_no_patch` exports left in the merged `Export.cpp`. Nothing else conflicted, #10488's four commits are unchanged, and this PR's other changed lines are the same. The 13 `guest_libressl` tests pass 10 runs in a row. Linux: 13 run, 13 pass, 0 skip, 0 fail. Windows: 13 run, 13 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (145 and 210) and on Windows (174 and 231). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **b8d832765e and f129b2fde7, following the rule that tests don't require a placeholder to throw, and a merge of `main` 84e91df418** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40339974856)). b8d832765e drops the cipher-context test's two checks that required `EVP_CIPHER_CTX_cleanup` with an `ENGINE` set, and `EVP_EncryptInit_ex` given one, to throw. The calls still refuse an `ENGINE`, as the debt entry says, and the null-pointer, malformed-context and invalid-length checks stay. f129b2fde7 merges `main`, whose #9745 (`SSLeay`) lowers the pending-export count in `docs/dev/debt/libSceLibreSsl.md` to 340, on the line this PR sets; the merge keeps it and sets 315, the `NotImplemented_nid_no_patch` exports left in the merged `Export.cpp`. Nothing else conflicted, #10488's four commits are unchanged, and this PR's other changed lines are the same. The `guest_libressl` tests with the tests for the files the merge changes, 23 of them, pass 10 runs in a row. Linux: 23 run, 23 pass, 0 skip, 0 fail. Windows: 23 run, 23 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (145 and 211) and on Windows (174 and 232). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **2b7040e434, this PR's eight commits rebased onto #10488's 10f8980dd5** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40886159749)), after alvaroelpob rebased #10488 onto `main` 4c7d275bef. The code is unchanged, and the two merges of `main` drop out with the rebase. Three places took the new base's lines around this PR's: - `include/Api.hpp`: `main`'s stack, UI, RSA and X509 store-context structs now sit above this PR's `LibreSslEvpCipher`. Both are kept. - The `add_library` line: this PR still adds one file, `src/EvpAes.cpp`, now to `main`'s longer source list. - The pending-export count in `docs/dev/debt/libSceLibreSsl.md` is now 274. That's the number of `NotImplemented_nid_no_patch` calls left in the rebased `Export.cpp`; the same count gives the line's 296 on #10488's head and 299 on `main`. - The `^guest_libressl` tests and `public_headers` ran 10 times with no failure. Linux: 34 run, 34 pass, 0 skip, 0 fail. Windows: 34 run, 34 pass, 0 skip, 0 fail. The libc and libkernel suites run 191 and 291 tests on Linux and 220 and 314 on Windows, with 0 failed. They ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **bc39d79482, this PR's eight commits rebased onto #10488's ea1a21792f** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41139739041)), after alvaroelpob rebased #10488 onto `main` da026c7065. - `git range-diff`: six commits are unchanged, the first changes only in a context line of the debt file, where #10488's X509 store-context entry moved, and the seventh only in the pending-export count. - The count is now 268, the `NotImplemented_nid_no_patch` calls left in the rebased `Export.cpp`: 290 on #10488's new head, less this PR's 22. - It merges cleanly with `main`, so no merge was needed, and the count holds on the merged tree. - **×10:** the `^guest_libressl` tests, `public_headers` and its 64 compile batches. Linux: 99 run, 99 pass, 0 skip, 0 fail. Windows: 99 run, 99 pass, 0 skip, 0 fail. The libc and libkernel suites run 198 and 307 tests on Linux and 225 and 327 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **0c989744ea, a merge of `main` c12e7e61a1** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41161962760)), which brings JaceTheBlu's #13562 (`OBJ_create` and `OBJ_cleanup`). #10488's head ea1a21792f is still this branch's base. - **The one conflict** was the pending-exports count in `docs/dev/debt/libSceLibreSsl.md`: `main` reads 292 after #13562, and the merged `Export.cpp` has 267 calls left that go through `NotImplemented_nid_no_patch`, so the entry now says 267. `CMakeLists.txt`, `Export.cpp` and `Api.hpp` merged without conflicts. - **One sentence beyond keeping both sides:** this PR's `EVP_cleanup` entry listed `OBJ_create` and `OBJ_cleanup` among the calls that aren't implemented, which #13562 made untrue. It now says that `OPENSSL_add_all_algorithms_noconf`, `SSL_library_init`, `CONF_modules_load_file`, `OPENSSL_load_builtin_modules` and `PKCS12_PBE_add` aren't implemented and that no cipher or digest can be registered under an `OBJ_create` NID to defer `OBJ_cleanup`. So `EVP_cleanup` still has nothing to clear: in LibreSSL 2.5.4 (2e2c612066, `evp/names.c` and `objects/obj_dat.c`), `EVP_cleanup` calls `OBJ_cleanup` only after `EVP_add_cipher` or `EVP_add_digest` has registered such a NID, and neither exists here. The merge commit's message names it. - This PR's other changed lines are the same. - **×10:** `^guest_libressl` and `public_headers`. Linux: 35 run, 35 pass, 0 skip, 0 fail. Windows: 35 run, 35 pass, 0 skip, 0 fail. The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **85e42b7647, a merge of `main` 0a148be963** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41264448816)), which brings #13760 (`GENERAL_NAME_free` and `GENERAL_NAMES_free`) and #13820 (SHA-384 and SHA-512 initialization buffers). - **The one conflict** was `docs/dev/debt/libSceLibreSsl.md`, where the merge keeps both sides' entries. The pending-exports count is recounted on the merged tree: `main`'s line was 2 above its own total (292 against 290 calls left in its `Export.cpp`), so this PR's 267 is now 265, the `NotImplemented_nid_no_patch` calls left in the merged `Export.cpp`. - **×10:** `^guest_libressl` and `public_headers`. Linux: 39 run, 39 pass, 0 skip, 0 fail. Windows: 39 run, 39 pass, 0 skip, 0 fail. The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **9f70186b52: this PR's eight commits restacked onto #10488's 16d0e81b02, then one docs commit** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41273075963)), after alvaroelpob rebased #10488 onto `main` cf79276fee. - **`git range-diff`:** six commits are unchanged. The first changes only in a context line of the debt file, the `PKCS12_PBE_add` entry that `main`'s #13562 rewrote. The seventh changes only in the pending-exports count and a context line, the Digest entry that #13820 extended. - **The count** is 265, the `NotImplemented_nid_no_patch` calls left in the restacked `Export.cpp`: 287 on #10488's new head, less this PR's 22. - **9f70186b52** ("docs(libSceLibreSsl): update the EVP_cleanup entry for OBJ_create and OBJ_cleanup") carries 0c989744ea's `EVP_cleanup` sentence (above) into the restacked commits, since that sentence was in the merge commit. After it, the debt file is the same as at 85e42b7647, and `git diff 85e42b7647 9f70186b52` over `core/libs/prx/libSceLibreSsl` and the debt file is empty. The two earlier merges of `main` are no longer in the branch's history. - It merges cleanly with `main` bbe8cf31c1, so no merge was needed. - **×10:** `^guest_libressl` and `public_headers`. Linux: 39 run, 39 pass, 0 skip, 0 fail. Windows: 39 run, 39 pass, 0 skip, 0 fail. The libc and libkernel suites run 199 and 308 tests on Linux and 226 and 330 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **8ea13cc9ea: merges of `main` 88e804b0a7 (ba51e03631) and 24238c4cb1 (8ea13cc9ea), with a recount between them (64b0d96659)** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41442049212), on 8ea13cc9ea). - **ba51e03631** brings Felipebmaitan's #9535 (error queues) and atharvjairath's #10078 (`X509_EXTENSION` getters). Two conflicts, both resolved by keeping both sides: in `Export.cpp`, #9535 removes the `ERR_error_string` stubs next to the `EVP_CIPHER_CTX` stubs this PR removes, and the pending-exports count line in `docs/dev/debt/libSceLibreSsl.md`. - **64b0d96659** sets the count to 259, the `NotImplemented_nid_no_patch` calls left in the merged `Export.cpp` (#9535 and #10078 implement three each). - **8ea13cc9ea** brings alvaroelpob's #10488 as it merged on `main`, which this branch already carried. After the first merge, GitHub reported the branch as conflicting: with #10488 merged on `main`, the branch had two merge bases, and with either one alone the merge conflicts. This merge leaves one. It merged without conflicts, the count stays 259, and this PR's changed lines over `main` are the same as they were over #10488's head. - **×10:** the `^guest_libressl` tests, with `guest_libressl_evp_cipher_ctx` and `public_headers`. Linux: 44 run, 44 pass, 0 skip, 0 fail. Windows: 44 run, 44 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **0143584d76, a merge of `main` b28bb77217** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41483831827)), which brings HQasper's #9448 (the EVP message digest and HMAC functions). - **Four conflicting files, all resolved by keeping both sides:** - the `add_library` source list in `CMakeLists.txt`, where #9448 adds `src/Evp.cpp` and this PR `src/EvpAes.cpp`; - `Export.cpp`, where #9448 removes its digest and HMAC stubs next to the cipher stubs this PR removes; - `include/Api.hpp`, where #9448 adds its digest and HMAC types next to this PR's `LibreSslEvpCipher`, and each side gives its own exports their real signatures in the same declaration lists; - `docs/dev/debt/libSceLibreSsl.md`, which keeps #9448's new entry. - **The count** is 239, the `NotImplemented_nid_no_patch` calls left in the merged `Export.cpp`: `main`'s 261, which its line now matches, less this PR's 22. - This PR's other changed lines over `main` are the same, and it merges cleanly with `main` a4eca2a056. - **×10:** the `^guest_libressl` tests, with `guest_libressl_evp_cipher_ctx` and `public_headers`. Linux: 46 run, 46 pass, 0 skip, 0 fail. Windows: 46 run, 46 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (217 and 319) and on Windows (244 and 340). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **319b7072de, a merge of `main` 4f41f4c375** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41613053062)), which brings Felipebmaitan's #9571 (CMAC with the AES-CBC ciphers). - **The conflicts, each resolved by keeping both sides:** - `CMakeLists.txt`'s `add_library` source list: the union of both sides' sources, each once; - `Export.cpp`: this PR's removal of the CFB8, CTR, GCM and `EVP_cleanup` stubs, and `main`'s removal of the CBC stubs; - `include/Api.hpp`: `main`'s ERR signatures and CBC getters, and this PR's context, CFB8, CTR, GCM and `EVP_cleanup` declarations; - `docs/dev/debt/libSceLibreSsl.md`: the merged `Export.cpp` has 209 `NotImplemented` exports, so the pending-exports entry now says 209 (this PR said 239, `main` 231). - **The two cipher types:** `main`'s CBC getters return its `LibreSslCipher` (`Cmac.hpp`), and this PR's `EVP_CipherInit_ex` takes its `LibreSslEvpCipher`. Their fields match in order and size, as do `main`'s `LibreSslCipherContext` and this PR's `LibreSslEvpCipherCtx` (`main` asserts 168 bytes, with `iv` at 40, `flags` at 112 and `cipherData` at 120). 8a9ab924f9's test passes `main`'s `EVP_aes_128_cbc()` through this PR's context (see below). - No function is in both PRs, and this PR's other lines are unchanged. - **×10:** every `^guest_libressl` test. Linux: 51 run, 51 pass, 0 skip, 0 fail. Windows: 51 run, 51 pass, 0 skip, 0 fail. The libc and libkernel suites run 300 and 322 tests on Linux and 327 and 342 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **AMD:** TechLevelZero's AMD bot ran this head merged onto `main` 4f41f4c: AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8; [report](https://github.com/boykopovar/AnyPS5/pull/10834#issuecomment-6604570792)): 1,147 passed, 6 failed, none new (4 also fail on `main`, 2 unstable on `main`), 6 skipped, with no new validation IDs (551 tests on the GPU). - **6e3ccd8ff3, debt corrections** (docs only), for XairRrR's [review](https://github.com/boykopovar/AnyPS5/pull/10834#pullrequestreview-5752949523). The EVP context entry no longer gives `ERR_get_error` and `ERR_peek_error` as the reason no error is queued, the `EVP_cleanup` entry says `PKCS12_PBE_add` is empty as in LibreSSL 2.5.4, and the CMAC entry says that, of the EVP cipher exports, only `EVP_CIPHER_block_size` still throws. - **AMD:** TechLevelZero's AMD bot ran this head merged onto `main` 4f41f4c: AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8; [report](https://github.com/boykopovar/AnyPS5/pull/10834#issuecomment-6607449482)): 1,147 passed, 6 failed, none new (4 also fail on `main`, 2 unstable on `main`), 6 skipped, with no new validation IDs (551 tests on the GPU). - **8a9ab924f9, a CBC round trip** (test-only, `GuestLibreSslEvpCipherCtx.cpp`), for the same review's point 4. `main`'s `EVP_aes_128_cbc()` descriptor goes through this PR's `EVP_EncryptInit_ex` and `EVP_DecryptInit_ex`, `Update` and `Final` with the CBC-AES128 vectors of NIST SP 800-38A F.2.1 and F.2.2: encryption and decryption without padding, and a round trip with PKCS#7 padding, in chunks of 1, 7, 16 and 64 bytes. It covers code that already works, so it has no red. - **×10** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41659686265)): every `^guest_libressl` test. Linux: 51 run, 51 pass, 0 skip, 0 fail. Windows: 51 run, 51 pass, 0 skip, 0 fail. The libc and libkernel suites run 300 and 322 tests on Linux and 327 and 342 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **da37daf69f, a merge of `main` 9ab6a281ea** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41881246648)), which brings MatteoSid's #10395 (EC groups and keys). - **The conflicts, each resolved by keeping both sides:** - `CMakeLists.txt`'s `add_library` source list: `main` adds `src/Ec.cpp` and this PR `src/EvpAes.cpp`, and the line keeps both; - `docs/dev/debt/libSceLibreSsl.md`: the merged `Export.cpp` has 200 `NotImplemented` exports, so the pending-exports entry now says 200 (this PR said 209, `main` 222). - No function is in both PRs, and this PR's other lines are unchanged. - **×10:** every `^guest_libressl` test, with `public_headers`. Linux: 54 run, 54 pass, 0 skip, 0 fail. Windows: 54 run, 54 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 327 tests on Linux and 335 and 354 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **c83992150b, a merge of `main` b611e634f7** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41909280115)), which brings LordVersA's #11662 (`SSL_library_init`). - **The conflict:** the pending-exports count in `docs/dev/debt/libSceLibreSsl.md`, which both sides changed. The merged `Export.cpp` had 199 `NotImplemented` exports, so the entry said 199 (this PR said 200, `main` 221). No function is in both PRs, and this PR's other lines are unchanged. - **×10:** every `^guest_libressl` test, with `public_headers`. Linux: 54 run, 54 pass, 0 skip, 0 fail. Windows: 54 run, 54 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **f30dd4849a, a merge of `main` d63781e9ce** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41928343817)), which brings alvaroelpob's #10450 (`EVP_CIPHER_block_size`). - **The conflicts:** - `include/Api.hpp`: #10450 adds its own `LibreSslEvpCipher`, with this PR's 13 fields in the same order but its function pointers as `void*`. The merge keeps this PR's typed definition, since `EvpCipherCtx.cpp` calls through those pointers, and declares `EVP_CIPHER_block_size` with `main`'s `const LibreSslEvpCipher*`. `main`'s `EvpCipher.cpp` reads only `blockSize`, and its layout checks (88 bytes, `blockSize` at 4, `init` at 24, `contextSize` at 48) hold for the typed struct. - `Export.cpp`: both sides' stub removals are kept, so no EVP cipher stub is left. - `CMakeLists.txt`'s `add_library` source list: `main` adds `src/EvpCipher.cpp` and this PR `src/EvpAes.cpp`, and the line keeps both. - `docs/dev/debt/libSceLibreSsl.md`: `main`'s `EVP_CIPHER_block_size` entry and this PR's five are kept. The merged `Export.cpp` had 198 `NotImplemented` exports, so the pending-exports entry said 198 (this PR said 199, `main` 220). - **Two debt sentences that `main` made untrue** are corrected, as the merge commit's message says. The CMAC entry drops "Of the EVP cipher exports, only `EVP_CIPHER_block_size` still throws" (#10450). The `EVP_cleanup` entry no longer lists `SSL_library_init` (#11662) among the calls that aren't implemented: it now says `SSL_library_init` returns 1 without adding a cipher or digest, so `EVP_cleanup` still has nothing to clear. - **×10:** every `^guest_libressl` test (now including #10450's `guest_libressl_evp_cipher`) and `public_headers`. Linux: 55 run, 55 pass, 0 skip, 0 fail. Windows: 55 run, 55 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - **db6537d1c7, a merge of `main` 9f9e420709** ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/41937674854)), which brings alvaroelpob's #10448 (`OCSP_response_status`, `OCSP_single_get0_status`). - **The conflicts:** - `include/Api.hpp`, where #10448 adds four OCSP structs right after `main`'s copy of `LibreSslEvpCipher`. The merge keeps the four structs and this PR's single typed definition. - `CMakeLists.txt`'s `add_library` source list, where `main` adds `src/OcspResponse.cpp` and this PR `src/EvpAes.cpp`. The line keeps both. - `docs/dev/debt/libSceLibreSsl.md`, which keeps #10448's OCSP entry beside this PR's five. The merged `Export.cpp` has 196 `NotImplemented` exports, so the pending-exports entry now says 196 (this PR said 198, `main` 218). - No function is in both PRs, and this PR's other lines are unchanged. - **×10:** every `^guest_libressl` test (now including #10448's `guest_libressl_ocsp_response`) and `public_headers`. Linux: 56 run, 56 pass, 0 skip, 0 fail. Windows: 56 run, 56 pass, 0 skip, 0 fail. The libc and libkernel suites run 303 and 329 tests on Linux and 335 and 360 on Windows, with 0 failed. The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. ### 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 (#10488, which this PR was built on, has merged; no other open PR implements these 22) - [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; #10488, which this PR was built on, has merged. Any order with our #10878 and #10915, which set the same pending-exports count line in `docs/dev/debt/libSceLibreSsl.md`: whichever merges later recounts it in a `main` merge - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-25 03:45:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T03:45:18Z.

Review: CHANGES_REQUESTED


Reviewed head 3b5f90d2a7355169cdcbed6a95608a19423ddd80. The current conventions check also fails because the first PR checklist item remains unchecked. The test run linked in the PR body is described as running against #10488's head, so I did not count it as a run on this exact head. I compiled the changed implementation and test translation units with the project's Linux compile flags; syntax compilation passed. Please address the GCM tag comparisons below, then rerun the cipher-context tests on the refreshed head and update the checklist after verifying the rebased base/overlap claims.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641384238 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10834#pullrequestreview-5641384238). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T03:45:18Z. **Review:** CHANGES_REQUESTED --- Reviewed head `3b5f90d2a7355169cdcbed6a95608a19423ddd80`. The current conventions check also fails because the first PR checklist item remains unchecked. The test run linked in the PR body is described as running against #10488's head, so I did not count it as a run on this exact head. I compiled the changed implementation and test translation units with the project's Linux compile flags; syntax compilation passed. Please address the GCM tag comparisons below, then rerun the cipher-context tests on the refreshed head and update the checklist after verifying the rebased base/overlap claims.
MarcZX10 commented 2026-10-25 04:44:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:44:29Z.

Review: COMMENTED


Follow-up on exact head 8f269fb3323c4e84bb47e607babb9a81f18d7514: the earlier GCM authentication timing issue is fixed. Both GcmFinish and the TLS decrypt path now use the full-length accumulator comparison rather than memcmp; the new tests flip each tag byte for vector GCM and TLS records and require rejection.

I verified the linked run 40159763558 uses a verification commit whose parent is this exact head, then inspected its uploaded summaries: the focused ^guest_libressl set passed 7/7 for 10 repetitions on both Linux and Windows (no skips), and the libc/libkernel suites also passed (123/204 Linux; 150/217 Windows). The comparison detects functional rejection, not timing behavior; the fixed-iteration volatile-load implementation is the code evidence for constant-time comparison. git diff --check passes locally.

The remaining conventions failure is still the unchecked “Based on current main” template item. The PR description explains that this draft is intentionally stacked on #10488, which currently conflicts with main; I agree that the box should stay unchecked until the branch is refreshed rather than claiming the condition is already met. I am not approving this draft while that base/checklist state remains unresolved.

AI-assisted review: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641568121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10834#pullrequestreview-5641568121). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T04:44:29Z. **Review:** COMMENTED --- Follow-up on exact head `8f269fb3323c4e84bb47e607babb9a81f18d7514`: the earlier GCM authentication timing issue is fixed. Both `GcmFinish` and the TLS decrypt path now use the full-length accumulator comparison rather than `memcmp`; the new tests flip each tag byte for vector GCM and TLS records and require rejection. I verified the linked run 40159763558 uses a verification commit whose parent is this exact head, then inspected its uploaded summaries: the focused `^guest_libressl` set passed 7/7 for 10 repetitions on both Linux and Windows (no skips), and the libc/libkernel suites also passed (123/204 Linux; 150/217 Windows). The comparison detects functional rejection, not timing behavior; the fixed-iteration volatile-load implementation is the code evidence for constant-time comparison. `git diff --check` passes locally. The remaining conventions failure is still the unchecked “Based on current main” template item. The PR description explains that this draft is intentionally stacked on #10488, which currently conflicts with main; I agree that the box should stay unchecked until the branch is refreshed rather than claiming the condition is already met. I am not approving this draft while that base/checklist state remains unresolved. AI-assisted review: yes.
ahmadmuj commented 2026-10-25 19:01:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T19:01:30Z.

Review: APPROVED


Reviewed head 820d1c0, merged locally onto main a7a2eec (clean). Linux, GCC 13.3, Release.

What I ran:

  • Built guest_libressl_evp_cipher_ctx_tests on the merge. ctest -R ^guest_libressl_evp_cipher_ctx$ passes, and so does check_conventions.py --base origin/main.
  • A differential against real LibreSSL 2.5.4 (release tarball, static libcrypto.a, asm/AES-NI build). One process links both libcrypto.a and libSceLibreSsl.prx, runs each scenario on both, and compares return values, outl, the whole output buffer and all 168 EVP_CIPHER_CTX bytes (pointer fields masked). 19,161 cases:
    • a test-defined cipher with block size 1/8/16, every mode, the CUSTOM_CIPHER / CUSTOM_IV / ALWAYS_CALL_INIT / CTRL_INIT combinations, random chunking with 0 and -1 lengths, padding on and off, bad padding (inner byte, 0, bs+1), re-init with a NULL cipher or key, enc -1
    • AES-128/192/256 CFB8 and CTR, including the 128-bit counter wrap
    • GCM with IV lengths 1/12/13/16/17/64, split AAD, GET_TAG/SET_TAG 0-17, wrong tags, SET_IV_FIXED, IV_GEN with carry and odd args, SET_IV_INV, TLS1_AAD records with a tampered tag or body and short records
  • Every return value, outl and output byte matches. The layouts match too: EVP_CIPHER 88 and EVP_CIPHER_CTX 168 with every field offset, and all 9 AES descriptors (nid, sizes, flags, ctx_size 264/680).
  • Mutation check: 17 small mutants each fail the test. They cover the pad checks, outl, the CBC IV copy, ctrl -1, the held final block, the GCM hash for non-12-byte IVs, the TLS wipe, the IV_GEN increment, the tag check, CFB8 feedback, the AAD flush, the SET_IV_INV offset and the CTR num reset.
  • Read EvpCipherCtx.cpp and EvpAes.cpp against 2.5.4 evp_enc.c, e_aes.c, gcm128.c and cfb128.c.

The only differences:

  • After whole-block updates, AES-CTR leaves the last keystream block in ctx->buf. 2.5.4's AES-NI path (CRYPTO_ctr128_encrypt_ctr32, ctr128.c:239) writes it only for a partial tail. Example: AES-128-CTR, zero key and IV, one 16-byte update. Real buf stays zero; the PR's buf is 66e94bd4.... The non-asm 2.5.4 path behaves like the PR, and buf isn't read while num is 0, so I don't think it matters.
  • The documented throws (CTR iv_len 17, IV_GEN with an IV under 8 bytes, SET_IV_INV past the IV) fire only where 2.5.4 writes outside the field.

Small notes, not blocking:

  • The body says the tag check is constant-time "as LibreSSL does with timingsafe_memcmp". In 2.5.4 the EVP GCM path uses plain memcmp (gcm128.c:1518, and e_aes.c:979 for TLS). timingsafe_memcmp is only in the EVP_AEAD code (e_aes.c:1507). Constant-time is fine and the results are the same; only the attribution is off.
  • #10488 has been rebased (now 3b0f1cd). This branch still carries its older commits, so it needs a rebase once #10488 lands. The three functions there are the same text. Only the type of cipher differs (const void* there).
  • #10450 also defines struct LibreSslEvpCipher in Api.hpp, with the same layout and void* callbacks. Whichever PR merges second has to drop one.

Not checked: the console, Windows, the ENGINE paths.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644766010 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10834#pullrequestreview-5644766010). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T19:01:30Z. **Review:** APPROVED --- Reviewed head 820d1c0, merged locally onto main a7a2eec (clean). Linux, GCC 13.3, Release. What I ran: - Built `guest_libressl_evp_cipher_ctx_tests` on the merge. `ctest -R ^guest_libressl_evp_cipher_ctx$` passes, and so does `check_conventions.py --base origin/main`. - A differential against real LibreSSL 2.5.4 (release tarball, static `libcrypto.a`, asm/AES-NI build). One process links both `libcrypto.a` and `libSceLibreSsl.prx`, runs each scenario on both, and compares return values, `outl`, the whole output buffer and all 168 `EVP_CIPHER_CTX` bytes (pointer fields masked). 19,161 cases: - a test-defined cipher with block size 1/8/16, every mode, the CUSTOM_CIPHER / CUSTOM_IV / ALWAYS_CALL_INIT / CTRL_INIT combinations, random chunking with 0 and -1 lengths, padding on and off, bad padding (inner byte, 0, bs+1), re-init with a NULL cipher or key, enc -1 - AES-128/192/256 CFB8 and CTR, including the 128-bit counter wrap - GCM with IV lengths 1/12/13/16/17/64, split AAD, GET_TAG/SET_TAG 0-17, wrong tags, SET_IV_FIXED, IV_GEN with carry and odd args, SET_IV_INV, TLS1_AAD records with a tampered tag or body and short records - Every return value, `outl` and output byte matches. The layouts match too: `EVP_CIPHER` 88 and `EVP_CIPHER_CTX` 168 with every field offset, and all 9 AES descriptors (nid, sizes, flags, ctx_size 264/680). - Mutation check: 17 small mutants each fail the test. They cover the pad checks, `outl`, the CBC IV copy, ctrl -1, the held final block, the GCM hash for non-12-byte IVs, the TLS wipe, the IV_GEN increment, the tag check, CFB8 feedback, the AAD flush, the SET_IV_INV offset and the CTR `num` reset. - Read `EvpCipherCtx.cpp` and `EvpAes.cpp` against 2.5.4 `evp_enc.c`, `e_aes.c`, `gcm128.c` and `cfb128.c`. The only differences: - After whole-block updates, AES-CTR leaves the last keystream block in `ctx->buf`. 2.5.4's AES-NI path (`CRYPTO_ctr128_encrypt_ctr32`, ctr128.c:239) writes it only for a partial tail. Example: AES-128-CTR, zero key and IV, one 16-byte update. Real `buf` stays zero; the PR's `buf` is `66e94bd4...`. The non-asm 2.5.4 path behaves like the PR, and `buf` isn't read while `num` is 0, so I don't think it matters. - The documented throws (CTR iv_len 17, IV_GEN with an IV under 8 bytes, SET_IV_INV past the IV) fire only where 2.5.4 writes outside the field. Small notes, not blocking: - The body says the tag check is constant-time "as LibreSSL does with `timingsafe_memcmp`". In 2.5.4 the EVP GCM path uses plain `memcmp` (gcm128.c:1518, and e_aes.c:979 for TLS). `timingsafe_memcmp` is only in the EVP_AEAD code (e_aes.c:1507). Constant-time is fine and the results are the same; only the attribution is off. - #10488 has been rebased (now 3b0f1cd). This branch still carries its older commits, so it needs a rebase once #10488 lands. The three functions there are the same text. Only the type of `cipher` differs (`const void*` there). - #10450 also defines `struct LibreSslEvpCipher` in `Api.hpp`, with the same layout and `void*` callbacks. Whichever PR merges second has to drop one. Not checked: the console, Windows, the ENGINE paths.
XairRrR commented 2026-11-03 13:25:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T13:25:32Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The cipher code follows LibreSSL 2.5.4, it builds, the focused tests pass, and the tests fail when I break the code, but two statements in docs/dev/debt/libSceLibreSsl.md are now false on the merged tree.

What I ran

Head 319b7072dea61cdb439af0e8319ba33321f667e9, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged with --no-ff in a clean worktree (Release, GCC 14.2.0, Ninja, Debian 13, 32 vCPU Xeon Gold 6136).

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...319b7072dea61cdb439af0e8319ba33321f667e9
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
grep -c "NotImplemented_nid_no_patch(__func__)" core/libs/prx/libSceLibreSsl/Export.cpp
ctest --test-dir build -j8 --test-load 32 -R "libressl|public_headers" --output-on-failure
ctest --test-dir build -R "evp_cipher_ctx|cmac" --output-on-failure
# negative control: production files from main, then targeted mutations (below)
ninja -C build -j32 -l32 guest_libressl_evp_cipher_ctx_tests
ctest --test-dir build -R "^guest_libressl_evp_cipher_ctx$" --output-on-failure

Results

Check Result
git diff --check clean
check_conventions.py "All conventions checks passed."
Build (script, merged tree) OK
Script test run (843 tests) 841 passed, 1 expected skip, 1 known failure on main (unwrap_self_..._group), no new failures
-R "libressl|public_headers" 116/116 passed, 76.8 s total. guest_libressl_evp_cipher_ctx takes 0.01 s
Pending-exports count 209 NotImplemented_nid_no_patch(__func__) calls in the merged Export.cpp, which matches the debt line (231 on main minus 22)
Vulkan validation not applicable (no AGC/shader/VideoOut change)

Negative control

  • All production files from main (CMakeLists.txt, Export.cpp, include/Api.hpp, src/EvpCipherCtx.cpp restored; include/Evp.hpp and src/EvpAes.cpp moved aside): guest_libressl_evp_cipher_ctx_tests no longer compiles ('LibreSslEvpCipher' does not name a type, too many arguments to function 'int EVP_CIPHER_CTX_cleanup_nid_postfix()').
  • Padding check removed in DecryptFinal (the ctx->final[--block] != pad comparison) plus the tag compare forced to 0: the test aborts at line 440 (the bad-padding case).
  • Tag compare forced to 0 alone (TimingSafeCompare returns 0): the test aborts at line 889 (the wrong-tag GCM case).
  • Afterwards I restored the merged files and rebuilt. The test passes again, and git status --porcelain is empty.

Rebuilding after the CMakeLists.txt revert made CMake regenerate, and that failed in the sandbox on files the build user doesn't own. I re-created those build-tree files under my user; the source tree was not changed.

Findings

Blocking

  1. The debt entry gives a reason that main has made false. docs/dev/debt/libSceLibreSsl.md:31 says "A failure returns 0 without queueing an error code, because ERR_get_error and ERR_peek_error are not implemented." Since #9535 they are implemented (Error.cpp L60-L62). The same module's CMAC code already queues EVP errors through LibreSslPutError_nid_no_patch (Cmac.cpp L30-L33). The PR description itself mentions that #9535 merged. As written, a title that calls ERR_get_error after a failed EVP_DecryptFinal_ex gets 0, and the debt file blames a gap that no longer exists.

    • Fix: either queue LibreSSL's EVPerr reasons at the failure returns in EvpCipherCtx.cpp (as Cmac.cpp does), or reword the entries at lines 31 and 32 to say plainly that no error is queued, without the false reason.
  2. The CMAC entry still says the general EVP cipher exports throw. docs/dev/debt/libSceLibreSsl.md:41 (CMAC and AES-CBC descriptors) ends with "Other built-in cipher selectors and the general EVP cipher exports still throw." With this PR, EVP_CipherInit_ex/Update/Final, the CFB8, CTR and GCM selectors, and the EVP_CIPHER_CTX calls are implemented. CONTRIBUTING requires a PR that closes a gap to remove the entry or cut it to what is still open.

    • Fix: cut that sentence to the selectors that still throw.

Non-blocking

  1. The EVP_cleanup entry says PKCS12_PBE_add is not implemented. docs/dev/debt/libSceLibreSsl.md:35 lists PKCS12_PBE_add among the calls that "are not implemented". On main it is implemented as an empty function (Export.cpp:494), with its own entry at line 28 citing that it is empty in LibreSSL 2.5.4. The conclusion (nothing can fill the PBE table) still holds, but the reason should say that PKCS12_PBE_add adds nothing in 2.5.4.

  2. Two types describe the same EVP_CIPHER and EVP_CIPHER_CTX.

    • LibreSslEvpCipher/LibreSslEvpCipherCtx (core/libs/prx/libSceLibreSsl/include/Api.hpp:310) duplicate LibreSslCipher/LibreSslCipherContext in include/Cmac.hpp:9. Both are 88/168 bytes with the same offsets.
    • EVP_aes_*_cbc returns const LibreSslCipher*, while EVP_EncryptInit_ex takes const LibreSslEvpCipher*. A guest won't notice (the layouts agree), but host code and tests cannot pass a CBC descriptor to the new calls without a cast.
    • No test runs AES-CBC, the most common guest use, through the new EVP_Encrypt*/EVP_Decrypt* path. Only a test-defined block cipher covers the padding paths.
    • Suggestion: use one type for both, or at least add a test that runs EVP_aes_128_cbc() through EVP_EncryptInit_ex/EVP_DecryptFinal_ex with an SP 800-38A CBC vector.

Code read against LibreSSL 2.5.4 (no defects found)

I compared these against 2.5.4's evp_enc.c, e_aes.c and gcm128.c:

  • EVP_CipherInit_ex, EVP_EncryptUpdate, EVP_DecryptUpdate, EVP_EncryptFinal_ex, EVP_DecryptFinal_ex, EVP_CIPHER_CTX_cleanup and EVP_CIPHER_CTX_ctrl;
  • aes_gcm_init_key, aes_gcm_ctrl (INIT, IVLEN, SET/GET_TAG, IV_FIXED, IV_GEN, SET_IV_INV, TLS1_AAD, COPY), aes_gcm_cipher and aes_gcm_tls_cipher;
  • CRYPTO_gcm128_setiv, aad, encrypt/decrypt, finish and tag.

Control flow and return values match. The extra throws are the ones listed in the debt entries. MarcZX10's earlier request for constant-time tag compares is addressed: both compares go through TimingSafeCompare, and my mutation confirms the wrong-tag cases fail without it.

Not verified

  • Nothing was run on a console or against the firmware module. I did not check the descriptor values (NIDs, flags, ctx_size 264/680) against firmware myself; they match my reading of e_aes.c, and the description cites BunnyFl's firmware 13.42 run.
  • Windows/MinGW build.
  • AES-CBC (from Cmac.cpp) through the new EVP calls; it is not exercised by any test.
  • Timing behaviour of the tag compare; only its result is tested.

To get this to a good state

  • Fix the error-queue statement in debt entries 31 and 32: queue the EVP errors as Cmac.cpp does, or drop the false reason.
  • Cut the "general EVP cipher exports still throw" sentence from the CMAC entry (line 41).
  • Optionally, correct the PKCS12_PBE_add wording in the EVP_cleanup entry, and add a CBC round-trip through the new calls.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5752949523 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10834#pullrequestreview-5752949523). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T13:25:32Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The cipher code follows LibreSSL 2.5.4, it builds, the focused tests pass, and the tests fail when I break the code, but two statements in `docs/dev/debt/libSceLibreSsl.md` are now false on the merged tree. ## What I ran Head `319b7072dea61cdb439af0e8319ba33321f667e9`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged with `--no-ff` in a clean worktree (Release, GCC 14.2.0, Ninja, Debian 13, 32 vCPU Xeon Gold 6136). ``` git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...319b7072dea61cdb439af0e8319ba33321f667e9 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 grep -c "NotImplemented_nid_no_patch(__func__)" core/libs/prx/libSceLibreSsl/Export.cpp ctest --test-dir build -j8 --test-load 32 -R "libressl|public_headers" --output-on-failure ctest --test-dir build -R "evp_cipher_ctx|cmac" --output-on-failure # negative control: production files from main, then targeted mutations (below) ninja -C build -j32 -l32 guest_libressl_evp_cipher_ctx_tests ctest --test-dir build -R "^guest_libressl_evp_cipher_ctx$" --output-on-failure ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | "All conventions checks passed." | | Build (script, merged tree) | OK | | Script test run (843 tests) | 841 passed, 1 expected skip, 1 known failure on `main` (`unwrap_self_..._group`), no new failures | | `-R "libressl\|public_headers"` | 116/116 passed, 76.8 s total. `guest_libressl_evp_cipher_ctx` takes 0.01 s | | Pending-exports count | 209 `NotImplemented_nid_no_patch(__func__)` calls in the merged `Export.cpp`, which matches the debt line (231 on `main` minus 22) | | Vulkan validation | not applicable (no AGC/shader/VideoOut change) | ## Negative control - **All production files from `main`** (`CMakeLists.txt`, `Export.cpp`, `include/Api.hpp`, `src/EvpCipherCtx.cpp` restored; `include/Evp.hpp` and `src/EvpAes.cpp` moved aside): `guest_libressl_evp_cipher_ctx_tests` no longer compiles (`'LibreSslEvpCipher' does not name a type`, `too many arguments to function 'int EVP_CIPHER_CTX_cleanup_nid_postfix()'`). - **Padding check removed** in `DecryptFinal` (the `ctx->final[--block] != pad` comparison) plus the tag compare forced to 0: the test aborts at line 440 (the bad-padding case). - **Tag compare forced to 0 alone** (`TimingSafeCompare` returns 0): the test aborts at line 889 (the wrong-tag GCM case). - Afterwards I restored the merged files and rebuilt. The test passes again, and `git status --porcelain` is empty. Rebuilding after the `CMakeLists.txt` revert made CMake regenerate, and that failed in the sandbox on files the build user doesn't own. I re-created those build-tree files under my user; the source tree was not changed. ## Findings ### Blocking 1. **The debt entry gives a reason that `main` has made false.** `docs/dev/debt/libSceLibreSsl.md:31` says "A failure returns 0 without queueing an error code, because `ERR_get_error` and `ERR_peek_error` are not implemented." Since #9535 they are implemented ([Error.cpp L60-L62](https://github.com/boykopovar/AnyPS5/blob/4f41f4c375f5abb487dbd184fbc150f31994d762/core/libs/prx/libSceLibreSsl/src/Error.cpp#L60-L62)). The same module's CMAC code already queues `EVP` errors through `LibreSslPutError_nid_no_patch` ([Cmac.cpp L30-L33](https://github.com/boykopovar/AnyPS5/blob/4f41f4c375f5abb487dbd184fbc150f31994d762/core/libs/prx/libSceLibreSsl/src/Cmac.cpp#L30-L33)). The PR description itself mentions that #9535 merged. As written, a title that calls `ERR_get_error` after a failed `EVP_DecryptFinal_ex` gets 0, and the debt file blames a gap that no longer exists. - **Fix:** either queue LibreSSL's `EVPerr` reasons at the failure returns in `EvpCipherCtx.cpp` (as `Cmac.cpp` does), or reword the entries at lines 31 and 32 to say plainly that no error is queued, without the false reason. 2. **The CMAC entry still says the general EVP cipher exports throw.** `docs/dev/debt/libSceLibreSsl.md:41` (CMAC and AES-CBC descriptors) ends with "Other built-in cipher selectors and the general EVP cipher exports still throw." With this PR, `EVP_CipherInit_ex`/`Update`/`Final`, the CFB8, CTR and GCM selectors, and the `EVP_CIPHER_CTX` calls are implemented. CONTRIBUTING requires a PR that closes a gap to remove the entry or cut it to what is still open. - **Fix:** cut that sentence to the selectors that still throw. ### Non-blocking 3. **The `EVP_cleanup` entry says `PKCS12_PBE_add` is not implemented.** `docs/dev/debt/libSceLibreSsl.md:35` lists `PKCS12_PBE_add` among the calls that "are not implemented". On `main` it is implemented as an empty function (`Export.cpp:494`), with its own entry at line 28 citing that it is empty in LibreSSL 2.5.4. The conclusion (nothing can fill the PBE table) still holds, but the reason should say that `PKCS12_PBE_add` adds nothing in 2.5.4. 4. **Two types describe the same `EVP_CIPHER` and `EVP_CIPHER_CTX`.** - `LibreSslEvpCipher`/`LibreSslEvpCipherCtx` (`core/libs/prx/libSceLibreSsl/include/Api.hpp:310`) duplicate `LibreSslCipher`/`LibreSslCipherContext` in `include/Cmac.hpp:9`. Both are 88/168 bytes with the same offsets. - `EVP_aes_*_cbc` returns `const LibreSslCipher*`, while `EVP_EncryptInit_ex` takes `const LibreSslEvpCipher*`. A guest won't notice (the layouts agree), but host code and tests cannot pass a CBC descriptor to the new calls without a cast. - No test runs AES-CBC, the most common guest use, through the new `EVP_Encrypt*`/`EVP_Decrypt*` path. Only a test-defined block cipher covers the padding paths. - **Suggestion:** use one type for both, or at least add a test that runs `EVP_aes_128_cbc()` through `EVP_EncryptInit_ex`/`EVP_DecryptFinal_ex` with an SP 800-38A CBC vector. ### Code read against LibreSSL 2.5.4 (no defects found) I compared these against 2.5.4's `evp_enc.c`, `e_aes.c` and `gcm128.c`: - `EVP_CipherInit_ex`, `EVP_EncryptUpdate`, `EVP_DecryptUpdate`, `EVP_EncryptFinal_ex`, `EVP_DecryptFinal_ex`, `EVP_CIPHER_CTX_cleanup` and `EVP_CIPHER_CTX_ctrl`; - `aes_gcm_init_key`, `aes_gcm_ctrl` (INIT, IVLEN, SET/GET_TAG, IV_FIXED, IV_GEN, SET_IV_INV, TLS1_AAD, COPY), `aes_gcm_cipher` and `aes_gcm_tls_cipher`; - `CRYPTO_gcm128_setiv`, `aad`, `encrypt`/`decrypt`, `finish` and `tag`. Control flow and return values match. The extra throws are the ones listed in the debt entries. MarcZX10's earlier request for constant-time tag compares is addressed: both compares go through `TimingSafeCompare`, and my mutation confirms the wrong-tag cases fail without it. ## Not verified - Nothing was run on a console or against the firmware module. I did not check the descriptor values (NIDs, flags, `ctx_size` 264/680) against firmware myself; they match my reading of `e_aes.c`, and the description cites BunnyFl's firmware 13.42 run. - Windows/MinGW build. - AES-CBC (from `Cmac.cpp`) through the new EVP calls; it is not exercised by any test. - Timing behaviour of the tag compare; only its result is tested. ## To get this to a good state - Fix the error-queue statement in debt entries 31 and 32: queue the `EVP` errors as `Cmac.cpp` does, or drop the false reason. - Cut the "general EVP cipher exports still throw" sentence from the CMAC entry (line 41). - Optionally, correct the `PKCS12_PBE_add` wording in the `EVP_cleanup` entry, and add a CBC round-trip through the new calls. <!-- anyps5-bots job=2109 head=319b7072dea61cdb439af0e8319ba33321f667e9 -->
XairRrR commented 2026-11-03 15:13:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T15:13:14Z.

Review: APPROVED


Re-checked — approved

The only new commit, 6e3ccd8ff3 ("docs(libressl): correct the EVP context, cleanup and CMAC debt entries"), fixes both blocking debt-file statements and the PKCS12_PBE_add wording. The checks and the focused tests pass on the merged tree.

What changed since my last review

  • git range-diff (delta.patch): commits 1–10 are identical, and one commit was added, 6e3ccd8ff3. It changes only docs/dev/debt/libSceLibreSsl.md, on three lines.
  • The author answered my four points (discussion, 2026-11-03T14:58Z). They agreed on the two cipher types and said a test-only CBC commit will follow on this PR. That commit is not on this head yet.

What I ran

Head 6e3ccd8ff387be6539cc084a0aa86b87f1726a8c, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged with --no-ff (tree 536fa6008424e80fe72dfb45c20ca084ecc6918f) in a clean worktree. Release build, GCC 14.2.0, Ninja, Debian 13.

git show 6e3ccd8ff387be6539cc084a0aa86b87f1726a8c
git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...6e3ccd8ff387be6539cc084a0aa86b87f1726a8c
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
grep -c "NotImplemented_nid_no_patch(__func__)" core/libs/prx/libSceLibreSsl/Export.cpp
grep -n "APS5_VABI EVP_" core/libs/prx/libSceLibreSsl/Export.cpp
ctest --test-dir build -j8 --test-load 32 -R "libressl" --output-on-failure
Check Result
git diff --check clean
check_conventions.py "All conventions checks passed."
Script build and test run (843 tests) 841 passed, 1 expected skip, 1 known failure that also fails on main (unwrap_self_..._group), no new failures
-R libressl 51/51 passed, 1.08 s in total
Pending-exports count 209 calls in the merged Export.cpp, which matches the debt line
Vulkan validation not applicable: the PR changes no AGC driver, shader recompiler or VideoOut file

Negative control: the new commit changes only docs, and no test or code changed since my last review. The negative control from that review still applies: the test fails with main's production files and with the padding and tag-compare mutations.

Previous findings

  1. Resolved. The error-queue entry gave a false reason (docs/dev/debt/libSceLibreSsl.md:31). It now says only "A failure returns 0 without queueing an error code", without blaming ERR_get_error or ERR_peek_error. Line 32 already said the same plainly.
  2. Resolved. The CMAC entry said "general EVP cipher exports still throw" (docs/dev/debt/libSceLibreSsl.md:41). It now says "Of the EVP cipher exports, only EVP_CIPHER_block_size still throws." I checked this against the merged Export.cpp: the only EVP cipher stub left is EVP_CIPHER_block_size at core/libs/prx/libSceLibreSsl/Export.cpp:333. The other EVP_ stubs are DigestVerify and PKEY calls.
  3. Resolved (non-blocking). The EVP_cleanup entry (docs/dev/debt/libSceLibreSsl.md:35) now says PKCS12_PBE_add "is empty as in LibreSSL 2.5.4", and it is no longer listed as unimplemented.
  4. Still open (non-blocking). Two types still describe the same EVP_CIPHER/EVP_CIPHER_CTX layout, and no test yet runs AES-CBC through EVP_EncryptInit_ex/EVP_DecryptFinal_ex. The author agreed and said a test-only commit with the SP 800-38A F.2.1/F.2.2 vectors will follow. This doesn't block the merge.

New findings

Blocking

None.

Non-blocking

None.

Not verified

  • Nothing was run on a console or against the firmware module.
  • I did not run a Windows/MinGW build.
  • No test exercises AES-CBC from Cmac.cpp through the new EVP calls; this is finding 4.
  • Only the result of the GCM tag compare is tested, not its timing.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5754654456 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10834#pullrequestreview-5754654456). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T15:13:14Z. **Review:** APPROVED --- # Re-checked — approved The only new commit, 6e3ccd8ff3 ("docs(libressl): correct the EVP context, cleanup and CMAC debt entries"), fixes both blocking debt-file statements and the `PKCS12_PBE_add` wording. The checks and the focused tests pass on the merged tree. ## What changed since my last review - `git range-diff` (delta.patch): commits 1–10 are identical, and one commit was added, 6e3ccd8ff3. It changes only `docs/dev/debt/libSceLibreSsl.md`, on three lines. - The author answered my four points (discussion, 2026-11-03T14:58Z). They agreed on the two cipher types and said a test-only CBC commit will follow on this PR. That commit is not on this head yet. ## What I ran Head `6e3ccd8ff387be6539cc084a0aa86b87f1726a8c`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged with `--no-ff` (tree `536fa6008424e80fe72dfb45c20ca084ecc6918f`) in a clean worktree. Release build, GCC 14.2.0, Ninja, Debian 13. ``` git show 6e3ccd8ff387be6539cc084a0aa86b87f1726a8c git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...6e3ccd8ff387be6539cc084a0aa86b87f1726a8c python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 grep -c "NotImplemented_nid_no_patch(__func__)" core/libs/prx/libSceLibreSsl/Export.cpp grep -n "APS5_VABI EVP_" core/libs/prx/libSceLibreSsl/Export.cpp ctest --test-dir build -j8 --test-load 32 -R "libressl" --output-on-failure ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | "All conventions checks passed." | | Script build and test run (843 tests) | 841 passed, 1 expected skip, 1 known failure that also fails on `main` (`unwrap_self_..._group`), no new failures | | `-R libressl` | 51/51 passed, 1.08 s in total | | Pending-exports count | 209 calls in the merged `Export.cpp`, which matches the debt line | | Vulkan validation | not applicable: the PR changes no AGC driver, shader recompiler or VideoOut file | Negative control: the new commit changes only docs, and no test or code changed since my last review. The negative control from that review still applies: the test fails with `main`'s production files and with the padding and tag-compare mutations. ## Previous findings 1. **Resolved.** The error-queue entry gave a false reason (`docs/dev/debt/libSceLibreSsl.md:31`). It now says only "A failure returns 0 without queueing an error code", without blaming `ERR_get_error` or `ERR_peek_error`. Line 32 already said the same plainly. 2. **Resolved.** The CMAC entry said "general EVP cipher exports still throw" (`docs/dev/debt/libSceLibreSsl.md:41`). It now says "Of the EVP cipher exports, only `EVP_CIPHER_block_size` still throws." I checked this against the merged `Export.cpp`: the only EVP cipher stub left is `EVP_CIPHER_block_size` at `core/libs/prx/libSceLibreSsl/Export.cpp:333`. The other `EVP_` stubs are DigestVerify and PKEY calls. 3. **Resolved** (non-blocking). The `EVP_cleanup` entry (`docs/dev/debt/libSceLibreSsl.md:35`) now says `PKCS12_PBE_add` "is empty as in LibreSSL 2.5.4", and it is no longer listed as unimplemented. 4. **Still open** (non-blocking). Two types still describe the same `EVP_CIPHER`/`EVP_CIPHER_CTX` layout, and no test yet runs AES-CBC through `EVP_EncryptInit_ex`/`EVP_DecryptFinal_ex`. The author agreed and said a test-only commit with the SP 800-38A F.2.1/F.2.2 vectors will follow. This doesn't block the merge. ## New findings ### Blocking None. ### Non-blocking None. ## Not verified - Nothing was run on a console or against the firmware module. - I did not run a Windows/MinGW build. - No test exercises AES-CBC from `Cmac.cpp` through the new EVP calls; this is finding 4. - Only the result of the GCM tag compare is tested, not its timing. <!-- anyps5-bots job=3392 head=6e3ccd8ff387be6539cc084a0aa86b87f1726a8c -->
XairRrR commented 2026-11-03 17:22:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T17:22:39Z.

Review: APPROVED


Re-checked — approved

The only new commit, 8a9ab924f9 ("test(libressl): run EVP_aes_128_cbc through the EVP cipher calls"), adds the CBC round trip that my last review asked for. The checks and the LibreSSL tests pass on the merged tree, and a mutation in CBC decryption makes the new case fail.

What changed since my last review

  • git range-diff (delta.patch): commits 1–11 are identical. One commit was added, 8a9ab924f9. It changes only core/libs/tests/GuestLibreSslEvpCipherCtx.cpp (+33 lines): a new TestAesCbc, called from main() before TestAesCfb8.
  • The test passes main's EVP_aes_128_cbc() (LibreSslCipher, from Cmac.cpp) to this PR's EVP_EncryptInit_ex/EVP_DecryptInit_ex, Update and Final. It runs in chunks of 1, 7, 16 and 64 bytes:
    • encryption without padding;
    • decryption without padding;
    • a PKCS#7 round trip, which checks that the first 64 bytes of the ciphertext match and that one 16-byte padding block follows.
  • I checked the vectors against SP 800-38A F.2.1/F.2.2 (key 2b7e1516…, IV 000102…0f, ciphertext 7649abac…, 5086cb9b…, 73bed6b8…, 3ff1caa1…), and they match.
  • Since my last review, the author's only change to the description is a section that describes this commit.

What I ran

Head 8a9ab924f9ed47584aaf92c776ef9b74cdc1a95b, main 1e658521a0a599872612bb91949311e2956b5283, merged with --no-ff (tree 297bc1f66abde4450aa49fee313705f462a6bedc) in a clean worktree. Release build, GCC 14.2.0, Ninja, Debian 13.

git show 8a9ab924f9ed47584aaf92c776ef9b74cdc1a95b
git diff --check 1e658521a0a599872612bb91949311e2956b5283...8a9ab924f9ed47584aaf92c776ef9b74cdc1a95b
python3 tools/check_conventions.py --base 1e658521a0a599872612bb91949311e2956b5283
ctest --test-dir build -j8 --test-load 32 -R libressl --output-on-failure
grep -c "NotImplemented_nid_no_patch(__func__)" core/libs/prx/libSceLibreSsl/Export.cpp
# mutation: Cmac.cpp:147 forces MBEDTLS_AES_ENCRYPT, so CBC decryption is wrong
ninja -C build -j32 -l32 guest_libressl_evp_cipher_ctx_tests
ctest --test-dir build -R "guest_libressl_(evp_cipher_ctx|cmac)" --output-on-failure
# restored the merged Cmac.cpp, rebuilt, reran -R libressl
Check Result
git diff --check clean
check_conventions.py "All conventions checks passed."
Script build and test run (850 tests) 848 passed, 1 expected skip, and 1 known failure that also fails on main (unwrap_self_..._group); no new failures
-R libressl 51/51 passed, 0.45 s in total
Pending-exports count 209 NotImplemented_nid_no_patch calls in the merged Export.cpp, which matches the debt line
Vulkan validation not applicable: the PR changes no AGC driver, shader recompiler or VideoOut file

Negative control

The new case covers code that already works, as the commit message says, so there is no red against main. Instead I made CBC decryption in main's descriptor wrong: at core/libs/prx/libSceLibreSsl/src/Cmac.cpp:147 I forced MBEDTLS_AES_ENCRYPT. CMAC only encrypts, so its own tests don't reach this path.

With the mutation, guest_libressl_evp_cipher_ctx aborts with "check failed at line 710", which is TestAesCbc's Require(output == plain) after the unpadded decrypt. So the new case does reach the CBC descriptor through the PR's calls.

I also tried a mutation in the PR's own CBC IV setup (EvpCipherCtx.cpp:267). An earlier custom-cipher case caught it first (line 501), before TestAesCbc ran. That is expected: those cases use the same code path.

After each mutation I restored the merged files and rebuilt. git status --porcelain is empty, and the 51 LibreSSL tests pass again.

Previous findings

  1. Resolved in my last review (the error-queue reason in the debt entry). This head does not change it.
  2. Resolved in my last review (the CMAC entry now says only EVP_CIPHER_block_size throws). This head does not change it.
  3. Resolved in my last review (PKCS12_PBE_add is described as empty, as in LibreSSL 2.5.4). This head does not change it.
  4. Resolved (non-blocking): two types describe the same EVP_CIPHER layout, and no test exercised AES-CBC through the EVP calls. TestAesCbc now passes EVP_aes_128_cbc() through EVP_EncryptInit_ex…EVP_DecryptFinal_ex, and the mutation above shows it catches a broken CBC decrypt. The two type names are still separate, as both sides agreed; the test now holds them to the same layout.

New findings

Blocking

None.

Non-blocking

None.

Not verified

  • Nothing was run on a console or against the firmware module.
  • I did not run a Windows/MinGW build. The author reports that Windows CI passed on this head.
  • Only the result of the GCM tag compare is tested, not its timing.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5756654221 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10834#pullrequestreview-5756654221). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T17:22:39Z. **Review:** APPROVED --- # Re-checked — approved The only new commit, 8a9ab924f9 ("test(libressl): run EVP_aes_128_cbc through the EVP cipher calls"), adds the CBC round trip that my last review asked for. The checks and the LibreSSL tests pass on the merged tree, and a mutation in CBC decryption makes the new case fail. ## What changed since my last review - `git range-diff` (delta.patch): commits 1–11 are identical. One commit was added, 8a9ab924f9. It changes only `core/libs/tests/GuestLibreSslEvpCipherCtx.cpp` (+33 lines): a new `TestAesCbc`, called from `main()` before `TestAesCfb8`. - The test passes `main`'s `EVP_aes_128_cbc()` (`LibreSslCipher`, from `Cmac.cpp`) to this PR's `EVP_EncryptInit_ex`/`EVP_DecryptInit_ex`, `Update` and `Final`. It runs in chunks of 1, 7, 16 and 64 bytes: - encryption without padding; - decryption without padding; - a PKCS#7 round trip, which checks that the first 64 bytes of the ciphertext match and that one 16-byte padding block follows. - I checked the vectors against SP 800-38A F.2.1/F.2.2 (key `2b7e1516…`, IV `000102…0f`, ciphertext `7649abac…`, `5086cb9b…`, `73bed6b8…`, `3ff1caa1…`), and they match. - Since my last review, the author's only change to the description is a section that describes this commit. ## What I ran Head `8a9ab924f9ed47584aaf92c776ef9b74cdc1a95b`, `main` `1e658521a0a599872612bb91949311e2956b5283`, merged with `--no-ff` (tree `297bc1f66abde4450aa49fee313705f462a6bedc`) in a clean worktree. Release build, GCC 14.2.0, Ninja, Debian 13. ``` git show 8a9ab924f9ed47584aaf92c776ef9b74cdc1a95b git diff --check 1e658521a0a599872612bb91949311e2956b5283...8a9ab924f9ed47584aaf92c776ef9b74cdc1a95b python3 tools/check_conventions.py --base 1e658521a0a599872612bb91949311e2956b5283 ctest --test-dir build -j8 --test-load 32 -R libressl --output-on-failure grep -c "NotImplemented_nid_no_patch(__func__)" core/libs/prx/libSceLibreSsl/Export.cpp # mutation: Cmac.cpp:147 forces MBEDTLS_AES_ENCRYPT, so CBC decryption is wrong ninja -C build -j32 -l32 guest_libressl_evp_cipher_ctx_tests ctest --test-dir build -R "guest_libressl_(evp_cipher_ctx|cmac)" --output-on-failure # restored the merged Cmac.cpp, rebuilt, reran -R libressl ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | "All conventions checks passed." | | Script build and test run (850 tests) | 848 passed, 1 expected skip, and 1 known failure that also fails on `main` (`unwrap_self_..._group`); no new failures | | `-R libressl` | 51/51 passed, 0.45 s in total | | Pending-exports count | 209 `NotImplemented_nid_no_patch` calls in the merged `Export.cpp`, which matches the debt line | | Vulkan validation | not applicable: the PR changes no AGC driver, shader recompiler or VideoOut file | ## Negative control The new case covers code that already works, as the commit message says, so there is no red against `main`. Instead I made CBC decryption in `main`'s descriptor wrong: at `core/libs/prx/libSceLibreSsl/src/Cmac.cpp:147` I forced `MBEDTLS_AES_ENCRYPT`. CMAC only encrypts, so its own tests don't reach this path. With the mutation, `guest_libressl_evp_cipher_ctx` aborts with "check failed at line 710", which is `TestAesCbc`'s `Require(output == plain)` after the unpadded decrypt. So the new case does reach the CBC descriptor through the PR's calls. I also tried a mutation in the PR's own CBC IV setup (`EvpCipherCtx.cpp:267`). An earlier custom-cipher case caught it first (line 501), before `TestAesCbc` ran. That is expected: those cases use the same code path. After each mutation I restored the merged files and rebuilt. `git status --porcelain` is empty, and the 51 LibreSSL tests pass again. ## Previous findings 1. **Resolved** in my last review (the error-queue reason in the debt entry). This head does not change it. 2. **Resolved** in my last review (the CMAC entry now says only `EVP_CIPHER_block_size` throws). This head does not change it. 3. **Resolved** in my last review (`PKCS12_PBE_add` is described as empty, as in LibreSSL 2.5.4). This head does not change it. 4. **Resolved** (non-blocking): two types describe the same `EVP_CIPHER` layout, and no test exercised AES-CBC through the EVP calls. `TestAesCbc` now passes `EVP_aes_128_cbc()` through `EVP_EncryptInit_ex`…`EVP_DecryptFinal_ex`, and the mutation above shows it catches a broken CBC decrypt. The two type names are still separate, as both sides agreed; the test now holds them to the same layout. ## New findings ### Blocking None. ### Non-blocking None. ## Not verified - Nothing was run on a console or against the firmware module. - I did not run a Windows/MinGW build. The author reports that Windows CI passed on this head. - Only the result of the GCM tag compare is tested, not its timing. <!-- anyps5-bots job=3455 head=8a9ab924f9ed47584aaf92c776ef9b74cdc1a95b -->
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!10834
No description provided.