Files

37 lines
1.0 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
#ifndef GXFP_TLS_H
#define GXFP_TLS_H
#include <stddef.h>
#include <stdint.h>
#include <mbedtls/ctr_drbg.h>
#include <mbedtls/entropy.h>
#include <mbedtls/ssl.h>
#include "gxfp/device.h"
struct gxfp_tls {
struct gxfp_device *device;
mbedtls_ssl_context ssl;
mbedtls_ssl_config config;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_entropy_context entropy;
unsigned char *rx_buffer;
size_t rx_length;
size_t rx_offset;
int initialized;
};
int gxfp_tls_init(struct gxfp_tls *tls, struct gxfp_device *device);
int gxfp_tls_handshake(struct gxfp_tls *tls);
int gxfp_tls_handshake_timeout(struct gxfp_tls *tls, int timeout_ms);
int gxfp_tls_write_all(struct gxfp_tls *tls, const void *data, size_t len);
int gxfp_tls_read(struct gxfp_tls *tls, void *data, size_t capacity,
size_t *data_len);
int gxfp_tls_read_timeout(struct gxfp_tls *tls, void *data, size_t capacity,
size_t *data_len, int timeout_ms);
void gxfp_tls_close(struct gxfp_tls *tls);
#endif