Hi all,
I have a doubt regarding the conversion of public
key to DER form ....
Please take time to go through the following
code...
BIO *bio;
X509_REQ *req; /* The
X509_REQ from which we extract the public key */
unsigned char *data;
int length;
EVP_PKEY *ppubkey ;
...
......
ppubkey =
X509_REQ_get_pubkey(req);
bio =
BIO_new(BIO_s_mem());
/* write the public key to the bio
*/
i2d_PUBKEY_bio(bio,ppubkey);
/* retrieve the memory pointer of the bio
*/
length = BIO_get_mem_data(bio,
&data);
printf( "Length....%d\n", length);
When I do like this I get the length
as.... 94
When I use
int icnt;
EVP_PKEY ppubKey;
X509_REQ
*req;
/* Request from which we extract public key */
unsigned char pkeyBuff[500];
ppubkey =
X509_REQ_get_pubkey(req); /* Get the public key
*/icnt =
i2d_PUBKEY(ppubKey,&pkeyBuf);
printf("Length........%d\n",
icnt);
In this case I get the length
as 74.
I didnt understand the concept
of the BIO structure in the former case. Can any one explain me what makes
the length more in the former than the later case.....
Please help me to understand
better the concept....
Thanks in
advance...
Regards
Suram
|