aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Ssl
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2021-04-13 03:04:18 +0200
committerGitHub <noreply@github.com>2021-04-13 03:04:18 +0200
commitb662a26c7e2b66d916986b1ed9ffae3b918619d1 (patch)
tree130908b7c94802ee747560929f43c8403b52d203 /Ryujinx.HLE/HOS/Services/Ssl
parent73881fad1995e079eae3e728cb2f4c657886e476 (diff)
nifm/ssl: Implement GetCurrentNetworkProfile and stub Ssl Service (#2186)
* nifm/ssl: Implement GetCurrentNetworkProfile and stub Ssl Service * remove InterfaceVersion
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Ssl')
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs16
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs113
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs53
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/Types/CertificateFormat.cs8
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/Types/IoMode.cs8
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/Types/OptionType.cs10
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/Types/SessionCacheMode.cs9
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/Types/SslVersion.cs15
-rw-r--r--Ryujinx.HLE/HOS/Services/Ssl/Types/VerifyOption.cs15
9 files changed, 232 insertions, 15 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs b/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs
index 7cc15320..b99e7b56 100644
--- a/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs
+++ b/Ryujinx.HLE/HOS/Services/Ssl/ISslService.cs
@@ -1,24 +1,27 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Ssl.SslService;
+using Ryujinx.HLE.HOS.Services.Ssl.Types;
namespace Ryujinx.HLE.HOS.Services.Ssl
{
[Service("ssl")]
class ISslService : IpcService
{
+ // NOTE: The SSL service is used by games to connect it to various official online services, which we do not intend to support.
+ // In this case it is acceptable to stub all calls of the service.
public ISslService(ServiceCtx context) { }
[Command(0)]
// CreateContext(nn::ssl::sf::SslVersion, u64, pid) -> object<nn::ssl::sf::ISslContext>
public ResultCode CreateContext(ServiceCtx context)
{
- int sslVersion = context.RequestData.ReadInt32();
- long unknown = context.RequestData.ReadInt64();
-
- Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { sslVersion, unknown });
+ SslVersion sslVersion = (SslVersion)context.RequestData.ReadUInt32();
+ ulong pidPlaceholder = context.RequestData.ReadUInt64();
MakeObject(context, new ISslContext(context));
+ Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { sslVersion });
+
return ResultCode.Success;
}
@@ -26,9 +29,10 @@ namespace Ryujinx.HLE.HOS.Services.Ssl
// SetInterfaceVersion(u32)
public ResultCode SetInterfaceVersion(ServiceCtx context)
{
- int version = context.RequestData.ReadInt32();
+ // 1 = 3.0.0+, 2 = 5.0.0+, 3 = 6.0.0+
+ uint interfaceVersion = context.RequestData.ReadUInt32();
- Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { version });
+ Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { interfaceVersion });
return ResultCode.Success;
}
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs b/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs
new file mode 100644
index 00000000..d039154c
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslConnection.cs
@@ -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;
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs b/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs
index b9ca92b0..5341f360 100644
--- a/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs
+++ b/Ryujinx.HLE/HOS/Services/Ssl/SslService/ISslContext.cs
@@ -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(2)]
+ // CreateConnection() -> object<nn::ssl::sf::ISslConnection>
+ public ResultCode CreateConnection(ServiceCtx context)
+ {
+ 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)
{
- int certificateFormat = context.RequestData.ReadInt32();
- long certificateDataPosition = context.Request.SendBuff[0].Position;
- long certificateDataSize = context.Request.SendBuff[0].Size;
- ulong certificateId = 1;
+ CertificateFormat certificateFormat = (CertificateFormat)context.RequestData.ReadUInt32();
- context.ResponseData.Write(certificateId);
+ long certificateDataPosition = context.Request.SendBuff[0].Position;
+ long certificateDataSize = context.Request.SendBuff[0].Size;
- Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { certificateFormat, certificateDataPosition, certificateDataSize });
+ 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;
+ }
}
-}
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/Types/CertificateFormat.cs b/Ryujinx.HLE/HOS/Services/Ssl/Types/CertificateFormat.cs
new file mode 100644
index 00000000..1d80f739
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Ssl/Types/CertificateFormat.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.HLE.HOS.Services.Ssl.Types
+{
+ enum CertificateFormat : uint
+ {
+ Pem = 1,
+ Der = 2
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/Types/IoMode.cs b/Ryujinx.HLE/HOS/Services/Ssl/Types/IoMode.cs
new file mode 100644
index 00000000..1cd06d6d
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Ssl/Types/IoMode.cs
@@ -0,0 +1,8 @@
+namespace Ryujinx.HLE.HOS.Services.Ssl.Types
+{
+ enum IoMode : uint
+ {
+ Blocking = 1,
+ NonBlocking = 2
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/Types/OptionType.cs b/Ryujinx.HLE/HOS/Services/Ssl/Types/OptionType.cs
new file mode 100644
index 00000000..3673200a
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Ssl/Types/OptionType.cs
@@ -0,0 +1,10 @@
+namespace Ryujinx.HLE.HOS.Services.Ssl.Types
+{
+ enum OptionType : uint
+ {
+ DoNotCloseSocket,
+ GetServerCertChain, // 3.0.0+
+ SkipDefaultVerify, // 5.0.0+
+ EnableAlpn // 9.0.0+
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/Types/SessionCacheMode.cs b/Ryujinx.HLE/HOS/Services/Ssl/Types/SessionCacheMode.cs
new file mode 100644
index 00000000..cec7b745
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Ssl/Types/SessionCacheMode.cs
@@ -0,0 +1,9 @@
+namespace Ryujinx.HLE.HOS.Services.Ssl.Types
+{
+ enum SessionCacheMode : uint
+ {
+ None,
+ SessionId,
+ SessionTicket
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/Types/SslVersion.cs b/Ryujinx.HLE/HOS/Services/Ssl/Types/SslVersion.cs
new file mode 100644
index 00000000..a8897802
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Ssl/Types/SslVersion.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace Ryujinx.HLE.HOS.Services.Ssl.Types
+{
+ [Flags]
+ enum SslVersion : uint
+ {
+ Auto = 1 << 0,
+ TlsV10 = 1 << 3,
+ TlsV11 = 1 << 4,
+ TlsV12 = 1 << 5,
+ TlsV13 = 1 << 6, // 11.0.0+
+ Auto2 = 1 << 24 // 11.0.0+
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Ssl/Types/VerifyOption.cs b/Ryujinx.HLE/HOS/Services/Ssl/Types/VerifyOption.cs
new file mode 100644
index 00000000..d25bb6c3
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Ssl/Types/VerifyOption.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace Ryujinx.HLE.HOS.Services.Ssl.Types
+{
+ [Flags]
+ enum VerifyOption : uint
+ {
+ PeerCa = 1 << 0,
+ HostName = 1 << 1,
+ DateCheck = 1 << 2,
+ EvCertPartial = 1 << 3,
+ EvPolicyOid = 1 << 4, // 6.0.0+
+ EvCertFingerprint = 1 << 5 // 6.0.0+
+ }
+} \ No newline at end of file