ocsp.h
1 /* ocsp.h
2  *
3  * Copyright (C) 2006-2020 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 
22 
23 
24 /* wolfSSL OCSP API */
25 
26 #ifndef WOLFSSL_OCSP_H
27 #define WOLFSSL_OCSP_H
28 
29 #ifdef HAVE_OCSP
30 
31 #include <wolfssl/ssl.h>
32 #include <wolfssl/wolfcrypt/asn.h>
33 
34 #ifdef __cplusplus
35  extern "C" {
36 #endif
37 
38 typedef struct WOLFSSL_OCSP WOLFSSL_OCSP;
39 
40 #if defined(OPENSSL_ALL) || defined(OPENSSL_EXTRA) || defined(WOLFSSL_NGINX) ||\
41  defined(WOLFSSL_HAPROXY)
43 
44 typedef struct OcspRequest WOLFSSL_OCSP_CERTID;
45 
46 typedef struct OcspRequest WOLFSSL_OCSP_ONEREQ;
47 
48 typedef struct OcspRequest WOLFSSL_OCSP_REQUEST;
49 #endif
50 
51 WOLFSSL_LOCAL int InitOCSP(WOLFSSL_OCSP*, WOLFSSL_CERT_MANAGER*);
52 WOLFSSL_LOCAL void FreeOCSP(WOLFSSL_OCSP*, int dynamic);
53 
54 WOLFSSL_LOCAL int CheckCertOCSP(WOLFSSL_OCSP*, DecodedCert*,
55  WOLFSSL_BUFFER_INFO* responseBuffer);
56 WOLFSSL_LOCAL int CheckCertOCSP_ex(WOLFSSL_OCSP*, DecodedCert*,
57  WOLFSSL_BUFFER_INFO* responseBuffer, WOLFSSL* ssl);
58 WOLFSSL_LOCAL int CheckOcspRequest(WOLFSSL_OCSP* ocsp,
59  OcspRequest* ocspRequest, WOLFSSL_BUFFER_INFO* responseBuffer);
60 WOLFSSL_LOCAL int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int responseSz,
61  WOLFSSL_BUFFER_INFO *responseBuffer, CertStatus *status,
62  OcspEntry *entry, OcspRequest *ocspRequest);
63 
64 #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
65  defined(WOLFSSL_APACHE_HTTPD)
66 
67  WOLFSSL_API int wolfSSL_OCSP_resp_find_status(WOLFSSL_OCSP_BASICRESP *bs,
68  WOLFSSL_OCSP_CERTID *id, int *status, int *reason,
69  WOLFSSL_ASN1_TIME **revtime, WOLFSSL_ASN1_TIME **thisupd,
70  WOLFSSL_ASN1_TIME **nextupd);
71 WOLFSSL_API const char *wolfSSL_OCSP_cert_status_str(long s);
72 WOLFSSL_API int wolfSSL_OCSP_check_validity(WOLFSSL_ASN1_TIME* thisupd,
73  WOLFSSL_ASN1_TIME* nextupd, long sec, long maxsec);
74 
75 WOLFSSL_API void wolfSSL_OCSP_CERTID_free(WOLFSSL_OCSP_CERTID* certId);
76 WOLFSSL_API WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_cert_to_id(
77  const WOLFSSL_EVP_MD *dgst, const WOLFSSL_X509 *subject,
78  const WOLFSSL_X509 *issuer);
79 
80 WOLFSSL_API void wolfSSL_OCSP_BASICRESP_free(WOLFSSL_OCSP_BASICRESP* basicResponse);
81 WOLFSSL_API int wolfSSL_OCSP_basic_verify(WOLFSSL_OCSP_BASICRESP *bs,
82  WOLF_STACK_OF(WOLFSSL_X509) *certs, WOLFSSL_X509_STORE *st, unsigned long flags);
83 
84 WOLFSSL_API void wolfSSL_OCSP_RESPONSE_free(OcspResponse* response);
85 WOLFSSL_API OcspResponse* wolfSSL_d2i_OCSP_RESPONSE_bio(WOLFSSL_BIO* bio,
86  OcspResponse** response);
87 WOLFSSL_API OcspResponse* wolfSSL_d2i_OCSP_RESPONSE(OcspResponse** response,
88  const unsigned char** data, int len);
89 WOLFSSL_API int wolfSSL_i2d_OCSP_RESPONSE(OcspResponse* response,
90  unsigned char** data);
91 WOLFSSL_API int wolfSSL_OCSP_response_status(OcspResponse *response);
92 WOLFSSL_API const char *wolfSSL_OCSP_response_status_str(long s);
93 WOLFSSL_API WOLFSSL_OCSP_BASICRESP* wolfSSL_OCSP_response_get1_basic(
94  OcspResponse* response);
95 
96 WOLFSSL_API OcspRequest* wolfSSL_OCSP_REQUEST_new(void);
97 WOLFSSL_API void wolfSSL_OCSP_REQUEST_free(OcspRequest* request);
98 WOLFSSL_API int wolfSSL_i2d_OCSP_REQUEST(OcspRequest* request,
99  unsigned char** data);
100 WOLFSSL_API WOLFSSL_OCSP_ONEREQ* wolfSSL_OCSP_request_add0_id(OcspRequest *req,
101  WOLFSSL_OCSP_CERTID *cid);
102 WOLFSSL_API WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_CERTID_dup(WOLFSSL_OCSP_CERTID*);
103 WOLFSSL_API int wolfSSL_i2d_OCSP_REQUEST_bio(WOLFSSL_BIO* out,
104  WOLFSSL_OCSP_REQUEST *req);
105 
106 #endif
107 #ifdef OPENSSL_EXTRA
108 WOLFSSL_API int wolfSSL_OCSP_REQUEST_add_ext(OcspRequest* req,
109  WOLFSSL_X509_EXTENSION* ext, int idx);
110 WOLFSSL_API OcspResponse* wolfSSL_OCSP_response_create(int status,
112 WOLFSSL_API const char* wolfSSL_OCSP_crl_reason_str(long s);
113 
114 WOLFSSL_API int wolfSSL_OCSP_id_get0_info(WOLFSSL_ASN1_STRING**,
117 
118 WOLFSSL_API int wolfSSL_OCSP_request_add1_nonce(OcspRequest* req,
119  unsigned char* val, int sz);
120 WOLFSSL_API int wolfSSL_OCSP_check_nonce(OcspRequest* req,
122 #endif
123 
124 
125 #ifdef __cplusplus
126  } /* extern "C" */
127 #endif
128 
129 
130 #endif /* HAVE_OCSP */
131 #endif /* WOLFSSL_OCSP_H */
132 
133 
Definition: asn.h:1361
Definition: asn.h:1336
Definition: asn.h:1279
WOLFSSL_API WOLF_STACK_OF(WOLFSSL_X509) *wolfSSL_get_peer_cert_chain(const WOLFSSL *)
This function gets the peer’s certificate chain.
Definition: ssl.c:16984
Definition: asn.h:1303
Header file containing key wolfSSL API.
Definition: asn.h:793
Definition: ssl.h:264
Definition: x509v3.h:61
Definition: ssl.h:564
Definition: ssl.h:505
Definition: internal.h:3598
Definition: ssl.h:212
Definition: asn_public.h:178
Definition: internal.h:1857
Definition: internal.h:1958
Definition: ssl.h:461
Definition: internal.h:3849
Definition: asn_public.h:213