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; }
57 void SetExpectedPeerName(
const AString & a_ExpectedPeerName);
65 int WritePlain(
const void * a_Data,
size_t a_NumBytes);
73 int ReadPlain(
void * a_Data,
size_t a_MaxBytes);
83 bool HasHandshaken(
void)
const {
return m_HasHandshaken; }
87 int NotifyClose(
void);
92 std::shared_ptr<const cSslConfig> m_Config;
95 mbedtls_ssl_context m_Ssl;
101 bool m_HasHandshaken;
104 static int ReceiveEncrypted(
void * a_This,
unsigned char * a_Buffer,
size_t a_NumBytes)
106 return (static_cast<cSslContext *>(a_This))->ReceiveEncrypted(a_Buffer, a_NumBytes);
110 static int SendEncrypted(
void * a_This,
const unsigned char * a_Buffer,
size_t a_NumBytes)
112 return (static_cast<cSslContext *>(a_This))->SendEncrypted(a_Buffer, a_NumBytes);
116 virtual int ReceiveEncrypted(
unsigned char * a_Buffer,
size_t a_NumBytes) = 0;
119 virtual int SendEncrypted(
const unsigned char * a_Buffer,
size_t a_NumBytes) = 0;