dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / lib / libcrypto / man / OCSP_resp_find_status.3
blobd06540d7167aa559edd6838268fb83988fd5f86d
1 .\"     $OpenBSD: OCSP_resp_find_status.3,v 1.5 2016/12/25 22:15:10 schwarze Exp $
2 .\"     OpenSSL c952780c Jun 21 07:03:34 2016 -0400
3 .\"
4 .\" This file is a derived work.
5 .\" The changes are covered by the following Copyright and license:
6 .\"
7 .\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
8 .\"
9 .\" Permission to use, copy, modify, and distribute this software for any
10 .\" purpose with or without fee is hereby granted, provided that the above
11 .\" copyright notice and this permission notice appear in all copies.
12 .\"
13 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 .\"
21 .\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22 .\" Copyright (c) 2014 The OpenSSL Project.  All rights reserved.
23 .\"
24 .\" Redistribution and use in source and binary forms, with or without
25 .\" modification, are permitted provided that the following conditions
26 .\" are met:
27 .\"
28 .\" 1. Redistributions of source code must retain the above copyright
29 .\"    notice, this list of conditions and the following disclaimer.
30 .\"
31 .\" 2. Redistributions in binary form must reproduce the above copyright
32 .\"    notice, this list of conditions and the following disclaimer in
33 .\"    the documentation and/or other materials provided with the
34 .\"    distribution.
35 .\"
36 .\" 3. All advertising materials mentioning features or use of this
37 .\"    software must display the following acknowledgment:
38 .\"    "This product includes software developed by the OpenSSL Project
39 .\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40 .\"
41 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42 .\"    endorse or promote products derived from this software without
43 .\"    prior written permission. For written permission, please contact
44 .\"    openssl-core@openssl.org.
45 .\"
46 .\" 5. Products derived from this software may not be called "OpenSSL"
47 .\"    nor may "OpenSSL" appear in their names without prior written
48 .\"    permission of the OpenSSL Project.
49 .\"
50 .\" 6. Redistributions of any form whatsoever must retain the following
51 .\"    acknowledgment:
52 .\"    "This product includes software developed by the OpenSSL Project
53 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54 .\"
55 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
59 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
67 .\"
68 .Dd $Mdocdate: December 25 2016 $
69 .Dt OCSP_RESP_FIND_STATUS 3
70 .Os
71 .Sh NAME
72 .Nm OCSP_SINGLERESP_new ,
73 .Nm OCSP_SINGLERESP_free ,
74 .Nm OCSP_CERTSTATUS_new ,
75 .Nm OCSP_CERTSTATUS_free ,
76 .Nm OCSP_REVOKEDINFO_new ,
77 .Nm OCSP_REVOKEDINFO_free ,
78 .Nm OCSP_resp_find_status ,
79 .Nm OCSP_resp_count ,
80 .Nm OCSP_resp_get0 ,
81 .Nm OCSP_resp_find ,
82 .Nm OCSP_single_get0_status ,
83 .Nm OCSP_check_validity
84 .Nd OCSP response utility functions
85 .Sh SYNOPSIS
86 .In openssl/ocsp.h
87 .Ft OCSP_SINGLERESP *
88 .Fn OCSP_SINGLERESP_new void
89 .Ft void
90 .Fn OCSP_SINGLERESP_free "OCSP_SINGLERESP *single"
91 .Ft OCSP_CERTSTATUS *
92 .Fn OCSP_CERTSTATUS_new void
93 .Ft void
94 .Fn OCSP_CERTSTATUS_free "OCSP_CERTSTATUS *certstatus"
95 .Ft OCSP_REVOKEDINFO *
96 .Fn OCSP_REVOKEDINFO_new void
97 .Ft void
98 .Fn OCSP_REVOKEDINFO_free "OCSP_REVOKEDINFO *revokedinfo"
99 .Ft int
100 .Fo OCSP_resp_find_status
101 .Fa "OCSP_BASICRESP *bs"
102 .Fa "OCSP_CERTID *id"
103 .Fa "int *status"
104 .Fa "int *reason"
105 .Fa "ASN1_GENERALIZEDTIME **revtime"
106 .Fa "ASN1_GENERALIZEDTIME **thisupd"
107 .Fa "ASN1_GENERALIZEDTIME **nextupd"
109 .Ft int
110 .Fo OCSP_resp_count
111 .Fa "OCSP_BASICRESP *bs"
113 .Ft OCSP_SINGLERESP *
114 .Fo OCSP_resp_get0
115 .Fa "OCSP_BASICRESP *bs"
116 .Fa "int idx"
118 .Ft int
119 .Fo OCSP_resp_find
120 .Fa "OCSP_BASICRESP *bs"
121 .Fa "OCSP_CERTID *id"
122 .Fa "int last"
124 .Ft int
125 .Fo OCSP_single_get0_status
126 .Fa "OCSP_SINGLERESP *single"
127 .Fa "int *reason"
128 .Fa "ASN1_GENERALIZEDTIME **revtime"
129 .Fa "ASN1_GENERALIZEDTIME **thisupd"
130 .Fa "ASN1_GENERALIZEDTIME **nextupd"
132 .Ft int
133 .Fo OCSP_check_validity
134 .Fa "ASN1_GENERALIZEDTIME *thisupd"
135 .Fa "ASN1_GENERALIZEDTIME *nextupd"
136 .Fa "long sec"
137 .Fa "long maxsec"
139 .Sh DESCRIPTION
140 .Fn OCSP_SINGLERESP_new
141 allocates and initializes an empty
142 .Vt OCSP_SINGLERESP
143 object, representing an ASN.1
144 .Vt SingleResponse
145 structure defined in RFC 6960.
146 Each such object can store the server's answer regarding the validity
147 of one individual certificate.
148 Such objects are used inside the
149 .Vt OCSP_RESPDATA
151 .Vt OCSP_BASICRESP
152 objects, which are described in
153 .Xr OCSP_BASICRESP_new 3 .
154 .Fn OCSP_SINGLERESP_free
155 frees
156 .Fa single .
158 .Fn OCSP_CERTSTATUS_new
159 allocates and initializes an empty
160 .Vt OCSP_CERTSTATUS
161 object, representing an ASN.1
162 .Vt CertStatus
163 structure defined in RFC 6960.
164 Such an object is used inside
165 .Vt OCSP_SINGLERESP .
166 .Fn OCSP_CERTSTATUS_free
167 frees
168 .Fa certstatus .
170 .Fn OCSP_REVOKEDINFO_new
171 allocates and initializes an empty
172 .Vt OCSP_REVOKEDINFO
173 object, representing an ASN.1
174 .Vt RevokedInfo
175 structure defined in RFC 6960.
176 Such an object is used inside
177 .Vt OCSP_CERTSTATUS .
178 .Fn OCSP_REVOKEDINFO_free
179 frees
180 .Fa revokedinfo .
182 .Fn OCSP_resp_find_status
183 searches
184 .Fa bs
185 for an OCSP response for
186 .Fa id .
187 If it is successful, the fields of the response are returned in
188 .Pf * Fa status ,
189 .Pf * Fa reason ,
190 .Pf * Fa revtime ,
191 .Pf * Fa thisupd
193 .Pf * Fa nextupd .
195 .Pf * Fa status
196 value will be one of
197 .Dv V_OCSP_CERTSTATUS_GOOD ,
198 .Dv V_OCSP_CERTSTATUS_REVOKED ,
200 .Dv V_OCSP_CERTSTATUS_UNKNOWN .
202 .Pf * Fa reason
204 .Pf * Fa revtime
205 fields are only set if the status is
206 .Dv V_OCSP_CERTSTATUS_REVOKED .
207 If set, the
208 .Pf * Fa reason
209 field will be set to the revocation reason which will be one of
210 .Dv OCSP_REVOKED_STATUS_NOSTATUS ,
211 .Dv OCSP_REVOKED_STATUS_UNSPECIFIED ,
212 .Dv OCSP_REVOKED_STATUS_KEYCOMPROMISE ,
213 .Dv OCSP_REVOKED_STATUS_CACOMPROMISE ,
214 .Dv OCSP_REVOKED_STATUS_AFFILIATIONCHANGED ,
215 .Dv OCSP_REVOKED_STATUS_SUPERSEDED ,
216 .Dv OCSP_REVOKED_STATUS_CESSATIONOFOPERATION ,
217 .Dv OCSP_REVOKED_STATUS_CERTIFICATEHOLD
219 .Dv OCSP_REVOKED_STATUS_REMOVEFROMCRL .
221 .Fn OCSP_resp_count
222 returns the number of
223 .Vt OCSP_SINGLERESP
224 structures in
225 .Fa bs .
227 .Fn OCSP_resp_get0
228 returns the
229 .Vt OCSP_SINGLERESP
230 structure in
231 .Fa bs
232 corresponding to index
233 .Fa idx ,
234 where
235 .Fa idx
236 runs from 0 to
237 .Fn OCSP_resp_count bs No - 1 .
239 .Fn OCSP_resp_find
240 searches
241 .Fa bs
243 .Fa id
244 and returns the index of the first matching entry after
245 .Fa last
246 or starting from the beginning if
247 .Fa last
248 is -1.
250 .Fn OCSP_single_get0_status
251 extracts the fields of
252 .Fa single
254 .Pf * Fa reason ,
255 .Pf * Fa revtime ,
256 .Pf * Fa thisupd ,
258 .Pf * Fa nextupd .
260 .Fn OCSP_check_validity
261 checks the validity of
262 .Fa thisupd
264 .Fa nextupd
265 values which will be typically obtained from
266 .Fn OCSP_resp_find_status
268 .Fn OCSP_single_get0_status .
270 .Fa sec
271 is non-zero it indicates how many seconds leeway should be allowed in
272 the check.
274 .Fa maxsec
275 is positive it indicates the maximum age of
276 .Fa thisupd
277 in seconds.
279 Applications will typically call
280 .Fn OCSP_resp_find_status
281 using the certificate ID of interest and then check its validity using
282 .Fn OCSP_check_validity .
283 They can then take appropriate action based on the status of the
284 certificate.
286 An OCSP response for a certificate contains
287 .Sy thisUpdate
289 .Sy nextUpdate
290 fields.
291 Normally the current time should be between these two values.
292 To account for clock skew, the
293 .Fa maxsec
294 field can be set to non-zero in
295 .Fn OCSP_check_validity .
296 Some responders do not set the
297 .Sy nextUpdate
298 field.
299 This would otherwise mean an ancient response would be considered
300 valid: the
301 .Fa maxsec
302 parameter to
303 .Fn OCSP_check_validity
304 can be used to limit the permitted age of responses.
306 The values written to
307 .Pf * Fa revtime ,
308 .Pf * Fa thisupd ,
310 .Pf * Fa nextupd
312 .Fn OCSP_resp_find_status
314 .Fn OCSP_single_get0_status
315 are internal pointers which must not be freed up by the calling
316 application.
317 Any or all of these parameters can be set to
318 .Dv NULL
319 if their value is not required.
320 .Sh RETURN VALUES
321 .Fn OCSP_SINGLERESP_new ,
322 .Fn OCSP_CERTSTATUS_new ,
324 .Fn OCSP_REVOKEDINFO_new
325 return a pointer to an empty
326 .Vt OCSP_SINGLERESP ,
327 .Vt OCSP_CERTSTATUS ,
329 .Vt OCSP_REVOKEDINFO
330 object, respectively, or
331 .Dv NULL
332 if an error occurred.
334 .Fn OCSP_resp_find_status
335 returns 1 if
336 .Fa id
337 is found in
338 .Fa bs
339 or 0 otherwise.
341 .Fn OCSP_resp_count
342 returns the total number of
343 .Vt OCSP_SINGLERESP
344 fields in
345 .Fa bs .
347 .Fn OCSP_resp_get0
348 returns a pointer to an
349 .Vt OCSP_SINGLERESP
350 structure or
351 .Dv NULL
353 .Fa idx
354 is out of range.
356 .Fn OCSP_resp_find
357 returns the index of
358 .Fa id
360 .Fa bs
361 (which may be 0) or -1 if
362 .Fa id
363 was not found.
365 .Fn OCSP_single_get0_status
366 returns the status of
367 .Fa single
368 or -1 if an error occurred.
369 .Sh SEE ALSO
370 .Xr OCSP_cert_to_id 3 ,
371 .Xr OCSP_CRLID_new 3 ,
372 .Xr OCSP_request_add1_nonce 3 ,
373 .Xr OCSP_REQUEST_new 3 ,
374 .Xr OCSP_response_status 3 ,
375 .Xr OCSP_sendreq_new 3
376 .Sh STANDARDS
377 RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate
378 Status Protocol, section 4.2: Response Syntax