>Hi,
>
>I have requested a certificate with the private key encrypted option set
>to yes. Now I have the encrypted private key and a password. How can I
>get the private key decrypted from a program ?
>
>Thanx in advance,
>Zoli
Hi!
I hope, this function is what you need.
int xxx();
{
char *heslo /* password */
char *klic; /* file with private key */
EVP_PKEY *sklic_vlastni; /*result - private key in EVP_PKEY structure */
BIO *in;
in = BIO_new(BIO_s_file());
if (BIO_read_filename(in, klic) <= 0)
{
BIO_free(in);
return 0;
}
if (heslo == NULL)
sklic_vlastni = PEM_read_bio_PrivateKey(in, NULL, NULL);
else
{
sklic_vlastni = PEM_read_bio_PrivateKey(in, NULL, key_callback);
memset(heslo, 0, strlen(heslo));
}
return 1;
}
int MS_CALLBACK key_callback(char *buf,int len,int verify)
{
int i;
if (heslo == NULL)
return(0);
i=strlen(heslo);
i=(i > len) ? len : i;
memcpy(buf, heslo, i);
return(i);
}
Bye.
-------
Pavel Konicar
e-mail: [EMAIL PROTECTED]
www: http://www.ica.cz
smime.p7s