Skip to content

Commit

Permalink
fix errors due to CreateOcspRequest()
Browse files Browse the repository at this point in the history
addressed review comments
  • Loading branch information
miyazakh committed Jul 31, 2024
1 parent 2c6405c commit 5ee488b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -23360,7 +23360,7 @@ int SendFinished(WOLFSSL* ssl)
*
* Returns 0 on success
*/
static int CreateOcspRequest(WOLFSSL* ssl, OcspRequest* request,
int CreateOcspRequest(WOLFSSL* ssl, OcspRequest* request,
DecodedCert* cert, byte* certData, word32 length,
byte *ctxOwnsRequest)
{
Expand Down
14 changes: 5 additions & 9 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -3165,12 +3165,8 @@ word16 TLSX_CSR_GetSize_ex(CertificateStatusRequest* csr, byte isRequest,
#endif
#if defined(WOLFSSL_TLS13) && !defined(NO_WOLFSSL_SERVER)
if (!isRequest && csr->ssl->options.tls1_3) {
if (csr->responses[idx].length != 0)
size = (word16)(OPAQUE8_LEN + OPAQUE24_LEN +
csr->responses[idx].length);
else
size = (word16)OPAQUE16_LEN;
return size;
return (word16)(OPAQUE8_LEN + OPAQUE24_LEN +
csr->responses[idx].length);;
}
#else
(void)idx;
Expand Down Expand Up @@ -3272,6 +3268,7 @@ static int TLSX_CSR_Parse(WOLFSSL* ssl, const byte* input, word16 length,
OcspRequest* request;
TLSX* extension;
CertificateStatusRequest* csr;
byte ctxOwnsRequest = 0;
#endif

#if !defined(NO_WOLFSSL_CLIENT) && defined(WOLFSSL_TLS13) \
Expand Down Expand Up @@ -3494,9 +3491,8 @@ static int TLSX_CSR_Parse(WOLFSSL* ssl, const byte* input, word16 length,
request = &csr->request.ocsp[i + 1];
if (ret == 0) {
ret = CreateOcspRequest(ssl, request, cert,
der.buffer, der.length);
if (ret == 0 &&
request == ssl->ctx->certOcspRequest) {
der.buffer, der.length, &ctxOwnsRequest);
if (ctxOwnsRequest) {
wolfSSL_Mutex* ocspLock =
&SSL_CM(ssl)->ocsp_stapling->ocspLock;
if (wc_LockMutex(ocspLock) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/tls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -8432,7 +8432,7 @@ static word32 WriteCSRToBuffer(WOLFSSL* ssl, word16* extSz, word16 extSz_num)
for (extIdx = 0; extIdx < (word16)(extSz_num); extIdx++) {
extSz[extIdx] = TLSX_CSR_GetSize_ex(csr, 0, extIdx + 1);

if (extSz[extIdx] > OPAQUE16_LEN &&
if (extSz[extIdx] > (OPAQUE8_LEN + OPAQUE24_LEN) &&
ssl->buffers.certExts[extIdx + 1] == NULL) {
ret = AllocDer(&ssl->buffers.certExts[extIdx + 1],
extSz[extIdx] + ex_offset,
Expand Down
3 changes: 2 additions & 1 deletion wolfssl/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3269,7 +3269,8 @@ WOLFSSL_LOCAL int TLSX_CSR_Write_ex(CertificateStatusRequest* csr, byte* output,
WOLFSSL_LOCAL void* TLSX_CSR_GetRequest_ex(TLSX* extensions, int idx);

WOLFSSL_LOCAL int CreateOcspRequest(WOLFSSL* ssl, OcspRequest* request,
DecodedCert* cert, byte* certData, word32 length);
DecodedCert* cert, byte* certData, word32 length,
byte *ctxOwnsRequest);
#endif

/** Certificate Status Request v2 - RFC 6961 */
Expand Down

0 comments on commit 5ee488b

Please sign in to comment.