2018-03-22 23:32:50 -07:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-04-10 11:40:53 -07:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
2018-09-02 08:36:43 -07:00
|
|
|
#include "core/hle/kernel/hle_ipc.h"
|
|
|
|
#include "core/hle/service/service.h"
|
|
|
|
#include "core/hle/service/sm/sm.h"
|
2018-03-22 23:32:50 -07:00
|
|
|
#include "core/hle/service/ssl/ssl.h"
|
|
|
|
|
2018-04-19 18:41:44 -07:00
|
|
|
namespace Service::SSL {
|
2018-03-22 23:32:50 -07:00
|
|
|
|
2018-04-10 11:40:53 -07:00
|
|
|
class ISslConnection final : public ServiceFramework<ISslConnection> {
|
|
|
|
public:
|
|
|
|
ISslConnection() : ServiceFramework("ISslConnection") {
|
2019-11-12 05:54:58 -08:00
|
|
|
// clang-format off
|
2018-04-10 11:40:53 -07:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "SetSocketDescriptor"},
|
|
|
|
{1, nullptr, "SetHostName"},
|
|
|
|
{2, nullptr, "SetVerifyOption"},
|
|
|
|
{3, nullptr, "SetIoMode"},
|
|
|
|
{4, nullptr, "GetSocketDescriptor"},
|
|
|
|
{5, nullptr, "GetHostName"},
|
|
|
|
{6, nullptr, "GetVerifyOption"},
|
|
|
|
{7, nullptr, "GetIoMode"},
|
|
|
|
{8, nullptr, "DoHandshake"},
|
|
|
|
{9, nullptr, "DoHandshakeGetServerCert"},
|
|
|
|
{10, nullptr, "Read"},
|
|
|
|
{11, nullptr, "Write"},
|
|
|
|
{12, nullptr, "Pending"},
|
|
|
|
{13, nullptr, "Peek"},
|
|
|
|
{14, nullptr, "Poll"},
|
|
|
|
{15, nullptr, "GetVerifyCertError"},
|
|
|
|
{16, nullptr, "GetNeededServerCertBufferSize"},
|
|
|
|
{17, nullptr, "SetSessionCacheMode"},
|
|
|
|
{18, nullptr, "GetSessionCacheMode"},
|
|
|
|
{19, nullptr, "FlushSessionCache"},
|
|
|
|
{20, nullptr, "SetRenegotiationMode"},
|
|
|
|
{21, nullptr, "GetRenegotiationMode"},
|
|
|
|
{22, nullptr, "SetOption"},
|
|
|
|
{23, nullptr, "GetOption"},
|
|
|
|
{24, nullptr, "GetVerifyCertErrors"},
|
|
|
|
{25, nullptr, "GetCipherInfo"},
|
2019-11-12 05:54:58 -08:00
|
|
|
{26, nullptr, "SetNextAlpnProto"},
|
|
|
|
{27, nullptr, "GetNextAlpnProto"},
|
2018-04-10 11:40:53 -07:00
|
|
|
};
|
2019-11-12 05:54:58 -08:00
|
|
|
// clang-format on
|
|
|
|
|
2018-04-10 11:40:53 -07:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ISslContext final : public ServiceFramework<ISslContext> {
|
|
|
|
public:
|
|
|
|
ISslContext() : ServiceFramework("ISslContext") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ISslContext::SetOption, "SetOption"},
|
|
|
|
{1, nullptr, "GetOption"},
|
|
|
|
{2, &ISslContext::CreateConnection, "CreateConnection"},
|
|
|
|
{3, nullptr, "GetConnectionCount"},
|
|
|
|
{4, nullptr, "ImportServerPki"},
|
|
|
|
{5, nullptr, "ImportClientPki"},
|
|
|
|
{6, nullptr, "RemoveServerPki"},
|
|
|
|
{7, nullptr, "RemoveClientPki"},
|
|
|
|
{8, nullptr, "RegisterInternalPki"},
|
|
|
|
{9, nullptr, "AddPolicyOid"},
|
|
|
|
{10, nullptr, "ImportCrl"},
|
|
|
|
{11, nullptr, "RemoveCrl"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void SetOption(Kernel::HLERequestContext& ctx) {
|
2019-04-04 09:56:04 -07:00
|
|
|
struct Parameters {
|
|
|
|
u8 enable;
|
|
|
|
u32 option;
|
|
|
|
};
|
2018-11-25 22:06:13 -08:00
|
|
|
|
2018-04-10 11:40:53 -07:00
|
|
|
IPC::RequestParser rp{ctx};
|
2019-04-04 09:56:04 -07:00
|
|
|
const auto parameters = rp.PopRaw<Parameters>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service_SSL, "(STUBBED) called. enable={}, option={}", parameters.enable,
|
|
|
|
parameters.option);
|
2018-04-10 11:40:53 -07:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-04-10 11:40:53 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateConnection(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_SSL, "(STUBBED) called");
|
2018-04-10 11:40:53 -07:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<ISslConnection>();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-09-02 08:36:43 -07:00
|
|
|
class SSL final : public ServiceFramework<SSL> {
|
|
|
|
public:
|
|
|
|
explicit SSL() : ServiceFramework{"ssl"} {
|
|
|
|
// clang-format off
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &SSL::CreateContext, "CreateContext"},
|
|
|
|
{1, nullptr, "GetContextCount"},
|
|
|
|
{2, nullptr, "GetCertificates"},
|
|
|
|
{3, nullptr, "GetCertificateBufSize"},
|
|
|
|
{4, nullptr, "DebugIoctl"},
|
|
|
|
{5, &SSL::SetInterfaceVersion, "SetInterfaceVersion"},
|
|
|
|
{6, nullptr, "FlushSessionCache"},
|
2019-04-10 11:48:37 -07:00
|
|
|
{7, nullptr, "SetDebugOption"},
|
|
|
|
{8, nullptr, "GetDebugOption"},
|
2018-09-02 08:36:43 -07:00
|
|
|
};
|
|
|
|
// clang-format on
|
2018-04-10 11:40:53 -07:00
|
|
|
|
2018-09-02 08:36:43 -07:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
2018-04-10 11:40:53 -07:00
|
|
|
|
2018-09-02 08:36:43 -07:00
|
|
|
private:
|
2018-09-18 23:46:11 -07:00
|
|
|
u32 ssl_version{};
|
2018-09-02 08:36:43 -07:00
|
|
|
void CreateContext(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_SSL, "(STUBBED) called");
|
2018-03-22 23:32:50 -07:00
|
|
|
|
2018-09-02 08:36:43 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<ISslContext>();
|
|
|
|
}
|
2018-04-21 22:04:24 -07:00
|
|
|
|
2018-09-02 08:36:43 -07:00
|
|
|
void SetInterfaceVersion(Kernel::HLERequestContext& ctx) {
|
2018-09-18 23:46:11 -07:00
|
|
|
LOG_DEBUG(Service_SSL, "called");
|
2018-11-25 22:06:13 -08:00
|
|
|
|
2018-09-02 08:36:43 -07:00
|
|
|
IPC::RequestParser rp{ctx};
|
2018-09-18 23:46:11 -07:00
|
|
|
ssl_version = rp.Pop<u32>();
|
2018-09-02 08:36:43 -07:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
};
|
2018-04-21 22:04:24 -07:00
|
|
|
|
2018-03-22 23:32:50 -07:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
|
|
|
std::make_shared<SSL>()->InstallAsService(service_manager);
|
|
|
|
}
|
|
|
|
|
2018-04-19 18:41:44 -07:00
|
|
|
} // namespace Service::SSL
|