libfilezilla
Loading...
Searching...
No Matches
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

namespace  fz
 The namespace used by libfilezilla.
 

Typedefs

using const_tls_param_ref
 Acts as a const lvalue reference to one of a tls_blob, tls_filepath or tls_pkcs11url.
 
using tls_param_ref
 Acts as a lvalue reference to one of a tls_blob, tls_filepath or tls_pkcs11url.
 
using tls_param
 Acts as an instance of one of a tls_blob, tls_filepath or tls_pkcs11url.
 

Enumerations

enum class  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.
 
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 >) &&std::is_constructible_v< std::string, T > > * = nullptr>
basic_tls_blob< std::string > tls_blob (T &&v)
 Creates a tls_blob object.
 
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.
 
template<typename T, std::enable_if_t<!(std::is_same_v< std::remove_cv_t< std::remove_reference_t< T > >, native_string >) &&std::is_constructible_v< native_string, T > > * = nullptr>
basic_tls_filepath< native_stringtls_filepath (T &&v)
 Creates a tls_filepath object.
 
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.
 
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.
 
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 tls_param, tls_param_ref and 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 const_tls_param_ref can be constructed from, or assigned by, one of:

The assignment rebinds.

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

The assignment rebinds.

A 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")));
basic_tls_param_variant< std::string, native_string, std::string > tls_param
Acts as an instance of one of a tls_blob, tls_filepath or tls_pkcs11url.
Definition tls_params.hpp:134
basic_tls_filepath< T > tls_filepath(T &&v)
Creates a tls_filepath object.
Definition tls_params.hpp:80
basic_tls_blob< T > tls_blob(T &&v)
Creates a tls_blob object.
Definition tls_params.hpp:59
#define fzT(x)
Macro for a string literal in system-native character type. Note: Macro definition changes depending...
Definition string.hpp:259