Google Cloud IoT device SDK for embedded C  1.0.2
iotc_bsp_tls.h
Go to the documentation of this file.
1 /* Copyright 2018-2020 Google LLC
2  *
3  * This is part of the Google Cloud IoT Device SDK for Embedded C.
4  * It is licensed under the BSD 3-Clause license; you may not use this file
5  * except in compliance with the License.
6  *
7  * You may obtain a copy of the License at:
8  * https://opensource.org/licenses/BSD-3-Clause
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __IOTC_BSP_TLS_H__
18 #define __IOTC_BSP_TLS_H__
19 
27 #include <stddef.h>
28 #include <stdint.h>
29 
36 typedef enum iotc_bsp_tls_state_e {
56 
68 
70  uint8_t* ca_cert_pem_buf;
73 
75  void* (*fp_libiotc_alloc)(size_t);
76 
78  void* (*fp_libiotc_calloc)(size_t, size_t);
79 
81  void* (*fp_libiotc_realloc)(void*, size_t);
82 
84  void (*fp_libiotc_free)(void*);
85 
88  const char* domain_name;
89 
91 
97 
110  iotc_bsp_tls_init_params_t* init_params);
120 
128 
140  uint8_t* data_ptr, size_t data_size,
141  int* bytes_read);
142 
150 
162  uint8_t* data_ptr, size_t data_size,
163  int* bytes_written);
164 
168  void* context, int* bytes_sent);
169 
173  void* context, int* bytes_sent);
174 
175 #endif /* __IOTC_BSP_TLS_H__ */
iotc_bsp_tls_state_t iotc_bsp_tls_write(iotc_bsp_tls_context_t *tls_context, uint8_t *data_ptr, size_t data_size, int *bytes_written)
Write data to a socket.
Can't initialize TLS library.
Definition: iotc_bsp_tls.h:40
iotc_bsp_tls_state_e
Definition: iotc_bsp_tls.h:36
iotc_bsp_tls_state_t iotc_bsp_tls_read(iotc_bsp_tls_context_t *tls_context, uint8_t *data_ptr, size_t data_size, int *bytes_read)
Reads data on a socket.
iotc_bsp_tls_state_t iotc_bsp_tls_init(iotc_bsp_tls_context_t **tls_context, iotc_bsp_tls_init_params_t *init_params)
Initializes a TLS library and creates a TLS context.
iotc_bsp_tls_state_t iotc_bsp_tls_send_callback(char *buf, int sz, void *context, int *bytes_sent)
void iotc_bsp_tls_context_t
The TLS context.
Definition: iotc_bsp_tls.h:96
TLS handshake is partially complete.
Definition: iotc_bsp_tls.h:50
size_t ca_cert_pem_buf_length
The length, in bytes, of ca_cert_pem_buf.
Definition: iotc_bsp_tls.h:72
uint8_t * ca_cert_pem_buf
A pointer to a buffer with root CA PEM certificates.
Definition: iotc_bsp_tls.h:70
iotc_bsp_tls_state_t iotc_bsp_tls_connect(iotc_bsp_tls_context_t *tls_context)
Starts a TLS handshake.
The TLS context parameters.
Definition: iotc_bsp_tls.h:65
void(* fp_libiotc_free)(void *)
A pointer to the client application's free memory function.
Definition: iotc_bsp_tls.h:84
iotc_bsp_tls_state_t iotc_bsp_tls_cleanup(iotc_bsp_tls_context_t **tls_context)
Frees a TLS context from memory and deletes any associated data.
int iotc_bsp_tls_pending(iotc_bsp_tls_context_t *tls_context)
Gets the pending readable bytes.
enum iotc_bsp_tls_state_e iotc_bsp_tls_state_t
The TLS function succeeded.
Definition: iotc_bsp_tls.h:38
TLS handshake is partially complete.
Definition: iotc_bsp_tls.h:47
void * libiotc_io_callback_context
Callback context.
Definition: iotc_bsp_tls.h:67
iotc_bsp_tls_state_t iotc_bsp_tls_recv_callback(char *buf, int sz, void *context, int *bytes_sent)
Can't validate CA certificate.
Definition: iotc_bsp_tls.h:42
Can't complete TLS handshake.
Definition: iotc_bsp_tls.h:44
const char * domain_name
A pointer to the host's domain name.
Definition: iotc_bsp_tls.h:88
struct iotc_bsp_tls_init_params_s iotc_bsp_tls_init_params_t
The TLS context parameters.