Reputation: 33
I am trying to use openSSL library for Base64 decoding followed by CMS usage to verify signature.
Below code always print buffer as NULL.
char signed_data[] = "MIIO";
int signed_data_length = sizeof(signed_data);
BIO *b64, *bmem;
char *buffer = (char *)malloc(signed_data_length);
memset(buffer, 0, signed_data_length);
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new_mem_buf(signed_data, signed_data_length);
bmem = BIO_push(b64, bmem);
BIO_read(bmem, buffer, signed_data_length);
printf("%s", buffer);
Upvotes: 2
Views: 1360
Reputation: 750
Add BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL) after the BIO_new() call to tell OpenSSL that all the input appears in a single line without newline.
Upvotes: 3