feat(libSceLibreSsl): implement RSA_verify_PKCS1_PSS and RSA_padding_add_PKCS1_PSS #11175
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11175"
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 ahmadmuj on 2026-10-25T20:37:30Z.
What
Implements
RSA_verify_PKCS1_PSSandRSA_padding_add_PKCS1_PSS, following LibreSSL 2.5.4 rsa_pss.c andPKCS1_MGF1in rsa_oaep.c.Head
b6882dc6619b295599e5310fc73e16a0041671e4merges maine16cf70591044d50e01e7111eadd0a7d0720be7ewithout rewriting published history. #11151, #11128, #10915 and #9448 are merged. The common guarded RSA body matches main exactly; the PSS extension and its test stay unchanged.The merge resolves only CMake placement. It keeps the PSS target and main's private-RSA/PKEY targets once. Main's native32/legacy56 PKEY split and the documented forwarding gaps stay unchanged. No unsupported-throw assertion is added.
Fresh Linux Release checks: 404-step build passes. RSA, private RSA, PSS, EVP, errors, legacy PKEY lifecycle/RSA and native PKEY lifecycle pass (8/8). The inherited actual-NID binding check and 65 public headers pass. Conventions and whitespace pass. Earlier differential and mutation results below are reused for unchanged feature code. Windows and firmware reports by other contributors remain separate evidence.
rsa->n(bit count andRSA_size), like 2.5.4. No method slot is involved. A non-normalised or negativenbehaves the wayBN_num_bitswould.EVP_DigestInit_ex/Update/Final_exon a local context, so a guest-definedEVP_MDgets the same calls in the same order.hLenover 64 returns 0 throughEVP_DigestFinal_ex, as in 2.5.4.EM[0] = 0for a modulus withbits % 8 == 1before its length check, and a nullHashorsLen < -2returns 0 beforersaorEMis read.arc4random_buf.hLen + sLen + 2, ansLenof -2 that leaves a negative salt (at the salt digest update), an empty masked DB in verify (read pastmalloc(0)), MGF1 with a 0-byte digest, and the null pointers it dereferences. Verify with a masked DB length of -1 returns 0 and queuesERR_R_MALLOC_FAILURE, because 2.5.4'smalloc(SIZE_MAX)fails there.RSAerrorinrsa_pss.c), and a success queues none. The EVP errors 2.5.4 adds for a null or over-64-byte digest are missing, since #9448's EVP functions queue none (in the debt entry). One new debt entry; the merged debt entry has no pending count.Verify accepts a key from
d2i_RSA_PUBKEYand pairs withRSA_public_decryptusingRSA_NO_PADDING. Add pairs withRSA_private_encryptfrom #11151. Main now implementsBN_newandBN_bin2bnfor private-key construction.Tested
The following feature checks predate this alignment. Fresh checks appear above.
Ubuntu 24.04 on WSL2, GCC 13.3, Release, on
main+ #11151 + #9448.libcrypto.a: a host generator recorded 6420 cases. They cover 80 moduli (124 to 4096 bits, everybits % 8class near the length limits), MD5/SHA-256/SHA-384/SHA-512,sLen-1, -2, 0, small, max and max+1, and single-byte mutations of 2.5.4-made EMs (first octet, trailer, masked DB, H, salt, separator, wrong mHash). A guest harness (not committed) got these results:RSA_verify_PKCS1_PSSaccepts all 267 salted outputs from the emulator.ERR_R_MALLOC_FAILUREhit. The only differences are 16 null-digest rows where 2.5.4 also queues the EVP code (the gap above).guest_libressl_rsa_psscovers:sLen0, and 2.5.4-made EMs with mutations;Hash,sLen < -2, trailer before the empty-DB throw);EVP_MDs whose init fails or whose size is 0, 65 orINT_MAX.RSA_padding_add_PKCS1_PSS_nid_postfix not implemented). Each of 15 mutations fails the test, among them: no DB top-bit mask, an MGF1 counter starting at 1,EM[0]zeroed only on success, a zero salt, the empty-DB throw moved above the trailer check, and the negative-salt throw moved before the digest calls.ctest -R libressl: 17/17 pass onmain9857eee+ #10915939a194+ #9448b2583e3.public_headers: 65/65 pass.check_conventions.py --base origin/mainpasses.EVP_sha1.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T20:39:30Z.
Review: COMMENTED
I reviewed the PSS implementation at head
edf25645a5b39a8e31de065f47919910f5bd4a38against the pinned LibreSSL 2.5.4 behavior, including the encoded-message length/top-bit handling,-1and-2salt modes, MGF1 counter encoding, and digest input order. I did not find a concrete correctness issue in the reviewed code. The committed tests cover boundary and mutation cases, and the PR reports differential results against the reference implementation.Independent checks here:
tools/check_conventions.py --base upstream/main --head HEAD,git diff --check upstream/main...HEAD, and C++20 syntax compilation ofRsa.cppplusGuestLibreSslRsaPss.cpppassed. I could not run the guest test binary: this worktree has an uninitialized mbedTLS submodule, so the full runtime test/build remains unverified here. Hosted eligibility, conventions, intake, labels, and report checks passed; product build jobs were skipped. I’m leaving this as a comment rather than approval until runtime/hosted build evidence is available.