OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::OpenSSLCrypto::CipherContext Class Reference

#include <cipher.hpp>

Public Types

enum  { MODE_UNDEF = -1 , ENCRYPT = 1 , DECRYPT = 0 }
 
enum  { MAX_IV_LENGTH = EVP_MAX_IV_LENGTH , CIPH_CBC_MODE = EVP_CIPH_CBC_MODE }
 

Public Member Functions

 OPENVPN_SIMPLE_EXCEPTION (openssl_cipher_mode_error)
 
 OPENVPN_SIMPLE_EXCEPTION (openssl_cipher_uninitialized)
 
 OPENVPN_EXCEPTION (openssl_cipher_error)
 
 CipherContext ()=default
 
 ~CipherContext ()
 
void init (SSLLib::Ctx libctx, const CryptoAlgs::Type alg, const unsigned char *key, const int mode)
 
void reset (const unsigned char *iv)
 
bool update (unsigned char *out, const size_t max_out_size, const unsigned char *in, const size_t in_size, size_t &out_acc)
 
bool final (unsigned char *out, const size_t max_out_size, size_t &out_acc)
 
bool is_initialized () const
 
size_t iv_length () const
 
size_t block_size () const
 
int cipher_mode () const
 

Static Public Member Functions

static bool is_supported (SSLLib::Ctx libctx, const CryptoAlgs::Type alg)
 

Private Types

using evp_cipher_type = const EVP_CIPHER
 
using CIPHER_unique_ptr = std::unique_ptr< evp_cipher_type, decltype(&::EVP_CIPHER_free)>
 

Private Member Functions

 CipherContext (const CipherContext &)=delete
 
CipherContextoperator= (const CipherContext &)=delete
 
void free_cipher_context ()
 
void check_initialized () const
 

Static Private Member Functions

static evp_cipher_typecipher_type (SSLLib::Ctx libctx, const CryptoAlgs::Type alg)
 

Private Attributes

EVP_CIPHER_CTX * ctx = nullptr
 

Detailed Description

Definition at line 31 of file cipher.hpp.

Member Typedef Documentation

◆ CIPHER_unique_ptr

Definition at line 42 of file cipher.hpp.

◆ evp_cipher_type

Definition at line 37 of file cipher.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MODE_UNDEF 
ENCRYPT 
DECRYPT 

Definition at line 53 of file cipher.hpp.

◆ anonymous enum

anonymous enum
Enumerator
MAX_IV_LENGTH 
CIPH_CBC_MODE 

Definition at line 61 of file cipher.hpp.

Constructor & Destructor Documentation

◆ CipherContext() [1/2]

openvpn::OpenSSLCrypto::CipherContext::CipherContext ( const CipherContext )
privatedelete

◆ CipherContext() [2/2]

openvpn::OpenSSLCrypto::CipherContext::CipherContext ( )
default

◆ ~CipherContext()

openvpn::OpenSSLCrypto::CipherContext::~CipherContext ( )
inline

Definition at line 69 of file cipher.hpp.

Member Function Documentation

◆ block_size()

size_t openvpn::OpenSSLCrypto::CipherContext::block_size ( ) const
inline

Definition at line 158 of file cipher.hpp.

◆ check_initialized()

void openvpn::OpenSSLCrypto::CipherContext::check_initialized ( ) const
inlineprivate

Definition at line 201 of file cipher.hpp.

Here is the caller graph for this function:

◆ cipher_mode()

int openvpn::OpenSSLCrypto::CipherContext::cipher_mode ( ) const
inline

Definition at line 165 of file cipher.hpp.

◆ cipher_type()

static evp_cipher_type * openvpn::OpenSSLCrypto::CipherContext::cipher_type ( SSLLib::Ctx  libctx,
const CryptoAlgs::Type  alg 
)
inlinestaticprivate

Definition at line 172 of file cipher.hpp.

Here is the caller graph for this function:

◆ final()

bool openvpn::OpenSSLCrypto::CipherContext::final ( unsigned char *  out,
const size_t  max_out_size,
size_t &  out_acc 
)
inline

Definition at line 131 of file cipher.hpp.

◆ free_cipher_context()

void openvpn::OpenSSLCrypto::CipherContext::free_cipher_context ( )
inlineprivate

Definition at line 195 of file cipher.hpp.

Here is the caller graph for this function:

◆ init()

void openvpn::OpenSSLCrypto::CipherContext::init ( SSLLib::Ctx  libctx,
const CryptoAlgs::Type  alg,
const unsigned char *  key,
const int  mode 
)
inline

Definition at line 80 of file cipher.hpp.

◆ is_initialized()

bool openvpn::OpenSSLCrypto::CipherContext::is_initialized ( ) const
inline

Definition at line 147 of file cipher.hpp.

◆ is_supported()

static bool openvpn::OpenSSLCrypto::CipherContext::is_supported ( SSLLib::Ctx  libctx,
const CryptoAlgs::Type  alg 
)
inlinestatic

Definition at line 74 of file cipher.hpp.

◆ iv_length()

size_t openvpn::OpenSSLCrypto::CipherContext::iv_length ( ) const
inline

Definition at line 152 of file cipher.hpp.

◆ OPENVPN_EXCEPTION()

openvpn::OpenSSLCrypto::CipherContext::OPENVPN_EXCEPTION ( openssl_cipher_error  )

◆ OPENVPN_SIMPLE_EXCEPTION() [1/2]

openvpn::OpenSSLCrypto::CipherContext::OPENVPN_SIMPLE_EXCEPTION ( openssl_cipher_mode_error  )

◆ OPENVPN_SIMPLE_EXCEPTION() [2/2]

openvpn::OpenSSLCrypto::CipherContext::OPENVPN_SIMPLE_EXCEPTION ( openssl_cipher_uninitialized  )

◆ operator=()

CipherContext & openvpn::OpenSSLCrypto::CipherContext::operator= ( const CipherContext )
privatedelete

◆ reset()

void openvpn::OpenSSLCrypto::CipherContext::reset ( const unsigned char *  iv)
inline

Definition at line 101 of file cipher.hpp.

◆ update()

bool openvpn::OpenSSLCrypto::CipherContext::update ( unsigned char *  out,
const size_t  max_out_size,
const unsigned char *  in,
const size_t  in_size,
size_t &  out_acc 
)
inline

Definition at line 111 of file cipher.hpp.

Member Data Documentation

◆ ctx

EVP_CIPHER_CTX* openvpn::OpenSSLCrypto::CipherContext::ctx = nullptr
private

Definition at line 209 of file cipher.hpp.


The documentation for this class was generated from the following file: