summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2021-10-24 13:50:14 +0000
committertb <>2021-10-24 13:50:14 +0000
commit9d8621b7e81419d953ce51428f69003f546bec2a (patch)
treeeed60dd7494a63e3394016ae80a2600ee0f7bcac /src/lib
parent48c471e6a98e03acff50a033e9a20091e4842f90 (diff)
downloadopenbsd-9d8621b7e81419d953ce51428f69003f546bec2a.tar.gz
openbsd-9d8621b7e81419d953ce51428f69003f546bec2a.tar.bz2
openbsd-9d8621b7e81419d953ce51428f69003f546bec2a.zip
Prepare to provide a bunch of OCSP_resp_* getters.
ok beck jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/ocsp/ocsp.h17
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_cl.c51
-rw-r--r--src/lib/libcrypto/ocsp/ocsp_vfy.c9
3 files changed, 74 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ocsp/ocsp.h b/src/lib/libcrypto/ocsp/ocsp.h
index 316fb8ed93..554d164601 100644
--- a/src/lib/libcrypto/ocsp/ocsp.h
+++ b/src/lib/libcrypto/ocsp/ocsp.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp.h,v 1.16 2018/08/24 20:03:21 tb Exp $ */ 1/* $OpenBSD: ocsp.h,v 1.17 2021/10/24 13:50:14 tb Exp $ */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL 2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */ 3 * project. */
4 4
@@ -414,8 +414,23 @@ int OCSP_request_sign(OCSP_REQUEST *req, X509 *signer, EVP_PKEY *key,
414int OCSP_response_status(OCSP_RESPONSE *resp); 414int OCSP_response_status(OCSP_RESPONSE *resp);
415OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); 415OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
416 416
417#if defined(LIBRESSL_NEW_API)
418const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs);
419const X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs);
420const OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs);
421int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer,
422 STACK_OF(X509) *extra_certs);
423#endif
424
417int OCSP_resp_count(OCSP_BASICRESP *bs); 425int OCSP_resp_count(OCSP_BASICRESP *bs);
418OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); 426OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
427#if defined(LIBRESSL_NEW_API)
428const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(const OCSP_BASICRESP *bs);
429const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs);
430int OCSP_resp_get0_id(const OCSP_BASICRESP *bs,
431 const ASN1_OCTET_STRING **pid, const X509_NAME **pname);
432#endif
433
419int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); 434int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
420int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, 435int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
421 ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd, 436 ASN1_GENERALIZEDTIME **revtime, ASN1_GENERALIZEDTIME **thisupd,
diff --git a/src/lib/libcrypto/ocsp/ocsp_cl.c b/src/lib/libcrypto/ocsp/ocsp_cl.c
index cb5a2f3d18..677a1b35dd 100644
--- a/src/lib/libcrypto/ocsp/ocsp_cl.c
+++ b/src/lib/libcrypto/ocsp/ocsp_cl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_cl.c,v 1.17 2020/10/09 17:19:35 tb Exp $ */ 1/* $OpenBSD: ocsp_cl.c,v 1.18 2021/10/24 13:50:14 tb Exp $ */
2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL 2/* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
3 * project. */ 3 * project. */
4 4
@@ -233,6 +233,55 @@ OCSP_resp_get0(OCSP_BASICRESP *bs, int idx)
233 return sk_OCSP_SINGLERESP_value(bs->tbsResponseData->responses, idx); 233 return sk_OCSP_SINGLERESP_value(bs->tbsResponseData->responses, idx);
234} 234}
235 235
236const ASN1_GENERALIZEDTIME *
237OCSP_resp_get0_produced_at(const OCSP_BASICRESP *bs)
238{
239 return bs->tbsResponseData->producedAt;
240}
241
242const STACK_OF(X509) *
243OCSP_resp_get0_certs(const OCSP_BASICRESP *bs)
244{
245 return bs->certs;
246}
247
248int
249OCSP_resp_get0_id(const OCSP_BASICRESP *bs, const ASN1_OCTET_STRING **pid,
250 const X509_NAME **pname)
251{
252 const OCSP_RESPID *rid = bs->tbsResponseData->responderId;
253
254 if (rid->type == V_OCSP_RESPID_NAME) {
255 *pname = rid->value.byName;
256 *pid = NULL;
257 } else if (rid->type == V_OCSP_RESPID_KEY) {
258 *pid = rid->value.byKey;
259 *pname = NULL;
260 } else {
261 return 0;
262 }
263
264 return 1;
265}
266
267const ASN1_OCTET_STRING *
268OCSP_resp_get0_signature(const OCSP_BASICRESP *bs)
269{
270 return bs->signature;
271}
272
273const X509_ALGOR *
274OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs)
275{
276 return bs->signatureAlgorithm;
277}
278
279const OCSP_RESPDATA *
280OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs)
281{
282 return bs->tbsResponseData;
283}
284
236/* Look single response matching a given certificate ID */ 285/* Look single response matching a given certificate ID */
237int 286int
238OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last) 287OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last)
diff --git a/src/lib/libcrypto/ocsp/ocsp_vfy.c b/src/lib/libcrypto/ocsp/ocsp_vfy.c
index ebdd826878..e92b5d7326 100644
--- a/src/lib/libcrypto/ocsp/ocsp_vfy.c
+++ b/src/lib/libcrypto/ocsp/ocsp_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ocsp_vfy.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */ 1/* $OpenBSD: ocsp_vfy.c,v 1.16 2021/10/24 13:50:14 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -179,6 +179,13 @@ end:
179 return ret; 179 return ret;
180} 180}
181 181
182int
183OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer,
184 STACK_OF(X509) *extra_certs)
185{
186 return ocsp_find_signer(signer, bs, extra_certs, NULL, 0) > 0;
187}
188
182static int 189static int
183ocsp_find_signer(X509 **psigner, OCSP_BASICRESP *bs, STACK_OF(X509) *certs, 190ocsp_find_signer(X509 **psigner, OCSP_BASICRESP *bs, STACK_OF(X509) *certs,
184 X509_STORE *st, unsigned long flags) 191 X509_STORE *st, unsigned long flags)