我已经安装了最新版本的OpenSSL.我只是尝试编译并运行OpenSSL_aes程序.
在使用gcc -Wall openssl_aes.c -lcrypto进行编译时出现以下错误.我尽力解决了这个问题,但无法解决这个编译错误.
openssl_aes.c: In function ‘aes_encrypt’: openssl_aes.c:51:22: error: ‘AES_BLOCK_SIZE’ undeclared (first use in this function) int c_len = *len + AES_BLOCK_SIZE, f_len = 0; ^ openssl_aes.c:51:22: note: each undeclared identifier is reported only once for each function it appears in openssl_aes.c: In function ‘aes_decrypt’: openssl_aes.c:75:45: error: ‘AES_BLOCK_SIZE’ undeclared (first use in this function) unsigned char *plaintext = malloc(p_len + AES_BLOCK_SIZE); ^
编辑:
当我#include
按照@ martin 添加时,编译问题就解决了.
现在,gcc -Wall openssl_aes.c -lcrypto已成功编译.
但是,当我尝试运行程序(运行我使用 - ./a.out)时,我得到了以下错误 分段错误(核心转储)
谁能帮助我解决这个问题并运行我的程序?我只想使用OpenSSL执行简单的加密/解密.我在Fedora 19下使用GCC.
提前致谢.
您可能不包括openssl/aes.h
,AES_BLOCK_SIZE
如下所示:#define AES_BLOCK_SIZE 16
.所以要确保你有:
#include <openssl/aes.h>
在你的文件中.