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) || defined(HAVE_LIGHTY)
|
---|
42 | typedef struct OcspResponse WOLFSSL_OCSP_BASICRESP;
|
---|
43 |
|
---|
44 | typedef struct OcspEntry WOLFSSL_OCSP_CERTID;
|
---|
45 |
|
---|
46 | typedef struct OcspEntry WOLFSSL_OCSP_SINGLERESP;
|
---|
47 |
|
---|
48 | typedef struct OcspRequest WOLFSSL_OCSP_ONEREQ;
|
---|
49 |
|
---|
50 | typedef struct OcspRequest WOLFSSL_OCSP_REQUEST;
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | WOLFSSL_LOCAL int InitOCSP(WOLFSSL_OCSP*, WOLFSSL_CERT_MANAGER*);
|
---|
54 | WOLFSSL_LOCAL void FreeOCSP(WOLFSSL_OCSP*, int dynamic);
|
---|
55 |
|
---|
56 | WOLFSSL_LOCAL int CheckCertOCSP(WOLFSSL_OCSP*, DecodedCert*,
|
---|
57 | WOLFSSL_BUFFER_INFO* responseBuffer);
|
---|
58 | WOLFSSL_LOCAL int CheckCertOCSP_ex(WOLFSSL_OCSP*, DecodedCert*,
|
---|
59 | WOLFSSL_BUFFER_INFO* responseBuffer, WOLFSSL* ssl);
|
---|
60 | WOLFSSL_LOCAL int CheckOcspRequest(WOLFSSL_OCSP* ocsp,
|
---|
61 | OcspRequest* ocspRequest, WOLFSSL_BUFFER_INFO* responseBuffer);
|
---|
62 | WOLFSSL_LOCAL int CheckOcspResponse(WOLFSSL_OCSP *ocsp, byte *response, int responseSz,
|
---|
63 | WOLFSSL_BUFFER_INFO *responseBuffer, CertStatus *status,
|
---|
64 | OcspEntry *entry, OcspRequest *ocspRequest);
|
---|
65 |
|
---|
66 | #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
|
---|
67 | defined(WOLFSSL_APACHE_HTTPD) || defined(HAVE_LIGHTY)
|
---|
68 |
|
---|
69 | WOLFSSL_API int wolfSSL_OCSP_resp_find_status(WOLFSSL_OCSP_BASICRESP *bs,
|
---|
70 | WOLFSSL_OCSP_CERTID *id, int *status, int *reason,
|
---|
71 | WOLFSSL_ASN1_TIME **revtime, WOLFSSL_ASN1_TIME **thisupd,
|
---|
72 | WOLFSSL_ASN1_TIME **nextupd);
|
---|
73 | WOLFSSL_API const char *wolfSSL_OCSP_cert_status_str(long s);
|
---|
74 | WOLFSSL_API int wolfSSL_OCSP_check_validity(WOLFSSL_ASN1_TIME* thisupd,
|
---|
75 | WOLFSSL_ASN1_TIME* nextupd, long sec, long maxsec);
|
---|
76 |
|
---|
77 | WOLFSSL_API void wolfSSL_OCSP_CERTID_free(WOLFSSL_OCSP_CERTID* certId);
|
---|
78 | WOLFSSL_API WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_cert_to_id(
|
---|
79 | const WOLFSSL_EVP_MD *dgst, const WOLFSSL_X509 *subject,
|
---|
80 | const WOLFSSL_X509 *issuer);
|
---|
81 |
|
---|
82 | WOLFSSL_API void wolfSSL_OCSP_BASICRESP_free(WOLFSSL_OCSP_BASICRESP* basicResponse);
|
---|
83 | WOLFSSL_API int wolfSSL_OCSP_basic_verify(WOLFSSL_OCSP_BASICRESP *bs,
|
---|
84 | WOLF_STACK_OF(WOLFSSL_X509) *certs, WOLFSSL_X509_STORE *st, unsigned long flags);
|
---|
85 |
|
---|
86 | WOLFSSL_API void wolfSSL_OCSP_RESPONSE_free(OcspResponse* response);
|
---|
87 | #ifndef NO_BIO
|
---|
88 | WOLFSSL_API OcspResponse* wolfSSL_d2i_OCSP_RESPONSE_bio(WOLFSSL_BIO* bio,
|
---|
89 | OcspResponse** response);
|
---|
90 | #endif
|
---|
91 | WOLFSSL_API OcspResponse* wolfSSL_d2i_OCSP_RESPONSE(OcspResponse** response,
|
---|
92 | const unsigned char** data, int len);
|
---|
93 | WOLFSSL_API int wolfSSL_i2d_OCSP_RESPONSE(OcspResponse* response,
|
---|
94 | unsigned char** data);
|
---|
95 | WOLFSSL_API int wolfSSL_OCSP_response_status(OcspResponse *response);
|
---|
96 | WOLFSSL_API const char *wolfSSL_OCSP_response_status_str(long s);
|
---|
97 | WOLFSSL_API WOLFSSL_OCSP_BASICRESP* wolfSSL_OCSP_response_get1_basic(
|
---|
98 | OcspResponse* response);
|
---|
99 |
|
---|
100 | WOLFSSL_API OcspRequest* wolfSSL_OCSP_REQUEST_new(void);
|
---|
101 | WOLFSSL_API void wolfSSL_OCSP_REQUEST_free(OcspRequest* request);
|
---|
102 | WOLFSSL_API int wolfSSL_i2d_OCSP_REQUEST(OcspRequest* request,
|
---|
103 | unsigned char** data);
|
---|
104 | WOLFSSL_API WOLFSSL_OCSP_ONEREQ* wolfSSL_OCSP_request_add0_id(OcspRequest *req,
|
---|
105 | WOLFSSL_OCSP_CERTID *cid);
|
---|
106 | WOLFSSL_API WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_CERTID_dup(WOLFSSL_OCSP_CERTID*);
|
---|
107 | #ifndef NO_BIO
|
---|
108 | WOLFSSL_API int wolfSSL_i2d_OCSP_REQUEST_bio(WOLFSSL_BIO* out,
|
---|
109 | WOLFSSL_OCSP_REQUEST *req);
|
---|
110 | #endif
|
---|
111 |
|
---|
112 | WOLFSSL_API int wolfSSL_i2d_OCSP_CERTID(WOLFSSL_OCSP_CERTID *, unsigned char **);
|
---|
113 | WOLFSSL_API const WOLFSSL_OCSP_CERTID* wolfSSL_OCSP_SINGLERESP_get0_id(const WOLFSSL_OCSP_SINGLERESP *single);
|
---|
114 | WOLFSSL_API int wolfSSL_OCSP_single_get0_status(WOLFSSL_OCSP_SINGLERESP *single,
|
---|
115 | int *reason,
|
---|
116 | WOLFSSL_ASN1_TIME **revtime,
|
---|
117 | WOLFSSL_ASN1_TIME **thisupd,
|
---|
118 | WOLFSSL_ASN1_TIME **nextupd);
|
---|
119 | WOLFSSL_API int wolfSSL_OCSP_resp_count(WOLFSSL_OCSP_BASICRESP *bs);
|
---|
120 | WOLFSSL_API WOLFSSL_OCSP_SINGLERESP* wolfSSL_OCSP_resp_get0(WOLFSSL_OCSP_BASICRESP *bs, int idx);
|
---|
121 |
|
---|
122 | #endif
|
---|
123 | #ifdef OPENSSL_EXTRA
|
---|
124 | WOLFSSL_API int wolfSSL_OCSP_REQUEST_add_ext(OcspRequest* req,
|
---|
125 | WOLFSSL_X509_EXTENSION* ext, int idx);
|
---|
126 | WOLFSSL_API OcspResponse* wolfSSL_OCSP_response_create(int status,
|
---|
127 | WOLFSSL_OCSP_BASICRESP* bs);
|
---|
128 | WOLFSSL_API const char* wolfSSL_OCSP_crl_reason_str(long s);
|
---|
129 |
|
---|
130 | WOLFSSL_API int wolfSSL_OCSP_id_get0_info(WOLFSSL_ASN1_STRING**,
|
---|
131 | WOLFSSL_ASN1_OBJECT**, WOLFSSL_ASN1_STRING**,
|
---|
132 | WOLFSSL_ASN1_INTEGER**, WOLFSSL_OCSP_CERTID*);
|
---|
133 |
|
---|
134 | WOLFSSL_API int wolfSSL_OCSP_request_add1_nonce(OcspRequest* req,
|
---|
135 | unsigned char* val, int sz);
|
---|
136 | WOLFSSL_API int wolfSSL_OCSP_check_nonce(OcspRequest* req,
|
---|
137 | WOLFSSL_OCSP_BASICRESP* bs);
|
---|
138 | #endif
|
---|
139 |
|
---|
140 |
|
---|
141 | #ifdef __cplusplus
|
---|
142 | } /* extern "C" */
|
---|
143 | #endif
|
---|
144 |
|
---|
145 |
|
---|
146 | #endif /* HAVE_OCSP */
|
---|
147 | #endif /* WOLFSSL_OCSP_H */
|
---|
148 |
|
---|
149 |
|
---|