feat(libSceLibreSsl): implement the EVP cipher calls on the cipher context #10834
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10834"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by 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}_cfb8andEVP_aes_{128,192,256}_ctron 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 withtimingsafe_memcmpEVP_cleanup: nothing in this module can fill the tables LibreSSL's names.c clears yet, so it returns; the debt entry says when that changesinclude/Api.hppdeclares the 22 exports once, with their real signatures, asmainasks since #10706. It holds LibreSSL's 88-byteEVP_CIPHERnext to #10488's 168-byteEVP_CIPHER_CTX, whosecipherfield this PR types asconst LibreSslEvpCipher*; the layout is unchanged.include/Evp.hppkeeps the internal constants and the layout checks. Failures queue no error code, a non-nullENGINEthrows, and inputs LibreSSL would dereference or overrun throw; the five new entries indocs/dev/debt/libSceLibreSsl.mdlist them.Built on #10488, which has merged. Its four commits are alvaroelpob's, unchanged, and are on
mainnow, so this PR's diff overmainis its own commits.Related: #10450 (
EVP_CIPHER_block_size, merged; sincef30dd4849ait takes this PR'sLibreSslEvpCipher), #9571 (CMAC and the CBC descriptors over the sameEVP_CIPHERlayout).Tested
(void)stubs to their real signatures ininclude/Api.hpp, andinclude/Aes.hppis dropped, sincemain'sApi.hpphasAesKeyand theAES_*calls. The test calls the exports with their public types through #10488'sContext()helper; its checks and their messages are unchanged.ctest -R '^(guest_libressl|public_headers)'passes at every one: 73 run, 73 pass. That's the eight LibreSSL tests,public_headersand its 64 compile batches.^guest_libressltests andpublic_headerspass 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.^guest_libressltests, 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.GcmFinishand the TLS decrypt path compare the tag in constant time, andguest_libressl_evp_cipher_ctxnow flips each byte of the tag in turn, for every GCM vector'sEVP_DecryptFinal_exand for a TLS record, and requires each to be rejected.std::memcmp, which finds every difference too, so they check that the new compare reads every tag byte. The timing itself isn't tested.guest_libressl_evp_cipher_ctx,guest_libressl_aes,guest_libressl_digest,guest_libressl_des,guest_libressl_runtime,guest_libressl_x509_errorsandguest_libressl3_digestpass 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.guest_libressl_evp_cipher_ctxgains 17 cases:EVP_Encrypt*,EVP_Decrypt*andEVP_Cipher*;EVP_CIPHER_CTX_ctrl, including wrong and truncated tags;EVP_CTRL_COPY, and the ctrl error returns;ctestas 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_lengthandguest_tcp.main7e4f6e0440(run). Dean Galvin's merge ofmaininto #10488 andmain'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.cppnow has 320NotImplementedexports, the base's 342 less this PR's 22. Theguest_libressltests andpublic_headerspass 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.mainae7d59258e. The code is unchanged; only the lines around it moved, wheremainchanged the LibreSSL debt file and theadd_librarysource list. A seventh commit sets the pending-exports count to 317, theNotImplementedexports left inExport.cpp: #10488's 339 less this PR's 22. Theguest_libressltests andpublic_headerspass 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.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 theEVP_CIPHERandEVP_CIPHER_CTXlayouts here.ctx_size, and which hooks are set.EVP_CIPHER_CTXoffsets match throughEVP_EncryptInit_exandEVP_EncryptUpdatewith AES-128 CTR, and through a padded AES-128 CBC decrypt.EVP_CIPHER_CTX_set_paddingsets and clears bit 0x100 of the word at 112, changes no other byte, and returns 1.main5e90e7569d(run).main's9a848d0b99implements the TLS alert descriptions and lowers the pending-export count indocs/dev/debt/libSceLibreSsl.mdfrom 342 to 341, on the line this PR sets. The merge keepsmain's change and sets the count to 316, theNotImplemented_nid_no_patchexports left in the mergedExport.cpp. Nothing else conflicted, #10488's four commits are unchanged, and this PR's other changed lines are the same. The 13guest_libressltests 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main84e91df418(run). b8d832765e drops the cipher-context test's two checks that requiredEVP_CIPHER_CTX_cleanupwith anENGINEset, andEVP_EncryptInit_exgiven one, to throw. The calls still refuse anENGINE, as the debt entry says, and the null-pointer, malformed-context and invalid-length checks stay. f129b2fde7 mergesmain, whose #9745 (SSLeay) lowers the pending-export count indocs/dev/debt/libSceLibreSsl.mdto 340, on the line this PR sets; the merge keeps it and sets 315, theNotImplemented_nid_no_patchexports left in the mergedExport.cpp. Nothing else conflicted, #10488's four commits are unchanged, and this PR's other changed lines are the same. Theguest_libressltests 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main4c7d275bef. The code is unchanged, and the two merges ofmaindrop 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'sLibreSslEvpCipher. Both are kept.add_libraryline: this PR still adds one file,src/EvpAes.cpp, now tomain's longer source list.docs/dev/debt/libSceLibreSsl.mdis now 274. That's the number ofNotImplemented_nid_no_patchcalls left in the rebasedExport.cpp; the same count gives the line's 296 on #10488's head and 299 onmain.^guest_libressltests andpublic_headersran 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.mainda026c7065.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.NotImplemented_nid_no_patchcalls left in the rebasedExport.cpp: 290 on #10488's new head, less this PR's 22.main, so no merge was needed, and the count holds on the merged tree.^guest_libressltests,public_headersand 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.mainc12e7e61a1(run), which brings JaceTheBlu's #13562 (OBJ_createandOBJ_cleanup). #10488's head ea1a21792f is still this branch's base.docs/dev/debt/libSceLibreSsl.md:mainreads 292 after #13562, and the mergedExport.cpphas 267 calls left that go throughNotImplemented_nid_no_patch, so the entry now says 267.CMakeLists.txt,Export.cppandApi.hppmerged without conflicts.EVP_cleanupentry listedOBJ_createandOBJ_cleanupamong the calls that aren't implemented, which #13562 made untrue. It now says thatOPENSSL_add_all_algorithms_noconf,SSL_library_init,CONF_modules_load_file,OPENSSL_load_builtin_modulesandPKCS12_PBE_addaren't implemented and that no cipher or digest can be registered under anOBJ_createNID to deferOBJ_cleanup. SoEVP_cleanupstill has nothing to clear: in LibreSSL 2.5.4 (2e2c612066,evp/names.candobjects/obj_dat.c),EVP_cleanupcallsOBJ_cleanuponly afterEVP_add_cipherorEVP_add_digesthas registered such a NID, and neither exists here. The merge commit's message names it.^guest_libresslandpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main0a148be963(run), which brings #13760 (GENERAL_NAME_freeandGENERAL_NAMES_free) and #13820 (SHA-384 and SHA-512 initialization buffers).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 itsExport.cpp), so this PR's 267 is now 265, theNotImplemented_nid_no_patchcalls left in the mergedExport.cpp.^guest_libresslandpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.9f70186b52: this PR's eight commits restacked onto #10488's16d0e81b02, then one docs commit (run), after alvaroelpob rebased #10488 ontomaincf79276fee.git range-diff: six commits are unchanged. The first changes only in a context line of the debt file, thePKCS12_PBE_addentry thatmain's #13562 rewrote. The seventh changes only in the pending-exports count and a context line, the Digest entry that #13820 extended.NotImplemented_nid_no_patchcalls left in the restackedExport.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'sEVP_cleanupsentence (above) into the restacked commits, since that sentence was in the merge commit. After it, the debt file is the same as at 85e42b7647, andgit diff 85e42b7647 9f70186b52overcore/libs/prx/libSceLibreSsland the debt file is empty. The two earlier merges ofmainare no longer in the branch's history.mainbbe8cf31c1, so no merge was needed.^guest_libresslandpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.8ea13cc9ea: merges ofmain88e804b0a7(ba51e03631) and24238c4cb1(8ea13cc9ea), with a recount between them (64b0d96659) (run, on8ea13cc9ea).ba51e03631brings Felipebmaitan's #9535 (error queues) and atharvjairath's #10078 (X509_EXTENSIONgetters). Two conflicts, both resolved by keeping both sides: inExport.cpp, #9535 removes theERR_error_stringstubs next to theEVP_CIPHER_CTXstubs this PR removes, and the pending-exports count line indocs/dev/debt/libSceLibreSsl.md.64b0d96659sets the count to 259, theNotImplemented_nid_no_patchcalls left in the mergedExport.cpp(#9535 and #10078 implement three each).8ea13cc9eabrings alvaroelpob's #10488 as it merged onmain, which this branch already carried. After the first merge, GitHub reported the branch as conflicting: with #10488 merged onmain, 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 overmainare the same as they were over #10488's head.^guest_libressltests, withguest_libressl_evp_cipher_ctxandpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.0143584d76, a merge ofmainb28bb77217(run), which brings HQasper's #9448 (the EVP message digest and HMAC functions).add_librarysource list inCMakeLists.txt, where #9448 addssrc/Evp.cppand this PRsrc/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'sLibreSslEvpCipher, 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.NotImplemented_nid_no_patchcalls left in the mergedExport.cpp:main's 261, which its line now matches, less this PR's 22.mainare the same, and it merges cleanly withmaina4eca2a056.^guest_libressltests, withguest_libressl_evp_cipher_ctxandpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.319b7072de, a merge ofmain4f41f4c375(run), which brings Felipebmaitan's #9571 (CMAC with the AES-CBC ciphers).CMakeLists.txt'sadd_librarysource list: the union of both sides' sources, each once;Export.cpp: this PR's removal of the CFB8, CTR, GCM andEVP_cleanupstubs, andmain's removal of the CBC stubs;include/Api.hpp:main's ERR signatures and CBC getters, and this PR's context, CFB8, CTR, GCM andEVP_cleanupdeclarations;docs/dev/debt/libSceLibreSsl.md: the mergedExport.cpphas 209NotImplementedexports, so the pending-exports entry now says 209 (this PR said 239,main231).main's CBC getters return itsLibreSslCipher(Cmac.hpp), and this PR'sEVP_CipherInit_extakes itsLibreSslEvpCipher. Their fields match in order and size, as domain'sLibreSslCipherContextand this PR'sLibreSslEvpCipherCtx(mainasserts 168 bytes, withivat 40,flagsat 112 andcipherDataat 120). 8a9ab924f9's test passesmain'sEVP_aes_128_cbc()through this PR's context (see below).^guest_libressltest. 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main4f41f4c: AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8; report): 1,147 passed, 6 failed, none new (4 also fail onmain, 2 unstable onmain), 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 givesERR_get_errorandERR_peek_erroras the reason no error is queued, theEVP_cleanupentry saysPKCS12_PBE_addis empty as in LibreSSL 2.5.4, and the CMAC entry says that, of the EVP cipher exports, onlyEVP_CIPHER_block_sizestill throws.main4f41f4c: AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8; report): 1,147 passed, 6 failed, none new (4 also fail onmain, 2 unstable onmain), 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'sEVP_aes_128_cbc()descriptor goes through this PR'sEVP_EncryptInit_exandEVP_DecryptInit_ex,UpdateandFinalwith 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.^guest_libressltest. 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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.da37daf69f, a merge ofmain9ab6a281ea(run), which brings MatteoSid's #10395 (EC groups and keys).CMakeLists.txt'sadd_librarysource list:mainaddssrc/Ec.cppand this PRsrc/EvpAes.cpp, and the line keeps both;docs/dev/debt/libSceLibreSsl.md: the mergedExport.cpphas 200NotImplementedexports, so the pending-exports entry now says 200 (this PR said 209,main222).^guest_libressltest, withpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.c83992150b, a merge ofmainb611e634f7(run), which brings LordVersA's #11662 (SSL_library_init).docs/dev/debt/libSceLibreSsl.md, which both sides changed. The mergedExport.cpphad 199NotImplementedexports, so the entry said 199 (this PR said 200,main221). No function is in both PRs, and this PR's other lines are unchanged.^guest_libressltest, withpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.f30dd4849a, a merge ofmaind63781e9ce(run), which brings alvaroelpob's #10450 (EVP_CIPHER_block_size).include/Api.hpp: #10450 adds its ownLibreSslEvpCipher, with this PR's 13 fields in the same order but its function pointers asvoid*. The merge keeps this PR's typed definition, sinceEvpCipherCtx.cppcalls through those pointers, and declaresEVP_CIPHER_block_sizewithmain'sconst LibreSslEvpCipher*.main'sEvpCipher.cppreads onlyblockSize, and its layout checks (88 bytes,blockSizeat 4,initat 24,contextSizeat 48) hold for the typed struct.Export.cpp: both sides' stub removals are kept, so no EVP cipher stub is left.CMakeLists.txt'sadd_librarysource list:mainaddssrc/EvpCipher.cppand this PRsrc/EvpAes.cpp, and the line keeps both.docs/dev/debt/libSceLibreSsl.md:main'sEVP_CIPHER_block_sizeentry and this PR's five are kept. The mergedExport.cpphad 198NotImplementedexports, so the pending-exports entry said 198 (this PR said 199,main220).mainmade untrue are corrected, as the merge commit's message says. The CMAC entry drops "Of the EVP cipher exports, onlyEVP_CIPHER_block_sizestill throws" (#10450). TheEVP_cleanupentry no longer listsSSL_library_init(#11662) among the calls that aren't implemented: it now saysSSL_library_initreturns 1 without adding a cipher or digest, soEVP_cleanupstill has nothing to clear.^guest_libressltest (now including #10450'sguest_libressl_evp_cipher) andpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.db6537d1c7, a merge ofmain9f9e420709(run), which brings alvaroelpob's #10448 (OCSP_response_status,OCSP_single_get0_status).include/Api.hpp, where #10448 adds four OCSP structs right aftermain's copy ofLibreSslEvpCipher. The merge keeps the four structs and this PR's single typed definition.CMakeLists.txt'sadd_librarysource list, wheremainaddssrc/OcspResponse.cppand this PRsrc/EvpAes.cpp. The line keeps both.docs/dev/debt/libSceLibreSsl.md, which keeps #10448's OCSP entry beside this PR's five. The mergedExport.cpphas 196NotImplementedexports, so the pending-exports entry now says 196 (this PR said 198,main218).^guest_libressltest (now including #10448'sguest_libressl_ocsp_response) andpublic_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 withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.Checklist
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)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)docs/dev/debt/libSceLibreSsl.md: whichever merges later recounts it in amainmergeImported 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.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. BothGcmFinishand the TLS decrypt path now use the full-length accumulator comparison rather thanmemcmp; 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_libresslset 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 --checkpasses 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.
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:
guest_libressl_evp_cipher_ctx_testson the merge.ctest -R ^guest_libressl_evp_cipher_ctx$passes, and so doescheck_conventions.py --base origin/main.libcrypto.a, asm/AES-NI build). One process links bothlibcrypto.aandlibSceLibreSsl.prx, runs each scenario on both, and compares return values,outl, the whole output buffer and all 168EVP_CIPHER_CTXbytes (pointer fields masked). 19,161 cases:outland output byte matches. The layouts match too:EVP_CIPHER88 andEVP_CIPHER_CTX168 with every field offset, and all 9 AES descriptors (nid, sizes, flags, ctx_size 264/680).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 CTRnumreset.EvpCipherCtx.cppandEvpAes.cppagainst 2.5.4evp_enc.c,e_aes.c,gcm128.candcfb128.c.The only differences:
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. Realbufstays zero; the PR'sbufis66e94bd4.... The non-asm 2.5.4 path behaves like the PR, andbufisn't read whilenumis 0, so I don't think it matters.Small notes, not blocking:
timingsafe_memcmp". In 2.5.4 the EVP GCM path uses plainmemcmp(gcm128.c:1518, and e_aes.c:979 for TLS).timingsafe_memcmpis 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.cipherdiffers (const void*there).struct LibreSslEvpCipherinApi.hpp, with the same layout andvoid*callbacks. Whichever PR merges second has to drop one.Not checked: the console, Windows, the ENGINE paths.
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.mdare now false on the merged tree.What I ran
Head
319b7072dea61cdb439af0e8319ba33321f667e9,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged with--no-ffin a clean worktree (Release, GCC 14.2.0, Ninja, Debian 13, 32 vCPU Xeon Gold 6136).Results
git diff --checkcheck_conventions.pymain(unwrap_self_..._group), no new failures-R "libressl|public_headers"guest_libressl_evp_cipher_ctxtakes 0.01 sNotImplemented_nid_no_patch(__func__)calls in the mergedExport.cpp, which matches the debt line (231 onmainminus 22)Negative control
main(CMakeLists.txt,Export.cpp,include/Api.hpp,src/EvpCipherCtx.cpprestored;include/Evp.hppandsrc/EvpAes.cppmoved aside):guest_libressl_evp_cipher_ctx_testsno longer compiles ('LibreSslEvpCipher' does not name a type,too many arguments to function 'int EVP_CIPHER_CTX_cleanup_nid_postfix()').DecryptFinal(thectx->final[--block] != padcomparison) plus the tag compare forced to 0: the test aborts at line 440 (the bad-padding case).TimingSafeComparereturns 0): the test aborts at line 889 (the wrong-tag GCM case).git status --porcelainis empty.Rebuilding after the
CMakeLists.txtrevert 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
The debt entry gives a reason that
mainhas made false.docs/dev/debt/libSceLibreSsl.md:31says "A failure returns 0 without queueing an error code, becauseERR_get_errorandERR_peek_errorare not implemented." Since #9535 they are implemented (Error.cpp L60-L62). The same module's CMAC code already queuesEVPerrors throughLibreSslPutError_nid_no_patch(Cmac.cpp L30-L33). The PR description itself mentions that #9535 merged. As written, a title that callsERR_get_errorafter a failedEVP_DecryptFinal_exgets 0, and the debt file blames a gap that no longer exists.EVPerrreasons at the failure returns inEvpCipherCtx.cpp(asCmac.cppdoes), or reword the entries at lines 31 and 32 to say plainly that no error is queued, without the false reason.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 theEVP_CIPHER_CTXcalls are implemented. CONTRIBUTING requires a PR that closes a gap to remove the entry or cut it to what is still open.Non-blocking
The
EVP_cleanupentry saysPKCS12_PBE_addis not implemented.docs/dev/debt/libSceLibreSsl.md:35listsPKCS12_PBE_addamong the calls that "are not implemented". Onmainit 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 thatPKCS12_PBE_addadds nothing in 2.5.4.Two types describe the same
EVP_CIPHERandEVP_CIPHER_CTX.LibreSslEvpCipher/LibreSslEvpCipherCtx(core/libs/prx/libSceLibreSsl/include/Api.hpp:310) duplicateLibreSslCipher/LibreSslCipherContextininclude/Cmac.hpp:9. Both are 88/168 bytes with the same offsets.EVP_aes_*_cbcreturnsconst LibreSslCipher*, whileEVP_EncryptInit_extakesconst 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.EVP_Encrypt*/EVP_Decrypt*path. Only a test-defined block cipher covers the padding paths.EVP_aes_128_cbc()throughEVP_EncryptInit_ex/EVP_DecryptFinal_exwith 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.candgcm128.c:EVP_CipherInit_ex,EVP_EncryptUpdate,EVP_DecryptUpdate,EVP_EncryptFinal_ex,EVP_DecryptFinal_ex,EVP_CIPHER_CTX_cleanupandEVP_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_cipherandaes_gcm_tls_cipher;CRYPTO_gcm128_setiv,aad,encrypt/decrypt,finishandtag.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
ctx_size264/680) against firmware myself; they match my reading ofe_aes.c, and the description cites BunnyFl's firmware 13.42 run.Cmac.cpp) through the new EVP calls; it is not exercised by any test.To get this to a good state
EVPerrors asCmac.cppdoes, or drop the false reason.PKCS12_PBE_addwording in theEVP_cleanupentry, and add a CBC round-trip through the new calls.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 thePKCS12_PBE_addwording. 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 onlydocs/dev/debt/libSceLibreSsl.md, on three lines.What I ran
Head
6e3ccd8ff387be6539cc084a0aa86b87f1726a8c,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged with--no-ff(tree536fa6008424e80fe72dfb45c20ca084ecc6918f) in a clean worktree. Release build, GCC 14.2.0, Ninja, Debian 13.git diff --checkcheck_conventions.pymain(unwrap_self_..._group), no new failures-R libresslExport.cpp, which matches the debt lineNegative 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
docs/dev/debt/libSceLibreSsl.md:31). It now says only "A failure returns 0 without queueing an error code", without blamingERR_get_errororERR_peek_error. Line 32 already said the same plainly.docs/dev/debt/libSceLibreSsl.md:41). It now says "Of the EVP cipher exports, onlyEVP_CIPHER_block_sizestill throws." I checked this against the mergedExport.cpp: the only EVP cipher stub left isEVP_CIPHER_block_sizeatcore/libs/prx/libSceLibreSsl/Export.cpp:333. The otherEVP_stubs are DigestVerify and PKEY calls.EVP_cleanupentry (docs/dev/debt/libSceLibreSsl.md:35) now saysPKCS12_PBE_add"is empty as in LibreSSL 2.5.4", and it is no longer listed as unimplemented.EVP_CIPHER/EVP_CIPHER_CTXlayout, and no test yet runs AES-CBC throughEVP_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
Cmac.cppthrough the new EVP calls; this is finding 4.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 onlycore/libs/tests/GuestLibreSslEvpCipherCtx.cpp(+33 lines): a newTestAesCbc, called frommain()beforeTestAesCfb8.main'sEVP_aes_128_cbc()(LibreSslCipher, fromCmac.cpp) to this PR'sEVP_EncryptInit_ex/EVP_DecryptInit_ex,UpdateandFinal. It runs in chunks of 1, 7, 16 and 64 bytes:2b7e1516…, IV000102…0f, ciphertext7649abac…,5086cb9b…,73bed6b8…,3ff1caa1…), and they match.What I ran
Head
8a9ab924f9ed47584aaf92c776ef9b74cdc1a95b,main1e658521a0a599872612bb91949311e2956b5283, merged with--no-ff(tree297bc1f66abde4450aa49fee313705f462a6bedc) in a clean worktree. Release build, GCC 14.2.0, Ninja, Debian 13.git diff --checkcheck_conventions.pymain(unwrap_self_..._group); no new failures-R libresslNotImplemented_nid_no_patchcalls in the mergedExport.cpp, which matches the debt lineNegative 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 inmain's descriptor wrong: atcore/libs/prx/libSceLibreSsl/src/Cmac.cpp:147I forcedMBEDTLS_AES_ENCRYPT. CMAC only encrypts, so its own tests don't reach this path.With the mutation,
guest_libressl_evp_cipher_ctxaborts with "check failed at line 710", which isTestAesCbc'sRequire(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), beforeTestAesCbcran. That is expected: those cases use the same code path.After each mutation I restored the merged files and rebuilt.
git status --porcelainis empty, and the 51 LibreSSL tests pass again.Previous findings
EVP_CIPHER_block_sizethrows). This head does not change it.PKCS12_PBE_addis described as empty, as in LibreSSL 2.5.4). This head does not change it.EVP_CIPHERlayout, and no test exercised AES-CBC through the EVP calls.TestAesCbcnow passesEVP_aes_128_cbc()throughEVP_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