61 #ifndef OPENSSL_NO_RSA
70 #ifndef OPENSSL_NO_RC4
110 int (*
cb)(
char *buf,
int len, const
char *prompt,
115 int (*
cb)(
char *buf,
int len, const
char *prompt,
122 int (*
cb)(
char *buf,
int len,
const char *prompt,
int verify),
126 int rsalen, pkeylen, olen;
129 unsigned char buf[256],*zz;
134 if (a == NULL)
return(0);
136 if ((pkey=NETSCAPE_PKEY_new()) == NULL)
goto err;
137 if ((enckey=NETSCAPE_ENCRYPTED_PKEY_new()) == NULL)
goto err;
144 rsalen = i2d_RSAPrivateKey(a, NULL);
152 pkeylen=i2d_NETSCAPE_PKEY(pkey,NULL);
164 olen = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, NULL);
165 NETSCAPE_PKEY_free(pkey);
166 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
180 i2d_RSAPrivateKey(a,&zz);
194 i2d_NETSCAPE_PKEY(pkey,&zz);
201 i=
cb((
char *)buf,256,
"Enter Private Key password:",1);
207 i = strlen((
char *)buf);
212 memcpy(buf + 16,
"SGCKEYSALT", 10);
229 ret = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, pp);
232 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
233 NETSCAPE_PKEY_free(pkey);
239 int (*
cb)(
char *buf,
int len,
const char *prompt,
246 int (*
cb)(
char *buf,
int len,
const char *prompt,
int verify),
250 const unsigned char *
p;
255 enckey = d2i_NETSCAPE_ENCRYPTED_PKEY(NULL, &p, length);
261 if ((enckey->
os->
length != 11) || (strncmp(
"private-key",
262 (
char *)enckey->
os->
data,11) != 0))
265 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
275 if ((ret=d2i_RSA_NET_2(a, enckey->
enckey->
digest,
cb, sgckey)) == NULL)
goto err;
280 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
286 int (*
cb)(
char *buf,
int len,
const char *prompt,
287 int verify),
int sgckey)
292 unsigned char buf[256];
293 const unsigned char *zz;
298 i=
cb((
char *)buf,256,
"Enter Private Key password:",0);
305 i = strlen((
char *)buf);
309 memcpy(buf + 16,
"SGCKEYSALT", 10);
327 if ((pkey=d2i_NETSCAPE_PKEY(NULL,&zz,os->
length)) == NULL)
341 NETSCAPE_PKEY_free(pkey);
350 static void *dummy=&dummy;