Skip to content

feat(libSceLibreSsl3): implement X509_cmp_current_time - #17243

Closed
fishingpvalues wants to merge 11 commits into
boykopovar:mainfrom
fishingpvalues:feat/libressl3-x509-cmp-current-time
Closed

fishingpvalues wants to merge 11 commits into
boykopovar:mainfrom
fishingpvalues:feat/libressl3-x509-cmp-current-time

Conversation

@fishingpvalues

@fishingpvalues fishingpvalues commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

What

feat(libSceLibreSsl3): implement X509_cmp_current_time. The implementation and its technical-debt entry are in this branch; the export leaves AdditionalExports.cpp and gains its real signature in include/Api.hpp.

Tested

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

  • cmake --build build --target guest_libressl3_x509_cmp_current_time_tests --parallel 4: passed.
  • ctest --test-dir build -R '^guest_libressl3_x509_cmp_current_time$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • Not run: Windows, a console or a title.

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
  • 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

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 8, 2026
@fishingpvalues
fishingpvalues force-pushed the feat/libressl3-x509-cmp-current-time branch from dd2f0fc to 4fad165 Compare November 8, 2026 16:11
@github-actions

github-actions Bot commented Nov 8, 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 docs/dev/debt/libSceLibreSsl3.md
PR 14212 docs/dev/debt/libSceLibreSsl3.md
PR 14465 docs/dev/debt/libSceLibreSsl3.md
PR 15163 docs/dev/debt/libSceLibreSsl3.md
PR 15618 docs/dev/debt/libSceLibreSsl3.md
PR 15737 docs/dev/debt/libSceLibreSsl3.md
PR 16529 docs/dev/debt/libSceLibreSsl3.md
PR 16589 docs/dev/debt/libSceLibreSsl3.md
PR 16654 docs/dev/debt/libSceLibreSsl3.md
PR 16689 docs/dev/debt/libSceLibreSsl3.md
PR 16819 docs/dev/debt/libSceLibreSsl3.md
PR 16918 docs/dev/debt/libSceLibreSsl3.md
PR 16926 docs/dev/debt/libSceLibreSsl3.md
PR 16979 docs/dev/debt/libSceLibreSsl3.md
PR 16980 docs/dev/debt/libSceLibreSsl3.md
PR 16981 docs/dev/debt/libSceLibreSsl3.md
PR 16996 docs/dev/debt/libSceLibreSsl3.md
PR 17528 docs/dev/debt/libSceLibreSsl3.md
PR 17544 docs/dev/debt/libSceLibreSsl3.md
PR 17621 docs/dev/debt/libSceLibreSsl3.md
PR 17622 docs/dev/debt/libSceLibreSsl3.md
PR 17626 docs/dev/debt/libSceLibreSsl3.md

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

@gabichuuuuu gabichuuuuu 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.

Read against the LibreSSL in 3rdparty/libressl-openbsd (078b3d1d), which is what this module follows. I haven't built or run this branch.

Differences from X509_cmp_time (x509/x509_vfy.c):

  1. Equal times. LibreSSL returns -1 for "the same as now". Its comment reads "0 is used for error, so map same to less than". Here value == now returns 0, which the caller reads as an error.
  2. The type field is ignored. LibreSSL parses with the string's type and applies RFC 5280: a UTCTime must be 13 characters and a GeneralizedTime 15, and a GeneralizedTime before 2050 is rejected. Here any 13- or 15-character string is accepted whatever its type. For example, type 24 with "20200101000000Z" gives 0 in LibreSSL and -1 here.
  3. Day check. std::chrono's date.ok() rejects 31 February, "260231000000Z", which returns 0 here. LibreSSL compares the parsed fields without validating the day.

Debt file: compared with main, this branch's docs/dev/debt/libSceLibreSsl3.md drops a BIO_meth line that main now has (src/BioMethod.cpp, #15761), and it repeats the new bullet on two consecutive lines. It looks rebased from an older copy of the file.

@fishingpvalues
fishingpvalues force-pushed the feat/libressl3-x509-cmp-current-time branch from 4fad165 to adf31e8 Compare November 8, 2026 17:03
@fishingpvalues

Copy link
Copy Markdown
Contributor Author

Fixed all three differences and the debt file.

  • Equal times now return -1; 0 remains the parse-error result.
  • Parsing uses the string type: a 13-character UTCTIME rejects type 24, a 15-character GENERALIZEDTIME rejects type 23, and the RFC 5280 2050 cutoff is applied, so type 24 with "20200101000000Z" now returns 0.
  • Removed std::chrono date validation: the day is accepted without checking the month length and the timegm normalization is reproduced, so "260231000000Z" is no longer an error.
  • A null time throws, as the module does for pointers LibreSSL dereferences.
  • Debt: restored main's BIO_meth entry, removed the duplicated X509_cmp_current_time bullet, corrected the inventory to 117 (108 named + 9 NID) and removed its table row.

Rebased onto origin/main (f35f1e5eca).

Test: ctest --test-dir build -R guest_libressl3_x509_cmp_current_time -V -> 1/1 passed.
python3 tools/check_conventions.py --base origin/main -> All conventions checks passed.

…mp-current-time

* origin/main:
  fix(libSceLibreSsl3): restore the p_lib.c licence notice in Key.cpp
  feat(libSceLibreSsl3): implement EVP_PKEY_get0_EC_KEY
  fix(libSceUsbStorageDialog): validate copied base parameters against guest address in sceUsbStorageDialogOpen
  fix(libSceCommonDialog): support guest address override in ValidateCommonDialogBaseParam
  docs(dev): document sceUsbStorageDialogOpen pointer validation in technical debt
  test(libSceUsbStorageDialog): verify invalid guest pointer rejection in sceUsbStorageDialogOpen
  fix(libSceUsbStorageDialog): validate guest parameters readability in sceUsbStorageDialogOpen
  fix(libkernel_sys): safely copy out compiled SDK versions
  feat(libSceNpManager): implement the Push and Push2 lifecycle
  feat(libc): export the Dinkumware _Mbrtowc and _Wcrtomb helpers
  feat(libSceSystemService): answer two ShellCoreUtil calls as firmware 13.42 does
  feat(libSceNpCommon): implement sceNpGetNavSdkVersion
@fishingpvalues

Copy link
Copy Markdown
Contributor Author

Head bce8f26a92 addresses the review against LibreSSL 078b3d1d:

  • Equal times return -1; 0 remains the parse-error result.
  • type is applied: a 13-character UTCTIME rejects type 24, a 15-character GENERALIZEDTIME rejects type 23, and the RFC 5280 2050 cutoff rejects type 24 with 20200101000000Z (0) while accepting 20500101000000Z (1).
  • No month-length validation: 260231000000Z parses and compares as 31 February. The comparison now uses the parsed fields field-by-field, as ASN1_time_tm_cmp does, instead of epoch seconds, so normalisation cannot change the order; timegm(tm) == -1 and a failed gmtime_r still return 0.
  • Debt: main's BIO_meth entry is restored, the X509_cmp_current_time bullet appears once, and the inventory is recounted to 116 (107 named + 9 NID) after removing the implemented row.

Tested on Linux x86-64, Release:

  • cmake --build build --target guest_libressl3_x509_cmp_current_time_tests --parallel 4 passed.
  • ctest --test-dir build -R '^guest_libressl3_x509_cmp_current_time$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base origin/main: passed.

Not run: Windows.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 9, 2026
…mp-current-time

* origin/main: (392 commits)
  feat(libSceNKWebKit): implement WebCore::CookieUtil::defaultPathForURL
  test(prx): drop asserts that pin unimplemented throws
  feat(libSceNKWebKit): implement WebCore::parseCacheControlDirectives
  fix(prx): implement firmware 4.03 contracts for four exports
  test(libSceFreeTypeOt): keep the size-metrics sentinels inside a 32-bit FT_Long
  refactor(libSceFreeTypeOt): call the bundled FreeType for the size metrics
  ci(linux): prefetch the FFmpeg prebuilt with retries
  ci(build): allow ninety minutes for a Windows dispatch that runs every test
  refactor(prx): leave the LibcInternal stubs boykopovar#16005 and boykopovar#16024 touch unnamed
  feat(libSceLibreSsl3): implement SSL_CTX_set_timeout
  fix(shader): follow chained predicate metadata replacements
  perf(libSceAgcDriver): raise the default dispatch cache budget
  fix(tests): include the InventoryExports6 header instead of redeclaring the deleting destructors
  feat(shader): accept SDWA destination selects on f32 rounding and frexp ops
  fix(agc): keep the driver window compare inside its image
  feat(shader): accept SDWA destination selects on v_cvt_f32_ubyte0..3
  test(shader): drop the cvt_norm_f16 SDWA refusal cases for valid forms
  feat(shader): implement SDWA for v_cvt_norm_i16_f16 and v_cvt_norm_u16_f16
  test(shader): allow 2 ulp on v_log_f32 results below 1.0 in the SDWA exp/log test
  feat(shader): support SDWA destination selectors on v_exp_f32, v_log_f32 and v_rcp_iflag_f32
  ...

# Conflicts:
#	docs/dev/debt/libSceLibreSsl3.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 9, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 9, 2026
@fishingpvalues

Copy link
Copy Markdown
Contributor Author

Merged latest origin/main (a26b7827e1) into the branch; head is now 6c6e204df5. One conflict, in docs/dev/debt/libSceLibreSsl3.md: the Additional exports inventory. Resolved to 110 still-unimplemented callable exports (101 named + 9 NID): main counted 111 after implementing one export, and this branch implements X509_cmp_current_time, so 111 - 1 = 110. The table row appears once and main's BIO_meth entry is preserved. No code changes were needed; the review fixes at bce8f26a92 are retained.

Tested on Linux x86-64, Release, against the merged tree:

  • cmake --build build --target guest_libressl3_x509_cmp_current_time_tests --parallel 4: passed.
  • ctest --test-dir build -R '^guest_libressl3_x509_cmp_current_time$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.
  • Not run: Windows, a console or a title.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 9, 2026
…mp-current-time

* origin/main: (59 commits)
  test(tools): cover BOM header package paths
  fix(tests): build the timed-join exe that stages the MinGW runtime for the import tests
  fix(tests): opt the FreeType allocator test out of Windows runtime staging
  fix(tools): add tests directory to sys.path in test_trace_intervals_csv
  fix(tools): add tests directory to sys.path in test_audit_strict_partial
  fix(tools): add tests directory to sys.path in test_annotation_symbols_json
  fix(tools): add tests directory to sys.path in test_ab_split_csv
  test(web): default test suite root path to parent directory when unprovided
  test(tools): verify tracked repository JSON files are unignored
  chore(gitignore): unignore tracked tools/input-mapper/package.json
  build(cmake): set explicit ctest timeouts for conventions_pr_template and relinker_fuzz_seeds
  feat(libSceFontFt): implement sceFontFtSupportFontFormats
  docs(debt): update the FreeType allocator note for the Ol Alloc and Free
  fix(libkernel): declare GUEST_EIO for every platform
  test(prx): pin all four u16 fields of the glyph-selection record
  fix(prx): implement decoded font support and selection contracts
  test(ngs2): distinguish PS4 custom control expectations
  test(ngs2): guard Delay control checks in the PS4 library
  fix(tests): opt the remaining patched-path test executables out of runtime staging
  fix(tests): opt LibreSSL patched-variant tests out of runtime staging
  ...

# Conflicts:
#	core/libs/prx/libSceLibreSsl3/AdditionalExports.cpp
#	core/libs/prx/libSceLibreSsl3/include/Api.hpp
#	docs/dev/debt/libSceLibreSsl3.md
…mp-current-time

* origin/main:
  docs(libkernel): pin the FreeBSD link in the SO_LINGER datagram entry
  feat(libSceNKWebKit): implement WKConnection message posting and client configuration
  feat(libSceNet): support SO_LINGER in sceNetSetsockopt and sceNetGetsockopt
  test(libharfbuzz): apply the complete NID runtime search path
  fix(libharfbuzz): skip guards for unused tag outputs
  test(libharfbuzz): patch the complete layout test context
  build(libharfbuzz): isolate layout test patching
  build(libharfbuzz): scope layout test dependencies
  test(libharfbuzz): cover refused guest output scopes
  docs(libharfbuzz): clarify opaque face validation limits
  feat(libharfbuzz): implement OpenType layout queries
  feat(libSceLibreSsl3): implement HMAC_CTX_new and HMAC_CTX_free

# Conflicts:
#	docs/dev/debt/libSceLibreSsl3.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 9, 2026
@JJenkx

JJenkx commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Windows check of head a56e43f7e3, merged onto main 6719b01bf3 (5d939a9405, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_libressl3_x509_cmp_current_time passes in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 10, 2026
…mp-current-time

* origin/main: (282 commits)
  docs(libSceLibreSsl3): recount additional exports after rebase
  fix(libSceLibreSsl3): leave the three loaders to boykopovar#17246
  feat(libSceLibreSsl3): return from seven calls as firmware 13.42 does
  fix(tools): leave a title's executables out of its module directories
  fix(tools): stage every ELF or SELF module and empty module directories
  fix(tools): stage a title's --module-dir modules in title runs
  docs(libSceLibreSsl3): record EVP_PKEY_base_id
  test(libSceLibreSsl3): check that EVP_PKEY_base_id maps aliases to the LibreSSL 4.0.0 base methods
  feat(libSceLibreSsl3): implement EVP_PKEY_base_id
  feat(libSceLibcInternal): implement __std_bitset_to_string_1 and _2
  fix(main): retry the storage refresh runs of label_ordered_flush until one takes the ordered flush
  test(libSceFreeType): expect an invalid face handle for a null face
  fix(libSceFreeType): reject a null face before FreeType sets variation coordinates
  feat(libcinternal): implement float and double min/max vector helpers
  feat(libSceLibreSsl3): implement X509_STORE_CTX_new, free, get0_param and X509_STORE_up_ref
  test(libc): let the file stream owner release its pointer on Windows
  fix(cmake): report the fuzzer and TSAN conflict before the TSAN platform check
  test(libwebrtc): check rtc::RateTracker rounding with an odd bucket width
  feat(libwebrtc): implement rtc::RateTracker
  feat(libSceLibreSsl): implement BN_print
  ...

# Conflicts:
#	docs/dev/debt/libSceLibreSsl3.md
…mp-current-time

* origin/main:
  test(relinker): extend signed LEB128 displacement fuzzing and overflow checks
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 10, 2026
main merged another X509_cmp_current_time implementation in
src/X509CmpTime.cpp (boykopovar#15620). Keep that file and its test target, replace
the implementation with this branch's review-fixed field comparison, merge
the test cases, and drop the duplicate X509CmpCurrentTime files.
@fishingpvalues

fishingpvalues commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged latest origin/main (7f96086b4e) into the branch; head is a5bec67251, now 3 files against main.

While resolving the conflict: main already implements X509_cmp_current_time in src/X509CmpTime.cpp (#15620). Keeping the branch's X509CmpCurrentTime.cpp would define the export twice, so the branch's review-fixed implementation now lives in src/X509CmpTime.cpp, using main's file and test-target names, and the duplicate X509CmpCurrentTime.cpp/tests/X509CmpCurrentTime.cpp are gone.

Behaviour from the review fixes is unchanged: equal times return -1, type is applied (13-character strings reject type 24, 15-character strings reject type 23), a 13-character string with type 4 still parses, the RFC 5280 2050 cutoff applies, the day of month is not validated, a null time throws, and an epoch of -1 or a failed gmtime_r returns 0. tests/X509CmpTime.cpp now carries the branch's cases merged with main's. One main test expectation was corrected: type 4 with a 13-character UTCTIME returns -1 (LibreSSL's ASN1_time_parse accepts any mode except the other time type), not 0.

Debt: kept main's current inventory (87: 82 named + 5 NID), preserved the BIO_meth entry, and replaced the single X509_cmp_current_time bullet.

Tested on Linux x86-64, Release, against the merged tree:

  • cmake --build build --target guest_libressl3_x509_cmp_time_tests --parallel 4: passed.
  • ctest --test-dir build -R '^guest_libressl3_x509_cmp_time$' --output-on-failure: 1/1 passed.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.

Not run: Windows, a console or a title.

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

Copy link
Copy Markdown
Collaborator

@fishingpvalues I reviewed a5bec67. X509_cmp_current_time is already implemented on main in src/X509CmpTime.cpp, so after your merge of main this branch replaces that version instead of adding the export (the PR body still describes it as leaving AdditionalExports.cpp). The replacement loses main's calendar check: main refuses a date such as February 31 through year_month_day::ok(), and this branch accepts any day from 1 to 31. It also throws for a null time, where main returns 0. Unless this fixes a case main gets wrong, I think the PR can be closed. If it does, could you name that case and keep main's date validation?

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@fishingpvalues X509_cmp_current_time in libSceLibreSsl3 is already on main: #15620 merged it on 11-10 as src/X509CmpTime.cpp with its own test and debt entry. This PR no longer adds the export, it rewrites main's version, and neither side has a console measurement behind it. The rewrite accepts any day from 1 to 31 where main checks the date with std::chrono::year_month_day, so a time like 210229000000Z is now a valid time, and it throws on a null time where main returns 0. I am closing it as already on main. If you have a console run showing that main's answers for a null time or an impossible date are wrong, a PR with that run is welcome.

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.

5 participants