76 explicit Protocol(
const Profile & ,
const std::string & peer_certificate_name = std::string() ,
77 const std::string & peer_host_name = std::string() ) ;
112 Result
read(
char * buffer ,
size_t buffer_size_in , ssize_t & data_size_out ) ;
140 Result
write(
const char * buffer ,
size_t data_size_in , ssize_t & data_size_out ) ;
160 static std::string
str( Result result ) ;
181 void operator=(
const Protocol & ) ;
210 void add(
const std::string & ) ;
213 std::string
state() ;
221 std::string
value() ;
225 shared_ptr<DigesterImpBase> m_imp ;
237 typedef void (*LogFn)( int ,
const std::string & ) ;
239 explicit Library(
bool active =
true ,
const std::string & library_config = std::string() ,
254 static void log(
int level ,
const std::string & line ) ;
263 void addProfile(
const std::string & profile_name ,
bool is_server_profile ,
264 const std::string & key_file = std::string() ,
const std::string & cert_file = std::string() ,
265 const std::string & ca_path = std::string() ,
266 const std::string & default_peer_certificate_name = std::string() ,
267 const std::string & default_peer_host_name = std::string() ,
268 const std::string & profile_config = std::string() ) ;
300 bool hasProfile(
const std::string & profile_name )
const ;
303 const Profile &
profile(
const std::string & profile_name )
const ;
311 std::string
id()
const ;
321 static std::string
credit(
const std::string & prefix ,
const std::string & eol ,
const std::string & eot ) ;
324 static std::string
ids() ;
327 static bool enabledAs(
const std::string & profile_name ) ;
339 Digester digester(
const std::string & name ,
const std::string & state = std::string() )
const ;
344 void operator=(
const Library & ) ;
350 static Library * m_this ;
364 virtual std::string
id()
const = 0 ;
367 virtual void addProfile(
const std::string & ,
bool ,
const std::string & ,
const std::string & ,
368 const std::string & ,
const std::string & ,
const std::string & ,
const std::string & ) = 0 ;
371 virtual bool hasProfile(
const std::string & profile_name )
const = 0 ;
374 virtual const Profile &
profile(
const std::string & profile_name )
const = 0 ;
380 virtual Digester digester(
const std::string & ,
const std::string & )
const = 0 ;
417 virtual Protocol::Result
stop() = 0 ;
420 virtual Protocol::Result
read(
char * ,
size_t , ssize_t & ) = 0 ;
423 virtual Protocol::Result
write(
const char * ,
size_t , ssize_t & ) = 0 ;
445 virtual void add(
const std::string & ) = 0 ;
448 virtual std::string
value() = 0 ;
451 virtual std::string
state() = 0 ;
A base interface for profile classes that work with concrete classes derived from GSsl::LibraryImpBas...
static Library * instance()
Returns a pointer to a library object, if any.
std::string peerCertificateChain() const
Returns the peer certificate chain in PEM format, starting with the peer certificate and progressing ...
virtual size_t blocksize() const =0
Implements Digester::blocksize().
Digester digester(const std::string &name, const std::string &state=std::string()) const
Returns a digester object.
An abstract interface for reading and writing from a non-blocking i/o channel.
A base interface for GSsl::Protocol pimple classes.
virtual const Profile & profile(const std::string &profile_name) const =0
Implements Library::profile().
virtual ~LibraryImpBase()
Destructor.
virtual ProtocolImpBase * newProtocol(const std::string &, const std::string &) const =0
Factory method for a new Protocol object on the heap.
std::string state()
Returns the intermediate state.
static G::StringArray digesters(bool require_state=false)
Returns a list of hash function names (such as "MD5") that the TLS library can do, ordered roughly from strongest to weakest.
bool hasProfile(const std::string &profile_name) const
Returns true if the named profile has been add()ed.
virtual G::StringArray digesters(bool) const =0
Implements Library::digesters().
virtual Protocol::Result read(char *, size_t, ssize_t &)=0
Implements Protocol::read().
std::vector< std::string > StringArray
A std::vector of std::strings.
static bool enabledAs(const std::string &profile_name)
A static convenience function that returns true if there is an enabled() Library instance() that has ...
virtual std::string peerCertificate() const =0
Implements Protocol::peerCertificate().
virtual std::string value()=0
Implements Digester::value().
static std::string str(Result result)
Converts a result enumeration into a printable string.
void addProfile(const std::string &profile_name, bool is_server_profile, const std::string &key_file=std::string(), const std::string &cert_file=std::string(), const std::string &ca_path=std::string(), const std::string &default_peer_certificate_name=std::string(), const std::string &default_peer_host_name=std::string(), const std::string &profile_config=std::string())
Creates a named Profile object that can be retrieved by profile().
virtual ~Profile()
Destructor.
~Library()
Destructor. Cleans up the underlying TLS library.
static void log(int level, const std::string &line)
The default logging callback function, where the level is 1 for debug, 2 for info, 3 for warnings, and 4 for errors.
A base interface for GSsl::Digester pimple classes.
virtual Protocol::Result accept(G::ReadWrite &)=0
Implements Protocol::accept().
static LibraryImpBase & impstance()
Returns a reference to the pimple object when enabled().
Protocol(const Profile &, const std::string &peer_certificate_name=std::string(), const std::string &peer_host_name=std::string())
Constructor.
virtual Protocol::Result connect(G::ReadWrite &)=0
Implements Protocol::connect().
virtual size_t statesize() const =0
Implements Digester::statesize().
Result stop()
Initiates the protocol shutdown.
virtual std::string peerCertificateChain() const =0
Implements Protocol::peerCertificateChain().
Returns an object that can perform a cryptographic hash.
virtual std::string id() const =0
Implements Library::id().
Result read(char *buffer, size_t buffer_size_in, ssize_t &data_size_out)
Reads user data into the supplied buffer.
Result accept(G::ReadWrite &io)
Starts the protocol passively (as a server).
static bool consume(G::StringArray &list, const std::string &item)
A convenience function that removes the item from the list and returns true iff is was removed...
A base interface for GSsl::Library pimple classes.
std::string value()
Returns the hash value.
Result connect(G::ReadWrite &io)
Starts the protocol actively (as a client).
static std::string credit(const std::string &prefix, const std::string &eol, const std::string &eot)
Returns a multi-line library credit for all available TLS libraries.
Digester(DigesterImpBase *)
Constructor, used by the Library class.
const Profile & profile(const std::string &profile_name) const
Returns an opaque reference to the named profile.
virtual void addProfile(const std::string &, bool, const std::string &, const std::string &, const std::string &, const std::string &, const std::string &, const std::string &)=0
Implements Library::addProfile().
std::string peerCertificate() const
Returns the peer certificate in PEM format.
virtual bool verified() const =0
Implements Protocol::verified().
size_t valuesize() const
Returns the hash function's value size in bytes.
Library(bool active=true, const std::string &library_config=std::string(), LogFn=Library::log, bool verbose=true)
Constructor.
void add(const std::string &)
Adds data of arbitrary size.
static std::string ids()
Returns a concatenation of all available TLS library names and versions.
virtual std::string state()=0
Implements Digester::state().
Result write(const char *buffer, size_t data_size_in, ssize_t &data_size_out)
Writes user data.
virtual Protocol::Result write(const char *, size_t, ssize_t &)=0
Implements Protocol::write().
virtual Protocol::Result stop()=0
Implements Protocol::stop().
A singleton class for initialising the underlying TLS library.
static bool real()
Returns true if this is a real TLS library.
size_t statesize() const
Returns the size of the state() string in bytes, or zero if state() is not implemented.
virtual ~DigesterImpBase()
Destructor.
bool enabled() const
Returns true if this is a real TLS library and the constructor's active parameter was set...
TLS/SSL transport layer security classes.
virtual size_t valuesize() const =0
Implements Digester::valuesize().
size_t blocksize() const
Returns the hash function's block size in bytes.
bool verified() const
Returns true if the peer certificate has been verified.
virtual bool hasProfile(const std::string &profile_name) const =0
Implements Library::hasProfile().
virtual Digester digester(const std::string &, const std::string &) const =0
Implements Library::digester().
virtual void add(const std::string &)=0
Implements Digester::add().
std::string id() const
Returns the TLS library name and version.
virtual ~ProtocolImpBase()
Destructor.