nettype_tls.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * @Author: jiejie
  3. * @Github: https://github.com/jiejieTop
  4. * @Date: 2020-01-11 19:45:44
  5. * @LastEditTime: 2020-10-17 14:14:11
  6. * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
  7. */
  8. #ifndef _NETTYPE_TLS_H_
  9. #define _NETTYPE_TLS_H_
  10. #include "mqtt_defconfig.h"
  11. #include "network.h"
  12. #include "mqtt_error.h"
  13. #include "mqtt_log.h"
  14. #ifndef MQTT_NETWORK_TYPE_NO_TLS
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. typedef struct nettype_tls_params {
  19. mbedtls_net_context socket_fd; /**< mbed TLS network context. */
  20. mbedtls_entropy_context entropy; /**< mbed TLS entropy. */
  21. mbedtls_ctr_drbg_context ctr_drbg; /**< mbed TLS ctr_drbg. */
  22. mbedtls_ssl_context ssl; /**< mbed TLS control context. */
  23. mbedtls_ssl_config ssl_conf; /**< mbed TLS configuration context. */
  24. #if defined(MBEDTLS_X509_CRT_PARSE_C)
  25. mbedtls_x509_crt ca_cert; /**< mbed TLS CA certification. */
  26. mbedtls_x509_crt client_cert; /**< mbed TLS Client certification. */
  27. #endif
  28. mbedtls_pk_context private_key; /**< mbed TLS Client key. */
  29. } nettype_tls_params_t;
  30. int nettype_tls_read(network_t *n, unsigned char *buf, int len, int timeout);
  31. int nettype_tls_write(network_t *n, unsigned char *buf, int len, int timeout);
  32. int nettype_tls_connect(network_t* n);
  33. void nettype_tls_disconnect(network_t* n);
  34. #endif /* MQTT_NETWORK_TYPE_NO_TLS */
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif