Hi,

        Here is the snippet of my code which generates RSA key pair and then 
saves the public and private keys in character buffer. However the output shows 
the public key and private keys are of different sizes.. I was under the 
impression that pub and priv keys are of same sizes.. is my understanding wrong 
or some problem with my code ?
        
Here is the code snippet..

/**************************************************************/

#define NUM_BITS 1024
#define RSA_F4  0x10001

RSA *rsa;
unsigned char ki_pub[1024]; /* Public Key generated by lamboot */
unsigned char ki_pri[1024]; /* corresponding Private Key generated by lamboot */
unsigned char *p;
int ki_pub_len; /* length of public key */
int ki_pri_len; /* length of private key */



/* Set up the initial RSA key pair ki */
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);

/********************************************************************/


The output generated is:
Length of public key is 140
Length of private key is 609


Is this output correct ?? am I missing something ?


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]

Reply via email to