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 #include "config.h"
00019
00020 #ifdef HAVE_WINTLS
00021
00022 #include <ctime>
00023
00024 #define SECURITY_WIN32
00025 #include <windows.h>
00026 #include <security.h>
00027 #include <schnlsp.h>
00028
00029 namespace gloox
00030 {
00031
00038 class SChannel : public TLSBase
00039 {
00040 public:
00046 SChannel( TLSHandler* th, const std::string& server );
00047
00051 virtual ~SChannel();
00052
00053
00054 virtual bool init( const std::string& = EmptyString,
00055 const std::string& = EmptyString,
00056 const StringList& = StringList() )
00057 { return true; }
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__