FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/asn.c
/* parse crl buffer into decoded state, 0 on success */
parse crl buffer into decoded state, 0 on success
parse crl buffer into decoded state 0 on success
int ParseCRL(DecodedCRL* dcrl, const byte* buff, word32 sz, void* cm)
{
    int          len;
    word32       idx = 0;
    Signer*      ca = NULL;
    SignatureCtx sigCtx;
    WOLFSSL_MSG("ParseCRL");
    if (GetSequence(buff, &idx, &len, sz) < 0)
        return ASN_PARSE_E;
    dcrl->certBegin = idx;
    sz = len + idx;
    if (GetSequence(buff, &idx, &len, sz) < 0)
        return ASN_PARSE_E;
    dcrl->sigIndex = len + idx;
    if (ParseCRL_CertList(dcrl, buff, &idx, dcrl->sigIndex) < 0)
        return ASN_PARSE_E;
    if (ParseCRL_Extensions(dcrl, buff, &idx, dcrl->sigIndex) < 0)
        return ASN_PARSE_E;
    idx = dcrl->sigIndex;
    if (GetAlgoId(buff, &idx, &dcrl->signatureOID, oidSigType, sz) < 0)
        return ASN_PARSE_E;
    if (GetCRL_Signature(buff, &idx, dcrl, sz) < 0)
        return ASN_PARSE_E;
#ifndef NO_SKID
    if (dcrl->extAuthKeyIdSet) {
        ca = GetCA(cm, dcrl->extAuthKeyId); 
    }
    if (ca != NULL && XMEMCMP(dcrl->issuerHash, ca->subjectNameHash,
                KEYID_SIZE) != 0) {
        ca = NULL;
    }
    if (ca == NULL) {
        ca = GetCAByName(cm, dcrl->issuerHash); 
        if (ca && dcrl->extAuthKeyIdSet) {
            WOLFSSL_MSG("CA SKID doesn't match AKID");
            ca = NULL;
        }
    }
#else
    ca = GetCA(cm, dcrl->issuerHash);
#endif 
    WOLFSSL_MSG("About to verify CRL signature");
    if (ca == NULL) {
        WOLFSSL_MSG("Did NOT find CRL issuer CA");
        return ASN_CRL_NO_SIGNER_E;
    }
    WOLFSSL_MSG("Found CRL issuer CA");
    return VerifyCRL_Signature(&sigCtx, buff + dcrl->certBegin,
           dcrl->sigIndex - dcrl->certBegin, dcrl->signature, dcrl->sigLength,
           dcrl->signatureOID, ca, dcrl->heap);
}
int ParseCRL ( DecodedCRL * dcrl , const byte * buff , word32 sz , void * cm ) { int len ; word32 idx = 0 ; Signer * ca = NULL ; SignatureCtx sigCtx ; WOLFSSL_MSG ( " " ) ; if ( GetSequence ( buff , & idx , & len , sz ) < 0 ) return ASN_PARSE_E ; dcrl -> certBegin = idx ; sz = len + idx ; if ( GetSequence ( buff , & idx , & len , sz ) < 0 ) return ASN_PARSE_E ; dcrl -> sigIndex = len + idx ; if ( ParseCRL_CertList ( dcrl , buff , & idx , dcrl -> sigIndex ) < 0 ) return ASN_PARSE_E ; if ( ParseCRL_Extensions ( dcrl , buff , & idx , dcrl -> sigIndex ) < 0 ) return ASN_PARSE_E ; idx = dcrl -> sigIndex ; if ( GetAlgoId ( buff , & idx , & dcrl -> signatureOID , oidSigType , sz ) < 0 ) return ASN_PARSE_E ; if ( GetCRL_Signature ( buff , & idx , dcrl , sz ) < 0 ) return ASN_PARSE_E ; #ifndef NO_SKID if ( dcrl -> extAuthKeyIdSet ) { ca = GetCA ( cm , dcrl -> extAuthKeyId ) ; } if ( ca != NULL && XMEMCMP ( dcrl -> issuerHash , ca -> subjectNameHash , KEYID_SIZE ) != 0 ) { ca = NULL ; } if ( ca == NULL ) { ca = GetCAByName ( cm , dcrl -> issuerHash ) ; if ( ca && dcrl -> extAuthKeyIdSet ) { WOLFSSL_MSG ( " " ) ; ca = NULL ; } } #else ca = GetCA ( cm , dcrl -> issuerHash ) ; #endif WOLFSSL_MSG ( " " ) ; if ( ca == NULL ) { WOLFSSL_MSG ( " " ) ; return ASN_CRL_NO_SIGNER_E ; } WOLFSSL_MSG ( " " ) ; return VerifyCRL_Signature ( & sigCtx , buff + dcrl -> certBegin , dcrl -> sigIndex - dcrl -> certBegin , dcrl -> signature , dcrl -> sigLength , dcrl -> signatureOID , ca , dcrl -> heap ) ; }
parse crl buffer into decoded state, 0 on success
parse crl buffer into decoded state 0 on success
/* raw crl hash */ /* hash here if needed for optimized comparisons
     * wc_Sha sha;
     * wc_InitSha(&sha);
     * wc_ShaUpdate(&sha, buff, sz);
     * wc_ShaFinal(&sha, dcrl->crlHash); */ /* Normalize sz for the length inside the outer sequence. */ /* openssl doesn't add skid by default for CRLs cause firefox chokes
       if experiencing issues uncomment NO_SKID define in CRL section of
       wolfssl/wolfcrypt/settings.h */ /* more unique than issuerHash */ /* last resort */ /* If AKID is available then this CA doesn't have the public
         * key required */ /* !NO_SKID */