feat(libSceLibreSsl3): implement ASN.1 type teardown and ECDSA_SIG lifetime #15826

Merged
fishingpvalues merged 6 commits from upstream-pr/15826 into main 2026-11-08 12:40:42 +00:00
fishingpvalues commented 2026-11-04 18:06:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fishingpvalues on 2026-11-04T18:06:31Z.


What

Implements four libSceLibreSsl3 exports that threw NotImplemented_nid_no_patch:

  • ASN1_TYPE_free (whL1IRBxFZA) frees an ASN1_TYPE by its type: an object through the 0x01/0x04/0x08 dynamic flags, a nested V_ASN1_ANY value by recursing into its inner type, a string or other primitive through the string no-free flag 0x10 and a zeroed data release, a dynamic object with no data without a write or a throw (as LibreSSL's null-safe freezero), and a boolean or null value without touching the inline union. The 16-byte layout is declared as Asn1Type with the type at offset 0, the union at offset 8 and a static assertion.
  • ECDSA_SIG_new (R3NyckUcClU) allocates the 16-byte { r, s } object with both components null, and queues ERR_R_MALLOC_FAILURE (65) through libSceLibreSsl when the guest heap refuses it.
  • ECDSA_SIG_set0 (xVv3qlSRldc) rejects a null component without mutation, frees the replaced BIGNUMs through libSceLibreSsl's BN_free, installs the new pair and returns 1.
  • ECDSA_SIG_free (HE-vihq-KKw), previously the unknown placeholder Unknown_HE_minus_vihq_minus_KKw, releases both components through BN_free and the 16-byte object; a null signature is a no-op.

Semantics follow LibreSSL 4.0.0 a_type.c, tasn_fre.c and ecs_lib.c, pinned by the existing 3rdparty/libressl-openbsd submodule. A null signature throws where LibreSSL dereferences it. docs/dev/debt/libSceLibreSsl3.md loses the three named rows and the one NID-only row (138 to 134 callable exports, 128 to 125 named and 10 to 9 NID-only) and gains one entry for the unverified PS5 ABI and console behaviour.

src/EcdsaSig.cpp gains the helpers and four exports; new tests/EcdsaSigLifetime.cpp is registered as guest_libressl3_ecdsa_sig_lifetime, and the four stubs leave AdditionalExports.cpp while the declarations gain their real signatures in include/Api.hpp. The branch was rebased onto current main 4ab649f4d8 (which had meanwhile added ECDSA_SIG_get0 in the same files) and the inventory counts were recalculated there.

Tested

Linux x86-64 (CachyOS, GCC 16.2.1), Release, BUILD_TESTING=ON, base main 105c9e4d91:

  • guest_libressl3_ecdsa_sig_lifetime covers the 16-byte layouts, successful and failing ECDSA_SIG_new, null-component and null-signature rejection, replacement ordering and freeing of the old BIGNUMs through a recording guest heap, destructor release, the object/string/boolean/null branches of ASN1_TYPE_free, a nested V_ASN1_ANY value, a dynamic object with null data, zeroed data release and the error queue. guest_libressl3_ecdsa_sig still passes.
  • ctest --test-dir build -R '^guest_libressl3_ecdsa_sig_lifetime$' --output-on-failure: 1/1 passed; guest_ampr_cpp_error and guest_libc_internal_exception_destructors also pass on the same tree.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • python3 tools/pr_overlap.py --branch pr-15826 --jobs 4: exit 2 only because it cannot confirm shared AdditionalExports.cpp/Api.hpp/debt files from conflicting PR heads; it reports no same exports.
  • Not run: Windows, a console, or a title.

Checklist

  • Based on current main; no other open PR implements these exports
  • 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)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5159174636 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15826). Originally posted by [fishingpvalues](https://github.com/fishingpvalues) on 2026-11-04T18:06:31Z. --- ### What Implements four `libSceLibreSsl3` exports that threw `NotImplemented_nid_no_patch`: - `ASN1_TYPE_free` (`whL1IRBxFZA`) frees an `ASN1_TYPE` by its type: an object through the `0x01`/`0x04`/`0x08` dynamic flags, a nested `V_ASN1_ANY` value by recursing into its inner type, a string or other primitive through the string no-free flag `0x10` and a zeroed data release, a dynamic object with no data without a write or a throw (as LibreSSL's null-safe `freezero`), and a boolean or null value without touching the inline union. The 16-byte layout is declared as `Asn1Type` with the type at offset 0, the union at offset 8 and a static assertion. - `ECDSA_SIG_new` (`R3NyckUcClU`) allocates the 16-byte `{ r, s }` object with both components null, and queues `ERR_R_MALLOC_FAILURE` (65) through libSceLibreSsl when the guest heap refuses it. - `ECDSA_SIG_set0` (`xVv3qlSRldc`) rejects a null component without mutation, frees the replaced BIGNUMs through libSceLibreSsl's `BN_free`, installs the new pair and returns 1. - `ECDSA_SIG_free` (`HE-vihq-KKw`), previously the unknown placeholder `Unknown_HE_minus_vihq_minus_KKw`, releases both components through `BN_free` and the 16-byte object; a null signature is a no-op. Semantics follow LibreSSL 4.0.0 [`a_type.c`](https://github.com/libressl/openbsd/blob/078b3d1df8ca2011c1605cd40418c58fa0f5b143/src/lib/libcrypto/asn1/a_type.c), [`tasn_fre.c`](https://github.com/libressl/openbsd/blob/078b3d1df8ca2011c1605cd40418c58fa0f5b143/src/lib/libcrypto/asn1/tasn_fre.c) and [`ecs_lib.c`](https://github.com/libressl/openbsd/blob/078b3d1df8ca2011c1605cd40418c58fa0f5b143/src/lib/libcrypto/ecdsa/ecs_lib.c), pinned by the existing `3rdparty/libressl-openbsd` submodule. A null signature throws where LibreSSL dereferences it. `docs/dev/debt/libSceLibreSsl3.md` loses the three named rows and the one NID-only row (138 to 134 callable exports, 128 to 125 named and 10 to 9 NID-only) and gains one entry for the unverified PS5 ABI and console behaviour. `src/EcdsaSig.cpp` gains the helpers and four exports; new `tests/EcdsaSigLifetime.cpp` is registered as `guest_libressl3_ecdsa_sig_lifetime`, and the four stubs leave `AdditionalExports.cpp` while the declarations gain their real signatures in `include/Api.hpp`. The branch was rebased onto current `main` `4ab649f4d8` (which had meanwhile added `ECDSA_SIG_get0` in the same files) and the inventory counts were recalculated there. ### Tested Linux x86-64 (CachyOS, GCC 16.2.1), Release, `BUILD_TESTING=ON`, base `main` `105c9e4d91`: - `guest_libressl3_ecdsa_sig_lifetime` covers the 16-byte layouts, successful and failing `ECDSA_SIG_new`, null-component and null-signature rejection, replacement ordering and freeing of the old BIGNUMs through a recording guest heap, destructor release, the object/string/boolean/null branches of `ASN1_TYPE_free`, a nested `V_ASN1_ANY` value, a dynamic object with null data, zeroed data release and the error queue. `guest_libressl3_ecdsa_sig` still passes. - `ctest --test-dir build -R '^guest_libressl3_ecdsa_sig_lifetime$' --output-on-failure`: 1/1 passed; `guest_ampr_cpp_error` and `guest_libc_internal_exception_destructors` also pass on the same tree. - `python3 tools/check_conventions.py --base origin/main`: passed. - `python3 tools/pr_overlap.py --branch pr-15826 --jobs 4`: exit 2 only because it cannot confirm shared `AdditionalExports.cpp`/`Api.hpp`/debt files from conflicting PR heads; it reports no same exports. - Not run: Windows, a console, or a title. ### Checklist - [x] Based on current `main`; no other open PR implements these exports - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
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!15826
No description provided.