Error: ‘AES_BLOCK_SIZE’ undeclared. Unable to compile OpenSSL with C in Linux
c, linux, openssl, shared-libraries
Solution
You are probably not including `openssl/aes.h`, as `AES_BLOCK_SIZE` is defined in there as: `#define AES_BLOCK_SIZE 16`. So make sure you have:
#include <openssl/aes.h>
in your file.
Problem
I have installed latest version of OpenSSL . I just try to compile and run the program OpenSSL_aes. While compiling with gcc -Wall openssl_aes.c -lcrypto I got following error. I tried my best solve this problem , but unable to solve this compiler error. ``` 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); ^ ``` Edit : while I add `#include<openssl/aes.h>` as per @ martin, the compilation problem is solved. now, gcc -Wall openssl_aes.c -lcrypto is successfully compiled. But, when I try to run the program ( to run i used - ./a.out ), I got following error Segmentation fault (core dumped) Can anyone help me to solve this and run my program? I just want to perform simple aes encryption/decryption using OpenSSL. I am using GCC under Fedora 19 . Thanks in advance.