FreeRTOS-Plus/ThirdParty/WolfSSL-FIPS-Ready/src/bio.c
/* Used to read data from a WOLFSSL_BIO structure
 *
 * bio  structure to read data from
 * buf  buffer to hold the result
 * len  length of buf buffer
 *
 * returns the number of bytes read on success
 */
Used to read data from a WOLFSSL_BIO structure
bio  structure to read data from
buf  buffer to hold the result
len  length of buf buffer

returns the number of bytes read on success
Used to read data from a WOLFSSL_BIO structure bio structure to read data from buf buffer to hold the result len length of buf buffer returns the number of bytes read on success
int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len)
{
    int  ret = 0;
    WOLFSSL_BIO* front = bio;
    int  sz  = 0;
    WOLFSSL_ENTER("wolfSSL_BIO_read");
    if (front != NULL && front->infoCb != NULL) {
        ret = (int)front->infoCb(front, WOLFSSL_BIO_CB_READ, (const char*)buf,
                                                                     len, 0, 1);
        if (ret <= 0) {
            return ret;
        }
    }
    while ((bio != NULL) && (bio->next != NULL)) {
        bio = bio->next;
    }
    while (bio != NULL && ret >= 0) {
        if (bio->method && bio->method->readCb) {
            ret = bio->method->readCb(bio, (char*)buf, len);
        }
        if (bio->type == WOLFSSL_BIO_BASE64 && ret > 0 && sz > 0) {
            ret = wolfSSL_BIO_BASE64_read(bio, buf, sz);
        }
        if (bio && bio->type == WOLFSSL_BIO_BIO) {
            ret = wolfSSL_BIO_BIO_read(bio, buf, len);
        }
        if (bio && bio->type == WOLFSSL_BIO_MEMORY) {
            ret = wolfSSL_BIO_MEMORY_read(bio, buf, len);
        }
    #ifndef NO_FILESYSTEM
        if (bio && bio->type == WOLFSSL_BIO_FILE) {
            ret = (int)XFREAD(buf, 1, len, (XFILE)bio->ptr);
        }
    #endif
    #ifndef WOLFCRYPT_ONLY
        if (bio && bio->type == WOLFSSL_BIO_SSL) {
            ret = wolfSSL_BIO_SSL_read(bio, buf, len, front);
        }
        if (bio && bio->type == WOLFSSL_BIO_MD && ret > 0) {
            ret = wolfSSL_BIO_MD_read(bio, buf, ret);
        }
    #endif
        if (bio == front) {
            break; 
        }
        if (ret > 0) {
            sz = ret; 
        }
        bio = bio->prev;
    }
    if (front != NULL && front->infoCb != NULL) {
        ret = (int)front->infoCb(front,
                                 WOLFSSL_BIO_CB_READ | WOLFSSL_BIO_CB_RETURN,
                                 (const char*)buf, len, 0, ret);
    }
    return ret;
}
int wolfSSL_BIO_read ( WOLFSSL_BIO * bio , void * buf , int len ) { int ret = 0 ; WOLFSSL_BIO * front = bio ; int sz = 0 ; WOLFSSL_ENTER ( " " ) ; if ( front != NULL && front -> infoCb != NULL ) { ret = ( int ) front -> infoCb ( front , WOLFSSL_BIO_CB_READ , ( const char * ) buf , len , 0 , 1 ) ; if ( ret <= 0 ) { return ret ; } } while ( ( bio != NULL ) && ( bio -> next != NULL ) ) { bio = bio -> next ; } while ( bio != NULL && ret >= 0 ) { if ( bio -> method && bio -> method -> readCb ) { ret = bio -> method -> readCb ( bio , ( char * ) buf , len ) ; } if ( bio -> type == WOLFSSL_BIO_BASE64 && ret > 0 && sz > 0 ) { ret = wolfSSL_BIO_BASE64_read ( bio , buf , sz ) ; } if ( bio && bio -> type == WOLFSSL_BIO_BIO ) { ret = wolfSSL_BIO_BIO_read ( bio , buf , len ) ; } if ( bio && bio -> type == WOLFSSL_BIO_MEMORY ) { ret = wolfSSL_BIO_MEMORY_read ( bio , buf , len ) ; } #ifndef NO_FILESYSTEM if ( bio && bio -> type == WOLFSSL_BIO_FILE ) { ret = ( int ) XFREAD ( buf , 1 , len , ( XFILE ) bio -> ptr ) ; } #endif #ifndef WOLFCRYPT_ONLY if ( bio && bio -> type == WOLFSSL_BIO_SSL ) { ret = wolfSSL_BIO_SSL_read ( bio , buf , len , front ) ; } if ( bio && bio -> type == WOLFSSL_BIO_MD && ret > 0 ) { ret = wolfSSL_BIO_MD_read ( bio , buf , ret ) ; } #endif if ( bio == front ) { break ; } if ( ret > 0 ) { sz = ret ; } bio = bio -> prev ; } if ( front != NULL && front -> infoCb != NULL ) { ret = ( int ) front -> infoCb ( front , WOLFSSL_BIO_CB_READ | WOLFSSL_BIO_CB_RETURN , ( const char * ) buf , len , 0 , ret ) ; } return ret ; }
Used to read data from a WOLFSSL_BIO structure
 bio  structure to read data from
 buf  buffer to hold the result
 len  length of buf buffer
Used to read data from a WOLFSSL_BIO structure bio structure to read data from buf buffer to hold the result len length of buf buffer
/* info cb, abort if user returns <= 0*/ /* start at end of list and work backwards */ /* check for custom read */ /* formatting data */ /* write BIOs */ /* data passing through BIO MD wrapper */ /* case where front of list is done */ /* at front of list so be done */ /* adjust size for formatting */ /* previous WOLFSSL_BIO in list working towards head of list */ /* info cb, user can override return value */