Repository navigation
fix(libSceLibreSsl3): accept the RSA digests of LibreSSL 4.0.0 check_padding_md - #25079
Merged
oneandonlydean merged 1 commit intoNov 21, 2026
Merged
Conversation
…padding_md CheckPaddingDigest carried the digest list of the bundled 3.4.1 submodule. LibreSSL 4.0.0 also accepts SHA-512/224, SHA-512/256 and the four SHA-3 digests, so EVP_PKEY_CTX_ctrl refused EVP_sha512_256, which this library exports, with RSA_R_INVALID_DIGEST. The list now matches 4.0.0, and PKCS#1 v1.5 signatures get the DigestInfo OID of SHA-512/256. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PrivacyOnion
approved these changes
Nov 21, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against b8bd87c60c:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_libressl3_pkey_context_testsbuilt cleanly. - CTest (
guest_libressl3_pkey_context):1/1 Test #4728: guest_libressl3_pkey_context ..... Passed 6.43 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceLibreSsl3/src/PkeyContext.cpp,core/libs/prx/libSceLibreSsl3/src/RsaCrypto.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #4728: guest_libressl3_pkey_context .....Subprocess aborted***Exception: 3.47 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified NID mapping and constants for SHA-512/224, SHA-512/256, SHA3-224, SHA3-256, SHA3-384, SHA3-512 against LibreSSL 4.0.0 obj_mac.num and check_padding_md in PkeyContext.cpp
- Verified ASN.1 DER DigestInfo OID prefix 2.16.840.1.101.3.4.2.6 ({0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x06}) for NID 1030 in RsaCrypto.cpp DigestIdentifier
- Verified technical debt fragment docs/dev/debt/changes/fix-libressl3-rsa-padding-digests.md matches repository format and documents the five unsupported OIDs throwing NotImplemented_nid_no_patch
- Verified comprehensive unit test coverage in core/libs/prx/libSceLibreSsl3/tests/PkeyContext.cpp covering PKCS#1 v1.5 and PSS signing, verification, negative digest rejection, and EVP_MD_CTX workflows
Looks Good To Me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
EVP_PKEY_CTX_ctrlrefusedEVP_sha512_256()for an RSA key:EVP_PKEY_CTRL_MDreturned 0 withRSA_R_INVALID_DIGEST.EVP_DigestSignInit,EVP_SignFinalandEVP_VerifyFinalgo through the same check, so no RSA signature with SHA-512/256 could be made or verified, although this library exports that digest.The cause:
CheckPaddingDigestinPkeyContext.cppcarried the digest list of the bundled 3.4.1 submodule. LibreSSL 4.0.0, the reference of this library, has six more entries incheck_padding_md:Two changes:
CheckPaddingDigestaccepts the 15 digest types of 4.0.0 (NIDs 1029 to 1034 added, values fromobj_mac.num).DigestIdentifierinRsaCrypto.cpp, the table PKCS#1 v1.5 signing takes theDigestInfoOID from, gets SHA-512/256: 2.16.840.1.101.3.4.2.6 (nist_hashalgs 6inobjects.txt).What a title can reach today: only SHA-512/256. No export of this library returns a SHA-512/224 or SHA-3 digest method. Those five types are in the list because it is the list of the source; with PKCS#1 v1.5 padding they pass the control and then throw
NotImplementedwhen signing, as any digest without an OID in the table does. The debt fragment says so.EVP_PKEY_CTRL_RSA_MGF1_MDdoes not go through this list in the source and is not changed.Tested
Windows 11, MinGW GCC 15.2. Not tested on a console.
Vectors. The RSA key is the one the test file already has. The message digest and two signatures were made with OpenSSL 3.2.4:
The test (
guest_libressl3_pkey_context), two new functions:EVP_PKEY_CTRL_MDunder PKCS#1 padding, by the switch to PSS, and byEVP_PKEY_CTRL_MDunder PSS, with an empty queue; types 0, 3, 999, 1026, 1028 and 1035 are refused withRSA_R_INVALID_DIGESTunder both paddings and leave the current digest unchanged; a hand-made method of type 1029 passes the control and then throws when it signs;EVP_DigestSignInit/EVP_DigestSignFinalandEVP_SignFinal/EVP_VerifyFinalon the message, compared with the OpenSSL signature.With the two source files from
mainthe test fails at the first new check (type 1029 refused); with the change it passes.Negative controls. 13 mutations, each rebuilt and run on its own, all make the test fail: each of the six new
caselines removed, three NID constants changed, the OID entry removed, its last byte changed, the SHA-512 OID used instead, and the OID also given to type 1029.python tools/check_conventions.py --base origin/mainandpython tools/debt_fold.py --checkpass.Overlap (
python tools/pr_overlap.py --branch fix/libressl3-rsa-padding-digests):EVP_PKEY_CTX_ctrlfor guest pointers, merges with this branch without a conflict.mainand sharestests/PkeyContext.cpp. I read its diff: in that file it changesDigestSignInitWithoutDigest, 60 lines above the place where this PR adds its two test 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)