Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
miyazakh committed Sep 21, 2024
1 parent fca6a40 commit 2b6ffec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/tls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -8404,7 +8404,7 @@ static word32 NextCert(byte* data, word32 length, word32* idx)
return len;
}

#if defined(HAVE_CERTIFICATE_STATUS_REQUEST)
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST) && !defined(NO_WOLFSSL_SERVER)
/* Write certificate status request into certificate to buffer.
*
* ssl SSL/TLS object.
Expand Down Expand Up @@ -8529,7 +8529,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
{
int ret = 0;
word32 certSz, certChainSz, headerSz, listSz, payloadSz;
word16 extSz[1 + MAX_CERT_EXTENSIONS];
word16 extSz[MAX_CERT_EXTENSIONS];
word16 extIdx = 0;
word32 maxFragment;
word32 totalextSz = 0;
Expand Down Expand Up @@ -8597,7 +8597,7 @@ static int SendTls13Certificate(WOLFSSL* ssl)
for (extIdx = 0; extIdx < (word16)XELEM_CNT(extSz); extIdx++)
extSz[extIdx] = OPAQUE16_LEN;

#if defined(HAVE_CERTIFICATE_STATUS_REQUEST)
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST) && !defined(NO_WOLFSSL_SERVER)
/* We only send CSR on the server side. On client side, the CSR data
* is populated with the server response. We would be sending the server
* its own stapling data. */
Expand Down Expand Up @@ -8730,14 +8730,14 @@ static int SendTls13Certificate(WOLFSSL* ssl)
if (certSz > 0 && ssl->fragOffset < certSz + extSz[0]) {
/* Put in the leaf certificate with extensions. */
word32 copySz = AddCertExt(ssl, ssl->buffers.certificate->buffer,
certSz, extSz[extIdx], ssl->fragOffset, fragSz,
output + i, extIdx);
certSz, extSz[0], ssl->fragOffset, fragSz,
output + i, 0);
i += copySz;
ssl->fragOffset += copySz;
length -= copySz;
fragSz -= copySz;
if (ssl->fragOffset == certSz + extSz[extIdx])
FreeDer(&ssl->buffers.certExts[extIdx]);
if (ssl->fragOffset == certSz + extSz[0])
FreeDer(&ssl->buffers.certExts[0]);
}
}
if (certChainSz > 0 && fragSz > 0) {
Expand All @@ -8754,8 +8754,11 @@ static int SendTls13Certificate(WOLFSSL* ssl)
ssl->buffers.certChain->length, &idx);
if (len == 0)
break;
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST) && \
!defined(NO_WOLFSSL_SERVER)
if (MAX_CERT_EXTENSIONS > extIdx)
extIdx++;
#endif
}
/* Write out certificate and extension. */
l = AddCertExt(ssl, p, len, extSz[extIdx], offset, fragSz,
Expand Down
7 changes: 7 additions & 0 deletions wolfssl/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,13 @@ enum Misc {
#define MAX_CHAIN_DEPTH 9
#endif

#if defined(HAVE_CERTIFICATE_STATUS_REQUEST) || \
defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2)
#if !defined(HAVE_OCSP)
#error OCSP Stapling and Stapling V2 needs OCSP. Please define HAVE_OCSP.
#endif
#endif

/* Max certificate extensions in TLS1.3 */
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST)
/* Number of extensions to set each OCSP response */
Expand Down

0 comments on commit 2b6ffec

Please sign in to comment.