Repository navigation
Expand file tree
/
Copy pathExport.cpp
More file actions
125 lines (102 loc) · 2.92 KB
/
Copy pathExport.cpp
File metadata and controls
125 lines (102 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <cstdint>
#include <cstddef>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
#include <atomic>
#include <map>
#include <mutex>
#include <stdexcept>
// No network is emulated: contexts, templates and requests can be created, but any request
// that would touch the network fails with the library's network error.
static constexpr int ERROR_NETWORK = static_cast<int>(0x80435001);
static std::atomic<int> g_nextHandle{1};
static std::mutex g_poolsMutex;
static std::map<int, uint64_t> g_pools;
namespace {
constexpr int ERROR_NOT_FOUND = static_cast<int>(0x8095F004);
constexpr int ERROR_INVALID_ARG = static_cast<int>(0x8095177A);
struct SslData {
char* ptr;
size_t size;
};
struct SslMemoryPoolStats {
size_t pool_size;
size_t max_inuse_size;
size_t current_inuse_size;
int32_t reserved;
};
struct SslCaCerts {
SslData* certs;
size_t num;
void* pool;
};
}
extern "C" {
int APS5_VABI sceSslFreeCaCerts(int ssl_ctx_id, void* ca_certs) {
(void)ssl_ctx_id;
if (!ca_certs) return ERROR_INVALID_ARG;
*static_cast<SslCaCerts*>(ca_certs) = {};
return 0;
}
int APS5_VABI sceSslGetCaCerts(int ssl_ctx_id, void* ca_certs) {
(void)ssl_ctx_id;
if (!ca_certs) return ERROR_INVALID_ARG;
*static_cast<SslCaCerts*>(ca_certs) = {};
return ERROR_NOT_FOUND;
}
int APS5_VABI sceSslInit_nid_postfix(uint64_t pool_size) {
const int id = g_nextHandle.fetch_add(1, std::memory_order_relaxed);
std::lock_guard lock(g_poolsMutex);
g_pools[id] = pool_size;
return id;
}
int APS5_VABI sceSslTerm_nid_postfix(int ssl_ctx_id) {
std::lock_guard lock(g_poolsMutex);
g_pools.erase(ssl_ctx_id);
return 0;
}
int APS5_VABI sceSslClose() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceSslGetSerialNumber() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceSslLoadCert() {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceSslGetMemoryPoolStats(int ssl_ctx_id, SslMemoryPoolStats* stats) {
if (stats == nullptr) APS5_INVALID_ARG_EX;
std::lock_guard lock(g_poolsMutex);
const auto pool = g_pools.find(ssl_ctx_id);
if (pool == g_pools.end()) throw std::invalid_argument("sceSslGetMemoryPoolStats: unknown context");
*stats = {static_cast<size_t>(pool->second), 0, 0, 0};
return 0;
}
int APS5_VABI sceSslFreeSslCertName(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceSslGetIssuerName(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceSslGetNameEntryCount(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceSslGetNameEntryInfo(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceSslGetPem(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceSslGetSubjectName(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
}