Steve Lihn wrote:
>
> Anybody can help me with manipulating ASN1_OBJECT?
>
> 1) How do I create a new object identifier, say 1.10.20.30.40 ?
> 2) How do I set it into ASN1_OBJECT variable?
> 3) If i2d is performed and ASN1_OBJECT is read from a certificate, what is the
>internal structure?
> I want to be able to verify I am reading correct identifier?
>
There are two ways of doing this. You can create "one off" objects using
the OBJ_txt2obj() function or you can add them to the OpenSSL internal
table.
In this case you should use the internal table. When you do this you get
an identifier back called a NID. The nid is a number which can be
converted to and from the object.
Anyway to create the object you can use:
int my_nid = OBJ_create("1.2.3.4", "myShortName", "myLongName");
The "shortname" and "longname" are used when Objects are printed out.
The values don't matter too much in this case.
Anyway now you've got the nid you can do things with it. To create an
ASN1_OBJECT:
ASN1_OBJECT *obj = OBJ_nid2obj(my_nid);
You can also get the nid back from an ASN1_OBJECT:
int obj_nid = OBJ_obj2nid(obj);
By comparing the result you can check to see if the object is the same
as the new one you created.
Steve.
--
Dr Stephen N. Henson. http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED]
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]