summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/EVP_PKEY_add1_attr.3
blob: ae910b167a01862029021b94b626097039b35a0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
.\" $OpenBSD: EVP_PKEY_add1_attr.3,v 1.3 2021/10/26 18:50:38 jmc Exp $
.\"
.\" Copyright (c) 2021 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: October 26 2021 $
.Dt EVP_PKEY_ADD1_ATTR 3
.Os
.Sh NAME
.Nm EVP_PKEY_add1_attr ,
.Nm EVP_PKEY_add1_attr_by_OBJ ,
.Nm EVP_PKEY_add1_attr_by_NID ,
.Nm EVP_PKEY_add1_attr_by_txt ,
.Nm EVP_PKEY_delete_attr ,
.Nm EVP_PKEY_get_attr ,
.Nm EVP_PKEY_get_attr_count ,
.Nm EVP_PKEY_get_attr_by_OBJ ,
.Nm EVP_PKEY_get_attr_by_NID
.Nd X.501 Attributes of private keys
.Sh SYNOPSIS
.In openssl/x509.h
.Ft int
.Fo EVP_PKEY_add1_attr
.Fa "EVP_PKEY *key"
.Fa "X509_ATTRIBUTE *attr"
.Fc
.Ft int
.Fo EVP_PKEY_add1_attr_by_OBJ
.Fa "EVP_PKEY *key"
.Fa "const ASN1_OBJECT *obj"
.Fa "int type"
.Fa "const unsigned char *data"
.Fa "int len"
.Fc
.Ft int
.Fo EVP_PKEY_add1_attr_by_NID
.Fa "EVP_PKEY *key"
.Fa "int nid"
.Fa "int type"
.Fa "const unsigned char *data"
.Fa "int len"
.Fc
.Ft int
.Fo EVP_PKEY_add1_attr_by_txt
.Fa "EVP_PKEY *key"
.Fa "const char *name"
.Fa "int type"
.Fa "const unsigned char *data"
.Fa "int len"
.Fc
.Ft X509_ATTRIBUTE *
.Fo EVP_PKEY_delete_attr
.Fa "EVP_PKEY *key"
.Fa "int index"
.Fc
.Ft X509_ATTRIBUTE *
.Fo EVP_PKEY_get_attr
.Fa "const EVP_PKEY *key"
.Fa "int index"
.Fc
.Ft int
.Fo EVP_PKEY_get_attr_count
.Fa "const EVP_PKEY *key"
.Fc
.Ft int
.Fo EVP_PKEY_get_attr_by_OBJ
.Fa "const EVP_PKEY *key"
.Fa "const ASN1_OBJECT *obj"
.Fa "int start_after"
.Fc
.Ft int
.Fo EVP_PKEY_get_attr_by_NID
.Fa "const EVP_PKEY *key"
.Fa "int nid"
.Fa "int start_after"
.Fc
.Sh DESCRIPTION
These functions support associating an array of X.501 Attributes
with a private key.
Such attributes can for example be included in PKCS#12 structures.
.Pp
.Fn EVP_PKEY_add1_attr
appends a deep copy of the
.Fa attr
using
.Xr X509at_add1_attr 3 .
.Pp
.Fn EVP_PKEY_add1_attr_by_OBJ ,
.Fn EVP_PKEY_add1_attr_by_NID ,
and
.Fn EVP_PKEY_add1_attr_by_txt
create a new X.501 Attribute object using
.Xr X509_ATTRIBUTE_create_by_OBJ 3 ,
.Xr X509_ATTRIBUTE_create_by_NID 3 ,
or
.Xr X509_ATTRIBUTE_create_by_txt 3 ,
respectively, and append it using
.Xr X509at_add1_attr 3 .
.Pp
.Fn EVP_PKEY_delete_attr
deletes the attribute with the zero-based
.Fa index
using
.Xr X509at_delete_attr 3 .
.Pp
.Fn EVP_PKEY_get_attr
returns the attribute with the zero-based
.Fa index
using
.Xr X509at_get_attr 3 .
.Pp
.Fn EVP_PKEY_get_attr_count
returns the number of attributes currently associated with the
.Fa key
using
.Xr X509at_get_attr_count 3 .
.Pp
.Fn EVP_PKEY_get_attr_by_OBJ
and
.Fn EVP_PKEY_get_attr_by_NID
search for an attribute of the type
.Fa obj
or
.Fa nid
using
.Xr X509at_get_attr_by_OBJ 3
or
.Xr X509at_get_attr_by_NID 3 ,
respectively.
.Sh RETURN VALUES
.Fn EVP_PKEY_add1_attr ,
.Fn EVP_PKEY_add1_attr_by_OBJ ,
.Fn EVP_PKEY_add1_attr_by_NID ,
and
.Fn EVP_PKEY_add1_attr_by_txt
return 1 for success or 0 for failure.
.Pp
.Fn EVP_PKEY_delete_attr
and
.Fn EVP_PKEY_get_attr
return the deleted or requested attribute or
.Dv NULL
if the requested index is negative or greater than or equal to
the current number of attributes associated with the
.Fa key .
.Pp
.Fn EVP_PKEY_get_attr_count
returns the current number of attributes.
.Pp
.Fn EVP_PKEY_get_attr_by_OBJ
and
.Fn EVP_PKEY_get_attr_by_NID
return the index of the first attribute that has an index greater than
.Fa start_after
and a type matching
.Fa obj
or
.Fa nid ,
respectively, or \-1 on failure.
In addition,
.Fn EVP_PKEY_get_attr_by_NID
returns \-2 if
.Xr OBJ_nid2obj 3
fails on the requested
.Fa nid .
.Sh SEE ALSO
.Xr EVP_PKEY_new 3 ,
.Xr OBJ_nid2obj 3 ,
.Xr PKCS12_create 3 ,
.Xr X509_ATTRIBUTE_create_by_OBJ 3 ,
.Xr X509_ATTRIBUTE_new 3 ,
.Xr X509at_add1_attr 3 ,
.Xr X509at_get_attr 3
.Sh HISTORY
These functions first appeared in OpenSSL 0.9.8
and have been available since
.Ox 4.5 .