feat(libSceLibreSsl): implement SSL_want

This commit is contained in:
Alvaro committed 2026-11-04 23:57:28 +01:00
1 parent 4574b58171
commit d5f0ea7f5f
4 files changed
+22 -7

No files matched your search

-5
View File
@@ -964,11 +964,6 @@ int APS5_VABI SSL_use_certificate_ASN1_nid_postfix(void) {
return 0;
}
int APS5_VABI SSL_want_nid_postfix(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI SSL_write_nid_postfix(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
+4
View File
@@ -95,4 +95,8 @@ int APS5_VABI SSL_get_shutdown_nid_postfix(const LibreSslSsl* ssl) {
return Internal(ssl, __func__).shutdown;
}
int APS5_VABI SSL_want_nid_postfix(const LibreSslSsl* ssl) {
return Internal(ssl, __func__).rwstate;
}
}
+16
View File
@@ -40,6 +40,7 @@ void* APS5_VABI SSL_get_wbio_nid_postfix(const TestSsl*);
int APS5_VABI SSL_version_nid_postfix(const TestSsl*);
std::int64_t APS5_VABI SSL_get_verify_result_nid_postfix(const TestSsl*);
int APS5_VABI SSL_get_shutdown_nid_postfix(const TestSsl*);
int APS5_VABI SSL_want_nid_postfix(const TestSsl*);
}
static void Require(bool condition, std::source_location location = std::source_location::current()) {
@@ -124,6 +125,20 @@ static void TestGetShutdown() {
Require(SSL_get_shutdown_nid_postfix(&ssl) == 3);
}
static void TestWant() {
TestSslInternal internal {};
TestSsl ssl {};
RequireThrows([] { SSL_want_nid_postfix(nullptr); });
RequireThrows([&] { SSL_want_nid_postfix(&ssl); });
ssl.internal = &internal;
Require(SSL_want_nid_postfix(&ssl) == 0);
internal.rwstate = 1;
Require(SSL_want_nid_postfix(&ssl) == 1);
internal.shutdown = 2;
internal.rwstate = 3;
Require(SSL_want_nid_postfix(&ssl) == 3);
}
int main() {
TestGetSslCtx();
TestGetRbio();
@@ -131,5 +146,6 @@ int main() {
TestVersion();
TestVerifyResult();
TestGetShutdown();
TestWant();
return 0;
}
+2 -2
View File
@@ -7,7 +7,7 @@
### Unknown function info
- [libSceLibreSsl pending exports](../../../core/libs/prx/libSceLibreSsl/Export.cpp) - 214 named callable exports are listed in the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c9cd71c1f34c790cfbe98c751a13262ad/libSceLibreSsl.c) and were 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`.
- [libSceLibreSsl pending exports](../../../core/libs/prx/libSceLibreSsl/Export.cpp) - 213 named callable exports are listed in the [PS5 3.20 export table](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c9cd71c1f34c790cfbe98c751a13262ad/libSceLibreSsl.c) and were 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`.
- [MD4, MD5, SHA1, SHA224, SHA256, SHA384 and SHA512 Init/Update/Final and SHA256](../../../core/libs/prx/libSceLibreSsl/src/Digest.cpp) (libSceLibreSsl) - signatures and context layouts follow the [LibreSSL headers](https://github.com/libressl/openbsd/blob/bc9483725c5815efb64b6d9acc52fc5fba139212/src/lib/libcrypto/sha/sha.h), and buffering and `Final` follow its [sources](https://github.com/libressl/openbsd/tree/bc9483725c5815efb64b6d9acc52fc5fba139212/src/lib/libcrypto/sha); nothing is checked on the console. Null contexts, null input with a nonzero length, null digest buffers in the 32-bit `Final` functions and a buffered byte count that is not below the block size, which LibreSSL does not check, throw. SHA-384 and SHA-512 initialization retains the block buffer, following [LibreSSL 2.5.4 `sha512.c`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/sha/sha512.c)
- [DES_set_key, DES_ecb_encrypt, DES_set_odd_parity](../../../core/libs/prx/libSceLibreSsl/Export.cpp) (libSceLibreSsl) - the 128-byte `DES_key_schedule` holds the 8-byte key followed by zeros instead of LibreSSL's precomputed subkeys, so a title reading its contents sees different bytes; `DES_ecb_encrypt` derives the subkeys through mbedtls on each call. Not compared with the console. Results follow LibreSSL [des_key.c](https://github.com/libressl/openbsd/blob/bc9483725c5815efb64b6d9acc52fc5fba139212/src/lib/libcrypto/des/des_key.c) and [des.c](https://github.com/libressl/openbsd/blob/bc9483725c5815efb64b6d9acc52fc5fba139212/src/lib/libcrypto/des/des.c): `DES_set_key` skips the parity and weak-key checks and returns 0, as it does while `DES_check_key` is 0 (that variable is not in the PS5 export inventory), a nonzero `enc` encrypts, and `DES_set_odd_parity` sets each byte's low bit for odd parity. Null pointers throw where LibreSSL faults
- [X509_verify_cert_error_string](../../../core/libs/prx/libSceLibreSsl/Export.cpp) - no console call is verified. The 64-bit argument, low-32-bit lookup, messages and shared numeric fallback follow [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/x509/x509_txt.c), the version identified in [published firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214). Console modifications and other firmware versions remain unverified. Unknown-code results share an overwritten static buffer and are not safe for concurrent use, as in that release; code 1 and codes above 54 use the numeric fallback.
@@ -31,7 +31,7 @@
- [EVP_PKEY_type](../../../core/libs/prx/libSceLibreSsl/src/Pkey.cpp) (libSceLibreSsl) - follows the method table of [LibreSSL 2.5.4](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/asn1/ameth_lib.c#L83-L111) `ameth_lib.c` built without GOST and with no engine (every `ENGINE_` export throws): RSA (6) and its alias 19 give 6, the DSA types 66, 67, 70, 113 and 116 give 116, DH (28), EC (408), HMAC (855) and CMAC (894) give themselves, and every other type, the GOST types 811, 815, 946 and 947 included, gives 0. These results match [firmware 13.42's module run natively on a PC](https://github.com/boykopovar/AnyPS5/pull/10398#issuecomment-6406072913) for every type from -1000 to 5000 and the `int` extremes; nothing is checked on the console
- [EVP_CIPHER_CTX_init, EVP_CIPHER_CTX_new, EVP_CIPHER_CTX_set_padding](../../../core/libs/prx/libSceLibreSsl/src/EvpCipherCtx.cpp) (libSceLibreSsl) - nothing is checked on the console. The 168-byte `EVP_CIPHER_CTX` layout and the results follow [LibreSSL 2.5.4](https://github.com/libressl/openbsd/tree/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp) `evp.h` and `evp_enc.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214), which also measured `EVP_CIPHER_CTX_init` clearing 168 bytes. `EVP_CIPHER_CTX_new` allocates through the guest `calloc` as the module would through libc. A null context, which LibreSSL dereferences, throws
- [EVP_CIPHER_block_size](../../../core/libs/prx/libSceLibreSsl/src/EvpCipher.cpp) (libSceLibreSsl) - nothing is checked on the console. The 88-byte `EVP_CIPHER` layout and the result follow [LibreSSL 2.5.4](https://github.com/libressl/openbsd/tree/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/evp) `evp.h` and `evp_lib.c`, the version in the [firmware 13.40 measurements](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214): `block_size` is returned as stored. A null cipher, which LibreSSL dereferences, throws
- [SSL_get_SSL_CTX, SSL_get_rbio, SSL_get_wbio, SSL_version, SSL_get_verify_result, SSL_get_shutdown](../../../core/libs/prx/libSceLibreSsl/src/Ssl.cpp) (libSceLibreSsl) - nothing is checked on the console. Layouts and results follow [LibreSSL 2.5.4](https://github.com/libressl/openbsd/tree/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl) `ssl.h`, `ssl_locl.h` and `ssl_lib.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 connection yet, so only connections the caller builds reach them. A null connection, and for the fields kept in `ssl_internal_st` a null internal state, which LibreSSL dereferences, throw
- [SSL_get_SSL_CTX, SSL_get_rbio, SSL_get_wbio, SSL_version, SSL_get_verify_result, SSL_get_shutdown, SSL_want](../../../core/libs/prx/libSceLibreSsl/src/Ssl.cpp) (libSceLibreSsl) - nothing is checked on the console. Layouts and results follow [LibreSSL 2.5.4](https://github.com/libressl/openbsd/tree/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl) `ssl.h`, `ssl_locl.h` and `ssl_lib.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 connection yet, so only connections the caller builds reach them. A null connection, and for the fields kept in `ssl_internal_st` a null internal state, which LibreSSL dereferences, throw
### Functional