tlsschannel.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TLSSCHANNEL_H__
00014 #define TLSSCHANNEL_H__
00015
00016 #include "tlsbase.h"
00017
00018 #ifdef _WIN32
00019 # include "../config.h.win"
00020 #elif defined( _WIN32_WCE )
00021 # include "../config.h.win"
00022 #else
00023 # include "config.h"
00024 #endif
00025
00026 #ifdef HAVE_WINTLS
00027
00028 #include <ctime>
00029
00030 #define SECURITY_WIN32
00031 #include <windows.h>
00032 #include <security.h>
00033 #include <schnlsp.h>
00034
00035 namespace gloox
00036 {
00037
00044 class SChannel : public TLSBase
00045 {
00046 public:
00052 SChannel( TLSHandler* th, const std::string& server );
00053
00057 virtual ~SChannel();
00058
00059
00060 virtual bool encrypt( const std::string& data );
00061
00062
00063 virtual int decrypt( const std::string& data );
00064
00065
00066 virtual void cleanup();
00067
00068
00069 virtual bool handshake();
00070
00071
00072 virtual void setCACerts( const StringList& cacerts );
00073
00074
00075 virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
00076
00077 private:
00078 void handshakeStage( const std::string& data );
00079 void setSizes();
00080
00081 int filetime2int( FILETIME t );
00082
00083 void validateCert();
00084 void connectionInfos();
00085 void certData();
00086 void setCertinfos();
00087 CredHandle m_credHandle;
00088 CtxtHandle m_context;
00089
00090 SecPkgContext_StreamSizes m_sizes;
00091
00092 size_t m_header_max;
00093 size_t m_message_max;
00094 size_t m_trailer_max;
00095
00096 std::string m_buffer;
00097
00098 bool m_cleanedup;
00099
00100
00101
00102
00103 };
00104 }
00105
00106 #endif // HAVE_WINTLS
00107
00108 #endif // TLSSCHANNEL_H__