lwIP 2.2.0 Lightweight IP stack

Functions
TLS layer
APIs » "raw" APIs » Application layered TCP Introduction » Application layered TCP Functions

## Functions
struct altcp_tls_config * | altcp_tls_create_config_server (u8_t cert_count)
err_t | altcp_tls_config_server_add_privkey_cert (struct altcp_tls_config *config, 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)
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)
struct altcp_tls_config * | altcp_tls_create_config_client (const u8_t *cert, size_t cert_len)
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)
int | altcp_tls_configure_alpn_protocols (struct altcp_tls_config *conf, const char **protos)
void | altcp_tls_free_config (struct altcp_tls_config *conf)
void | altcp_tls_free_entropy (void)
struct altcp_pcb * | altcp_tls_wrap (struct altcp_tls_config *config, struct altcp_pcb *inner_pcb)
struct altcp_pcb * | altcp_tls_new (struct altcp_tls_config *config, u8_t ip_type)
struct altcp_pcb * | altcp_tls_alloc (void *arg, u8_t ip_type)
void * | altcp_tls_context (struct altcp_pcb *conn)
void | altcp_tls_init_session (struct altcp_tls_session *dest)
err_t | altcp_tls_get_session (struct altcp_pcb *conn, struct altcp_tls_session *dest)
err_t | altcp_tls_set_session (struct altcp_pcb *conn, struct altcp_tls_session *from)
void | altcp_tls_free_session (struct altcp_tls_session *dest)

## Detailed Description

This file contains function prototypes for a TLS layer. A port to ARM mbedtls is provided in the apps/ tree (LWIP_ALTCP_TLS_MBEDTLS option).

## Function Documentation

## ◆ altcp_tls_alloc()

struct altcp_pcb* altcp_tls_alloc | ( | void * | arg,
|  | u8_t | ip_type
| ) |  |

Create new ALTCP_TLS layer pcb and its inner tcp pcb. Same as altcp_tls_new but this allocator function fits to altcp_allocator_t / altcp_new.
'arg' must contain a struct altcp_tls_config *.

This standard allocator function creates an altcp pcb for TLS over TCP

## ◆ altcp_tls_config_server_add_privkey_cert()

err_t altcp_tls_config_server_add_privkey_cert | ( | struct altcp_tls_config * | config,
|  | 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
| ) |  |

Add a certificate to an ALTCP_TLS server configuration handle

## ◆ altcp_tls_configure_alpn_protocols()

int altcp_tls_configure_alpn_protocols | ( | struct altcp_tls_config * | conf,
|  | const char ** | protos
| ) |  |

Configure ALPN TLS extension Example:
static const char *g_alpn_protocols[] = { "x-amzn-mqtt-ca", NULL };
tls_config = altcp_tls_create_config_client(ca, ca_len);
altcp_tls_conf_alpn_protocols(tls_config, g_alpn_protocols);

## ◆ altcp_tls_context()

void* altcp_tls_context | ( | struct altcp_pcb * | conn | ) |

Return pointer to internal TLS context so application can tweak it. Real type depends on port (e.g. mbedtls)

## ◆ altcp_tls_create_config_client()

struct altcp_tls_config* altcp_tls_create_config_client | ( | const u8_t * | cert,
|  | size_t | cert_len
| ) |  |

Create an ALTCP_TLS client configuration handle

## ◆ altcp_tls_create_config_client_2wayauth()

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

## ◆ altcp_tls_create_config_server()

struct altcp_tls_config* altcp_tls_create_config_server | ( | u8_t | cert_count | ) |

Create an ALTCP_TLS server configuration handle prepared for multiple certificates

## ◆ altcp_tls_create_config_server_privkey_cert()

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 an ALTCP_TLS server configuration handle with one certificate (short version of calling altcp_tls_create_config_server and altcp_tls_config_server_add_privkey_cert)

## ◆ altcp_tls_free_config()

void altcp_tls_free_config | ( | struct altcp_tls_config * | conf | ) |

Free an ALTCP_TLS configuration handle

## ◆ altcp_tls_free_entropy()

void altcp_tls_free_entropy | ( | void |  | ) |

Free an ALTCP_TLS global entropy instance. All ALTCP_TLS configuration are linked to one altcp_tls_entropy_rng structure that handle an unique system entropy & ctr_drbg instance. This function allow application to free this altcp_tls_entropy_rng structure when all configuration referencing it were destroyed. This function does nothing if some ALTCP_TLS configuration handle are still active.

## ◆ altcp_tls_free_session()

void altcp_tls_free_session | ( | struct altcp_tls_session * | dest | ) |

Free allocated data inside a TLS session buffer. Real type depends on port (e.g. mbedtls use mbedtls_ssl_session)

## ◆ altcp_tls_get_session()

err_t altcp_tls_get_session | ( | struct altcp_pcb * | conn,
|  | struct altcp_tls_session * | dest
| ) |  |

Save current connected session to reuse it later. Should be called after altcp_connect() succeeded. Return error if saving session fail. Real type depends on port (e.g. mbedtls use mbedtls_ssl_session)

## ◆ altcp_tls_init_session()

void altcp_tls_init_session | ( | struct altcp_tls_session * | dest | ) |

Initialise a TLS session buffer. Real type depends on port (e.g. mbedtls use mbedtls_ssl_session)

## ◆ altcp_tls_new()

struct altcp_pcb* altcp_tls_new | ( | struct altcp_tls_config * | config,
|  | u8_t | ip_type
| ) |  |

Create new ALTCP_TLS pcb and its inner tcp pcb

This standard allocator function creates an altcp pcb for TLS over TCP

## ◆ altcp_tls_set_session()

err_t altcp_tls_set_session | ( | struct altcp_pcb * | conn,
|  | struct altcp_tls_session * | from
| ) |  |

Restore a previously saved session. Must be called before altcp_connect(). Return error if cannot restore session. Real type depends on port (e.g. mbedtls use mbedtls_ssl_session)

## ◆ altcp_tls_wrap()

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. TLS over TCP)