xref: /openbsd-src/lib/libcrypto/engine/engine.h (revision 1e091ee9aec21ba88d79df6820558d531fa19405)
1*1e091ee9Stb /* $OpenBSD: engine.h,v 1.44 2024/03/02 10:22:07 tb Exp $ */
2c109e398Sbeck /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3c109e398Sbeck  * project 2000.
4c109e398Sbeck  */
5c109e398Sbeck /* ====================================================================
64fcf65c5Sdjm  * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.
7c109e398Sbeck  *
8c109e398Sbeck  * Redistribution and use in source and binary forms, with or without
9c109e398Sbeck  * modification, are permitted provided that the following conditions
10c109e398Sbeck  * are met:
11c109e398Sbeck  *
12c109e398Sbeck  * 1. Redistributions of source code must retain the above copyright
13c109e398Sbeck  *    notice, this list of conditions and the following disclaimer.
14c109e398Sbeck  *
15c109e398Sbeck  * 2. Redistributions in binary form must reproduce the above copyright
16c109e398Sbeck  *    notice, this list of conditions and the following disclaimer in
17c109e398Sbeck  *    the documentation and/or other materials provided with the
18c109e398Sbeck  *    distribution.
19c109e398Sbeck  *
20c109e398Sbeck  * 3. All advertising materials mentioning features or use of this
21c109e398Sbeck  *    software must display the following acknowledgment:
22c109e398Sbeck  *    "This product includes software developed by the OpenSSL Project
23c109e398Sbeck  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24c109e398Sbeck  *
25c109e398Sbeck  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26c109e398Sbeck  *    endorse or promote products derived from this software without
27c109e398Sbeck  *    prior written permission. For written permission, please contact
28c109e398Sbeck  *    licensing@OpenSSL.org.
29c109e398Sbeck  *
30c109e398Sbeck  * 5. Products derived from this software may not be called "OpenSSL"
31c109e398Sbeck  *    nor may "OpenSSL" appear in their names without prior written
32c109e398Sbeck  *    permission of the OpenSSL Project.
33c109e398Sbeck  *
34c109e398Sbeck  * 6. Redistributions of any form whatsoever must retain the following
35c109e398Sbeck  *    acknowledgment:
36c109e398Sbeck  *    "This product includes software developed by the OpenSSL Project
37c109e398Sbeck  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38c109e398Sbeck  *
39c109e398Sbeck  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40c109e398Sbeck  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41c109e398Sbeck  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42c109e398Sbeck  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43c109e398Sbeck  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44c109e398Sbeck  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45c109e398Sbeck  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46c109e398Sbeck  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47c109e398Sbeck  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48c109e398Sbeck  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49c109e398Sbeck  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50c109e398Sbeck  * OF THE POSSIBILITY OF SUCH DAMAGE.
51c109e398Sbeck  * ====================================================================
52c109e398Sbeck  *
53c109e398Sbeck  * This product includes cryptographic software written by Eric Young
54c109e398Sbeck  * (eay@cryptsoft.com).  This product includes software written by Tim
55c109e398Sbeck  * Hudson (tjh@cryptsoft.com).
56c109e398Sbeck  *
57c109e398Sbeck  */
584fcf65c5Sdjm /* ====================================================================
594fcf65c5Sdjm  * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
604fcf65c5Sdjm  * ECDH support in OpenSSL originally developed by
614fcf65c5Sdjm  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
624fcf65c5Sdjm  */
63c109e398Sbeck 
64c109e398Sbeck #ifndef HEADER_ENGINE_H
65c109e398Sbeck #define HEADER_ENGINE_H
66c109e398Sbeck 
67767fe2ffSmarkus #include <openssl/opensslconf.h>
68767fe2ffSmarkus 
697e2b557aStb #include <openssl/err.h>
70da347917Sbeck #include <openssl/ui.h>
714fcf65c5Sdjm 
724fcf65c5Sdjm #include <openssl/ossl_typ.h>
73c109e398Sbeck 
74c109e398Sbeck #ifdef  __cplusplus
75c109e398Sbeck extern "C" {
76c109e398Sbeck #endif
77c109e398Sbeck 
78c109e398Sbeck #define ENGINE_METHOD_RSA		(unsigned int)0x0001
79c109e398Sbeck #define ENGINE_METHOD_DSA		(unsigned int)0x0002
80c109e398Sbeck #define ENGINE_METHOD_DH		(unsigned int)0x0004
81c109e398Sbeck #define ENGINE_METHOD_RAND		(unsigned int)0x0008
82da347917Sbeck #define ENGINE_METHOD_CIPHERS		(unsigned int)0x0040
83da347917Sbeck #define ENGINE_METHOD_DIGESTS		(unsigned int)0x0080
844fcf65c5Sdjm #define ENGINE_METHOD_STORE		(unsigned int)0x0100
850a5d6edeSdjm #define ENGINE_METHOD_PKEY_METHS	(unsigned int)0x0200
860a5d6edeSdjm #define ENGINE_METHOD_PKEY_ASN1_METHS	(unsigned int)0x0400
8795bbafeeStb #define ENGINE_METHOD_EC		(unsigned int)0x0800
88c109e398Sbeck #define ENGINE_METHOD_ALL		(unsigned int)0xFFFF
89c109e398Sbeck #define ENGINE_METHOD_NONE		(unsigned int)0x0000
90c109e398Sbeck 
9154359922Stb /*
9254359922Stb  * Prototypes for the stub functions in engine_stubs.c. They are provided to
933e3c85d5Stb  * build M2Crypto, Dovecot, apr-utils without patching.
9454359922Stb  */
9554359922Stb void ENGINE_load_builtin_engines(void);
9654359922Stb void ENGINE_load_dynamic(void);
9754359922Stb void ENGINE_load_openssl(void);
9854359922Stb int ENGINE_register_all_complete(void);
9954359922Stb 
10054359922Stb void ENGINE_cleanup(void);
10154359922Stb 
10224656ea8Stb ENGINE *ENGINE_new(void);
10354359922Stb int ENGINE_free(ENGINE *engine);
10454359922Stb int ENGINE_init(ENGINE *engine);
10554359922Stb int ENGINE_finish(ENGINE *engine);
10654359922Stb 
10754359922Stb ENGINE *ENGINE_by_id(const char *id);
10854359922Stb const char *ENGINE_get_id(const ENGINE *engine);
10954359922Stb const char *ENGINE_get_name(const ENGINE *engine);
11054359922Stb 
11154359922Stb int ENGINE_set_default(ENGINE *engine, unsigned int flags);
11254359922Stb 
11354359922Stb ENGINE *ENGINE_get_default_RSA(void);
11454359922Stb int ENGINE_set_default_RSA(ENGINE *engine);
11554359922Stb 
1163e3c85d5Stb int ENGINE_ctrl_cmd(ENGINE *engine, const char *cmd_name, long i, void *p,
11754359922Stb     void (*f)(void), int cmd_optional);
11854359922Stb int ENGINE_ctrl_cmd_string(ENGINE *engine, const char *cmd, const char *arg,
11954359922Stb     int cmd_optional);
12054359922Stb 
12154359922Stb EVP_PKEY *ENGINE_load_private_key(ENGINE *engine, const char *key_id,
12254359922Stb     UI_METHOD *ui_method, void *callback_data);
12354359922Stb EVP_PKEY *ENGINE_load_public_key(ENGINE *engine, const char *key_id,
12454359922Stb     UI_METHOD *ui_method, void *callback_data);
125c109e398Sbeck 
126c109e398Sbeck /* Error codes for the ENGINE functions. */
127c109e398Sbeck 
128c109e398Sbeck /* Function codes. */
129da347917Sbeck #define ENGINE_F_DYNAMIC_CTRL				 180
130da347917Sbeck #define ENGINE_F_DYNAMIC_GET_DATA_CTX			 181
131da347917Sbeck #define ENGINE_F_DYNAMIC_LOAD				 182
1324fcf65c5Sdjm #define ENGINE_F_DYNAMIC_SET_DATA_CTX			 183
133c109e398Sbeck #define ENGINE_F_ENGINE_ADD				 105
134c109e398Sbeck #define ENGINE_F_ENGINE_BY_ID				 106
135da347917Sbeck #define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE		 170
136c109e398Sbeck #define ENGINE_F_ENGINE_CTRL				 142
137da347917Sbeck #define ENGINE_F_ENGINE_CTRL_CMD			 178
138da347917Sbeck #define ENGINE_F_ENGINE_CTRL_CMD_STRING			 171
139c109e398Sbeck #define ENGINE_F_ENGINE_FINISH				 107
1404fcf65c5Sdjm #define ENGINE_F_ENGINE_FREE_UTIL			 108
141da347917Sbeck #define ENGINE_F_ENGINE_GET_CIPHER			 185
142da347917Sbeck #define ENGINE_F_ENGINE_GET_DEFAULT_TYPE		 177
143da347917Sbeck #define ENGINE_F_ENGINE_GET_DIGEST			 186
144c109e398Sbeck #define ENGINE_F_ENGINE_GET_NEXT			 115
1450a5d6edeSdjm #define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH		 193
1460a5d6edeSdjm #define ENGINE_F_ENGINE_GET_PKEY_METH			 192
147c109e398Sbeck #define ENGINE_F_ENGINE_GET_PREV			 116
148c109e398Sbeck #define ENGINE_F_ENGINE_INIT				 119
149c109e398Sbeck #define ENGINE_F_ENGINE_LIST_ADD			 120
150c109e398Sbeck #define ENGINE_F_ENGINE_LIST_REMOVE			 121
151c109e398Sbeck #define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY		 150
152c109e398Sbeck #define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY			 151
1530a5d6edeSdjm #define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT		 194
154c109e398Sbeck #define ENGINE_F_ENGINE_NEW				 122
155c109e398Sbeck #define ENGINE_F_ENGINE_REMOVE				 123
156da347917Sbeck #define ENGINE_F_ENGINE_SET_DEFAULT_STRING		 189
157c109e398Sbeck #define ENGINE_F_ENGINE_SET_DEFAULT_TYPE		 126
158c109e398Sbeck #define ENGINE_F_ENGINE_SET_ID				 129
159c109e398Sbeck #define ENGINE_F_ENGINE_SET_NAME			 130
160da347917Sbeck #define ENGINE_F_ENGINE_TABLE_REGISTER			 184
161c109e398Sbeck #define ENGINE_F_ENGINE_UNLOAD_KEY			 152
1624fcf65c5Sdjm #define ENGINE_F_ENGINE_UNLOCKED_FINISH			 191
163767fe2ffSmarkus #define ENGINE_F_ENGINE_UP_REF				 190
164da347917Sbeck #define ENGINE_F_INT_CTRL_HELPER			 172
165da347917Sbeck #define ENGINE_F_INT_ENGINE_CONFIGURE			 188
1664fcf65c5Sdjm #define ENGINE_F_INT_ENGINE_MODULE_INIT			 187
167c109e398Sbeck #define ENGINE_F_LOG_MESSAGE				 141
168c109e398Sbeck 
169c109e398Sbeck /* Reason codes. */
170c109e398Sbeck #define ENGINE_R_ALREADY_LOADED				 100
171da347917Sbeck #define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER		 133
172da347917Sbeck #define ENGINE_R_CMD_NOT_EXECUTABLE			 134
173da347917Sbeck #define ENGINE_R_COMMAND_TAKES_INPUT			 135
174da347917Sbeck #define ENGINE_R_COMMAND_TAKES_NO_INPUT			 136
175c109e398Sbeck #define ENGINE_R_CONFLICTING_ENGINE_ID			 103
176c109e398Sbeck #define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED		 119
177da347917Sbeck #define ENGINE_R_DH_NOT_IMPLEMENTED			 139
178da347917Sbeck #define ENGINE_R_DSA_NOT_IMPLEMENTED			 140
179c109e398Sbeck #define ENGINE_R_DSO_FAILURE				 104
180da347917Sbeck #define ENGINE_R_DSO_NOT_FOUND				 132
181da347917Sbeck #define ENGINE_R_ENGINES_SECTION_ERROR			 148
1820a5d6edeSdjm #define ENGINE_R_ENGINE_CONFIGURATION_ERROR		 102
183c109e398Sbeck #define ENGINE_R_ENGINE_IS_NOT_IN_LIST			 105
184da347917Sbeck #define ENGINE_R_ENGINE_SECTION_ERROR			 149
185c109e398Sbeck #define ENGINE_R_FAILED_LOADING_PRIVATE_KEY		 128
186c109e398Sbeck #define ENGINE_R_FAILED_LOADING_PUBLIC_KEY		 129
187c109e398Sbeck #define ENGINE_R_FINISH_FAILED				 106
188c109e398Sbeck #define ENGINE_R_GET_HANDLE_FAILED			 107
189c109e398Sbeck #define ENGINE_R_ID_OR_NAME_MISSING			 108
190c109e398Sbeck #define ENGINE_R_INIT_FAILED				 109
191c109e398Sbeck #define ENGINE_R_INTERNAL_LIST_ERROR			 110
192da347917Sbeck #define ENGINE_R_INVALID_ARGUMENT			 143
193da347917Sbeck #define ENGINE_R_INVALID_CMD_NAME			 137
194da347917Sbeck #define ENGINE_R_INVALID_CMD_NUMBER			 138
195da347917Sbeck #define ENGINE_R_INVALID_INIT_VALUE			 151
196da347917Sbeck #define ENGINE_R_INVALID_STRING				 150
197c109e398Sbeck #define ENGINE_R_NOT_INITIALISED			 117
198c109e398Sbeck #define ENGINE_R_NOT_LOADED				 112
199c109e398Sbeck #define ENGINE_R_NO_CONTROL_FUNCTION			 120
200da347917Sbeck #define ENGINE_R_NO_INDEX				 144
201c109e398Sbeck #define ENGINE_R_NO_LOAD_FUNCTION			 125
202c109e398Sbeck #define ENGINE_R_NO_REFERENCE				 130
203c109e398Sbeck #define ENGINE_R_NO_SUCH_ENGINE				 116
204c109e398Sbeck #define ENGINE_R_NO_UNLOAD_FUNCTION			 126
205c109e398Sbeck #define ENGINE_R_PROVIDE_PARAMETERS			 113
206da347917Sbeck #define ENGINE_R_RSA_NOT_IMPLEMENTED			 141
207da347917Sbeck #define ENGINE_R_UNIMPLEMENTED_CIPHER			 146
208da347917Sbeck #define ENGINE_R_UNIMPLEMENTED_DIGEST			 147
2090a5d6edeSdjm #define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD	 101
210da347917Sbeck #define ENGINE_R_VERSION_INCOMPATIBILITY		 145
211c109e398Sbeck 
212c109e398Sbeck #ifdef  __cplusplus
213c109e398Sbeck }
214c109e398Sbeck #endif
215c109e398Sbeck #endif
216