tlsschannel.h
/*
* Copyright (c) 2007-2023 by Jakob Schröter <js@camaya.net>
* This file is part of the gloox library. http://camaya.net/gloox
*
* This software is distributed under a license. The full license
* agreement can be found in the file LICENSE in this distribution.
* This software may not be copied, modified, sold or distributed
* other than expressed in the named license agreement.
*
* This software is distributed without any warranty.
*/
#ifndef TLSSCHANNEL_H__
#define TLSSCHANNEL_H__
#include "tlsbase.h"
#include "config.h"
#ifdef HAVE_WINTLS
#include <ctime>
#define SECURITY_WIN32
#include <windows.h>
#include <security.h>
#include <schnlsp.h>
namespace gloox
{
class SChannel : public TLSBase
{
public:
SChannel( TLSHandler* th, const std::string& server );
virtual ~SChannel();
// reimplemented from TLSBase
virtual bool init( const std::string& /*clientKey*/ = EmptyString,
const std::string& /*clientCerts*/ = EmptyString,
const StringList& /*cacerts*/ = StringList() )
{ return true; }
// reimplemented from TLSBase
virtual bool encrypt( const std::string& data );
// reimplemented from TLSBase
virtual int decrypt( const std::string& data );
// reimplemented from TLSBase
virtual void cleanup();
// reimplemented from TLSBase
virtual bool handshake();
// reimplemented from TLSBase
virtual bool hasChannelBinding() const;
// reimplemented from TLSBase
virtual const std::string channelBinding() const;
// reimplemented from TLSBase
virtual void setCACerts( const StringList& cacerts );
// reimplemented from TLSBase
virtual void setClientCert( const std::string& clientKey, const std::string& clientCerts );
private:
void handshakeStage( const std::string& data );
void setSizes();
int filetime2int( FILETIME t );
void validateCert();
void connectionInfos();
void certData();
void setCertinfos();
CredHandle m_credHandle;
CtxtHandle m_context;
SecPkgContext_StreamSizes m_sizes;
size_t m_header_max;
size_t m_message_max;
size_t m_trailer_max;
std::string m_buffer;
bool m_cleanedup;
// windows error outputs
// void print_error( int errorcode, const char* place = 0 );
};
}
#endif // HAVE_WINTLS
#endif // TLSSCHANNEL_H__
gloox::SChannel::encrypt
virtual bool encrypt(const std::string &data)
Definition tlsschannel.cpp:34
gloox::SChannel::~SChannel
virtual ~SChannel()
Definition tlsschannel.cpp:27
gloox::SChannel::setCACerts
virtual void setCACerts(const StringList &cacerts)
Definition tlsschannel.cpp:502
gloox::SChannel::handshake
virtual bool handshake()
Definition tlsschannel.cpp:265
gloox::SChannel::cleanup
virtual void cleanup()
Definition tlsschannel.cpp:247
gloox::SChannel::setClientCert
virtual void setClientCert(const std::string &clientKey, const std::string &clientCerts)
Definition tlsschannel.cpp:504
gloox::SChannel::SChannel
SChannel(TLSHandler *th, const std::string &server)
Definition tlsschannel.cpp:21
gloox::SChannel::channelBinding
virtual const std::string channelBinding() const
Definition tlsschannel.cpp:490
gloox::SChannel::init
virtual bool init(const std::string &=EmptyString, const std::string &=EmptyString, const StringList &=StringList())
Definition tlsschannel.h:54
gloox::SChannel::hasChannelBinding
virtual bool hasChannelBinding() const
Definition tlsschannel.cpp:481
gloox::SChannel::decrypt
virtual int decrypt(const std::string &data)
Definition tlsschannel.cpp:110
gloox::TLSBase::TLSBase
TLSBase(TLSHandler *th, const std::string server)
Definition tlsbase.h:39
gloox::TLSHandler
An interface that allows for interacting with TLS implementations derived from TLSBase.
Definition tlshandler.h:35
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StringList
std::list< std::string > StringList
Definition gloox.h:1251
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124