FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/asn.c
static int SetNameFromCert(CertName* cn, const byte* der, int derSz)
{
    int ret;
#ifdef WOLFSSL_SMALL_STACK
    DecodedCert* decoded;
#else
    DecodedCert decoded[1];
#endif

    if (derSz < 0)
        return derSz;

#ifdef WOLFSSL_SMALL_STACK
    decoded = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
                                                       DYNAMIC_TYPE_TMP_BUFFER);
    if (decoded == NULL)
        return MEMORY_E;
#endif

    InitDecodedCert(decoded, der, derSz, NULL);
    ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0);

    if (ret < 0) {
        WOLFSSL_MSG("ParseCertRelative error");
    }
    else {
        SetNameFromDcert(cn, decoded);
    }

    FreeDecodedCert(decoded);

#ifdef WOLFSSL_SMALL_STACK
    XFREE(decoded, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif

    return ret < 0 ? ret : 0;
}
/* Set cn name from der buffer, return 0 on success */
Set cn name from der buffer, return 0 on success
Set cn name from der buffer return 0 on success
static int SetNameFromCert(CertName* cn, const byte* der, int derSz)
{
    int ret;
#ifdef WOLFSSL_SMALL_STACK
    DecodedCert* decoded;
#else
    DecodedCert decoded[1];
#endif
    if (derSz < 0)
        return derSz;
#ifdef WOLFSSL_SMALL_STACK
    decoded = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
                                                       DYNAMIC_TYPE_TMP_BUFFER);
    if (decoded == NULL)
        return MEMORY_E;
#endif
    InitDecodedCert(decoded, der, derSz, NULL);
    ret = ParseCertRelative(decoded, CA_TYPE, NO_VERIFY, 0);
    if (ret < 0) {
        WOLFSSL_MSG("ParseCertRelative error");
    }
    else {
        SetNameFromDcert(cn, decoded);
    }
    FreeDecodedCert(decoded);
#ifdef WOLFSSL_SMALL_STACK
    XFREE(decoded, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif
    return ret < 0 ? ret : 0;
}
static int SetNameFromCert ( CertName * cn , const byte * der , int derSz ) { int ret ; #ifdef WOLFSSL_SMALL_STACK DecodedCert * decoded ; #else DecodedCert decoded [ 1 ] ; #endif if ( derSz < 0 ) return derSz ; #ifdef WOLFSSL_SMALL_STACK decoded = ( DecodedCert * ) XMALLOC ( sizeof ( DecodedCert ) , NULL , DYNAMIC_TYPE_TMP_BUFFER ) ; if ( decoded == NULL ) return MEMORY_E ; #endif InitDecodedCert ( decoded , der , derSz , NULL ) ; ret = ParseCertRelative ( decoded , CA_TYPE , NO_VERIFY , 0 ) ; if ( ret < 0 ) { WOLFSSL_MSG ( " " ) ; } else { SetNameFromDcert ( cn , decoded ) ; } FreeDecodedCert ( decoded ) ; #ifdef WOLFSSL_SMALL_STACK XFREE ( decoded , NULL , DYNAMIC_TYPE_TMP_BUFFER ) ; #endif return ret < 0 ? ret : 0 ; }
Set cn name from der buffer, return 0 on success
Set cn name from der buffer return 0 on success