OpenVPN
ssl_mbedtls.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-2025 OpenVPN Inc <sales@openvpn.net>
9 * Copyright (C) 2010-2021 Sentyron B.V. <openvpn@sentyron.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, see <https://www.gnu.org/licenses/>.
22 */
23
29#ifndef SSL_MBEDTLS_H_
30#define SSL_MBEDTLS_H_
31
32#include "syshead.h"
33
34#include <mbedtls/ssl.h>
35#include <mbedtls/x509_crt.h>
36#include <mbedtls/version.h>
37
38#if defined(ENABLE_PKCS11)
39#include <pkcs11-helper-1.0/pkcs11h-certificate.h>
40#endif
41
43
45{
46 size_t length;
47 uint8_t *data;
49};
50
57
63
77typedef bool (*external_sign_func)(void *sign_ctx, const void *src, size_t src_size, void *dst,
78 size_t dst_size);
79
87
88#if !defined(MBEDTLS_SSL_KEYING_MATERIAL_EXPORT)
96{
97 unsigned char client_server_random[64];
98 mbedtls_tls_prf_types tls_prf_type;
99 unsigned char master_secret[48];
100};
101#else /* !defined(MBEDTLS_SSL_KEYING_MATERIAL_EXPORT) */
102struct tls_key_cache
103{
104};
105#endif
106
114{
119 mbedtls_dhm_context *dhm_ctx;
120 mbedtls_x509_crt *crt_chain;
121 mbedtls_x509_crt *ca_chain;
122 mbedtls_pk_context *priv_key;
123 mbedtls_x509_crl *crl;
126#ifdef ENABLE_PKCS11
127 pkcs11h_certificate_t pkcs11_cert;
128#endif
131 uint16_t *groups;
132 mbedtls_x509_crt_profile cert_profile;
133};
134
136{
137 mbedtls_ssl_config *ssl_config;
138 mbedtls_ssl_context *ctx;
140
142};
143
155 void *sign_ctx);
156
157static inline void
159{
160}
161#endif /* SSL_MBEDTLS_H_ */
int tls_ctx_use_external_signing_func(struct tls_root_ctx *ctx, external_sign_func sign_func, void *sign_ctx)
Call the supplied signing function to create a TLS signature during the TLS handshake.
static void tls_clear_error(void)
bool(* external_sign_func)(void *sign_ctx, const void *src, size_t src_size, void *dst, size_t dst_size)
External signing function prototype.
Definition ssl_mbedtls.h:77
Definition ssl_mbedtls.h:45
size_t length
Definition ssl_mbedtls.h:46
uint8_t * data
Definition ssl_mbedtls.h:47
buffer_entry * next_block
Definition ssl_mbedtls.h:48
endless_buffer out
Definition ssl_mbedtls.h:61
endless_buffer in
Definition ssl_mbedtls.h:60
Definition buffer.h:1107
size_t data_start
Definition ssl_mbedtls.h:53
buffer_entry * first_block
Definition ssl_mbedtls.h:54
buffer_entry * last_block
Definition ssl_mbedtls.h:55
Context used by external_pkcs1_sign()
Definition ssl_mbedtls.h:82
external_sign_func sign
Definition ssl_mbedtls.h:84
size_t signature_length
Definition ssl_mbedtls.h:83
bio_ctx * bio_ctx
mbedtls_ssl_config * ssl_config
mbedTLS global ssl config
mbedtls_ssl_context * ctx
mbedTLS connection context
struct to cache TLS secrets for keying material exporter (RFC 5705).
Definition ssl_mbedtls.h:96
unsigned char master_secret[48]
Definition ssl_mbedtls.h:99
mbedtls_tls_prf_types tls_prf_type
Definition ssl_mbedtls.h:98
unsigned char client_server_random[64]
Definition ssl_mbedtls.h:97
Structure that wraps the TLS context.
mbedtls_x509_crl * crl
Certificate Revocation List.
off_t crl_last_size
size of last loaded CRL
mbedtls_x509_crt * crt_chain
Local Certificate chain.
uint16_t * groups
List of allowed groups for this connection.
mbedtls_x509_crt * ca_chain
CA chain for remote verification.
int * allowed_ciphers
List of allowed ciphers for this connection.
mbedtls_dhm_context * dhm_ctx
Diffie-Helmann-Merkle context.
time_t crl_last_mtime
CRL last modification time.
mbedtls_x509_crt_profile cert_profile
Allowed certificate types.
bool initialised
True if the context has been initialised.
int endpoint
Whether or not this is a server or a client.
struct external_context external_key
External key context.
mbedtls_pk_context * priv_key
Local private key.