ssl.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/service/ssl/ssl.h"
  6. namespace Service {
  7. namespace SSL {
  8. class ISslConnection final : public ServiceFramework<ISslConnection> {
  9. public:
  10. ISslConnection() : ServiceFramework("ISslConnection") {
  11. static const FunctionInfo functions[] = {
  12. {0, nullptr, "SetSocketDescriptor"},
  13. {1, nullptr, "SetHostName"},
  14. {2, nullptr, "SetVerifyOption"},
  15. {3, nullptr, "SetIoMode"},
  16. {4, nullptr, "GetSocketDescriptor"},
  17. {5, nullptr, "GetHostName"},
  18. {6, nullptr, "GetVerifyOption"},
  19. {7, nullptr, "GetIoMode"},
  20. {8, nullptr, "DoHandshake"},
  21. {9, nullptr, "DoHandshakeGetServerCert"},
  22. {10, nullptr, "Read"},
  23. {11, nullptr, "Write"},
  24. {12, nullptr, "Pending"},
  25. {13, nullptr, "Peek"},
  26. {14, nullptr, "Poll"},
  27. {15, nullptr, "GetVerifyCertError"},
  28. {16, nullptr, "GetNeededServerCertBufferSize"},
  29. {17, nullptr, "SetSessionCacheMode"},
  30. {18, nullptr, "GetSessionCacheMode"},
  31. {19, nullptr, "FlushSessionCache"},
  32. {20, nullptr, "SetRenegotiationMode"},
  33. {21, nullptr, "GetRenegotiationMode"},
  34. {22, nullptr, "SetOption"},
  35. {23, nullptr, "GetOption"},
  36. {24, nullptr, "GetVerifyCertErrors"},
  37. {25, nullptr, "GetCipherInfo"},
  38. };
  39. RegisterHandlers(functions);
  40. }
  41. };
  42. class ISslContext final : public ServiceFramework<ISslContext> {
  43. public:
  44. ISslContext() : ServiceFramework("ISslContext") {
  45. static const FunctionInfo functions[] = {
  46. {0, &ISslContext::SetOption, "SetOption"},
  47. {1, nullptr, "GetOption"},
  48. {2, &ISslContext::CreateConnection, "CreateConnection"},
  49. {3, nullptr, "GetConnectionCount"},
  50. {4, nullptr, "ImportServerPki"},
  51. {5, nullptr, "ImportClientPki"},
  52. {6, nullptr, "RemoveServerPki"},
  53. {7, nullptr, "RemoveClientPki"},
  54. {8, nullptr, "RegisterInternalPki"},
  55. {9, nullptr, "AddPolicyOid"},
  56. {10, nullptr, "ImportCrl"},
  57. {11, nullptr, "RemoveCrl"},
  58. };
  59. RegisterHandlers(functions);
  60. }
  61. ~ISslContext() = default;
  62. private:
  63. void SetOption(Kernel::HLERequestContext& ctx) {
  64. LOG_WARNING(Service_SSL, "(STUBBED) called");
  65. IPC::RequestParser rp{ctx};
  66. IPC::ResponseBuilder rb = rp.MakeBuilder(2, 0, 0);
  67. rb.Push(RESULT_SUCCESS);
  68. }
  69. void CreateConnection(Kernel::HLERequestContext& ctx) {
  70. LOG_WARNING(Service_SSL, "(STUBBED) called");
  71. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  72. rb.Push(RESULT_SUCCESS);
  73. rb.PushIpcInterface<ISslConnection>();
  74. }
  75. };
  76. void SSL::CreateContext(Kernel::HLERequestContext& ctx) {
  77. LOG_WARNING(Service_SSL, "(STUBBED) called");
  78. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  79. rb.Push(RESULT_SUCCESS);
  80. rb.PushIpcInterface<ISslContext>();
  81. }
  82. SSL::SSL() : ServiceFramework("ssl") {
  83. static const FunctionInfo functions[] = {
  84. {0, &SSL::CreateContext, "CreateContext"},
  85. {1, nullptr, "GetContextCount"},
  86. {2, nullptr, "GetCertificates"},
  87. {3, nullptr, "GetCertificateBufSize"},
  88. {4, nullptr, "DebugIoctl"},
  89. {5, nullptr, "SetInterfaceVersion"},
  90. {6, nullptr, "FlushSessionCache"},
  91. };
  92. RegisterHandlers(functions);
  93. }
  94. void InstallInterfaces(SM::ServiceManager& service_manager) {
  95. std::make_shared<SSL>()->InstallAsService(service_manager);
  96. }
  97. } // namespace SSL
  98. } // namespace Service