ocsp.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* ocsp.h
  2. *
  3. * Copyright (C) 2006-2021 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. /* wolfSSL OCSP API */
  22. #ifndef WOLFSSL_OCSP_H
  23. #define WOLFSSL_OCSP_H
  24. #ifdef HAVE_OCSP
  25. #include <wolfssl/ssl.h>
  26. #include <wolfssl/wolfcrypt/asn.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. typedef struct WOLFSSL_OCSP WOLFSSL_OCSP;
  31. #if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) || defined(WOLFSSL_NGINX) ||\
  32. defined(WOLFSSL_HAPROXY) || defined(HAVE_LIGHTY)
  33. typedef struct OcspResponse WOLFSSL_OCSP_BASICRESP;
  34. typedef struct OcspEntry WOLFSSL_OCSP_CERTID;
  35. typedef struct OcspEntry WOLFSSL_OCSP_SINGLERESP;
  36. typedef struct OcspRequest WOLFSSL_OCSP_ONEREQ;
  37. typedef struct OcspRequest WOLFSSL_OCSP_REQUEST;
  38. #endif
  39. WOLFSSL_LOCAL int InitOCSP(WOLFSSL_OCSP*, WOLFSSL_CERT_MANAGER*);
  40. WOLFSSL_LOCAL void FreeOCSP(WOLFSSL_OCSP*, int dynamic);
  41. WOLFSSL_LOCAL int CheckCertOCSP(WOLFSSL_OCSP*, DecodedCert*,
  42. WOLFSSL_BUFFER_INFO* responseBuffer);
  43. WOLFSSL_LOCAL int CheckCertOCSP_ex(WOLFSSL_OCSP*, DecodedCert*,
  44. WOLFSSL_BUFFER_INFO* responseBuffer, WOLFSSL* ssl);
  45. WOLFSSL_LOCAL int CheckOcspRequest(WOLFSSL_OCSP* ocsp,
  46. OcspRequest* ocspRequest, WOLFSSL_BUFFER_INFO* responseBuffer);
  47. WOLFSSL_LOCAL int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int responseSz,
  48. WOLFSSL_BUFFER_INFO *responseBuffer, CertStatus *status,
  49. OcspEntry *entry, OcspRequest *ocspRequest);
  50. #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
  51. defined(WOLFSSL_APACHE_HTTPD) || defined(HAVE_LIGHTY)
  52. WOLFSSL_API int wolfSSL_OCSP_resp_find_status(WOLFSSL_OCSP_BASICRESP *bs,
  53. WOLFSSL_OCSP_CERTID *id, int *status, int *reason,
  54. WOLFSSL_ASN1_TIME **revtime, WOLFSSL_ASN1_TIME **thisupd,
  55. WOLFSSL_ASN1_TIME **nextupd);
  56. WOLFSSL_API const char *wolfSSL_OCSP_cert_status_str(long s);
  57. WOLFSSL_API int wolfSSL_OCSP_check_validity(WOLFSSL_ASN1_TIME* thisupd,
  58. WOLFSSL_ASN1_TIME* nextupd, long sec, long maxsec);
  59. WOLFSSL_API void wolfSSL_OCSP_CERTID_free(WOLFSSL_OCSP_CERTID* certId);
  60. WOLFSSL_API WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_cert_to_id(
  61. const WOLFSSL_EVP_MD *dgst, const WOLFSSL_X509 *subject,
  62. const WOLFSSL_X509 *issuer);
  63. WOLFSSL_API void wolfSSL_OCSP_BASICRESP_free(WOLFSSL_OCSP_BASICRESP* basicResponse);
  64. WOLFSSL_API int wolfSSL_OCSP_basic_verify(WOLFSSL_OCSP_BASICRESP *bs,
  65. WOLF_STACK_OF(WOLFSSL_X509) *certs, WOLFSSL_X509_STORE *st, unsigned long flags);
  66. WOLFSSL_API void wolfSSL_OCSP_RESPONSE_free(OcspResponse* response);
  67. #ifndef NO_BIO
  68. WOLFSSL_API OcspResponse* wolfSSL_d2i_OCSP_RESPONSE_bio(WOLFSSL_BIO* bio,
  69. OcspResponse** response);
  70. #endif
  71. WOLFSSL_API OcspResponse* wolfSSL_d2i_OCSP_RESPONSE(OcspResponse** response,
  72. const unsigned char** data, int len);
  73. WOLFSSL_API int wolfSSL_i2d_OCSP_RESPONSE(OcspResponse* response,
  74. unsigned char** data);
  75. WOLFSSL_API int wolfSSL_OCSP_response_status(OcspResponse *response);
  76. WOLFSSL_API const char *wolfSSL_OCSP_response_status_str(long s);
  77. WOLFSSL_API WOLFSSL_OCSP_BASICRESP* wolfSSL_OCSP_response_get1_basic(
  78. OcspResponse* response);
  79. WOLFSSL_API OcspRequest* wolfSSL_OCSP_REQUEST_new(void);
  80. WOLFSSL_API void wolfSSL_OCSP_REQUEST_free(OcspRequest* request);
  81. WOLFSSL_API int wolfSSL_i2d_OCSP_REQUEST(OcspRequest* request,
  82. unsigned char** data);
  83. WOLFSSL_API WOLFSSL_OCSP_ONEREQ* wolfSSL_OCSP_request_add0_id(OcspRequest *req,
  84. WOLFSSL_OCSP_CERTID *cid);
  85. WOLFSSL_API WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_CERTID_dup(WOLFSSL_OCSP_CERTID*);
  86. #ifndef NO_BIO
  87. WOLFSSL_API int wolfSSL_i2d_OCSP_REQUEST_bio(WOLFSSL_BIO* out,
  88. WOLFSSL_OCSP_REQUEST *req);
  89. #endif
  90. WOLFSSL_API int wolfSSL_i2d_OCSP_CERTID(WOLFSSL_OCSP_CERTID *, unsigned char **);
  91. WOLFSSL_API const WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_SINGLERESP_get0_id(const WOLFSSL_OCSP_SINGLERESP *single);
  92. WOLFSSL_API int wolfSSL_OCSP_id_cmp(WOLFSSL_OCSP_CERTID *a, WOLFSSL_OCSP_CERTID *b);
  93. WOLFSSL_API int wolfSSL_OCSP_single_get0_status(WOLFSSL_OCSP_SINGLERESP *single,
  94. int *reason,
  95. WOLFSSL_ASN1_TIME **revtime,
  96. WOLFSSL_ASN1_TIME **thisupd,
  97. WOLFSSL_ASN1_TIME **nextupd);
  98. WOLFSSL_API int wolfSSL_OCSP_resp_count(WOLFSSL_OCSP_BASICRESP *bs);
  99. WOLFSSL_API WOLFSSL_OCSP_SINGLERESP* wolfSSL_OCSP_resp_get0(WOLFSSL_OCSP_BASICRESP *bs, int idx);
  100. #endif
  101. #ifdef OPENSSL_EXTRA
  102. WOLFSSL_API int wolfSSL_OCSP_REQUEST_add_ext(OcspRequest* req,
  103. WOLFSSL_X509_EXTENSION* ext, int idx);
  104. WOLFSSL_API OcspResponse* wolfSSL_OCSP_response_create(int status,
  105. WOLFSSL_OCSP_BASICRESP* bs);
  106. WOLFSSL_API const char* wolfSSL_OCSP_crl_reason_str(long s);
  107. WOLFSSL_API int wolfSSL_OCSP_id_get0_info(WOLFSSL_ASN1_STRING**,
  108. WOLFSSL_ASN1_OBJECT**, WOLFSSL_ASN1_STRING**,
  109. WOLFSSL_ASN1_INTEGER**, WOLFSSL_OCSP_CERTID*);
  110. WOLFSSL_API int wolfSSL_OCSP_request_add1_nonce(OcspRequest* req,
  111. unsigned char* val, int sz);
  112. WOLFSSL_API int wolfSSL_OCSP_check_nonce(OcspRequest* req,
  113. WOLFSSL_OCSP_BASICRESP* bs);
  114. #endif
  115. #ifdef __cplusplus
  116. } /* extern "C" */
  117. #endif
  118. #endif /* HAVE_OCSP */
  119. #endif /* WOLFSSL_OCSP_H */