OpenVPN
ssl_util.h
Go to the documentation of this file.
1/*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single TCP/UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
7 *
8 * Copyright (C) 2002-2026 OpenVPN Inc <sales@openvpn.net>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, see <https://www.gnu.org/licenses/>.
21 */
22
30#ifndef SSL_UTIL_H_
31#define SSL_UTIL_H_
32
33#include "buffer.h"
34
44unsigned int
45peer_info_extract_int(const char *peer_info, const char *field, const char *format, unsigned int default_value);
46
54unsigned int
55peer_info_extract_uint(const char *peer_info, const char *field);
56
68char *extract_var_peer_info(const char *peer_info, const char *var, struct gc_arena *gc);
69
76static inline unsigned int
77extract_iv_proto(const char *peer_info)
78{
79 return peer_info_extract_uint(peer_info, "IV_PROTO=");
80}
81
88uint32_t extract_asymmetric_peer_id(const char *peer_info);
89
102const char *options_string_compat_lzo(const char *options, struct gc_arena *gc);
103
110typedef struct
111{
112 const char *openssl_name;
113 const char *iana_name;
115const tls_cipher_name_pair *tls_get_cipher_name_pair(const char *cipher_name, size_t len);
116
128int get_num_elements(const char *string, char delimiter);
129
130#endif /* ifndef SSL_UTIL_H_ */
Buffer management functions and garbage collection.
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 e...
Definition ssl_util.c:355
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...
Definition ssl_util.c:63
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.
Definition ssl_util.c:91
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 en...
Definition ssl_util.c:127
const tls_cipher_name_pair * tls_get_cipher_name_pair(const char *cipher_name, size_t len)
Definition ssl_util.c:336
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.
Definition ssl_util.c:115
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.
Definition ssl_util.c:109
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.
Definition ssl_util.h:77
Garbage collection arena used to keep track of dynamically allocated memory.
Definition buffer.h:127
Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name.
Definition ssl_util.h:111
const char * iana_name
Definition ssl_util.h:113
const char * openssl_name
Definition ssl_util.h:112
struct gc_arena gc
Definition test_ssl.c:122