FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/src/bio.c
/* Converts data into base64 output
 *
 * returns the resulting buffer size on success.
 */
Converts data into base64 output
returns the resulting buffer size on success.
Converts data into base64 output returns the resulting buffer size on success .
static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data,
        word32 inLen, byte* out, word32* outLen)
{
    byte* tmp = NULL;
    int ret   = 0;
    WOLFSSL_ENTER("wolfSSL_BIO_BASE64_write");
    if (bio == NULL || data == NULL || out == NULL || outLen == NULL) {
        return BAD_FUNC_ARG;
    }
#if defined(WOLFSSL_BASE64_ENCODE)
    tmp = (byte*)XMALLOC(*outLen, bio->heap, DYNAMIC_TYPE_TMP_BUFFER);
    if (tmp == NULL) {
        return WOLFSSL_FATAL_ERROR;
    }
    if ((bio->flags & WOLFSSL_BIO_FLAG_BASE64_NO_NL) ==
            WOLFSSL_BIO_FLAG_BASE64_NO_NL) {
        if (Base64_Encode_NoNl((const byte*)data, inLen,
                tmp, outLen) < 0) {
            ret = WOLFSSL_FATAL_ERROR;
        }
    }
    else {
        if (Base64_Encode((const byte*)data, inLen,
                tmp, outLen) < 0) {
            ret = WOLFSSL_FATAL_ERROR;
        }
    }
    if (ret != WOLFSSL_FATAL_ERROR) {
        ret = (int) inLen;
        XMEMCPY(out, tmp, *outLen);
    }
    XFREE(tmp, bio->heap, DYNAMIC_TYPE_TMP_BUFFER);
#else
    (void)bio;
    (void)data;
    (void)inLen;
    (void)out;
    (void)outLen;
    (void)tmp;
    WOLFSSL_MSG("BASE64 encoding not compiled in");
#endif
    return ret;
}
static int wolfSSL_BIO_BASE64_write ( WOLFSSL_BIO * bio , const void * data , word32 inLen , byte * out , word32 * outLen ) { byte * tmp = NULL ; int ret = 0 ; WOLFSSL_ENTER ( " " ) ; if ( bio == NULL || data == NULL || out == NULL || outLen == NULL ) { return BAD_FUNC_ARG ; } #if defined ( WOLFSSL_BASE64_ENCODE ) tmp = ( byte * ) XMALLOC ( * outLen , bio -> heap , DYNAMIC_TYPE_TMP_BUFFER ) ; if ( tmp == NULL ) { return WOLFSSL_FATAL_ERROR ; } if ( ( bio -> flags & WOLFSSL_BIO_FLAG_BASE64_NO_NL ) == WOLFSSL_BIO_FLAG_BASE64_NO_NL ) { if ( Base64_Encode_NoNl ( ( const byte * ) data , inLen , tmp , outLen ) < 0 ) { ret = WOLFSSL_FATAL_ERROR ; } } else { if ( Base64_Encode ( ( const byte * ) data , inLen , tmp , outLen ) < 0 ) { ret = WOLFSSL_FATAL_ERROR ; } } if ( ret != WOLFSSL_FATAL_ERROR ) { ret = ( int ) inLen ; XMEMCPY ( out , tmp , * outLen ) ; } XFREE ( tmp , bio -> heap , DYNAMIC_TYPE_TMP_BUFFER ) ; #else ( void ) bio ; ( void ) data ; ( void ) inLen ; ( void ) out ; ( void ) outLen ; ( void ) tmp ; WOLFSSL_MSG ( " " ) ; #endif return ret ; }
Converts data into base64 output
 returns the resulting buffer size on success.
Converts data into base64 output returns the resulting buffer size on success .