1OBJ_nid2obj(3) OpenSSL OBJ_nid2obj(3)
2
3
4
6 OBJ_nid2obj, OBJ_nid2ln, OBJ_nid2sn, OBJ_obj2nid, OBJ_txt2nid,
7 OBJ_ln2nid, OBJ_sn2nid, OBJ_cmp, OBJ_dup, OBJ_txt2obj, OBJ_obj2txt,
8 OBJ_create, OBJ_cleanup - ASN1 object utility functions
9
11 #include <openssl/objects.h>
12
13 ASN1_OBJECT * OBJ_nid2obj(int n);
14 const char * OBJ_nid2ln(int n);
15 const char * OBJ_nid2sn(int n);
16
17 int OBJ_obj2nid(const ASN1_OBJECT *o);
18 int OBJ_ln2nid(const char *ln);
19 int OBJ_sn2nid(const char *sn);
20
21 int OBJ_txt2nid(const char *s);
22
23 ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name);
24 int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name);
25
26 int OBJ_cmp(const ASN1_OBJECT *a,const ASN1_OBJECT *b);
27 ASN1_OBJECT * OBJ_dup(const ASN1_OBJECT *o);
28
29 int OBJ_create(const char *oid,const char *sn,const char *ln);
30 void OBJ_cleanup(void);
31
33 The ASN1 object utility functions process ASN1_OBJECT structures which
34 are a representation of the ASN1 OBJECT IDENTIFIER (OID) type.
35
36 OBJ_nid2obj(), OBJ_nid2ln() and OBJ_nid2sn() convert the NID n to an
37 ASN1_OBJECT structure, its long name and its short name respectively,
38 or NULL is an error occurred.
39
40 OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() return the corresponding NID
41 for the object o, the long name <ln> or the short name <sn>
42 respectively or NID_undef if an error occurred.
43
44 OBJ_txt2nid() returns NID corresponding to text string <s>. s can be a
45 long name, a short name or the numerical respresentation of an object.
46
47 OBJ_txt2obj() converts the text string s into an ASN1_OBJECT structure.
48 If no_name is 0 then long names and short names will be interpreted as
49 well as numerical forms. If no_name is 1 only the numerical form is
50 acceptable.
51
52 OBJ_obj2txt() converts the ASN1_OBJECT a into a textual representation.
53 The representation is written as a null terminated string to buf at
54 most buf_len bytes are written, truncating the result if necessary.
55 The total amount of space required is returned. If no_name is 0 then if
56 the object has a long or short name then that will be used, otherwise
57 the numerical form will be used. If no_name is 1 then the numerical
58 form will always be used.
59
60 OBJ_cmp() compares a to b. If the two are identical 0 is returned.
61
62 OBJ_dup() returns a copy of o.
63
64 OBJ_create() adds a new object to the internal table. oid is the
65 numerical form of the object, sn the short name and ln the long name. A
66 new NID is returned for the created object.
67
68 OBJ_cleanup() cleans up OpenSSLs internal object table: this should be
69 called before an application exits if any new objects were added using
70 OBJ_create().
71
73 Objects in OpenSSL can have a short name, a long name and a numerical
74 identifier (NID) associated with them. A standard set of objects is
75 represented in an internal table. The appropriate values are defined in
76 the header file objects.h.
77
78 For example the OID for commonName has the following definitions:
79
80 #define SN_commonName "CN"
81 #define LN_commonName "commonName"
82 #define NID_commonName 13
83
84 New objects can be added by calling OBJ_create().
85
86 Table objects have certain advantages over other objects: for example
87 their NIDs can be used in a C language switch statement. They are also
88 static constant structures which are shared: that is there is only a
89 single constant structure for each table object.
90
91 Objects which are not in the table have the NID value NID_undef.
92
93 Objects do not need to be in the internal tables to be processed, the
94 functions OBJ_txt2obj() and OBJ_obj2txt() can process the numerical
95 form of an OID.
96
98 Create an object for commonName:
99
100 ASN1_OBJECT *o;
101 o = OBJ_nid2obj(NID_commonName);
102
103 Check if an object is commonName
104
105 if (OBJ_obj2nid(obj) == NID_commonName)
106 /* Do something */
107
108 Create a new NID and initialize an object from it:
109
110 int new_nid;
111 ASN1_OBJECT *obj;
112 new_nid = OBJ_create("1.2.3.4", "NewOID", "New Object Identifier");
113
114 obj = OBJ_nid2obj(new_nid);
115
116 Create a new object directly:
117
118 obj = OBJ_txt2obj("1.2.3.4", 1);
119
121 OBJ_obj2txt() is awkward and messy to use: it doesn't follow the
122 convention of other OpenSSL functions where the buffer can be set to
123 NULL to determine the amount of data that should be written. Instead
124 buf must point to a valid buffer and buf_len should be set to a
125 positive value. A buffer length of 80 should be more than enough to
126 handle any OID encountered in practice.
127
129 OBJ_nid2obj() returns an ASN1_OBJECT structure or NULL is an error
130 occurred.
131
132 OBJ_nid2ln() and OBJ_nid2sn() returns a valid string or NULL on error.
133
134 OBJ_obj2nid(), OBJ_ln2nid(), OBJ_sn2nid() and OBJ_txt2nid() return a
135 NID or NID_undef on error.
136
138 ERR_get_error(3)
139
141 TBA
142
143
144
1451.0.1e 2013-02-11 OBJ_nid2obj(3)