xref: /freebsd/crypto/openssl/doc/man3/OCSP_request_add1_nonce.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimOCSP_request_add1_nonce, OCSP_basic_add1_nonce, OCSP_check_nonce, OCSP_copy_nonce - OCSP nonce functions
6e71b7053SJung-uk Kim
7e71b7053SJung-uk Kim=head1 SYNOPSIS
8e71b7053SJung-uk Kim
9e71b7053SJung-uk Kim #include <openssl/ocsp.h>
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
12e71b7053SJung-uk Kim int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
13e71b7053SJung-uk Kim int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
14e71b7053SJung-uk Kim int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *resp);
15e71b7053SJung-uk Kim
16e71b7053SJung-uk Kim=head1 DESCRIPTION
17e71b7053SJung-uk Kim
18e71b7053SJung-uk KimOCSP_request_add1_nonce() adds a nonce of value B<val> and length B<len> to
19e71b7053SJung-uk KimOCSP request B<req>. If B<val> is B<NULL> a random nonce is used. If B<len>
20e71b7053SJung-uk Kimis zero or negative a default length will be used (currently 16 bytes).
21e71b7053SJung-uk Kim
22e71b7053SJung-uk KimOCSP_basic_add1_nonce() is identical to OCSP_request_add1_nonce() except
23e71b7053SJung-uk Kimit adds a nonce to OCSP basic response B<resp>.
24e71b7053SJung-uk Kim
25e71b7053SJung-uk KimOCSP_check_nonce() compares the nonce value in B<req> and B<resp>.
26e71b7053SJung-uk Kim
2717f01e99SJung-uk KimOCSP_copy_nonce() copies any nonce value present in B<req> to B<resp>.
28e71b7053SJung-uk Kim
29e71b7053SJung-uk Kim=head1 RETURN VALUES
30e71b7053SJung-uk Kim
31e71b7053SJung-uk KimOCSP_request_add1_nonce() and OCSP_basic_add1_nonce() return 1 for success
32e71b7053SJung-uk Kimand 0 for failure.
33e71b7053SJung-uk Kim
34e71b7053SJung-uk KimOCSP_copy_nonce() returns 1 if a nonce was successfully copied, 2 if no nonce
35e71b7053SJung-uk Kimwas present in B<req> and 0 if an error occurred.
36e71b7053SJung-uk Kim
37e71b7053SJung-uk KimOCSP_check_nonce() returns the result of the nonce comparison between B<req>
38e71b7053SJung-uk Kimand B<resp>. The return value indicates the result of the comparison.  If
39e71b7053SJung-uk Kimnonces are present and equal 1 is returned. If the nonces are absent 2 is
40e71b7053SJung-uk Kimreturned. If a nonce is present in the response only 3 is returned. If nonces
41e71b7053SJung-uk Kimare present and unequal 0 is returned. If the nonce is present in the request
42e71b7053SJung-uk Kimonly then -1 is returned.
43e71b7053SJung-uk Kim
44e71b7053SJung-uk Kim=head1 NOTES
45e71b7053SJung-uk Kim
46e71b7053SJung-uk KimFor most purposes the nonce value in a request is set to a random value so
47e71b7053SJung-uk Kimthe B<val> parameter in OCSP_request_add1_nonce() is usually NULL.
48e71b7053SJung-uk Kim
49e71b7053SJung-uk KimAn OCSP nonce is typically added to an OCSP request to thwart replay attacks
50e71b7053SJung-uk Kimby checking the same nonce value appears in the response.
51e71b7053SJung-uk Kim
52e71b7053SJung-uk KimSome responders may include a nonce in all responses even if one is not
53e71b7053SJung-uk Kimsupplied.
54e71b7053SJung-uk Kim
55e71b7053SJung-uk KimSome responders cache OCSP responses and do not sign each response for
56e71b7053SJung-uk Kimperformance reasons. As a result they do not support nonces.
57e71b7053SJung-uk Kim
58e71b7053SJung-uk KimThe return values of OCSP_check_nonce() can be checked to cover each case.  A
59e71b7053SJung-uk Kimpositive return value effectively indicates success: nonces are both present
6058f35182SJung-uk Kimand match, both absent or present in the response only. A nonzero return
61e71b7053SJung-uk Kimadditionally covers the case where the nonce is present in the request only:
62e71b7053SJung-uk Kimthis will happen if the responder doesn't support nonces. A zero return value
63e71b7053SJung-uk Kimindicates present and mismatched nonces: this should be treated as an error
64e71b7053SJung-uk Kimcondition.
65e71b7053SJung-uk Kim
66e71b7053SJung-uk Kim=head1 SEE ALSO
67e71b7053SJung-uk Kim
68e71b7053SJung-uk KimL<crypto(7)>,
69e71b7053SJung-uk KimL<OCSP_cert_to_id(3)>,
70e71b7053SJung-uk KimL<OCSP_REQUEST_new(3)>,
71e71b7053SJung-uk KimL<OCSP_resp_find_status(3)>,
72e71b7053SJung-uk KimL<OCSP_response_status(3)>,
73e71b7053SJung-uk KimL<OCSP_sendreq_new(3)>
74e71b7053SJung-uk Kim
75e71b7053SJung-uk Kim=head1 COPYRIGHT
76e71b7053SJung-uk Kim
7717f01e99SJung-uk KimCopyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
78e71b7053SJung-uk Kim
79*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
80e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
81e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
82e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
83e71b7053SJung-uk Kim
84e71b7053SJung-uk Kim=cut
85