我正在尝试使用 openSSL 库进行 Base64 解码,然后使用 CMS 来验证签名。
下面的代码总是将缓冲区打印为 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);