gpt4 book ai didi

c - 错误 : ‘AES_BLOCK_SIZE’ undeclared. 无法在 Linux 中使用 C 编译 OpenSSL

转载 作者:太空狗 更新时间:2023-10-29 11:24:44 28 4
gpt4 key购买 nike

我已经安装了最新版本的 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<openssl/aes.h> 时根据@martin,编译问题已解决。

至此,gcc -Wall openssl_aes.c -lcrypto 编译成功。

但是,当我尝试运行该程序(运行我使用 - ./a.out )时,出现以下错误段错误(核心已转储)

谁能帮我解决这个问题并运行我的程序?我只想使用 OpenSSL 执行简单的 aes 加密/解密。我在 Fedora 19 下使用 GCC。

提前致谢。

最佳答案

您可能没有包含 openssl/aes.h,因为 AES_BLOCK_SIZE 在其中定义为:#define AES_BLOCK_SIZE 16。因此,请确保您拥有:

#include <openssl/aes.h>

在你的文件中。

关于c - 错误 : ‘AES_BLOCK_SIZE’ undeclared. 无法在 Linux 中使用 C 编译 OpenSSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21512424/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com