36#if defined(ENABLE_CRYPTO_MBEDTLS)
49#include <mbedtls/debug.h>
50#include <mbedtls/error.h>
51#include <mbedtls/net_sockets.h>
52#include <mbedtls/oid.h>
53#include <mbedtls/pem.h>
54#include <mbedtls/version.h>
56static const mbedtls_x509_crt_profile openvpn_x509_crt_profile_legacy = {
58 MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA1) | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_RIPEMD160)
59 | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA224) | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA256)
60 | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA384) | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA512),
66static const mbedtls_x509_crt_profile openvpn_x509_crt_profile_preferred = {
68 MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA224) | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA256)
69 | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA384) | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA512),
75#define openvpn_x509_crt_profile_suiteb mbedtls_x509_crt_profile_suiteb;
80 if (psa_crypto_init() != PSA_SUCCESS)
82 msg(
M_FATAL,
"mbedtls: psa_crypto_init() failed");
111 mbedtls_x509_crt_free(ctx->
ca_chain);
117 mbedtls_x509_crl_free(ctx->
crl);
120#if defined(ENABLE_PKCS11)
124 if (ctx->pkcs11_cert)
126 pkcs11h_certificate_freeCertificate(ctx->pkcs11_cert);
151 void *ekm,
size_t ekm_size)
153 ASSERT(strlen(label) == label_size);
156 return mbed_ok(mbedtls_ssl_export_keying_material(ctx, ekm, ekm_size, label, label_size,
167tls_translate_cipher_name(
const char *cipher_name)
177 if (0 != strcmp(cipher_name, pair->
iana_name))
180 msg(
M_WARN,
"Deprecated cipher suite name '%s', please use IANA name '%s'",
197 "mbed TLS does not support setting tls-ciphersuites. "
198 "Ignoring TLS 1.3 cipher list: %s",
205 char *tmp_ciphers, *tmp_ciphers_orig;
223 tmp_ciphers_orig = tmp_ciphers =
string_alloc(ciphers, NULL);
225 const
char *token =
strtok_r(tmp_ciphers,
":", &lasts);
228 ctx->
allowed_ciphers[i] = mbedtls_ssl_get_ciphersuite_id(tls_translate_cipher_name(token));
233 token =
strtok_r(NULL,
":", &lasts);
235 free(tmp_ciphers_orig);
241 if (!profile || 0 == strcmp(profile,
"legacy") || 0 == strcmp(profile,
"insecure"))
245 else if (0 == strcmp(profile,
"preferred"))
249 else if (0 == strcmp(profile,
"suiteb"))
255 msg(
M_FATAL,
"ERROR: Invalid cert profile: %s", profile);
263} mbedtls_ecp_curve_info;
265static const mbedtls_ecp_curve_info ecp_curve_info_table[] = {
267#if defined(PSA_WANT_ECC_SECP_R1_256)
268 {
"secp256r1", MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1 },
270#if defined(PSA_WANT_ECC_SECP_R1_384)
271 {
"secp384r1", MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1 },
273#if defined(PSA_WANT_ECC_SECP_R1_521)
274 {
"secp521r1", MBEDTLS_SSL_IANA_TLS_GROUP_SECP521R1 },
278#if defined(PSA_WANT_ECC_MONTGOMERY_255)
279 {
"X25519", MBEDTLS_SSL_IANA_TLS_GROUP_X25519 },
283#if defined(PSA_WANT_ECC_MONTGOMERY_448)
284 {
"X448", MBEDTLS_SSL_IANA_TLS_GROUP_X448 },
288#if defined(PSA_WANT_ECC_BRAINPOOL_P_R1_256)
289 {
"brainpoolP256r1", MBEDTLS_SSL_IANA_TLS_GROUP_BP256R1 },
291#if defined(PSA_WANT_ECC_BRAINPOOL_P_R1_384)
292 {
"brainpoolP384r1", MBEDTLS_SSL_IANA_TLS_GROUP_BP384R1 },
294#if defined(PSA_WANT_ECC_BRAINPOOL_P_R1_512)
295 {
"brainpoolP512r1", MBEDTLS_SSL_IANA_TLS_GROUP_BP512R1 },
299#if defined(PSA_WANT_DH_RFC7919_2048)
300 {
"ffdhe2048", MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE2048 },
302#if defined(PSA_WANT_DH_RFC7919_3072)
303 {
"ffdhe3072", MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE3072 },
305#if defined(PSA_WANT_DH_RFC7919_4096)
306 {
"ffdhe4096", MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE4096 },
308#if defined(PSA_WANT_DH_RFC7919_6144)
309 {
"ffdhe6144", MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE6144 },
311#if defined(PSA_WANT_DH_RFC7919_8192)
312 {
"ffdhe8192", MBEDTLS_SSL_IANA_TLS_GROUP_FFDHE8192 },
315static const size_t ecp_curve_info_table_items =
sizeof(ecp_curve_info_table) /
sizeof(mbedtls_ecp_curve_info);
317static const mbedtls_ecp_curve_info *
318mbedtls_ecp_curve_info_from_name(
const char *name)
320 for (
size_t i = 0; i < ecp_curve_info_table_items; i++)
322 if (strcmp(name, ecp_curve_info_table[i].name) == 0)
324 return &ecp_curve_info_table[i];
345 while ((token =
strsep(&tmp_groups,
":")))
347 const mbedtls_ecp_curve_info *ci = mbedtls_ecp_curve_info_from_name(token);
350 msg(
M_WARN,
"Warning unknown curve/group specified: %s", token);
354 ctx->
groups[i] = ci->tls_id;
362 msg(
M_FATAL,
"Error: All groups in \"%s\" are invalid or unsupported.", groups);
383 if (mbedtls_x509_time_is_future(&ctx->
crt_chain->valid_from))
385 msg(
M_WARN,
"WARNING: Your certificate is not yet valid!");
388 if (mbedtls_x509_time_is_past(&ctx->
crt_chain->valid_to))
390 msg(
M_WARN,
"WARNING: Your certificate has expired!");
397 if (strcmp(dh_file,
"none") != 0)
399 msg(
M_FATAL,
"Mbed TLS 4 only supports pre-defined Diffie-Hellman groups.");
406 if (NULL != curve_name)
408 msg(
M_WARN,
"WARNING: mbed TLS builds do not support specifying an "
409 "ECDH curve with --ecdh-curve, using default curves. Use "
410 "--tls-groups to specify curves.");
418 msg(
M_FATAL,
"PKCS #12 files not yet supported for mbed TLS.");
422#ifdef ENABLE_CRYPTOAPI
426 msg(
M_FATAL,
"Windows CryptoAPI not yet supported for mbed TLS.");
444 msg(
M_FATAL,
"Cannot load inline certificate: NULL");
446 if (!
mbed_ok(mbedtls_x509_crt_parse(ctx->
crt_chain, (
const unsigned char *)cert_file,
447 strlen(cert_file) + 1)))
449 msg(
M_FATAL,
"Cannot load inline certificate");
456 msg(
M_FATAL,
"Cannot load certificate file %s", cert_file);
474 status = mbedtls_pk_parse_key(ctx->
priv_key, (
const unsigned char *)priv_key_file,
475 strlen(priv_key_file) + 1, NULL, 0);
477 if (MBEDTLS_ERR_PK_PASSWORD_REQUIRED ==
status)
481 status = mbedtls_pk_parse_key(
482 ctx->
priv_key, (
const unsigned char *)priv_key_file, strlen(priv_key_file) + 1,
488 status = mbedtls_pk_parse_keyfile(ctx->
priv_key, priv_key_file, NULL);
489 if (MBEDTLS_ERR_PK_PASSWORD_REQUIRED ==
status)
498#ifdef ENABLE_MANAGEMENT
504 msg(
M_WARN,
"Cannot load private key file %s",
511#if MBEDTLS_VERSION_NUMBER >= 0x04010000
512 if (ctx->
priv_key->MBEDTLS_PRIVATE(pub_raw_len) == 0)
515 ctx->
priv_key->MBEDTLS_PRIVATE(pub_raw),
516 sizeof(ctx->
priv_key->MBEDTLS_PRIVATE(pub_raw)),
517 &ctx->
priv_key->MBEDTLS_PRIVATE(pub_raw_len))));
522 msg(
M_WARN,
"Private key does not match the certificate");
533 msg(
M_WARN,
"tls_ctx_use_external_signing_func is not implemented for Mbed TLS 4.");
537#ifdef ENABLE_MANAGEMENT
540management_sign_func(
void *sign_ctx,
const void *src,
size_t src_len,
void *dst,
size_t dst_len)
543 char *src_b64 = NULL;
544 char *dst_b64 = NULL;
587 msg(
M_FATAL,
"ERROR: mbed TLS cannot handle the capath directive");
590 if (ca_file && ca_inline)
592 if (!
mbed_ok(mbedtls_x509_crt_parse(ctx->
ca_chain, (
const unsigned char *)ca_file,
593 strlen(ca_file) + 1)))
595 msg(
M_FATAL,
"Cannot load inline CA certificates");
603 msg(
M_FATAL,
"Cannot load CA certificate file %s", ca_file);
610 bool extra_certs_inline)
619 if (extra_certs_inline)
621 if (!
mbed_ok(mbedtls_x509_crt_parse(ctx->
crt_chain, (
const unsigned char *)extra_certs_file,
622 strlen(extra_certs_file) + 1)))
624 msg(
M_FATAL,
"Cannot load inline extra-certs file");
629 if (!
mbed_ok(mbedtls_x509_crt_parse_file(ctx->
crt_chain, extra_certs_file)))
631 msg(
M_FATAL,
"Cannot load extra-certs file: %s", extra_certs_file);
663 buf_free_entry(cur_block);
669endless_buf_read(
endless_buffer *in,
unsigned char *out,
size_t out_len)
673 ASSERT(out_len <= INT_MAX);
677 return MBEDTLS_ERR_SSL_WANT_READ;
680 while (in->
first_block != NULL && read_len < out_len)
683 if (block_len <= out_len - read_len)
686 memcpy(out + read_len, cur_entry->data + in->
data_start, block_len);
688 read_len += block_len;
698 buf_free_entry(cur_entry);
708 return (
int)read_len;
712endless_buf_write(
endless_buffer *out,
const unsigned char *in,
size_t len)
715 if (NULL == new_block)
717 return MBEDTLS_ERR_NET_SEND_FAILED;
720 new_block->data = malloc(len);
721 if (NULL == new_block->data)
724 return MBEDTLS_ERR_NET_SEND_FAILED;
729 new_block->length = len;
730 new_block->next_block = NULL;
732 memcpy(new_block->data, in, len);
750ssl_bio_read(
void *ctx,
unsigned char *out,
size_t out_len)
753 return endless_buf_read(&my_ctx->
in, out, out_len);
757ssl_bio_write(
void *ctx,
const unsigned char *in,
size_t in_len)
760 return endless_buf_write(&my_ctx->
out, in, in_len);
764my_debug(
void *ctx,
int level,
const char *file,
int line,
const char *str)
767 msg(my_loglevel,
"mbed TLS msg (%s:%d): %s", file, line, str);
781#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
783#elif defined(MBEDTLS_SSL_PROTO_TLS1_2)
786#error mbedtls is compiled without support for TLS 1.2 or 1.3
797mbedtls_ssl_protocol_version
798tls_version_to_ssl_version(
int tls_ver)
802#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
804 return MBEDTLS_SSL_VERSION_TLS1_2;
807#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
809 return MBEDTLS_SSL_VERSION_TLS1_3;
813 msg(
M_FATAL,
"%s: invalid or unsupported TLS version %d", __func__, tls_ver);
814 return MBEDTLS_SSL_VERSION_UNKNOWN;
823 if (ctx->
crl == NULL)
827 mbedtls_x509_crl_free(ctx->
crl);
831 if (!
mbed_ok(mbedtls_x509_crl_parse(ctx->
crl, (
const unsigned char *)crl_file,
832 strlen(crl_file) + 1)))
834 msg(
M_WARN,
"CRL: cannot parse inline CRL");
840 if (!
mbed_ok(mbedtls_x509_crl_parse_file(ctx->
crl, crl_file)))
842 msg(
M_WARN,
"CRL: cannot read CRL from file %s", crl_file);
849 mbedtls_x509_crl_free(ctx->
crl);
863 int endpoint = is_server ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT;
864 mbedtls_ssl_config_defaults(ks_ssl->
ssl_config,
endpoint, MBEDTLS_SSL_TRANSPORT_STREAM,
865 MBEDTLS_SSL_PRESET_DEFAULT);
866#ifdef MBEDTLS_DEBUG_C
873 mbedtls_debug_set_threshold(3);
877 mbedtls_debug_set_threshold(2);
880 mbedtls_ssl_conf_dbg(ks_ssl->
ssl_config, my_debug, NULL);
897#if defined(MBEDTLS_SSL_RENEGOTIATION)
898 mbedtls_ssl_conf_renegotiation(ks_ssl->
ssl_config, MBEDTLS_SSL_RENEGOTIATION_DISABLED);
905#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
906 mbedtls_ssl_conf_cbc_record_splitting(ks_ssl->
ssl_config,
907 MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED);
916 mbedtls_ssl_conf_authmode(ks_ssl->
ssl_config, MBEDTLS_SSL_VERIFY_OPTIONAL);
920 mbedtls_ssl_conf_authmode(ks_ssl->
ssl_config, MBEDTLS_SSL_VERIFY_REQUIRED);
929 const int configured_tls_version_min =
933 mbedtls_ssl_protocol_version version = MBEDTLS_SSL_VERSION_TLS1_2;
937 version = tls_version_to_ssl_version(configured_tls_version_min);
940 mbedtls_ssl_conf_min_tls_version(ks_ssl->
ssl_config, version);
945 const int configured_tls_version_max =
948 mbedtls_ssl_protocol_version version = MBEDTLS_SSL_VERSION_UNKNOWN;
952 version = tls_version_to_ssl_version(configured_tls_version_max);
960 mbedtls_ssl_conf_max_tls_version(ks_ssl->
ssl_config, version);
965 mbedtls_ssl_init(ks_ssl->
ctx);
974 mbedtls_ssl_set_bio(ks_ssl->
ctx, ks_ssl->
bio_ctx, ssl_bio_write, ssl_bio_read, NULL);
981 mbedtls_ssl_send_alert_message(ks_ssl->
ctx, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
982 MBEDTLS_SSL_ALERT_MSG_CLOSE_NOTIFY);
992 mbedtls_ssl_free(ks_ssl->
ctx);
1043 retval = mbedtls_ssl_write(ks->
ctx, data, len);
1047 if (MBEDTLS_ERR_SSL_WANT_WRITE == retval || MBEDTLS_ERR_SSL_WANT_READ == retval)
1057 msg(
D_TLS_ERRORS,
"TLS ERROR: write tls_write_plaintext_const incomplete %d/%d", retval,
1090 if (MBEDTLS_ERR_SSL_WANT_WRITE == retval || MBEDTLS_ERR_SSL_WANT_READ == retval)
1129 if (MBEDTLS_ERR_SSL_WANT_WRITE == retval || MBEDTLS_ERR_SSL_WANT_READ == retval)
1137 if (retval != buf->
len)
1139 msg(
D_TLS_ERRORS,
"TLS ERROR: write tls_write_ciphertext incomplete %d/%d", retval,
1170 retval = mbedtls_ssl_read(ks->
ctx,
BPTR(buf), len);
1175 if (MBEDTLS_ERR_SSL_WANT_WRITE == retval || MBEDTLS_ERR_SSL_WANT_READ == retval
1176 || MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET == retval)
1208 const mbedtls_x509_crt *cert;
1213 snprintf(s1,
sizeof(s1),
"%s %s, cipher %s", prefix, mbedtls_ssl_get_version(ks_ssl->
ctx),
1214 mbedtls_ssl_get_ciphersuite(ks_ssl->
ctx));
1216 cert = mbedtls_ssl_get_peer_cert(ks_ssl->
ctx);
1219 snprintf(s2,
sizeof(s2),
", %u bit key", (
unsigned int)mbedtls_pk_get_bitlen(&cert->pk));
1234 const int *ciphers = mbedtls_ssl_list_ciphersuites();
1240 if (tls_ctx.allowed_ciphers)
1242 ciphers = tls_ctx.allowed_ciphers;
1245 while (*ciphers != 0)
1247 printf(
"%s\n", mbedtls_ssl_get_ciphersuite_name(*ciphers));
1256 printf(
"Available elliptic curves:\n\n");
1257 for (
size_t i = 0; i < ecp_curve_info_table_items; i++)
1259 printf(
"%s\n", ecp_curve_info_table[i].name);
1266 static char mbedtls_version[30];
1267 unsigned int pv = mbedtls_version_get_number();
1268 snprintf(mbedtls_version,
sizeof(mbedtls_version),
"mbed TLS %u.%u.%u", (pv >> 24) & 0xff,
1269 (pv >> 16) & 0xff, (pv >> 8) & 0xff);
1270 return mbedtls_version;
char * string_alloc(const char *str, struct gc_arena *gc)
Duplicate a string, allocating memory under garbage collection.
Buffer management functions and garbage collection.
#define BPTR(buf)
Return a pointer to the start of the buffer content.
#define ALLOC_ARRAY_CLEAR(dptr, type, n)
Allocate and zero-initialise an array of n elements of the given type.
static int buf_forward_capacity(const struct buffer *buf)
Return the number of bytes that can still be appended to the buffer.
#define BLEN(buf)
Return the length of the buffer content in bytes.
static void gc_free(struct gc_arena *a)
Free all allocations in a garbage collection arena.
#define ALLOC_OBJ_CLEAR(dptr, type)
Allocate and zero-initialise memory for a single object of the given type.
static struct gc_arena gc_new(void)
Allocate and return a new, empty garbage collection arena.
char * strsep(char **stringp, const char *delim)
char * strtok_r(char *s, const char *delim, char **last)
const char * print_key_filename(const char *str, bool is_inline)
To be used when printing a string that may contain inline data.
#define mbed_ok(errval)
Check errval and log on error.
bool mbed_log_err(unsigned int flags, int errval, const char *prefix)
Log the supplied mbed TLS error, prefixed by supplied prefix.
#define D_HANDSHAKE_VERBOSE
#define KS_PRIMARY
Primary key state index.
int key_state_read_plaintext(struct key_state_ssl *ks_ssl, struct buffer *buf)
Extract plaintext data from the TLS module.
int key_state_write_ciphertext(struct key_state_ssl *ks_ssl, struct buffer *buf)
Insert a ciphertext buffer into the TLS module.
int key_state_read_ciphertext(struct key_state_ssl *ks_ssl, struct buffer *buf)
Extract ciphertext data from the TLS module.
int key_state_write_plaintext_const(struct key_state_ssl *ks_ssl, const uint8_t *data, int len)
Insert plaintext data into the TLS module.
int key_state_write_plaintext(struct key_state_ssl *ks_ssl, struct buffer *buf)
Insert a plaintext buffer into the TLS module.
int verify_callback(void *session_obj, mbedtls_x509_crt *cert, int cert_depth, uint32_t *flags)
Verify that the remote OpenVPN peer's certificate allows setting up a VPN tunnel.
static SERVICE_STATUS status
void management_auth_failure(const struct management *man, const char *type, const char *reason)
char * management_query_pk_sig(struct management *man, const char *b64_data, const char *algorithm)
PKCS #11 SSL library-specific backend.
int openvpn_base64_decode(const char *str, void *data, int size)
int openvpn_base64_encode(const void *data, int size, char **str)
static struct user_pass passbuf
int pem_password_callback(char *buf, int size, int rwflag, void *u)
Callback to retrieve the user's password.
void load_xkey_provider(void)
Load ovpn.xkey provider used for external key signing.
Control Channel SSL library backend module.
void tls_ctx_set_tls_groups(struct tls_root_ctx *ctx, const char *groups)
Set the (elliptic curve) group allowed for signatures and key exchange.
void tls_ctx_free(struct tls_root_ctx *ctx)
Frees the library-specific TLSv1 context.
const char * get_ssl_library_version(void)
return a pointer to a static memory area containing the name and version number of the SSL library in...
bool key_state_export_keying_material(struct tls_session *session, const char *label, size_t label_size, void *ekm, size_t ekm_size)
Keying Material Exporters [RFC 5705] allows additional keying material to be derived from existing TL...
void show_available_tls_ciphers_list(const char *cipher_list, const char *tls_cert_profile, bool tls13)
Show the TLS ciphers that are available for us to use in the library depending on the TLS version.
void show_available_curves(void)
Show the available elliptic curves in the crypto library.
void key_state_ssl_free(struct key_state_ssl *ks_ssl)
Free the SSL channel part of the given key state.
int tls_ctx_load_priv_file(struct tls_root_ctx *ctx, const char *priv_key_file, bool priv_key_file_inline)
Load private key file into the given TLS context.
void key_state_ssl_shutdown(struct key_state_ssl *ks_ssl)
Sets a TLS session to be shutdown state, so the TLS library will generate a shutdown alert.
void tls_ctx_load_extra_certs(struct tls_root_ctx *ctx, const char *extra_certs_file, bool extra_certs_file_inline)
Load extra certificate authority certificates from the given file or path.
void tls_ctx_check_cert_time(const struct tls_root_ctx *ctx)
Check our certificate notBefore and notAfter fields, and warn if the cert is either not yet valid or ...
void tls_ctx_restrict_ciphers_tls13(struct tls_root_ctx *ctx, const char *ciphers)
Restrict the list of ciphers that can be used within the TLS context for TLS 1.3 and higher.
int tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file, bool pkcs12_file_inline, bool load_ca_file)
Load PKCS #12 file for key, cert and (optionally) CA certs, and add to library-specific TLS context.
void key_state_ssl_init(struct key_state_ssl *ks_ssl, const struct tls_root_ctx *ssl_ctx, bool is_server, struct tls_session *session)
Initialise the SSL channel part of the given key state.
void tls_free_lib(void)
Free any global SSL library-specific data structures.
void tls_ctx_load_ecdh_params(struct tls_root_ctx *ctx, const char *curve_name)
Load Elliptic Curve Parameters, and load them into the library-specific TLS context.
void tls_init_lib(void)
Perform any static initialisation necessary by the library.
void print_details(struct key_state_ssl *ks_ssl, const char *prefix)
Print a one line summary of SSL/TLS session handshake.
int tls_version_max(void)
Return the maximum TLS version (as a TLS_VER_x constant) supported by current SSL implementation.
void backend_tls_ctx_reload_crl(struct tls_root_ctx *ssl_ctx, const char *crl_file, bool crl_inline)
Reload the Certificate Revocation List for the SSL channel.
void tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)
Restrict the list of ciphers that can be used within the TLS context for TLS 1.2 and below.
void tls_ctx_load_ca(struct tls_root_ctx *ctx, const char *ca_file, bool ca_file_inline, const char *ca_path, bool tls_server)
Load certificate authority certificates from the given file or path.
void tls_ctx_set_cert_profile(struct tls_root_ctx *ctx, const char *profile)
Set the TLS certificate profile.
int tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)
Tell the management interface to load the given certificate and the external private key matching the...
void tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert)
Use Windows cryptoapi for key and cert, and add to library-specific TLS context.
bool tls_ctx_initialised(const struct tls_root_ctx *ctx)
Checks whether the given TLS context is initialised.
bool tls_ctx_set_options(struct tls_root_ctx *ctx, unsigned int ssl_flags)
Set any library specific options.
void tls_ctx_load_dh_params(struct tls_root_ctx *ctx, const char *dh_file, bool dh_file_inline)
Load Diffie Hellman Parameters, and load them into the library-specific TLS context.
void tls_ctx_new(struct tls_root_ctx *ctx)
Initialise a library-specific TLS context.
void tls_ctx_load_cert_file(struct tls_root_ctx *ctx, const char *cert_file, bool cert_file_inline)
Load certificate file into the given TLS context.
Control Channel Common Data Structures.
#define SSLF_TLS_VERSION_MAX_SHIFT
#define UP_TYPE_PRIVATE_KEY
#define SSLF_CLIENT_CERT_OPTIONAL
#define SSLF_CLIENT_CERT_NOT_REQUIRED
#define SSLF_TLS_DEBUG_ENABLED
#define SSLF_TLS_VERSION_MAX_MASK
#define SSLF_TLS_VERSION_MIN_SHIFT
#define SSLF_TLS_VERSION_MIN_MASK
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.
bool(* external_sign_func)(void *sign_ctx, const void *src, size_t src_size, void *dst, size_t dst_size)
External signing function prototype.
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...
const tls_cipher_name_pair * tls_get_cipher_name_pair(const char *cipher_name, size_t len)
Control Channel Verification Module mbed TLS backend.
buffer_entry * next_block
One node in a buffer_list linked list.
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
buffer_entry * first_block
buffer_entry * last_block
Garbage collection arena used to keep track of dynamically allocated memory.
mbedtls_ssl_config * ssl_config
mbedTLS global ssl config
mbedtls_ssl_context * ctx
mbedTLS connection context
Get a tls_cipher_name_pair containing OpenSSL and IANA names for supplied TLS cipher name.
const char * openssl_name
Structure that wraps the TLS context.
mbedtls_x509_crl * crl
Certificate Revocation List.
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_x509_crt_profile cert_profile
Allowed certificate types.
bool initialised
True if the context has been initialised.
mbedtls_pk_context * priv_key
Local private key.
Security parameter state of a single session within a VPN tunnel.
static int cleanup(void **state)