#include <openssl/evp.h>
#include <openssl/rand.h>
void
Generate_Random_Val( unsigned char* val, int size )
{
RAND_bytes( val, size );
}
int
seed_prng( int bytes )
{
if( !(RAND_load_file( "/dev/random", bytes) ) )
{
return 0;
}
return 1;
}
int
main()
{
if( !(seed_prng( 1024 ) )
{
return 1;
}
unsigned char key[MAX_EVP_KEY_LENGTH]
Generate_Random_Val( key, MAX_EVP_KEY_LENGTH);
unsigned char iv[MAX_EVP_IV_LENGTH];
Generate_Random_Val(iv, MAX_EVP_IV_LENGTH];
EVP_CIPHER_CTX ctx;
EVP_EncryptInit( &ctx, EVP_aes_256_cbc(), key, iv );
return 0;
}
To build this I'm using the following:
cc -g -L/usr/local/ssl/lib -lssl -lcrypto -I/usr/local/ssl/include -I//usr/include functions.cpp
Ther error I get is
Undefined symbol first referenced in file
EVP_aes_128_cbc functions.o
ld:fatal: Symbol referencing errors. No output written to a.out
Thanks,
Melinda
Main Topics
Browse All Topics





by: jleviePosted on 2005-07-11 at 19:26:49ID: 14418108
My guess would be that you aren't linking against the right libs.
It would be a help if you'd posted a complete example, meaning a simple (complete) example and the steps you are using to compile and link the example.