.\" $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 .\" .\" 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 .