Blame doc/man3/OCSP_request_add1_nonce.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
OCSP_request_add1_nonce, OCSP_basic_add1_nonce, OCSP_check_nonce, OCSP_copy_nonce - OCSP nonce functions
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/ocsp.h>
Packit c4476c
Packit c4476c
 int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len);
Packit c4476c
 int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len);
Packit c4476c
 int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
Packit c4476c
 int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *resp);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
OCSP_request_add1_nonce() adds a nonce of value B<val> and length B<len> to
Packit c4476c
OCSP request B<req>. If B<val> is B<NULL> a random nonce is used. If B<len>
Packit c4476c
is zero or negative a default length will be used (currently 16 bytes).
Packit c4476c
Packit c4476c
OCSP_basic_add1_nonce() is identical to OCSP_request_add1_nonce() except
Packit c4476c
it adds a nonce to OCSP basic response B<resp>.
Packit c4476c
Packit c4476c
OCSP_check_nonce() compares the nonce value in B<req> and B<resp>.
Packit c4476c
Packit c4476c
OCSP_copy_nonce() copies any nonce value present in B<req> to B<resp>.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
OCSP_request_add1_nonce() and OCSP_basic_add1_nonce() return 1 for success
Packit c4476c
and 0 for failure.
Packit c4476c
Packit c4476c
OCSP_copy_nonce() returns 1 if a nonce was successfully copied, 2 if no nonce
Packit c4476c
was present in B<req> and 0 if an error occurred.
Packit c4476c
Packit c4476c
OCSP_check_nonce() returns the result of the nonce comparison between B<req>
Packit c4476c
and B<resp>. The return value indicates the result of the comparison.  If
Packit c4476c
nonces are present and equal 1 is returned. If the nonces are absent 2 is
Packit c4476c
returned. If a nonce is present in the response only 3 is returned. If nonces
Packit c4476c
are present and unequal 0 is returned. If the nonce is present in the request
Packit c4476c
only then -1 is returned.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
For most purposes the nonce value in a request is set to a random value so
Packit c4476c
the B<val> parameter in OCSP_request_add1_nonce() is usually NULL.
Packit c4476c
Packit c4476c
An OCSP nonce is typically added to an OCSP request to thwart replay attacks
Packit c4476c
by checking the same nonce value appears in the response.
Packit c4476c
Packit c4476c
Some responders may include a nonce in all responses even if one is not
Packit c4476c
supplied.
Packit c4476c
Packit c4476c
Some responders cache OCSP responses and do not sign each response for
Packit c4476c
performance reasons. As a result they do not support nonces.
Packit c4476c
Packit c4476c
The return values of OCSP_check_nonce() can be checked to cover each case.  A
Packit c4476c
positive return value effectively indicates success: nonces are both present
Packit c4476c
and match, both absent or present in the response only. A non-zero return
Packit c4476c
additionally covers the case where the nonce is present in the request only:
Packit c4476c
this will happen if the responder doesn't support nonces. A zero return value
Packit c4476c
indicates present and mismatched nonces: this should be treated as an error
Packit c4476c
condition.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<crypto(7)>,
Packit c4476c
L<OCSP_cert_to_id(3)>,
Packit c4476c
L<OCSP_REQUEST_new(3)>,
Packit c4476c
L<OCSP_resp_find_status(3)>,
Packit c4476c
L<OCSP_response_status(3)>,
Packit c4476c
L<OCSP_sendreq_new(3)>
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut