client-tls.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* client-tls.h
  2. *
  3. * Copyright (C) 2006-2024 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifndef _CLIENT_TLS_H_
  22. #define _CLIENT_TLS_H_
  23. /* Local project, auto-generated configuration */
  24. #include "sdkconfig.h"
  25. #include <wolfssl/wolfcrypt/settings.h>
  26. #include <wolfssl/ssl.h>
  27. /* See main/Kconfig.projbuild for default configuration settings */
  28. #ifdef CONFIG_WOLFSSL_TARGET_HOST
  29. #define TLS_SMP_TARGET_HOST CONFIG_WOLFSSL_TARGET_HOST
  30. #else
  31. #define TLS_SMP_TARGET_HOST "192.168.1.37"
  32. #endif
  33. #ifdef CONFIG_WOLFSSL_TARGET_PORT
  34. #define TLS_SMP_DEFAULT_PORT CONFIG_WOLFSSL_TARGET_PORT
  35. #else
  36. #define TLS_SMP_DEFAULT_PORT 11111
  37. #endif
  38. #define TLS_SMP_CLIENT_TASK_NAME "tls_client_example"
  39. /* Reminder: Vanilla FreeRTOS is words, Espressif is bytes. */
  40. #if defined(WOLFSSL_ESP8266)
  41. #if defined(WOLFSSL_HAVE_KYBER)
  42. /* Minimum ESP8266 stack size = 10K with Kyber.
  43. * Note there's a maximum not far away as Kyber needs heap
  44. * and the total DRAM is typically only 80KB total. */
  45. #define TLS_SMP_CLIENT_TASK_BYTES (11 * 1024)
  46. #else
  47. /* Minimum ESP8266 stack size = 6K without Kyber */
  48. #define TLS_SMP_CLIENT_TASK_BYTES (6 * 1024)
  49. #endif
  50. #else
  51. #if defined(WOLFSSL_HAVE_KYBER)
  52. /* Minimum ESP32 stack size = 12K with Kyber enabled. */
  53. #define TLS_SMP_CLIENT_TASK_BYTES (12 * 1024)
  54. #else
  55. /* Minimum ESP32 stack size = 8K without Kyber */
  56. #define TLS_SMP_CLIENT_TASK_BYTES (8 * 1024)
  57. #endif
  58. #endif
  59. #define TLS_SMP_CLIENT_TASK_PRIORITY 8
  60. #if defined(SINGLE_THREADED)
  61. #define WOLFSSL_ESP_TASK int
  62. #else
  63. #include <freertos/FreeRTOS.h>
  64. #define WOLFSSL_ESP_TASK void
  65. #endif
  66. typedef struct {
  67. int port;
  68. int loops;
  69. } tls_args;
  70. /* Function to show the ciphers available / in use. */
  71. #if defined(DEBUG_WOLFSSL)
  72. int ShowCiphers(WOLFSSL* ssl);
  73. #endif
  74. /* This is the TLS Client function, possibly in an RTOS thread. */
  75. WOLFSSL_ESP_TASK tls_smp_client_task(void* args);
  76. /* init will create an RTOS task, otherwise server is simply function call. */
  77. #if defined(SINGLE_THREADED)
  78. /* no init needed */
  79. #else
  80. WOLFSSL_ESP_TASK tls_smp_client_init(void* args);
  81. #endif
  82. #endif /* _SERVER_TLS_ */