ocsp.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* ocsp.h
  2. *
  3. * Copyright (C) 2006-2017 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(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
  32. typedef struct OcspResponse WOLFSSL_OCSP_BASICRESP;
  33. typedef struct OcspRequest WOLFSSL_OCSP_CERTID;
  34. typedef struct OcspRequest WOLFSSL_OCSP_ONEREQ;
  35. #endif
  36. WOLFSSL_LOCAL int InitOCSP(WOLFSSL_OCSP*, WOLFSSL_CERT_MANAGER*);
  37. WOLFSSL_LOCAL void FreeOCSP(WOLFSSL_OCSP*, int dynamic);
  38. WOLFSSL_LOCAL int CheckCertOCSP(WOLFSSL_OCSP*, DecodedCert*,
  39. WOLFSSL_BUFFER_INFO* responseBuffer);
  40. WOLFSSL_LOCAL int CheckCertOCSP_ex(WOLFSSL_OCSP*, DecodedCert*,
  41. WOLFSSL_BUFFER_INFO* responseBuffer, WOLFSSL* ssl);
  42. WOLFSSL_LOCAL int CheckOcspRequest(WOLFSSL_OCSP* ocsp,
  43. OcspRequest* ocspRequest, WOLFSSL_BUFFER_INFO* responseBuffer);
  44. #if defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
  45. WOLFSSL_API int wolfSSL_OCSP_resp_find_status(WOLFSSL_OCSP_BASICRESP *bs,
  46. WOLFSSL_OCSP_CERTID* id, int* status, int* reason,
  47. WOLFSSL_ASN1_TIME** revtime, WOLFSSL_ASN1_TIME** thisupd,
  48. WOLFSSL_ASN1_TIME** nextupd);
  49. WOLFSSL_API const char *wolfSSL_OCSP_cert_status_str(long s);
  50. WOLFSSL_API int wolfSSL_OCSP_check_validity(WOLFSSL_ASN1_TIME* thisupd,
  51. WOLFSSL_ASN1_TIME* nextupd, long sec, long maxsec);
  52. WOLFSSL_API void wolfSSL_OCSP_CERTID_free(WOLFSSL_OCSP_CERTID* certId);
  53. WOLFSSL_API WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_cert_to_id(
  54. const WOLFSSL_EVP_MD *dgst, const WOLFSSL_X509 *subject,
  55. const WOLFSSL_X509 *issuer);
  56. WOLFSSL_API void wolfSSL_OCSP_BASICRESP_free(WOLFSSL_OCSP_BASICRESP* basicResponse);
  57. WOLFSSL_API int wolfSSL_OCSP_basic_verify(WOLFSSL_OCSP_BASICRESP *bs,
  58. WOLF_STACK_OF(WOLFSSL_X509) *certs, WOLFSSL_X509_STORE *st, unsigned long flags);
  59. WOLFSSL_API void wolfSSL_OCSP_RESPONSE_free(OcspResponse* response);
  60. WOLFSSL_API OcspResponse* wolfSSL_d2i_OCSP_RESPONSE_bio(WOLFSSL_BIO* bio,
  61. OcspResponse** response);
  62. WOLFSSL_API OcspResponse* wolfSSL_d2i_OCSP_RESPONSE(OcspResponse** response,
  63. const unsigned char** data, int len);
  64. WOLFSSL_API int wolfSSL_i2d_OCSP_RESPONSE(OcspResponse* response,
  65. unsigned char** data);
  66. WOLFSSL_API int wolfSSL_OCSP_response_status(OcspResponse *response);
  67. WOLFSSL_API const char *wolfSSL_OCSP_response_status_str(long s);
  68. WOLFSSL_API WOLFSSL_OCSP_BASICRESP* wolfSSL_OCSP_response_get1_basic(
  69. OcspResponse* response);
  70. WOLFSSL_API OcspRequest* wolfSSL_OCSP_REQUEST_new(void);
  71. WOLFSSL_API void wolfSSL_OCSP_REQUEST_free(OcspRequest* request);
  72. WOLFSSL_API int wolfSSL_i2d_OCSP_REQUEST(OcspRequest* request,
  73. unsigned char** data);
  74. WOLFSSL_API WOLFSSL_OCSP_ONEREQ* wolfSSL_OCSP_request_add0_id(OcspRequest *req,
  75. WOLFSSL_OCSP_CERTID *cid);
  76. #endif
  77. #ifdef __cplusplus
  78. } /* extern "C" */
  79. #endif
  80. #endif /* HAVE_OCSP */
  81. #endif /* WOLFSSL_OCSP_H */