Go to the documentation of this file.
30 #ifndef SSL_BACKEND_H_
31 #define SSL_BACKEND_H_
35 #ifdef ENABLE_CRYPTO_OPENSSL
38 #define SSLAPI SSLAPI_OPENSSL
40 #ifdef ENABLE_CRYPTO_MBEDTLS
43 #define SSLAPI SSLAPI_MBEDTLS
48 #define SSLAPI SSLAPI_NONE
103 #define TLS_VER_BAD -1
104 #define TLS_VER_UNSPEC 0
105 #define TLS_VER_1_0 1
106 #define TLS_VER_1_1 2
107 #define TLS_VER_1_2 3
108 #define TLS_VER_1_3 4
222 bool dh_file_inline);
248 bool pkcs12_file_inline,
bool load_ca_file);
257 #ifdef ENABLE_CRYPTOAPI
273 bool cert_file_inline);
288 bool priv_key_file_inline);
290 #ifdef ENABLE_MANAGEMENT
317 bool ca_file_inline,
const char *ca_path,
bool tls_server);
333 const char *extra_certs_file,
334 bool extra_certs_file_inline);
336 #ifdef ENABLE_CRYPTO_MBEDTLS
343 void tls_ctx_personalise_random(
struct tls_root_ctx *ctx);
388 const char *crl_file,
bool crl_inline);
390 #define EXPORT_KEY_DATA_LABEL "EXPORTER-OpenVPN-datakeys"
391 #define EXPORT_P2P_PEERID_LABEL "EXPORTER-OpenVPN-p2p-peerid"
392 #define EXPORT_DYNAMIC_TLS_CRYPT_LABEL "EXPORTER-OpenVPN-dynamic-tls-crypt"
407 const char *label,
size_t label_size,
408 void *ekm,
size_t ekm_size);
452 const uint8_t *data,
int len);
549 const char *tls_cert_profile,
void key_state_ssl_free(struct key_state_ssl *ks_ssl)
Free the SSL channel part of the given key state.
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.
void tls_init_lib(void)
Perform any static initialisation necessary by the library.
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 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.
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...
void print_details(struct key_state_ssl *ks_ssl, const char *prefix)
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_client_new(struct tls_root_ctx *ctx)
Initialises a library-specific TLS context for a client.
void tls_ctx_server_new(struct tls_root_ctx *ctx)
Initialise a library-specific TLS context for a server.
void show_available_tls_ciphers_list(const char *cipher_list, const char *tls_cert_profile, bool tls13)
bool tls_ctx_set_options(struct tls_root_ctx *ctx, unsigned int ssl_flags)
Set any library specific options.
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.
void tls_free_lib(void)
Free any global SSL library-specific data structures.
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.
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...
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_plaintext(struct key_state_ssl *ks_ssl, struct buffer *buf)
Extract plaintext data from the TLS module.
bool tls_ctx_initialised(struct tls_root_ctx *ctx)
Checks whether the given TLS context is initialised.
int tls_version_max(void)
Return the maximum TLS version (as a TLS_VER_x constant) supported by current SSL implementation.
void tls_ctx_free(struct tls_root_ctx *ctx)
Frees the library-specific TLSv1 context.
void tls_ctx_set_cert_profile(struct tls_root_ctx *ctx, const char *profile)
Set the TLS certificate profile.
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.
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...
Wrapper structure for dynamically allocated memory.
int key_state_write_plaintext(struct key_state_ssl *ks_ssl, struct buffer *buf)
Insert a plaintext buffer into the TLS module.
void get_highest_preference_tls_cipher(char *buf, int size)
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.
Security parameter state of a single session within a VPN tunnel.
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.
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 ...
int pem_password_callback(char *buf, int size, int rwflag, void *u)
Callback to retrieve the user's password.
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.
Structure that wraps the TLS context.
void show_available_curves(void)
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 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.
int tls_version_parse(const char *vstr, const char *extra)
void tls_clear_error(void)
Clear the underlying SSL library's error state.
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_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.
int key_state_read_ciphertext(struct key_state_ssl *ks_ssl, struct buffer *buf)
Extract ciphertext data from the TLS module.
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.