feat(libressl3): implement ASN.1 object header parsing #14465

Merged
Ninot1Quyi merged 5 commits from upstream-pr/14465 into main 2026-11-13 11:06:13 +00:00
Ninot1Quyi commented 2026-11-01 14:43:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ninot1Quyi on 2026-11-01T14:43:21Z.


What

Implement the previously throwing ASN1_get_object export in libSceLibreSsl3, using the existing bounded BER identifier/length readers. Valid headers advance the input cursor and return the tag, class, length and constructed/indefinite flags. A truncated payload still returns its decoded header with the error flag; malformed headers reset the outputs without advancing the cursor. Errors enter the existing parent-library queue.

The behavior reference is LibreSSL 4.0.0, pinned to OpenBSD commit ce488b78e0bd994780569df718596b9776ff681a. The new code is independently written and reuses project code; no third-party sources were copied. Console ABI/error-queue sharing is unverified and documented, as are exceptions for negative bounds and faulting null arguments. The existing integer decoder behavior is unchanged.

Based on main f1a7b02028ae50adaf6c5aaaef892a51841b25bf. No dependency on the separate ASN1_TIME_diff candidate.

Tested

Linux x86-64:

  • Full product Release build passed. All 9 guest_libressl3_ CTests passed, including the new object-header test linked to the real guest libraries (0.01 seconds), and the existing ASN.1 integer decoder regression.
  • Actual production IntegerDecoder.cpp and Error.cpp with the committed fixture passed a direct GCC C++20 build and ASan/UBSan with detect_leaks=0. The focused link discards unrelated unused exports; the full build/CTest above validates integration.
  • A source-built LibreSSL 4.0.0 oracle matched 165,488 cases, comparing status, cursor, length, tag, class, and error queue. Cases include all two-byte headers, deterministic random/truncated buffers, oversized lengths and high tags.
  • Main-source negative control compiled against the same fixture and failed at the original NotImplemented export (SIGABRT/134), as expected.
  • Conventions and diff checks passed. Public-header audit: 399 libraries, 26,742 exports. Script registration: 238 scripts.

Overlap audit: all 1,669 open PRs were scanned. The checker exited 2 because 11 shared branches could not merge with main. The 22 shared heads were unchanged from the earlier full manual audit; the additional shared IntegerDecoder.cpp patch in #14292 was read in full and only changes d2i fault exceptions. No same export or same new test exists. Debt text overlaps mechanically with #14292 and #14366; this implementation does not depend on them.

The complete CTest suite, LSan, PS5/title behavior and Windows/macOS were not tested. Upstream CI has not run for this unpublished candidate. No CI conditions were changed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source — no new production dependency
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none verified
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5108415006 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14465). Originally posted by [Ninot1Quyi](https://github.com/Ninot1Quyi) on 2026-11-01T14:43:21Z. --- ### What Implement the previously throwing `ASN1_get_object` export in libSceLibreSsl3, using the existing bounded BER identifier/length readers. Valid headers advance the input cursor and return the tag, class, length and constructed/indefinite flags. A truncated payload still returns its decoded header with the error flag; malformed headers reset the outputs without advancing the cursor. Errors enter the existing parent-library queue. The behavior reference is LibreSSL 4.0.0, pinned to OpenBSD commit `ce488b78e0bd994780569df718596b9776ff681a`. The new code is independently written and reuses project code; no third-party sources were copied. Console ABI/error-queue sharing is unverified and documented, as are exceptions for negative bounds and faulting null arguments. The existing integer decoder behavior is unchanged. Based on main `f1a7b02028ae50adaf6c5aaaef892a51841b25bf`. No dependency on the separate ASN1_TIME_diff candidate. ### Tested Linux x86-64: - Full product Release build passed. All 9 `guest_libressl3_` CTests passed, including the new object-header test linked to the real guest libraries (0.01 seconds), and the existing ASN.1 integer decoder regression. - Actual production IntegerDecoder.cpp and Error.cpp with the committed fixture passed a direct GCC C++20 build and ASan/UBSan with `detect_leaks=0`. The focused link discards unrelated unused exports; the full build/CTest above validates integration. - A source-built LibreSSL 4.0.0 oracle matched 165,488 cases, comparing status, cursor, length, tag, class, and error queue. Cases include all two-byte headers, deterministic random/truncated buffers, oversized lengths and high tags. - Main-source negative control compiled against the same fixture and failed at the original NotImplemented export (SIGABRT/134), as expected. - Conventions and diff checks passed. Public-header audit: 399 libraries, 26,742 exports. Script registration: 238 scripts. Overlap audit: all 1,669 open PRs were scanned. The checker exited 2 because 11 shared branches could not merge with main. The 22 shared heads were unchanged from the earlier full manual audit; the additional shared IntegerDecoder.cpp patch in #14292 was read in full and only changes d2i fault exceptions. No same export or same new test exists. Debt text overlaps mechanically with #14292 and #14366; this implementation does not depend on them. The complete CTest suite, LSan, PS5/title behavior and Windows/macOS were not tested. Upstream CI has not run for this unpublished candidate. No CI conditions were changed. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source — no new production dependency - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none verified - [x] GPUs tested: n/a - [x] AI-assisted: yes
CnRJay commented 2026-11-01 19:47:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:47:03Z.

Review: COMMENTED


Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (Unblocks: none is allowed), and it contained no code review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729914305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14465#pullrequestreview-5729914305). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:47:03Z. **Review:** COMMENTED --- Withdrawn. This review applied a title-ID/log requirement that is not in CONTRIBUTING (`Unblocks: none` is allowed), and it contained no code review.
MarcZX10 commented 2026-11-02 05:50:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T05:50:26Z.

Review: COMMENTED


Reviewed — no blocking findings

This replaces the ASN1_get_object stub with a BER header parser: identifier, length (short, long and indefinite forms), and the constructed, indefinite and too-long flags. The Windows CTest run was cancelled, so nothing ran for this head. The helpers advance the input span by reference, so the caller's pointer moves past the header. The error codes and the test follow the rules in the debt entry. The test was read, not run.

What I ran

  • Head 1a0d0b71e512fc129344d5ed8fc2fd5301eafe21; base d8b60b46ed425b117b6fae18900fe6ab81ed6661. 6 files, +142/-8: src/IntegerDecoder.cpp (+34), tests/ObjectHeader.cpp (+94, new), CMakeLists.txt (+10, new guest_libressl3_object_header test), include/Api.hpp (declaration with five parameters), AdditionalExports.cpp (stub removed), docs/dev/debt/libSceLibreSsl3.md (+6/-2).
  • Read ASN1_get_object_nid_postfix, the ReadIdentifier and ReadLength helpers it calls, and the new test in full, plus the debt diff and the declaration.
  • Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check passed. ABI audit passed: 270 symbols, no findings.
  • Hosted: the Windows check-run windows is cancelled, so there is no CTest result for this head. Linux and the relinker jobs are skipped.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout
Mergeability and dependencies passed stack check passed
ABI audit (main-checkout tool) passed 270 symbols, no findings
Declaration matches the definition passed five parameters in Api.hpp and in IntegerDecoder.cpp
Input advance (*input moves past the header) passed by reading ReadIdentifier and ReadLength take the span by reference
Error codes (header too long 123, length too long 155, return 0x80) passed by reading as in the debt entry
Null and invalid arguments throw without writing outputs passed by reading checks run before any output is written
guest_libressl3_object_header (hosted) not run the Windows run was cancelled
Debt entry export counts (175, 165, 10; 115 of 126) not verified not recounted
Build (Windows and Linux) not run no local build
Negative controls not run no local build
Hosted CI not complete windows cancelled; linux, register-context, relinkers and write-watch skipped; report and conventions passed
Read-only check output

Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: passed (270 symbols). Stack check: passed. Hosted: gh api repos/boykopovar/AnyPS5/commits/1a0d0b71e512fc129344d5ed8fc2fd5301eafe21/check-runs.

Negative control

Not run here. A negative control needs a build, and code from this head is not run here.

Findings

Blocking

None.

Non-blocking

  • The Windows check was cancelled, so the new test has no hosted result. The test is table-driven (every identifier byte whose low five bits are not 31, every short length from 0 to 127, plus the fault and long-form cases), so a run is worth having.
  • The debt entry's export counts changed from 176 (50 named, 126 NID-only) to 175 (165 named, 10 NID-only), and the table sentence from 116 to 115 of 126. The arithmetic is internally consistent (165 + 10 = 175), but I did not recount the export list.

Sources

Not verified

  • Whether the test passes, on Windows or Linux.
  • The export counts in the debt entry.
  • The behaviour of the reference LibreSSL 4.0.0 for null arguments and for the length rules, which the debt entry says it follows.

To get this to a good state

  • Nothing blocking. A run of guest_libressl3_object_header on Windows and Linux would settle the test result. Recounting the export list would make the debt counts checkable.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732565218 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14465#pullrequestreview-5732565218). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T05:50:26Z. **Review:** COMMENTED --- # Reviewed — no blocking findings This replaces the `ASN1_get_object` stub with a BER header parser: identifier, length (short, long and indefinite forms), and the constructed, indefinite and too-long flags. The Windows CTest run was cancelled, so nothing ran for this head. The helpers advance the input span by reference, so the caller's pointer moves past the header. The error codes and the test follow the rules in the debt entry. The test was read, not run. ## What I ran - Head `1a0d0b71e512fc129344d5ed8fc2fd5301eafe21`; base `d8b60b46ed425b117b6fae18900fe6ab81ed6661`. 6 files, +142/-8: `src/IntegerDecoder.cpp` (+34), `tests/ObjectHeader.cpp` (+94, new), `CMakeLists.txt` (+10, new `guest_libressl3_object_header` test), `include/Api.hpp` (declaration with five parameters), `AdditionalExports.cpp` (stub removed), `docs/dev/debt/libSceLibreSsl3.md` (+6/-2). - Read `ASN1_get_object_nid_postfix`, the `ReadIdentifier` and `ReadLength` helpers it calls, and the new test in full, plus the debt diff and the declaration. - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check passed. ABI audit passed: 270 symbols, no findings. - Hosted: the Windows check-run `windows` is cancelled, so there is no CTest result for this head. Linux and the relinker jobs are skipped. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout | | Mergeability and dependencies | passed | stack check passed | | ABI audit (main-checkout tool) | passed | 270 symbols, no findings | | Declaration matches the definition | passed | five parameters in `Api.hpp` and in `IntegerDecoder.cpp` | | Input advance (`*input` moves past the header) | passed by reading | `ReadIdentifier` and `ReadLength` take the span by reference | | Error codes (header too long 123, length too long 155, return 0x80) | passed by reading | as in the debt entry | | Null and invalid arguments throw without writing outputs | passed by reading | checks run before any output is written | | `guest_libressl3_object_header` (hosted) | not run | the Windows run was cancelled | | Debt entry export counts (175, 165, 10; 115 of 126) | not verified | not recounted | | Build (Windows and Linux) | not run | no local build | | Negative controls | not run | no local build | | Hosted CI | not complete | windows cancelled; linux, register-context, relinkers and write-watch skipped; report and conventions passed | <details><summary>Read-only check output</summary> Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: passed (270 symbols). Stack check: passed. Hosted: `gh api repos/boykopovar/AnyPS5/commits/1a0d0b71e512fc129344d5ed8fc2fd5301eafe21/check-runs`. </details> ## Negative control Not run here. A negative control needs a build, and code from this head is not run here. ## Findings **Blocking** None. **Non-blocking** - The Windows check was cancelled, so the new test has no hosted result. The test is table-driven (every identifier byte whose low five bits are not 31, every short length from 0 to 127, plus the fault and long-form cases), so a run is worth having. - The debt entry's export counts changed from 176 (50 named, 126 NID-only) to 175 (165 named, 10 NID-only), and the table sentence from 116 to 115 of 126. The arithmetic is internally consistent (165 + 10 = 175), but I did not recount the export list. ## Sources - Implementation: https://github.com/boykopovar/AnyPS5/blob/1a0d0b71e512fc129344d5ed8fc2fd5301eafe21/core/libs/prx/libSceLibreSsl3/src/IntegerDecoder.cpp - Test: https://github.com/boykopovar/AnyPS5/blob/1a0d0b71e512fc129344d5ed8fc2fd5301eafe21/core/libs/prx/libSceLibreSsl3/tests/ObjectHeader.cpp - Registration: https://github.com/boykopovar/AnyPS5/blob/1a0d0b71e512fc129344d5ed8fc2fd5301eafe21/core/libs/prx/libSceLibreSsl3/CMakeLists.txt - Debt entry: https://github.com/boykopovar/AnyPS5/blob/1a0d0b71e512fc129344d5ed8fc2fd5301eafe21/docs/dev/debt/libSceLibreSsl3.md ## Not verified - Whether the test passes, on Windows or Linux. - The export counts in the debt entry. - The behaviour of the reference LibreSSL 4.0.0 for null arguments and for the length rules, which the debt entry says it follows. ## To get this to a good state - Nothing blocking. A run of `guest_libressl3_object_header` on Windows and Linux would settle the test result. Recounting the export list would make the debt counts checkable.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!14465
No description provided.