FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/wolfcrypt/src/asn.c
/* Return bytes written to buff or < 0 for error */
Return bytes written to buff or < 0 for error
Return bytes written to buff or < 0 for error
int wc_PubKeyPemToDer(const unsigned char* pem, int pemSz,
                           unsigned char* buff, int buffSz)
{
    int ret;
    DerBuffer* der = NULL;
    WOLFSSL_ENTER("wc_PubKeyPemToDer");
    if (pem == NULL || buff == NULL || buffSz <= 0) {
        WOLFSSL_MSG("Bad pem der args");
        return BAD_FUNC_ARG;
    }
    ret = PemToDer(pem, pemSz, PUBLICKEY_TYPE, &der, NULL, NULL, NULL);
    if (ret < 0 || der == NULL) {
        WOLFSSL_MSG("Bad Pem To Der");
    }
    else {
        if (der->length <= (word32)buffSz) {
            XMEMCPY(buff, der->buffer, der->length);
            ret = der->length;
        }
        else {
            WOLFSSL_MSG("Bad der length");
            ret = BAD_FUNC_ARG;
        }
    }
    FreeDer(&der);
    return ret;
}
int wc_PubKeyPemToDer ( const unsigned char * pem , int pemSz , unsigned char * buff , int buffSz ) { int ret ; DerBuffer * der = NULL ; WOLFSSL_ENTER ( " " ) ; if ( pem == NULL || buff == NULL || buffSz <= 0 ) { WOLFSSL_MSG ( " " ) ; return BAD_FUNC_ARG ; } ret = PemToDer ( pem , pemSz , PUBLICKEY_TYPE , & der , NULL , NULL , NULL ) ; if ( ret < 0 || der == NULL ) { WOLFSSL_MSG ( " " ) ; } else { if ( der -> length <= ( word32 ) buffSz ) { XMEMCPY ( buff , der -> buffer , der -> length ) ; ret = der -> length ; } else { WOLFSSL_MSG ( " " ) ; ret = BAD_FUNC_ARG ; } } FreeDer ( & der ) ; return ret ; }
Return bytes written to buff or < 0 for error
Return bytes written to buff or < 0 for error