diff options
author | Liam <byteslice@airmail.cc> | 2023-07-17 00:55:27 +0200 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-08-08 17:09:37 +0200 |
commit | 83eee1d2266a1de374be0a8b2c0f2827f5e25bcf (patch) | |
tree | 7dfbdfb32b6671a79f433c3cb59acc7ba0e5cc9c /src/core/hle/service/ssl/ssl_backend_securetransport.cpp | |
parent | core: remove ResultVal type (diff) | |
download | yuzu-83eee1d2266a1de374be0a8b2c0f2827f5e25bcf.tar yuzu-83eee1d2266a1de374be0a8b2c0f2827f5e25bcf.tar.gz yuzu-83eee1d2266a1de374be0a8b2c0f2827f5e25bcf.tar.bz2 yuzu-83eee1d2266a1de374be0a8b2c0f2827f5e25bcf.tar.lz yuzu-83eee1d2266a1de374be0a8b2c0f2827f5e25bcf.tar.xz yuzu-83eee1d2266a1de374be0a8b2c0f2827f5e25bcf.tar.zst yuzu-83eee1d2266a1de374be0a8b2c0f2827f5e25bcf.zip |
Diffstat (limited to 'src/core/hle/service/ssl/ssl_backend_securetransport.cpp')
-rw-r--r-- | src/core/hle/service/ssl/ssl_backend_securetransport.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/core/hle/service/ssl/ssl_backend_securetransport.cpp b/src/core/hle/service/ssl/ssl_backend_securetransport.cpp index b3083cbad..5f9e6bef7 100644 --- a/src/core/hle/service/ssl/ssl_backend_securetransport.cpp +++ b/src/core/hle/service/ssl/ssl_backend_securetransport.cpp @@ -103,24 +103,20 @@ public: return HandleReturn("SSLHandshake", 0, status).Code(); } - ResultVal<size_t> Read(std::span<u8> data) override { - size_t actual; - OSStatus status = SSLRead(context, data.data(), data.size(), &actual); - ; - return HandleReturn("SSLRead", actual, status); + Result Read(size_t* out_size, std::span<u8> data) override { + OSStatus status = SSLRead(context, data.data(), data.size(), &out_size); + return HandleReturn("SSLRead", out_size, status); } - ResultVal<size_t> Write(std::span<const u8> data) override { - size_t actual; - OSStatus status = SSLWrite(context, data.data(), data.size(), &actual); - ; - return HandleReturn("SSLWrite", actual, status); + Result Write(size_t* out_size, std::span<const u8> data) override { + OSStatus status = SSLWrite(context, data.data(), data.size(), &out_size); + return HandleReturn("SSLWrite", out_size, status); } - ResultVal<size_t> HandleReturn(const char* what, size_t actual, OSStatus status) { + Result HandleReturn(const char* what, size_t* actual, OSStatus status) { switch (status) { case 0: - return actual; + return ResultSuccess; case errSSLWouldBlock: return ResultWouldBlock; default: { @@ -136,22 +132,21 @@ public: } } - ResultVal<std::vector<std::vector<u8>>> GetServerCerts() override { + Result GetServerCerts(std::vector<std::vector<u8>>* out_certs) override { CFReleaser<SecTrustRef> trust; OSStatus status = SSLCopyPeerTrust(context, &trust.ptr); if (status) { LOG_ERROR(Service_SSL, "SSLCopyPeerTrust failed: {}", OSStatusToString(status)); return ResultInternalError; } - std::vector<std::vector<u8>> ret; for (CFIndex i = 0, count = SecTrustGetCertificateCount(trust); i < count; i++) { SecCertificateRef cert = SecTrustGetCertificateAtIndex(trust, i); CFReleaser<CFDataRef> data(SecCertificateCopyData(cert)); ASSERT_OR_EXECUTE(data, { return ResultInternalError; }); const u8* ptr = CFDataGetBytePtr(data); - ret.emplace_back(ptr, ptr + CFDataGetLength(data)); + out_certs->emplace_back(ptr, ptr + CFDataGetLength(data)); } - return ret; + return ResultSuccess; } static OSStatus ReadCallback(SSLConnectionRef connection, void* data, size_t* dataLength) { @@ -210,13 +205,13 @@ private: std::shared_ptr<Network::SocketBase> socket; }; -ResultVal<std::unique_ptr<SSLConnectionBackend>> CreateSSLConnectionBackend() { +Result CreateSSLConnectionBackend(std::unique_ptr<SSLConnectionBackend>* out_backend) { auto conn = std::make_unique<SSLConnectionBackendSecureTransport>(); - const Result res = conn->Init(); - if (res.IsFailure()) { - return res; - } - return conn; + + R_TRY(conn->Init()); + + *out_backend = std::move(conn); + return ResultSuccess; } } // namespace Service::SSL |