Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -3097,6 +3097,7 @@ static word16 TLSX_CSR_Write(CertificateStatusRequest* csr, byte* output,

#ifndef NO_WOLFSSL_CLIENT
if (isRequest) {
int ret = 0;
word16 offset = 0;
word16 length = 0;

Expand All @@ -3110,12 +3111,16 @@ static word16 TLSX_CSR_Write(CertificateStatusRequest* csr, byte* output,
offset += OPAQUE16_LEN;

/* request extensions */
if (csr->request.ocsp.nonceSz)
length = (word16)EncodeOcspRequestExtensions(
&csr->request.ocsp,
if (csr->request.ocsp.nonceSz) {
ret = (int)EncodeOcspRequestExtensions(&csr->request.ocsp,
output + offset + OPAQUE16_LEN,
OCSP_NONCE_EXT_SZ);

if (ret > 0) {
length = (word16)ret;
}
}

c16toa(length, output + offset);
offset += OPAQUE16_LEN + length;

Expand Down Expand Up @@ -3558,6 +3563,7 @@ static word16 TLSX_CSR2_Write(CertificateStatusRequestItemV2* csr2,

#ifndef NO_WOLFSSL_CLIENT
if (isRequest) {
int ret = 0;
word16 offset;
word16 length;

Expand Down Expand Up @@ -3585,12 +3591,17 @@ static word16 TLSX_CSR2_Write(CertificateStatusRequestItemV2* csr2,
/* request extensions */
length = 0;

if (csr2->request.ocsp[0].nonceSz)
length = (word16)EncodeOcspRequestExtensions(
if (csr2->request.ocsp[0].nonceSz) {
ret = (int)EncodeOcspRequestExtensions(
&csr2->request.ocsp[0],
output + offset + OPAQUE16_LEN,
OCSP_NONCE_EXT_SZ);

if (ret > 0) {
length = (word16)ret;
}
}

c16toa(length, output + offset);
offset += OPAQUE16_LEN + length;
break;
Expand Down
20 changes: 11 additions & 9 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -36359,18 +36359,20 @@ word32 EncodeOcspRequestExtensions(OcspRequest* req, byte* output, word32 size)
/* Check request has nonce to write in extension. */
if (req != NULL && req->nonceSz != 0) {
DECL_ASNSETDATA(dataASN, ocspNonceExtASN_Length);
int sz;
int sz = 0;

CALLOC_ASNSETDATA(dataASN, ocspNonceExtASN_Length, ret, req->heap);

/* Set nonce extension OID and nonce. */
SetASN_Buffer(&dataASN[OCSPNONCEEXTASN_IDX_EXT_OID], NonceObjId,
sizeof(NonceObjId));
SetASN_Buffer(&dataASN[OCSPNONCEEXTASN_IDX_EXT_NONCE], req->nonce,
(word32)req->nonceSz);
/* Calculate size of nonce extension. */
ret = SizeASN_Items(ocspNonceExtASN, dataASN, ocspNonceExtASN_Length,
&sz);
if ((ret == 0) && (output != NULL)) {
/* Set nonce extension OID and nonce. */
SetASN_Buffer(&dataASN[OCSPNONCEEXTASN_IDX_EXT_OID], NonceObjId,
sizeof(NonceObjId));
SetASN_Buffer(&dataASN[OCSPNONCEEXTASN_IDX_EXT_NONCE], req->nonce,
(word32)req->nonceSz);
/* Calculate size of nonce extension. */
ret = SizeASN_Items(ocspNonceExtASN, dataASN,
ocspNonceExtASN_Length, &sz);
}
/* Check buffer big enough for encoding if supplied. */
if ((ret == 0) && (output != NULL) && (sz > (int)size)) {
ret = BUFFER_E;
Expand Down