ssl.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/hle/ipc_helpers.h"
  5. #include "core/hle/kernel/hle_ipc.h"
  6. #include "core/hle/service/service.h"
  7. #include "core/hle/service/sm/sm.h"
  8. #include "core/hle/service/ssl/ssl.h"
  9. namespace Service::SSL {
  10. class ISslConnection final : public ServiceFramework<ISslConnection> {
  11. public:
  12. ISslConnection() : ServiceFramework("ISslConnection") {
  13. static const FunctionInfo functions[] = {
  14. {0, nullptr, "SetSocketDescriptor"},
  15. {1, nullptr, "SetHostName"},
  16. {2, nullptr, "SetVerifyOption"},
  17. {3, nullptr, "SetIoMode"},
  18. {4, nullptr, "GetSocketDescriptor"},
  19. {5, nullptr, "GetHostName"},
  20. {6, nullptr, "GetVerifyOption"},
  21. {7, nullptr, "GetIoMode"},
  22. {8, nullptr, "DoHandshake"},
  23. {9, nullptr, "DoHandshakeGetServerCert"},
  24. {10, nullptr, "Read"},
  25. {11, nullptr, "Write"},
  26. {12, nullptr, "Pending"},
  27. {13, nullptr, "Peek"},
  28. {14, nullptr, "Poll"},
  29. {15, nullptr, "GetVerifyCertError"},
  30. {16, nullptr, "GetNeededServerCertBufferSize"},
  31. {17, nullptr, "SetSessionCacheMode"},
  32. {18, nullptr, "GetSessionCacheMode"},
  33. {19, nullptr, "FlushSessionCache"},
  34. {20, nullptr, "SetRenegotiationMode"},
  35. {21, nullptr, "GetRenegotiationMode"},
  36. {22, nullptr, "SetOption"},
  37. {23, nullptr, "GetOption"},
  38. {24, nullptr, "GetVerifyCertErrors"},
  39. {25, nullptr, "GetCipherInfo"},
  40. };
  41. RegisterHandlers(functions);
  42. }
  43. };
  44. class ISslContext final : public ServiceFramework<ISslContext> {
  45. public:
  46. ISslContext() : ServiceFramework("ISslContext") {
  47. static const FunctionInfo functions[] = {
  48. {0, &ISslContext::SetOption, "SetOption"},
  49. {1, nullptr, "GetOption"},
  50. {2, &ISslContext::CreateConnection, "CreateConnection"},
  51. {3, nullptr, "GetConnectionCount"},
  52. {4, nullptr, "ImportServerPki"},
  53. {5, nullptr, "ImportClientPki"},
  54. {6, nullptr, "RemoveServerPki"},
  55. {7, nullptr, "RemoveClientPki"},
  56. {8, nullptr, "RegisterInternalPki"},
  57. {9, nullptr, "AddPolicyOid"},
  58. {10, nullptr, "ImportCrl"},
  59. {11, nullptr, "RemoveCrl"},
  60. };
  61. RegisterHandlers(functions);
  62. }
  63. ~ISslContext() = default;
  64. private:
  65. void SetOption(Kernel::HLERequestContext& ctx) {
  66. LOG_WARNING(Service_SSL, "(STUBBED) called");
  67. IPC::RequestParser rp{ctx};
  68. IPC::ResponseBuilder rb{ctx, 2};
  69. rb.Push(RESULT_SUCCESS);
  70. }
  71. void CreateConnection(Kernel::HLERequestContext& ctx) {
  72. LOG_WARNING(Service_SSL, "(STUBBED) called");
  73. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  74. rb.Push(RESULT_SUCCESS);
  75. rb.PushIpcInterface<ISslConnection>();
  76. }
  77. };
  78. class SSL final : public ServiceFramework<SSL> {
  79. public:
  80. explicit SSL() : ServiceFramework{"ssl"} {
  81. // clang-format off
  82. static const FunctionInfo functions[] = {
  83. {0, &SSL::CreateContext, "CreateContext"},
  84. {1, nullptr, "GetContextCount"},
  85. {2, nullptr, "GetCertificates"},
  86. {3, nullptr, "GetCertificateBufSize"},
  87. {4, nullptr, "DebugIoctl"},
  88. {5, &SSL::SetInterfaceVersion, "SetInterfaceVersion"},
  89. {6, nullptr, "FlushSessionCache"},
  90. };
  91. // clang-format on
  92. RegisterHandlers(functions);
  93. }
  94. private:
  95. u32 ssl_version{};
  96. void CreateContext(Kernel::HLERequestContext& ctx) {
  97. LOG_WARNING(Service_SSL, "(STUBBED) called");
  98. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  99. rb.Push(RESULT_SUCCESS);
  100. rb.PushIpcInterface<ISslContext>();
  101. }
  102. void SetInterfaceVersion(Kernel::HLERequestContext& ctx) {
  103. LOG_DEBUG(Service_SSL, "called");
  104. IPC::RequestParser rp{ctx};
  105. ssl_version = rp.Pop<u32>();
  106. IPC::ResponseBuilder rb{ctx, 2};
  107. rb.Push(RESULT_SUCCESS);
  108. }
  109. };
  110. void InstallInterfaces(SM::ServiceManager& service_manager) {
  111. std::make_shared<SSL>()->InstallAsService(service_manager);
  112. }
  113. } // namespace Service::SSL