--_44929f64-4e3f-4243-9a4d-458bc4860eab_
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit


Hello,

I created a private key with password. But I can not read that key again. And the callback function "pass_cb" was not called at all.

FILE *privateKeyFilePW;
RSA *keyReading=NULL;

privateKeyFilePW =fopen("PrivatekeyPW.pem", "w");
PEM_write_RSAPrivateKey(privateKeyFilePW, r,EVP_des_ede3_cbc(),NULL, 0, NULL, NULL);
fclose(privateKeyFilePW);
keyReading=RSA_new();
privateKeyFilePW =fopen("PrivatekeyPW.pem", "r");
PEM_read_RSAPrivateKey(privateKeyFilePW, &keyReading, pass_cb, "My Private Key");
fclose(privateKeyFilePW);

The callback function.
int pass_cb(char *buf, int size, int rwflag, void *u)
{
int len;
char *tmp;
/* We'd probably do something else if 'rwflag' is 1 */
printf("Enter pass phrase for \"%s\"\n", u);

/* get pass phrase, length 'len' into 'tmp' */
tmp = "hello";
len = strlen(tmp);

if (len <= 0) return 0;
/* if too long, truncate */
if (len > size) len = size;
memcpy(buf, tmp, len);
return len;
}

__________________________________________________ _______________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q...n-US&form=QBRE
--_44929f64-4e3f-4243-9a4d-458bc4860eab_
Content-Type: text/html; charset="gb2312"
Content-Transfer-Encoding: 8bit






Hello,

I created a private key with password. But I can not read that key again. And the callback function "pass_cb" was not called at all.

FILE *privateKeyFilePW;
RSA *keyReading=NULL;

privateKeyFilePW =fopen("PrivatekeyPW.pem", "w");
PEM_write_RSAPrivateKey(privateKeyFilePW, r,EVP_des_ede3_cbc(),NULL, 0, NULL, NULL);
fclose(privateKeyFilePW);
keyReading=RSA_new();
privateKeyFilePW =fopen("PrivatekeyPW.pem", "r");
PEM_read_RSAPrivateKey(privateKeyFilePW, &keyReading, pass_cb, "My Private Key");
fclose(privateKeyFilePW);

The callback function.
int pass_cb(char *buf, int size, int rwflag, void *u)
{
        int len;
        char *tmp;
        /* We'd probably do something else if 'rwflag' is
1 */
        printf("Enter pass phrase for \"%s\"\n", u);

        /* get pass phrase, length 'len' into 'tmp' */
        tmp = "hello";
        len = strlen(tmp);

        if (len <= 0) return 0;
        /* if too long, truncate */
        if (len > size) len = size;
        memcpy(buf, tmp, len);
        return len;
 }


Explore the seven wonders of the world Learn more!

--_44929f64-4e3f-4243-9a4d-458bc4860eab_--
__________________________________________________ ____________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majordomo@openssl.org