Hello Michel,

Thanks for the link.
I have the following code.
int main()
{

RSA *key;
    unsigned char input_ptext[] =
"58FD6F1C310FC9D0194FB8B0E99070A6CBA3473BFE69F953E60E99070A6CBA3473BFE69F953E0E99070A6CBA3473BFE69F953E0E99070A6CBAE";
    unsigned char ctext[256];
    unsigned char ptext[256];
    int n,i;

 ERR_clear_error();
 key = RSA_generate_key(1024,65537,NULL,NULL);
printf("the size of input_text is %ld\n", sizeof(input_ptext));

 if (!key)
        return 0;
    n = RSA_size(key);

 n = RSA_public_encrypt(sizeof(input_ptext) -
1,input_ptext,ctext,key,RSA_PKCS1_PADDING);
 if (n < 0)
        return 0;

n = RSA_private_decrypt(n,ctext,ptext,key,RSA_PKCS1_PADDING);
if (n < 0)
        return 0;
    RSA_free(key);
printf("the decrypted text is %s\n",ptext);

    if (memcmp(input_ptext,ptext,sizeof(input_ptext) - 1))
        return 0;
printf("Finished\n");
printf("the decrypted text is %s\n",ptext);


  return 1;
 }


But the problem is, I have to encrypt it at clients side and decrypt it at
servers side. In the above program  I generated the key at clients side.
But How do I transport the public key to the other party for it to generate
the private key? If I send the key using TCP/IP channel, that makes the
system vulnerable, which is not desirable. So how do I transport the keys
between client and the server.


Thanks and Regards,
Yamini.


On Tue, Jun 18, 2013 at 1:43 AM, Michel <msa...@paybox.com> wrote:

> Hi Yamini,
>
> I would suggest looking at the 'EVP Envelope' API :
> https://www.openssl.org/docs/**crypto/EVP_SealInit.html<https://www.openssl.org/docs/crypto/EVP_SealInit.html>
>
>
> Le 17/06/2013 19:26, yamini a écrit :
>
>> Hello,
>>
>> I am implementing the DES algorithm between my client and server systems
>> for
>> encryption. The DES key is transmitted in encrypted form between Client
>> and
>> Server using RSA encryption and decryption.
>> My idea of implementing the above task is creating RSA key
>> (RSA_generate_key) and using the public key for encryption and private key
>> for decryption. I have looked for sample codes to do this in C language
>> but
>> found nothing. So if anyone has any code snippets for this task please
>> post
>> them here. It would be very helpful.
>> The code for RSA encryption and Decryption between client and
>> server(client
>> and server are on different machines).
>>
>>
>> Thanks and Regards,
>> Yamini.
>>
>
>

Reply via email to