From bfaed1768d1f7ae6b8fd028f67f662de21e34e9c Mon Sep 17 00:00:00 2001 From: Oleg Date: Sat, 31 Oct 2026 00:57:51 +0500 Subject: [PATCH] feat(libSceLibreSsl3): implement X509 field accessors --- core/libs/prx/libSceLibreSsl3/CMakeLists.txt | 10 +- core/libs/prx/libSceLibreSsl3/Export.cpp | 40 -------- core/libs/prx/libSceLibreSsl3/include/Api.hpp | 17 ++-- core/libs/prx/libSceLibreSsl3/include/Key.hpp | 37 ++++++- .../prx/libSceLibreSsl3/src/X509Accessors.cpp | 63 ++++++++++++ .../tests/GuestLibreSsl3X509Accessors.cpp | 98 +++++++++++++++++++ docs/dev/debt/libSceLibreSsl3.md | 4 +- 7 files changed, 215 insertions(+), 54 deletions(-) create mode 100644 core/libs/prx/libSceLibreSsl3/src/X509Accessors.cpp create mode 100644 core/libs/tests/GuestLibreSsl3X509Accessors.cpp diff --git a/core/libs/prx/libSceLibreSsl3/CMakeLists.txt b/core/libs/prx/libSceLibreSsl3/CMakeLists.txt index 63ec1811e47d..ea534c2f26c9 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) +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/X509Accessors.cpp) target_include_directories(libSceLibreSsl3 PRIVATE ${LIBS_INCLUDE_DIR}) target_link_libraries(libSceLibreSsl3 PRIVATE libSceLibreSsl libc) configure_windows_unwind(libSceLibreSsl3) @@ -40,11 +40,15 @@ if(BUILD_TESTING) add_test_executable(guest_libressl3_key_reference_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibreSsl3KeyReference.cpp) target_include_directories(guest_libressl3_key_reference_tests PRIVATE ${LIBS_INCLUDE_DIR}) target_link_libraries(guest_libressl3_key_reference_tests PRIVATE libSceLibreSsl3) - configure_windows_unwind(guest_libressl3_key_reference_tests) add_test(NAME guest_libressl3_key_reference COMMAND guest_libressl3_key_reference_tests) set_tests_properties(guest_libressl3_key_reference PROPERTIES TIMEOUT 20) + add_test_executable(guest_libressl3_x509_accessors_tests ${LIBS_INCLUDE_DIR}/tests/GuestLibreSsl3X509Accessors.cpp) + target_include_directories(guest_libressl3_x509_accessors_tests PRIVATE ${LIBS_INCLUDE_DIR}) + target_link_libraries(guest_libressl3_x509_accessors_tests PRIVATE libSceLibreSsl3) + add_test(NAME guest_libressl3_x509_accessors COMMAND guest_libressl3_x509_accessors_tests) + set_tests_properties(guest_libressl3_x509_accessors PROPERTIES TIMEOUT 20) if(WIN32) - set_tests_properties(guest_crypto_memcmp guest_libressl3_digest guest_libressl3_asn1 guest_libressl3_key_reference PROPERTIES ENVIRONMENT_MODIFICATION + set_tests_properties(guest_crypto_memcmp guest_libressl3_digest guest_libressl3_asn1 guest_libressl3_key_reference guest_libressl3_x509_accessors PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") endif() endif() diff --git a/core/libs/prx/libSceLibreSsl3/Export.cpp b/core/libs/prx/libSceLibreSsl3/Export.cpp index a299a4c7a7a5..8d5e23f86e75 100644 --- a/core/libs/prx/libSceLibreSsl3/Export.cpp +++ b/core/libs/prx/libSceLibreSsl3/Export.cpp @@ -331,51 +331,11 @@ int APS5_VABI X509_STORE_up_ref_nid_postfix(void) { return 0; } -int APS5_VABI X509_get0_extensions_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - -int APS5_VABI X509_get0_notAfter_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - 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; -} - -int APS5_VABI X509_get_ext_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - -int APS5_VABI X509_get_ext_count_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - return 0; -} - int APS5_VABI X509_get_version_nid_postfix(void) { NotImplemented_nid_no_patch(__func__); return 0; } -int APS5_VABI X509_getm_notAfter_nid_postfix(void) { - NotImplemented_nid_no_patch(__func__); - 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/include/Api.hpp b/core/libs/prx/libSceLibreSsl3/include/Api.hpp index 2bb0ee093019..be3e3e435ec6 100644 --- a/core/libs/prx/libSceLibreSsl3/include/Api.hpp +++ b/core/libs/prx/libSceLibreSsl3/include/Api.hpp @@ -6,6 +6,7 @@ extern "C" { + int APS5_VABI ASN1_INTEGER_free_nid_postfix(void); int APS5_VABI ASN1_OBJECT_free_nid_postfix(void); int APS5_VABI ASN1_STRING_get0_data_nid_postfix(void); @@ -73,15 +74,15 @@ int APS5_VABI X509_STORE_CTX_free_nid_postfix(void); 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); -int APS5_VABI X509_get_ext_nid_postfix(void); -int APS5_VABI X509_get_ext_count_nid_postfix(void); +void* APS5_VABI X509_get0_extensions_nid_postfix(const LibreSsl3X509* certificate); +const Asn1String* APS5_VABI X509_get0_notAfter_nid_postfix(const LibreSsl3X509* certificate); +const Asn1String* APS5_VABI X509_get0_notBefore_nid_postfix(const LibreSsl3X509* certificate); +void APS5_VABI X509_get0_signature_nid_postfix(const Asn1String** signature, void** algorithm, const LibreSsl3X509* certificate); +void* APS5_VABI X509_get_ext_nid_postfix(const LibreSsl3X509* certificate, int location); +int APS5_VABI X509_get_ext_count_nid_postfix(const LibreSsl3X509* certificate); 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); +Asn1String* APS5_VABI X509_getm_notAfter_nid_postfix(LibreSsl3X509* certificate); +Asn1String* APS5_VABI X509_getm_notBefore_nid_postfix(LibreSsl3X509* 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/include/Key.hpp b/core/libs/prx/libSceLibreSsl3/include/Key.hpp index 4dac85fd570b..ffb011b785fb 100644 --- a/core/libs/prx/libSceLibreSsl3/include/Key.hpp +++ b/core/libs/prx/libSceLibreSsl3/include/Key.hpp @@ -1,8 +1,8 @@ -#pragma once - #include #include +#include "prx/libSceLibreSsl/include/Api.hpp" + struct LibreSsl3EvpPkey { std::int32_t type; std::int32_t references; @@ -47,9 +47,42 @@ struct LibreSsl3Rsa { void* mtBlinding; }; +struct LibreSsl3X509Val { + Asn1String* notBefore; + Asn1String* notAfter; +}; + +struct LibreSsl3X509CertInfo { + Asn1String* version; + void* serialNumber; + void* signature; + void* issuer; + LibreSsl3X509Val* validity; + void* subject; + void* key; + void* issuerUID; + void* subjectUID; + LibreSslStack* extensions; +}; + +struct LibreSsl3X509 { + LibreSsl3X509CertInfo* certInfo; + void* sigAlg; + void* signature; + std::int32_t valid; + std::int32_t references; +}; + static_assert(sizeof(LibreSsl3EvpPkey) == 32); static_assert(offsetof(LibreSsl3EvpPkey, references) == 4); static_assert(sizeof(LibreSsl3EcKey) == 64); static_assert(offsetof(LibreSsl3EcKey, references) == 48); static_assert(sizeof(LibreSsl3Rsa) == 152); static_assert(offsetof(LibreSsl3Rsa, references) == 104); +static_assert(sizeof(LibreSsl3X509Val) == 16); +static_assert(sizeof(LibreSsl3X509CertInfo) == 80); +static_assert(sizeof(LibreSsl3X509) == 32); +static_assert(offsetof(LibreSsl3X509, references) == 28); +static_assert(offsetof(LibreSsl3X509, certInfo) == 0); +static_assert(offsetof(LibreSsl3X509CertInfo, validity) == 32); +static_assert(offsetof(LibreSsl3X509CertInfo, extensions) == 72); diff --git a/core/libs/prx/libSceLibreSsl3/src/X509Accessors.cpp b/core/libs/prx/libSceLibreSsl3/src/X509Accessors.cpp new file mode 100644 index 000000000000..1857cff75264 --- /dev/null +++ b/core/libs/prx/libSceLibreSsl3/src/X509Accessors.cpp @@ -0,0 +1,63 @@ +#include "prx/libSceLibreSsl3/libSceLibreSsl3.hpp" + +#include +#include +#include + +extern "C" { + +const Asn1String* APS5_VABI X509_get0_notBefore_nid_postfix(const LibreSsl3X509* certificate) { + if (!certificate) throw std::invalid_argument("X509_get0_notBefore requires a certificate"); + if (!certificate->certInfo) throw std::invalid_argument("X509_get0_notBefore requires cert info"); + if (!certificate->certInfo->validity) return nullptr; + return certificate->certInfo->validity->notBefore; +} + +const Asn1String* APS5_VABI X509_get0_notAfter_nid_postfix(const LibreSsl3X509* certificate) { + if (!certificate) throw std::invalid_argument("X509_get0_notAfter requires a certificate"); + if (!certificate->certInfo) throw std::invalid_argument("X509_get0_notAfter requires cert info"); + if (!certificate->certInfo->validity) return nullptr; + return certificate->certInfo->validity->notAfter; +} + +Asn1String* APS5_VABI X509_getm_notBefore_nid_postfix(LibreSsl3X509* certificate) { + if (!certificate) throw std::invalid_argument("X509_getm_notBefore requires a certificate"); + if (!certificate->certInfo) throw std::invalid_argument("X509_getm_notBefore requires cert info"); + if (!certificate->certInfo->validity) return nullptr; + return certificate->certInfo->validity->notBefore; +} + +Asn1String* APS5_VABI X509_getm_notAfter_nid_postfix(LibreSsl3X509* certificate) { + if (!certificate) throw std::invalid_argument("X509_getm_notAfter requires a certificate"); + if (!certificate->certInfo) throw std::invalid_argument("X509_getm_notAfter requires cert info"); + if (!certificate->certInfo->validity) return nullptr; + return certificate->certInfo->validity->notAfter; +} + +void APS5_VABI X509_get0_signature_nid_postfix(const Asn1String** signature, void** algorithm, const LibreSsl3X509* certificate) { + if (!certificate) throw std::invalid_argument("X509_get0_signature requires a certificate"); + if (signature) *signature = static_cast(certificate->signature); + if (algorithm) *algorithm = certificate->sigAlg; +} + +void* APS5_VABI X509_get_ext_nid_postfix(const LibreSsl3X509* certificate, int location) { + if (!certificate) throw std::invalid_argument("X509_get_ext requires a certificate"); + if (!certificate->certInfo || !certificate->certInfo->extensions) return nullptr; + auto* const stack = certificate->certInfo->extensions; + if (location < 0 || location >= stack->num) return nullptr; + return stack->data[location]; +} + +int APS5_VABI X509_get_ext_count_nid_postfix(const LibreSsl3X509* certificate) { + if (!certificate) throw std::invalid_argument("X509_get_ext_count requires a certificate"); + if (!certificate->certInfo || !certificate->certInfo->extensions) return 0; + return certificate->certInfo->extensions->num; +} + +void* APS5_VABI X509_get0_extensions_nid_postfix(const LibreSsl3X509* certificate) { + if (!certificate) throw std::invalid_argument("X509_get0_extensions requires a certificate"); + if (!certificate->certInfo) return nullptr; + return certificate->certInfo->extensions; +} + +} diff --git a/core/libs/tests/GuestLibreSsl3X509Accessors.cpp b/core/libs/tests/GuestLibreSsl3X509Accessors.cpp new file mode 100644 index 000000000000..bc008adf20f9 --- /dev/null +++ b/core/libs/tests/GuestLibreSsl3X509Accessors.cpp @@ -0,0 +1,98 @@ +#include "prx/libSceLibreSsl3/libSceLibreSsl3.hpp" + +#include +#include +#include +#include +#include +#include +#include + +static void Require(bool condition, const char* message) { + if (!condition) { + std::fprintf(stderr, "%s\n", message); + std::abort(); + } +} + +static void CheckAccessors() { + Asn1String notBefore{5, 23, nullptr, 0}; + Asn1String notAfter{7, 23, nullptr, 0}; + LibreSsl3X509Val validity{¬Before, ¬After}; + LibreSslStack extensions{2, nullptr, 0, 4, nullptr}; + void* extensionData[4] = {reinterpret_cast(0x10), reinterpret_cast(0x20), nullptr, nullptr}; + extensions.data = reinterpret_cast(extensionData); + LibreSsl3X509CertInfo certInfo{}; + certInfo.version = nullptr; + certInfo.validity = &validity; + certInfo.extensions = &extensions; + LibreSsl3X509 certificate{}; + certificate.certInfo = &certInfo; + certificate.sigAlg = reinterpret_cast(0xABC); + certificate.signature = reinterpret_cast(0xDEF); + certificate.valid = 1; + certificate.references = 7; + + Require(X509_get0_notBefore_nid_postfix(&certificate) == ¬Before, "notBefore mismatch"); + Require(X509_get0_notAfter_nid_postfix(&certificate) == ¬After, "notAfter mismatch"); + Require(X509_getm_notBefore_nid_postfix(&certificate) == ¬Before, "mutable notBefore mismatch"); + Require(X509_getm_notAfter_nid_postfix(&certificate) == ¬After, "mutable notAfter mismatch"); + + const Asn1String* signature = nullptr; + void* algorithm = nullptr; + X509_get0_signature_nid_postfix(&signature, &algorithm, &certificate); + Require(signature == reinterpret_cast(certificate.signature), "signature pointer mismatch"); + Require(algorithm == certificate.sigAlg, "algorithm pointer mismatch"); + + X509_get0_signature_nid_postfix(nullptr, &algorithm, &certificate); + Require(algorithm == certificate.sigAlg, "null signature output must not clobber algorithm"); + X509_get0_signature_nid_postfix(&signature, nullptr, &certificate); + Require(signature == reinterpret_cast(certificate.signature), "null algorithm output must not clobber signature"); + + Require(X509_get_ext_count_nid_postfix(&certificate) == 2, "extension count mismatch"); + Require(X509_get_ext_nid_postfix(&certificate, 0) == extensionData[0], "extension 0 mismatch"); + Require(X509_get_ext_nid_postfix(&certificate, 1) == extensionData[1], "extension 1 mismatch"); + Require(X509_get_ext_nid_postfix(&certificate, 2) == nullptr, "out of range extension must be null"); + Require(X509_get_ext_nid_postfix(&certificate, -1) == nullptr, "negative extension index must be null"); + Require(X509_get0_extensions_nid_postfix(&certificate) == &extensions, "extensions stack mismatch"); + + certInfo.validity = nullptr; + Require(X509_get0_notBefore_nid_postfix(&certificate) == nullptr, "null validity must yield null notBefore"); + Require(X509_get0_notAfter_nid_postfix(&certificate) == nullptr, "null validity must yield null notAfter"); + Require(X509_getm_notBefore_nid_postfix(&certificate) == nullptr, "null validity must yield null mutable notBefore"); + Require(X509_getm_notAfter_nid_postfix(&certificate) == nullptr, "null validity must yield null mutable notAfter"); + + certInfo.extensions = nullptr; + Require(X509_get_ext_count_nid_postfix(&certificate) == 0, "null extensions must yield zero count"); + Require(X509_get_ext_nid_postfix(&certificate, 0) == nullptr, "null extensions must yield null extension"); + Require(X509_get0_extensions_nid_postfix(&certificate) == nullptr, "null extensions must yield null stack"); + + bool nullThrown = false; + try { + X509_get0_notBefore_nid_postfix(nullptr); + } catch (const std::invalid_argument&) { + nullThrown = true; + } + Require(nullThrown, "null certificate for notBefore did not throw"); + + nullThrown = false; + try { + X509_get_ext_count_nid_postfix(nullptr); + } catch (const std::invalid_argument&) { + nullThrown = true; + } + Require(nullThrown, "null certificate for ext count did not throw"); + + nullThrown = false; + try { + X509_get0_signature_nid_postfix(nullptr, nullptr, nullptr); + } catch (const std::invalid_argument&) { + nullThrown = true; + } + Require(nullThrown, "null certificate for signature did not throw"); +} + +int main() { + CheckAccessors(); + return 0; +} diff --git a/docs/dev/debt/libSceLibreSsl3.md b/docs/dev/debt/libSceLibreSsl3.md index a6c1edbe5c45..a37b2e30a333 100644 --- a/docs/dev/debt/libSceLibreSsl3.md +++ b/docs/dev/debt/libSceLibreSsl3.md @@ -2,7 +2,7 @@ ### Unknown function info -- [libSceLibreSsl3 pending exports](../../../core/libs/prx/libSceLibreSsl3/Export.cpp) - 80 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref` and `RSA_up_ref`, 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) - 72 named callable exports, excluding `CRYPTO_memcmp`, `MD5`, `SHA1`, `d2i_ASN1_INTEGER`, `EVP_PKEY_up_ref`, `EC_KEY_up_ref` and `RSA_up_ref`, 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`. ### Functional @@ -11,6 +11,8 @@ - [MD5 and SHA1](../../../core/libs/prx/libSceLibreSsl3/src/Digest.cpp) (libSceLibreSsl3) - follow LibreSSL's [md5.c, sha1.c](https://github.com/libressl/openbsd/tree/bc9483725c5815efb64b6d9acc52fc5fba139212/src/lib/libcrypto) and hash through libSceLibreSsl's `MD5_*` and `SHA1_*`. A null digest buffer, which LibreSSL 4.0.0 does not check, throws. Nothing is checked on the console - [EVP_PKEY_up_ref, EC_KEY_up_ref and RSA_up_ref](../../../core/libs/prx/libSceLibreSsl3/src/Key.cpp) - console layouts and retain/release interoperability are unverified. The 32-byte EVP, 64-byte EC and 152-byte RSA layouts, with counters at offsets 4, 48 and 104, follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/tree/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto) `evp/evp_local.h`, `evp/p_lib.c`, `ec/ec_local.h`, `ec/ec_key.c`, `rsa/rsa_local.h` and `rsa/rsa_lib.c`; the RSA layout has no `engine` field, unlike libSceLibreSsl's `LibreSslRsa`. Atomic retains replace its internal mutex; future releases must synchronize with the same counters. With no key constructors/destructors in this module, tests use caller-owned objects without validating allocator or destruction compatibility. Null keys and signed-counter overflow, undefined upstream, throw without mutation. Closes when: console layouts and lifetime interoperability are measured. +- [X509_get0_notBefore, X509_get0_notAfter, X509_getm_notBefore, X509_getm_notAfter, X509_get0_signature, X509_get_ext, X509_get_ext_count and X509_get0_extensions](../../../core/libs/prx/libSceLibreSsl3/src/X509Accessors.cpp) (libSceLibreSsl3) - follow [LibreSSL 4.0.0](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/x509/x509_local.h) `x509_st` and `x509_cinf_st`. The 32-byte `LibreSsl3X509` mirrors the v2 `LibreSslX509`. Its 80-byte `certInfo` holds version, serial number, signature, issuer, validity, subject, key, issuer UID, subject UID and extensions. `notBefore` and `notAfter` come from `validity`. Extension access uses `LibreSslStack` `num` and `data` directly since `sk_num`/`sk_value` are unimplemented. Null certificates throw; missing validity or extension stack returns null or zero. Console layouts and lifetime interoperability are unverified. Closes when: measured on a PS5. + - [Parent export forwarding](../../../core/libs/prx/libSceLibreSsl3/ParentExports.cpp) exposes 395 parent-library exports on Windows through IAT tail jumps without changing their ABI. Non-Windows hosts use their existing dependency lookup. Static COFF inspection verifies names, parent imports and tail jumps; Windows loading and runtime behavior remain unverified. Parent functions retain their existing implementation limitations. - [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`