Hi,
I am implementing a linux application about smime, it requires loading
private-key for decryption. I rewrite the load_key function just the
same as OpenSSL. But It returns a NULL pointer.
By debugging, I found that an error may occurs when adding ciphers to
the hash table. The EVP_CIPHER object seems wrong. So I wrote the
following codes for testing.
test.cxx :
#include <openssl/evp.h>
int main()
{
const EVP_CIPHER* c = EVP_des_ede3_cbc();
return 0;
}
then: g++ -g -lssl test.cxx
and gdb says:
(gdb) p *c
$1 = {nid = 44, block_size = 8, key_len = 24, iv_len = 8, flags = 1026,
init = 0xa1a378 <EVP_des_ede3_cfb8+126>,
do_cipher = 0xa1a021 <EVP_bf_ecb+303>, cleanup = 0, ctx_size = 384,
set_asn1_parameters = 0xa1e8c5 <EVP_CIPHER_set_asn1_iv>,
get_asn1_parameters = 0xa1e82a <EVP_CIPHER_get_asn1_iv>, ctrl = 0,
app_data = 0x0}
but when debug:
openssl smime -decrypt -in my.enc -out my.dec -inkey ca.key -recip ca.crt
it says:
$1 = {nid = 44, block_size = 8, key_len = 24, iv_len = 8, flags = 514,
init = 0x80e2d10 <des_ede3_init_key>,
do_cipher = 0x80e2a90 <des_ede_cbc_cipher>, cleanup = 0, ctx_size = 384,
set_asn1_parameters = 0x80e6920 <EVP_CIPHER_set_asn1_iv>,
get_asn1_parameters = 0x80e68b0 <EVP_CIPHER_get_asn1_iv>,
ctrl = 0x80e2d60 <des3_ctrl>, app_data = 0x0}
I DON'T know why they are different. With the former one in my program,
the decryption of private key will failed, so load_key returns NULL.
Is there anyone can help me? Thanks a lot!!