74 if (use_epoch_data_format)
80 uint8_t *mac_out = NULL;
138 "ENCRYPT: buffer size error, bc=%d bo=%d bl=%d wc=%d wo=%d wl=%d",
201 if (buf->
len > 0 && opt)
204 uint8_t *mac_out = NULL;
205 const uint8_t *hmac_start = NULL;
219 hmac_start =
BEND(&work);
265 msg(
D_CRYPT_ERRORS,
"ENCRYPT: buffer size error, bc=%d bo=%d bl=%d wc=%d wo=%d wl=%d cbs=%d",
339 if (buf->
len > 0 && opt)
404 msg(
D_GENKEY,
"Received data packet with new epoch %d. Updating "
405 "receive key", epoch);
425 "see the man page entry for --replay-window for "
426 "more info or silence this warning with --mute-replay-warnings",
444 const uint8_t *ad_start)
446 static const char error_prefix[] =
"AEAD Decrypt error";
455 CRYPT_DROP(
"Decryption failed verification limit reached.");
479 if (use_epoch_data_format)
481 min_packet_len +=
sizeof(uint32_t);
484 if (buf->
len < min_packet_len)
486 CRYPT_ERROR(
"missing IV info, missing tag or no payload");
497 if (use_epoch_data_format)
500 const size_t packet_iv_len =
sizeof(uint64_t);
503 memcpy(iv,
BPTR(buf), packet_iv_len);
517 CRYPT_DROP(
"Decryption failed verification limit reached");
524 memcpy(iv,
BPTR(buf), packet_iv_len);
533 for (
int i = 0; i < iv_len; i++)
547 const int ad_size =
BPTR(buf) - ad_start;
549 uint8_t *tag_ptr = NULL;
552 if (use_epoch_data_format)
554 data_len =
BLEN(buf) - tag_size;
555 tag_ptr =
BPTR(buf) + data_len;
561 data_len =
BLEN(buf);
588 &outlen, tag_ptr, tag_size))
591 CRYPT_DROP(
"packet tag authentication failed");
633 static const char error_prefix[] =
"Authenticate/Decrypt packet error";
637 if (buf->
len > 0 && opt)
641 bool have_pin =
false;
658 if (buf->
len < hmac_len)
669 CRYPT_DROP(
"packet HMAC authentication failed");
687 if (buf->
len < iv_size)
691 memcpy(iv_buf,
BPTR(buf), iv_size);
722 CRYPT_DROP(
"packet authentication failed, dropping.");
800 if (buf->
len > 0 && opt)
880 msg(
M_WARN,
"WARNING: INSECURE cipher (%s) with block size less than 128"
881 " bit (%d bit). This allows attacks like SWEET32. Mitigate by "
882 "using a --cipher with a larger block size (e.g. AES-256-CBC). "
883 "Support for these insecure ciphers will be removed in "
903 if (
strcmp(ciphername,
"none") != 0)
907 msg(
M_FATAL,
"Cipher %s not supported", ciphername);
919 msg(
M_FATAL,
"Cipher '%s' mode not supported", ciphername);
924 msg(
M_FATAL,
"Cipher '%s' not allowed: block size too big.", ciphername);
935 msg(
M_WARN,
"******* WARNING *******: '--cipher none' was specified. "
936 "This means NO encryption will be performed and tunnelled "
937 "data WILL be transmitted in clear text over the network! "
938 "PLEASE DO RECONSIDER THIS SETTING!");
942 if (
strcmp(authname,
"none") != 0)
954 msg(
M_FATAL,
"HMAC '%s' not allowed: digest size too big.", authname);
962 msg(
M_WARN,
"******* WARNING *******: '--auth none' was specified. "
963 "This means no authentication will be performed on received "
964 "packets, meaning you CANNOT trust that the data received by "
965 "the remote side have NOT been manipulated. "
966 "PLEASE DO RECONSIDER THIS SETTING!");
1046 "%s: Using %d bit message hash '%s' for HMAC authentication",
1064 const struct key_type *kt,
const char *name)
1066 char log_prefix[128] = { 0 };
1068 snprintf(log_prefix,
sizeof(log_prefix),
"Outgoing %s", name);
1076 const struct key_type *kt,
const char *name)
1078 char log_prefix[128] = { 0 };
1080 snprintf(log_prefix,
sizeof(log_prefix),
"Incoming %s", name);
1088 int key_direction,
const struct key_type *kt,
const char *name)
1136 for (
int i = 0; i < cipher_length; ++i)
1181 msg(
M_FATAL,
"ERROR: Random number generator cannot obtain entropy for key generation");
1210 const char *prefix0,
1211 const char *prefix1)
1265 msg(
M_INFO,
"TESTING ENCRYPT/DECRYPT of packet length=%d",
i);
1295 for (
j = 0;
j <
i; ++
j)
1301 msg(
M_FATAL,
"SELF TEST FAILED, pos=%d in=%d out=%d",
j, in, out);
1314 return "[[INLINE]]";
1339 msg(
M_ERR,
"File '%s' does not have OpenVPN Static Key format. Using "
1340 "free-form passphrase file is not supported anymore.",
1365 "Non-Hex character ('%c') found at line %d in key file '%s' (%d/%d/%d bytes found/min/max)";
1368 "Non-Hex, unprintable character (0x%02x) found at line %d in key file '%s' (%d/%d/%d bytes found/min/max)";
1381 const unsigned char *
cp;
1393#define PARSE_INITIAL 0
1396#define PARSE_DATA_COMPLETE 3
1398#define PARSE_FINISHED 5
1422 msg(
M_FATAL,
"Read error on key file ('%s')", file);
1428 cp = (
unsigned char *)in.
data;
1431 const unsigned char c = *
cp;
1434 msg(
M_INFO,
"char='%c'[%d] s=%d ln=%d li=%d m=%d c=%d",
1466 if (++
match == hlen)
1534 msg(
M_FATAL,
"Insufficient key material or header text not found in file '%s' (%d/%d/%d bytes found/min/max)",
1541 msg(
M_FATAL,
"Footer text not found in file '%s' (%d/%d/%d bytes found/min/max)",
1581 int nbits = nkeys *
sizeof(
struct key) * 8;
1620 if (!filename || strcmp(filename,
"")==0)
1622 printf(
"%.*s\n",
BLEN(&out),
BPTR(&out));
1645 msg(
M_FATAL,
"Key file '%s' used in --%s contains insufficient key material [keys found=%d required=%d]", filename, option,
key2->
n, n);
1647 msg(
M_FATAL,
"Key file '%s' used in --%s contains insufficient key material [keys found=%d required=%d] -- try generating a new key file with '" PACKAGE
" --genkey secret [file]', or use the existing key file in bidirectional mode by specifying --%s without a key direction parameter", filename, option,
key2->
n, n, option);
1659 else if (!strcmp(str,
"0"))
1663 else if (!strcmp(str,
"1"))
1669 msg(msglevel,
"Unknown key direction '%s' -- must be '0' or '1'", str);
1691 return remote ?
"1" :
"0";
1695 return remote ?
"0" :
"1";
1708 switch (key_direction)
1738 for (i = 0; i <
key2->
n; ++i)
1743 msg(
M_FATAL,
"Key #%d in '%s' is bad. Try making a new key with --genkey.",
1744 i+1, shared_secret_file);
1771 printf(
"%s (%d bit key, ",
1777 printf(
"stream cipher");
1786 printf(
", TLS client/server mode only");
1792 printf(
", %s", reason);
1809 || 0 == strcmp(cipher_name, pair->
lib_name))
1849 struct key server_key = { 0 };
1862 msg(
M_WARN,
"ERROR: could not PEM-encode key");
1866 if (!filename ||
strcmp(filename,
"")==0)
1872 msg(
M_ERR,
"ERROR: could not write key file");
1892 msg(
M_WARN,
"ERROR: could not generate random key");
1914 msg(
M_WARN,
"ERROR: failed to read %s file (%s)",
1915 pem_name, key_file);
1921 buf_set_read(&key_pem, (
const void *)key_file, strlen(key_file) + 1);
1926 msg(
M_WARN,
"ERROR: %s pem decode failed", pem_name);
1947 const char *seed =
"tls1-prf-test";
1948 const char *secret =
"tls1-prf-test-secret";
1950 uint8_t expected_out[] = {
'q',
'D',
'\xfe',
'%',
'@',
's',
'u',
'\x95' };
1952 int ret =
ssl_tls1_PRF((uint8_t *)seed, (
int) strlen(seed),
1953 (uint8_t *)secret, (
int) strlen(secret),
1956 return (ret && memcmp(out, expected_out,
sizeof(out)) == 0);
void buf_clear(struct buffer *buf)
bool buffer_write_file(const char *filename, const struct buffer *buf)
Write buffer contents to file.
bool buf_printf(struct buffer *buf, const char *format,...)
char * format_hex_ex(const uint8_t *data, int size, int maxoutput, unsigned int space_break_flags, const char *separator, struct gc_arena *gc)
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
struct buffer buffer_read_from_file(const char *filename, struct gc_arena *gc)
buffer_read_from_file - copy the content of a file into a buffer
static char * format_hex(const uint8_t *data, int size, int maxoutput, struct gc_arena *gc)
static struct buffer clear_buf(void)
Return an empty struct buffer.
static bool buf_write_prepend(struct buffer *dest, const void *src, int size)
static bool buf_inc_len(struct buffer *buf, int inc)
static bool buf_valid(const struct buffer *buf)
static void gc_init(struct gc_arena *a)
static bool buf_safe(const struct buffer *buf, size_t len)
static void buf_set_write(struct buffer *buf, uint8_t *data, int size)
static bool buf_advance(struct buffer *buf, int size)
static int buf_len(const struct buffer *buf)
static void buf_set_read(struct buffer *buf, const uint8_t *data, size_t size)
static void secure_memzero(void *data, size_t len)
Securely zeroise memory.
static uint8_t * buf_write_alloc(struct buffer *buf, size_t size)
static bool buf_write(struct buffer *dest, const void *src, size_t size)
static uint8_t * buf_prepend(struct buffer *buf, int size)
static void gc_free(struct gc_arena *a)
#define buf_init(buf, offset)
static struct gc_arena gc_new(void)
const char * translate_cipher_name_from_openvpn(const char *cipher_name)
Translate an OpenVPN cipher name to a crypto library cipher name.
static void key_print(const struct key *key, const struct key_type *kt, const char *prefix)
static const char static_key_head[]
void free_key_ctx_bi(struct key_ctx_bi *ctx)
const char * print_key_filename(const char *str, bool is_inline)
To be used when printing a string that may contain inline data.
static void warn_insecure_key_type(const char *ciphername)
void prng_bytes(uint8_t *output, int len)
void init_key_ctx(struct key_ctx *ctx, const struct key_parameters *key, const struct key_type *kt, int enc, const char *prefix)
unsigned int calculate_crypto_overhead(const struct key_type *kt, unsigned int pkt_id_size, bool occ)
Calculate the maximum overhead that our encryption has on a packet.
void key2_print(const struct key2 *k, const struct key_type *kt, const char *prefix0, const char *prefix1)
Prints the keys in a key2 structure.
void verify_fix_key2(struct key2 *key2, const struct key_type *kt, const char *shared_secret_file)
void init_key_bi_ctx_send(struct key_ctx *ctx, const struct key_parameters *key_params, const struct key_type *kt, const char *name)
void read_key_file(struct key2 *key2, const char *file, const unsigned int flags)
long int get_random(void)
static bool key_is_zero(struct key *key, const struct key_type *kt)
static bool openvpn_decrypt_aead(struct buffer *buf, struct buffer work, struct crypto_options *opt, const struct frame *frame, const uint8_t *ad_start)
Unwrap (authenticate, decrypt and check replay protection) AEAD-mode data channel packets.
bool read_pem_key_file(struct buffer *key, const char *pem_name, const char *key_file, bool key_inline)
Read key material from a PEM encoded files into the key structure.
void init_key_type(struct key_type *kt, const char *ciphername, const char *authname, bool tls_mode, bool warn)
Initialize a key_type structure with.
int ascii2keydirection(int msglevel, const char *str)
bool generate_ephemeral_key(struct buffer *key, const char *key_name)
Generate ephermal key material into the key structure.
void must_have_n_keys(const char *filename, const char *option, const struct key2 *key2, int n)
const char * keydirection2ascii(int kd, bool remote, bool humanreadable)
int write_key_file(const int nkeys, const char *filename)
Write nkeys 1024-bits keys to file.
bool check_key(struct key *key, const struct key_type *kt)
const char * translate_cipher_name_to_openvpn(const char *cipher_name)
Translate a crypto library cipher name to an OpenVPN cipher name.
void write_pem_key_file(const char *filename, const char *pem_name)
Generate a server key with enough randomness to fill a key struct and write to file.
void key_parameters_from_key(struct key_parameters *key_params, const struct key *key)
Converts a struct key representation into a struct key_parameters representation.
#define PARSE_DATA_COMPLETE
static const char static_key_foot[]
uint64_t cipher_get_aead_limits(const char *ciphername)
Check if the cipher is an AEAD cipher and needs to be limited to a certain number of number of blocks...
static const cipher_name_pair * get_cipher_name_pair(const char *cipher_name)
void init_key_ctx_bi(struct key_ctx_bi *ctx, const struct key2 *key2, int key_direction, const struct key_type *kt, const char *name)
bool check_tls_prf_working(void)
Checks if the current TLS library supports the TLS 1.0 PRF with MD5+SHA1 that OpenVPN uses when TLS K...
void key_direction_state_init(struct key_direction_state *kds, int key_direction)
unsigned int crypto_max_overhead(void)
Return the worst-case OpenVPN crypto overhead (in bytes)
static void openvpn_encrypt_v1(struct buffer *buf, struct buffer work, struct crypto_options *opt)
static void key_ctx_update_implicit_iv(struct key_ctx *ctx, const struct key_parameters *key)
Update the implicit IV for a key_ctx based on TLS session ids and cipher used.
static const char unprintable_char_fmt[]
void print_cipher(const char *ciphername)
Print a cipher list entry.
static void generate_key_random(struct key *key)
void test_crypto(struct crypto_options *co, struct frame *frame)
void crypto_read_openvpn_key(const struct key_type *key_type, struct key_ctx_bi *ctx, const char *key_file, bool key_inline, const int key_direction, const char *key_name, const char *opt_name, struct key2 *keydata)
bool crypto_check_replay(struct crypto_options *opt, const struct packet_id_net *pin, uint16_t epoch, const char *error_prefix, struct gc_arena *gc)
Check packet ID for replay, and perform replay administration.
static void openvpn_encrypt_aead(struct buffer *buf, struct buffer work, struct crypto_options *opt)
static bool openvpn_decrypt_v1(struct buffer *buf, struct buffer work, struct crypto_options *opt, const struct frame *frame)
void free_key_ctx(struct key_ctx *ctx)
static const char printable_char_fmt[]
void init_key_bi_ctx_recv(struct key_ctx *ctx, const struct key_parameters *key_params, const struct key_type *kt, const char *name)
Data Channel Cryptography Module.
#define AEAD_LIMIT_BLOCKSIZE
Blocksize used for the AEAD limit caluclation.
#define KEY_DIRECTION_NORMAL
#define CO_PACKET_ID_LONG_FORM
Bit-flag indicating whether to use OpenVPN's long packet ID format.
static bool cipher_decrypt_verify_fail_exceeded(const struct key_ctx *ctx)
Check if the number of failed decryption is over the acceptable limit.
#define OPENVPN_AEAD_MIN_IV_LEN
Minimal IV length for AEAD mode ciphers (in bytes): 4-byte packet id + 8 bytes implicit IV.
#define CRYPT_DROP(format)
#define CRYPT_ERROR(format)
#define CO_IGNORE_PACKET_ID
Bit-flag indicating whether to ignore the packet ID of a received packet.
#define CO_EPOCH_DATA_KEY_FORMAT
Bit-flag indicating the epoch the data format.
#define CO_MUTE_REPLAY_WARNINGS
Bit-flag indicating not to display replay warnings.
#define KEY_DIRECTION_BIDIRECTIONAL
int memcmp_constant_time(const void *a, const void *b, size_t size)
As memcmp(), but constant-time.
#define KEY_DIRECTION_INVERSE
int cipher_ctx_update(cipher_ctx_t *ctx, uint8_t *dst, int *dst_len, uint8_t *src, int src_len)
Updates the given cipher context, encrypting data in the source buffer, and placing any complete bloc...
void hmac_ctx_update(hmac_ctx_t *ctx, const uint8_t *src, int src_len)
hmac_ctx_t * hmac_ctx_new(void)
void hmac_ctx_reset(hmac_ctx_t *ctx)
int cipher_ctx_block_size(const cipher_ctx_t *ctx)
Returns the block size of the cipher, in bytes.
bool cipher_kt_mode_cbc(const char *ciphername)
Check if the supplied cipher is a supported CBC mode cipher.
void hmac_ctx_init(hmac_ctx_t *ctx, const uint8_t *key, const char *mdname)
static bool cipher_defined(const char *ciphername)
Checks if the cipher is defined and is not the null (none) cipher.
void hmac_ctx_final(hmac_ctx_t *ctx, uint8_t *dst)
bool ssl_tls1_PRF(const uint8_t *seed, int seed_len, const uint8_t *secret, int secret_len, uint8_t *output, int output_len)
Calculates the TLS 1.0-1.1 PRF function.
int cipher_ctx_iv_length(const cipher_ctx_t *ctx)
Returns the size of the IV used by the cipher, in bytes, or 0 if no IV is used.
int cipher_kt_block_size(const char *ciphername)
Returns the block size of the cipher, in bytes.
bool cipher_kt_mode_aead(const char *ciphername)
Check if the supplied cipher is a supported AEAD mode cipher.
bool cipher_ctx_mode_cbc(const cipher_ctx_t *ctx)
Check if the supplied cipher is a supported CBC mode cipher.
cipher_ctx_t * cipher_ctx_new(void)
Generic cipher functions.
bool cipher_kt_mode_ofb_cfb(const char *ciphername)
Check if the supplied cipher is a supported OFB or CFB mode cipher.
const char * md_kt_name(const char *mdname)
Retrieve a string describing the digest digest (e.g.
int hmac_ctx_size(hmac_ctx_t *ctx)
bool cipher_kt_insecure(const char *ciphername)
Returns true if we consider this cipher to be insecure.
#define MAX_CIPHER_KEY_LENGTH
void crypto_clear_error(void)
bool crypto_pem_decode(const char *name, struct buffer *dst, const struct buffer *src)
Decode a PEM buffer to binary data.
void cipher_ctx_free(cipher_ctx_t *ctx)
Cleanup and free a cipher context.
int cipher_ctx_mode(const cipher_ctx_t *ctx)
Returns the mode that the cipher runs in.
bool cipher_ctx_mode_ofb_cfb(const cipher_ctx_t *ctx)
Check if the supplied cipher is a supported OFB or CFB mode cipher.
bool cipher_ctx_mode_aead(const cipher_ctx_t *ctx)
Check if the supplied cipher is a supported AEAD mode cipher.
static bool cipher_valid(const char *ciphername)
Returns if the cipher is valid, based on the given cipher name.
void hmac_ctx_free(hmac_ctx_t *ctx)
int cipher_kt_iv_size(const char *ciphername)
Returns the size of the IV used by the cipher, in bytes, or 0 if no IV is used.
int cipher_kt_tag_size(const char *ciphername)
Returns the MAC tag size of the cipher, in bytes.
int cipher_ctx_update_ad(cipher_ctx_t *ctx, const uint8_t *src, int src_len)
Updates the given cipher context, providing additional data (AD) for authenticated encryption with ad...
int rand_bytes(uint8_t *output, int len)
Wrapper for secure random number generator.
const size_t cipher_name_translation_table_count
const char * cipher_kt_name(const char *ciphername)
Retrieve a normalised string describing the cipher (e.g.
#define MAX_HMAC_KEY_LENGTH
#define OPENVPN_AEAD_TAG_LENGTH
void cipher_ctx_init(cipher_ctx_t *ctx, const uint8_t *key, const char *ciphername, crypto_operation_t enc)
Initialise a cipher context, based on the given key and key type.
int cipher_ctx_get_tag(cipher_ctx_t *ctx, uint8_t *tag, int tag_len)
Gets the computed message authenticated code (MAC) tag for this cipher.
int cipher_kt_key_size(const char *ciphername)
Returns the size of keys used by the cipher, in bytes.
#define OPENVPN_MAX_CIPHER_BLOCK_SIZE
void hmac_ctx_cleanup(hmac_ctx_t *ctx)
int cipher_ctx_reset(cipher_ctx_t *ctx, const uint8_t *iv_buf)
Resets the given cipher context, setting the IV to the specified value.
const cipher_name_pair cipher_name_translation_table[]
Cipher name translation table.
int cipher_ctx_final(cipher_ctx_t *ctx, uint8_t *dst, int *dst_len)
Pads the final cipher block using PKCS padding, and output to the destination buffer.
#define OPENVPN_MAX_HMAC_SIZE
unsigned char md_kt_size(const char *mdname)
Returns the size of the message digest, in bytes.
static bool md_defined(const char *mdname)
Checks if the cipher is defined and is not the null (none) cipher.
bool cipher_valid_reason(const char *ciphername, const char **reason)
Returns if the cipher is valid, based on the given cipher name and provides a reason if invalid.
int cipher_ctx_final_check_tag(cipher_ctx_t *ctx, uint8_t *dst, int *dst_len, uint8_t *tag, size_t tag_len)
Like cipher_ctx_final, but check the computed authentication tag against the supplied (expected) tag.
bool crypto_pem_encode(const char *name, struct buffer *dst, const struct buffer *src, struct gc_arena *gc)
Encode binary data as PEM.
void epoch_replace_update_recv_key(struct crypto_options *co, uint16_t new_epoch)
This is called when the peer uses a new send key that is not the default key.
void epoch_check_send_iterate(struct crypto_options *opt)
Checks if we need to iterate the send epoch key.
struct key_ctx * epoch_lookup_decrypt_key(struct crypto_options *opt, uint16_t epoch)
Using an epoch, this function will try to retrieve a decryption key context that matches that epoch f...
#define OPENVPN_OP_DECRYPT
Cipher should decrypt.
mbedtls_cipher_context_t cipher_ctx_t
Generic cipher context.
#define OPENVPN_MODE_CBC
Cipher is in CBC mode.
#define OPENVPN_MAX_IV_LENGTH
Maximum length of an IV.
#define OPENVPN_OP_ENCRYPT
Cipher should encrypt.
#define D_SHOW_KEY_SOURCE
void openvpn_encrypt(struct buffer *buf, struct buffer work, struct crypto_options *opt)
Encrypt and HMAC sign a packet so that it can be sent as a data channel VPN tunnel packet to a remote...
bool openvpn_decrypt(struct buffer *buf, struct buffer work, struct crypto_options *opt, const struct frame *frame, const uint8_t *ad_start)
HMAC verify and decrypt a data channel packet received from a remote OpenVPN peer.
static int max_int(int x, int y)
static const char * np(const char *str)
static void update_time(void)
bool packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin)
bool packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
const char * packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
void packet_id_add(struct packet_id_rec *p, const struct packet_id_net *pin)
bool packet_id_write(struct packet_id_send *p, struct buffer *buf, bool long_form, bool prepend)
Write a packet ID to buf, and update the packet ID state.
bool packet_id_write_epoch(struct packet_id_send *p, uint16_t epoch, struct buffer *buf)
Writes the packet ID containing both the epoch and the packet id to the buffer specified by buf.
uint16_t packet_id_read_epoch(struct packet_id_net *p, struct buffer *buf)
Reads the packet ID containing both the epoch and the per-epoch counter from the buf.
static void packet_id_reap_test(struct packet_id_rec *p)
static void packet_id_persist_save_obj(struct packet_id_persist *p, const struct packet_id *pid)
static bool packet_id_initialized(const struct packet_id *pid)
Is this struct packet_id initialized?
static int packet_id_size(bool long_form)
Wrapper structure for dynamically allocated memory.
int capacity
Size in bytes of memory allocated by malloc().
uint8_t * data
Pointer to the allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
int offset
Offset in bytes of the actual content within the allocated memory.
Struct used in cipher name translation table.
const char * openvpn_name
Cipher name used by OpenVPN.
const char * lib_name
Cipher name used by crypto library.
Security parameter state for processing data channel packets.
struct key_ctx epoch_retiring_data_receive_key
The old key before the sender switched to a new epoch data key.
unsigned int flags
Bit-flags determining behavior of security operation functions.
struct packet_id_persist * pid_persist
Persistent packet ID state for keeping state between successive OpenVPN process startups.
struct key_ctx_bi key_ctx_bi
OpenSSL cipher and HMAC contexts for both sending and receiving directions.
struct packet_id_rec epoch_retiring_key_pid_recv
struct packet_id packet_id
Current packet ID state for both sending and receiving directions.
Packet geometry parameters.
int payload_size
the maximum size that a payload that our buffers can hold from either tun device or network link.
int headroom
the headroom in the buffer, this is choosen to allow all potential header to be added before the pack...
Garbage collection arena used to keep track of dynamically allocated memory.
Container for bidirectional cipher and HMAC key material.
int n
The number of key objects stored in the key2.keys array.
struct key keys[2]
Two unidirectional sets of key material.
Container for two sets of OpenSSL cipher and/or HMAC contexts for both sending and receiving directio...
struct key_ctx decrypt
cipher and/or HMAC contexts for receiving direction.
struct key_ctx encrypt
Cipher and/or HMAC contexts for sending direction.
Container for one set of cipher and/or HMAC contexts.
uint8_t implicit_iv[OPENVPN_MAX_IV_LENGTH]
This implicit IV will be always XORed with the packet id that is sent on the wire to get the IV.
uint16_t epoch
OpenVPN data channel epoch, this variable holds the epoch number this key belongs to.
uint64_t failed_verifications
number of failed verification using this cipher
cipher_ctx_t * cipher
Generic cipher context.
hmac_ctx_t * hmac
Generic HMAC context.
uint64_t plaintext_blocks
Counter for the number of plaintext block encrypted using this cipher with the current key in number ...
Key ordering of the key2.keys array.
int need_keys
The number of key objects necessary to support both sending and receiving.
int in_key
Index into the key2.keys array for the receiving direction.
int out_key
Index into the key2.keys array for the sending direction.
internal structure similar to struct key that holds key information but is not represented on wire an...
int hmac_size
Number of bytes set in the HMac key material.
int cipher_size
Number of bytes set in the cipher key material.
uint16_t epoch
the epoch of the key.
uint8_t hmac[MAX_HMAC_KEY_LENGTH]
Key material for HMAC operations.
uint8_t cipher[MAX_CIPHER_KEY_LENGTH]
Key material for cipher operations.
const char * cipher
const name of the cipher
const char * digest
Message digest static parameters.
Container for unidirectional cipher and HMAC key material.
uint8_t cipher[MAX_CIPHER_KEY_LENGTH]
Key material for cipher operations.
uint8_t hmac[MAX_HMAC_KEY_LENGTH]
Key material for HMAC operations.
Data structure for describing the packet id that is received/send to the network.
struct packet_id_send send
static int cleanup(void **state)