---
name: "libressl-OCSP_request_add1_nonce"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-OCSP_request_add1_nonce"
---

# libressl-OCSP\_request\_add1\_nonce(3)

OCSP nonce functions

## NAME

**OCSP\_request\_add1\_nonce**, **OCSP\_basic\_add1\_nonce**, **OCSP\_check\_nonce**, **OCSP\_copy\_nonce** – OCSP nonce functions

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/ocsp.h\>**

*int*\

**OCSP\_request\_add1\_nonce**(*OCSP\_REQUEST \*req*, *unsigned char \*val*, *int len*);

*int*\

**OCSP\_basic\_add1\_nonce**(*OCSP\_BASICRESP \*resp*, *unsigned char \*val*, *int len*);

*int*\

**OCSP\_check\_nonce**(*OCSP\_REQUEST \*req*, *OCSP\_BASICRESP \*resp*);

*int*\

**OCSP\_copy\_nonce**(*OCSP\_BASICRESP \*resp*, *OCSP\_REQUEST \*req*);

## DESCRIPTION

An OCSP nonce is typically added to an OCSP request to thwart replay attacks by checking the same nonce value appears in the response.

**OCSP\_request\_add1\_nonce**() adds a nonce of value *val* and length *len* to OCSP request *req*. If *val* is NULL, a random nonce is used. If *len* is zero or negative, a default length will be used (currently 16 bytes). For most purposes the nonce value in a request is set to a random value so the *val* parameter in **OCSP\_request\_add1\_nonce**() is usually NULL.

**OCSP\_basic\_add1\_nonce**() is identical to **OCSP\_request\_add1\_nonce**() except it adds a nonce to OCSP basic response *resp*.

**OCSP\_check\_nonce**() compares the nonce value in *req* and *resp*.

**OCSP\_copy\_nonce**() copies any nonce value present in *req* to *resp*.

Some responders may include a nonce in all responses even if one is not supplied.

Some responders cache OCSP responses and do not sign each response for performance reasons. As a result they do not support nonces.

## RETURN VALUES

**OCSP\_request\_add1\_nonce**() and **OCSP\_basic\_add1\_nonce**() return 1 for success or 0 for failure.

**OCSP\_copy\_nonce**() returns 1 if a nonce was successfully copied, 2 if no nonce was present in *req*, or 0 if an error occurred.

**OCSP\_check\_nonce**() returns positive values for success: 1 if nonces are present and equal, 2 if both nonces are absent, or 3 if a nonce is present in the response only. A zero return value indicates that both nonces are present but mismatch: this should be treated as an error condition. A return value of -1 indicates that a nonce is present in the request only: this will happen if the responder doesn't support nonces.

## SEE ALSO

OCSP\_cert\_to\_id(3), OCSP\_REQUEST\_new(3), OCSP\_resp\_find\_status(3), OCSP\_response\_status(3), OCSP\_sendreq\_new(3)

## HISTORY

These functions first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.
