OpenVPN
|
Go to the source code of this file.
Data Structures | |
struct | tls_auth_standalone |
struct | tls_pre_decrypt_state |
struct that stores the temporary data for the tls lite decrypt functions More... | |
Macros | |
#define | P_KEY_ID_MASK 0x07 |
#define | P_OPCODE_SHIFT 3 |
#define | P_CONTROL_HARD_RESET_CLIENT_V1 1 /* initial key from client, forget previous state */ |
#define | P_CONTROL_HARD_RESET_SERVER_V1 2 /* initial key from server, forget previous state */ |
#define | P_CONTROL_SOFT_RESET_V1 3 /* new key, graceful transition from old to new key */ |
#define | P_CONTROL_V1 4 /* control channel packet (usually TLS ciphertext) */ |
#define | P_ACK_V1 5 /* acknowledgement for packets received */ |
#define | P_DATA_V1 6 /* data channel packet */ |
#define | P_DATA_V2 9 /* data channel packet with peer-id */ |
#define | P_CONTROL_HARD_RESET_CLIENT_V2 7 /* initial key from client, forget previous state */ |
#define | P_CONTROL_HARD_RESET_SERVER_V2 8 /* initial key from server, forget previous state */ |
#define | P_CONTROL_HARD_RESET_CLIENT_V3 10 /* initial key from client, forget previous state */ |
#define | P_CONTROL_WKC_V1 11 |
#define | P_FIRST_OPCODE 3 |
#define | P_LAST_OPCODE 11 |
#define | TLS_RELIABLE_N_SEND_BUFFERS 6 /* also window size for reliability layer */ |
#define | TLS_RELIABLE_N_REC_BUFFERS 12 |
#define | EARLY_NEG_MASK 0xff000000 |
#define | EARLY_NEG_START 0x0f000000 |
#define | TLV_TYPE_EARLY_NEG_FLAGS 0x0001 |
#define | EARLY_NEG_FLAG_RESEND_WKC 0x0001 |
Enumerations | |
enum | first_packet_verdict { VERDICT_VALID_RESET_V2, VERDICT_VALID_RESET_V3, VERDICT_VALID_CONTROL_V1, VERDICT_VALID_ACK_V1, VERDICT_VALID_WKC_V1, VERDICT_INVALID } |
Functions | |
void | free_tls_pre_decrypt_state (struct tls_pre_decrypt_state *state) |
enum first_packet_verdict | tls_pre_decrypt_lite (const struct tls_auth_standalone *tas, struct tls_pre_decrypt_state *state, const struct link_socket_actual *from, const struct buffer *buf) |
Inspect an incoming packet for which no VPN tunnel is active, and determine whether a new VPN tunnel should be created. More... | |
hmac_ctx_t * | session_id_hmac_init (void) |
struct session_id | calculate_session_id_hmac (struct session_id client_sid, const struct openvpn_sockaddr *from, hmac_ctx_t *hmac, int handwindow, int offset) |
Calculates the HMAC based server session id based on a client session id and socket addr. More... | |
bool | check_session_id_hmac (struct tls_pre_decrypt_state *state, const struct openvpn_sockaddr *from, hmac_ctx_t *hmac, int handwindow) |
Checks if a control packet has a correct HMAC server session id. More... | |
void | write_control_auth (struct tls_session *session, struct key_state *ks, struct buffer *buf, struct link_socket_actual **to_link_addr, int opcode, int max_ack, bool prepend_ack) |
bool | read_control_auth (struct buffer *buf, struct tls_wrap_ctx *ctx, const struct link_socket_actual *from, const struct tls_options *opt) |
struct buffer | tls_reset_standalone (struct tls_wrap_ctx *ctx, struct tls_auth_standalone *tas, struct session_id *own_sid, struct session_id *remote_sid, uint8_t header, bool request_resend_wkc) |
This function creates a reset packet using the information from the tls pre decrypt state. More... | |
static const char * | packet_opcode_name (int op) |
static struct tls_wrap_ctx * | tls_session_get_tls_wrap (struct tls_session *session, int key_id) |
Determines if the current session should use the renegotiation tls wrap struct instead the normal one and returns it. More... | |
#define P_ACK_V1 5 /* acknowledgement for packets received */ |
#define P_CONTROL_HARD_RESET_CLIENT_V1 1 /* initial key from client, forget previous state */ |
#define P_CONTROL_HARD_RESET_CLIENT_V2 7 /* initial key from client, forget previous state */ |
#define P_CONTROL_HARD_RESET_CLIENT_V3 10 /* initial key from client, forget previous state */ |
#define P_CONTROL_HARD_RESET_SERVER_V1 2 /* initial key from server, forget previous state */ |
#define P_CONTROL_HARD_RESET_SERVER_V2 8 /* initial key from server, forget previous state */ |
#define P_CONTROL_V1 4 /* control channel packet (usually TLS ciphertext) */ |
#define TLS_RELIABLE_N_SEND_BUFFERS 6 /* also window size for reliability layer */ |
enum first_packet_verdict |
struct session_id calculate_session_id_hmac | ( | struct session_id | client_sid, |
const struct openvpn_sockaddr * | from, | ||
hmac_ctx_t * | hmac, | ||
int | handwindow, | ||
int | offset | ||
) |
Calculates the HMAC based server session id based on a client session id and socket addr.
client_sid | session id of the client |
from | link_socket from the client |
hmac | the hmac context to use for the calculation |
handwindow | the quantisation of the current time |
offset | offset to 'now' to use |
Definition at line 487 of file ssl_pkt.c.
References hmac_ctx_final(), hmac_ctx_reset(), hmac_ctx_update(), now, SHA256_DIGEST_LENGTH, and SID_SIZE.
Referenced by check_session_id_hmac(), do_pre_decrypt_check(), and test_calc_session_id_hmac_static().
bool check_session_id_hmac | ( | struct tls_pre_decrypt_state * | state, |
const struct openvpn_sockaddr * | from, | ||
hmac_ctx_t * | hmac, | ||
int | handwindow | ||
) |
Checks if a control packet has a correct HMAC server session id.
client_sid | session id of the client |
from | link_socket from the client |
hmac | the hmac context to use for the calculation |
handwindow | the quantisation of the current time |
Definition at line 529 of file ssl_pkt.c.
References calculate_session_id_hmac(), memcmp_constant_time(), tls_pre_decrypt_state::newbuf, tls_pre_decrypt_state::peer_session_id, reliable_ack_parse(), tls_pre_decrypt_state::server_session_id, and SID_SIZE.
Referenced by do_pre_decrypt_check(), test_verify_hmac_none(), and test_verify_hmac_tls_auth().
void free_tls_pre_decrypt_state | ( | struct tls_pre_decrypt_state * | state | ) |
state |
Definition at line 285 of file ssl_pkt.c.
References tls_wrap_ctx::cleanup_key_ctx, free_buf(), free_key_ctx_bi(), crypto_options::key_ctx_bi, tls_pre_decrypt_state::newbuf, tls_wrap_ctx::opt, tls_wrap_ctx::tls_crypt_v2_metadata, and tls_pre_decrypt_state::tls_wrap_tmp.
Referenced by multi_get_create_instance_udp(), test_generate_reset_packet_plain(), test_generate_reset_packet_tls_auth(), test_tls_decrypt_lite_auth(), test_tls_decrypt_lite_crypt(), test_tls_decrypt_lite_none(), test_verify_hmac_none(), and test_verify_hmac_tls_auth().
|
inlinestatic |
Definition at line 234 of file ssl_pkt.h.
References P_ACK_V1, P_CONTROL_HARD_RESET_CLIENT_V1, P_CONTROL_HARD_RESET_CLIENT_V2, P_CONTROL_HARD_RESET_CLIENT_V3, P_CONTROL_HARD_RESET_SERVER_V1, P_CONTROL_HARD_RESET_SERVER_V2, P_CONTROL_SOFT_RESET_V1, P_CONTROL_V1, P_CONTROL_WKC_V1, P_DATA_V1, and P_DATA_V2.
Referenced by do_pre_decrypt_check(), protocol_dump(), tls_pre_decrypt(), and write_control_auth().
bool read_control_auth | ( | struct buffer * | buf, |
struct tls_wrap_ctx * | ctx, | ||
const struct link_socket_actual * | from, | ||
const struct tls_options * | opt | ||
) |
Definition at line 200 of file ssl_pkt.c.
References alloc_buf_gc(), ASSERT, BPTR, buf_advance(), buf_clear(), buf_copy(), buf_forward_capacity_total(), buf_init, key_ctx::cipher, cleanup(), clear_buf(), D_TLS_ERRORS, gc_free(), gc_new(), buffer::len, tls_wrap_ctx::mode, msg, buffer::offset, openvpn_decrypt(), tls_wrap_ctx::opt, P_CONTROL_HARD_RESET_CLIENT_V3, P_CONTROL_WKC_V1, P_OPCODE_SHIFT, print_link_socket_actual(), SID_SIZE, swap_hmac(), tls_crypt_unwrap(), tls_crypt_v2_extract_client_key(), and tls_wrap_ctx::tls_crypt_v2_server_key.
Referenced by tls_pre_decrypt(), and tls_pre_decrypt_lite().
hmac_ctx_t* session_id_hmac_init | ( | void | ) |
Definition at line 473 of file ssl_pkt.c.
References ASSERT, hmac_ctx_init(), hmac_ctx_new(), md_valid(), rand_bytes(), and SHA256_DIGEST_LENGTH.
Referenced by do_init_crypto_tls(), test_verify_hmac_none(), and test_verify_hmac_tls_auth().
struct buffer tls_reset_standalone | ( | struct tls_wrap_ctx * | ctx, |
struct tls_auth_standalone * | tas, | ||
struct session_id * | own_sid, | ||
struct session_id * | remote_sid, | ||
uint8_t | header, | ||
bool | request_resend_wkc | ||
) |
This function creates a reset packet using the information from the tls pre decrypt state.
Definition at line 428 of file ssl_pkt.c.
References ASSERT, frame::buf, buf_init, buf_write(), buf_write_u16(), buf_write_u32(), buf_write_u8(), EARLY_NEG_FLAG_RESEND_WKC, tls_auth_standalone::frame, frame::headroom, htonpid, session_id::id, SID_SIZE, tls_wrap_control(), TLV_TYPE_EARLY_NEG_FLAGS, and tls_auth_standalone::workbuf.
Referenced by send_hmac_reset_packet(), test_generate_reset_packet_plain(), and test_generate_reset_packet_tls_auth().
|
inlinestatic |
Determines if the current session should use the renegotiation tls wrap struct instead the normal one and returns it.
session | |
key_id | key_id of the received/or to be send packet |
Definition at line 285 of file ssl_pkt.h.
References tls_wrap_ctx::TLS_WRAP_CRYPT.
Referenced by tls_pre_decrypt(), and write_control_auth().
void write_control_auth | ( | struct tls_session * | session, |
struct key_state * | ks, | ||
struct buffer * | buf, | ||
struct link_socket_actual ** | to_link_addr, | ||
int | opcode, | ||
int | max_ack, | ||
bool | prepend_ack | ||
) |
Definition at line 168 of file ssl_pkt.c.
References ASSERT, CO_USE_TLS_KEY_MATERIAL_EXPORT, D_TLS_DEBUG, key_state::key_id, link_socket_actual_defined(), key_state::lru_acks, min_int(), msg, P_OPCODE_SHIFT, packet_opcode_name(), key_state::rec_ack, reliable_ack_write(), key_state::remote_addr, key_state::session_id_remote, tls_session_get_tls_wrap(), and tls_wrap_control().
Referenced by tls_process(), and tls_process_state().