summaryrefslogtreecommitdiffstats
path: root/src/PolarSSL++/CallbackSslContext.cpp
blob: c4d19b2a06ed215efdc70d31f391a1e0f01737c2 (plain) (blame)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

// CallbackSslContext.cpp

// Declares the cCallbackSslContext class representing a SSL context wrapper that uses callbacks to read and write SSL peer data

#include "Globals.h"
#include "CallbackSslContext.h"






cCallbackSslContext::cCallbackSslContext(void) :
	m_Callbacks(NULL)
{
	// Nothing needed, but the constructor needs to exist so
}





cCallbackSslContext::cCallbackSslContext(cCallbackSslContext::cDataCallbacks & a_Callbacks) :
	m_Callbacks(&a_Callbacks)
{
}





int cCallbackSslContext::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes)
{
	if (m_Callbacks == NULL)
	{
		LOGWARNING("SSL: Trying to receive data with no callbacks, aborting.");
		return POLARSSL_ERR_NET_RECV_FAILED;
	}
	return m_Callbacks->ReceiveEncrypted(a_Buffer, a_NumBytes);
}





int cCallbackSslContext::SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes)
{
	if (m_Callbacks == NULL)
	{
		LOGWARNING("SSL: Trying to send data with no callbacks, aborting.");
		return POLARSSL_ERR_NET_SEND_FAILED;
	}
	return m_Callbacks->SendEncrypted(a_Buffer, a_NumBytes);
}