mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
ocsp: refactor wolfSSL_OCSP_response_get1_basic
The internal fields of OcspResponse refer to the resp->source buffer. Copying these fields is complex, so it's better to decode the response again.
This commit is contained in:
22
src/ocsp.c
22
src/ocsp.c
@ -1163,27 +1163,9 @@ const char *wolfSSL_OCSP_response_status_str(long s)
|
||||
WOLFSSL_OCSP_BASICRESP* wolfSSL_OCSP_response_get1_basic(OcspResponse* response)
|
||||
{
|
||||
WOLFSSL_OCSP_BASICRESP* bs;
|
||||
const unsigned char *ptr = response->source;
|
||||
|
||||
bs = (WOLFSSL_OCSP_BASICRESP*)XMALLOC(sizeof(WOLFSSL_OCSP_BASICRESP), NULL,
|
||||
DYNAMIC_TYPE_OCSP_REQUEST);
|
||||
if (bs == NULL)
|
||||
return NULL;
|
||||
|
||||
XMEMCPY(bs, response, sizeof(OcspResponse));
|
||||
bs->single = (OcspEntry*)XMALLOC(sizeof(OcspEntry), NULL,
|
||||
DYNAMIC_TYPE_OCSP_ENTRY);
|
||||
bs->source = (byte*)XMALLOC(bs->maxIdx, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (bs->single == NULL || bs->source == NULL) {
|
||||
XFREE(bs->single, NULL, DYNAMIC_TYPE_OCSP_ENTRY);
|
||||
bs->single = NULL;
|
||||
wolfSSL_OCSP_RESPONSE_free(bs);
|
||||
bs = NULL;
|
||||
}
|
||||
else {
|
||||
XMEMCPY(bs->single, response->single, sizeof(OcspEntry));
|
||||
XMEMCPY(bs->source, response->source, response->maxIdx);
|
||||
bs->single->ownStatus = 0;
|
||||
}
|
||||
bs = wolfSSL_d2i_OCSP_RESPONSE(NULL, &ptr, response->maxIdx);
|
||||
return bs;
|
||||
}
|
||||
|
||||
|
@ -37454,6 +37454,7 @@ static int DecodeBasicOcspResponse(byte* source, word32* ioIndex,
|
||||
DECL_ASNGETDATA(dataASN, ocspBasicRespASN_Length);
|
||||
int ret = 0;
|
||||
word32 idx = *ioIndex;
|
||||
Signer* ca = NULL;
|
||||
|
||||
WOLFSSL_ENTER("DecodeBasicOcspResponse");
|
||||
(void)heap;
|
||||
|
Reference in New Issue
Block a user