gloox
1.0
|
00001 /* 00002 Copyright (c) 2007-2009 by Jakob Schroeter <js@camaya.net> 00003 This file is part of the gloox library. http://camaya.net/gloox 00004 00005 This software is distributed under a license. The full license 00006 agreement can be found in the file LICENSE in this distribution. 00007 This software may not be copied, modified, sold or distributed 00008 other than expressed in the named license agreement. 00009 00010 This software is distributed without any warranty. 00011 */ 00012 00013 00014 00015 #ifndef TLSGNUTLSBASE_H__ 00016 #define TLSGNUTLSBASE_H__ 00017 00018 #include "tlsbase.h" 00019 00020 #include "config.h" 00021 00022 #ifdef HAVE_GNUTLS 00023 00024 #include <gnutls/gnutls.h> 00025 #include <gnutls/x509.h> 00026 00027 namespace gloox 00028 { 00029 00038 class GnuTLSBase : public TLSBase 00039 { 00040 public: 00046 GnuTLSBase( TLSHandler* th, const std::string& server = EmptyString ); 00047 00051 virtual ~GnuTLSBase(); 00052 00053 // reimplemented from TLSBase 00054 virtual bool encrypt( const std::string& data ); 00055 00056 // reimplemented from TLSBase 00057 virtual int decrypt( const std::string& data ); 00058 00059 // reimplemented from TLSBase 00060 virtual void cleanup(); 00061 00062 // reimplemented from TLSBase 00063 virtual bool handshake(); 00064 00065 // reimplemented from TLSBase 00066 virtual void setCACerts( const StringList& /*cacerts*/ ) {} 00067 00068 // reimplemented from TLSBase 00069 virtual void setClientCert( const std::string& /*clientKey*/, const std::string& /*clientCerts*/ ) {} 00070 00071 protected: 00072 virtual void getCertInfo() {} 00073 00074 gnutls_session_t* m_session; 00075 00076 std::string m_recvBuffer; 00077 char* m_buf; 00078 const int m_bufsize; 00079 00080 ssize_t pullFunc( void* data, size_t len ); 00081 static ssize_t pullFunc( gnutls_transport_ptr_t ptr, void* data, size_t len ); 00082 00083 ssize_t pushFunc( const void* data, size_t len ); 00084 static ssize_t pushFunc( gnutls_transport_ptr_t ptr, const void* data, size_t len ); 00085 00086 }; 00087 00088 } 00089 00090 #endif // HAVE_GNUTLS 00091 00092 #endif // TLSGNUTLSBASE_H__