Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

altcp_tls_mbedtls.c File Reference

altcp_tls_mbedtls.c File Reference

Application layered TCP/TLS connection API (to be used from TCPIP thread) More...

Go to the source code of this file.

Functions

static err_t altcp_mbedtls_lower_recv (void *arg, struct altcp_pcb *inner_conn, struct pbuf *p, err_t err)
 Recv callback from lower connection (i.e.
static int altcp_mbedtls_bio_send (void *ctx, const unsigned char *dataptr, size_t size)
 Send callback function called from mbedtls (set via mbedtls_ssl_set_bio) This function is either called during handshake or when sending application data via altcp_mbedtls_write (or altcp_write)
static err_t altcp_mbedtls_lower_accept (void *arg, struct altcp_pcb *accepted_conn, err_t err)
 Accept callback from lower connection (i.e.
static err_t altcp_mbedtls_lower_connected (void *arg, struct altcp_pcb *inner_conn, err_t err)
 Connected callback from lower connection (i.e.
static int altcp_mbedtls_bio_recv (void *ctx, unsigned char *buf, size_t len)
 Receive callback function called from mbedtls (set via mbedtls_ssl_set_bio) This function mainly copies data from pbufs and frees the pbufs after copying.
static err_t altcp_mbedtls_lower_sent (void *arg, struct altcp_pcb *inner_conn, u16_t len)
 Sent callback from lower connection (i.e.
static err_t altcp_mbedtls_lower_poll (void *arg, struct altcp_pcb *inner_conn)
 Poll callback from lower connection (i.e.
struct altcp_pcb * altcp_tls_wrap (struct altcp_tls_config *config, struct altcp_pcb *inner_pcb)
 Create new ALTCP_TLS layer wrapping an existing pcb as inner connection (e.g.
void * altcp_tls_context (struct altcp_pcb *conn)
 Return pointer to internal TLS context so application can tweak it.
static int dummy_rng (void *ctx, unsigned char *buffer, size_t len)
 ATTENTION: It is *really* important to *NOT* use this dummy RNG in production code!!!!
static struct altcp_tls_config * altcp_tls_create_config (int is_server, int have_cert, int have_pkey, int have_ca)
 Create new TLS configuration ATTENTION: Server certificate and private key have to be added outside this function!
struct altcp_tls_config * altcp_tls_create_config_server_privkey_cert (const u8_t *privkey, size_t privkey_len, const u8_t *privkey_pass, size_t privkey_pass_len, const u8_t *cert, size_t cert_len)
 Create new TLS configuration This is a suboptimal version that gets the encrypted private key and its password, as well as the server certificate.
struct altcp_tls_config * altcp_tls_create_config_client (const u8_t *ca, size_t ca_len)
 Create an ALTCP_TLS client configuration handle.
struct altcp_tls_config * altcp_tls_create_config_client_2wayauth (const u8_t *ca, size_t ca_len, const u8_t *privkey, size_t privkey_len, const u8_t *privkey_pass, size_t privkey_pass_len, const u8_t *cert, size_t cert_len)
 Create an ALTCP_TLS client configuration handle with two-way server/client authentication.
void altcp_tls_free_config (struct altcp_tls_config *conf)
 Free an ALTCP_TLS configuration handle.
static u16_t altcp_mbedtls_sndbuf (struct altcp_pcb *conn)
 Allow caller of altcp_write() to limit to negotiated chunk size or remaining sndbuf space of inner_conn.
static err_t altcp_mbedtls_write (struct altcp_pcb *conn, const void *dataptr, u16_t len, u8_t apiflags)
 Write data to a TLS connection.

Detailed Description

Application layered TCP/TLS connection API (to be used from TCPIP thread)

This file provides a TLS layer using mbedTLS

Definition in file altcp_tls_mbedtls.c.


Function Documentation

static int altcp_mbedtls_bio_recv ( void *  ctx,
unsigned char *  buf,
size_t  len 
) [static]

Receive callback function called from mbedtls (set via mbedtls_ssl_set_bio) This function mainly copies data from pbufs and frees the pbufs after copying.

Definition at line 438 of file altcp_tls_mbedtls.c.

static int altcp_mbedtls_bio_send ( void *  ctx,
const unsigned char *  dataptr,
size_t  size 
) [static]

Send callback function called from mbedtls (set via mbedtls_ssl_set_bio) This function is either called during handshake or when sending application data via altcp_mbedtls_write (or altcp_write)

Definition at line 1088 of file altcp_tls_mbedtls.c.

static err_t altcp_mbedtls_lower_accept ( void *  arg,
struct altcp_pcb *  accepted_conn,
err_t  err 
) [static]

Accept callback from lower connection (i.e.

TCP) Allocate one of our structures, assign it to the new connection's 'state' and call the new connection's 'accepted' callback. If that succeeds, we wait to receive connection setup handshake bytes from the client.

Definition at line 126 of file altcp_tls_mbedtls.c.

static err_t altcp_mbedtls_lower_connected ( void *  arg,
struct altcp_pcb *  inner_conn,
err_t  err 
) [static]

Connected callback from lower connection (i.e.

TCP). Not really implemented/tested yet...

Definition at line 151 of file altcp_tls_mbedtls.c.

static err_t altcp_mbedtls_lower_poll ( void *  arg,
struct altcp_pcb *  inner_conn 
) [static]

Poll callback from lower connection (i.e.

TCP) Just pass this on to the application.

Definition at line 519 of file altcp_tls_mbedtls.c.

static err_t altcp_mbedtls_lower_recv ( void *  arg,
struct altcp_pcb *  inner_conn,
struct pbuf p,
err_t  err 
) [static]

Recv callback from lower connection (i.e.

TCP) This one mainly differs between connection setup/handshake (data is fed into mbedTLS only) and application phase (data is decoded by mbedTLS and passed on to the application).

Definition at line 184 of file altcp_tls_mbedtls.c.

static err_t altcp_mbedtls_lower_sent ( void *  arg,
struct altcp_pcb *  inner_conn,
u16_t  len 
) [static]

Sent callback from lower connection (i.e.

TCP) This only informs the upper layer to try to send more, not about the number of ACKed bytes.

Definition at line 492 of file altcp_tls_mbedtls.c.

static u16_t altcp_mbedtls_sndbuf ( struct altcp_pcb *  conn ) [static]

Allow caller of altcp_write() to limit to negotiated chunk size or remaining sndbuf space of inner_conn.

Definition at line 992 of file altcp_tls_mbedtls.c.

static err_t altcp_mbedtls_write ( struct altcp_pcb *  conn,
const void *  dataptr,
u16_t  len,
u8_t  apiflags 
) [static]

Write data to a TLS connection.

Calls into mbedTLS, which in turn calls into altcp_mbedtls_bio_send() to send the encrypted data

Definition at line 1031 of file altcp_tls_mbedtls.c.

static struct altcp_tls_config* altcp_tls_create_config ( int  is_server,
int  have_cert,
int  have_pkey,
int  have_ca 
) [static, read]

Create new TLS configuration ATTENTION: Server certificate and private key have to be added outside this function!

Definition at line 673 of file altcp_tls_mbedtls.c.

static int dummy_rng ( void *  ctx,
unsigned char *  buffer,
size_t  len 
) [static]

ATTENTION: It is *really* important to *NOT* use this dummy RNG in production code!!!!

Definition at line 656 of file altcp_tls_mbedtls.c.