Files
AnyPS5/core/libs/tests/GuestLibreSslPkeyLifecycle.cpp
T
Dean Galvin e3877cf746 test(libressl): drop the unimplemented-path throw pin from the EVP_PKEY lifecycle test
The block held a key with algorithm data and required EVP_PKEY_free to throw; the free path with key data is not implemented, so the test no longer pins it. The reference counting, null and release checks stay.
2026-11-05 21:50:53 +00:00

35 lines
1.1 KiB
C++

#include "prx/libSceLibreSsl/include/Api.hpp"
#include "prx/libc/include/ApplicationHeap.hpp"
#include "prx/libc/include/general/VabiMacros.hpp"
#include <cstddef>
#include <cstdio>
#include <cstring>
#include <exception>
namespace {
void Require(bool condition, const char* message) {
if (condition) return;
std::fprintf(stderr, "failed: %s\n", message);
std::terminate();
}
}
int main() {
void* const api[10]{};
ApplicationHeapRegister_nid_no_patch(api);
void* pkey = EVP_PKEY_new_nid_postfix();
Require(pkey != nullptr, "allocates a key");
int fields[3];
std::memcpy(fields, pkey, sizeof(fields));
Require(fields[0] == 0 && fields[1] == 0, "a new key has type and save_type EVP_PKEY_NONE");
Require(fields[2] == 1, "a new key holds one reference");
const int extra = 2;
std::memcpy(static_cast<std::byte*>(pkey) + 8, &extra, sizeof(extra));
EVP_PKEY_free_nid_postfix(pkey);
std::memcpy(fields, pkey, sizeof(fields));
Require(fields[2] == 1, "freeing a shared key only drops one reference");
EVP_PKEY_free_nid_postfix(pkey);
EVP_PKEY_free_nid_postfix(nullptr);
return 0;
}