For the first:
- generate the RSA key
- pull n,e,d bignums out of the RSA structure
- use bn2bin to get the key parts

For the second:
- use bin2bn on n,e,d
- assign the bignums to the RSA structure

I can point you to sample code if you like.

On 3/25/2013 10:32 AM, rod_proteus wrote:
Hello.

  I need to Get and Set public and private keys to encrypt and decrypt using
RSA algorithm.
In both cases I need to handle the info in binary format , something like
this:

  For example:
   int KeyLen = 256;
   unsigned char Modulus[32];
   unsigned char Exponent[32];
   unsigned char Private[32];

   memset((void *)Modulus, 0x00, sizeof(Modulus));
   memset((void *)Exponent, 0x00, sizeof(Exponent));
   memset((void *)Private, 0x00, sizeof(Private));


   RSA *pstRSA = NULL

   Call the function o process to get Modulus, Exponent and Private info.

   Save the info (Modulus, Exponent and Private) to a file.

   return.


   In another application:

   Load Modulus, Exponent and Private from file.

   Set up the (Modulus, Exponent and Private) into RSA structure.

   Then encrypt and decrypt data.

   return.


   The info (Modulus, Exponent and Private) must be no encypted (without
phrase protection or so).





______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to