pianod2
multisource multiuser scriptable networked music player
Functions | Variables
fb_transport_mbedtls.c File Reference

Football transport implementations for mBed TLS (formerly Polar SSL). More...

#include <config.h>
#include <assert.h>
#include <errno.h>
#include "fb_public.h"
#include "fb_transport.h"
#include "fb_service.h"
#include <sys/socket.h>
#include <mbedtls/net.h>
#include <mbedtls/ssl.h>
#include <mbedtls/entropy.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/pem.h>
#include <mbedtls/pk.h>
#include <mbedtls/error.h>
#include <mbedtls/debug.h>
Include dependency graph for fb_transport_mbedtls.c:

Functions

static void mbedtls_debug (void *ctx, int level, const char *file, int line, const char *str)
 
static void fb_mbedtls_error (struct fb_connection_t *connection, const char *func, int error)
 
static void fb_mbedtls_config_error (const char *func, int error)
 
bool fb_mbedtls_configure (const FB_TLS_CONFIG_FILENAMES *path)
 
bool fb_mbedtls_init (FB_CONNECTION *connection)
 
ssize_t fb_mbedtls_handshake (struct fb_connection_t *connection)
 
ssize_t fb_mbedtls_buffering (struct fb_connection_t *connection)
 
ssize_t fb_mbedtls_read (struct fb_connection_t *connection, char *data, ssize_t byte_count)
 
ssize_t fb_mbedtls_write (struct fb_connection_t *connection, const char *data, ssize_t byte_count)
 
void fb_mbedtls_done (FB_CONNECTION *connection)
 
void fb_mbedtls_cleanup ()
 

Variables

static bool fb_tls_initialized
 
static mbedtls_x509_crt tls_certificate
 
static mbedtls_pk_context tls_public_key
 
static mbedtls_x509_crt root_ca_certificate
 
static mbedtls_x509_crl root_revokation_certificate
 
static mbedtls_entropy_context entropy
 
static mbedtls_ctr_drbg_context random_context
 
static mbedtls_ssl_config server_config
 
const FB_TRANSPORT_FUNCS fb_transport_encrypted
 

Detailed Description

Football transport implementations for mBed TLS (formerly Polar SSL).

Function Documentation

◆ fb_mbedtls_buffering()

ssize_t fb_mbedtls_buffering ( struct fb_connection_t connection)

Query number of bytes in TLS buffers. mbedtls doesn't seem to have a pending bytes function, or possibly I am unable to find it in their documentation. To simulate, we read one byte and buffer it, then tack it onto the front of the next read.

◆ fb_mbedtls_cleanup()

void fb_mbedtls_cleanup ( )

◆ fb_mbedtls_config_error()

static void fb_mbedtls_config_error ( const char *  func,
int  error 
)
static
Here is the caller graph for this function:

◆ fb_mbedtls_configure()

bool fb_mbedtls_configure ( const FB_TLS_CONFIG_FILENAMES path)

Load certificates and keys.

Here is the call graph for this function:

◆ fb_mbedtls_done()

void fb_mbedtls_done ( FB_CONNECTION connection)

◆ fb_mbedtls_error()

static void fb_mbedtls_error ( struct fb_connection_t connection,
const char *  func,
int  error 
)
static
Here is the caller graph for this function:

◆ fb_mbedtls_handshake()

ssize_t fb_mbedtls_handshake ( struct fb_connection_t connection)

Perform TLS handshaking on a new connection. Return incomplete, failure, or 0.

Here is the call graph for this function:

◆ fb_mbedtls_init()

bool fb_mbedtls_init ( FB_CONNECTION connection)

Initialize the TLS stuff for a new connection.

Parameters
connectionThe connection to initialize.
Returns
true on success, false on error.
Here is the call graph for this function:

◆ fb_mbedtls_read()

ssize_t fb_mbedtls_read ( struct fb_connection_t connection,
char *  data,
ssize_t  byte_count 
)

Read data from a TLS connection using mBedTLS.

Here is the call graph for this function:

◆ fb_mbedtls_write()

ssize_t fb_mbedtls_write ( struct fb_connection_t connection,
const char *  data,
ssize_t  byte_count 
)

Write data to a TLS connection using mBedTLS.

Here is the call graph for this function:

◆ mbedtls_debug()

static void mbedtls_debug ( void *  ctx,
int  level,
const char *  file,
int  line,
const char *  str 
)
static
Here is the caller graph for this function:

Variable Documentation

◆ entropy

mbedtls_entropy_context entropy
static

◆ fb_tls_initialized

bool fb_tls_initialized
static

◆ fb_transport_encrypted

const FB_TRANSPORT_FUNCS fb_transport_encrypted
Initial value:
= {
.configure = fb_mbedtls_configure,
.cleanup = fb_mbedtls_cleanup,
.init = fb_mbedtls_init,
.handshake = fb_mbedtls_handshake,
.buffering = fb_mbedtls_buffering,
.read = fb_mbedtls_read,
.write = fb_mbedtls_write,
}
ssize_t fb_mbedtls_write(struct fb_connection_t *connection, const char *data, ssize_t byte_count)
Definition: fb_transport_mbedtls.c:183
void fb_mbedtls_cleanup()
Definition: fb_transport_mbedtls.c:200
ssize_t fb_mbedtls_buffering(struct fb_connection_t *connection)
Definition: fb_transport_mbedtls.c:150
bool fb_mbedtls_configure(const FB_TLS_CONFIG_FILENAMES *path)
Definition: fb_transport_mbedtls.c:71
ssize_t fb_mbedtls_handshake(struct fb_connection_t *connection)
Definition: fb_transport_mbedtls.c:134
ssize_t fb_mbedtls_read(struct fb_connection_t *connection, char *data, ssize_t byte_count)
Definition: fb_transport_mbedtls.c:160
void fb_mbedtls_done(FB_CONNECTION *connection)
Definition: fb_transport_mbedtls.c:196
bool fb_mbedtls_init(FB_CONNECTION *connection)
Definition: fb_transport_mbedtls.c:101

◆ random_context

mbedtls_ctr_drbg_context random_context
static

◆ root_ca_certificate

mbedtls_x509_crt root_ca_certificate
static

◆ root_revokation_certificate

mbedtls_x509_crl root_revokation_certificate
static

◆ server_config

mbedtls_ssl_config server_config
static

◆ tls_certificate

mbedtls_x509_crt tls_certificate
static

◆ tls_public_key

mbedtls_pk_context tls_public_key
static