36#if defined(LWS_WITH_DTLS)
38#if defined(LWS_WITH_MBEDTLS)
39#include <mbedtls/ssl.h>
40#include <mbedtls/entropy.h>
41#include <mbedtls/ctr_drbg.h>
42#include <mbedtls/ssl_cookie.h>
43#elif defined(LWS_WITH_GNUTLS)
44#include <gnutls/gnutls.h>
45#elif defined(LWS_WITH_SCHANNEL)
50#include <openssl/ssl.h>
53struct lws_gendtls_ctx {
54#if defined(LWS_WITH_MBEDTLS)
55 mbedtls_ssl_context ssl;
56 mbedtls_ssl_config conf;
57 mbedtls_ctr_drbg_context ctr_drbg;
58 mbedtls_entropy_context entropy;
59 mbedtls_x509_crt cacert;
60 mbedtls_pk_context pkey;
61 mbedtls_ssl_cookie_ctx cookie_ctx;
62 struct lws_buflist *rx_head;
63 struct lws_buflist *tx_head;
67#if defined(MBEDTLS_SSL_DTLS_SRTP)
68 mbedtls_ssl_srtp_profile srtp_profiles[4];
70#elif defined(LWS_WITH_GNUTLS)
71 gnutls_session_t session;
72 gnutls_certificate_credentials_t cred;
73 gnutls_datum_t cookie_key;
74 struct lws_buflist *rx_head;
75 struct lws_buflist *tx_head;
83 struct lws_context *context;
84#elif defined(LWS_WITH_SCHANNEL)
87 struct lws_buflist *rx_head;
88 struct lws_buflist *tx_head;
89 struct lws_context *context;
94 PCCERT_CONTEXT cert_ctxt;
95 SCHANNEL_CRED schannel_cred;
102 char key_container_name[64];
103 NCRYPT_KEY_HANDLE key_cng;
105 struct sockaddr_storage client_addr;
106 size_t client_addr_len;
113enum lws_gendtls_conn_mode {
114 LWS_GENDTLS_MODE_CLIENT,
115 LWS_GENDTLS_MODE_SERVER
118struct lws_gendtls_creation_info {
119 struct lws_context *context;
120 enum lws_gendtls_conn_mode mode;
122 unsigned int timeout_ms;
123 const char *use_srtp;
136lws_gendtls_create(
struct lws_gendtls_ctx *ctx,
137 const struct lws_gendtls_creation_info *info);
146lws_gendtls_destroy(
struct lws_gendtls_ctx *ctx);
157lws_gendtls_set_cert_mem(
struct lws_gendtls_ctx *ctx,
const uint8_t *cert,
size_t len);
168lws_gendtls_set_key_mem(
struct lws_gendtls_ctx *ctx,
const uint8_t *key,
size_t len);
179lws_gendtls_put_rx(
struct lws_gendtls_ctx *ctx,
const uint8_t *in,
size_t len);
190lws_gendtls_get_rx(
struct lws_gendtls_ctx *ctx,
uint8_t *out,
size_t max_len);
201lws_gendtls_put_tx(
struct lws_gendtls_ctx *ctx,
const uint8_t *in,
size_t len);
212lws_gendtls_get_tx(
struct lws_gendtls_ctx *ctx,
uint8_t *out,
size_t max_len);
227lws_gendtls_export_keying_material(
struct lws_gendtls_ctx *ctx,
const char *label,
228 size_t label_len,
const uint8_t *context,
229 size_t context_len,
uint8_t *out,
size_t out_len);
238lws_gendtls_handshake_done(
struct lws_gendtls_ctx *ctx);
247lws_gendtls_is_clean(
struct lws_gendtls_ctx *ctx);
256lws_gendtls_get_srtp_profile(
struct lws_gendtls_ctx *ctx);
258#if defined(LWS_WITH_SCHANNEL)
269lws_gendtls_schannel_set_client_addr(
struct lws_gendtls_ctx *ctx,
270 const struct sockaddr *sa,
size_t sa_len);