1.\" $OpenBSD: OCSP_request_add1_nonce.3,v 1.4 2018/03/22 21:08:22 schwarze Exp $ 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 3.\" 4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 5.\" Copyright (c) 2014, 2016 The OpenSSL Project. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in 16.\" the documentation and/or other materials provided with the 17.\" distribution. 18.\" 19.\" 3. All advertising materials mentioning features or use of this 20.\" software must display the following acknowledgment: 21.\" "This product includes software developed by the OpenSSL Project 22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 23.\" 24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 25.\" endorse or promote products derived from this software without 26.\" prior written permission. For written permission, please contact 27.\" openssl-core@openssl.org. 28.\" 29.\" 5. Products derived from this software may not be called "OpenSSL" 30.\" nor may "OpenSSL" appear in their names without prior written 31.\" permission of the OpenSSL Project. 32.\" 33.\" 6. Redistributions of any form whatsoever must retain the following 34.\" acknowledgment: 35.\" "This product includes software developed by the OpenSSL Project 36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 37.\" 38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" 51.Dd $Mdocdate: March 22 2018 $ 52.Dt OCSP_REQUEST_ADD1_NONCE 3 53.Os 54.Sh NAME 55.Nm OCSP_request_add1_nonce , 56.Nm OCSP_basic_add1_nonce , 57.Nm OCSP_check_nonce , 58.Nm OCSP_copy_nonce 59.Nd OCSP nonce functions 60.Sh SYNOPSIS 61.In openssl/ocsp.h 62.Ft int 63.Fo OCSP_request_add1_nonce 64.Fa "OCSP_REQUEST *req" 65.Fa "unsigned char *val" 66.Fa "int len" 67.Fc 68.Ft int 69.Fo OCSP_basic_add1_nonce 70.Fa "OCSP_BASICRESP *resp" 71.Fa "unsigned char *val" 72.Fa "int len" 73.Fc 74.Ft int 75.Fo OCSP_check_nonce 76.Fa "OCSP_REQUEST *req" 77.Fa "OCSP_BASICRESP *resp" 78.Fc 79.Ft int 80.Fo OCSP_copy_nonce 81.Fa "OCSP_BASICRESP *resp" 82.Fa "OCSP_REQUEST *req" 83.Fc 84.Sh DESCRIPTION 85An OCSP nonce is typically added to an OCSP request to thwart replay 86attacks by checking the same nonce value appears in the response. 87.Pp 88.Fn OCSP_request_add1_nonce 89adds a nonce of value 90.Fa val 91and length 92.Fa len 93to OCSP request 94.Fa req . 95If 96.Fa val 97is 98.Dv NULL , 99a random nonce is used. 100If 101.Fa len 102is zero or negative, a default length will be used (currently 16 bytes). 103For most purposes the nonce value in a request is set to a random value 104so the 105.Fa val 106parameter in 107.Fn OCSP_request_add1_nonce 108is usually NULL. 109.Pp 110.Fn OCSP_basic_add1_nonce 111is identical to 112.Fn OCSP_request_add1_nonce 113except it adds a nonce to OCSP basic response 114.Fa resp . 115.Pp 116.Fn OCSP_check_nonce 117compares the nonce value in 118.Fa req 119and 120.Fa resp . 121.Pp 122.Fn OCSP_copy_nonce 123copies any nonce value present in 124.Fa req 125to 126.Fa resp . 127.Pp 128Some responders may include a nonce in all responses even if one is not 129supplied. 130.Pp 131Some responders cache OCSP responses and do not sign each response for 132performance reasons. 133As a result they do not support nonces. 134.Sh RETURN VALUES 135.Fn OCSP_request_add1_nonce 136and 137.Fn OCSP_basic_add1_nonce 138return 1 for success or 0 for failure. 139.Pp 140.Fn OCSP_copy_nonce 141returns 1 if a nonce was successfully copied, 2 if no nonce was 142present in 143.Fa req , 144or 0 if an error occurred. 145.Pp 146.Fn OCSP_check_nonce 147returns positive values for success: 1 if nonces are present and 148equal, 2 if both nonces are absent, or 3 if a nonce is present in 149the response only. 150A zero return value indicates that both nonces are present but 151mismatch: this should be treated as an error condition. 152A return value of -1 indicates that a nonce is present in the request 153only: this will happen if the responder doesn't support nonces. 154.Sh SEE ALSO 155.Xr OCSP_cert_to_id 3 , 156.Xr OCSP_REQUEST_new 3 , 157.Xr OCSP_resp_find_status 3 , 158.Xr OCSP_response_status 3 , 159.Xr OCSP_sendreq_new 3 160.Sh HISTORY 161These functions first appeared in OpenSSL 0.9.7 162and have been available since 163.Ox 3.2 . 164