1 /*
2  * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 #include "esp_tls.h"
9 
10 /**
11  * Internal Callback for creating ssl handle for wolfssl
12  */
13 int esp_create_wolfssl_handle(const char *hostname, size_t hostlen, const void *cfg, esp_tls_t *tls);
14 
15 /**
16  * Internal Callback for wolfssl_handshake
17  */
18 int esp_wolfssl_handshake(esp_tls_t *tls, const esp_tls_cfg_t *cfg);
19 
20 /**
21  * Internal Callback API for wolfssl_ssl_read
22  */
23 ssize_t esp_wolfssl_read(esp_tls_t *tls, char *data, size_t datalen);
24 
25 /**
26  * Internal callback API for wolfssl_ssl_write
27  */
28 ssize_t esp_wolfssl_write(esp_tls_t *tls, const char *data, size_t datalen);
29 
30 /**
31  * Internal Callback for wolfssl_cleanup , frees up all the memory used by wolfssl
32  */
33 void esp_wolfssl_cleanup(esp_tls_t *tls);
34 
35 /**
36  * Internal Callback for Certificate verification for wolfssl
37  */
38 void esp_wolfssl_verify_certificate(esp_tls_t *tls);
39 
40 /**
41  * Internal Callback for deleting the wolfssl connection
42  */
43 void esp_wolfssl_conn_delete(esp_tls_t *tls);
44 
45 /**
46  * Internal Callback for wolfssl_get_bytes_avail
47  */
48 ssize_t esp_wolfssl_get_bytes_avail(esp_tls_t *tls);
49 
50 /**
51  * Callback function for setting global CA store data for TLS/SSL using wolfssl
52  */
53 esp_err_t esp_wolfssl_set_global_ca_store(const unsigned char *cacert_pem_buf, const unsigned int cacert_pem_bytes);
54 
55 /**
56  * Callback function for freeing global ca store for TLS/SSL using wolfssl
57  */
58 void esp_wolfssl_free_global_ca_store(void);
59 
60 /**
61  *
62  * Callback function for Initializing the global ca store for TLS?SSL using wolfssl
63  */
64 esp_err_t esp_wolfssl_init_global_ca_store(void);
65 
66 /**
67  * wolfSSL function for Initializing socket wrappers (no-operation for wolfSSL)
68  */
esp_wolfssl_net_init(esp_tls_t * tls)69 static inline void esp_wolfssl_net_init(esp_tls_t *tls)
70 {
71 }
72 
73 #ifdef CONFIG_ESP_TLS_SERVER
74 
75 /**
76  * Function to Create ESP-TLS Server session with wolfssl Stack
77  */
78 int esp_wolfssl_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls_t *tls);
79 
80 /*
81  * Delete Server Session
82  */
83 void esp_wolfssl_server_session_delete(esp_tls_t *tls);
84 
85 #endif
86