esp_tls_mbedtls.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright 2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #include "esp_tls.h"
  15. /**
  16. * Internal Callback API for mbedtls_ssl_read
  17. */
  18. ssize_t esp_mbedtls_read(esp_tls_t *tls, char *data, size_t datalen);
  19. /**
  20. * Internal callback API for mbedtls_ssl_write
  21. */
  22. ssize_t esp_mbedtls_write(esp_tls_t *tls, const char *data, size_t datalen);
  23. /**
  24. * Internal Callback for mbedtls_handshake
  25. */
  26. int esp_mbedtls_handshake(esp_tls_t *tls, const esp_tls_cfg_t *cfg);
  27. /**
  28. * Internal Callback for mbedtls_cleanup , frees up all the memory used by mbedtls
  29. */
  30. void esp_mbedtls_cleanup(esp_tls_t *tls);
  31. /**
  32. * Internal Callback for Certificate verification for mbedtls
  33. */
  34. void esp_mbedtls_verify_certificate(esp_tls_t *tls);
  35. /**
  36. * Internal Callback for deleting the mbedtls connection
  37. */
  38. void esp_mbedtls_conn_delete(esp_tls_t *tls);
  39. /**
  40. * Internal Callback for mbedtls_get_bytes_avail
  41. */
  42. ssize_t esp_mbedtls_get_bytes_avail(esp_tls_t *tls);
  43. /**
  44. * Internal Callback for creating ssl handle for mbedtls
  45. */
  46. esp_err_t esp_create_mbedtls_handle(const char *hostname, size_t hostlen, const void *cfg, esp_tls_t *tls);
  47. #ifdef CONFIG_ESP_TLS_SERVER
  48. /**
  49. * Internal Callback for set_server_config
  50. *
  51. * /note :- can only be used with mbedtls ssl library
  52. */
  53. esp_err_t set_server_config(esp_tls_cfg_server_t *cfg, esp_tls_t *tls);
  54. /**
  55. * Internal Callback for mbedtls_server_session_create
  56. *
  57. * /note :- The function can only be used with mbedtls ssl library
  58. */
  59. int esp_mbedtls_server_session_create(esp_tls_cfg_server_t *cfg, int sockfd, esp_tls_t *tls);
  60. /**
  61. * Internal Callback for mbedtls_server_session_delete
  62. *
  63. * /note :- The function can only be used with mbedtls ssl library
  64. */
  65. void esp_mbedtls_server_session_delete(esp_tls_t *tls);
  66. #endif
  67. /**
  68. * Internal Callback for set_client_config_function
  69. */
  70. esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t *cfg, esp_tls_t *tls);
  71. /**
  72. * Internal Callback for mbedtls_init_global_ca_store
  73. */
  74. esp_err_t esp_mbedtls_init_global_ca_store(void);
  75. /**
  76. * Callback function for setting global CA store data for TLS/SSL using mbedtls
  77. */
  78. esp_err_t esp_mbedtls_set_global_ca_store(const unsigned char *cacert_pem_buf, const unsigned int cacert_pem_bytes);
  79. /**
  80. * Internal Callback for esp_tls_global_ca_store
  81. */
  82. mbedtls_x509_crt *esp_mbedtls_get_global_ca_store(void);
  83. /**
  84. * Callback function for freeing global ca store for TLS/SSL using mbedtls
  85. */
  86. void esp_mbedtls_free_global_ca_store(void);