Skip to content

feat(libSceLibreSsl3): implement X509V3_EXT_conf_nid - #22761

Merged
oneandonlydean merged 4 commits into
boykopovar:mainfrom
fishingpvalues:feat/libressl3-x509v3-ext-conf-nid
Nov 18, 2026
Merged

oneandonlydean merged 4 commits into
boykopovar:mainfrom
fishingpvalues:feat/libressl3-x509v3-ext-conf-nid

Conversation

@fishingpvalues

Copy link
Copy Markdown
Contributor

What

Implements the X509V3_EXT_conf_nid export (TKGJOgbeyuA) as
X509V3_EXT_conf_nid_nid_postfix in a new src/X509V3ExtConfNid.cpp, following LibreSSL 4.0.0
x509_conf.c (X509V3_EXT_conf_nid, X509V3_EXT_nconf_nid, v3_check_critical,
v3_check_generic, v3_generic_extension, do_ext_nconf), v3_utl.c (string_to_hex,
s2i_ASN1_INTEGER, X509V3_parse_list) and asn1_gen.c (ASN1_generate_v3).

Handled:

  • critical, prefixes, then a DER: prefix: the hex bytes (with : separators, optional) become
    the extension's octet value.
  • An ASN1: prefix: BOOLEAN, INTEGER, ENUMERATED, NULL, OBJECT, OCTET STRING, BIT STRING,
    IA5String and UTF8String, with the ASCII, UTF8, HEX and BITLIST FORMAT: modifiers.
    ASN1:INTEGER:5 produces 02 01 05; OIDs accept dotted-decimal text and short/long names.
  • Plain values for nsCertType (71), keyUsage (83) and extendedKeyUsage (126): bit names from
    the reference tables (short and long spellings) and OID lists.
  • Identity: the extension object is the NID's object, the critical flag is 0/1, and the value
    is a fresh octet string. A null value, an unknown NID, malformed hex and malformed ASN1: text
    return null.

Other standard-extension NIDs with a plain value, other ASN1: tags, the IMP/EXP/SEQWRAP/
SETWRAP/BITWRAP/OCTWRAP modifiers, and a non-null conf holding an @section value throw
NotImplemented_nid_no_patch(__func__). The @section path needs the CONF layout, which the port
does not have. This implements the minimal text-to-DER it needs and does not depend on or copy
#21702 (src/X509Add1ExtI2d.cpp).

Also: one declaration in include/Api.hpp, the stub removed from AdditionalExports.cpp, CMake
wiring for guest_libressl3_x509v3_ext_conf_nid[_tests], and one debt fragment that adds the
Functional bullet and removes the TKGJOgbeyuA inventory row (git grep -l 'TKGJOgbeyuA' origin/main -- docs/dev/debt/changes/ found no other pending fragment claiming it).

Tested

No CMake/Ninja build exists on this host, so no ctest run.

  • clang++ -target x86_64-apple-darwin -std=c++20 -fsyntax-only -w -I core/libs -I core/libs/prx/libSceLibreSsl3/include -I 3rdparty -I /Users/dfischer/workdir/AnyPS5/3rdparty/mbedtls/include -I . on src/X509V3ExtConfNid.cpp and
    tests/X509V3ExtConfNid.cpp: clean.
  • A throwaway harness actually executed the test assertions: it linked the test, the new source,
    src/Objects.cpp and libSceLibreSsl/src/ObjectTable.cpp with small stubs for the heap, the
    object tables' added-object calls, OBJ_sn2nid, the error queue and the extension/octet-string
    frees, plus a minimal prx/libc/libc.hpp shim (this arm64 host's long double fails the real
    header's x86-64 static assertion, so only the harness shims it). Output:
    libSceLibreSsl3 X509V3_EXT_conf_nid tests passed.
  • python3 /tmp/anyps5-tools/cmake_wiring.py core/libs/prx/libSceLibreSsl3/CMakeLists.txt: no
    unregistered test properties, no duplicate targets.
  • python3 tools/debt_fold.py --check: passes, and --show libSceLibreSsl3 removes the
    TKGJOgbeyuA row.
  • python3 tools/check_conventions.py --base origin/main: "All conventions checks passed."
  • No conflict markers under *.cpp, *.hpp, *.md.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against ef1a146967:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_x509v3_ext_conf_nid_tests built cleanly.
  • CTest (guest_libressl3_x509v3_ext_conf_nid):
    1/1 Test #4441: guest_libressl3_x509v3_ext_conf_nid ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp: BuildExtension verifies der.size() <= INT32_MAX, checks allocations from malloc_nid_postfix and calloc_nid_postfix, properly cleans up via free_nid_postfix / ASN1_OCTET_STRING_free_nid_postfix on partial allocation failure, and avoids memory leaks.
    • core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp: ParseHex, ParseIntegerLiteral, Base128, and AddDecimal handle hex and decimal decoding, boundary conditions, zero inputs, negative numbers, and odd-digit hex errors with exact LibreSSL error queuing.
    • core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp: PlainExtension handles NIDs 71 (nsCertType), 83 (keyUsage), and 126 (extendedKeyUsage), properly distinguishing unknown non-extension NIDs (UnknownExtension) from unknown extension names (UnknownExtensionName), and delegating unsupported standard extensions to NotImplemented_nid_no_patch.
    • core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp: ParseAsn1 and EncodeString properly implement BOOLEAN, INTEGER, ENUMERATED, NULL, OBJECT, OCTETSTRING, BITSTRING, IA5STRING, and UTF8String with FORMAT modifiers (ASCII, UTF8, HEX, BITLIST) and reject malformed/unsupported combinations.
    • docs/dev/debt/changes/feat-libressl3-x509v3-ext-conf-nid.md and AGENTS.md compliance: verifies technical debt fragment follows repository rules, removes export TKGJOgbeyuA, contains no prohibited code comments, and adds no illegal files.

Looks Good To Me

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 18, 2026

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against f3cb56f01b:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_x509v3_ext_conf_nid_tests built cleanly.
  • CTest (guest_libressl3_x509v3_ext_conf_nid):
    1/1 Test #4444: guest_libressl3_x509v3_ext_conf_nid ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp: BuildExtension checks der.size() against INT32_MAX and checks all allocations from malloc_nid_postfix / calloc_nid_postfix, cleaning up properly on partial failures.
    • Verified core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp: ParseHex, ParseIntegerLiteral, Base128, and AddDecimal correctly handle hex and decimal decoding, boundary conditions, zero inputs, negative numbers, and odd-digit hex errors with exact LibreSSL error queuing.
    • Verified core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp: PlainExtension handles NIDs 71 (nsCertType), 83 (keyUsage), and 126 (extendedKeyUsage), correctly distinguishing non-extension NIDs (UnknownExtension) from unknown extension names (UnknownExtensionName) and delegating unsupported standard extensions to NotImplemented_nid_no_patch.
    • Verified core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp: ParseAsn1 and EncodeString properly implement BOOLEAN, INTEGER, ENUMERATED, NULL, OBJECT, OCTETSTRING, BITSTRING, IA5STRING, and UTF8String with FORMAT modifiers (ASCII, UTF8, HEX, BITLIST) and reject malformed/unsupported combinations.
    • Verified AGENTS.md compliance: docs/dev/debt/changes/feat-libressl3-x509v3-ext-conf-nid.md correctly documents the debt fragment, removes export TKGJOgbeyuA, no forbidden code comments are present, and no extraneous files are added.

Looks Good To Me

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 12315 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 15163 core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 16589 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 16654 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 16981 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 17621 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 17622 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 17626 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 18284 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 18942 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 19483 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 20967 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 22316 core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
core/libs/prx/libSceLibreSsl3/include/Api.hpp
PR 22808 core/libs/prx/libSceLibreSsl3/CMakeLists.txt
core/libs/prx/libSceLibreSsl3/include/Api.hpp

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 18, 2026
@ycbuzi

ycbuzi commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Tested f3cb56f01b merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 4 tests failed out of 6201; 99% tests passed, 3 tests failed out of 6201. 3 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 6201; 100% tests passed, 0 tests failed out of 6201. run

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 18, 2026

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 5ce43c3e46:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libressl3_x509v3_ext_conf_nid_tests built cleanly.
  • CTest (guest_libressl3_x509v3_ext_conf_nid):
    1/1 Test #4463: guest_libressl3_x509v3_ext_conf_nid ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp, core/libs/prx/libSceLibreSsl3/include/Api.hpp, core/libs/prx/libSceLibreSsl3/src/X509V3ExtConfNid.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified memory allocation safety in BuildExtension (X509V3ExtConfNid.cpp:665-689): checked der.size() boundary against INT32_MAX, validated malloc_nid_postfix and calloc_nid_postfix return pointers, and verified full cleanup of intermediate buffers via ASN1_OCTET_STRING_free_nid_postfix / free_nid_postfix on partial allocation failure.
    • Verified hex, integer, and decimal conversion functions (ParseHex, ParseIntegerLiteral, Base128, AddDecimal, DecimalBytes) in X509V3ExtConfNid.cpp for boundary handling, empty string guards, odd-character count detection, and exact LibreSSL error queuing (OddNumberOfDigits, IllegalHexDigit).
    • Verified PlainExtension handling for standard NIDs (71 nsCertType, 83 keyUsage, 126 extendedKeyUsage) in X509V3ExtConfNid.cpp: properly rejects unknown extensions with UnknownExtension or UnknownExtensionName error codes and routes unhandled standard extensions to NotImplemented_nid_no_patch(func).
    • Verified ParseAsn1 and EncodeString handling for supported types (BOOLEAN, INTEGER, ENUMERATED, NULL, OBJECT, OCTETSTRING, BITSTRING, IA5STRING, UTF8String) and FORMAT modifiers (ASCII, UTF8, HEX, BITLIST) against LibreSSL 4.0.0 behavior, confirming proper rejection of unsupported tags and invalid encodings.
    • Verified strict AGENTS.md compliance: confirmed docs/dev/debt/changes/feat-libressl3-x509v3-ext-conf-nid.md correctly tracks functional addition and removal of export TKGJOgbeyuA, no forbidden code comments exist, and no unauthorized files or silent success stubs were added.

Looks Good To Me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants