tinydtls
0.8.1
|
High level DTLS API and visible structures. More...
#include <stdint.h>
#include "t_list.h"
#include "state.h"
#include "peer.h"
#include "uthash.h"
#include "alert.h"
#include "crypto.h"
#include "hmac.h"
#include "global.h"
#include "dtls_time.h"
Go to the source code of this file.
Data Structures | |
struct | dtls_ecdsa_key_t |
struct | dtls_handler_t |
struct | dtls_context_t |
Macros | |
#define | DTLS_VERSION 0xfefd /* DTLS v1.2 */ |
#define | DTLS_COOKIE_SECRET_LENGTH 12 |
#define | dtls_set_app_data(CTX, DATA) ((CTX)->app = (DATA)) |
#define | dtls_get_app_data(CTX) ((CTX)->app) |
#define | DTLS_COOKIE_LENGTH 16 |
#define | DTLS_CT_CHANGE_CIPHER_SPEC 20 |
#define | DTLS_CT_ALERT 21 |
#define | DTLS_CT_HANDSHAKE 22 |
#define | DTLS_CT_APPLICATION_DATA 23 |
#define | DTLS_HT_HELLO_REQUEST 0 |
#define | DTLS_HT_CLIENT_HELLO 1 |
#define | DTLS_HT_SERVER_HELLO 2 |
#define | DTLS_HT_HELLO_VERIFY_REQUEST 3 |
#define | DTLS_HT_CERTIFICATE 11 |
#define | DTLS_HT_SERVER_KEY_EXCHANGE 12 |
#define | DTLS_HT_CERTIFICATE_REQUEST 13 |
#define | DTLS_HT_SERVER_HELLO_DONE 14 |
#define | DTLS_HT_CERTIFICATE_VERIFY 15 |
#define | DTLS_HT_CLIENT_KEY_EXCHANGE 16 |
#define | DTLS_HT_FINISHED 20 |
Typedefs | |
typedef enum dtls_credentials_type_t | dtls_credentials_type_t |
typedef struct dtls_ecdsa_key_t | dtls_ecdsa_key_t |
typedef struct dtls_context_t | dtls_context_t |
Enumerations | |
enum | dtls_credentials_type_t { DTLS_PSK_HINT, DTLS_PSK_IDENTITY, DTLS_PSK_KEY } |
Functions | |
void | dtls_init () |
dtls_context_t * | dtls_new_context (void *app_data) |
void | dtls_free_context (dtls_context_t *ctx) |
static void | dtls_set_handler (dtls_context_t *ctx, dtls_handler_t *h) |
int | dtls_connect (dtls_context_t *ctx, const session_t *dst) |
int | dtls_connect_peer (dtls_context_t *ctx, dtls_peer_t *peer) |
int | dtls_close (dtls_context_t *ctx, const session_t *remote) |
int | dtls_renegotiate (dtls_context_t *ctx, const session_t *dst) |
int | dtls_write (struct dtls_context_t *ctx, session_t *session, uint8 *buf, size_t len) |
void | dtls_check_retransmit (dtls_context_t *context, clock_time_t *next) |
struct | __attribute__ ((__packed__)) |
int | dtls_handle_message (dtls_context_t *ctx, session_t *session, uint8 *msg, int msglen) |
dtls_peer_t * | dtls_get_peer (const dtls_context_t *context, const session_t *session) |
Variables | |
dtls_record_header_t | |
dtls_handshake_header_t | |
dtls_client_hello_t | |
dtls_hello_verify_t | |
High level DTLS API and visible structures.
Definition in file dtls.h.
#define DTLS_COOKIE_SECRET_LENGTH 12 |
#define dtls_set_app_data | ( | CTX, | |
DATA | |||
) | ((CTX)->app = (DATA)) |
typedef struct dtls_context_t dtls_context_t |
Holds global information of the DTLS engine.
typedef enum dtls_credentials_type_t dtls_credentials_type_t |
typedef struct dtls_ecdsa_key_t dtls_ecdsa_key_t |
struct __attribute__ | ( | (__packed__) | ) |
Generic header structure of the DTLS record layer.
Header structure for the DTLS handshake protocol.
Structure of the Client Hello message.
Structure of the Hello Verify Request.
< content type of the included message
< Protocol version
< counter for cipher state changes
< sequence number
< length of the following fragment
< Type of handshake message (one of DTLS_HT_)
< length of this message
< Message sequence number
< Fragment offset.
< Fragment length.
< Client version
< GMT time of the random byte creation
< Client random bytes
< Server version
< Length of the included cookie
< up to 32 bytes making up the cookie
void dtls_check_retransmit | ( | dtls_context_t * | context, |
clock_time_t * | next | ||
) |
Checks sendqueue of given DTLS context object for any outstanding packets to be transmitted.
context | The DTLS context object to use. |
next | If not NULL, next is filled with the timestamp of the next scheduled retransmission, or 0 when no packets are waiting. |
int dtls_close | ( | dtls_context_t * | ctx, |
const session_t * | remote | ||
) |
int dtls_connect | ( | dtls_context_t * | ctx, |
const session_t * | dst | ||
) |
Establishes a DTLS channel with the specified remote peer dst
. This function returns 0
if that channel already exists, a value greater than zero when a new ClientHello message was sent, and a value less than zero on error.
ctx | The DTLS context to use. |
dst | The remote party to connect to. |
int dtls_connect_peer | ( | dtls_context_t * | ctx, |
dtls_peer_t * | peer | ||
) |
Establishes a DTLS channel with the specified remote peer. This function returns 0
if that channel already exists, a value greater than zero when a new ClientHello message was sent, and a value less than zero on error.
ctx | The DTLS context to use. |
peer | The peer object that describes the session. |
void dtls_free_context | ( | dtls_context_t * | ctx | ) |
dtls_peer_t* dtls_get_peer | ( | const dtls_context_t * | context, |
const session_t * | session | ||
) |
Check if session
is associated with a peer object in context
. This function returns a pointer to the peer if found, NULL otherwise.
context | The DTLS context to search. |
session | The remote address and local interface |
session
or NULL if none exists. int dtls_handle_message | ( | dtls_context_t * | ctx, |
session_t * | session, | ||
uint8 * | msg, | ||
int | msglen | ||
) |
Handles incoming data as DTLS message from given peer.
ctx | The dtls context to use. |
session | The current session |
msg | The received data |
msglen | The actual length of msg . |
Handles incoming data as DTLS message from given peer.
void dtls_init | ( | ) |
dtls_context_t* dtls_new_context | ( | void * | app_data | ) |
Creates a new context object. The storage allocated for the new object must be released with dtls_free_context().
int dtls_renegotiate | ( | dtls_context_t * | ctx, |
const session_t * | dst | ||
) |
|
inlinestatic |
int dtls_write | ( | struct dtls_context_t * | ctx, |
session_t * | session, | ||
uint8 * | buf, | ||
size_t | len | ||
) |
Writes the application data given in buf
to the peer specified by session
.
ctx | The DTLS context to use. |
session | The remote transport address and local interface. |
buf | The data to write. |
len | The actual length of data . |
-1
on error.