I wrote the following simple code to read a private key that's inside a
PKCS12 object:

FILE * fp ;
PKCS12* p12=NULL;
EVP_PKEY *prkey=NULL;
        
if ( (fp = fopen ( p12file, "rb" )) == NULL ) {
        return 0
}
        
d2i_PKCS12_fp(fp, &p12);

if (!PKCS12_parse(p12, pass, &prkey, NULL,NULL)) {
        return 0;
}

...

the PKCS12_parse always fail reporting
PKCS12_F_PKCS12_PARSE,PKCS12_R_MAC_VERIFY_FAILURE.

Stepping inside it I've seen that PKCS12_verify_mac fails reporting
PKCS12_F_VERIFY_MAC,PKCS12_R_MAC_GENERATION_ERROR,

Stepping inside PKCS12_verify_mac I've seen that PKCS12_gen_mac fails
reporting PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_UNKNOWN_DIGEST_ALGORITHM.

Finally, stepping inside PKCS12_gen_mac I've seen that (md_type =
EVP_get_digestbyobj) fails reporting
PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_UNKNOWN_DIGEST_ALGORITHM.

What is happening?

I've tried with different p12 and pfx keys and the result was always the
same.
Note that I've been able to load and use these keys by means of others
toolkits and libraries.

Thanks in advance


--------------------------------------------------------------------------
Marco Donati
Context Security -  Software
P.zza Liberazione, 25 - 20013 Magenta (MI)
Phone: ++39-02-97291291,         Fax: ++39-02-97298225
E-Mail: [EMAIL PROTECTED],   Web site:http://www.csg.it
--------------------------------------------------------------------------


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to