nifm/ssl: Implement GetCurrentNetworkProfile and stub Ssl Service (#2186)

* nifm/ssl: Implement GetCurrentNetworkProfile and stub Ssl Service

* remove InterfaceVersion
This commit is contained in:
Ac_K 2021-04-13 03:04:18 +02:00 committed by GitHub
parent 73881fad19
commit b662a26c7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 375 additions and 56 deletions

View file

@ -0,0 +1,113 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Ssl.Types;
using System.Text;
namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
{
class ISslConnection : IpcService
{
public ISslConnection() { }
[Command(0)]
// SetSocketDescriptor(u32) -> u32
public ResultCode SetSocketDescriptor(ServiceCtx context)
{
uint socketFd = context.RequestData.ReadUInt32();
uint duplicateSocketFd = 0;
context.ResponseData.Write(duplicateSocketFd);
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { socketFd });
return ResultCode.Success;
}
[Command(1)]
// SetHostName(buffer<bytes, 5>)
public ResultCode SetHostName(ServiceCtx context)
{
long hostNameDataPosition = context.Request.SendBuff[0].Position;
long hostNameDataSize = context.Request.SendBuff[0].Size;
byte[] hostNameData = new byte[hostNameDataSize];
context.Memory.Read((ulong)hostNameDataPosition, hostNameData);
string hostName = Encoding.ASCII.GetString(hostNameData).Trim('\0');
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { hostName });
return ResultCode.Success;
}
[Command(2)]
// SetVerifyOption(nn::ssl::sf::VerifyOption)
public ResultCode SetVerifyOption(ServiceCtx context)
{
VerifyOption verifyOption = (VerifyOption)context.RequestData.ReadUInt32();
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { verifyOption });
return ResultCode.Success;
}
[Command(3)]
// SetIoMode(nn::ssl::sf::IoMode)
public ResultCode SetIoMode(ServiceCtx context)
{
IoMode ioMode = (IoMode)context.RequestData.ReadUInt32();
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { ioMode });
return ResultCode.Success;
}
[Command(8)]
// DoHandshake()
public ResultCode DoHandshake(ServiceCtx context)
{
Logger.Stub?.PrintStub(LogClass.ServiceSsl);
return ResultCode.Success;
}
[Command(11)]
// Write(buffer<bytes, 5>) -> u32
public ResultCode Write(ServiceCtx context)
{
long inputDataPosition = context.Request.SendBuff[0].Position;
long inputDataSize = context.Request.SendBuff[0].Size;
uint transferredSize = 0;
context.ResponseData.Write(transferredSize);
Logger.Stub?.PrintStub(LogClass.ServiceSsl);
return ResultCode.Success;
}
[Command(17)]
// SetSessionCacheMode(nn::ssl::sf::SessionCacheMode)
public ResultCode SetSessionCacheMode(ServiceCtx context)
{
SessionCacheMode sessionCacheMode = (SessionCacheMode)context.RequestData.ReadUInt32();
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { sessionCacheMode });
return ResultCode.Success;
}
[Command(22)]
// SetOption(b8, nn::ssl::sf::OptionType)
public ResultCode SetOption(ServiceCtx context)
{
bool optionEnabled = context.RequestData.ReadBoolean();
OptionType optionType = (OptionType)context.RequestData.ReadUInt32();
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { optionType, optionEnabled });
return ResultCode.Success;
}
}
}

View file

@ -1,27 +1,62 @@
using Ryujinx.Common.Logging;
using System;
using Ryujinx.HLE.HOS.Services.Ssl.Types;
using System.Text;
namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
{
class ISslContext : IpcService
{
private ulong _serverCertificateId;
private ulong _clientCertificateId;
public ISslContext(ServiceCtx context) { }
[Command(4)]
// ImportServerPki(nn::ssl::sf::CertificateFormat certificateFormat, buffer<bytes, 5> certificate) -> u64 certificateId
public ResultCode ImportServerPki(ServiceCtx context)
[Command(2)]
// CreateConnection() -> object<nn::ssl::sf::ISslConnection>
public ResultCode CreateConnection(ServiceCtx context)
{
int certificateFormat = context.RequestData.ReadInt32();
long certificateDataPosition = context.Request.SendBuff[0].Position;
long certificateDataSize = context.Request.SendBuff[0].Size;
ulong certificateId = 1;
context.ResponseData.Write(certificateId);
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { certificateFormat, certificateDataPosition, certificateDataSize });
MakeObject(context, new ISslConnection());
return ResultCode.Success;
}
[Command(4)]
// ImportServerPki(nn::ssl::sf::CertificateFormat certificateFormat, buffer<bytes, 5> certificate) -> u64 certificateId
public ResultCode ImportServerPki(ServiceCtx context)
{
CertificateFormat certificateFormat = (CertificateFormat)context.RequestData.ReadUInt32();
long certificateDataPosition = context.Request.SendBuff[0].Position;
long certificateDataSize = context.Request.SendBuff[0].Size;
context.ResponseData.Write(_serverCertificateId++);
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { certificateFormat });
return ResultCode.Success;
}
[Command(5)]
// ImportClientPki(buffer<bytes, 5> certificate, buffer<bytes, 5> ascii_password) -> u64 certificateId
public ResultCode ImportClientPki(ServiceCtx context)
{
long certificateDataPosition = context.Request.SendBuff[0].Position;
long certificateDataSize = context.Request.SendBuff[0].Size;
long asciiPasswordDataPosition = context.Request.SendBuff[1].Position;
long asciiPasswordDataSize = context.Request.SendBuff[1].Size;
byte[] asciiPasswordData = new byte[asciiPasswordDataSize];
context.Memory.Read((ulong)asciiPasswordDataPosition, asciiPasswordData);
string asciiPassword = Encoding.ASCII.GetString(asciiPasswordData).Trim('\0');
context.ResponseData.Write(_clientCertificateId++);
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { asciiPassword });
return ResultCode.Success;
}
}
}
}