forked from love2d/lua-https
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSChannelConnection.h
More file actions
37 lines (27 loc) · 844 Bytes
/
SChannelConnection.h
File metadata and controls
37 lines (27 loc) · 844 Bytes
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
#pragma once
#include "../common/config.h"
#ifdef HTTPS_BACKEND_SCHANNEL
#include "../common/Connection.h"
#include "../common/PlaintextConnection.h"
#include <vector>
struct _SecHandle;
using CtxtHandle = _SecHandle;
class SChannelConnection : public Connection
{
public:
SChannelConnection();
virtual bool connect(const std::string &hostname, uint16_t port) override;
virtual size_t read(char *buffer, size_t size) override;
virtual size_t write(const char *buffer, size_t size) override;
virtual void close() override;
virtual ~SChannelConnection();
static bool valid();
private:
PlaintextConnection socket;
CtxtHandle *context;
std::vector<char> encRecvBuffer;
std::vector<char> decRecvBuffer;
size_t decrypt(char *buffer, size_t size, bool recurse = true);
void destroyContext();
};
#endif // HTTPS_BACKEND_SCHANNEL