tlsgnutlsbase.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 TLSGNUTLSBASE_H__
#define TLSGNUTLSBASE_H__
#include "tlsbase.h"
#include "config.h"
#ifdef HAVE_GNUTLS
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
namespace gloox
{
class GnuTLSBase : public TLSBase
{
public:
GnuTLSBase( TLSHandler* th, const std::string& server = EmptyString );
virtual ~GnuTLSBase();
// 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*/ ) {}
protected:
virtual void getCertInfo() {}
void getCommonCertInfo();
gnutls_session_t* m_session;
std::string m_recvBuffer;
char* m_buf;
const int m_bufsize;
ssize_t pullFunc( void* data, size_t len );
static ssize_t pullFunc( gnutls_transport_ptr_t ptr, void* data, size_t len );
ssize_t pushFunc( const void* data, size_t len );
static ssize_t pushFunc( gnutls_transport_ptr_t ptr, const void* data, size_t len );
};
}
#endif // HAVE_GNUTLS
#endif // TLSGNUTLSBASE_H__
gloox::GnuTLSBase::encrypt
virtual bool encrypt(const std::string &data)
Definition tlsgnutlsbase.cpp:45
gloox::GnuTLSBase::~GnuTLSBase
virtual ~GnuTLSBase()
Definition tlsgnutlsbase.cpp:33
gloox::GnuTLSBase::handshake
virtual bool handshake()
Definition tlsgnutlsbase.cpp:122
gloox::GnuTLSBase::cleanup
virtual void cleanup()
Definition tlsgnutlsbase.cpp:98
gloox::GnuTLSBase::setClientCert
virtual void setClientCert(const std::string &, const std::string &)
Definition tlsgnutlsbase.h:75
gloox::GnuTLSBase::channelBinding
virtual const std::string channelBinding() const
Definition tlsgnutlsbase.cpp:159
gloox::GnuTLSBase::hasChannelBinding
virtual bool hasChannelBinding() const
Definition tlsgnutlsbase.cpp:150
gloox::GnuTLSBase::setCACerts
virtual void setCACerts(const StringList &)
Definition tlsgnutlsbase.h:72
gloox::GnuTLSBase::GnuTLSBase
GnuTLSBase(TLSHandler *th, const std::string &server=EmptyString)
Definition tlsgnutlsbase.cpp:27
gloox::GnuTLSBase::decrypt
virtual int decrypt(const std::string &data)
Definition tlsgnutlsbase.cpp:64
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