fix(libSceLibreSsl): report why EVP_DecryptFinal_ex fails #16649
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16649"
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 AlexWhitehouse on 2026-11-07T13:04:25Z.
What
In libSceLibreSsl,
EVP_DecryptFinal_ex(NIDurpDB9rHb4s), andEVP_CipherFinal_ex(FgP0jMzeUU0) in decrypt mode, returned 0 for bad padding or a wrong final block without queueing an error. A caller that checksERR_get_error()after a failed decrypt found an empty queue. Onmain, a 16-byte block whose last padding byte is 0 givesret=0 length=0 error=0.LibreSSL 2.5.4's
evp_enc.c, lines 514–539, is the version the existing port and its debt entries follow, and it queues a reason on each failing branch:evp.h)EVP_CIPH_NO_PADDINGwith buffered bytes leftEVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH(138)EVP_R_WRONG_FINAL_BLOCK_LENGTH(109)finalbufferEVP_R_BAD_BLOCK_LENGTH(136)EVP_R_BAD_DECRYPT(100)The non-custom-cipher path of
DecryptFinalincore/libs/prx/libSceLibreSsl/src/EvpCipherCtx.cppnow queues the same reasons through the module's existingLibreSslPutError_nid_no_patch:ERR_LIB_EVP(6) and function 0xfff, asEVPerrordoes in that version'serr.h;ERR_get_error()returns, for example,0x06fff064forBAD_DECRYPT.Return values, output lengths and output bytes are unchanged. Nothing else in the file changes.
The existing debt entry's clause that failures queue no error code now names this exception. The rest of the entry is unchanged.
Tested
New
TestDecryptFinalErrorsin the registeredguest_libressl_evp_cipher_ctx(core/libs/tests/GuestLibreSslEvpCipherCtx.cpp). It runs nine cases through bothEVP_DecryptFinal_exandEVP_CipherFinal_exin decrypt mode:Each case checks the return value,
*outl == 0, untouched output bytes, the library, function and reason fields ofERR_get_error(), and that the queue is empty afterwards (for the valid cases, empty to begin with). Every existing assertion is kept.Linux x86-64 (Ubuntu 26.04, GCC 15, Release), the libSceLibreSsl tests:
main, the new test fails withdecrypt final scenario 0: ret=0 length=0 error=0x0 expected EVP/fff/100;mainwithout the new test).Mutation check: changing the
BAD_DECRYPTreason from 100 to 109 fails the test.Windows 11 (build 26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Release):
main'sEvpCipherCtx.cpp,guest_libressl_evp_cipher_ctxfails with the samedecrypt final scenario 0: ret=0 length=0 error=0x0 expected EVP/fff/100.python3 tools/check_conventions.py --base origin/main: all conventions checks passed.python3 tools/pr_overlap.py --branch fix/libscelibressl-decrypt-final-errors: no open PR changesEVP_DecryptFinal_exorEVP_CipherFinal_ex.EVP_CipherInit_exand merge cleanly in code.Evp.cpp) touches different functions.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code