Go to the documentation of this file.
69 uint8_t *mac_out = NULL;
117 "ENCRYPT: buffer size error, bc=%d bo=%d bl=%d wc=%d wo=%d wl=%d",
160 if (buf->
len > 0 && opt)
163 uint8_t *mac_out = NULL;
164 const uint8_t *hmac_start = NULL;
178 hmac_start =
BEND(&work);
224 msg(
D_CRYPT_ERRORS,
"ENCRYPT: buffer size error, bc=%d bo=%d bl=%d wc=%d wo=%d wl=%d cbs=%d",
245 || outlen == iv_size);
258 hmac_start =
BPTR(buf);
298 if (buf->
len > 0 && opt)
332 "see the man page entry for --replay-window for "
333 "more info or silence this warning with --mute-replay-warnings",
351 const uint8_t *ad_start)
353 static const char error_prefix[] =
"AEAD Decrypt error";
356 uint8_t *tag_ptr = NULL;
389 memcpy(iv,
BPTR(buf), packet_iv_len);
409 if (buf->
len < tag_size)
432 const int ad_size =
BPTR(buf) - ad_start - tag_size;
446 &outlen, tag_ptr, tag_size))
484 static const char error_prefix[] =
"Authenticate/Decrypt packet error";
488 if (buf->
len > 0 && opt)
492 bool have_pin =
false;
509 if (buf->
len < hmac_len)
538 if (buf->
len < iv_size)
542 memcpy(iv_buf,
BPTR(buf), iv_size);
647 const uint8_t *ad_start)
651 if (buf->
len > 0 && opt)
671 unsigned int pkt_id_size,
674 unsigned int crypto_overhead = 0;
679 crypto_overhead += pkt_id_size;
715 return crypto_overhead;
731 msg(
M_WARN,
"WARNING: INSECURE cipher (%s) with block size less than 128"
732 " bit (%d bit). This allows attacks like SWEET32. Mitigate by "
733 "using a --cipher with a larger block size (e.g. AES-256-CBC). "
734 "Support for these insecure ciphers will be removed in "
745 const char *authname,
bool tls_mode,
bool warn)
747 bool aead_cipher =
false;
754 if (strcmp(ciphername,
"none") != 0)
758 msg(
M_FATAL,
"Cipher %s not supported", ciphername);
764 || (tls_mode && aead_cipher)
770 msg(
M_FATAL,
"Cipher '%s' mode not supported", ciphername);
775 msg(
M_FATAL,
"Cipher '%s' not allowed: block size too big.", ciphername);
786 msg(
M_WARN,
"******* WARNING *******: '--cipher none' was specified. "
787 "This means NO encryption will be performed and tunnelled "
788 "data WILL be transmitted in clear text over the network! "
789 "PLEASE DO RECONSIDER THIS SETTING!");
793 if (strcmp(authname,
"none") != 0)
805 msg(
M_FATAL,
"HMAC '%s' not allowed: digest size too big.", authname);
809 else if (!aead_cipher)
813 msg(
M_WARN,
"******* WARNING *******: '--auth none' was specified. "
814 "This means no authentication will be performed on received "
815 "packets, meaning you CANNOT trust that the data received by "
816 "the remote side have NOT been manipulated. "
817 "PLEASE DO RECONSIDER THIS SETTING!");
853 "%s: Using %d bit message hash '%s' for HMAC authentication",
870 int key_direction,
const struct key_type *kt,
const char *name)
872 char log_prefix[128] = { 0 };
877 snprintf(log_prefix,
sizeof(log_prefix),
"Outgoing %s", name);
881 snprintf(log_prefix,
sizeof(log_prefix),
"Incoming %s", name);
916 for (
int i = 0; i < cipher_length; ++i)
961 msg(
M_FATAL,
"ERROR: Random number generator cannot obtain entropy for key generation");
1038 msg(
M_INFO,
"TESTING ENCRYPT/DECRYPT of packet length=%d", i);
1052 memcpy(buf_p,
BPTR(&src),
BLEN(&src));
1068 for (j = 0; j < i; ++j)
1070 const uint8_t in = *(
BPTR(&src) + j);
1071 const uint8_t out = *(
BPTR(&buf) + j);
1074 msg(
M_FATAL,
"SELF TEST FAILED, pos=%d in=%d out=%d", j, in, out);
1087 return "[[INLINE]]";
1095 struct key_ctx_bi *ctx,
const char *key_file,
1096 bool key_inline,
const int key_direction,
1097 const char *key_name,
const char *opt_name,
1098 struct key2 *keydata)
1112 msg(
M_ERR,
"File '%s' does not have OpenVPN Static Key format. Using "
1113 "free-form passphrase file is not supported anymore.",
1138 "Non-Hex character ('%c') found at line %d in key file '%s' (%d/%d/%d bytes found/min/max)";
1141 "Non-Hex, unprintable character (0x%02x) found at line %d in key file '%s' (%d/%d/%d bytes found/min/max)";
1151 uint8_t hex_byte[3] = {0, 0, 0};
1154 const unsigned char *cp;
1161 uint8_t *out = (uint8_t *) &
key2->
keys;
1162 const int keylen =
sizeof(
key2->
keys);
1166 #define PARSE_INITIAL 0
1167 #define PARSE_HEAD 1
1168 #define PARSE_DATA 2
1169 #define PARSE_DATA_COMPLETE 3
1170 #define PARSE_FOOT 4
1171 #define PARSE_FINISHED 5
1177 const int onekeylen =
sizeof(
key2->
keys[0]);
1187 size = strlen(file) + 1;
1195 msg(
M_FATAL,
"Read error on key file ('%s')", file);
1201 cp = (
unsigned char *)in.
data;
1204 const unsigned char c = *cp;
1207 msg(
M_INFO,
"char='%c'[%d] s=%d ln=%d li=%d m=%d c=%d",
1208 c, (
int)c, state, line_num, line_index, match, count);
1213 line_index = match = 0;
1239 if (++match == hlen)
1251 if (++match == flen)
1263 ASSERT(hb_index >= 0 && hb_index < 2);
1264 hex_byte[hb_index++] = c;
1268 ASSERT(sscanf((
const char *)hex_byte,
"%x", &u) == 1);
1271 if (++count == keylen)
1277 else if (isspace(c))
1299 key2->
n = count / onekeylen;
1307 msg(
M_FATAL,
"Insufficient key material or header text not found in file '%s' (%d/%d/%d bytes found/min/max)",
1314 msg(
M_FATAL,
"Footer text not found in file '%s' (%d/%d/%d bytes found/min/max)",
1330 printf(
"KEY READ, n=%d\n",
key2->
n);
1340 printf(
"[%d]\n%s\n\n", i, fmt);
1354 int nbits = nkeys *
sizeof(
struct key) * 8;
1360 const int bytes_per_line = 16;
1363 buf_printf(&out,
"#\n# %d bit OpenVPN static key\n#\n", nbits);
1366 for (
int i = 0; i < nkeys; ++i)
1393 if (!filename || strcmp(filename,
"")==0)
1395 printf(
"%.*s\n",
BLEN(&out),
BPTR(&out));
1418 msg(
M_FATAL,
"Key file '%s' used in --%s contains insufficient key material [keys found=%d required=%d]", filename, option,
key2->
n, n);
1420 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);
1432 else if (!strcmp(str,
"0"))
1436 else if (!strcmp(str,
"1"))
1442 msg(msglevel,
"Unknown key direction '%s' -- must be '0' or '1'", str);
1464 return remote ?
"1" :
"0";
1468 return remote ?
"0" :
"1";
1481 switch (key_direction)
1511 for (i = 0; i <
key2->
n; ++i)
1516 msg(
M_FATAL,
"Key #%d in '%s' is bad. Try making a new key with --genkey.",
1517 i+1, shared_secret_file);
1563 uint8_t cipher_length;
1564 uint8_t hmac_length;
1567 if (!
buf_read(buf, &cipher_length, 1))
1571 if (!
buf_read(buf, &hmac_length, 1))
1598 "TLS Error: key length mismatch, local cipher/hmac %d/%d, remote cipher/hmac %d/%d",
1625 printf(
"%s (%d bit key, ",
1631 printf(
"stream cipher");
1640 printf(
", TLS client/server mode only");
1646 printf(
", %s", reason);
1663 || 0 == strcmp(cipher_name, pair->
lib_name))
1703 struct key server_key = { 0 };
1707 if (!
rand_bytes((
void *)&server_key,
sizeof(server_key)))
1712 buf_set_read(&server_key_buf, (
void *)&server_key,
sizeof(server_key));
1714 &server_key_buf, &gc))
1716 msg(
M_WARN,
"ERROR: could not PEM-encode key");
1720 if (!filename || strcmp(filename,
"")==0)
1722 printf(
"%.*s",
BLEN(&server_key_pem),
BPTR(&server_key_pem));
1726 msg(
M_ERR,
"ERROR: could not write key file");
1742 msg(
M_INFO,
"Using random %s.", key_name);
1746 msg(
M_WARN,
"ERROR: could not generate random key");
1757 const char *key_file,
bool key_inline)
1760 struct buffer key_pem = { 0 };
1768 msg(
M_WARN,
"ERROR: failed to read %s file (%s)",
1769 pem_name, key_file);
1775 buf_set_read(&key_pem, (
const void *)key_file, strlen(key_file) + 1);
1780 msg(
M_WARN,
"ERROR: %s pem decode failed", pem_name);
1801 const char *seed =
"tls1-prf-test";
1802 const char *secret =
"tls1-prf-test-secret";
1804 uint8_t expected_out[] = {
'q',
'D',
'\xfe',
'%',
'@',
's',
'u',
'\x95' };
1806 int ret =
ssl_tls1_PRF((uint8_t *)seed, (
int) strlen(seed),
1807 (uint8_t *)secret, (
int) strlen(secret),
1810 return (ret && memcmp(out, expected_out,
sizeof(out)) == 0);
static bool buf_safe(const struct buffer *buf, size_t len)
bool buffer_write_file(const char *filename, const struct buffer *buf)
Write buffer contents to file.
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
void must_have_n_keys(const char *filename, const char *option, const struct key2 *key2, int n)
static const char static_key_foot[]
cipher_ctx_t * cipher_ctx_new(void)
Generic cipher functions.
int write_key_file(const int nkeys, const char *filename)
Write nkeys 1024-bits keys to file.
int out_key
Index into the key2.keys array for the sending direction.
static bool cipher_valid(const char *ciphername)
Returns if the cipher is valid, based on the given cipher name.
int n
The number of key objects stored in the key2.keys array.
void hmac_ctx_cleanup(hmac_ctx_t *ctx)
#define OPENVPN_MODE_CBC
Cipher is in CBC mode.
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.
static bool buf_read(struct buffer *src, void *dest, int size)
#define KEY_DIRECTION_BIDIRECTIONAL
static struct gc_arena gc_new(void)
#define OPENVPN_AEAD_MIN_IV_LEN
Minimal IV length for AEAD mode ciphers (in bytes): 4-byte packet id + 8 bytes implicit IV.
int len
Length in bytes of the actual content within the allocated memory.
static bool cipher_defined(const char *ciphername)
Checks if the cipher is defined and is not the null (none) cipher.
#define KEY_DIRECTION_NORMAL
const char * translate_cipher_name_to_openvpn(const char *cipher_name)
Translate a crypto library cipher name to an OpenVPN cipher name.
#define buf_init(buf, offset)
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.
long int get_random(void)
const char * keydirection2ascii(int kd, bool remote, bool humanreadable)
int capacity
Size in bytes of memory allocated by malloc().
struct buffer alloc_buf_gc(size_t size, struct gc_arena *gc)
cipher_ctx_t * cipher
Generic cipher context.
void print_cipher(const char *ciphername)
Print a cipher list entry.
void buf_clear(struct buffer *buf)
void prng_bytes(uint8_t *output, int len)
struct key_ctx encrypt
Cipher and/or HMAC contexts for sending direction.
const char * print_key_filename(const char *str, bool is_inline)
To be used when printing a string that may contain inline data.
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.
#define KEY_DIRECTION_INVERSE
static bool packet_id_initialized(const struct packet_id *pid)
Is this struct packet_id initialized?
bool cipher_ctx_mode_cbc(const cipher_ctx_t *ctx)
Check if the supplied cipher is a supported CBC mode cipher.
char * format_hex_ex(const uint8_t *data, int size, int maxoutput, unsigned int space_break_flags, const char *separator, struct gc_arena *gc)
void hmac_ctx_update(hmac_ctx_t *ctx, const uint8_t *src, int src_len)
static struct buffer clear_buf(void)
Return an empty struct buffer.
int ascii2keydirection(int msglevel, const char *str)
void key_direction_state_init(struct key_direction_state *kds, int key_direction)
const char * translate_cipher_name_from_openvpn(const char *cipher_name)
Translate an OpenVPN cipher name to a crypto library cipher name.
static void openvpn_encrypt_v1(struct buffer *buf, struct buffer work, struct crypto_options *opt)
const char * cipher_kt_name(const char *ciphername)
Retrieve a normalised string describing the cipher (e.g.
uint8_t hmac[MAX_HMAC_KEY_LENGTH]
Key material for HMAC operations.
Packet geometry parameters.
#define MAX_CIPHER_KEY_LENGTH
static const char printable_char_fmt[]
bool packet_id_test(struct packet_id_rec *p, const struct packet_id_net *pin)
bool cipher_ctx_mode_ofb_cfb(const cipher_ctx_t *ctx)
Check if the supplied cipher is a supported OFB or CFB mode cipher.
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.
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)
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)
Container for unidirectional cipher and HMAC key material.
static const char * np(const char *str)
static const char unprintable_char_fmt[]
void cipher_ctx_free(cipher_ctx_t *ctx)
Cleanup and free a cipher context.
void test_crypto(struct crypto_options *co, struct frame *frame)
int cipher_kt_block_size(const char *ciphername)
Returns the block size of the cipher, in bytes.
const cipher_name_pair cipher_name_translation_table[]
Cipher name translation table.
void free_key_ctx_bi(struct key_ctx_bi *ctx)
Container for two sets of OpenSSL cipher and/or HMAC contexts for both sending and receiving directio...
#define OPENVPN_MAX_CIPHER_BLOCK_SIZE
static void secure_memzero(void *data, size_t len)
Securely zeroise memory.
#define MAX_HMAC_KEY_LENGTH
#define ENABLE_OFB_CFB_MODE
static bool buf_advance(struct buffer *buf, int size)
const char * md_kt_name(const char *mdname)
Retrieve a string describing the digest digest (e.g.
static bool buf_inc_len(struct buffer *buf, int inc)
#define OPENVPN_AEAD_TAG_LENGTH
static void packet_id_persist_save_obj(struct packet_id_persist *p, const struct packet_id *pid)
Key ordering of the key2.keys array.
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.
const char * openvpn_name
Cipher name used by OpenVPN.
const char * digest
Message digest static parameters.
static bool buf_write_prepend(struct buffer *dest, const void *src, int size)
int payload_size
the maximum size that a payload that our buffers can hold from either tun device or network link.
static void update_time(void)
mbedtls_cipher_context_t cipher_ctx_t
Generic cipher context.
static void generate_key_random(struct key *key)
void init_key_ctx(struct key_ctx *ctx, const struct key *key, const struct key_type *kt, int enc, const char *prefix)
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...
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...
#define OPENVPN_MAX_HMAC_SIZE
Container for one set of cipher and/or HMAC contexts.
void cipher_ctx_init(cipher_ctx_t *ctx, const uint8_t *key, const char *cipername, crypto_operation_t enc)
Initialise a cipher context, based on the given key and key type.
int in_key
Index into the key2.keys array for the receiving direction.
#define CO_MUTE_REPLAY_WARNINGS
Bit-flag indicating not to display replay warnings.
void crypto_clear_error(void)
int cipher_ctx_mode(const cipher_ctx_t *ctx)
Returns the mode that the cipher runs in.
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.
unsigned char md_kt_size(const char *mdname)
Returns the size of the message digest, in bytes.
static bool buf_valid(const struct buffer *buf)
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...
bool check_key(struct key *key, const struct key_type *kt)
bool generate_ephemeral_key(struct buffer *key, const char *key_name)
Generate ephermal key material into the key structure.
void hmac_ctx_final(hmac_ctx_t *ctx, uint8_t *dst)
bool cipher_kt_mode_aead(const char *ciphername)
Check if the supplied cipher is a supported AEAD mode cipher.
bool packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
bool cipher_ctx_mode_aead(const cipher_ctx_t *ctx)
Check if the supplied cipher is a supported AEAD mode cipher.
void packet_id_add(struct packet_id_rec *p, const struct packet_id_net *pin)
const size_t cipher_name_translation_table_count
Wrapper structure for dynamically allocated memory.
const char * packet_id_net_print(const struct packet_id_net *pin, bool print_timestamp, struct gc_arena *gc)
void verify_fix_key2(struct key2 *key2, const struct key_type *kt, const char *shared_secret_file)
#define OPENVPN_MAX_IV_LENGTH
Maximum length of an IV.
size_t implicit_iv_len
The length of implicit_iv.
void hmac_ctx_reset(hmac_ctx_t *ctx)
int rand_bytes(uint8_t *output, int len)
Wrapper for secure random number generator.
void hmac_ctx_free(hmac_ctx_t *ctx)
Struct used in cipher name translation table.
static bool buf_write(struct buffer *dest, const void *src, size_t size)
int cipher_ctx_block_size(const cipher_ctx_t *ctx)
Returns the block size of the cipher, in bytes.
int need_keys
The number of key objects necessary to support both sending and receiving.
uint8_t implicit_iv[OPENVPN_MAX_IV_LENGTH]
The implicit part of the IV.
bool cipher_kt_mode_ofb_cfb(const char *ciphername)
Check if the supplied cipher is a supported OFB or CFB mode cipher.
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.
static void packet_id_reap_test(struct packet_id_rec *p)
bool cipher_kt_insecure(const char *ciphername)
Returns true if we consider this cipher to be insecure.
Garbage collection arena used to keep track of dynamically allocated memory.
bool crypto_pem_encode(const char *name, struct buffer *dst, const struct buffer *src, struct gc_arena *gc)
Encode binary data as PEM.
static void buf_set_write(struct buffer *buf, uint8_t *data, int size)
const char * cipher
const name of the cipher
int read_key(struct key *key, const struct key_type *kt, struct buffer *buf)
#define PARSE_DATA_COMPLETE
int offset
Offset in bytes of the actual content within the allocated memory.
static const cipher_name_pair * get_cipher_name_pair(const char *cipher_name)
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.
#define CRYPT_ERROR(format)
#define OPENVPN_OP_ENCRYPT
Cipher should encrypt.
static uint8_t * buf_prepend(struct buffer *buf, int size)
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.
int memcmp_constant_time(const void *a, const void *b, size_t size)
As memcmp(), but constant-time.
void free_key_ctx(struct key_ctx *ctx)
bool crypto_check_replay(struct crypto_options *opt, const struct packet_id_net *pin, const char *error_prefix, struct gc_arena *gc)
Check packet ID for replay, and perform replay administration.
int cipher_kt_tag_size(const char *ciphername)
Returns the MAC tag size of the cipher, in bytes.
unsigned int crypto_max_overhead(void)
Return the worst-case OpenVPN crypto overhead (in bytes)
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.
static int max_int(int x, int y)
struct packet_id_send send
static bool key_is_zero(struct key *key, const struct key_type *kt)
#define D_SHOW_KEY_SOURCE
static int packet_id_size(bool long_form)
static void key_print(const struct key *key, const struct key_type *kt, const char *prefix)
bool crypto_pem_decode(const char *name, struct buffer *dst, const struct buffer *src)
Decode a PEM buffer to binary data.
#define CO_PACKET_ID_LONG_FORM
Bit-flag indicating whether to use OpenVPN's long packet ID format.
static void gc_free(struct gc_arena *a)
static bool md_defined(const char *mdname)
Checks if the cipher is defined and is not the null (none) cipher.
bool write_key(const struct key *key, const struct key_type *kt, struct buffer *buf)
bool cipher_kt_mode_cbc(const char *ciphername)
Check if the supplied cipher is a supported CBC mode cipher.
uint8_t cipher[MAX_CIPHER_KEY_LENGTH]
Key material for cipher operations.
struct key_ctx_bi key_ctx_bi
OpenSSL cipher and HMAC contexts for both sending and receiving directions.
static uint8_t * buf_write_alloc(struct buffer *buf, size_t size)
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.
hmac_ctx_t * hmac_ctx_new(void)
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 read_key_file(struct key2 *key2, const char *file, const unsigned int flags)
static void gc_init(struct gc_arena *a)
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.
Container for bidirectional cipher and HMAC key material.
#define OPENVPN_OP_DECRYPT
Cipher should decrypt.
static bool openvpn_decrypt_v1(struct buffer *buf, struct buffer work, struct crypto_options *opt, const struct frame *frame)
static char * format_hex(const uint8_t *data, int size, int maxoutput, struct gc_arena *gc)
#define CO_IGNORE_PACKET_ID
Bit-flag indicating whether to ignore the packet ID of a received packet.
static void openvpn_encrypt_aead(struct buffer *buf, struct buffer work, struct crypto_options *opt)
void hmac_ctx_init(hmac_ctx_t *ctx, const uint8_t *key, const char *mdname)
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.
struct packet_id packet_id
Current packet ID state for both sending and receiving directions.
hmac_ctx_t * hmac
Generic HMAC context.
unsigned int flags
Bit-flags determining behavior of security operation functions.
struct key keys[2]
Two unidirectional sets of key material.
struct packet_id_persist * pid_persist
Persistent packet ID state for keeping state between successive OpenVPN process startups.
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.
const char * lib_name
Cipher name used by crypto library.
struct key_ctx decrypt
cipher and/or HMAC contexts for receiving direction.
static void warn_insecure_key_type(const char *ciphername)
bool buf_printf(struct buffer *buf, const char *format,...)
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.
static const char static_key_head[]
static void buf_set_read(struct buffer *buf, const uint8_t *data, size_t size)
int headroom
the headroom in the buffer, this is choosen to allow all potential header to be added before the pack...
int hmac_ctx_size(hmac_ctx_t *ctx)
Security parameter state for processing data channel packets.
uint8_t * data
Pointer to the allocated memory.
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...
static int cleanup(void **state)