70 lines
2.2 KiB
Plaintext
70 lines
2.2 KiB
Plaintext
The Object library.
|
|
|
|
As part of my Crypto library, I found I required a method of identifying various
|
|
objects. These objects normally had 3 different values associated with
|
|
them, a short text name, a long (or lower case) text name, and an
|
|
ASN.1 Object Identifier (which is a sequence of numbers).
|
|
This library contains a static list of objects and functions to lookup
|
|
according to one type and to return the other types.
|
|
|
|
To use these routines, 'Object.h' needs to be included.
|
|
|
|
For each supported object, #define entries are defined as follows
|
|
#define SN_Algorithm "Algorithm"
|
|
#define LN_algorithm "algorithm"
|
|
#define NID_algorithm 38
|
|
#define OBJ_algorithm 1L,3L,14L,3L,2L
|
|
|
|
SN_ stands for short name.
|
|
LN_ stands for either long name or lowercase name.
|
|
NID_ stands for Numeric ID. I each object has a unique NID and this
|
|
should be used internally to identify objects.
|
|
OBJ_ stands for ASN.1 Object Identifier or ASN1_OBJECT as defined in the
|
|
ASN1 routines. These values are used in ASN1 encoding.
|
|
|
|
The following functions are to be used to return pointers into a static
|
|
definition of these types. What this means is "don't try to free() any
|
|
pointers returned from these functions.
|
|
|
|
ASN1_OBJECT *OBJ_nid2obj(
|
|
int n);
|
|
Return the ASN1_OBJECT that corresponds to a NID of n.
|
|
|
|
char *OBJ_nid2ln(
|
|
int n);
|
|
Return the long/lower case name of the object represented by the
|
|
NID of n.
|
|
|
|
char *OBJ_nid2sn(
|
|
int n);
|
|
Return the short name for the object represented by the NID of n.
|
|
|
|
ASN1_OBJECT *OBJ_dup(
|
|
ASN1_OBJECT *o);
|
|
Duplicate and return a new ASN1_OBJECT that is the same as the
|
|
passed parameter.
|
|
|
|
int OBJ_obj2nid(
|
|
ASN1_OBJECT *o);
|
|
Given ASN1_OBJECT o, return the NID that corresponds.
|
|
|
|
int OBJ_ln2nid(
|
|
char *s);
|
|
Given the long/lower case name 's', return the NID of the object.
|
|
|
|
int OBJ_sn2nid(
|
|
char *s);
|
|
Given the short name 's', return the NID of the object.
|
|
|
|
char *OBJ_bsearch(
|
|
char *key,
|
|
char *base,
|
|
int num,
|
|
int size,
|
|
int (*cmp)());
|
|
Since I have come across a few platforms that do not have the
|
|
bsearch() function, OBJ_bsearch is my version of that function.
|
|
Feel free to use this function, but you may as well just use the
|
|
normal system bsearch(3) if it is present. This version also
|
|
has tolerance of being passed NULL pointers.
|