Repository navigation
Conversation
PEM_read_bio_PrivateKey, PEM_read_RSAPrivateKey, PEM_read_bio_PUBKEY and PEM_write_bio_PrivateKey threw NotImplemented for every encrypted record and for every cipher passed to the writer. Follow LibreSSL 4.0.0 for both formats: - Proc-Type and DEK-Info records: PEM_get_EVP_CIPHER_INFO, PEM_do_header and EVP_BytesToKey with AES-128/192/256-CBC. - ENCRYPTED PRIVATE KEY records: the X509_SIG, PBES2 and PBKDF2 structures with the tasn_dec.c rules, then PKCS12_pbe_crypt, EVP_PBE_CipherInit and the PBES2 and PBKDF2 key generators with the HMAC digests this port has. - Writing with a cipher: PKCS8_encrypt with PKCS5_pbe2_set. - The pass phrase from the callback, or from u when the callback is null. Ciphers, PBE schemes and digests this port has no primitive for, the terminal prompt and three BER forms still throw; the debt fragment lists them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The PEM readers decrypted AES records only. Add the DES family from LibreSSL 4.0.0: - DEK-Info records in DES-CBC, DES-EDE-CBC and DES-EDE3-CBC. - PBES2 with the DES-CBC and DES-EDE3-CBC OIDs. - PBES1 (PKCS5_PBE_keyivgen): PBE-MD5-DES and PBE-SHA1-DES. - The PKCS#12 schemes PBE-SHA1-3DES and PBE-SHA1-2DES, with PKCS12_key_gen_uni. The blocks are decrypted with mbedtls and the checks of EVP_DecryptFinal_ex are redone on the result, with their errors. The two MD2 schemes now queue EVP_R_UNKNOWN_DIGEST, as 4.0.0 has no MD2, instead of throwing. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A DSA PRIVATE KEY record threw, and a DSA key in PKCS#8 was an unsupported algorithm. Follow LibreSSL 4.0.0: - old_dsa_priv_decode: d2i_DSAPrivateKey, dsa_check_key, then q divides p - 1, g has order q and q is prime, each with its error. - dsa_priv_decode for PKCS#8, with the four alias OIDs; the public key is computed from the private one. - dsa_priv_encode, so PEM_write_bio_PrivateKey writes the key back. - The DSA object has the dsa_st layout; EVP_PKEY_free releases it. The ASN.1 reader of PemEncryption.cpp moves to Asn1Reader.hpp so both files share it. Bignum arithmetic comes from mbedtls. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…PrivateKey_bio d2i_PUBKEY and PEM_read_bio_PUBKEY refused a DSA SubjectPublicKeyInfo as an unsupported algorithm. They now follow dsa_pub_decode of LibreSSL 4.0.0: parameters as a SEQUENCE are decoded and the key is checked with dsa_check_key; absent or NULL parameters give a key that holds only its public number; any other parameter type is a parameter encoding error. d2i_PrivateKey_bio read a traditional DSA key, a SEQUENCE of six elements, as an RSA key and failed. d2i_AutoPrivateKey counts the elements and takes six as DSA. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…blic-keys Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ted-pem-private-keys
main dropped the file's GuestWritablePreservingErrno wrapper now that GuestWritable_nid_no_patch keeps errno itself; use it for the slot a PEM private key read replaces. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…bressl3-des-pem-private-keys
…3-dsa-pem-private-keys
…3-dsa-public-keys
catminou4
left a comment
There was a problem hiding this comment.
Built libSceLibreSsl3 and ran guest_libressl3_pem_keys_tests on Linux (x86-64, GCC 11): passes (exit 0). Large new surface (RSA_free, d2i_RSAPublicKey_bio, encrypted PEM, DSA keys, PKCS#8 KeyDer), so no meaningful main control.
The debt fragment is exemplary — it pins each behavior to a specific LibreSSL 4.0.0 source file and line, states plainly what is "not measured on a PS5," and enumerates the exact gaps (unsupported ciphers/digests, missing i2d_PUBKEY, Miller-Rabin vs Baillie-PSW, meth-carrying keys throwing on free). Two things worth a maintainer's eye before merge, both already flagged in the note: DSA_new does not exist yet so meth stays null and DSA public-key writes are stubs, and EVP_PKEY_ASN1_METHOD is a static list so writes are always PKCS#8. Nothing here looks like made-up success — the unimplemented paths throw through NotImplemented_nid_no_patch.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 610cc26e76:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_libressl3_pem_keys_testsbuilt cleanly. - CTest (
guest_libressl3_pem_keys):1/1 Test #4826: guest_libressl3_pem_keys ......... Passed 7.11 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceLibreSsl3/src/KeyDer.cpp,core/libs/prx/libSceLibreSsl3/src/PemKeys.cpp,core/libs/prx/libSceLibreSsl3/src/PkeyLifecycle.cpp,core/libs/prx/libSceLibreSsl3/src/DsaKeys.cpp,core/libs/prx/libSceLibreSsl3/src/PemEncryption.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #4826: guest_libressl3_pem_keys .........Subprocess aborted***Exception: 0.50 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- Verified DsaDecodePublicKey_nid_no_patch against LibreSSL 4.0.0 dsa_pub_decode parameter handling (SEQUENCE, absent/NULL, invalid types) and error codes
- Checked DsaDecodeTraditionalKey_nid_no_patch and DsaDecodePkcs8Key_nid_no_patch for memory leaks and resource lifetime management
- Verified ASN.1 DER decoding logic in Asn1Reader.hpp for integer bounds, tag parsing, and negative zero/two's complement edge cases
- Validated DSA_free / DsaFree_nid_no_patch guest pointer memory access checks (GuestCopyIn_nid_no_patch, GuestWritable_nid_no_patch) and atomic reference counting
- Confirmed AGENTS.md compliance regarding comments, conventions, and absence of undocumented silent stubs or hardcoded title IDs
Looks Good To Me
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The targeted DSA public key and BIO decoding paths show no verified blocking defect at head 610cc26e764296ee59e2820ca8cfa871f8304f70; the full change was not reviewed.
What I ran
Read the prepared description, commit list, manifest, and relevant diff excerpts. Read DsaKeys.cpp lines 1–220 and KeyDer.cpp lines 1450–1615 through repo_read.py. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Targeted code review | not run | Partial inspection only |
| Tests | not run | No local execution |
| Console behavior | not run | Not verified |
Negative control
Not run; the reported mutations were supplied by the author and were not independently executed.
Findings
Blocking
None identified in the inspected DSA decode paths.
Non-blocking
None.
Sources
Reviewed the prepared diff for KeyDer.cpp and DsaKeys.cpp, including the DSA public-key decoder and the d2i_PrivateKey_bio dispatch changes. Those claims are limited to the inspected code; no commit-pinned links were available through the reader.
Not verified
The manifest lists 10 changed files, all included. Full text was read for 2 changed files: DsaKeys.cpp (partial range) and KeyDer.cpp (partial range). The other 8 changed files were not read in full; the diff was inspected only around the targeted DSA paths and test excerpts. Tests, build checks, CI, console behavior, and the author-reported test results were not independently verified.
To get this to a good state
Nothing is required. Optional: complete review of the remaining changed files and run the reported checks before relying on this as a full PR review.
…ted-pem-private-keys # Conflicts: # docs/dev/debt/changes/feat-libressl3-rsa-free-rsapublickey-bio.md
…bressl3-des-pem-private-keys # Conflicts: # docs/dev/debt/changes/feat-libressl3-rsa-free-rsapublickey-bio.md
…3-dsa-pem-private-keys
…3-dsa-public-keys
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this change; the inspected DSA decode paths and error handling support the stated behavior.
What I ran
- Reviewed head
5c17a4684c9824a22f045548568bc3f226ae5241; base ismain. No commands or tests were run. - Read
description.md,commits.md,diff.patch,manifest.json,README.md, and the changed source ranges forDsaKeys.cpp,Asn1Reader.hpp,KeyDer.cpp,PemKeys.cpp, andCMakeLists.txt.
Results
| Check | Result | Note |
|---|---|---|
| DSA public key decode | passed | Parameters and optional parameter handling inspected |
| Traditional DSA auto-detection | passed | Six-element route inspected |
| Programmatic tests | not run | Author-reported results only |
| Review coverage | partial | Several changed files were not read |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of PemEncryption.cpp, PemKeys.cpp, tests/PemKeys.cpp, and the debt change was available but not read in full; only the noted PemKeys.cpp range was inspected. The full text of DsaKeys.hpp and PemEncryption.hpp was present in the diff but their callers were not audited. No build, test, convention check, or console run was performed. The author reports Windows 11/MinGW test results; these were not independently verified. files.json was not available as a review document; the prepared manifest marks each changed file as included.
To get this to a good state
Nothing is required. The unverified areas are coverage limits, not confirmed defects.
|
Thanks for the work. I'm closing this because I know of no title that loads a DSA key, and it builds on the encrypted PEM changes that were closed for the same reason (#26409, #26410), so the whole stack is large to review for nothing a game reaches today. If a title imports one of these paths, please say so and I'll reopen it. |
What
Resubmission of #25445, which was closed when my fork left the fork network (I switched it to private by mistake) and cannot be reopened. Same head commit
a9981c5159c; the reviews and the discussion are on #25445.Stacked on #26409, #26410 and #26414: only the last two commits are new (the change and a merge of
main).Two DSA paths that #26414 left failing and listed in its debt entry. Reference: LibreSSL 4.0.0,
libressl/openbsd@ce488b78.1. A DSA
PUBLIC KEY.d2i_PUBKEYandPEM_read_bio_PUBKEYrefused a DSA SubjectPublicKeyInfo withX509_R_UNSUPPORTED_ALGORITHM. They now followdsa_pub_decode:dsa_check_keyDSA_R_PARAMETER_ENCODING_ERRORBytes after the INTEGER inside the BIT STRING are left alone, as
d2i_ASN1_INTEGERleaves them. The five DSA object identifiers give the same key type, as they already did for private keys. A failure ends withX509_R_PUBLIC_KEY_DECODE_ERROR, whichX509_PUBKEY_get0adds.2. A traditional DSA key through
d2i_PrivateKey_bio.d2i_AutoPrivateKeypicks the type from the number of elements of the outer SEQUENCE:The port tried six elements as RSA and failed. It now calls the decoder that the
DSA PRIVATE KEYlabel already uses (d2i_PrivateKeyforEVP_PKEY_DSA).Left as it was, in the debt fragment:
i2d_PUBKEYis a stub, so a DSA public key is read but not written; an algorithm parameter that is not NULL, an OID or a SEQUENCE is refused by the AlgorithmIdentifier reader beforedsa_pub_decodesees it.Tested
Windows 11, MinGW GCC 15.2. Not tested on a console.
guest_libressl3_pem_keys, two new functions. The public halves of the two private test keys (1024 and 2048 bits) were produced by OpenSSL 3.2.4 (openssl pkey -pubout); the test checks that they are byte for byte the DER it builds itself, then reads them throughd2i_PUBKEYandPEM_read_bio_PUBKEYand compares p, q, g and the public number. Then: the five object identifiers; absent and NULL parameters; a public number of 1, accepted without parameters and refused with them; bytes after the INTEGER; an OID as parameter, a SEQUENCE of two integers, an OCTET STRING as key, a public number equal to p and an even q, each with its whole error queue. Ford2i_PrivateKey_bio: both traditional keys, and two six-element inputs that fail, whose error queue has to be the one theDSA PRIVATE KEYlabel gives for the same bytes, without the PEM error.guest_libressl3_key_derpasses without a change to its file.X509_R_PUBLIC_KEY_DECODE_ERRORdropped; the input pointer not advanced; parameters required, NULL parameters refused, another parameter type accepted or reported as a decode error; parameters not read, read with the private key layout, or failing withoutDSA_R_DECODE_ERROR; the key INTEGER failing without its error; the number stored as the private one; the key never checked, or checked without parameters; six elements read as RSA or as EC, and five or nine elements read as DSA.python tools/check_conventions.py --base origin/mainandpython core/libs/tests/test_public_headers.py --audit-onlypass.python tools/debt_fold.py --checkfails for the reason it fails onmaintoday (twolibkernel_sysfragments, docs(debt): retarget two libkernel_sys fragments at their libkernel entries #25313 and fix(docs): open the libkernel section for two debt fragment entries #25318).Not verified. The expected results come from reading the LibreSSL source and from the OpenSSL-made vectors, not from running the console module.
Overlap (
python tools/pr_overlap.py --branch feat/libressl3-dsa-public-keys):main. It merged 39 open pull requests that touch the same files without a conflict, and reports two, both on lines that come from the pull requests below this one, not from its own commit: fix(libSceLibreSsl3): validate guest EVP_PKEY pointers in lifecycle helpers #23438 (PkeyLifecycle.cpp, the lines feat(libSceLibreSsl3): read and write DSA private keys in PEM #26414 changes) and fix(libSceLibreSsl3): accept BER long-form lengths in the key decoders #25390 (line 6 of the shared debt fragment, thed2i_RSAPublicKey_bioentry). fix(libSceLibreSsl3): accept BER long-form lengths in the key decoders #25390 also changesKeyDer.cpp; it merges with this branch without a conflict there.mainthemselves. Fifteen share onlyCMakeLists.txt. feat(libSceLibreSsl): implement EC_KEY_get0_private_key and EC_KEY_set_private_key #11146 sharesKeyDer.cppandtests/PemKeys.cpp; I read its diff: it is about EC private keys and does not touchDecodeSpki,ParseAlgorithmord2i_PrivateKey_bio.dsa_pub_decode,d2i_AutoPrivateKeyor DSA public keys.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)