14#ifndef OPENVPN_CRYPTO_DECRYPT_CHM_H
15#define OPENVPN_CRYPTO_DECRYPT_CHM_H
32template <
typename CRYPTO_API>
47 unsigned char local_hmac[CRYPTO_API::HMACContext::MAX_HMAC_SIZE];
48 const size_t hmac_size =
hmac.output_size();
49 const unsigned char *packet_hmac = buf.
read_alloc(hmac_size);
61 unsigned char iv_buf[CRYPTO_API::CipherContext::MAX_IV_LENGTH];
62 const size_t iv_length =
cipher.iv_length();
65 buf.
read(iv_buf, iv_length);
80 const int cipher_mode =
cipher.cipher_mode();
81 if (cipher_mode == CRYPTO_API::CipherContext::CIPH_CBC_MODE)
91 throw chm_unsupported_cipher_mode();
void swap(BufferAllocatedType< T_ > &other)
Swaps the contents of this BufferAllocatedType object with another BufferAllocatedType object.
const T * c_data() const
Returns a const pointer to the start of the buffer.
size_t max_size() const
Return the maximum allowable size value in T objects given the current offset (without considering re...
size_t size() const
Returns the size of the buffer in T objects.
T * data()
Get a mutable pointer to the start of the array.
auto * read_alloc(const size_t size)
Allocate memory and read data from the buffer into the allocated memory.
void set_size(const size_t size)
After an external method, operating on the array as a mutable unsigned char buffer,...
void reset_size()
Resets the size of the buffer to zero.
void read(NCT *data, const size_t size)
Read data from the buffer into the specified memory location.
OPENVPN_SIMPLE_EXCEPTION(chm_unsupported_cipher_mode)
bool verify_packet_id(BufferAllocated &buf, const std::time_t now)
OvpnHMAC< CRYPTO_API > hmac
Error::Type decrypt(BufferAllocated &buf, const std::time_t now)
CipherContext< CRYPTO_API > cipher
PacketIDDataReceive pid_recv
size_t prepare(const unsigned int context, Buffer &buf) const
PacketIDData read_next(Buffer &buf) const
bool test_add(const PacketIDData &pin, const Time::base_type now, const SessionStats::Ptr &stats)
bool memneq(const void *a, const void *b, size_t size)