You must save original pointer because i2c and i2d function move pointer in
order to prepare it for subsequent calls.

ASN1_INTEGER * serial;
unsigned char * serialNumberDER,*temp;

 size = i2c_ASN1_INTEGER(serial, NULL);
temp=serialNumberDER = new unsigned char[*size];
size = i2c_ASN1_INTEGER(serial, &temp);

serialNumberDER contains required value

francesco petruzzi

----- Original Message ----- 
From: "Andrzej Posiadala" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 11, 2004 1:57 PM
Subject: How to convert internal ASN1_INTEGER into little endian content
octets


> Hi ,
>
> i'm trying to convert ASN1_INTEGER (specifically certificate serial
> number) into its DER representation.
> I'm using i2c_ASN1_INTEGER - and if it's the right function - then I don't
> understand why it moves a pointer passed to it as second parameter behind
> reserved memory.
> Here is what I'm doing:
>
> int size;
> ASN1_INTEGER * serial;
> unsigned char * serialNumberDER;
>
> size = i2c_ASN1_INTEGER(serial, NULL);
> serialNumberDER = new unsigned char[*size];
> size = i2c_ASN1_INTEGER(serial, & serialNumberDER);
>
> The function has this code at the end:
>
> *pp+=ret;
>
> where pp is a pointer to serialNumberDER, so in effect it moves
> serialNumberDER behind created array of unsigned char.
>
> Please, explain it to me.
> Thanks in advance.
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    [EMAIL PROTECTED]
> Automated List Manager                           [EMAIL PROTECTED]

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to