xref: /openbsd-src/lib/libcrypto/man/X509_NAME_ENTRY_get_object.3 (revision ae3cb403620ab940fbaabb3055fac045a63d56b7)
1.\"	$OpenBSD: X509_NAME_ENTRY_get_object.3,v 1.6 2016/12/25 22:15:10 schwarze Exp $
2.\"	OpenSSL aebb9aac Jul 19 09:27:53 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
22.\" Copyright (c) 2002, 2005, 2006 The OpenSSL Project.  All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\"    notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\"    notice, this list of conditions and the following disclaimer in
33.\"    the documentation and/or other materials provided with the
34.\"    distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\"    software must display the following acknowledgment:
38.\"    "This product includes software developed by the OpenSSL Project
39.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\"    endorse or promote products derived from this software without
43.\"    prior written permission. For written permission, please contact
44.\"    openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\"    nor may "OpenSSL" appear in their names without prior written
48.\"    permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\"    acknowledgment:
52.\"    "This product includes software developed by the OpenSSL Project
53.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: December 25 2016 $
69.Dt X509_NAME_ENTRY_GET_OBJECT 3
70.Os
71.Sh NAME
72.Nm X509_NAME_ENTRY_new ,
73.Nm X509_NAME_ENTRY_free ,
74.Nm X509_NAME_ENTRY_get_object ,
75.Nm X509_NAME_ENTRY_get_data ,
76.Nm X509_NAME_ENTRY_set_object ,
77.Nm X509_NAME_ENTRY_set_data ,
78.Nm X509_NAME_ENTRY_create_by_txt ,
79.Nm X509_NAME_ENTRY_create_by_NID ,
80.Nm X509_NAME_ENTRY_create_by_OBJ
81.\" In the following line, "X.501" is not a typo.
82.\" This object defined in X.501, not in X.509.
83.Nd X.501 relative distinguished name
84.Sh SYNOPSIS
85.In openssl/x509.h
86.Ft X509_NAME_ENTRY *
87.Fn X509_NAME_ENTRY_new void
88.Ft void
89.Fo X509_NAME_ENTRY_free
90.Fa "X509_NAME_ENTRY* ne"
91.Fc
92.Ft ASN1_OBJECT *
93.Fo X509_NAME_ENTRY_get_object
94.Fa "X509_NAME_ENTRY *ne"
95.Fc
96.Ft ASN1_STRING *
97.Fo X509_NAME_ENTRY_get_data
98.Fa "X509_NAME_ENTRY *ne"
99.Fc
100.Ft int
101.Fo X509_NAME_ENTRY_set_object
102.Fa "X509_NAME_ENTRY *ne"
103.Fa "ASN1_OBJECT *obj"
104.Fc
105.Ft int
106.Fo X509_NAME_ENTRY_set_data
107.Fa "X509_NAME_ENTRY *ne"
108.Fa "int type"
109.Fa "const unsigned char *bytes"
110.Fa "int len"
111.Fc
112.Ft X509_NAME_ENTRY *
113.Fo X509_NAME_ENTRY_create_by_txt
114.Fa "X509_NAME_ENTRY **ne"
115.Fa "const char *field"
116.Fa "int type"
117.Fa "const unsigned char *bytes"
118.Fa "int len"
119.Fc
120.Ft X509_NAME_ENTRY *
121.Fo X509_NAME_ENTRY_create_by_NID
122.Fa "X509_NAME_ENTRY **ne"
123.Fa "int nid"
124.Fa "int type"
125.Fa "unsigned char *bytes"
126.Fa "int len"
127.Fc
128.Ft X509_NAME_ENTRY *
129.Fo X509_NAME_ENTRY_create_by_OBJ
130.Fa "X509_NAME_ENTRY **ne"
131.Fa "ASN1_OBJECT *obj"
132.Fa "int type"
133.Fa "const unsigned char *bytes"
134.Fa "int len"
135.Fc
136.Sh DESCRIPTION
137An X.501
138.Vt RelativeDistinguishedName
139is a set of field type and value pairs.
140It is the building block for constructing X.501
141.Vt Name
142objects.
143This implementation only supports sets with one element, so an
144.Vt X509_NAME_ENTRY
145object contains only one field type and one value.
146.Pp
147.Fn X509_NAME_ENTRY_new
148allocates and initializes an empty
149.Vt X509_NAME_ENTRY
150object, representing an ASN.1
151.Vt RelativeDistinguishedName
152structure defined in RFC 5280 section 4.1.2.4.
153.Pp
154.Fn X509_NAME_ENTRY_free
155frees
156.Fa ne
157and the type and value contained in it.
158.Pp
159.Fn X509_NAME_ENTRY_get_object
160retrieves the field type of
161.Fa ne
162in an
163.Vt ASN1_OBJECT
164structure.
165.Fn X509_NAME_ENTRY_get_data
166retrieves the field value of
167.Fa ne
168in an
169.Vt ASN1_STRING
170structure.
171These two functions can be used to examine an
172.Vt X509_NAME_ENTRY
173object as returned by
174.Xr X509_NAME_get_entry 3 .
175.Pp
176.Fn X509_NAME_ENTRY_set_object
177sets the field type of
178.Fa ne
179to
180.Fa obj .
181.Pp
182.Fn X509_NAME_ENTRY_set_data
183sets the field value of
184.Fa ne
185to string type
186.Fa type
187and the value determined by
188.Fa bytes
189and
190.Fa len .
191.Pp
192.Fn X509_NAME_ENTRY_create_by_txt ,
193.Fn X509_NAME_ENTRY_create_by_NID ,
194and
195.Fn X509_NAME_ENTRY_create_by_OBJ
196create and return an
197.Vt X509_NAME_ENTRY
198structure.
199.Pp
200Except for
201.Fn X509_NAME_ENTRY_get_object
202and
203.Fn X509_NAME_ENTRY_get_data ,
204these functions are rarely used because
205.Vt X509_NAME_ENTRY
206structures are almost always part of
207.Vt X509_NAME
208structures and the functions described in
209.Xr X509_NAME_add_entry_by_txt 3
210are typically used to create and add new entries in a single operation.
211.Pp
212The arguments of these functions support similar options to the
213similarly named ones described in
214.Xr X509_NAME_add_entry_by_txt 3 .
215So for example
216.Fa type
217can be set to
218.Dv MBSTRING_ASC ,
219but in the case of
220.Fn X509_NAME_ENTRY_set_data
221the field type must be set first so the relevant field information
222can be looked up internally.
223.Sh SEE ALSO
224.Xr ERR_get_error 3 ,
225.Xr OBJ_nid2obj 3 ,
226.Xr X509_NAME_add_entry 3 ,
227.Xr X509_NAME_get_entry 3 ,
228.Xr X509_NAME_new 3
229.Sh STANDARDS
230RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
231Certificate Revocation List (CRL) Profile
232.Pp
233ITU-T Recommendation X.501, also known as ISO/IEC 9594-2: Information
234Technology  Open Systems Interconnection  The Directory: Models,
235section 9.3: Relative distinguished name
236