Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

tlsopenssl.h

00001 /*
00002   Copyright (c) 2007-2008 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 TLSOPENSSL_H__
00016 #define TLSOPENSSL_H__
00017 
00018 #include "tlsbase.h"
00019 
00020 #ifdef _WIN32
00021 # include "../config.h.win"
00022 #elif defined( _WIN32_WCE )
00023 # include "../config.h.win"
00024 #else
00025 # include "config.h"
00026 #endif
00027 
00028 #ifdef HAVE_OPENSSL
00029 
00030 #include <openssl/ssl.h>
00031 
00032 namespace gloox
00033 {
00034 
00041   class OpenSSL : public TLSBase
00042   {
00043     public:
00049       OpenSSL( TLSHandler* th, const std::string& server );
00050 
00054       virtual ~OpenSSL();
00055 
00056       // reimplemented from TLSBase
00057       virtual bool init();
00058 
00059       // reimplemented from TLSBase
00060       virtual bool encrypt( const std::string& data );
00061 
00062       // reimplemented from TLSBase
00063       virtual int decrypt( const std::string& data );
00064 
00065       // reimplemented from TLSBase
00066       virtual void cleanup();
00067 
00068       // reimplemented from TLSBase
00069       virtual bool handshake();
00070 
00071       // reimplemented from TLSBase
00072       virtual void setCACerts( const StringList& cacerts );
00073 
00074       // reimplemented from TLSBase
00075       virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
00076 
00077     private:
00078       void pushFunc();
00079 
00080       enum TLSOperation
00081       {
00082         TLSHandshake,
00083         TLSWrite,
00084         TLSRead
00085       };
00086 
00087       void doTLSOperation( TLSOperation op );
00088       int openSSLTime2UnixTime( const char* time_string );
00089 
00090       SSL* m_ssl;
00091       SSL_CTX* m_ctx;
00092       BIO* m_ibio;
00093       BIO* m_nbio;
00094       std::string m_recvBuffer;
00095       std::string m_sendBuffer;
00096       char* m_buf;
00097       const int m_bufsize;
00098   };
00099 
00100 }
00101 
00102 #endif // HAVE_OPENSSL
00103 
00104 #endif // TLSOPENSSL_H__

Generated on Mon Nov 17 02:45:13 2008 for gloox by  doxygen 1.4.1