Skip to content

File syn_tls.c

FileList > net > syn_tls.c

Go to the source code of this file

Native Zero-Heap TLS 1.3 Protocol Engine & Transport Adapter implementation.

  • #include "syntropic/net/syn_tls.h"
  • #include "syntropic/crypto/syn_ed25519.h"
  • #include "syntropic/crypto/syn_hmac.h"
  • #include "syntropic/util/syn_random.h"
  • #include <string.h>

Public Functions

Type Name
void syn_tls_bind_transport (SYN_TLS_Context * tls_ctx, SYN_Transport * tr_out)
Wrap a TLS 1.3 context into a standard SYN_Transport abstraction.
bool syn_tls_handshake (SYN_TLS_Context * ctx)
Perform a non-blocking TLS 1.3 handshake step.
bool syn_tls_init (SYN_TLS_Context * ctx, const SYN_TLS_Config * config, SYN_Transport * transport, uint8_t * rx_buf, size_t rx_buf_size, uint8_t * tx_buf, size_t tx_buf_size)
Initialize a TLS 1.3 context.
bool syn_tls_recv (SYN_TLS_Context * ctx, uint8_t * data, size_t max_len, size_t * out_len)
Receive and decrypt TLS 1.3 record payload into caller buffer.
bool syn_tls_send (SYN_TLS_Context * ctx, const uint8_t * data, size_t len)
Encrypt and transmit application data payload over TLS 1.3.
SYN_PT_Status syn_tls_task (SYN_PT * pt, SYN_Task * task)
Cooperative protothread task — drives the TLS 1.3 client handshake & session.

Public Functions Documentation

function syn_tls_bind_transport

Wrap a TLS 1.3 context into a standard SYN_Transport abstraction.

void syn_tls_bind_transport (
    SYN_TLS_Context * tls_ctx,
    SYN_Transport * tr_out
) 

Parameters:

  • tls_ctx Initialized TLS 1.3 context.
  • tr_out [out] Output transport instance.

function syn_tls_handshake

Perform a non-blocking TLS 1.3 handshake step.

bool syn_tls_handshake (
    SYN_TLS_Context * ctx
) 

Parameters:

  • ctx TLS 1.3 context.

Returns:

true if handshake completed or progressing, false on fatal error.


function syn_tls_init

Initialize a TLS 1.3 context.

bool syn_tls_init (
    SYN_TLS_Context * ctx,
    const SYN_TLS_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 Configuration.
  • transport Wire transport instance.
  • rx_buf Caller-owned RX record buffer.
  • rx_buf_size RX buffer capacity.
  • tx_buf Caller-owned TX record buffer.
  • tx_buf_size TX buffer capacity.

Returns:

true on success.


function syn_tls_recv

Receive and decrypt TLS 1.3 record payload into caller buffer.

bool syn_tls_recv (
    SYN_TLS_Context * ctx,
    uint8_t * data,
    size_t max_len,
    size_t * out_len
) 

Parameters:

  • ctx TLS 1.3 context.
  • data [out] Output buffer for decrypted data.
  • max_len Capacity of output buffer.
  • out_len [out] Actual decrypted bytes written.

Returns:

true if a complete record decrypted.


function syn_tls_send

Encrypt and transmit application data payload over TLS 1.3.

bool syn_tls_send (
    SYN_TLS_Context * ctx,
    const uint8_t * data,
    size_t len
) 

Parameters:

  • ctx TLS 1.3 context.
  • data Application data buffer.
  • len Application data length.

Returns:

true if record encrypted and sent successfully.


function syn_tls_task

Cooperative protothread task — drives the TLS 1.3 client handshake & session.

SYN_PT_Status syn_tls_task (
    SYN_PT * pt,
    SYN_Task * task
) 

Parameters:

  • pt Protothread handle.
  • task Task descriptor.

Returns:

PT status.



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