I have an function which decodes the encoded base64 data in binary data but I dont know how to find the length of decoded data. I use the BIO functions in openssl.
unsigned char *unbase64(unsigned char *input, int length) { BIO *b64, *bmem; unsigned char *buffer = (unsigned char *)malloc(length); memset(buffer, 0, length); b64 = BIO_new(BIO_f_base64()); bmem = BIO_new_mem_buf(input, length); bmem = BIO_push(b64, bmem); BIO_read(bmem, buffer, length); BIO_free_all(bmem); return buffer; }
BIO_read will return the number of bytes read. You should check for return values throughout, anyway.