OpenVPN
|
#include "syshead.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <setjmp.h>
#include <cmocka.h>
#include "crypto.h"
#include "crypto_epoch.h"
#include "options.h"
#include "ssl_backend.h"
#include "mss.h"
#include "test_common.h"
Go to the source code of this file.
Data Structures | |
struct | epoch_test_state |
Functions | |
static void | crypto_pem_encode_decode_loopback (void **state) |
static void | test_translate_cipher (const char *ciphername, const char *openvpn_name) |
static void | test_cipher_names (const char *ciphername, const char *openvpn_name) |
static void | crypto_translate_cipher_names (void **state) |
static void | crypto_test_tls_prf (void **state) |
static void | crypto_test_hmac (void **state) |
static void | test_occ_mtu_calculation (void **state) |
static void | test_mssfix_mtu_calculation (void **state) |
void | crypto_test_aead_limits (void **state) |
void | crypto_test_hkdf_expand_testa1 (void **state) |
void | crypto_test_hkdf_expand_testa2 (void **state) |
void | crypto_test_hkdf_expand_testa3 (void **state) |
void | crypto_test_hkdf_expand_test_ovpn (void **state) |
void | crypto_test_ovpn_label_expand (void **state) |
void | crypto_test_ovpn_expand_openssl3 (void **state) |
static int | crypto_test_epoch_setup (void **state) |
static int | crypto_test_epoch_teardown (void **state) |
void | crypto_test_epoch_key_generation (void **state) |
void | crypto_test_epoch_key_rotation (void **state) |
void | crypto_test_epoch_key_receive_lookup (void **state) |
void | crypto_test_epoch_key_overflow (void **state) |
void | epoch_test_derive_data_key (void **state) |
int | main (void) |
Variables | |
static const char | testtext [] = "Dummy text to test PEM encoding" |
static const char * | ipsumlorem |
static uint8_t | testkey [20] = { 0x0b, 0x00 } |
static uint8_t | goodhash [20] |
|
static |
Definition at line 53 of file test_crypto.c.
References BLEN, BPTR, buf_set_read(), buf_set_write(), crypto_pem_decode(), crypto_pem_encode(), gc, gc_free(), gc_new(), buffer::len, and testtext.
Referenced by main().
void crypto_test_aead_limits | ( | void ** | state | ) |
Definition at line 456 of file test_crypto.c.
References cipher_get_aead_limits().
Referenced by main().
void crypto_test_epoch_key_generation | ( | void ** | state | ) |
Definition at line 709 of file test_crypto.c.
References CLEAR, epoch_test_state::co, key_ctx_bi::decrypt, epoch_key::epoch, key_ctx::epoch, crypto_options::epoch_data_keys_future, epoch_generate_future_receive_keys(), crypto_options::epoch_key_recv, crypto_options::epoch_key_send, free_key_ctx(), and crypto_options::key_ctx_bi.
Referenced by main().
void crypto_test_epoch_key_overflow | ( | void ** | state | ) |
Definition at line 829 of file test_crypto.c.
References epoch_test_state::co, key_ctx_bi::decrypt, key_ctx_bi::encrypt, epoch_key::epoch, key_ctx::epoch, crypto_options::epoch_data_keys_future, crypto_options::epoch_data_keys_future_count, crypto_options::epoch_key_recv, crypto_options::epoch_key_send, epoch_lookup_decrypt_key(), epoch_replace_update_recv_key(), i, and crypto_options::key_ctx_bi.
Referenced by main().
void crypto_test_epoch_key_receive_lookup | ( | void ** | state | ) |
Definition at line 770 of file test_crypto.c.
References epoch_test_state::co, key_ctx::epoch, epoch_lookup_decrypt_key(), epoch_replace_update_recv_key(), and crypto_options::epoch_retiring_data_receive_key.
Referenced by main().
void crypto_test_epoch_key_rotation | ( | void ** | state | ) |
Definition at line 733 of file test_crypto.c.
References epoch_test_state::co, key_ctx_bi::decrypt, key_ctx_bi::encrypt, epoch_key::epoch, key_ctx::epoch, epoch_iterate_send_key(), crypto_options::epoch_key_send, epoch_replace_update_recv_key(), crypto_options::epoch_retiring_data_receive_key, i, and crypto_options::key_ctx_bi.
Referenced by main().
|
static |
Definition at line 678 of file test_crypto.c.
References epoch_test_state::co, epoch_key::epoch, epoch_init_key_ctx(), epoch_test_state::gc, gc_new(), init_key_type(), and epoch_test_state::kt.
Referenced by main().
|
static |
Definition at line 698 of file test_crypto.c.
References epoch_test_state::co, free_epoch_key_ctx(), free_key_ctx_bi(), epoch_test_state::gc, gc_free(), and crypto_options::key_ctx_bi.
Referenced by main().
void crypto_test_hkdf_expand_test_ovpn | ( | void ** | state | ) |
void crypto_test_hkdf_expand_testa1 | ( | void ** | state | ) |
void crypto_test_hkdf_expand_testa2 | ( | void ** | state | ) |
void crypto_test_hkdf_expand_testa3 | ( | void ** | state | ) |
|
static |
Definition at line 183 of file test_crypto.c.
References goodhash, hmac_ctx_cleanup(), hmac_ctx_final(), hmac_ctx_free(), hmac_ctx_init(), hmac_ctx_new(), hmac_ctx_reset(), hmac_ctx_update(), ipsumlorem, md_kt_size(), and testkey.
Referenced by main().
void crypto_test_ovpn_expand_openssl3 | ( | void ** | state | ) |
Definition at line 664 of file test_crypto.c.
Referenced by main().
void crypto_test_ovpn_label_expand | ( | void ** | state | ) |
|
static |
Definition at line 151 of file test_crypto.c.
References ipsumlorem, and ssl_tls1_PRF().
Referenced by main().
|
static |
void epoch_test_derive_data_key | ( | void ** | state | ) |
Definition at line 873 of file test_crypto.c.
References key_parameters::cipher, key_parameters::cipher_size, epoch_key::epoch, epoch_data_key_derive(), key_parameters::hmac, key_parameters::hmac_size, and init_key_type().
Referenced by main().
int main | ( | void | ) |
Definition at line 898 of file test_crypto.c.
References crypto_pem_encode_decode_loopback(), crypto_test_aead_limits(), crypto_test_epoch_key_generation(), crypto_test_epoch_key_overflow(), crypto_test_epoch_key_receive_lookup(), crypto_test_epoch_key_rotation(), crypto_test_epoch_setup(), crypto_test_epoch_teardown(), crypto_test_hkdf_expand_test_ovpn(), crypto_test_hkdf_expand_testa1(), crypto_test_hkdf_expand_testa2(), crypto_test_hkdf_expand_testa3(), crypto_test_hmac(), crypto_test_ovpn_expand_openssl3(), crypto_test_ovpn_label_expand(), crypto_test_tls_prf(), crypto_translate_cipher_names(), epoch_test_derive_data_key(), openvpn_unit_test_setup(), test_mssfix_mtu_calculation(), and test_occ_mtu_calculation().
|
static |
Definition at line 95 of file test_crypto.c.
References gc, gc_free(), gc_new(), i, string_alloc(), and test_translate_cipher().
Referenced by crypto_translate_cipher_names().
|
static |
Definition at line 347 of file test_crypto.c.
References compress_options::alg, options::authname, options::ce, options::ciphername, options::comp, COMP_ALG_LZO, COMP_ALG_UNDEF, frame_calculate_dynamic(), gc, gc_free(), gc_new(), i, init_key_type(), frame::mss_fix, connection_entry::mssfix, options::peer_id, connection_entry::proto, PROTO_UDP, options::shared_secret_file, options::tls_client, connection_entry::tun_mtu, and options::use_peer_id.
Referenced by main().
|
static |
Definition at line 226 of file test_crypto.c.
References compress_options::alg, options::authname, calc_options_string_link_mtu(), options::ce, options::ciphername, options::comp, COMP_ALG_LZO, COMP_ALG_UNDEF, connection_entry::fragment, gc, gc_free(), gc_new(), connection_entry::proto, PROTO_TCP_CLIENT, PROTO_UDP, options::pull, options::shared_secret_file, connection_entry::socks_proxy_server, options::tls_auth_file, options::tls_client, and connection_entry::tun_mtu.
Referenced by main().
|
static |
Definition at line 79 of file test_crypto.c.
References cipher_kt_name(), cipher_valid(), and buffer::len.
Referenced by test_cipher_names().
|
static |
Definition at line 179 of file test_crypto.c.
Referenced by crypto_test_hmac().
|
static |
Definition at line 146 of file test_crypto.c.
Referenced by crypto_test_hmac(), and crypto_test_tls_prf().
|
static |
Definition at line 178 of file test_crypto.c.
Referenced by crypto_test_hmac().
|
static |
Definition at line 50 of file test_crypto.c.
Referenced by crypto_pem_encode_decode_loopback().