On Fri, Jan 14, 2005, Przemek Michalski wrote: > Hi there, > > I am trying to play with large serial numbers, however I found that the > function > ASN1_INTEGER_get() applied with the following code: > > /*--------------*/ > ASN1_INTEGER_get(X509_get_serialNumber(cert)); > /*--------------*/ > > where 'cert' is the certificate resource, has limited capabilities, in terms > of returning > 'long' values. It simply returns '-1' value if the certificate serial number > is a very > large value, which clearly this function can not handle for some reason. > > Instead of having a 'long' value, I could use a hexadecimal value of the > serial number > represented/converted by/to a char string. > > Does anyone has a simple code for that. > > I have found that asn1.h has a declaration of a function: > i2a_ASN1_INTEGER() > > which outputs a hexadecimal representation of the serial number value to the > BIO variable. > I wish not to use a bio structure variable, but a simple char variable, that > I could use > in other parts of my application code. > > Any advise, sample codes, really appreciated. >
This is an openssl-users question not openssl-dev. The X509_get_serialNumber() function returns an ASN1_INTEGER type. You can use ASN1_STRING_{type,length,data) on that to get the internal data. This will be a big endian format where the type is V_ASN1_NEG_INTEGER if it is negative. Alternatively you can use ASN1_INTEGER_to_BN() to convert to a BIGNUM which you can then use the appropriate bn functions on. Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Funding needed! Details on homepage. Homepage: http://www.drh-consultancy.demon.co.uk ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]