ssl_methods.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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, 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. get_fd, \
  41. set_bufflen, \
  42. get_verify_result, \
  43. get_state \
  44. };
  45. #define IMPLEMENT_TLS_METHOD(ver, mode, fun, func_name) \
  46. const SSL_METHOD* func_name(void) { \
  47. static const SSL_METHOD func_name##_data LOCAL_ATRR = { \
  48. ver, \
  49. mode, \
  50. &(fun), \
  51. }; \
  52. return &func_name##_data; \
  53. }
  54. #define IMPLEMENT_SSL_METHOD(ver, mode, fun, func_name) \
  55. const SSL_METHOD* func_name(void) { \
  56. static const SSL_METHOD func_name##_data LOCAL_ATRR = { \
  57. ver, \
  58. mode, \
  59. &(fun), \
  60. }; \
  61. return &func_name##_data; \
  62. }
  63. #define IMPLEMENT_X509_METHOD(func_name, \
  64. new, \
  65. free, \
  66. load, \
  67. show_info) \
  68. const X509_METHOD* func_name(void) { \
  69. static const X509_METHOD func_name##_data LOCAL_ATRR = { \
  70. new, \
  71. free, \
  72. load, \
  73. show_info \
  74. }; \
  75. return &func_name##_data; \
  76. }
  77. #define IMPLEMENT_PKEY_METHOD(func_name, \
  78. new, \
  79. free, \
  80. load) \
  81. const PKEY_METHOD* func_name(void) { \
  82. static const PKEY_METHOD func_name##_data LOCAL_ATRR = { \
  83. new, \
  84. free, \
  85. load \
  86. }; \
  87. return &func_name##_data; \
  88. }
  89. /**
  90. * @brief get X509 object method
  91. *
  92. * @param none
  93. *
  94. * @return X509 object method point
  95. */
  96. const X509_METHOD* X509_method(void);
  97. /**
  98. * @brief get private key object method
  99. *
  100. * @param none
  101. *
  102. * @return private key object method point
  103. */
  104. const PKEY_METHOD* EVP_PKEY_method(void);
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif