ssl_x509.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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_X509_H_
  14. #define _SSL_X509_H_
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "ssl_types.h"
  19. #include "ssl_stack.h"
  20. DEFINE_STACK_OF(X509_NAME)
  21. /**
  22. * @brief create a X509 certification object according to input X509 certification
  23. *
  24. * @param ix - input X509 certification point
  25. *
  26. * @return new X509 certification object point
  27. */
  28. X509* __X509_new(X509 *ix);
  29. /**
  30. * @brief create a X509 certification object
  31. *
  32. * @param none
  33. *
  34. * @return X509 certification object point
  35. */
  36. X509* X509_new(void);
  37. /**
  38. * @brief load a character certification context into system context. If '*cert' is pointed to the
  39. * certification, then load certification into it. Or create a new X509 certification object
  40. *
  41. * @param cert - a point pointed to X509 certification
  42. * @param buffer - a point pointed to the certification context memory point
  43. * @param length - certification bytes
  44. *
  45. * @return X509 certification object point
  46. */
  47. X509* d2i_X509(X509 **cert, const unsigned char *buffer, long len);
  48. /**
  49. * @brief free a X509 certification object
  50. *
  51. * @param x - X509 certification object point
  52. *
  53. * @return none
  54. */
  55. void X509_free(X509 *x);
  56. /**
  57. * @brief set SSL context client CA certification
  58. *
  59. * @param ctx - SSL context point
  60. * @param x - X509 certification point
  61. *
  62. * @return result
  63. * 0 : failed
  64. * 1 : OK
  65. */
  66. int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x);
  67. /**
  68. * @brief add CA client certification into the SSL
  69. *
  70. * @param ssl - SSL point
  71. * @param x - X509 certification point
  72. *
  73. * @return result
  74. * 0 : failed
  75. * 1 : OK
  76. */
  77. int SSL_add_client_CA(SSL *ssl, X509 *x);
  78. /**
  79. * @brief load certification into the SSL
  80. *
  81. * @param ssl - SSL point
  82. * @param len - data bytes
  83. * @param d - data point
  84. *
  85. * @return result
  86. * 0 : failed
  87. * 1 : OK
  88. *
  89. */
  90. int SSL_use_certificate_ASN1(SSL *ssl, int len, const unsigned char *d);
  91. /**
  92. * @brief set SSL context client CA certification
  93. *
  94. * @param store - pointer to X509_STORE
  95. * @param x - pointer to X509 certification point
  96. *
  97. * @return result
  98. * 0 : failed
  99. * 1 : OK
  100. */
  101. int X509_STORE_add_cert(X509_STORE *store, X509 *x);
  102. /**
  103. * @brief load a character certification context into system context.
  104. *
  105. * If '*cert' is pointed to the certification, then load certification
  106. * into it, or create a new X509 certification object.
  107. *
  108. * @param bp - pointer to BIO
  109. * @param buffer - pointer to the certification context memory
  110. * @param cb - pointer to a callback which queries pass phrase used
  111. for encrypted PEM structure
  112. * @param u - pointer to arbitary data passed by application to callback
  113. *
  114. * @return X509 certification object point
  115. */
  116. X509 * PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb cb, void *u);
  117. /**
  118. * @brief load a character certification context into system context.
  119. *
  120. * Current implementation directly calls PEM_read_bio_X509
  121. *
  122. * @param bp - pointer to BIO
  123. * @param buffer - pointer to the certification context memory
  124. * @param cb - pointer to the callback (not implemented)
  125. * @param u - pointer to arbitrary data (not implemented)
  126. *
  127. * @return X509 certification object point
  128. */
  129. X509 *PEM_read_bio_X509_AUX(BIO *bp, X509 **cert, pem_password_cb *cb, void *u);
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133. #endif