blob: b38ff92149f2026344bdc9ec1744e846375fc070 (
plain) (
blame)
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
|
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Ssl.Types;
using System.Text;
namespace Ryujinx.HLE.HOS.Services.Ssl.SslService
{
class ISslContext : IpcService
{
private uint _connectionCount;
private readonly ulong _processId;
private readonly SslVersion _sslVersion;
private ulong _serverCertificateId;
private ulong _clientCertificateId;
public ISslContext(ulong processId, SslVersion sslVersion)
{
_processId = processId;
_sslVersion = sslVersion;
}
[CommandCmif(2)]
// CreateConnection() -> object<nn::ssl::sf::ISslConnection>
public ResultCode CreateConnection(ServiceCtx context)
{
MakeObject(context, new ISslConnection(_processId, _sslVersion));
_connectionCount++;
return ResultCode.Success;
}
[CommandCmif(3)]
// GetConnectionCount() -> u32 count
public ResultCode GetConnectionCount(ServiceCtx context)
{
context.ResponseData.Write(_connectionCount);
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { _connectionCount });
return ResultCode.Success;
}
[CommandCmif(4)]
// ImportServerPki(nn::ssl::sf::CertificateFormat certificateFormat, buffer<bytes, 5> certificate) -> u64 certificateId
public ResultCode ImportServerPki(ServiceCtx context)
{
CertificateFormat certificateFormat = (CertificateFormat)context.RequestData.ReadUInt32();
ulong certificateDataPosition = context.Request.SendBuff[0].Position;
ulong certificateDataSize = context.Request.SendBuff[0].Size;
context.ResponseData.Write(_serverCertificateId++);
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { certificateFormat });
return ResultCode.Success;
}
[CommandCmif(5)]
// ImportClientPki(buffer<bytes, 5> certificate, buffer<bytes, 5> ascii_password) -> u64 certificateId
public ResultCode ImportClientPki(ServiceCtx context)
{
ulong certificateDataPosition = context.Request.SendBuff[0].Position;
ulong certificateDataSize = context.Request.SendBuff[0].Size;
ulong asciiPasswordDataPosition = context.Request.SendBuff[1].Position;
ulong asciiPasswordDataSize = context.Request.SendBuff[1].Size;
byte[] asciiPasswordData = new byte[asciiPasswordDataSize];
context.Memory.Read(asciiPasswordDataPosition, asciiPasswordData);
string asciiPassword = Encoding.ASCII.GetString(asciiPasswordData).Trim('\0');
context.ResponseData.Write(_clientCertificateId++);
Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { asciiPassword });
return ResultCode.Success;
}
}
}
|