Hi Dr Henson and openssl users list.
I'm very thankful by your answers.
This time I'm having problems with the d2i_PKCS8PrivateKey_bio function. This always returns me 0 , and really I don't know what's wrong.
My code:
RSA *rsa;
EVP_PKEY *dec_key, **x=NULL;
EVP_PKEY *dec_key, **x=NULL;
BIO *in=NULL;
char *password = "am01key";
char *priv_key_der = "llaveAMp5.key";/*PBE privkey file */
char *priv_key_der = "llaveAMp5.key";/*PBE privkey file */
int i,size_llave=0;
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
ERR_load_crypto_strings();
in=BIO_new(BIO_s_file());
if (in==NULL) /*not problem */
{
/* Error code*/
if (in==NULL) /*not problem */
{
/* Error code*/
}
if (BIO_read_filename(in,priv_key_der) <= 0) /*not problem*/
{
/*Error Code*/
if (BIO_read_filename(in,priv_key_der) <= 0) /*not problem*/
{
/*Error Code*/
}
/*dec_key=EVP_PKEY_new(); comment this because I thought could be the problem*/
dec_key=d2i_PKCS8PrivateKey_bio(in, x, NULL,password);
if (dec_key=NULL) /*also not problem*/
{
/*Error code */
dec_key=d2i_PKCS8PrivateKey_bio(in, x, NULL,password);
if (dec_key=NULL) /*also not problem*/
{
/*Error code */
}
size_llave=EVP_PKEY_size(dec_key); /*result of this function is always 0 */
printf("%d\n", size_llave); /*prints zero 0 */
rsa=RSA_new();
rsa=EVP_PKEY_get1_RSA(dec_key); /*this function breaks because dec_key is 0 size bytes, right ? */
rsa=EVP_PKEY_get1_RSA(dec_key); /*this function breaks because dec_key is 0 size bytes, right ? */
With all my test keys the results are the same (privkeyp5.key, privkeyp8.key, privkey_der.key). Is there some type of bug ? Or this is caused by my C code??
I'm a little desperate.....
Thanks again in advance
Zainos
Do You Yahoo!?
Yahoo! Net: La mejor conexión a internet y 25MB extra a tu correo por $100 al mes.