On Wed, Mar 29, 2006, Nagy Zoltn Mrk wrote: > Dear all > > I would like to create a data structure in C. > Below you can see what I have created, but it doesn't work correctly. > My question is: why doesn't initialised EVP_aes_128_cbc() into cipher? > > #define ORANGE 0xffa500 > > struct ciphers_name > { > unsigned char *name; > unsigned char *description; > const EVP_CIPHER *cipher; > unsigned int color; > }; > > > struct ciphers_name ciphers[] = > { > { "aes128cbc","AES 128bit CBC",EVP_aes_128_cbc(),ORANGE} > }; >
That wont work in many cases because you are trying to initialize the structure with the return value from a function. The initialization is done at compile time but that return value is only available at runtime. You have a couple of options. One is to change that definition to a function pointer which you set to EVP_aes_128_cbc note *NOT* EVP_aes_128_cbc(). Then at runtime you call that function pointer to get the EVP_CIPHER. The alternative is to include something which you can lookup to get that cipher. An example would be NID_aes_128_cbc which you can then lookup using EVP_getcipherbynid(). Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Funding needed! Details on homepage. Homepage: http://www.drh-consultancy.demon.co.uk ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]