|
OpenVPN
|
SSL utility functions. More...
#include "buffer.h"

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 | |
| unsigned int | peer_info_extract_int (const char *peer_info, const char *field, const char *format, unsigned int default_value) |
| Extracts the named integer variable and returns its value or default_value if it cannot be extracted. | |
| unsigned int | peer_info_extract_uint (const char *peer_info, const char *field) |
| Extracts the named integer variable and returns its value or 0 if it cannot be extracted. | |
| 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. | |
| static 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. | |
| uint32_t | extract_asymmetric_peer_id (const char *peer_info) |
| Extracts the ID variable and returns its value or MAX_PEER_ID 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_pair * | tls_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. | |
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.
| uint32_t extract_asymmetric_peer_id | ( | const char * | peer_info | ) |
Extracts the ID variable and returns its value or MAX_PEER_ID if it cannot be extracted.
| peer_info | peer info string to search for ID |
Definition at line 115 of file ssl_util.c.
References MAX_PEER_ID, and peer_info_extract_int().
Referenced by key_method_2_read(), p2p_ncp_set_options(), and ssl_test_extract_peer_info().
|
inlinestatic |
Extracts the IV_PROTO variable and returns its value or 0 if it cannot be extracted.
| peer_info | peer info string to search for IV_PROTO |
Definition at line 77 of file ssl_util.h.
References peer_info_extract_uint().
Referenced by multi_client_set_protocol_options(), p2p_ncp_set_options(), send_auth_pending_messages(), ssl_test_extract_peer_info(), and support_push_update().
| 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.
| peer_info | The peer's peer_info |
| var | The variable including =, e.g. IV_CIPHERS= |
| gc | GC arena to allocate return value in |
Definition at line 63 of file ssl_util.c.
References gc, peer_info_extract_varstr(), and string_alloc().
Referenced by check_auth_pending_method(), get_p2p_ncp_cipher(), ssl_test_extract_peer_info(), and tls_peer_ncp_list().
| 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
| string | the string to work on |
| delimiter | the delimiter to count, typically ':' |
Definition at line 355 of file ssl_util.c.
References ASSERT, and buffer::len.
Referenced by tls_ctx_set_tls_groups().
| 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.
| options | the locally generated OCC string |
| gc | gc_arena to allocate the returned string in |
Definition at line 127 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().
| unsigned int peer_info_extract_int | ( | const char * | peer_info, |
| const char * | field, | ||
| const char * | format, | ||
| unsigned int | default_value | ||
| ) |
Extracts the named integer variable and returns its value or default_value if it cannot be extracted.
| peer_info | peer info string to search in |
| field | name of the field to be extracted including the = |
| format | sscanf/printf format string of the type to extract |
| default_value | default value to return if the field cannot be extracted |
Definition at line 91 of file ssl_util.c.
References peer_info_extract_varstr().
Referenced by extract_asymmetric_peer_id(), peer_info_extract_uint(), and ssl_test_extract_peer_info().
| unsigned int peer_info_extract_uint | ( | const char * | peer_info, |
| const char * | field | ||
| ) |
Extracts the named integer variable and returns its value or 0 if it cannot be extracted.
| peer_info | peer info string to search in |
| field | name of the field to be extracted |
Definition at line 109 of file ssl_util.c.
References peer_info_extract_int().
Referenced by extract_iv_proto(), prepare_push_reply(), ssl_test_extract_peer_info(), and tls_peer_info_ncp_ver().
| const tls_cipher_name_pair * tls_get_cipher_name_pair | ( | const char * | cipher_name, |
| size_t | len | ||
| ) |
Definition at line 336 of file ssl_util.c.
References buffer::len, and tls_cipher_name_translation_table.
Referenced by convert_tls_list_to_openssl(), and show_available_tls_ciphers_list().