Cuberite
A lightweight, fast and extensible game server for Minecraft
CallbackSslContext.h
Go to the documentation of this file.
1 
2 // CallbackSslContext.h
3 
4 // Declares the cCallbackSslContext class representing a SSL context wrapper that uses callbacks to read and write SSL peer data
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "SslContext.h"
13 #include "ErrorCodes.h"
14 
15 
16 
17 
18 
20  public cSslContext
21 {
22 public:
25  {
26  public:
27  // Force a virtual destructor in descendants:
28  virtual ~cDataCallbacks() {}
29 
36  virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) = 0;
37 
44  virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) = 0;
45  } ;
46 
47 
49  cCallbackSslContext(void);
50 
52  cCallbackSslContext(cDataCallbacks & a_Callbacks);
53 
54 protected:
57 
58  // cSslContext overrides:
59  virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) override;
60  virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) override;
61 };
62 
63 
64 
65 
virtual int SendEncrypted(const unsigned char *a_Buffer, size_t a_NumBytes) override
cCallbackSslContext(void)
Creates a new SSL context with no callbacks assigned.
cDataCallbacks * m_Callbacks
The callbacks to use to send and receive SSL peer data.
virtual int ReceiveEncrypted(unsigned char *a_Buffer, size_t a_NumBytes) override
Interface used as a data sink for the SSL peer data.
virtual int SendEncrypted(const unsigned char *a_Buffer, size_t a_NumBytes)=0
Called when mbedTLS wants to write encrypted data to the SSL peer.
virtual int ReceiveEncrypted(unsigned char *a_Buffer, size_t a_NumBytes)=0
Called when mbedTLS wants to read encrypted data from the SSL peer.