ssl_x509.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif