On 01/06/2014 10:34 PM, Alan Cabrera wrote:
I should have obtained the DER form using i2d_RSA_PUBKEY(). Also,
passing &buf to the method should have warned me that the pointer was
being modified. I have no idea why it gets modified and what it points
to after the call.
So now I do
|der_form= throw_away= (unsigned char *) malloc(len);
i2d_RSAPublicKey(public_key, &throw_away);|
and use the contents of der_form.
Regards,
Alan
This is standard behaviour with any i2d_* function. The second pointer
is increased to the end of the written data.
Read, for instance, the WARNINGS section here:
http://www.openssl.org/docs/crypto/d2i_X509.html
For what I recall, this is done because you often want to append more
ASN.1 data at the end of the current data, so you need to keep track of
where you are.