EVP_MD_CTX“错误:‘ctx’的存储大小未知"; [英] EVP_MD_CTX "error: storage size of ‘ctx’ isn’t known"
本文介绍了EVP_MD_CTX“错误:‘ctx’的存储大小未知";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的系统是 Ubuntu16.04 LTS.当我使用 OpenSSL EVP_MD_CTX
时,出现此错误.有人可以帮我吗?
My system is Ubuntu16.04 LTS. when I use the OpenSSL EVP_MD_CTX
, this error appeared. Can anyone help me?
代码:
#include <stdio.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
int main()
{
int ret,inlen,outlen=0;
unsigned long e=RSA_3;
char data[100],out[500];
EVP_MD_CTX md_ctx, md_ctx2;
...
}
错误:
root@ubuntu:/work/test# gcc evp_openssl_test.c -I/usr/local/include -L/usr/local/lib -lssl -lcrypto -o
evptestevp_openssl_test.c: In function ‘main’:
evp_openssl_test.c:13:19: error: storage size of ‘md_ctx’ isn’t known
EVP_MD_CTX md_ctx,md_ctx2;
推荐答案
您正在使用 OpenSSL 1.1.0,这使得该结构(以及许多其他结构)变得不透明 - 这意味着您无法对其进行堆栈分配.而是这样做:
You are using OpenSSL 1.1.0 which made this structure (and many others) opaque - which means you cannot stack allocate it. Instead do this:
EVP_MD_CTX *md_ctx;
md_ctx = EVP_MD_CTX_new();
if (md_ctx == NULL)
...
...
EVP_MD_CTX_free(md_ctx);
这篇关于EVP_MD_CTX“错误:‘ctx’的存储大小未知";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文