Hey folks, I've got a problem where I'm trying to decode base64 in memory and BIO_read is returning 1 when I think it should be returning the number of bytes read into buf after doing a base64 decode. The code is based on the BIO_f_base64(3) manpage. The output should be "BOOGA BOOG". The correct data is being placed in the buf but the length being returned is incorrect.
#include <stdio.h> #include <string.h> #include <openssl/buffer.h> #include <openssl/bio.h> #include <openssl/evp.h> int main(void) { char *data = "Qk9PR0EgQk9PRw==\n"; int dlen = strlen(data); int inlen, totallen = 0; char buf[512]; BIO *bio, *bio_out; BIO *b64 = BIO_new(BIO_f_base64()); bio = BIO_new_mem_buf(data, dlen); bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); bio = BIO_push(b64, bio); while((inlen = BIO_read(bio, buf, 512) > 0)) { totallen += inlen; BIO_write(bio_out, buf, inlen); BIO_flush(bio_out); } printf("\n%d was total len!\n", totallen); BIO_free_all(bio); return 0; } -- Chris Green <[EMAIL PROTECTED]> A watched process never cores. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]