How to find size of decoded base64 data in C
I have a function that decodes base64 encoded data into binary data, but I don't know how to find the length of the decoded data. I am using 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;
}
+1
Granit
source
to share