Skip to content

Commit

Permalink
Add some accessors.
Browse files Browse the repository at this point in the history
Author: Remi Gacogne <rgacogne-github@coredump.fr>
GH334: Add an OCSP_SINGLERESP_get0_id() accessor to the OCSP_CERTID of
a OCSP_SINGLERESP. It is possible to do it the other way around using
OCSP_resp_find(), but this is more efficient when you have a tree indexed
by OCSP_CERTID, like haproxy does. (This is also RT4251)

Author: Marek Klein <kleinmrk@gmail.com>
GH556: OCSP_resp_get_produced_at() accessor to the producedAt of a
OCSP_BASICRESP
GH555: TS_STATUS_INFO_get_status(), TS_STATUS_INFO_get_text() and
TS_STATUS_INFO_get_failure_info() accessors for a TS_STATUS_INFO

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
  • Loading branch information
richsalz authored and Rich Salz committed Jan 17, 2016
1 parent 0b3a231 commit 9e5cd4b
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crypto/ocsp/ocsp_cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx)
return sk_OCSP_SINGLERESP_value(bs->tbsResponseData.responses, idx);
}

ASN1_GENERALIZEDTIME *OCSP_resp_get_produced_at(OCSP_BASICRESP* bs)
{
if (!bs)
return NULL;
return bs->tbsResponseData.producedAt;
}

/* Look single response matching a given certificate ID */

int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last)
Expand Down Expand Up @@ -386,3 +393,8 @@ int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd,

return ret;
}

OCSP_CERTID *OCSP_SINGLERESP_get0_id(OCSP_SINGLERESP *single)
{
return single->certId;
}
15 changes: 15 additions & 0 deletions crypto/ts/ts_rsp_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,3 +397,18 @@ int TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i)
{
return ASN1_INTEGER_set(a->status, i);
}

ASN1_INTEGER *TS_STATUS_INFO_get_status(TS_STATUS_INFO *a)
{
return a->status;
}

STACK_OF(ASN1_UTF8STRING) *TS_STATUS_INFO_get_text(TS_STATUS_INFO *a)
{
return a->text;
}

ASN1_BIT_STRING *TS_STATUS_INFO_get_failure_info(TS_STATUS_INFO *a)
{
return a->failure_info;
}
2 changes: 2 additions & 0 deletions include/openssl/ocsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ ASN1_OCTET_STRING *OCSP_resp_get0_signature(OCSP_BASICRESP *bs);

int OCSP_resp_count(OCSP_BASICRESP *bs);
OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx);
ASN1_GENERALIZEDTIME *OCSP_resp_get_produced_at(OCSP_BASICRESP* bs);
int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last);
int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason,
ASN1_GENERALIZEDTIME **revtime,
Expand Down Expand Up @@ -359,6 +360,7 @@ void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit,
int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value,
int crit, unsigned long flags);
int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc);
OCSP_CERTID *OCSP_SINGLERESP_get0_id(OCSP_SINGLERESP *x);

DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP)
DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS)
Expand Down
5 changes: 5 additions & 0 deletions include/openssl/ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ int TS_REQ_set_version(TS_REQ *a, long version);
long TS_REQ_get_version(const TS_REQ *a);

int TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i);
ASN1_INTEGER *TS_STATUS_INFO_get_status(TS_STATUS_INFO *a);

STACK_OF(ASN1_UTF8STRING) *TS_STATUS_INFO_get_text(TS_STATUS_INFO *a);

ASN1_BIT_STRING *TS_STATUS_INFO_get_failure_info(TS_STATUS_INFO *a);

int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint);
TS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a);
Expand Down
5 changes: 5 additions & 0 deletions util/libeay.num
Original file line number Diff line number Diff line change
Expand Up @@ -4759,3 +4759,8 @@ EC_KEY_set_ex_data 5153 1_1_0 EXIST::FUNCTION:EC
EC_KEY_get_ex_data 5154 1_1_0 EXIST::FUNCTION:EC
EC_KEY_set_method 5155 1_1_0 EXIST::FUNCTION:EC
EC_KEY_get_method 5156 1_1_0 EXIST::FUNCTION:EC
OCSP_SINGLERESP_get0_id 5157 1_1_0 EXIST::FUNCTION:
TS_STATUS_INFO_get_status 5158 1_1_0 EXIST::FUNCTION:
OCSP_resp_get_produced_at 5159 1_1_0 EXIST::FUNCTION:
TS_STATUS_INFO_get_failure_info 5160 1_1_0 EXIST::FUNCTION:
TS_STATUS_INFO_get_text 5161 1_1_0 EXIST::FUNCTION:

0 comments on commit 9e5cd4b

Please sign in to comment.