----- Forwarded message from ÃÖ¿ë»ï <[EMAIL PROTECTED]> ----- From: "ÃÖ¿ë»ï" <[EMAIL PROTECTED]> Reply-To: "ÃÖ¿ë»ï" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: How can I get private key and public key separately? Date: Sun, 06 Jun 1999 17:11:11 KST Errors-To: <[EMAIL PROTECTED]> Hi, I'm a newbie to openssl. I want to get public key and private key separately in DER form. Below is my code to make this with reference to the exam.c in "demo" directory. ---------------------------------------------------------- #include <stdio.h> #include <string.h> #include <openssl/rsa.h> typedef struct { unsigned char der_pubkey[BUFSIZ*10]; int siz_pubkey; unsigned char der_privkey[BUFSIZ*10]; int siz_privkey; } DER_RSAKEY; void gen_rsaderkey(DER_RSAKEY *rk, int keysize) { RSA *rsa, *pub_rsa, *priv_rsa; unsigned char keybuf[BUFSIZ*10], *pbuf; int len; rsa = RSA_generate_key(keysize, RSA_F4, callback, (char *)stdout); pbuf = keybuf; len = i2d_RSAPublicKey(rsa, &pbuf); len += i2d_RSAPrivateKey(rsa, &pbuf); /* get separated rsa key pair */ pbuf = keybuf; pub_rsa = d2i_RSAPublicKey(NULL, &pbuf, (long) len); len -= pbuf - keybuf; priv_rsa = d2i_RSAPrivateKey(NULL, &pbuf, (long) len); /* get separated der key pair */ pbuf = rk->der_privkey; rk->siz_privkey = i2d_RSAPublicKey(priv_rsa, &pbuf); rk->siz_privkey += i2d_RSAPrivateKey(priv_rsa, &pbuf); pbuf = rk->der_pubkey; rk->siz_pubkey = i2d_RSAPublicKey(pub_rsa, &pbuf); rk->siz_pubkey += i2d_RSAPrivateKey(pub_rsa, &pbuf); //******// RSA_free(rsa); RSA_free(pub_rsa); RSA_free(priv_rsa); } ---------------------------------------------------- In the part // ****** I got segmentation fault and I suppose that it is because pub_rsa has no private key. Please help me with getting separated key pair. TIA, Foombar ================================================== Æò»ý ¾²´Â ¹«·á E-mail ÁÖ¼Ò ÇѸÞÀÏ³Ý http://www.hanmail.net ----- End forwarded message ----- ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]