oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
net_tls.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
9#ifndef OVE_NET_TLS_H
10#define OVE_NET_TLS_H
11
27#include "ove/types.h"
28#include "ove/net.h"
29#include "ove_config.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
43typedef struct {
44 const unsigned char *ca_cert;
45 size_t ca_cert_len;
46 const char *hostname;
47 const unsigned char
50 const unsigned char *client_key;
54
55#include "ove/storage.h"
56
57#ifdef CONFIG_OVE_NET_TLS
58
66int ove_tls_init(ove_tls_t *tls, ove_tls_storage_t *storage);
67
74
84
94int ove_tls_send(ove_tls_t tls, const void *data, size_t len, size_t *sent);
95
105int ove_tls_recv(ove_tls_t tls, void *buf, size_t len, size_t *received);
106
115
116#ifdef OVE_HEAP_NET_TLS
124
131#endif /* OVE_HEAP_NET_TLS */
132
133#else /* !CONFIG_OVE_NET_TLS */
134
136#ifndef CONFIG_OVE_NET_TLS
137typedef struct {
138 uint8_t _unused;
139} ove_tls_storage_t;
140#endif
141
142static inline int ove_tls_init(ove_tls_t *tls, ove_tls_storage_t *storage)
143{
144 (void)tls;
145 (void)storage;
147}
148static inline void ove_tls_deinit(ove_tls_t tls)
149{
150 (void)tls;
151}
152static inline int ove_tls_handshake(ove_tls_t tls, ove_socket_t sock, const ove_tls_config_t *cfg)
153{
154 (void)tls;
155 (void)sock;
156 (void)cfg;
158}
159static inline int ove_tls_send(ove_tls_t tls, const void *data, size_t len, size_t *sent)
160{
161 (void)tls;
162 (void)data;
163 (void)len;
164 (void)sent;
166}
167static inline int ove_tls_recv(ove_tls_t tls, void *buf, size_t len, size_t *received)
168{
169 (void)tls;
170 (void)buf;
171 (void)len;
172 (void)received;
174}
175static inline void ove_tls_close(ove_tls_t tls)
176{
177 (void)tls;
178}
181#endif /* CONFIG_OVE_NET_TLS */
182
183#ifdef __cplusplus
184}
185#endif
186
189#endif /* OVE_NET_TLS_H */
void ove_tls_close(ove_tls_t tls)
Shut down the TLS session (sends close_notify).
void ove_tls_deinit(ove_tls_t tls)
De-initialise a TLS session (frees internal resources, not storage).
int ove_tls_init(ove_tls_t *tls, ove_tls_storage_t *storage)
Initialise a TLS session from caller-supplied storage.
int ove_tls_handshake(ove_tls_t tls, ove_socket_t sock, const ove_tls_config_t *cfg)
Perform the TLS handshake over an established socket.
int ove_tls_send(ove_tls_t tls, const void *data, size_t len, size_t *sent)
Send data over an encrypted TLS session.
int ove_tls_create(ove_tls_t *tls)
Heap-allocate and initialise a TLS session.
void ove_tls_destroy(ove_tls_t tls)
Destroy a heap-allocated TLS session.
int ove_tls_recv(ove_tls_t tls, void *buf, size_t len, size_t *received)
Receive data from an encrypted TLS session.
struct ove_tls * ove_tls_t
Opaque handle for a TLS session.
Definition types.h:253
struct ove_socket * ove_socket_t
Opaque handle for a network socket.
Definition types.h:247
@ OVE_ERR_NOT_SUPPORTED
Definition types.h:98
TLS session configuration.
Definition net_tls.h:43
size_t client_key_len
Definition net_tls.h:51
const unsigned char * ca_cert
Definition net_tls.h:44
size_t ca_cert_len
Definition net_tls.h:45
int allow_insecure
Definition net_tls.h:52
size_t client_cert_len
Definition net_tls.h:49
const char * hostname
Definition net_tls.h:46
const unsigned char * client_cert
Definition net_tls.h:48
const unsigned char * client_key
Definition net_tls.h:50