int OBJ_new_nid(num)
int num;
int OBJ_create(oid, sn, ln)
char *oid;
char *sn;
char *ln;
int OBJ_add_object(obj)
ASN1_OBJECT *obj;
int OBJ_create_objects(in)
BIO *in;
ASN1_OBJECT *OBJ_dup(o)
ASN1_OBJECT *o;
ASN1_OBJECT *OBJ_nid2obj(n)
int n;
char *OBJ_nid2ln(n)
int n;
char *OBJ_nid2sn(n)
int n;
int OBJ_obj2nid(o)
ASN1_OBJECT *o;
int OBJ_txt2nid(s)
char *s;
int OBJ_ln2nid(s)
char *s;
int OBJ_sn2nid(s)
char *s;
int OBJ_cmp(a, b)
ASN1_OBJECT *a;
ASN1_OBJECT *b;
char *OBJ_bsearch(key, base, num, size, cmp)
char *key;
char *base;
int num;
int size;
int (*cmp)();
void OBJ_cleanup();
void ERR_load_OBJ_strings();
typedef struct asn1_object_st
{
char *sn; /* short name */
char *ln; /* long name (or lowercase name, depending) */
int nid; /* unique but meaningless number for this object */
int length; /* length of data field in bytes */
unsigned char *data; /* actual value */
int flags; /* Should we free this one */
} ASN1_OBJECT;
The data field contains the OID (Object Identifier) associated with the particular object; for more on OIDs see Oject Identifiers for various ASN.1 Objects.
An example of values for such an object is:
#define SN_Algorithm "Algorithm" #define LN_algorithm "algorithm" #define NID_algorithm 38 #define OBJ_algorithm 1L,3L,14L,3L,2L
and the full list of all SNs and LNs is in ASN1 Object names and nids.
All of the objects are defined in a static list in object_dat.h, which
static ASN1_OBJECT nid_objs[NUM_NID]={
{"UNDEF","undefined",NID_undef,0,NULL},
{"rsadsi","rsadsi",NID_rsadsi,6,&(lvalues[0]),0},
{"pkcs","pkcs",NID_pkcs,7,&(lvalues[6]),0},
...
(most lines omitted, but you get the idea)
...
{"RC5-CFB","rc5-cfb",NID_rc5_cfb64,0,NULL},
{"RC5-OFB","rc5-ofb",NID_rc5_ofb64,0,NULL},
};
Pointers to members of these lists are also available in three other static lists, sn_objs, ordered by sn, ln_objs, ordered by ln, and obj_objs, ordered by object identifier.
Most of the following functions return pointers into these static lists; do *not* try to free anything you get back from these functions.
OBJ_new_nid uses the static new_nid which keeps track of the next numeric identifier available (not already used by the library). It returns the current value and increments the static variable by num. Ordinarily you will call this function with an argument of 1.
OBJ_create creates a new ASN1_OBJECT with the given oid, sn, and ln, and calls OBJ_new_nid to get a new nid to use for the object. It then calls OBJ_add_object to add the object to a separate static list for new objects not predefined by the library. This list is an linked list with search by hash functionality (see hash table routines for more on this).
Any of the arguments to this function can be NULL. The function returns the nid of the new object or 0 on error.
OBJ_add_object(obj) adds obj to a separate static list of new objects not predefined by the library. It is generally not invoked directly; use OBJ_create instead.
The following macro is provided as a convenience to the user:
#define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c)
which reminds you what OBJ_create really does.
OBJ_create_objects reads from the BIO in and creates a pile of objects by calling OBJ_create. The format of the data read in is:
oid in number and dot form (1.2.840. ...) whitespace short name (with no spaces) whitespace long name (with no spaces)
You can omit the long name. or both the long name and short name, from any entry. The function returns the number of new objects added.
This function is called by apps/asn1parse.c
OBJ_dup creates a new ASN1_OBJECT, copies the fields from o into it, and returns a pointer to it, or NULL on error.
OBJ_nid2obj returns the ASN1_OBJECT that corresponds to a NID of n, or 0 on error.
OBJ_nid2ln returns the long/lower case name of the object represented by the NID of n, or "undefined" on error.
OBJ_nid2sn returns the short name for the object represented by the NID of n, or "UNDEF" on error.
OBJ_obj2nid returns the NID that corresponds to the object o or NID_undef on error.
OBJ_txt2nid returns the NID that corresponds to s, which can be either the short name or the long/lowercase name. It returns NID_undef on error.
OBJ_ln2nid returns the NID that corresponds to the long/lowercase name s, or NID_undef on error.
OBJ_sn2nid returns the NID that corresponds to the short name s, or NID_undef on error.
OBJ_cmp returns an integer less than, equal to, or greater than zero depending on whether the length and value of the data in a is less than, equal to, or greater than the length and value of the data in b. The lengths are checked first and if those match the the values are compared.
OBJ_bsearch is a replacement for the normal bsearch(3) function which is not implemented on some platforms. It is called by the various OBJ_***2nid functions. It functions identically to the normal bsearch(3), returning a pointer to the desired object, or NULL if no match is found.
OBJ_cleanup should be used any time you are exiting an application (or set of subroutines) that used OBJ_add or OBJ_create; it clears out the static list of objects you created and sets the list to NULL.
ERR_load_OBJ_strings initializes arrays for the error-handling library with messages specific to the OBJ library. Call this before using any OBJ routines in your code.