12 #include "mbedtls/ssl.h"
13 #include "../ByteBuffer.h"
35 class cSslContext
abstract
41 virtual ~cSslContext();
46 int Initialize(std::shared_ptr<const cSslConfig> a_Config);
49 int Initialize(
bool a_IsClient);
52 bool IsValid(
void)
const {
return m_IsValid; }
59 void SetExpectedPeerName(
const std::string_view a_ExpectedPeerName);
67 int WritePlain(
const void * a_Data,
size_t a_NumBytes);
75 int ReadPlain(
void * a_Data,
size_t a_MaxBytes);
85 bool HasHandshaken(
void)
const {
return m_HasHandshaken; }
89 int NotifyClose(
void);
94 std::shared_ptr<const cSslConfig> m_Config;
97 mbedtls_ssl_context m_Ssl;
103 bool m_HasHandshaken;
106 static int ReceiveEncrypted(
void * a_This,
unsigned char * a_Buffer,
size_t a_NumBytes)
108 return (
static_cast<cSslContext *
>(a_This))->ReceiveEncrypted(a_Buffer, a_NumBytes);
112 static int SendEncrypted(
void * a_This,
const unsigned char * a_Buffer,
size_t a_NumBytes)
114 return (
static_cast<cSslContext *
>(a_This))->SendEncrypted(a_Buffer, a_NumBytes);
118 virtual int ReceiveEncrypted(
unsigned char * a_Buffer,
size_t a_NumBytes) = 0;
121 virtual int SendEncrypted(
const unsigned char * a_Buffer,
size_t a_NumBytes) = 0;