Developer World
Spresense Arduino Library v3.2.0-77d75a4
TLSClient.h
1/*
2 * TLSClient.h - TLSClient include file for Spresense Arduino
3 * Copyright 2019 Sony Semiconductor Solutions Corporation
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef _TLS_CLIENT_H_
21#define _TLS_CLIENT_H_
22
23#ifdef SUBCORE
24#error "TLSClient library is NOT supported by SubCore."
25#endif
26
27/****************************************************************************
28 * Included Files
29 ****************************************************************************/
30
31#include <mbedtls/config.h>
32#include <mbedtls/ctr_drbg.h>
33#include <mbedtls/entropy.h>
34#include <mbedtls/net_sockets.h>
35#include <mbedtls/platform.h>
36#include <mbedtls/ssl.h>
37
38typedef struct tlsClientContext_s
39{
40 mbedtls_ssl_context ssl;
41 mbedtls_ssl_config conf;
42 mbedtls_net_context serverFd;
43 mbedtls_ctr_drbg_context ctrDrbg;
44 mbedtls_entropy_context entropy;
45 mbedtls_x509_crt caCert;
46 mbedtls_x509_crt cliCert;
47 mbedtls_pk_context cliKey;
49
50void tlsInit(tlsClientContext_t *tlsCtx);
51void tlsShutdown(tlsClientContext_t *tlsCtx);
52int tlsConnect(tlsClientContext_t *tlsCtx, const char *host, uint32_t port,
53 uint32_t timeout,
54 const char *rootCA, size_t rootCASize,
55 const char *clientCA, size_t clientCASize,
56 const char *privateKey, size_t privateKeySize);
57int tlsGetAvailable(tlsClientContext_t *tlsCtx);
58int tlsRead(tlsClientContext_t *tlsCtx, uint8_t *buffer, int len);
59int tlsWrite(tlsClientContext_t *tlsCtx, const uint8_t *buffer, int len,
60 uint32_t timeout);
61
62#endif
Definition: TLSClient.h:39