Hi,
In my c code I am sending the rsa public key from A (which generated the
RSA key pair) to B. B now tries to encrypt a message with the public key
received from A and send the encryted message to A and A decrypts it with the
private key of the RSA key pair it generated.
Now the problem is that I cannot encrypt the message at B with the
received public key (it gives seg fault).
Is it possible to do what I have mentioned ? can you tell me where am I
going wrong ?
Here is the snippet of my code...
-----------------
"A"
-----------------
if ((rsa=RSA_generate_key(NUM_BITS,RSA_F4,NULL,NULL))==NULL) {
perror("RSA key generation failed");
}
/* Save the public and private keys into the char array */
p = ki_pub;
ki_pub_len = i2d_RSAPublicKey(rsa,&p);
printf("Length of public key is %d\n",ki_pub_len);
p = ki_pri;
ki_pri_len = i2d_RSAPrivateKey(rsa,&p);
printf("Length of private key is %d\n",ki_pri_len);
/* Find out the length that can be encoded by RSA */
rsa_msg_len = RSA_size(rsa);
printf("Max encoding length is %d\n",rsa_msg_len);
/* send ki_pub_len to B */
...
/* send ki_pub to B */
...
/* send rsa_msg_len to B */
...
---------------
"B"
---------------
/* receive ki_pub_len */
...
/* receive ki_pub */
...
/* put the ki_pub into pub_rsa */
p = ki_pub;
pub_rsa = d2i_RSAPublicKey(NULL, &p, (long)ki_pub_len);
/* receive rsa_msg_len */
...
/* Encrypt message */
encrypt_len = RSA_public_encrypt(msg_len, unencrypted_mesg,
encrypted_mesg, pub_rsa,
RSA_PKCS1_OAEP_PADDING);
RSA_public_encrypt() segfaults at B.
help appreciated,
thanks,
Manish
------------------------------------------------------
Manish Chablani ([EMAIL PROTECTED]),
Graduate Student,
Computer Science Department,
Indiana University
------------------------------------------------------
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]