libfilezilla
Namespaces | Typedefs | Enumerations | Functions
tls_params.hpp File Reference

Functions and classes to abstract away the type of different parameters to tls-related functions. More...

#include "basic_tls_params.hpp"
Include dependency graph for tls_params.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 fz
 The namespace used by libfilezilla.
 

Typedefs

using const_tls_param_ref = basic_tls_param_variant< std::string_view const, native_string const &, std::string const & >
 Acts as a const lvalue reference to one of a fz::tls_blob, fz::tls_filepath or fz::tls_pkcs11url.
 
using tls_param_ref = basic_tls_param_variant< std::string &, native_string const &, std::string const & >
 Acts as a lvalue reference to one of a fz::tls_blob, fz::tls_filepath or fz::tls_pkcs11url.
 
using tls_param = basic_tls_param_variant< std::string, native_string, std::string >
 Acts as an instance of one of a fz::tls_blob, fz::tls_filepath or fz::tls_pkcs11url.
 

Enumerations

enum  tls_data_format { autodetect, pem, der }
 The encoding type of a fz::tls_blob or the file pointed to by a fz::tls_filepath. More...
 

Functions

template<typename T , std::enable_if_t< std::is_same_v< std::remove_cv_t< std::remove_reference_t< T >>, std::string >||std::is_same_v< T, std::string_view >> * = nullptr>
basic_tls_blob< T > tls_blob (T &&v)
 Creates a tls_blob object. More...
 
template<typename T >
basic_tls_blob< std::string > tls_blob (T &&v)
 Creates a tls_blob object. More...
 
template<typename T , std::enable_if_t< std::is_same_v< std::remove_cv_t< std::remove_reference_t< T >>, native_string >> * = nullptr>
basic_tls_filepath< T > tls_filepath (T &&v)
 Creates a tls_filepath object. More...
 
template<typename T >
basic_tls_filepath< native_string > tls_filepath (T &&v)
 Creates a tls_filepath object. More...
 
template<typename T , std::enable_if_t< std::is_same_v< std::remove_cv_t< std::remove_reference_t< T >>, std::string >> * = nullptr>
basic_tls_pkcs11url< T > tls_pkcs11url (T &&v)
 Creates a tls_pkcs11url object. More...
 
template<typename T , std::enable_if_t<!std::is_same_v< std::remove_cv_t< std::remove_reference_t< T >>, std::string > &&std::is_constructible_v< std::string, T >> * = nullptr>
basic_tls_pkcs11url< std::string > tls_pkcs11url (T &&v)
 Creates a tls_pkcs11url object. More...
 
bool is_pem (std::string_view blob)
 returns true if the blob is in PEM format. Uses a simple heuristic.
 

Detailed Description

Functions and classes to abstract away the type of different parameters to tls-related functions.

Certain APIs require to be passed references to TLS certificates and/or cryptographic keys, which shall be named "tls object" from now on. These tls objects could reside on files, in memory or in PCKS#11 compliant security tokens (or compatible repositories).

To express the full combination of possibilities, the APIs can take one of fz::tls_param, fz::tls_param_ref and fz::const_tls_param_ref as one of more of their parameters.

Each of those types encapsulates, respectively, a tls object, a lvalue reference to that object, or a const lvalue reference to that object.

A tls object can be one of

A fz::const_tls_param_ref can be constructed from, or assigned by, one of:

The assignment rebinds.

A fz::tls_param_ref can be constructed from, or assigned by, one of:

The assignment rebinds.

A fz::tls_param can be constructed from, or assigned by, one of:

The assignment and the constructors copy (or move, if appropriate) the tls object contained in or referenced to by the right hand side.

Example usage:
int my_tls_funcion(fz::tls_param contains_the_tls_object, fz::const_tls_param contains_a_reference_to_the_object);
int result = my_tls_function(fz::tls_blob("-----BEGIN PRIVATE KEY-----"), fz::tls_filepath(fzT("/path/to/the/file")));