ssl_methods.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // Copyright 2015-2016 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. #ifndef _SSL_METHODS_H_
  14. #define _SSL_METHODS_H_
  15. #include "ssl_types.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * TLS method function implement
  21. */
  22. #define IMPLEMENT_TLS_METHOD_FUNC(func_name, \
  23. new, free, \
  24. handshake, shutdown, clear, \
  25. read, send, pending, \
  26. set_fd, set_hostname, get_fd, \
  27. set_bufflen, \
  28. get_verify_result, \
  29. get_state) \
  30. static const SSL_METHOD_FUNC func_name LOCAL_ATRR = { \
  31. new, \
  32. free, \
  33. handshake, \
  34. shutdown, \
  35. clear, \
  36. read, \
  37. send, \
  38. pending, \
  39. set_fd, \
  40. set_hostname, \
  41. get_fd, \
  42. set_bufflen, \
  43. get_verify_result, \
  44. get_state \
  45. };
  46. #define IMPLEMENT_TLS_METHOD(ver, mode, fun, func_name) \
  47. const SSL_METHOD* func_name(void) { \
  48. static const SSL_METHOD func_name##_data LOCAL_ATRR = { \
  49. ver, \
  50. mode, \
  51. &(fun), \
  52. }; \
  53. return &func_name##_data; \
  54. }
  55. #define IMPLEMENT_SSL_METHOD(ver, mode, fun, func_name) \
  56. const SSL_METHOD* func_name(void) { \
  57. static const SSL_METHOD func_name##_data LOCAL_ATRR = { \
  58. ver, \
  59. mode, \
  60. &(fun), \
  61. }; \
  62. return &func_name##_data; \
  63. }
  64. #define IMPLEMENT_X509_METHOD(func_name, \
  65. new, \
  66. free, \
  67. load, \
  68. show_info) \
  69. const X509_METHOD* func_name(void) { \
  70. static const X509_METHOD func_name##_data LOCAL_ATRR = { \
  71. new, \
  72. free, \
  73. load, \
  74. show_info \
  75. }; \
  76. return &func_name##_data; \
  77. }
  78. #define IMPLEMENT_PKEY_METHOD(func_name, \
  79. new, \
  80. free, \
  81. load) \
  82. const PKEY_METHOD* func_name(void) { \
  83. static const PKEY_METHOD func_name##_data LOCAL_ATRR = { \
  84. new, \
  85. free, \
  86. load \
  87. }; \
  88. return &func_name##_data; \
  89. }
  90. /**
  91. * @brief get X509 object method
  92. *
  93. * @param none
  94. *
  95. * @return X509 object method point
  96. */
  97. const X509_METHOD* X509_method(void);
  98. /**
  99. * @brief get private key object method
  100. *
  101. * @param none
  102. *
  103. * @return private key object method point
  104. */
  105. const PKEY_METHOD* EVP_PKEY_method(void);
  106. #ifdef __cplusplus
  107. }
  108. #endif
  109. #endif