00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00057 virtual bool encrypt( const std::string& data );
00058
00059
00060 virtual int decrypt( const std::string& data );
00061
00062
00063 virtual void cleanup();
00064
00065
00066 virtual bool handshake();
00067
00068
00069 virtual void setCACerts( const StringList& cacerts );
00070
00071
00072 virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
00073
00074 private:
00075 void pushFunc();
00076
00077 enum TLSOperation
00078 {
00079 TLSHandshake,
00080 TLSWrite,
00081 TLSRead
00082 };
00083
00084 void doTLSOperation( TLSOperation op );
00085
00086 SSL *m_ssl;
00087 SSL_CTX *m_ctx;
00088 BIO *m_ibio;
00089 BIO *m_nbio;
00090 std::string m_recvBuffer;
00091 std::string m_sendBuffer;
00092 char *m_buf;
00093 const int m_bufsize;
00094
00095 };
00096
00097 }
00098
00099 #endif // HAVE_OPENSSL
00100
00101 #endif // TLSOPENSSL_H__