summaryrefslogtreecommitdiffstats
path: root/src/PolarSSL++/CallbackSslContext.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-04-27 22:27:53 +0200
committermadmaxoft <github@xoft.cz>2014-04-27 22:27:53 +0200
commit0bdc49221b325feb3a09988737559361fe916be2 (patch)
tree4d534326cc07ce4898bb74cfe7a3275c7bdc931e /src/PolarSSL++/CallbackSslContext.cpp
parentcSocket creates the socket in Connect if no socket is present yet. (diff)
downloadcuberite-0bdc49221b325feb3a09988737559361fe916be2.tar
cuberite-0bdc49221b325feb3a09988737559361fe916be2.tar.gz
cuberite-0bdc49221b325feb3a09988737559361fe916be2.tar.bz2
cuberite-0bdc49221b325feb3a09988737559361fe916be2.tar.lz
cuberite-0bdc49221b325feb3a09988737559361fe916be2.tar.xz
cuberite-0bdc49221b325feb3a09988737559361fe916be2.tar.zst
cuberite-0bdc49221b325feb3a09988737559361fe916be2.zip
Diffstat (limited to '')
-rw-r--r--src/PolarSSL++/CallbackSslContext.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/PolarSSL++/CallbackSslContext.cpp b/src/PolarSSL++/CallbackSslContext.cpp
new file mode 100644
index 000000000..0cc88a14a
--- /dev/null
+++ b/src/PolarSSL++/CallbackSslContext.cpp
@@ -0,0 +1,59 @@
+
+// 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)
+{
+ // 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);
+}
+
+
+
+
+