Embedded TCP/IP stack  4.7.0
fnet_tls.h
1 /**************************************************************************
2 *
3 * Copyright 2015-2018 by Andrey Butok. FNET Community.
4 *
5 ***************************************************************************
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ***************************************************************************
20 *
21 * TLS Library API.
22 *
23 ***************************************************************************/
24 #ifndef _FNET_TLS_H_
25 
26 #define _FNET_TLS_H_
27 
28 #if FNET_CFG_TLS || defined(__DOXYGEN__)
29 
48 /**************************************************************************/
52 typedef void *fnet_tls_desc_t;
53 
54 /**************************************************************************/
58 typedef void *fnet_tls_socket_t;
59 
60 /**************************************************************************/
63 typedef enum
64 {
68 
69 #if defined(__cplusplus)
70 extern "C" {
71 #endif
72 
73 /***************************************************************************/
94 
95 /***************************************************************************/
117 fnet_return_t fnet_tls_set_own_certificate(fnet_tls_desc_t tls_desc, const fnet_uint8_t *own_certificate, fnet_size_t own_certificate_size, const fnet_uint8_t *private_key, fnet_size_t private_key_size);
118 
119 /***************************************************************************/
141 fnet_return_t fnet_tls_set_ca_certificate(fnet_tls_desc_t tls_desc, const fnet_uint8_t *ca_certificate, fnet_size_t ca_certificate_size);
142 
143 /***************************************************************************/
156 void fnet_tls_release(fnet_tls_desc_t tls_desc);
157 
158 /***************************************************************************/
181 
182 /***************************************************************************/
199 
200 /***************************************************************************/
222 
223 /***************************************************************************/
245 
246 /***************************************************************************/
271 fnet_ssize_t fnet_tls_socket_recv(fnet_tls_socket_t tls_sock, fnet_uint8_t *buf, fnet_size_t len);
272 
273 /***************************************************************************/
298 fnet_ssize_t fnet_tls_socket_send(fnet_tls_socket_t tls_sock, const fnet_uint8_t *buf, fnet_size_t len);
299 
300 #if defined(__cplusplus)
301 }
302 #endif
303 
306 #endif /* FNET_CFG_TLS */
307 
308 #endif /* _FNET_TLS_H_ */
void fnet_tls_socket_close(fnet_tls_socket_t tls_sock)
Close the TLS socket.
TLS Server.
Definition: fnet_tls.h:65
fnet_return_t fnet_tls_socket_set_hostname(fnet_tls_socket_t tls_sock, const fnet_char_t *hostname)
Set the host name to check against the received server certificate.
fnet_tls_desc_t fnet_tls_init(fnet_tls_role_t role)
Initialize the TLS context.
fnet_ssize_t fnet_tls_socket_send(fnet_tls_socket_t tls_sock, const fnet_uint8_t *buf, fnet_size_t len)
Send data on a TLS socket.
fnet_return_t fnet_tls_socket_connect(fnet_tls_socket_t tls_sock)
Perform the TLS handshake.
void * fnet_tls_desc_t
TLS context descriptor.
Definition: fnet_tls.h:52
fnet_return_t
General return codes, used by most of API functions.
Definition: fnet_stdlib.h:89
void * fnet_socket_t
Socket descriptor.
Definition: fnet_socket.h:652
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
Definition: fnet_stdlib.h:55
fnet_return_t fnet_tls_set_own_certificate(fnet_tls_desc_t tls_desc, const fnet_uint8_t *own_certificate, fnet_size_t own_certificate_size, const fnet_uint8_t *private_key, fnet_size_t private_key_size)
Set own certificate chain and private key.
fnet_tls_role_t
TLS roles.
Definition: fnet_tls.h:63
fnet_ssize_t fnet_tls_socket_recv(fnet_tls_socket_t tls_sock, fnet_uint8_t *buf, fnet_size_t len)
Receive data from a TLS socket.
void * fnet_tls_socket_t
TLS socket descriptor.
Definition: fnet_tls.h:58
TLS Client.
Definition: fnet_tls.h:66
fnet_tls_socket_t fnet_tls_socket(fnet_tls_desc_t tls_desc, fnet_socket_t sock)
Create the TLS socket.
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:75
void fnet_tls_release(fnet_tls_desc_t tls_desc)
Release the TLS context.
fnet_return_t fnet_tls_set_ca_certificate(fnet_tls_desc_t tls_desc, const fnet_uint8_t *ca_certificate, fnet_size_t ca_certificate_size)
Assign Certificate Authority certificate.
long fnet_ssize_t
Signed integer type representing the size in bytes.
Definition: fnet_stdlib.h:60

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net