FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/src/ocsp.c
/* Mallocs responseBuffer->buffer and is up to caller to free on success
 *
 * Returns OCSP status
 */
Mallocs responseBuffer->buffer and is up to caller to free on success
Returns OCSP status
Mallocs responseBuffer - > buffer and is up to caller to free on success Returns OCSP status
static int GetOcspStatus(WOLFSSL_OCSP* ocsp, OcspRequest* request,
                  OcspEntry* entry, CertStatus** status, buffer* responseBuffer)
{
    int ret = OCSP_INVALID_STATUS;
    WOLFSSL_ENTER("GetOcspStatus");
    *status = NULL;
    if (wc_LockMutex(&ocsp->ocspLock) != 0) {
        WOLFSSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E);
        return BAD_MUTEX_E;
    }
    for (*status = entry->status; *status; *status = (*status)->next)
        if ((*status)->serialSz == request->serialSz
        &&  !XMEMCMP((*status)->serial, request->serial, (*status)->serialSz))
            break;
    if (responseBuffer && *status && !(*status)->rawOcspResponse) {
        ret = OCSP_INVALID_STATUS;
    }
    else if (*status) {
#ifndef NO_ASN_TIME
        if (XVALIDATE_DATE((*status)->thisDate,
                                             (*status)->thisDateFormat, BEFORE)
        &&  ((*status)->nextDate[0] != 0)
        &&  XVALIDATE_DATE((*status)->nextDate,
                                             (*status)->nextDateFormat, AFTER))
#endif
        {
            ret = xstat2err((*status)->status);
            if (responseBuffer) {
                responseBuffer->buffer = (byte*)XMALLOC(
                   (*status)->rawOcspResponseSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
                if (responseBuffer->buffer) {
                    responseBuffer->length = (*status)->rawOcspResponseSz;
                    XMEMCPY(responseBuffer->buffer,
                            (*status)->rawOcspResponse,
                            (*status)->rawOcspResponseSz);
                }
            }
        }
    }
    wc_UnLockMutex(&ocsp->ocspLock);
    return ret;
}
static int GetOcspStatus ( WOLFSSL_OCSP * ocsp , OcspRequest * request , OcspEntry * entry , CertStatus * * status , buffer * responseBuffer ) { int ret = OCSP_INVALID_STATUS ; WOLFSSL_ENTER ( " " ) ; * status = NULL ; if ( wc_LockMutex ( & ocsp -> ocspLock ) != 0 ) { WOLFSSL_LEAVE ( " " , BAD_MUTEX_E ) ; return BAD_MUTEX_E ; } for ( * status = entry -> status ; * status ; * status = ( * status ) -> next ) if ( ( * status ) -> serialSz == request -> serialSz && ! XMEMCMP ( ( * status ) -> serial , request -> serial , ( * status ) -> serialSz ) ) break ; if ( responseBuffer && * status && ! ( * status ) -> rawOcspResponse ) { ret = OCSP_INVALID_STATUS ; } else if ( * status ) { #ifndef NO_ASN_TIME if ( XVALIDATE_DATE ( ( * status ) -> thisDate , ( * status ) -> thisDateFormat , BEFORE ) && ( ( * status ) -> nextDate [ 0 ] != 0 ) && XVALIDATE_DATE ( ( * status ) -> nextDate , ( * status ) -> nextDateFormat , AFTER ) ) #endif { ret = xstat2err ( ( * status ) -> status ) ; if ( responseBuffer ) { responseBuffer -> buffer = ( byte * ) XMALLOC ( ( * status ) -> rawOcspResponseSz , NULL , DYNAMIC_TYPE_TMP_BUFFER ) ; if ( responseBuffer -> buffer ) { responseBuffer -> length = ( * status ) -> rawOcspResponseSz ; XMEMCPY ( responseBuffer -> buffer , ( * status ) -> rawOcspResponse , ( * status ) -> rawOcspResponseSz ) ; } } } } wc_UnLockMutex ( & ocsp -> ocspLock ) ; return ret ; }
Mallocs responseBuffer->buffer and is up to caller to free on success
 Returns OCSP status
Mallocs responseBuffer - > buffer and is up to caller to free on success Returns OCSP status
/* force fetching again */