Skip to content

File syn_dtls.c

FileList > net > syn_dtls.c

Go to the source code of this file

Native Zero-Heap DTLS 1.3 Datagram Protocol Engine (RFC 9147).

  • #include "syn_dtls.h"
  • #include "syntropic/crypto/syn_asn1.h"
  • #include "syntropic/crypto/syn_ed25519.h"
  • #include "syntropic/crypto/syn_hkdf.h"
  • #include "syntropic/crypto/syn_p256.h"
  • #include <string.h>

Public Functions

Type Name
void syn_dtls_bind_transport (SYN_DTLS_Context * dtls_ctx, SYN_Transport * tr_out)
Bind DTLS 1.3 engine to abstract SYN_Transport interface.
bool syn_dtls_handshake (SYN_DTLS_Context * ctx)
Execute DTLS 1.3 handshake.
bool syn_dtls_init (SYN_DTLS_Context * ctx, const SYN_DTLS_Config * config, SYN_Transport * transport, uint8_t * rx_buf, size_t rx_buf_size, uint8_t * tx_buf, size_t tx_buf_size)
Initialize DTLS 1.3 engine context with caller-allocated memory.
bool syn_dtls_recv (SYN_DTLS_Context * ctx, uint8_t * data, size_t max_len, size_t * out_len)
Receive and decrypt a DTLS 1.3 datagram record.
bool syn_dtls_replay_check (const SYN_DTLS_ReplayWindow * win, uint64_t seq)
Check whether a sequence number is acceptable by the replay window.
void syn_dtls_replay_update (SYN_DTLS_ReplayWindow * win, uint64_t seq)
Commit a validated sequence number to the replay window.
bool syn_dtls_send (SYN_DTLS_Context * ctx, const uint8_t * data, size_t len)
Send application data protected by DTLS 1.3 AEAD datagram record.
SYN_PT_Status syn_dtls_task (SYN_PT * pt, SYN_Task * task)
Non-blocking DTLS background task (Protothread).

Public Functions Documentation

function syn_dtls_bind_transport

Bind DTLS 1.3 engine to abstract SYN_Transport interface.

void syn_dtls_bind_transport (
    SYN_DTLS_Context * dtls_ctx,
    SYN_Transport * tr_out
) 

Parameters:

  • dtls_ctx Initialized DTLS context.
  • tr_out [out] Transport instance to populate.

function syn_dtls_handshake

Execute DTLS 1.3 handshake.

bool syn_dtls_handshake (
    SYN_DTLS_Context * ctx
) 

Parameters:

  • ctx Initialized DTLS context.

Returns:

true on successful handshake completion.


function syn_dtls_init

Initialize DTLS 1.3 engine context with caller-allocated memory.

bool syn_dtls_init (
    SYN_DTLS_Context * ctx,
    const SYN_DTLS_Config * config,
    SYN_Transport * transport,
    uint8_t * rx_buf,
    size_t rx_buf_size,
    uint8_t * tx_buf,
    size_t tx_buf_size
) 

Parameters:

  • ctx Context to initialize.
  • config Engine configuration.
  • transport Underlying transport (UDP, Socket, Serial).
  • rx_buf Caller-allocated buffer for incoming datagrams.
  • rx_buf_size Size of rx_buf in bytes.
  • tx_buf Caller-allocated buffer for outgoing datagrams.
  • tx_buf_size Size of tx_buf in bytes.

Returns:

true on success, false on invalid parameters.


function syn_dtls_recv

Receive and decrypt a DTLS 1.3 datagram record.

bool syn_dtls_recv (
    SYN_DTLS_Context * ctx,
    uint8_t * data,
    size_t max_len,
    size_t * out_len
) 

Parameters:

  • ctx Established DTLS context.
  • data Output buffer for decrypted application data.
  • max_len Capacity of output buffer.
  • out_len [out] Actual decrypted payload length.

Returns:

true if valid uncorrupted, non-replayed record received.


function syn_dtls_replay_check

Check whether a sequence number is acceptable by the replay window.

bool syn_dtls_replay_check (
    const SYN_DTLS_ReplayWindow * win,
    uint64_t seq
) 

Parameters:

  • win Pointer to replay window.
  • seq 64-bit reconstructed packet sequence number.

Returns:

true if packet is not a duplicate and is within or ahead of window.


function syn_dtls_replay_update

Commit a validated sequence number to the replay window.

void syn_dtls_replay_update (
    SYN_DTLS_ReplayWindow * win,
    uint64_t seq
) 

Parameters:

  • win Pointer to replay window.
  • seq 64-bit packet sequence number.

function syn_dtls_send

Send application data protected by DTLS 1.3 AEAD datagram record.

bool syn_dtls_send (
    SYN_DTLS_Context * ctx,
    const uint8_t * data,
    size_t len
) 

Parameters:

  • ctx Established DTLS context.
  • data Application data buffer.
  • len Length in bytes.

Returns:

true if encrypted record was sent.


function syn_dtls_task

Non-blocking DTLS background task (Protothread).

SYN_PT_Status syn_dtls_task (
    SYN_PT * pt,
    SYN_Task * task
) 

Parameters:

  • pt Pointer to task protothread.
  • task Pointer to scheduler task context.

Returns:

SYN_PT_Status.



The documentation for this class was generated from the following file src/syntropic/net/syn_dtls.c