41#ifndef MBEDTLS_SUPPORT_H_
42#define MBEDTLS_SUPPORT_H_
44#include MBEDTLS_CONFIG_FILE
45#include "mbedtls/ssl.h"
46#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
47#include "mbedtls/entropy.h"
49#include "mbedtls/ctr_drbg.h"
52#ifdef MBEDTLS_TIMING_ALT
53#include "timing_alt.h"
55#include "mbedtls/timing.h"
58#ifdef COAP_DTLS_CONF_WITH_CERT
59#include "mbedtls/x509.h"
61#ifdef COAP_DTLS_CONF_WITH_SERVER
62#include "mbedtls/ssl_cookie.h"
63#if defined(MBEDTLS_SSL_CACHE_C)
64#include "mbedtls/ssl_cache.h"
68#include "dtls-support-config.h"
73typedef enum coap_dtls_sec_mode_e {
74 COAP_DTLS_SEC_MODE_NONE = 0,
75 COAP_DTLS_SEC_MODE_PSK = 1,
76 COAP_DTLS_SEC_MODE_CERT = 2,
77} coap_dtls_sec_mode_t;
79typedef enum coap_mbedtls_role_e {
80 COAP_MBEDTLS_ROLE_NONE = 0,
81 COAP_MBEDTLS_ROLE_CLIENT = 1,
82 COAP_MBEDTLS_ROLE_SERVER = 2,
85typedef enum coap_mbedtls_event_e {
86 COAP_MBEDTLS_EVENT_NONE = 0,
87 COAP_MBEDTLS_EVENT_RETRANSMISSION_EVENT = 1,
88 COAP_MBEDTLS_EVENT_SEND_MESSAGE_EVENT = 2,
89} coap_mbedtls_event_t;
92typedef struct coap_dtls_session_info {
93 struct coap_dtls_session_info *next;
94 enum coap_mbedtls_role_e role;
97 bool is_packet_consumed;
99 mbedtls_ssl_context ssl;
100 mbedtls_ssl_config conf;
101 uint32_t ciphersuite;
102#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
103 mbedtls_entropy_context entropy;
105 mbedtls_ctr_drbg_context ctr_drbg;
106 struct mbedtls_timing_delay_context
timer;
107 struct etimer retransmission_et;
109#ifdef COAP_DTLS_CONF_WITH_CERT
111 mbedtls_x509_crt ca_cert;
112 mbedtls_x509_crt own_cert;
113 mbedtls_pk_context pkey;
115#ifdef COAP_DTLS_CONF_WITH_SERVER
117 mbedtls_ssl_cookie_ctx cookie_ctx;
118#if defined(MBEDTLS_SSL_CACHE_C)
119 mbedtls_ssl_cache_context cache;
122} coap_dtls_session_info_t;
125typedef struct coap_dtls_send_message {
126 struct coap_mbedtls_send_message *next;
128 unsigned char send_buf[COAP_MBEDTLS_MTU];
130} coap_dtls_send_message_t;
133typedef struct coap_dtls_context {
134 struct etimer fragmentation_et;
138 struct process *host_process;
141} coap_dtls_context_t;
165 struct process *host_process);
178 const unsigned char *message,
int len);
204coap_dtls_session_info_t *
207#ifdef COAP_DTLS_CONF_WITH_CLIENT
220int coap_ep_dtls_connect(
const coap_endpoint_t *ep,
221 coap_dtls_sec_mode_t sec_mode,
const void *keystore_entry);
224#ifdef COAP_DTLS_CONF_WITH_SERVER
237int coap_dtls_server_setup(
const coap_dtls_sec_mode_t sec_mode,
238 const void *keystore_entry);
API to address CoAP endpoints.
#define LIST_STRUCT(name)
Declare a linked list inside a structure declaraction.
void coap_dtls_conn_init(struct uip_udp_conn *udp_conn, struct process *host_process)
Registers, 1.
int coap_ep_get_dtls_state(const coap_endpoint_t *ep)
Check in what DTLS state the peer is in.
int coap_ep_dtls_write(const coap_endpoint_t *ep, const unsigned char *message, int len)
Encrypt app.
bool coap_ep_is_dtls_peer(const coap_endpoint_t *ep)
Check if a CoAP endpoint is a peer in the list of DTLS sessions.
bool coap_ep_is_dtls_connected(const coap_endpoint_t *ep)
Check if a peer has completed the handshake successfully.
void coap_dtls_init(void)
Initializes CoAP-MbedTLS global info.
void coap_ep_dtls_disconnect(const coap_endpoint_t *ep)
Disconnect a peer.
void coap_dtls_event_handler(void)
Handler for timer, and process-poll events.
int coap_ep_dtls_handle_message(const coap_endpoint_t *ep)
Handler for new DTLS messages.
coap_dtls_session_info_t * coap_ep_get_dtls_session_info(const coap_endpoint_t *ep)
Get session struct associated with CoAP endpoint.
Representation of a uIP UDP connection.