OpenVPN
Data Structures | Functions
ssl_util.h File Reference

SSL utility functions. More...

#include "buffer.h"
Include dependency graph for ssl_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tls_cipher_name_pair
 Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name. More...
 

Functions

char * extract_var_peer_info (const char *peer_info, const char *var, struct gc_arena *gc)
 Extracts a variable from peer info, the returned string will be allocated using the supplied gc_arena.
 
unsigned int extract_iv_proto (const char *peer_info)
 Extracts the IV_PROTO variable and returns its value or 0 if it cannot be extracted.
 
const char * options_string_compat_lzo (const char *options, struct gc_arena *gc)
 Takes a locally produced OCC string for TLS server mode and modifies as if the option comp-lzo was enabled.
 
const tls_cipher_name_pairtls_get_cipher_name_pair (const char *cipher_name, size_t len)
 
int get_num_elements (const char *string, char delimiter)
 Returns the occurrences of 'delimiter' in a string +1 This is typically used to find out the number elements in a cipher string or similar that is separated by : like.
 

Detailed Description

SSL utility functions.

This file (and its .c file) is designed to to be included in units/etc without pulling in a lot of dependencies.

Definition in file ssl_util.h.

Function Documentation

◆ extract_iv_proto()

unsigned int extract_iv_proto ( const char *  peer_info)

Extracts the IV_PROTO variable and returns its value or 0 if it cannot be extracted.

Parameters
peer_infopeer info string to search for IV_PROTO

Definition at line 62 of file ssl_util.c.

Referenced by multi_client_set_protocol_options(), p2p_ncp_set_options(), and send_auth_pending_messages().

◆ extract_var_peer_info()

char * extract_var_peer_info ( const char *  peer_info,
const char *  var,
struct gc_arena gc 
)

Extracts a variable from peer info, the returned string will be allocated using the supplied gc_arena.

Parameters
peer_infoThe peer's peer_info
varThe variable including =, e.g. IV_CIPHERS=
gcGC arena to allocate return value in
Returns
The content of the variable as NULL terminated string or NULL if the variable cannot be found.

Definition at line 32 of file ssl_util.c.

References gc, and string_alloc().

Referenced by check_auth_pending_method(), get_p2p_ncp_cipher(), prepare_push_reply(), and tls_peer_ncp_list().

◆ get_num_elements()

int get_num_elements ( const char *  string,
char  delimiter 
)

Returns the occurrences of 'delimiter' in a string +1 This is typically used to find out the number elements in a cipher string or similar that is separated by : like.

X25519:secp256r1:X448:secp512r1:secp384r1:brainpoolP384r1

Parameters
stringthe string to work on
delimiterthe delimiter to count, typically ':'
Returns
occrrences of delimiter + 1

Definition at line 284 of file ssl_util.c.

References ASSERT, and buffer::len.

Referenced by tls_ctx_set_tls_groups().

◆ options_string_compat_lzo()

const char * options_string_compat_lzo ( const char *  options,
struct gc_arena gc 
)

Takes a locally produced OCC string for TLS server mode and modifies as if the option comp-lzo was enabled.

This is to send a client in comp-lzo migrate mode the expected OCC string.

Note: This function expects the string to be in the locally generated format and does not accept arbitrary strings.

Parameters
optionsthe locally generated OCC string
gcgc_arena to allocate the returned string in
Returns
the modified string or options on error

Definition at line 78 of file ssl_util.c.

References alloc_buf_gc(), BSTR, buf_printf(), buf_write(), gc, and buffer::len.

Referenced by key_method_2_read(), and test_compat_lzo_string().

◆ tls_get_cipher_name_pair()

const tls_cipher_name_pair * tls_get_cipher_name_pair ( const char *  cipher_name,
size_t  len 
)