OCSP_REQUEST_ADD1_NONCE(3ossl)
π OCSP_REQUEST_ADD1_NONCE
okay so bestie, this is a page from the 3ossl manual β that's the OpenSSL corner of manpage-land, and today we're learning about nonces for OCSP. Yes, nonces. No, not that kind. Sit down, I got you. π
β¨ NAME β¨
OCSP_request_add1_nonce, OCSP_basic_add1_nonce, OCSP_check_nonce, OCSP_copy_nonce β the OCSP nonce functions, aka the four little besties that add, copy, and vibe-check nonces on OCSP requests and responses. π¦
πΈ SYNOPSIS πΈ
#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_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req);
int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *resp);
π DESCRIPTION π
π«Ά OCSP_request_add1_nonce()
Slaps a nonce onto the OCSP request req β the nonce has value val and length len. If val is NULL, it just rolls a random one for you (iconic behaviour, honestly). And if len is zero or negative, a default length kicks in β currently 16 bytes. π₯
π«Ά OCSP_basic_add1_nonce()
Literally identical to OCSP_request_add1_nonce() in every way, except the nonce lands on the OCSP basic response resp instead. Same energy, different target. π
π«Ά OCSP_check_nonce()
Compares the nonce value sitting in req against the one in resp. Like a vibe check, but for cryptographic nonces. β
π«Ά OCSP_copy_nonce()
Takes whatever nonce value is present in req and copies it over to resp. Copy-paste but make it protocol. π§
π RETURN VALUES π
OCSP_request_add1_nonce()andOCSP_basic_add1_nonce()β return1for success,0for failure. Simple. Clean. No notes. β¨OCSP_copy_nonce()β returns1if a nonce was successfully copied,2if there was no nonce present inreqat all, and0if an error occurred. Three moods, one function. πOCSP_check_nonce()β returns the result of the nonce comparison betweenreqandresp, and the return value is the answer. Let's break it down because this is the part everyone asks about in the group chat:- nonces present and equal β
1π - nonces absent β
2πΈ - nonce present in the response only β
3π¦ - nonces present and unequal β
0π - nonce present in the request only β
-1π
- nonces present and equal β
π NOTES π
For most purposes, the nonce value in a request is set to a random value β which is exactly why the val parameter in OCSP_request_add1_nonce() is usually NULL. Let the function cook. π₯
An OCSP nonce is typically added to an OCSP request to thwart replay attacks, by checking that the same nonce value shows up in the response. Matchy-matchy = safe. π«Ά
Some responders may include a nonce in all responses, even if one was never supplied. Rude? Generous? Unclear. π€·
Some responders cache OCSP responses and don't sign each response, purely for performance reasons. As a result, they do not support nonces. So if that's your responder, don't come for the nonces. π
The return values of OCSP_check_nonce() can be checked to cover each case:
- A positive return value effectively indicates success: nonces are both present and match, both absent, or present in the response only. β
- A nonzero return additionally covers the case where the nonce is present in the request only β which will happen if the responder doesn't support nonces. π€
- A zero return value indicates present and mismatched nonces, and this should be treated as an error condition. Not a vibe. Treat it as an error. Periodt. π¨
π SEE ALSO π
crypto(7), OCSP_cert_to_id(3), OCSP_REQUEST_new(3), OCSP_resp_find_status(3), OCSP_response_status(3), OCSP_sendreq_new(3)
π COPYRIGHT π
Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
bestie, real talk: that license line means you actually have to follow the license. don't just skim it. π
and that's the whole page, bestie π β brought to you by OpenSSL 3.5.6, dated 2026-04-07, filed under OCSP_REQUEST_ADD1_NONCE(3ossl). go forth and nonce responsibly π
β¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms