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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
.\" $OpenBSD: ENGINE_add.3,v 1.3 2018/04/18 03:39:22 schwarze Exp $
.\" content checked up to: OpenSSL 1f13ad31 Dec 25 17:50:39 2017 +0800
.\"
.\" Copyright (c) 2018 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: April 18 2018 $
.Dt ENGINE_ADD 3
.Os
.Sh NAME
.Nm ENGINE_add ,
.Nm ENGINE_set_id ,
.Nm ENGINE_get_id ,
.Nm ENGINE_set_name ,
.Nm ENGINE_get_name ,
.Nm ENGINE_remove ,
.Nm ENGINE_cleanup ,
.Nm ENGINE_get_first ,
.Nm ENGINE_get_last ,
.Nm ENGINE_get_next ,
.Nm ENGINE_get_prev ,
.Nm ENGINE_by_id
.Nd maintain a global list of ENGINE objects
.Sh SYNOPSIS
.In openssl/engine.h
.Ft int
.Fo ENGINE_add
.Fa "ENGINE *e"
.Fc
.Ft int
.Fo ENGINE_set_id
.Fa "ENGINE *e"
.Fa "const char *id"
.Fc
.Ft const char *
.Fo ENGINE_get_id
.Fa "const ENGINE *e"
.Fc
.Ft int
.Fo ENGINE_set_name
.Fa "ENGINE *e"
.Fa "const char *name"
.Fc
.Ft const char *
.Fo ENGINE_get_name
.Fa "const ENGINE *e"
.Fc
.Ft int
.Fo ENGINE_remove
.Fa "ENGINE *e"
.Fc
.Ft void
.Fn ENGINE_cleanup void
.Ft ENGINE *
.Fn ENGINE_get_first void
.Ft ENGINE *
.Fn ENGINE_get_last void
.Ft ENGINE *
.Fo ENGINE_get_next
.Fa "ENGINE *e"
.Fc
.Ft ENGINE *
.Fo ENGINE_get_prev
.Fa "ENGINE *e"
.Fc
.Ft ENGINE *
.Fo ENGINE_by_id
.Fa "const char *id"
.Fc
.Sh DESCRIPTION
The crypto library maintains a global list of
.Vt ENGINE
objects.
.Pp
.Fn ENGINE_add
appends
.Fa e
to the end of the list
and increments its structural reference count by 1.
A unique identifier and a name of
.Fa e
have to be set with
.Fn ENGINE_set_id
and
.Fn ENGINE_set_name
before calling this function.
.Fn ENGINE_add
fails if the list already contains an
.Vt ENGINE
with the same identifier.
.Pp
.Fn ENGINE_remove
removes
.Fa e
from the list.
If successful, it calls
.Xr ENGINE_free 3
on
.Fa e .
.Pp
.Fn ENGINE_cleanup
calls
.Xr ENGINE_finish 3
on all
.Vt ENGINE
objects that were selected as default engines, for example using the
functions documented in the
.Xr ENGINE_set_default 3
and
.Xr ENGINE_get_default_RSA 3
manual pages, and it calls
.Fn ENGINE_remove
on all
.Vt ENGINE
objects that were added to the global list with
.Fn ENGINE_add .
Calling this function is required at the end of each program using
.Fn ENGINE_add ,
even if no engines are explicitly registered or used.
.Pp
.Fn ENGINE_get_first
and
.Fn ENGINE_get_last
provide access to the first and last
.Vt ENGINE
object on the list, respectively.
Unless the list is empty, they increment the structural reference
count of the retrieved object by 1.
.Pp
.Fn ENGINE_get_next
and
.Fn ENGINE_get_prev
support iteration of the list.
They always call
.Xr ENGINE_free 3
on
.Fa e .
Unless the end of the list is reached, they increment the structural
reference count of the retrieved object by 1.
.Pp
.Fn ENGINE_by_id
searches the list for an
.Vt ENGINE
object with a matching
.Fa id .
If found, it increments the structural reference count of the
retrieved object by 1.
If
.Dv ENGINE_FLAGS_BY_ID_COPY
was set on
.Fa e
with
.Xr ENGINE_set_flags 3 ,
it returns a shallow copy of the object rather than incrementing
the reference count and returning a pointer to the original.
.Sh RETURN VALUES
.Fn ENGINE_add ,
.Fn ENGINE_set_id ,
.Fn ENGINE_set_name ,
and
.Fn ENGINE_remove
return 1 on success or 0 on error.
.Fn ENGINE_set_id
and
.Fn ENGINE_set_name
can only fail if the supplied
.Fa id
or
.Fa name
is
.Dv NULL .
.Pp
.Fn ENGINE_get_id
and
.Fn ENGINE_get_name
return a pointer to an internal string
representing the identifier and the name of
.Fa e ,
respectively.
.Pp
.Fn ENGINE_get_first
and
.Fn ENGINE_get_last
return an
.Vt ENGINE
object or
.Dv NULL
if the list is empty.
.Pp
.Fn ENGINE_get_next
and
.Fn ENGINE_get_prev
return an
.Vt ENGINE
object or
.Dv NULL
when the end of the list is reached.
.Pp
.Fn ENGINE_by_id
returns an
.Vt ENGINE
object or
.Dv NULL
if no matching object is found.
.Sh SEE ALSO
.Xr ENGINE_get_default_RSA 3 ,
.Xr ENGINE_init 3 ,
.Xr ENGINE_new 3 ,
.Xr ENGINE_register_all_RSA 3 ,
.Xr ENGINE_register_RSA 3 ,
.Xr ENGINE_set_default 3 ,
.Xr ENGINE_set_flags 3 ,
.Xr ENGINE_unregister_RSA 3
.Sh HISTORY
.Fn ENGINE_add ,
.Fn ENGINE_set_id ,
.Fn ENGINE_get_id ,
.Fn ENGINE_set_name ,
.Fn ENGINE_get_name ,
.Fn ENGINE_remove ,
.Fn ENGINE_get_first ,
.Fn ENGINE_get_last ,
.Fn ENGINE_get_next ,
.Fn ENGINE_get_prev ,
and
.Fn ENGINE_by_id
first appeared in OpenSSL 0.9.7 and have been available since
.Ox 2.9 .
.Pp
.Fn ENGINE_cleanup
first appeared in OpenSSL 0.9.7 and has been available since
.Ox 3.2 .
|