From 0cfe06f283d585222b757b19210398b4f7b184e6 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sat, 24 Oct 2026 05:20:06 +0200 Subject: [PATCH 01/10] feat(libSceLibreSsl3): implement X509_getm_notBefore --- core/libs/prx/libSceLibreSsl3/CMakeLists.txt | 13 +++- core/libs/prx/libSceLibreSsl3/Export.cpp | 5 -- .../prx/libSceLibreSsl3/src/X509Validity.cpp | 50 +++++++++++++ .../libs/tests/GuestLibreSsl3X509Validity.cpp | 71 +++++++++++++++++++ docs/dev/debt/libSceLibreSsl3.md | 3 +- 5 files changed, 135 insertions(+), 7 deletions(-) create mode 100644 core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp create mode 100644 core/libs/tests/GuestLibreSsl3X509Validity.cpp diff --git a/core/libs/prx/libSceLibreSsl3/CMakeLists.txt b/core/libs/prx/libSceLibreSsl3/CMakeLists.txt index 496fb2a9b913..9f0c01449798 100644 --- a/core/libs/prx/libSceLibreSsl3/CMakeLists.txt +++ b/core/libs/prx/libSceLibreSsl3/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(libSceLibreSsl3 SHARED EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/Export.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Digest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/IntegerDecoder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Key.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/EvpDigest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/X509PubkeyParam.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/ObjCmp.cpp) +add_library(libSceLibreSsl3 SHARED EXCLUDE_FROM_ALL ${CMAKE_CURRENT_SOURCE_DIR}/Export.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Digest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/IntegerDecoder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Key.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/EvpDigest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/X509PubkeyParam.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/ObjCmp.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/X509Validity.cpp) target_include_directories(libSceLibreSsl3 PRIVATE ${LIBS_INCLUDE_DIR}) target_link_libraries(libSceLibreSsl3 PRIVATE libSceLibreSsl libc) configure_windows_unwind(libSceLibreSsl3) @@ -130,6 +130,17 @@ if(BUILD_TESTING) set_tests_properties(guest_crypto_memcmp guest_libressl3_digest guest_libressl3_asn1 guest_libressl3_key_reference guest_libressl3_evp guest_libressl3_version guest_libressl3_x509_pubkey_param PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") endif() + + add_test_executable(guest_libressl3_x509_validity_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibreSsl3X509Validity.cpp) + target_include_directories(guest_libressl3_x509_validity_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_libressl3_x509_validity_tests PRIVATE libSceLibreSsl3) + configure_windows_unwind(guest_libressl3_x509_validity_tests) + add_test(NAME guest_libressl3_x509_validity COMMAND guest_libressl3_x509_validity_tests) + set_tests_properties(guest_libressl3_x509_validity PROPERTIES TIMEOUT 30) + if(WIN32) + set_tests_properties(guest_libressl3_x509_validity PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() endif() if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL "Linux" AND EXISTS "${LIBS_INCLUDE_DIR}/prx/libSceLibreSsl/src/Evp.cpp") diff --git a/core/libs/prx/libSceLibreSsl3/Export.cpp b/core/libs/prx/libSceLibreSsl3/Export.cpp index 6ba83e997add..2fb6180b1311 100644 --- a/core/libs/prx/libSceLibreSsl3/Export.cpp +++ b/core/libs/prx/libSceLibreSsl3/Export.cpp @@ -326,11 +326,6 @@ int APS5_VABI X509_getm_notAfter_nid_postfix(void) { return 0; } -int APS5_VABI X509_getm_notBefore_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - int APS5_VABI X509_up_ref_nid_postfix(void) { NotImplemented_nid_no_patch(__func__); return 0; diff --git a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp new file mode 100644 index 000000000000..7af7413d84cd --- /dev/null +++ b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include "prx/libc/include/General.hpp" + +struct LibreSsl3X509Validity { + void* notBefore; + void* notAfter; +}; + +struct LibreSsl3ValidityCertInfo { + void* version; + void* serialNumber; + void* signature; + void* issuer; + LibreSsl3X509Validity* validity; + unsigned char rest[64]; +}; + +struct LibreSsl3ValidityX509 { + LibreSsl3ValidityCertInfo* certInfo; + const void* sigAlg; + const void* signature; + unsigned char rest[192]; +}; + +static_assert(sizeof(LibreSsl3X509Validity) == 16); +static_assert(sizeof(LibreSsl3ValidityCertInfo) == 104); +static_assert(offsetof(LibreSsl3ValidityCertInfo, validity) == 32); +static_assert(sizeof(LibreSsl3ValidityX509) == 216); +static_assert(offsetof(LibreSsl3ValidityX509, sigAlg) == 8); +static_assert(offsetof(LibreSsl3ValidityX509, signature) == 16); + +namespace { + +const LibreSsl3X509Validity* Validity(const LibreSsl3ValidityX509* certificate) { + if (!certificate || !certificate->certInfo) return nullptr; + return certificate->certInfo->validity; +} + +} + +extern "C" { + +void* APS5_VABI X509_getm_notBefore_nid_postfix(const LibreSsl3ValidityX509* certificate) { + const LibreSsl3X509Validity* validity = Validity(certificate); + return validity ? validity->notBefore : nullptr; +} + +} diff --git a/core/libs/tests/GuestLibreSsl3X509Validity.cpp b/core/libs/tests/GuestLibreSsl3X509Validity.cpp new file mode 100644 index 000000000000..3ac648410569 --- /dev/null +++ b/core/libs/tests/GuestLibreSsl3X509Validity.cpp @@ -0,0 +1,71 @@ +#include "prx/libc/include/general/VabiMacros.hpp" +#include +#include +#include +#include +#include + +struct TestValidity { + void* notBefore; + void* notAfter; +}; + +struct TestCertInfo { + void* version; + void* serialNumber; + void* signature; + void* issuer; + TestValidity* validity; + void* subject; + void* rest[7]; +}; + +struct TestX509 { + TestCertInfo* certInfo; + const void* sigAlg; + const void* signature; + void* rest[24]; +}; + +static_assert(sizeof(TestCertInfo) == 104 && offsetof(TestCertInfo, validity) == 32); +static_assert(sizeof(TestX509) == 216 && offsetof(TestX509, signature) == 16); + +static int Before; +static int After; + +extern "C" { +void* APS5_VABI X509_getm_notBefore_nid_postfix(const TestX509*); +} + +static void Require(bool condition, std::source_location location = std::source_location::current()) { + if (condition) return; + std::fprintf(stderr, "LibreSSL X509 validity check failed at line %u\n", location.line()); + std::abort(); +} + +template static void RequireThrows(TAction action, std::source_location location = std::source_location::current()) { + try { action(); } catch (const std::exception&) { return; } + Require(false, location); +} + +static void TestGetmNotBefore() { + TestValidity validity {}; + TestCertInfo info {}; + TestX509 certificate {}; + Require(X509_getm_notBefore_nid_postfix(nullptr) == nullptr); + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); + certificate.certInfo = &info; + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); + info.validity = &validity; + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); + validity.notBefore = &Before; + validity.notAfter = &After; + Require(X509_getm_notBefore_nid_postfix(&certificate) == &Before); + validity.notBefore = nullptr; + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); +} + +int main() { + TestGetmNotBefore(); + return 0; +} diff --git a/docs/dev/debt/libSceLibreSsl3.md b/docs/dev/debt/libSceLibreSsl3.md index bafab7de8620..32ce7a360015 100644 --- a/docs/dev/debt/libSceLibreSsl3.md +++ b/docs/dev/debt/libSceLibreSsl3.md @@ -10,7 +10,7 @@ ### Unknown function info -- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `OpenSSL_version`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. +- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. 73 `OpenSSL_version` `X509_getm_notBefore`, ### Functional @@ -28,6 +28,7 @@ - [EVP_CIPHER_key_length and EVP_CIPHER_iv_length](../../../core/libs/prx/libSceLibreSsl3/src/Cipher.cpp) (libSceLibreSsl3) - nothing is checked on the console. They return `key_len` and `iv_len` from the 80-byte `EVP_CIPHER` of [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp) `evp_local.h` and `evp_cipher.c`. The fields are at offsets 8 and 12, as in the [2.5.4 layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h) of the ciphers the forwarded libSceLibreSsl exports handle. A null cipher, which LibreSSL dereferences, throws. Closes when: compared with the console. - [X509_VERIFY_PARAM_set_flags](../../../core/libs/prx/libSceLibreSsl3/src/X509VerifyParam.cpp) (libSceLibreSsl3) - nothing is checked on the console. It ORs the flags into `flags` and returns 1, as both [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_vpm.c) and [4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_vpm.c) `x509_vpm.c` do. They differ when `EXPLICIT_POLICY`, `INHIBIT_ANY` or `INHIBIT_MAP` is set while `POLICY_CHECK` is neither set nor requested: 2.5.4 also adds `POLICY_CHECK` and 4.0.0 does not. The console's choice is unknown, so that case throws through `NotImplemented_nid_no_patch` and leaves the parameters unchanged. It writes libSceLibreSsl's 2.5.4 `LibreSslX509VerifyParam`, whose `flags` is at offset 24 as in 4.0.0. Null parameters throw. Closes when: the console's policy behaviour is measured. - [sk_new, sk_push and sk_free](../../../core/libs/prx/libSceLibreSsl3/src/Stack.cpp) (libSceLibreSsl3) - follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/stack/stack.c) `stack.c` with libSceLibreSsl's 32-byte `_STACK` layout, which `stack_local.h` keeps there. Stacks and element arrays come from the guest heap, so the forwarded `sk_pop_free` can release them. Nothing is checked on the console. Where LibreSSL faults or overflows, they throw: `sk_push` on a null stack, on a negative element count, on a null element array it does not regrow, or when the element array cannot double without overflowing `int` +- [X509_getm_notBefore](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach it. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws - [ASN1_TIME_diff](../../../core/libs/prx/libSceLibreSsl3/src/Time.cpp) has no console ABI or behavior verification. Its signature and date rules follow LibreSSL 4.0.0 [a_time.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time.c), [a_time_tm.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_tm.c) and [a_time_posix.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_posix.c), using the existing 24-byte string layout. Null inputs use the host wall clock; the console clock relationship is unverified. Null output pointers throw after valid input parsing, where the reference dereferences them. Closes when: measured on a PS5. From c97f048bcf57442d8306ca1b007fd3c1ba740523 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sat, 24 Oct 2026 05:21:07 +0200 Subject: [PATCH 02/10] feat(libSceLibreSsl3): implement X509_getm_notAfter --- core/libs/prx/libSceLibreSsl3/Export.cpp | 5 ----- .../prx/libSceLibreSsl3/src/X509Validity.cpp | 5 +++++ .../libs/tests/GuestLibreSsl3X509Validity.cpp | 19 +++++++++++++++++++ docs/dev/debt/libSceLibreSsl3.md | 4 ++-- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/core/libs/prx/libSceLibreSsl3/Export.cpp b/core/libs/prx/libSceLibreSsl3/Export.cpp index 2fb6180b1311..03aa4c1bbcf1 100644 --- a/core/libs/prx/libSceLibreSsl3/Export.cpp +++ b/core/libs/prx/libSceLibreSsl3/Export.cpp @@ -321,11 +321,6 @@ int APS5_VABI X509_get_version_nid_postfix(void) { return 0; } -int APS5_VABI X509_getm_notAfter_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - int APS5_VABI X509_up_ref_nid_postfix(void) { NotImplemented_nid_no_patch(__func__); return 0; diff --git a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp index 7af7413d84cd..324b122dec40 100644 --- a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp +++ b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp @@ -47,4 +47,9 @@ void* APS5_VABI X509_getm_notBefore_nid_postfix(const LibreSsl3ValidityX509* cer return validity ? validity->notBefore : nullptr; } +void* APS5_VABI X509_getm_notAfter_nid_postfix(const LibreSsl3ValidityX509* certificate) { + const LibreSsl3X509Validity* validity = Validity(certificate); + return validity ? validity->notAfter : nullptr; +} + } diff --git a/core/libs/tests/GuestLibreSsl3X509Validity.cpp b/core/libs/tests/GuestLibreSsl3X509Validity.cpp index 3ac648410569..8188a201f351 100644 --- a/core/libs/tests/GuestLibreSsl3X509Validity.cpp +++ b/core/libs/tests/GuestLibreSsl3X509Validity.cpp @@ -35,6 +35,7 @@ static int After; extern "C" { void* APS5_VABI X509_getm_notBefore_nid_postfix(const TestX509*); +void* APS5_VABI X509_getm_notAfter_nid_postfix(const TestX509*); } static void Require(bool condition, std::source_location location = std::source_location::current()) { @@ -65,7 +66,25 @@ static void TestGetmNotBefore() { Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); } +static void TestGetmNotAfter() { + TestValidity validity {}; + TestCertInfo info {}; + TestX509 certificate {}; + Require(X509_getm_notAfter_nid_postfix(nullptr) == nullptr); + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); + certificate.certInfo = &info; + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); + info.validity = &validity; + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); + validity.notBefore = &Before; + validity.notAfter = &After; + Require(X509_getm_notAfter_nid_postfix(&certificate) == &After); + validity.notAfter = nullptr; + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); +} + int main() { TestGetmNotBefore(); + TestGetmNotAfter(); return 0; } diff --git a/docs/dev/debt/libSceLibreSsl3.md b/docs/dev/debt/libSceLibreSsl3.md index 32ce7a360015..307a0a4bea0c 100644 --- a/docs/dev/debt/libSceLibreSsl3.md +++ b/docs/dev/debt/libSceLibreSsl3.md @@ -10,7 +10,7 @@ ### Unknown function info -- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. 73 `OpenSSL_version` `X509_getm_notBefore`, +- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. 72 `OpenSSL_version`, `X509_getm_notBefore` `X509_getm_notAfter`, ### Functional @@ -28,7 +28,7 @@ - [EVP_CIPHER_key_length and EVP_CIPHER_iv_length](../../../core/libs/prx/libSceLibreSsl3/src/Cipher.cpp) (libSceLibreSsl3) - nothing is checked on the console. They return `key_len` and `iv_len` from the 80-byte `EVP_CIPHER` of [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp) `evp_local.h` and `evp_cipher.c`. The fields are at offsets 8 and 12, as in the [2.5.4 layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h) of the ciphers the forwarded libSceLibreSsl exports handle. A null cipher, which LibreSSL dereferences, throws. Closes when: compared with the console. - [X509_VERIFY_PARAM_set_flags](../../../core/libs/prx/libSceLibreSsl3/src/X509VerifyParam.cpp) (libSceLibreSsl3) - nothing is checked on the console. It ORs the flags into `flags` and returns 1, as both [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_vpm.c) and [4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_vpm.c) `x509_vpm.c` do. They differ when `EXPLICIT_POLICY`, `INHIBIT_ANY` or `INHIBIT_MAP` is set while `POLICY_CHECK` is neither set nor requested: 2.5.4 also adds `POLICY_CHECK` and 4.0.0 does not. The console's choice is unknown, so that case throws through `NotImplemented_nid_no_patch` and leaves the parameters unchanged. It writes libSceLibreSsl's 2.5.4 `LibreSslX509VerifyParam`, whose `flags` is at offset 24 as in 4.0.0. Null parameters throw. Closes when: the console's policy behaviour is measured. - [sk_new, sk_push and sk_free](../../../core/libs/prx/libSceLibreSsl3/src/Stack.cpp) (libSceLibreSsl3) - follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/stack/stack.c) `stack.c` with libSceLibreSsl's 32-byte `_STACK` layout, which `stack_local.h` keeps there. Stacks and element arrays come from the guest heap, so the forwarded `sk_pop_free` can release them. Nothing is checked on the console. Where LibreSSL faults or overflows, they throw: `sk_push` on a null stack, on a negative element count, on a null element array it does not regrow, or when the element array cannot double without overflowing `int` -- [X509_getm_notBefore](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach it. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws +- [X509_getm_notBefore, X509_getm_notAfter](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws - [ASN1_TIME_diff](../../../core/libs/prx/libSceLibreSsl3/src/Time.cpp) has no console ABI or behavior verification. Its signature and date rules follow LibreSSL 4.0.0 [a_time.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time.c), [a_time_tm.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_tm.c) and [a_time_posix.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_posix.c), using the existing 24-byte string layout. Null inputs use the host wall clock; the console clock relationship is unverified. Null output pointers throw after valid input parsing, where the reference dereferences them. Closes when: measured on a PS5. From 6e47a20e3614bfb18320f11f7e0c420ec1836d16 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sat, 24 Oct 2026 05:21:17 +0200 Subject: [PATCH 03/10] feat(libSceLibreSsl3): implement X509_get0_notBefore --- core/libs/prx/libSceLibreSsl3/Export.cpp | 5 ----- .../prx/libSceLibreSsl3/src/X509Validity.cpp | 4 ++++ .../libs/tests/GuestLibreSsl3X509Validity.cpp | 19 +++++++++++++++++++ docs/dev/debt/libSceLibreSsl3.md | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/core/libs/prx/libSceLibreSsl3/Export.cpp b/core/libs/prx/libSceLibreSsl3/Export.cpp index 03aa4c1bbcf1..a5f51b092fac 100644 --- a/core/libs/prx/libSceLibreSsl3/Export.cpp +++ b/core/libs/prx/libSceLibreSsl3/Export.cpp @@ -296,11 +296,6 @@ int APS5_VABI X509_get0_notAfter_nid_postfix(void) { return 0; } -int APS5_VABI X509_get0_notBefore_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - int APS5_VABI X509_get0_signature_nid_postfix(void) { NotImplemented_nid_no_patch(__func__); return 0; diff --git a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp index 324b122dec40..f145c0610edd 100644 --- a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp +++ b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp @@ -52,4 +52,8 @@ void* APS5_VABI X509_getm_notAfter_nid_postfix(const LibreSsl3ValidityX509* cert return validity ? validity->notAfter : nullptr; } +const void* APS5_VABI X509_get0_notBefore_nid_postfix(const LibreSsl3ValidityX509* certificate) { + return X509_getm_notBefore_nid_postfix(certificate); +} + } diff --git a/core/libs/tests/GuestLibreSsl3X509Validity.cpp b/core/libs/tests/GuestLibreSsl3X509Validity.cpp index 8188a201f351..328fc90b1e15 100644 --- a/core/libs/tests/GuestLibreSsl3X509Validity.cpp +++ b/core/libs/tests/GuestLibreSsl3X509Validity.cpp @@ -36,6 +36,7 @@ static int After; extern "C" { void* APS5_VABI X509_getm_notBefore_nid_postfix(const TestX509*); void* APS5_VABI X509_getm_notAfter_nid_postfix(const TestX509*); +const void* APS5_VABI X509_get0_notBefore_nid_postfix(const TestX509*); } static void Require(bool condition, std::source_location location = std::source_location::current()) { @@ -83,8 +84,26 @@ static void TestGetmNotAfter() { Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); } +static void TestGet0NotBefore() { + TestValidity validity {}; + TestCertInfo info {}; + TestX509 certificate {}; + Require(X509_get0_notBefore_nid_postfix(nullptr) == nullptr); + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); + certificate.certInfo = &info; + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); + info.validity = &validity; + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); + validity.notBefore = &Before; + validity.notAfter = &After; + Require(X509_get0_notBefore_nid_postfix(&certificate) == &Before); + validity.notBefore = nullptr; + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); +} + int main() { TestGetmNotBefore(); TestGetmNotAfter(); + TestGet0NotBefore(); return 0; } diff --git a/docs/dev/debt/libSceLibreSsl3.md b/docs/dev/debt/libSceLibreSsl3.md index 307a0a4bea0c..9c26a76b5acc 100644 --- a/docs/dev/debt/libSceLibreSsl3.md +++ b/docs/dev/debt/libSceLibreSsl3.md @@ -10,7 +10,7 @@ ### Unknown function info -- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. 72 `OpenSSL_version`, `X509_getm_notBefore` `X509_getm_notAfter`, +- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. `OpenSSL_version`, 71 `X509_getm_notBefore`, `X509_getm_notAfter` `X509_get0_notBefore`, ### Functional @@ -28,7 +28,7 @@ - [EVP_CIPHER_key_length and EVP_CIPHER_iv_length](../../../core/libs/prx/libSceLibreSsl3/src/Cipher.cpp) (libSceLibreSsl3) - nothing is checked on the console. They return `key_len` and `iv_len` from the 80-byte `EVP_CIPHER` of [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp) `evp_local.h` and `evp_cipher.c`. The fields are at offsets 8 and 12, as in the [2.5.4 layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h) of the ciphers the forwarded libSceLibreSsl exports handle. A null cipher, which LibreSSL dereferences, throws. Closes when: compared with the console. - [X509_VERIFY_PARAM_set_flags](../../../core/libs/prx/libSceLibreSsl3/src/X509VerifyParam.cpp) (libSceLibreSsl3) - nothing is checked on the console. It ORs the flags into `flags` and returns 1, as both [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_vpm.c) and [4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_vpm.c) `x509_vpm.c` do. They differ when `EXPLICIT_POLICY`, `INHIBIT_ANY` or `INHIBIT_MAP` is set while `POLICY_CHECK` is neither set nor requested: 2.5.4 also adds `POLICY_CHECK` and 4.0.0 does not. The console's choice is unknown, so that case throws through `NotImplemented_nid_no_patch` and leaves the parameters unchanged. It writes libSceLibreSsl's 2.5.4 `LibreSslX509VerifyParam`, whose `flags` is at offset 24 as in 4.0.0. Null parameters throw. Closes when: the console's policy behaviour is measured. - [sk_new, sk_push and sk_free](../../../core/libs/prx/libSceLibreSsl3/src/Stack.cpp) (libSceLibreSsl3) - follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/stack/stack.c) `stack.c` with libSceLibreSsl's 32-byte `_STACK` layout, which `stack_local.h` keeps there. Stacks and element arrays come from the guest heap, so the forwarded `sk_pop_free` can release them. Nothing is checked on the console. Where LibreSSL faults or overflows, they throw: `sk_push` on a null stack, on a negative element count, on a null element array it does not regrow, or when the element array cannot double without overflowing `int` -- [X509_getm_notBefore, X509_getm_notAfter](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws +- [X509_getm_notBefore, X509_getm_notAfter, X509_get0_notBefore](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws - [ASN1_TIME_diff](../../../core/libs/prx/libSceLibreSsl3/src/Time.cpp) has no console ABI or behavior verification. Its signature and date rules follow LibreSSL 4.0.0 [a_time.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time.c), [a_time_tm.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_tm.c) and [a_time_posix.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_posix.c), using the existing 24-byte string layout. Null inputs use the host wall clock; the console clock relationship is unverified. Null output pointers throw after valid input parsing, where the reference dereferences them. Closes when: measured on a PS5. From 12af500c4abdb479f5748a105e449a975dd570d8 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sat, 24 Oct 2026 05:21:27 +0200 Subject: [PATCH 04/10] feat(libSceLibreSsl3): implement X509_get0_notAfter --- core/libs/prx/libSceLibreSsl3/Export.cpp | 5 ----- .../prx/libSceLibreSsl3/src/X509Validity.cpp | 4 ++++ .../libs/tests/GuestLibreSsl3X509Validity.cpp | 19 +++++++++++++++++++ docs/dev/debt/libSceLibreSsl3.md | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/core/libs/prx/libSceLibreSsl3/Export.cpp b/core/libs/prx/libSceLibreSsl3/Export.cpp index a5f51b092fac..eb9e84785366 100644 --- a/core/libs/prx/libSceLibreSsl3/Export.cpp +++ b/core/libs/prx/libSceLibreSsl3/Export.cpp @@ -291,11 +291,6 @@ int APS5_VABI X509_get0_extensions_nid_postfix(void) { return 0; } -int APS5_VABI X509_get0_notAfter_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - int APS5_VABI X509_get0_signature_nid_postfix(void) { NotImplemented_nid_no_patch(__func__); return 0; diff --git a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp index f145c0610edd..106e44c61280 100644 --- a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp +++ b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp @@ -56,4 +56,8 @@ const void* APS5_VABI X509_get0_notBefore_nid_postfix(const LibreSsl3ValidityX50 return X509_getm_notBefore_nid_postfix(certificate); } +const void* APS5_VABI X509_get0_notAfter_nid_postfix(const LibreSsl3ValidityX509* certificate) { + return X509_getm_notAfter_nid_postfix(certificate); +} + } diff --git a/core/libs/tests/GuestLibreSsl3X509Validity.cpp b/core/libs/tests/GuestLibreSsl3X509Validity.cpp index 328fc90b1e15..ac5fa5e7333e 100644 --- a/core/libs/tests/GuestLibreSsl3X509Validity.cpp +++ b/core/libs/tests/GuestLibreSsl3X509Validity.cpp @@ -37,6 +37,7 @@ extern "C" { void* APS5_VABI X509_getm_notBefore_nid_postfix(const TestX509*); void* APS5_VABI X509_getm_notAfter_nid_postfix(const TestX509*); const void* APS5_VABI X509_get0_notBefore_nid_postfix(const TestX509*); +const void* APS5_VABI X509_get0_notAfter_nid_postfix(const TestX509*); } static void Require(bool condition, std::source_location location = std::source_location::current()) { @@ -101,9 +102,27 @@ static void TestGet0NotBefore() { Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); } +static void TestGet0NotAfter() { + TestValidity validity {}; + TestCertInfo info {}; + TestX509 certificate {}; + Require(X509_get0_notAfter_nid_postfix(nullptr) == nullptr); + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); + certificate.certInfo = &info; + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); + info.validity = &validity; + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); + validity.notBefore = &Before; + validity.notAfter = &After; + Require(X509_get0_notAfter_nid_postfix(&certificate) == &After); + validity.notAfter = nullptr; + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); +} + int main() { TestGetmNotBefore(); TestGetmNotAfter(); TestGet0NotBefore(); + TestGet0NotAfter(); return 0; } diff --git a/docs/dev/debt/libSceLibreSsl3.md b/docs/dev/debt/libSceLibreSsl3.md index 9c26a76b5acc..6f74c190a442 100644 --- a/docs/dev/debt/libSceLibreSsl3.md +++ b/docs/dev/debt/libSceLibreSsl3.md @@ -10,7 +10,7 @@ ### Unknown function info -- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. `OpenSSL_version`, 71 `X509_getm_notBefore`, `X509_getm_notAfter` `X509_get0_notBefore`, +- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. `OpenSSL_version`, `X509_getm_notBefore`, 70 `X509_getm_notAfter`, `X509_get0_notBefore` `X509_get0_notAfter`, ### Functional @@ -28,7 +28,7 @@ - [EVP_CIPHER_key_length and EVP_CIPHER_iv_length](../../../core/libs/prx/libSceLibreSsl3/src/Cipher.cpp) (libSceLibreSsl3) - nothing is checked on the console. They return `key_len` and `iv_len` from the 80-byte `EVP_CIPHER` of [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp) `evp_local.h` and `evp_cipher.c`. The fields are at offsets 8 and 12, as in the [2.5.4 layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h) of the ciphers the forwarded libSceLibreSsl exports handle. A null cipher, which LibreSSL dereferences, throws. Closes when: compared with the console. - [X509_VERIFY_PARAM_set_flags](../../../core/libs/prx/libSceLibreSsl3/src/X509VerifyParam.cpp) (libSceLibreSsl3) - nothing is checked on the console. It ORs the flags into `flags` and returns 1, as both [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_vpm.c) and [4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_vpm.c) `x509_vpm.c` do. They differ when `EXPLICIT_POLICY`, `INHIBIT_ANY` or `INHIBIT_MAP` is set while `POLICY_CHECK` is neither set nor requested: 2.5.4 also adds `POLICY_CHECK` and 4.0.0 does not. The console's choice is unknown, so that case throws through `NotImplemented_nid_no_patch` and leaves the parameters unchanged. It writes libSceLibreSsl's 2.5.4 `LibreSslX509VerifyParam`, whose `flags` is at offset 24 as in 4.0.0. Null parameters throw. Closes when: the console's policy behaviour is measured. - [sk_new, sk_push and sk_free](../../../core/libs/prx/libSceLibreSsl3/src/Stack.cpp) (libSceLibreSsl3) - follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/stack/stack.c) `stack.c` with libSceLibreSsl's 32-byte `_STACK` layout, which `stack_local.h` keeps there. Stacks and element arrays come from the guest heap, so the forwarded `sk_pop_free` can release them. Nothing is checked on the console. Where LibreSSL faults or overflows, they throw: `sk_push` on a null stack, on a negative element count, on a null element array it does not regrow, or when the element array cannot double without overflowing `int` -- [X509_getm_notBefore, X509_getm_notAfter, X509_get0_notBefore](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws +- [X509_getm_notBefore, X509_getm_notAfter, X509_get0_notBefore, X509_get0_notAfter](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws - [ASN1_TIME_diff](../../../core/libs/prx/libSceLibreSsl3/src/Time.cpp) has no console ABI or behavior verification. Its signature and date rules follow LibreSSL 4.0.0 [a_time.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time.c), [a_time_tm.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_tm.c) and [a_time_posix.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_posix.c), using the existing 24-byte string layout. Null inputs use the host wall clock; the console clock relationship is unverified. Null output pointers throw after valid input parsing, where the reference dereferences them. Closes when: measured on a PS5. From f0e15bcbc0408cbdf1659ae59f9d705b66546df7 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sat, 24 Oct 2026 05:21:37 +0200 Subject: [PATCH 05/10] feat(libSceLibreSsl3): implement X509_get0_signature --- core/libs/prx/libSceLibreSsl3/Export.cpp | 5 ---- .../prx/libSceLibreSsl3/src/X509Validity.cpp | 6 +++++ .../libs/tests/GuestLibreSsl3X509Validity.cpp | 24 +++++++++++++++++++ docs/dev/debt/libSceLibreSsl3.md | 4 ++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/core/libs/prx/libSceLibreSsl3/Export.cpp b/core/libs/prx/libSceLibreSsl3/Export.cpp index eb9e84785366..090c55965775 100644 --- a/core/libs/prx/libSceLibreSsl3/Export.cpp +++ b/core/libs/prx/libSceLibreSsl3/Export.cpp @@ -291,11 +291,6 @@ int APS5_VABI X509_get0_extensions_nid_postfix(void) { return 0; } -int APS5_VABI X509_get0_signature_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - int APS5_VABI X509_get_ext_nid_postfix(void) { NotImplemented_nid_no_patch(__func__); return 0; diff --git a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp index 106e44c61280..8614350bd45f 100644 --- a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp +++ b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp @@ -60,4 +60,10 @@ const void* APS5_VABI X509_get0_notAfter_nid_postfix(const LibreSsl3ValidityX509 return X509_getm_notAfter_nid_postfix(certificate); } +void APS5_VABI X509_get0_signature_nid_postfix(const void** signature, const void** algorithm, const LibreSsl3ValidityX509* certificate) { + if (!certificate) throw std::invalid_argument(std::string(__func__) + ": null certificate"); + if (signature) *signature = certificate->signature; + if (algorithm) *algorithm = certificate->sigAlg; +} + } diff --git a/core/libs/tests/GuestLibreSsl3X509Validity.cpp b/core/libs/tests/GuestLibreSsl3X509Validity.cpp index ac5fa5e7333e..578934c7f3a6 100644 --- a/core/libs/tests/GuestLibreSsl3X509Validity.cpp +++ b/core/libs/tests/GuestLibreSsl3X509Validity.cpp @@ -38,6 +38,7 @@ void* APS5_VABI X509_getm_notBefore_nid_postfix(const TestX509*); void* APS5_VABI X509_getm_notAfter_nid_postfix(const TestX509*); const void* APS5_VABI X509_get0_notBefore_nid_postfix(const TestX509*); const void* APS5_VABI X509_get0_notAfter_nid_postfix(const TestX509*); +void APS5_VABI X509_get0_signature_nid_postfix(const void**, const void**, const TestX509*); } static void Require(bool condition, std::source_location location = std::source_location::current()) { @@ -119,10 +120,33 @@ static void TestGet0NotAfter() { Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); } +static void TestGet0Signature() { + int signatureBits = 0; + int algorithm = 0; + TestX509 certificate {}; + const void* signature = &Before; + const void* signatureAlgorithm = &Before; + X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, &certificate); + Require(signature == nullptr && signatureAlgorithm == nullptr); + certificate.signature = &signatureBits; + certificate.sigAlg = &algorithm; + X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, &certificate); + Require(signature == &signatureBits && signatureAlgorithm == &algorithm); + signature = signatureAlgorithm = &After; + X509_get0_signature_nid_postfix(nullptr, &signatureAlgorithm, &certificate); + Require(signature == &After && signatureAlgorithm == &algorithm); + X509_get0_signature_nid_postfix(&signature, nullptr, &certificate); + Require(signature == &signatureBits); + X509_get0_signature_nid_postfix(nullptr, nullptr, &certificate); + RequireThrows([&] { X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, nullptr); }); + RequireThrows([] { X509_get0_signature_nid_postfix(nullptr, nullptr, nullptr); }); +} + int main() { TestGetmNotBefore(); TestGetmNotAfter(); TestGet0NotBefore(); TestGet0NotAfter(); + TestGet0Signature(); return 0; } diff --git a/docs/dev/debt/libSceLibreSsl3.md b/docs/dev/debt/libSceLibreSsl3.md index 6f74c190a442..cdf43c86ce27 100644 --- a/docs/dev/debt/libSceLibreSsl3.md +++ b/docs/dev/debt/libSceLibreSsl3.md @@ -10,7 +10,7 @@ ### Unknown function info -- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. `OpenSSL_version`, `X509_getm_notBefore`, 70 `X509_getm_notAfter`, `X509_get0_notBefore` `X509_get0_notAfter`, +- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. `OpenSSL_version`, `X509_getm_notBefore`, `X509_getm_notAfter`, 69 `X509_get0_notBefore`, `X509_get0_notAfter` `X509_get0_signature`, ### Functional @@ -28,7 +28,7 @@ - [EVP_CIPHER_key_length and EVP_CIPHER_iv_length](../../../core/libs/prx/libSceLibreSsl3/src/Cipher.cpp) (libSceLibreSsl3) - nothing is checked on the console. They return `key_len` and `iv_len` from the 80-byte `EVP_CIPHER` of [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp) `evp_local.h` and `evp_cipher.c`. The fields are at offsets 8 and 12, as in the [2.5.4 layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h) of the ciphers the forwarded libSceLibreSsl exports handle. A null cipher, which LibreSSL dereferences, throws. Closes when: compared with the console. - [X509_VERIFY_PARAM_set_flags](../../../core/libs/prx/libSceLibreSsl3/src/X509VerifyParam.cpp) (libSceLibreSsl3) - nothing is checked on the console. It ORs the flags into `flags` and returns 1, as both [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_vpm.c) and [4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_vpm.c) `x509_vpm.c` do. They differ when `EXPLICIT_POLICY`, `INHIBIT_ANY` or `INHIBIT_MAP` is set while `POLICY_CHECK` is neither set nor requested: 2.5.4 also adds `POLICY_CHECK` and 4.0.0 does not. The console's choice is unknown, so that case throws through `NotImplemented_nid_no_patch` and leaves the parameters unchanged. It writes libSceLibreSsl's 2.5.4 `LibreSslX509VerifyParam`, whose `flags` is at offset 24 as in 4.0.0. Null parameters throw. Closes when: the console's policy behaviour is measured. - [sk_new, sk_push and sk_free](../../../core/libs/prx/libSceLibreSsl3/src/Stack.cpp) (libSceLibreSsl3) - follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/stack/stack.c) `stack.c` with libSceLibreSsl's 32-byte `_STACK` layout, which `stack_local.h` keeps there. Stacks and element arrays come from the guest heap, so the forwarded `sk_pop_free` can release them. Nothing is checked on the console. Where LibreSSL faults or overflows, they throw: `sk_push` on a null stack, on a negative element count, on a null element array it does not regrow, or when the element array cannot double without overflowing `int` -- [X509_getm_notBefore, X509_getm_notAfter, X509_get0_notBefore, X509_get0_notAfter](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws +- [X509_getm_notBefore, X509_getm_notAfter, X509_get0_notBefore, X509_get0_notAfter, X509_get0_signature](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws - [ASN1_TIME_diff](../../../core/libs/prx/libSceLibreSsl3/src/Time.cpp) has no console ABI or behavior verification. Its signature and date rules follow LibreSSL 4.0.0 [a_time.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time.c), [a_time_tm.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_tm.c) and [a_time_posix.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_posix.c), using the existing 24-byte string layout. Null inputs use the host wall clock; the console clock relationship is unverified. Null output pointers throw after valid input parsing, where the reference dereferences them. Closes when: measured on a PS5. From 4a6a38be820ee0acf687c70637dcb822d356f6e0 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sun, 25 Oct 2026 05:59:47 +0100 Subject: [PATCH 06/10] refactor(libSceLibreSsl3): declare the X509 validity exports in the public header --- core/libs/prx/libSceLibreSsl3/include/Api.hpp | 31 ++++++++-- .../prx/libSceLibreSsl3/src/X509Validity.cpp | 22 +------ .../libs/tests/GuestLibreSsl3X509Validity.cpp | 59 +++++++++---------- 3 files changed, 55 insertions(+), 57 deletions(-) diff --git a/core/libs/prx/libSceLibreSsl3/include/Api.hpp b/core/libs/prx/libSceLibreSsl3/include/Api.hpp index d55f88861572..91aeda23c2af 100644 --- a/core/libs/prx/libSceLibreSsl3/include/Api.hpp +++ b/core/libs/prx/libSceLibreSsl3/include/Api.hpp @@ -30,6 +30,27 @@ static_assert(sizeof(LibreSsl3X509Algor) == 16); static_assert(sizeof(LibreSsl3X509Pubkey) == 24); static_assert(offsetof(LibreSsl3X509Pubkey, publicKey) == 8); +struct LibreSsl3X509Validity { + void* notBefore; + void* notAfter; +}; + +struct LibreSsl3ValidityCertInfo { + void* version; + void* serialNumber; + void* signature; + void* issuer; + LibreSsl3X509Validity* validity; + unsigned char rest[64]; +}; + +struct LibreSsl3ValidityX509 { + LibreSsl3ValidityCertInfo* certInfo; + const void* sigAlg; + const void* signature; + unsigned char rest[192]; +}; + extern "C" { int APS5_VABI ASN1_INTEGER_free_nid_postfix(void); @@ -100,14 +121,14 @@ int APS5_VABI X509_STORE_CTX_init_nid_postfix(void); int APS5_VABI X509_STORE_CTX_new_nid_postfix(void); int APS5_VABI X509_STORE_up_ref_nid_postfix(void); int APS5_VABI X509_get0_extensions_nid_postfix(void); -int APS5_VABI X509_get0_notAfter_nid_postfix(void); -int APS5_VABI X509_get0_notBefore_nid_postfix(void); -int APS5_VABI X509_get0_signature_nid_postfix(void); +const void* APS5_VABI X509_get0_notAfter_nid_postfix(const LibreSsl3ValidityX509* certificate); +const void* APS5_VABI X509_get0_notBefore_nid_postfix(const LibreSsl3ValidityX509* certificate); +void APS5_VABI X509_get0_signature_nid_postfix(const void** signature, const void** algorithm, const LibreSsl3ValidityX509* certificate); int APS5_VABI X509_get_ext_nid_postfix(void); int APS5_VABI X509_get_ext_count_nid_postfix(void); int APS5_VABI X509_get_version_nid_postfix(void); -int APS5_VABI X509_getm_notAfter_nid_postfix(void); -int APS5_VABI X509_getm_notBefore_nid_postfix(void); +void* APS5_VABI X509_getm_notAfter_nid_postfix(const LibreSsl3ValidityX509* certificate); +void* APS5_VABI X509_getm_notBefore_nid_postfix(const LibreSsl3ValidityX509* certificate); int APS5_VABI X509_up_ref_nid_postfix(void); void* APS5_VABI d2i_ASN1_INTEGER_nid_postfix(void** output, const unsigned char** input, std::int64_t length); int APS5_VABI d2i_ECParameters_nid_postfix(void); diff --git a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp index 8614350bd45f..dd3267470b17 100644 --- a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp +++ b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp @@ -1,29 +1,9 @@ +#include "prx/libSceLibreSsl3/include/Api.hpp" #include #include #include #include "prx/libc/include/General.hpp" -struct LibreSsl3X509Validity { - void* notBefore; - void* notAfter; -}; - -struct LibreSsl3ValidityCertInfo { - void* version; - void* serialNumber; - void* signature; - void* issuer; - LibreSsl3X509Validity* validity; - unsigned char rest[64]; -}; - -struct LibreSsl3ValidityX509 { - LibreSsl3ValidityCertInfo* certInfo; - const void* sigAlg; - const void* signature; - unsigned char rest[192]; -}; - static_assert(sizeof(LibreSsl3X509Validity) == 16); static_assert(sizeof(LibreSsl3ValidityCertInfo) == 104); static_assert(offsetof(LibreSsl3ValidityCertInfo, validity) == 32); diff --git a/core/libs/tests/GuestLibreSsl3X509Validity.cpp b/core/libs/tests/GuestLibreSsl3X509Validity.cpp index 578934c7f3a6..8e6130482870 100644 --- a/core/libs/tests/GuestLibreSsl3X509Validity.cpp +++ b/core/libs/tests/GuestLibreSsl3X509Validity.cpp @@ -1,3 +1,4 @@ +#include "prx/libSceLibreSsl3/include/Api.hpp" #include "prx/libc/include/general/VabiMacros.hpp" #include #include @@ -33,12 +34,8 @@ static_assert(sizeof(TestX509) == 216 && offsetof(TestX509, signature) == 16); static int Before; static int After; -extern "C" { -void* APS5_VABI X509_getm_notBefore_nid_postfix(const TestX509*); -void* APS5_VABI X509_getm_notAfter_nid_postfix(const TestX509*); -const void* APS5_VABI X509_get0_notBefore_nid_postfix(const TestX509*); -const void* APS5_VABI X509_get0_notAfter_nid_postfix(const TestX509*); -void APS5_VABI X509_get0_signature_nid_postfix(const void**, const void**, const TestX509*); +static const LibreSsl3ValidityX509* Certificate(const TestX509* certificate) { + return reinterpret_cast(certificate); } static void Require(bool condition, std::source_location location = std::source_location::current()) { @@ -57,16 +54,16 @@ static void TestGetmNotBefore() { TestCertInfo info {}; TestX509 certificate {}; Require(X509_getm_notBefore_nid_postfix(nullptr) == nullptr); - Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); + Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); certificate.certInfo = &info; - Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); + Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); info.validity = &validity; - Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); + Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); validity.notBefore = &Before; validity.notAfter = &After; - Require(X509_getm_notBefore_nid_postfix(&certificate) == &Before); + Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == &Before); validity.notBefore = nullptr; - Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); + Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); } static void TestGetmNotAfter() { @@ -74,16 +71,16 @@ static void TestGetmNotAfter() { TestCertInfo info {}; TestX509 certificate {}; Require(X509_getm_notAfter_nid_postfix(nullptr) == nullptr); - Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); + Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); certificate.certInfo = &info; - Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); + Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); info.validity = &validity; - Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); + Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); validity.notBefore = &Before; validity.notAfter = &After; - Require(X509_getm_notAfter_nid_postfix(&certificate) == &After); + Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == &After); validity.notAfter = nullptr; - Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); + Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); } static void TestGet0NotBefore() { @@ -91,16 +88,16 @@ static void TestGet0NotBefore() { TestCertInfo info {}; TestX509 certificate {}; Require(X509_get0_notBefore_nid_postfix(nullptr) == nullptr); - Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); + Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); certificate.certInfo = &info; - Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); + Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); info.validity = &validity; - Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); + Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); validity.notBefore = &Before; validity.notAfter = &After; - Require(X509_get0_notBefore_nid_postfix(&certificate) == &Before); + Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == &Before); validity.notBefore = nullptr; - Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); + Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); } static void TestGet0NotAfter() { @@ -108,16 +105,16 @@ static void TestGet0NotAfter() { TestCertInfo info {}; TestX509 certificate {}; Require(X509_get0_notAfter_nid_postfix(nullptr) == nullptr); - Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); + Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); certificate.certInfo = &info; - Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); + Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); info.validity = &validity; - Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); + Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); validity.notBefore = &Before; validity.notAfter = &After; - Require(X509_get0_notAfter_nid_postfix(&certificate) == &After); + Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == &After); validity.notAfter = nullptr; - Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); + Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); } static void TestGet0Signature() { @@ -126,18 +123,18 @@ static void TestGet0Signature() { TestX509 certificate {}; const void* signature = &Before; const void* signatureAlgorithm = &Before; - X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, &certificate); + X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, Certificate(&certificate)); Require(signature == nullptr && signatureAlgorithm == nullptr); certificate.signature = &signatureBits; certificate.sigAlg = &algorithm; - X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, &certificate); + X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, Certificate(&certificate)); Require(signature == &signatureBits && signatureAlgorithm == &algorithm); signature = signatureAlgorithm = &After; - X509_get0_signature_nid_postfix(nullptr, &signatureAlgorithm, &certificate); + X509_get0_signature_nid_postfix(nullptr, &signatureAlgorithm, Certificate(&certificate)); Require(signature == &After && signatureAlgorithm == &algorithm); - X509_get0_signature_nid_postfix(&signature, nullptr, &certificate); + X509_get0_signature_nid_postfix(&signature, nullptr, Certificate(&certificate)); Require(signature == &signatureBits); - X509_get0_signature_nid_postfix(nullptr, nullptr, &certificate); + X509_get0_signature_nid_postfix(nullptr, nullptr, Certificate(&certificate)); RequireThrows([&] { X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, nullptr); }); RequireThrows([] { X509_get0_signature_nid_postfix(nullptr, nullptr, nullptr); }); } From ab684804106919cb7bb4a102c7a0118be1fd305d Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sun, 25 Oct 2026 17:57:29 +0100 Subject: [PATCH 07/10] fix(libSceLibreSsl3): read the certificate in X509_get0_signature only for requested outputs --- core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp index dd3267470b17..25835cb2b833 100644 --- a/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp +++ b/core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp @@ -41,7 +41,7 @@ const void* APS5_VABI X509_get0_notAfter_nid_postfix(const LibreSsl3ValidityX509 } void APS5_VABI X509_get0_signature_nid_postfix(const void** signature, const void** algorithm, const LibreSsl3ValidityX509* certificate) { - if (!certificate) throw std::invalid_argument(std::string(__func__) + ": null certificate"); + if (!certificate && (signature || algorithm)) throw std::invalid_argument(std::string(__func__) + ": null certificate"); if (signature) *signature = certificate->signature; if (algorithm) *algorithm = certificate->sigAlg; } From 289dbf3b08aa3c465382cfada4cc2a6e25cc3458 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sun, 25 Oct 2026 17:57:59 +0100 Subject: [PATCH 08/10] test(libSceLibreSsl3): use the public X509 structs and check the no-output X509_get0_signature call --- .../libs/tests/GuestLibreSsl3X509Validity.cpp | 110 +++++++----------- 1 file changed, 41 insertions(+), 69 deletions(-) diff --git a/core/libs/tests/GuestLibreSsl3X509Validity.cpp b/core/libs/tests/GuestLibreSsl3X509Validity.cpp index 8e6130482870..13b6e84c034a 100644 --- a/core/libs/tests/GuestLibreSsl3X509Validity.cpp +++ b/core/libs/tests/GuestLibreSsl3X509Validity.cpp @@ -1,43 +1,13 @@ #include "prx/libSceLibreSsl3/include/Api.hpp" #include "prx/libc/include/general/VabiMacros.hpp" -#include #include #include #include #include -struct TestValidity { - void* notBefore; - void* notAfter; -}; - -struct TestCertInfo { - void* version; - void* serialNumber; - void* signature; - void* issuer; - TestValidity* validity; - void* subject; - void* rest[7]; -}; - -struct TestX509 { - TestCertInfo* certInfo; - const void* sigAlg; - const void* signature; - void* rest[24]; -}; - -static_assert(sizeof(TestCertInfo) == 104 && offsetof(TestCertInfo, validity) == 32); -static_assert(sizeof(TestX509) == 216 && offsetof(TestX509, signature) == 16); - static int Before; static int After; -static const LibreSsl3ValidityX509* Certificate(const TestX509* certificate) { - return reinterpret_cast(certificate); -} - static void Require(bool condition, std::source_location location = std::source_location::current()) { if (condition) return; std::fprintf(stderr, "LibreSSL X509 validity check failed at line %u\n", location.line()); @@ -50,93 +20,95 @@ template static void RequireThrows(TAction action, std::source } static void TestGetmNotBefore() { - TestValidity validity {}; - TestCertInfo info {}; - TestX509 certificate {}; + LibreSsl3X509Validity validity {}; + LibreSsl3ValidityCertInfo info {}; + LibreSsl3ValidityX509 certificate {}; Require(X509_getm_notBefore_nid_postfix(nullptr) == nullptr); - Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); certificate.certInfo = &info; - Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); info.validity = &validity; - Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); validity.notBefore = &Before; validity.notAfter = &After; - Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == &Before); + Require(X509_getm_notBefore_nid_postfix(&certificate) == &Before); validity.notBefore = nullptr; - Require(X509_getm_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr); } static void TestGetmNotAfter() { - TestValidity validity {}; - TestCertInfo info {}; - TestX509 certificate {}; + LibreSsl3X509Validity validity {}; + LibreSsl3ValidityCertInfo info {}; + LibreSsl3ValidityX509 certificate {}; Require(X509_getm_notAfter_nid_postfix(nullptr) == nullptr); - Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); certificate.certInfo = &info; - Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); info.validity = &validity; - Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); validity.notBefore = &Before; validity.notAfter = &After; - Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == &After); + Require(X509_getm_notAfter_nid_postfix(&certificate) == &After); validity.notAfter = nullptr; - Require(X509_getm_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr); } static void TestGet0NotBefore() { - TestValidity validity {}; - TestCertInfo info {}; - TestX509 certificate {}; + LibreSsl3X509Validity validity {}; + LibreSsl3ValidityCertInfo info {}; + LibreSsl3ValidityX509 certificate {}; Require(X509_get0_notBefore_nid_postfix(nullptr) == nullptr); - Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); certificate.certInfo = &info; - Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); info.validity = &validity; - Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); validity.notBefore = &Before; validity.notAfter = &After; - Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == &Before); + Require(X509_get0_notBefore_nid_postfix(&certificate) == &Before); validity.notBefore = nullptr; - Require(X509_get0_notBefore_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr); } static void TestGet0NotAfter() { - TestValidity validity {}; - TestCertInfo info {}; - TestX509 certificate {}; + LibreSsl3X509Validity validity {}; + LibreSsl3ValidityCertInfo info {}; + LibreSsl3ValidityX509 certificate {}; Require(X509_get0_notAfter_nid_postfix(nullptr) == nullptr); - Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); certificate.certInfo = &info; - Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); info.validity = &validity; - Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); validity.notBefore = &Before; validity.notAfter = &After; - Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == &After); + Require(X509_get0_notAfter_nid_postfix(&certificate) == &After); validity.notAfter = nullptr; - Require(X509_get0_notAfter_nid_postfix(Certificate(&certificate)) == nullptr); + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr); } static void TestGet0Signature() { int signatureBits = 0; int algorithm = 0; - TestX509 certificate {}; + LibreSsl3ValidityX509 certificate {}; const void* signature = &Before; const void* signatureAlgorithm = &Before; - X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, Certificate(&certificate)); + X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, &certificate); Require(signature == nullptr && signatureAlgorithm == nullptr); certificate.signature = &signatureBits; certificate.sigAlg = &algorithm; - X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, Certificate(&certificate)); + X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, &certificate); Require(signature == &signatureBits && signatureAlgorithm == &algorithm); signature = signatureAlgorithm = &After; - X509_get0_signature_nid_postfix(nullptr, &signatureAlgorithm, Certificate(&certificate)); + X509_get0_signature_nid_postfix(nullptr, &signatureAlgorithm, &certificate); Require(signature == &After && signatureAlgorithm == &algorithm); - X509_get0_signature_nid_postfix(&signature, nullptr, Certificate(&certificate)); + X509_get0_signature_nid_postfix(&signature, nullptr, &certificate); Require(signature == &signatureBits); - X509_get0_signature_nid_postfix(nullptr, nullptr, Certificate(&certificate)); + X509_get0_signature_nid_postfix(nullptr, nullptr, &certificate); + X509_get0_signature_nid_postfix(nullptr, nullptr, nullptr); RequireThrows([&] { X509_get0_signature_nid_postfix(&signature, &signatureAlgorithm, nullptr); }); - RequireThrows([] { X509_get0_signature_nid_postfix(nullptr, nullptr, nullptr); }); + RequireThrows([&] { X509_get0_signature_nid_postfix(&signature, nullptr, nullptr); }); + RequireThrows([&] { X509_get0_signature_nid_postfix(nullptr, &signatureAlgorithm, nullptr); }); } int main() { From 618fba526b411659e7b6dc9143241635b1c89b3a Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sun, 25 Oct 2026 17:58:00 +0100 Subject: [PATCH 09/10] docs(libSceLibreSsl3): record the no-output X509_get0_signature call --- docs/dev/debt/libSceLibreSsl3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/debt/libSceLibreSsl3.md b/docs/dev/debt/libSceLibreSsl3.md index cdf43c86ce27..8b2b88fe0da4 100644 --- a/docs/dev/debt/libSceLibreSsl3.md +++ b/docs/dev/debt/libSceLibreSsl3.md @@ -28,7 +28,7 @@ - [EVP_CIPHER_key_length and EVP_CIPHER_iv_length](../../../core/libs/prx/libSceLibreSsl3/src/Cipher.cpp) (libSceLibreSsl3) - nothing is checked on the console. They return `key_len` and `iv_len` from the 80-byte `EVP_CIPHER` of [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/evp) `evp_local.h` and `evp_cipher.c`. The fields are at offsets 8 and 12, as in the [2.5.4 layout](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp/evp.h) of the ciphers the forwarded libSceLibreSsl exports handle. A null cipher, which LibreSSL dereferences, throws. Closes when: compared with the console. - [X509_VERIFY_PARAM_set_flags](../../../core/libs/prx/libSceLibreSsl3/src/X509VerifyParam.cpp) (libSceLibreSsl3) - nothing is checked on the console. It ORs the flags into `flags` and returns 1, as both [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_vpm.c) and [4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_vpm.c) `x509_vpm.c` do. They differ when `EXPLICIT_POLICY`, `INHIBIT_ANY` or `INHIBIT_MAP` is set while `POLICY_CHECK` is neither set nor requested: 2.5.4 also adds `POLICY_CHECK` and 4.0.0 does not. The console's choice is unknown, so that case throws through `NotImplemented_nid_no_patch` and leaves the parameters unchanged. It writes libSceLibreSsl's 2.5.4 `LibreSslX509VerifyParam`, whose `flags` is at offset 24 as in 4.0.0. Null parameters throw. Closes when: the console's policy behaviour is measured. - [sk_new, sk_push and sk_free](../../../core/libs/prx/libSceLibreSsl3/src/Stack.cpp) (libSceLibreSsl3) - follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/stack/stack.c) `stack.c` with libSceLibreSsl's 32-byte `_STACK` layout, which `stack_local.h` keeps there. Stacks and element arrays come from the guest heap, so the forwarded `sk_pop_free` can release them. Nothing is checked on the console. Where LibreSSL faults or overflows, they throw: `sk_push` on a null stack, on a negative element count, on a null element array it does not regrow, or when the element array cannot double without overflowing `int` -- [X509_getm_notBefore, X509_getm_notAfter, X509_get0_notBefore, X509_get0_notAfter, X509_get0_signature](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature`, which LibreSSL dereferences, throws +- [X509_getm_notBefore, X509_getm_notAfter, X509_get0_notBefore, X509_get0_notAfter, X509_get0_signature](../../../core/libs/prx/libSceLibreSsl3/src/X509Validity.cpp) (libSceLibreSsl3) - nothing is checked on the console. The `X509`, `X509_CINF` and `X509_VAL` layouts and the results follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `x509_local.h`, `x509_set.c` and `x_x509.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). No export of this module creates a certificate yet, so only certificates the caller builds reach them. A null certificate in `X509_get0_signature` throws when an output is requested, where LibreSSL dereferences it; with both outputs null the call returns without reading the certificate, as in LibreSSL - [ASN1_TIME_diff](../../../core/libs/prx/libSceLibreSsl3/src/Time.cpp) has no console ABI or behavior verification. Its signature and date rules follow LibreSSL 4.0.0 [a_time.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time.c), [a_time_tm.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_tm.c) and [a_time_posix.c](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/a_time_posix.c), using the existing 24-byte string layout. Null inputs use the host wall clock; the console clock relationship is unverified. Null output pointers throw after valid input parsing, where the reference dereferences them. Closes when: measured on a PS5. From 20496fe1f43acc56e699990955af8a36c0baa3cd Mon Sep 17 00:00:00 2001 From: Alvaro Date: Thu, 5 Nov 2026 19:31:44 +0100 Subject: [PATCH 10/10] docs(libSceLibreSsl3): count 62 pending exports after the rebase --- docs/dev/debt/libSceLibreSsl3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/debt/libSceLibreSsl3.md b/docs/dev/debt/libSceLibreSsl3.md index 8b2b88fe0da4..706ee4ff99c2 100644 --- a/docs/dev/debt/libSceLibreSsl3.md +++ b/docs/dev/debt/libSceLibreSsl3.md @@ -10,7 +10,7 @@ ### Unknown function info -- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 67 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. `OpenSSL_version`, `X509_getm_notBefore`, `X509_getm_notAfter`, 69 `X509_get0_notBefore`, `X509_get0_notAfter` `X509_get0_signature`, +- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 62 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref`, `RSA_up_ref`, `EVP_PKEY_get0_RSA`, `EVP_PKEY_get0_DSA`, `EVP_PKEY_get0_DH`, `EVP_MD_CTX_new`, `EVP_MD_CTX_free`, `EVP_DigestInit`, `EVP_sha1`, `EVP_sha224`, `ERR_load_crypto_strings`, `ERR_peek_last_error`, `X509_PUBKEY_get0_param` and `OBJ_cmp`, remain unimplemented from the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibreSsl3.c), cross-checked against the same module in PS5 firmware 13.60. Their signatures and behaviour are unverified; the declarations use the no-parameter unknown-signature convention and throw through `NotImplemented_nid_no_patch`. `OpenSSL_version`, `X509_getm_notBefore`, `X509_getm_notAfter`, 69 `X509_get0_notBefore`, `X509_get0_notAfter` `X509_get0_signature`, ### Functional