2
0

wolfssl_demo.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* wolfssl_demo.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 WOLFSSL_DEMO_H_
  22. #define WOLFSSL_DEMO_H_
  23. #include <wolfssl/ssl.h>
  24. #include "FreeRTOS_IP.h"
  25. #include "FreeRTOS_Sockets.h"
  26. #define FREQ 10000 /* Hz */
  27. /* Client connects to the server with these details. */
  28. #define SERVER_IP "192.168.11.65"
  29. #define DEFAULT_PORT 11111
  30. typedef struct tagTestInfo
  31. {
  32. int id;
  33. int port;
  34. char name[32];
  35. const char* cipher;
  36. WOLFSSL_CTX* ctx;
  37. } TestInfo;
  38. /* Enable Crypt Unit Test */
  39. /* #define UNIT_TEST */
  40. /* Enable wolfcrypt test */
  41. /* can be enabled with benchmark test */
  42. #define CRYPT_TEST
  43. /* Enable benchmark */
  44. /* can be enabled with cyrpt test */
  45. /* #define BENCHMARK */
  46. /* Enable TLS client */
  47. /* #define TLS_CLIENT */
  48. /* Enable TLS Server */
  49. /* #define TLS_SERVER */
  50. #if defined(TLS_CLIENT)
  51. extern WOLFSSL_CTX *client_ctx;
  52. /* Use RSA certificates */
  53. #define USE_CERT_BUFFERS_2048
  54. /* Use ECC certificates */
  55. /*#define USE_CERT_BUFFERS_256*/
  56. #endif
  57. #if defined(TLS_SERVER)
  58. extern WOLFSSL_CTX *server_ctx;
  59. /* Use RSA certificates */
  60. #define USE_CERT_BUFFERS_2048
  61. /* Use ECC certificates */
  62. /*#define USE_CERT_BUFFERS_256*/
  63. #endif
  64. #if defined(USE_CERT_BUFFERS_2048) && defined(USE_CERT_BUFFERS_256)
  65. #error please set either macro USE_CERT_BUFFERS_2048 or USE_CERT_BUFFERS_256
  66. #endif
  67. #define FR_SOCKET_SUCCESS 0
  68. static void util_Cleanup(WOLFSSL_CTX *ctx, WOLFSSL *ssl) {
  69. printf("Cleaning up socket and wolfSSL objects.\n");
  70. if (ssl != NULL)
  71. wolfSSL_free(ssl);
  72. if (ctx != NULL)
  73. wolfSSL_CTX_free(ctx);
  74. wolfSSL_Cleanup();
  75. }
  76. static inline void util_inf_loop(WOLFSSL_CTX *ctx, WOLFSSL *ssl) {
  77. util_Cleanup(ctx, ssl);
  78. printf("Reached infinite loop.\n");
  79. while (1)
  80. ;
  81. }
  82. void TCPInit();
  83. void wolfSSL_TLS_client_init();
  84. int wolfSSL_TLS_client_do(void *pvParam);
  85. void wolfSSL_TLS_server_init();
  86. int wolfSSL_TLS_server_do(void *pvParam);
  87. void wolfSSL_TLS_cleanup();
  88. #endif /* WOLFSSL_DEMO_H_ */