Hi All, I'm trying to decode a base64 encoded string. The problem I'm running in to is that BIO_read() always returns 0. BIO_should_retry() and BIO_should_read() also return 0 when BIO_read() returns 0. If the base64 encoded string is shortened, BIO_read returns the decoded information. I get this result using OpenSSL 0.9.8k (cross-compiled for a Blackfin processor) and OpenSSL 0.9.8g on Ubuntu 9.04.
Any suggestions on what I'm doing wrong? Thanks, ...doug ---8<----- /* * Compiled with: gcc -Wall -lssl */ #include <openssl/bio.h> #include <openssl/evp.h> #include <stdio.h> #include <string.h> int main(int argc, char **argv) { #if 1 /* * This does not work */ char *message = "Tm8gaXMgdGhlIHRpbWUgZm9yIGFsbCBnb29kIG1lbiB0byBjb21lIHRvIHRoZSBhaWQgb2YgdGhlaXIgY291bnRyeS4NClRoZSBxdWljayBicm93biBmb3gganVtcGVkIG92ZXIgdGhlIGxhenkgZG9nJ3MgYmFjayAwMTIzNDU2Nzg5Lg==\n"; #endif #if 0 /* * This shortened version works */ char *message = "Tm8gaXMgdGhlIHRpbWUgZm9yIGFsbCBnb29kIG1lbiB0by==\n"; #endif BIO *b64, *bio, *bmem; char *buf; int i = strlen(message); buf = malloc(i); if (!buf) { printf("malloc fail, %m\n"); return -1; } bmem = BIO_new_mem_buf((void*)message, -1); b64 = BIO_new(BIO_f_base64()); BIO_set_flags(bmem, BIO_FLAGS_BASE64_NO_NL); bio = BIO_push(b64, bmem); i = BIO_read(bio, (void*)buf, i); buf[i] = '\0'; BIO_free_all(bio); printf("%s\n%s\n", message, buf); return 0; } ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org