1 /* $OpenBSD: engine.h,v 1.33 2019/01/19 01:07:00 tb Exp $ */
2 /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3  * project 2000.
4  */
5 /* ====================================================================
6  * Copyright (c) 1999-2004 The OpenSSL Project.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in
17  *    the documentation and/or other materials provided with the
18  *    distribution.
19  *
20  * 3. All advertising materials mentioning features or use of this
21  *    software must display the following acknowledgment:
22  *    "This product includes software developed by the OpenSSL Project
23  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24  *
25  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26  *    endorse or promote products derived from this software without
27  *    prior written permission. For written permission, please contact
28  *    licensing@OpenSSL.org.
29  *
30  * 5. Products derived from this software may not be called "OpenSSL"
31  *    nor may "OpenSSL" appear in their names without prior written
32  *    permission of the OpenSSL Project.
33  *
34  * 6. Redistributions of any form whatsoever must retain the following
35  *    acknowledgment:
36  *    "This product includes software developed by the OpenSSL Project
37  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50  * OF THE POSSIBILITY OF SUCH DAMAGE.
51  * ====================================================================
52  *
53  * This product includes cryptographic software written by Eric Young
54  * (eay@cryptsoft.com).  This product includes software written by Tim
55  * Hudson (tjh@cryptsoft.com).
56  *
57  */
58 /* ====================================================================
59  * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
60  * ECDH support in OpenSSL originally developed by
61  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
62  */
63 module libressl_d.openssl.engine;
64 
65 
66 private static import core.stdc.config;
67 private static import libressl_d.openssl.crypto;
68 public import libressl_d.openssl.ec;
69 public import libressl_d.openssl.err;
70 public import libressl_d.openssl.opensslconf;
71 public import libressl_d.openssl.ossl_typ;
72 public import libressl_d.openssl.x509;
73 
74 version (OPENSSL_NO_ENGINE) {
75 	static assert(false, "ENGINE is disabled.");
76 }
77 
78 version (OPENSSL_NO_DEPRECATED) {
79 } else {
80 	public import libressl_d.openssl.bn;
81 
82 	version (OPENSSL_NO_RSA) {
83 	} else {
84 		public import libressl_d.openssl.rsa;
85 	}
86 
87 	version (OPENSSL_NO_DSA) {
88 	} else {
89 		public import libressl_d.openssl.dsa;
90 	}
91 
92 	version (OPENSSL_NO_DH) {
93 	} else {
94 		public import libressl_d.openssl.dh;
95 	}
96 
97 	version (OPENSSL_NO_ECDH) {
98 	} else {
99 		public import libressl_d.openssl.ecdh;
100 	}
101 
102 	version (OPENSSL_NO_ECDSA) {
103 	} else {
104 		public import libressl_d.openssl.ecdsa;
105 	}
106 
107 	version (OPENSSL_NO_EC) {
108 	} else {
109 		public import libressl_d.openssl.ec;
110 	}
111 
112 	public import libressl_d.openssl.err;
113 	public import libressl_d.openssl.ui;
114 }
115 
116 extern (C):
117 nothrow @nogc:
118 
119 /*
120  * These flags are used to control combinations of algorithm (methods)
121  * by bitwise "OR"ing.
122  */
123 enum uint ENGINE_METHOD_RSA = 0x0001;
124 enum uint ENGINE_METHOD_DSA = 0x0002;
125 enum uint ENGINE_METHOD_DH = 0x0004;
126 enum uint ENGINE_METHOD_RAND = 0x0008;
127 enum uint ENGINE_METHOD_ECDH = 0x0010;
128 enum uint ENGINE_METHOD_ECDSA = 0x0020;
129 enum uint ENGINE_METHOD_CIPHERS = 0x0040;
130 enum uint ENGINE_METHOD_DIGESTS = 0x0080;
131 enum uint ENGINE_METHOD_STORE = 0x0100;
132 enum uint ENGINE_METHOD_PKEY_METHS = 0x0200;
133 enum uint ENGINE_METHOD_PKEY_ASN1_METHS = 0x0400;
134 enum uint ENGINE_METHOD_EC = 0x0800;
135 /* Obvious all-or-nothing cases. */
136 enum uint ENGINE_METHOD_ALL = 0xFFFF;
137 enum uint ENGINE_METHOD_NONE = 0x0000;
138 
139 /**
140  * This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used
141  * internally to control registration of ENGINE implementations, and can be set
142  * by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to
143  * initialise registered ENGINEs if they are not already initialised.
144  */
145 enum uint ENGINE_TABLE_FLAG_NOINIT = 0x0001;
146 
147 /* ENGINE flags that can be set by ENGINE_set_flags(). */
148 /* enum ENGINE_FLAGS_MALLOCED = 0x0001; */ /* Not used */
149 
150 /**
151  * This flag is for ENGINEs that wish to handle the various 'CMD'-related
152  * control commands on their own. Without this flag, ENGINE_ctrl() handles these
153  * control commands on behalf of the ENGINE using their "cmd_defns" data.
154  */
155 enum int ENGINE_FLAGS_MANUAL_CMD_CTRL = 0x0002;
156 
157 /**
158  * This flag is for ENGINEs who return new duplicate structures when found via
159  * "ENGINE_by_id()". When an ENGINE must store state (eg. if ENGINE_ctrl()
160  * commands are called in sequence as part of some stateful process like
161  * key-generation setup and execution), it can set this flag - then each attempt
162  * to obtain the ENGINE will result in it being copied into a new structure.
163  * Normally, ENGINEs don't declare this flag so ENGINE_by_id() just increments
164  * the existing ENGINE's structural reference count.
165  */
166 enum int ENGINE_FLAGS_BY_ID_COPY = 0x0004;
167 
168 /**
169  * This flag if for an ENGINE that does not want its methods registered as
170  * part of ENGINE_register_all_complete() for example if the methods are
171  * not usable as default methods.
172  */
173 enum int ENGINE_FLAGS_NO_REGISTER_ALL = 0x0008;
174 
175 /*
176  * ENGINEs can support their own command types, and these flags are used in
177  * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input each
178  * command expects. Currently only numeric and string input is supported. If a
179  * control command supports none of the _NUMERIC, _STRING, or _NO_INPUT options,
180  * then it is regarded as an "internal" control command - and not for use in
181  * config setting situations. As such, they're not available to the
182  * ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() access. Changes to
183  * this list of 'command types' should be reflected carefully in
184  * ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string().
185  */
186 
187 /**
188  * accepts a 'core.stdc.config.c_long' input value (3rd parameter to ENGINE_ctrl)
189  */
190 enum uint ENGINE_CMD_FLAG_NUMERIC = 0x0001;
191 
192 /**
193  * accepts string input (cast from 'void*' to 'const (char)* ', 4th parameter to
194  * ENGINE_ctrl)
195  */
196 enum uint ENGINE_CMD_FLAG_STRING = 0x0002;
197 
198 /**
199  * Indicates that the control command takes *no* input. Ie. the control command
200  * is unparameterised.
201  */
202 enum uint ENGINE_CMD_FLAG_NO_INPUT = 0x0004;
203 
204 /**
205  * Indicates that the control command is internal. This control command won't
206  * be shown in any output, and is only usable through the ENGINE_ctrl_cmd()
207  * function.
208  */
209 enum uint ENGINE_CMD_FLAG_INTERNAL = 0x0008;
210 
211 /*
212  * NB: These 3 control commands are deprecated and should not be used. ENGINEs
213  * relying on these commands should compile conditional support for
214  * compatibility (eg. if these symbols are defined) but should also migrate the
215  * same functionality to their own ENGINE-specific control functions that can be
216  * "discovered" by calling applications. The fact these control commands
217  * wouldn't be "executable" (ie. usable by text-based config) doesn't change the
218  * fact that application code can find and use them without requiring per-ENGINE
219  * hacking.
220  */
221 
222 /*
223  * These flags are used to tell the ctrl function what should be done.
224  * All command numbers are shared between all engines, even if some don't
225  * make sense to some engines.  In such a case, they do nothing but return
226  * the error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED.
227  */
228 enum ENGINE_CTRL_SET_LOGSTREAM = 1;
229 enum ENGINE_CTRL_SET_PASSWORD_CALLBACK = 2;
230 
231 /**
232  * Close and reinitialise any
233  * handles/connections etc.
234  */
235 enum ENGINE_CTRL_HUP = 3;
236 
237 /**
238  * Alternative to callback
239  */
240 enum ENGINE_CTRL_SET_USER_INTERFACE = 4;
241 
242 /**
243  * User-specific data, used
244  * when calling the password
245  * callback and the user
246  * interface
247  */
248 enum ENGINE_CTRL_SET_CALLBACK_DATA = 5;
249 
250 /**
251  * Load a configuration, given
252  * a string that represents a
253  * file name or so
254  */
255 enum ENGINE_CTRL_LOAD_CONFIGURATION = 6;
256 
257 /**
258  * Load data from a given
259  * section in the already loaded
260  * configuration
261  */
262 enum ENGINE_CTRL_LOAD_SECTION = 7;
263 
264 /*
265  * These control commands allow an application to deal with an arbitrary engine
266  * in a dynamic way. Warn: Negative return values indicate errors FOR THESE
267  * COMMANDS because zero is used to indicate 'end-of-list'. Other commands,
268  * including ENGINE-specific command types, return zero for an error.
269  *
270  * An ENGINE can choose to implement these ctrl functions, and can internally
271  * manage things however it chooses - it does so by setting the
272  * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise the
273  * ENGINE_ctrl() code handles this on the ENGINE's behalf using the cmd_defns
274  * data (set using ENGINE_set_cmd_defns()). This means an ENGINE's ctrl()
275  * handler need only implement its own commands - the above "meta" commands will
276  * be taken care of.
277  */
278 
279 /**
280  * Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", then
281  * all the remaining control commands will return failure, so it is worth
282  * checking this first if the caller is trying to "discover" the engine's
283  * capabilities and doesn't want errors generated unnecessarily.
284  */
285 enum ENGINE_CTRL_HAS_CTRL_FUNCTION = 10;
286 
287 /**
288  * Returns a positive command number for the first command supported by the
289  * engine. Returns zero if no ctrl commands are supported.
290  */
291 enum ENGINE_CTRL_GET_FIRST_CMD_TYPE = 11;
292 
293 /**
294  * The 'core.stdc.config.c_long' argument specifies a command implemented by the engine, and the
295  * return value is the next command supported, or zero if there are no more.
296  */
297 enum ENGINE_CTRL_GET_NEXT_CMD_TYPE = 12;
298 
299 /**
300  * The 'void*' argument is a command name (cast from 'const (char)* '), and the
301  * return value is the command that corresponds to it.
302  */
303 enum ENGINE_CTRL_GET_CMD_FROM_NAME = 13;
304 
305 /*
306  * The next two allow a command to be converted into its corresponding string
307  * form. In each case, the 'core.stdc.config.c_long' argument supplies the command. In the NAME_LEN
308  * case, the return value is the length of the command name (not counting a
309  * trailing EOL). In the NAME case, the 'void*' argument must be a string buffer
310  * large enough, and it will be populated with the name of the command (WITH a
311  * trailing EOL).
312  */
313 enum ENGINE_CTRL_GET_NAME_LEN_FROM_CMD = 14;
314 enum ENGINE_CTRL_GET_NAME_FROM_CMD = 15;
315 /* The next two are similar but give a "short description" of a command. */
316 enum ENGINE_CTRL_GET_DESC_LEN_FROM_CMD = 16;
317 enum ENGINE_CTRL_GET_DESC_FROM_CMD = 17;
318 
319 /**
320  * With this command, the return value is the OR'd combination of
321  * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given
322  * engine-specific ctrl command expects.
323  */
324 enum ENGINE_CTRL_GET_CMD_FLAGS = 18;
325 
326 /**
327  * ENGINE implementations should start the numbering of their own control
328  * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc).
329  */
330 enum ENGINE_CMD_BASE = 200;
331 
332 /**
333  * If an ENGINE supports its own specific control commands and wishes the
334  * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on its
335  * behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN entries
336  * to ENGINE_set_cmd_defns(). It should also implement a ctrl() handler that
337  * supports the stated commands (ie. the "cmd_num" entries as described by the
338  * array). NB: The array must be ordered in increasing order of cmd_num.
339  * "null-terminated" means that the last ENGINE_CMD_DEFN element has cmd_num set
340  * to zero and/or cmd_name set to null.
341  */
342 struct ENGINE_CMD_DEFN_st
343 {
344 	/**
345 	 * The command number
346 	 */
347 	uint cmd_num;
348 
349 	/**
350 	 * The command name itself
351 	 */
352 	const (char)* cmd_name;
353 
354 	/**
355 	 * A short description of the command
356 	 */
357 	const (char)* cmd_desc;
358 
359 	/**
360 	 * The input the command expects
361 	 */
362 	uint cmd_flags;
363 }
364 
365 alias ENGINE_CMD_DEFN = .ENGINE_CMD_DEFN_st;
366 
367 /**
368  * Generic function pointer
369  */
370 alias ENGINE_GEN_FUNC_PTR = extern (C) nothrow @nogc int function();
371 
372 /**
373  * Generic function pointer taking no arguments
374  */
375 alias ENGINE_GEN_INT_FUNC_PTR = extern (C) nothrow @nogc int function(libressl_d.openssl.ossl_typ.ENGINE*);
376 
377 /**
378  * Specific control function pointer
379  */
380 alias ENGINE_CTRL_FUNC_PTR = extern (C) nothrow @nogc int function(libressl_d.openssl.ossl_typ.ENGINE*, int, core.stdc.config.c_long, void*, void function() f);
381 
382 /**
383  * Generic load_key function pointer
384  */
385 alias ENGINE_LOAD_KEY_PTR = extern (C) nothrow @nogc libressl_d.openssl.ossl_typ.EVP_PKEY* function(libressl_d.openssl.ossl_typ.ENGINE*, const (char)*, libressl_d.openssl.ossl_typ.UI_METHOD* ui_method, void* callback_data);
386 alias ENGINE_SSL_CLIENT_CERT_PTR = extern (C) nothrow @nogc int function(libressl_d.openssl.ossl_typ.ENGINE*, libressl_d.openssl.ossl_typ.SSL* ssl, libressl_d.openssl.x509.stack_st_X509_NAME* ca_dn, libressl_d.openssl.ossl_typ.X509** pcert, libressl_d.openssl.ossl_typ.EVP_PKEY** pkey, libressl_d.openssl.x509.stack_st_X509** pother, libressl_d.openssl.ossl_typ.UI_METHOD* ui_method, void* callback_data);
387 
388 /*
389  * These callback types are for an ENGINE's handler for cipher and digest logic.
390  * These handlers have these prototypes;
391  *   int foo(ENGINE* , const (libressl_d.openssl.ossl_typ.EVP_CIPHER)** cipher, const (int)** nids, int nid);
392  *   int foo(ENGINE* , const (libressl_d.openssl.ossl_typ.EVP_MD)** digest, const (int)** nids, int nid);
393  * Looking at how to implement these handlers in the case of cipher support, if
394  * the framework wants the EVP_CIPHER for 'nid', it will call;
395  *   foo(e, &p_evp_cipher, null, nid);    (return zero for failure)
396  * If the framework wants a list of supported 'nid's, it will call;
397  *   foo(e, null, &p_nids, 0); (returns number of 'nids' or -1 for error)
398  */
399 /*
400  * Returns to a pointer to the array of supported cipher 'nid's. If the second
401  * parameter is non-null it is set to the size of the returned array.
402  */
403 alias ENGINE_CIPHERS_PTR = extern (C) nothrow @nogc int function(libressl_d.openssl.ossl_typ.ENGINE*, const (libressl_d.openssl.ossl_typ.EVP_CIPHER)**, const (int)**, int);
404 alias ENGINE_DIGESTS_PTR = extern (C) nothrow @nogc int function(libressl_d.openssl.ossl_typ.ENGINE*, const (libressl_d.openssl.ossl_typ.EVP_MD)**, const (int)**, int);
405 alias ENGINE_PKEY_METHS_PTR = extern (C) nothrow @nogc int function(libressl_d.openssl.ossl_typ.ENGINE*, libressl_d.openssl.ossl_typ.EVP_PKEY_METHOD**, const (int)**, int);
406 alias ENGINE_PKEY_ASN1_METHS_PTR = extern (C) nothrow @nogc int function(libressl_d.openssl.ossl_typ.ENGINE*, libressl_d.openssl.ossl_typ.EVP_PKEY_ASN1_METHOD**, const (int)**, int);
407 
408 /*
409  * STRUCTURE functions ... all of these functions deal with pointers to ENGINE
410  * structures where the pointers have a "structural reference". This means that
411  * their reference is to allowed access to the structure but it does not imply
412  * that the structure is functional. To simply increment or decrement the
413  * structural reference count, use ENGINE_by_id and ENGINE_free. NB: This is not
414  * required when iterating using ENGINE_get_next as it will automatically
415  * decrement the structural reference count of the "current" ENGINE and
416  * increment the structural reference count of the ENGINE it returns (unless it
417  * is null).
418  */
419 
420 /* Get the first/last "ENGINE" type available. */
421 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_first();
422 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_last();
423 
424 /* Iterate to the next/previous "ENGINE" type (null = end of the list). */
425 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_next(libressl_d.openssl.ossl_typ.ENGINE* e);
426 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_prev(libressl_d.openssl.ossl_typ.ENGINE* e);
427 
428 /**
429  * Add another "ENGINE" type into the array.
430  */
431 int ENGINE_add(libressl_d.openssl.ossl_typ.ENGINE* e);
432 
433 /**
434  * Remove an existing "ENGINE" type from the array.
435  */
436 int ENGINE_remove(libressl_d.openssl.ossl_typ.ENGINE* e);
437 
438 /**
439  * Retrieve an engine from the list by its unique "id" value.
440  */
441 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_by_id(const (char)* id);
442 
443 /* Add all the built-in engines. */
444 void ENGINE_load_openssl();
445 void ENGINE_load_dynamic();
446 
447 version (OPENSSL_NO_STATIC_ENGINE) {
448 } else {
449 	void ENGINE_load_padlock();
450 }
451 
452 void ENGINE_load_builtin_engines();
453 
454 /*
455  * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
456  * "registry" handling.
457  */
458 uint ENGINE_get_table_flags();
459 void ENGINE_set_table_flags(uint flags);
460 
461 /*
462  * Manage registration of ENGINEs per "table". For each type, there are 3
463  * functions;
464  *   ENGINE_register_***(e) - registers the implementation from 'e' (if it has one)
465  *   ENGINE_unregister_***(e) - unregister the implementation from 'e'
466  *   ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list
467  * Cleanup is automatically registered from each table when required, so
468  * ENGINE_cleanup() will reverse any "register" operations.
469  */
470 
471 int ENGINE_register_RSA(libressl_d.openssl.ossl_typ.ENGINE* e);
472 void ENGINE_unregister_RSA(libressl_d.openssl.ossl_typ.ENGINE* e);
473 void ENGINE_register_all_RSA();
474 
475 int ENGINE_register_DSA(libressl_d.openssl.ossl_typ.ENGINE* e);
476 void ENGINE_unregister_DSA(libressl_d.openssl.ossl_typ.ENGINE* e);
477 void ENGINE_register_all_DSA();
478 
479 int ENGINE_register_ECDH(libressl_d.openssl.ossl_typ.ENGINE* e);
480 void ENGINE_unregister_ECDH(libressl_d.openssl.ossl_typ.ENGINE* e);
481 void ENGINE_register_all_ECDH();
482 
483 int ENGINE_register_ECDSA(libressl_d.openssl.ossl_typ.ENGINE* e);
484 void ENGINE_unregister_ECDSA(libressl_d.openssl.ossl_typ.ENGINE* e);
485 void ENGINE_register_all_ECDSA();
486 
487 int ENGINE_register_EC(libressl_d.openssl.ossl_typ.ENGINE* e);
488 void ENGINE_unregister_EC(libressl_d.openssl.ossl_typ.ENGINE* e);
489 void ENGINE_register_all_EC();
490 
491 int ENGINE_register_DH(libressl_d.openssl.ossl_typ.ENGINE* e);
492 void ENGINE_unregister_DH(libressl_d.openssl.ossl_typ.ENGINE* e);
493 void ENGINE_register_all_DH();
494 
495 int ENGINE_register_RAND(libressl_d.openssl.ossl_typ.ENGINE* e);
496 void ENGINE_unregister_RAND(libressl_d.openssl.ossl_typ.ENGINE* e);
497 void ENGINE_register_all_RAND();
498 
499 int ENGINE_register_STORE(libressl_d.openssl.ossl_typ.ENGINE* e);
500 void ENGINE_unregister_STORE(libressl_d.openssl.ossl_typ.ENGINE* e);
501 void ENGINE_register_all_STORE();
502 
503 int ENGINE_register_ciphers(libressl_d.openssl.ossl_typ.ENGINE* e);
504 void ENGINE_unregister_ciphers(libressl_d.openssl.ossl_typ.ENGINE* e);
505 void ENGINE_register_all_ciphers();
506 
507 int ENGINE_register_digests(libressl_d.openssl.ossl_typ.ENGINE* e);
508 void ENGINE_unregister_digests(libressl_d.openssl.ossl_typ.ENGINE* e);
509 void ENGINE_register_all_digests();
510 
511 int ENGINE_register_pkey_meths(libressl_d.openssl.ossl_typ.ENGINE* e);
512 void ENGINE_unregister_pkey_meths(libressl_d.openssl.ossl_typ.ENGINE* e);
513 void ENGINE_register_all_pkey_meths();
514 
515 int ENGINE_register_pkey_asn1_meths(libressl_d.openssl.ossl_typ.ENGINE* e);
516 void ENGINE_unregister_pkey_asn1_meths(libressl_d.openssl.ossl_typ.ENGINE* e);
517 void ENGINE_register_all_pkey_asn1_meths();
518 
519 /*
520  * These functions register all support from the above categories. Note, use of
521  * these functions can result in static linkage of code your application may not
522  * need. If you only need a subset of functionality, consider using more
523  * selective initialisation.
524  */
525 int ENGINE_register_complete(libressl_d.openssl.ossl_typ.ENGINE* e);
526 int ENGINE_register_all_complete();
527 
528 /**
529  * Send parametrised control commands to the engine. The possibilities to send
530  * down an integer, a pointer to data or a function pointer are provided. Any of
531  * the parameters may or may not be null, depending on the command number. In
532  * actuality, this function only requires a structural (rather than functional)
533  * reference to an engine, but many control commands may require the engine be
534  * functional. The caller should be aware of trying commands that require an
535  * operational ENGINE, and only use functional references in such situations.
536  */
537 int ENGINE_ctrl(libressl_d.openssl.ossl_typ.ENGINE* e, int cmd, core.stdc.config.c_long i, void* p, void function() f);
538 
539 /**
540  * This function tests if an ENGINE-specific command is usable as a "setting".
541  * Eg. in an application's config file that gets processed through
542  * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to
543  * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl().
544  */
545 int ENGINE_cmd_is_executable(libressl_d.openssl.ossl_typ.ENGINE* e, int cmd);
546 
547 /**
548  * This function works like ENGINE_ctrl() with the exception of taking a
549  * command name instead of a command number, and can handle optional commands.
550  * See the comment on ENGINE_ctrl_cmd_string() for an explanation on how to
551  * use the cmd_name and cmd_optional.
552  */
553 int ENGINE_ctrl_cmd(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* cmd_name, core.stdc.config.c_long i, void* p, void function() f, int cmd_optional);
554 
555 /**
556  * This function passes a command-name and argument to an ENGINE. The cmd_name
557  * is converted to a command number and the control command is called using
558  * 'arg' as an argument (unless the ENGINE doesn't support such a command, in
559  * which case no control command is called). The command is checked for input
560  * flags, and if necessary the argument will be converted to a numeric value. If
561  * cmd_optional is non-zero, then if the ENGINE doesn't support the given
562  * cmd_name the return value will be success anyway. This function is intended
563  * for applications to use so that users (or config files) can supply
564  * engine-specific config data to the ENGINE at run-time to control behaviour of
565  * specific engines. As such, it shouldn't be used for calling ENGINE_ctrl()
566  * functions that return data, deal with binary data, or that are otherwise
567  * supposed to be used directly through ENGINE_ctrl() in application code. Any
568  * "return" data from an ENGINE_ctrl() operation in this function will be lost -
569  * the return value is interpreted as failure if the return value is zero,
570  * success otherwise, and this function returns a boolean value as a result. In
571  * other words, vendors of 'ENGINE'-enabled devices should write ENGINE
572  * implementations with parameterisations that work in this scheme, so that
573  * compliant ENGINE-based applications can work consistently with the same
574  * configuration for the same ENGINE-enabled devices, across applications.
575  */
576 int ENGINE_ctrl_cmd_string(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* cmd_name, const (char)* arg, int cmd_optional);
577 
578 /*
579  * These functions are useful for manufacturing new ENGINE structures. They
580  * don't address reference counting at all - one uses them to populate an ENGINE
581  * structure with personalised implementations of things prior to using it
582  * directly or adding it to the builtin ENGINE list in OpenSSL. These are also
583  * here so that the ENGINE structure doesn't have to be exposed and break binary
584  * compatibility!
585  */
586 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_new();
587 int ENGINE_free(libressl_d.openssl.ossl_typ.ENGINE* e);
588 int ENGINE_up_ref(libressl_d.openssl.ossl_typ.ENGINE* e);
589 int ENGINE_set_id(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* id);
590 int ENGINE_set_name(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* name);
591 int ENGINE_set_RSA(libressl_d.openssl.ossl_typ.ENGINE* e, const (libressl_d.openssl.ossl_typ.RSA_METHOD)* rsa_meth);
592 int ENGINE_set_DSA(libressl_d.openssl.ossl_typ.ENGINE* e, const (libressl_d.openssl.ossl_typ.DSA_METHOD)* dsa_meth);
593 int ENGINE_set_ECDH(libressl_d.openssl.ossl_typ.ENGINE* e, const (libressl_d.openssl.ossl_typ.ECDH_METHOD)* ecdh_meth);
594 int ENGINE_set_ECDSA(libressl_d.openssl.ossl_typ.ENGINE* e, const (libressl_d.openssl.ossl_typ.ECDSA_METHOD)* ecdsa_meth);
595 int ENGINE_set_EC(libressl_d.openssl.ossl_typ.ENGINE* e, const (libressl_d.openssl.ec.EC_KEY_METHOD)* ec_meth);
596 int ENGINE_set_DH(libressl_d.openssl.ossl_typ.ENGINE* e, const (libressl_d.openssl.ossl_typ.DH_METHOD)* dh_meth);
597 int ENGINE_set_RAND(libressl_d.openssl.ossl_typ.ENGINE* e, const (libressl_d.openssl.ossl_typ.RAND_METHOD)* rand_meth);
598 int ENGINE_set_STORE(libressl_d.openssl.ossl_typ.ENGINE* e, const (libressl_d.openssl.ossl_typ.STORE_METHOD)* store_meth);
599 int ENGINE_set_destroy_function(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_GEN_INT_FUNC_PTR destroy_f);
600 int ENGINE_set_init_function(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_GEN_INT_FUNC_PTR init_f);
601 int ENGINE_set_finish_function(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_GEN_INT_FUNC_PTR finish_f);
602 int ENGINE_set_ctrl_function(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_CTRL_FUNC_PTR ctrl_f);
603 int ENGINE_set_load_privkey_function(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_LOAD_KEY_PTR loadpriv_f);
604 int ENGINE_set_load_pubkey_function(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_LOAD_KEY_PTR loadpub_f);
605 int ENGINE_set_load_ssl_client_cert_function(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_SSL_CLIENT_CERT_PTR loadssl_f);
606 int ENGINE_set_ciphers(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_CIPHERS_PTR f);
607 int ENGINE_set_digests(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_DIGESTS_PTR f);
608 int ENGINE_set_pkey_meths(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_PKEY_METHS_PTR f);
609 int ENGINE_set_pkey_asn1_meths(libressl_d.openssl.ossl_typ.ENGINE* e, .ENGINE_PKEY_ASN1_METHS_PTR f);
610 int ENGINE_set_flags(libressl_d.openssl.ossl_typ.ENGINE* e, int flags);
611 int ENGINE_set_cmd_defns(libressl_d.openssl.ossl_typ.ENGINE* e, const (.ENGINE_CMD_DEFN)* defns);
612 
613 /* These functions allow control over any per-structure ENGINE data. */
614 int ENGINE_get_ex_new_index(core.stdc.config.c_long argl, void* argp, libressl_d.openssl.ossl_typ.CRYPTO_EX_new* new_func, libressl_d.openssl.ossl_typ.CRYPTO_EX_dup* dup_func, libressl_d.openssl.ossl_typ.CRYPTO_EX_free* free_func);
615 int ENGINE_set_ex_data(libressl_d.openssl.ossl_typ.ENGINE* e, int idx, void* arg);
616 void* ENGINE_get_ex_data(const (libressl_d.openssl.ossl_typ.ENGINE)* e, int idx);
617 
618 /**
619  * This function cleans up anything that needs it. Eg. the ENGINE_add() function
620  * automatically ensures the list cleanup function is registered to be called
621  * from ENGINE_cleanup(). Similarly, all ENGINE_register_*** functions ensure
622  * ENGINE_cleanup() will clean up after them.
623  */
624 void ENGINE_cleanup();
625 
626 /*
627  * These return values from within the ENGINE structure. These can be useful
628  * with functional references as well as structural references - it depends
629  * which you obtained. Using the result for functional purposes if you only
630  * obtained a structural reference may be problematic!
631  */
632 const (char)* ENGINE_get_id(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
633 const (char)* ENGINE_get_name(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
634 const (libressl_d.openssl.ossl_typ.RSA_METHOD)* ENGINE_get_RSA(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
635 const (libressl_d.openssl.ossl_typ.DSA_METHOD)* ENGINE_get_DSA(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
636 const (libressl_d.openssl.ossl_typ.ECDH_METHOD)* ENGINE_get_ECDH(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
637 const (libressl_d.openssl.ossl_typ.ECDSA_METHOD)* ENGINE_get_ECDSA(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
638 const (libressl_d.openssl.ec.EC_KEY_METHOD)* ENGINE_get_EC(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
639 const (libressl_d.openssl.ossl_typ.DH_METHOD)* ENGINE_get_DH(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
640 const (libressl_d.openssl.ossl_typ.RAND_METHOD)* ENGINE_get_RAND(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
641 const (libressl_d.openssl.ossl_typ.STORE_METHOD)* ENGINE_get_STORE(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
642 .ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
643 .ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
644 .ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
645 .ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
646 .ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
647 .ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
648 .ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
649 .ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
650 .ENGINE_DIGESTS_PTR ENGINE_get_digests(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
651 .ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
652 .ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
653 const (libressl_d.openssl.ossl_typ.EVP_CIPHER)* ENGINE_get_cipher(libressl_d.openssl.ossl_typ.ENGINE* e, int nid);
654 const (libressl_d.openssl.ossl_typ.EVP_MD)* ENGINE_get_digest(libressl_d.openssl.ossl_typ.ENGINE* e, int nid);
655 const (libressl_d.openssl.ossl_typ.EVP_PKEY_METHOD)* ENGINE_get_pkey_meth(libressl_d.openssl.ossl_typ.ENGINE* e, int nid);
656 const (libressl_d.openssl.ossl_typ.EVP_PKEY_ASN1_METHOD)* ENGINE_get_pkey_asn1_meth(libressl_d.openssl.ossl_typ.ENGINE* e, int nid);
657 const (libressl_d.openssl.ossl_typ.EVP_PKEY_ASN1_METHOD)* ENGINE_get_pkey_asn1_meth_str(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* str, int len);
658 const (libressl_d.openssl.ossl_typ.EVP_PKEY_ASN1_METHOD)* ENGINE_pkey_asn1_find_str(libressl_d.openssl.ossl_typ.ENGINE** pe, const (char)* str, int len);
659 const (.ENGINE_CMD_DEFN)* ENGINE_get_cmd_defns(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
660 int ENGINE_get_flags(const (libressl_d.openssl.ossl_typ.ENGINE)* e);
661 
662 /*
663  * FUNCTIONAL functions. These functions deal with ENGINE structures
664  * that have (or will) be initialised for use. Broadly speaking, the
665  * structural functions are useful for iterating the list of available
666  * engine types, creating new engine types, and other "list" operations.
667  * These functions actually deal with ENGINEs that are to be used. As
668  * such these functions can fail (if applicable) when particular
669  * engines are unavailable - eg. if a hardware accelerator is not
670  * attached or not functioning correctly. Each ENGINE has 2 reference
671  * counts; structural and functional. Every time a functional reference
672  * is obtained or released, a corresponding structural reference is
673  * automatically obtained or released too.
674  */
675 
676 /**
677  * Initialise a engine type for use (or up its reference count if it's
678  * already in use). This will fail if the engine is not currently
679  * operational and cannot initialise.
680  */
681 int ENGINE_init(libressl_d.openssl.ossl_typ.ENGINE* e);
682 
683 /**
684  * Free a functional reference to a engine type. This does not require
685  * a corresponding call to ENGINE_free as it also releases a structural
686  * reference.
687  */
688 int ENGINE_finish(libressl_d.openssl.ossl_typ.ENGINE* e);
689 
690 /*
691  * The following functions handle keys that are stored in some secondary
692  * location, handled by the engine.  The storage may be on a card or
693  * whatever.
694  */
695 libressl_d.openssl.ossl_typ.EVP_PKEY* ENGINE_load_private_key(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* key_id, libressl_d.openssl.ossl_typ.UI_METHOD* ui_method, void* callback_data);
696 libressl_d.openssl.ossl_typ.EVP_PKEY* ENGINE_load_public_key(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* key_id, libressl_d.openssl.ossl_typ.UI_METHOD* ui_method, void* callback_data);
697 int ENGINE_load_ssl_client_cert(libressl_d.openssl.ossl_typ.ENGINE* e, libressl_d.openssl.ossl_typ.SSL* s, libressl_d.openssl.x509.stack_st_X509_NAME* ca_dn, libressl_d.openssl.ossl_typ.X509** pcert, libressl_d.openssl.ossl_typ.EVP_PKEY** ppkey, libressl_d.openssl.x509.stack_st_X509** pother, libressl_d.openssl.ossl_typ.UI_METHOD* ui_method, void* callback_data);
698 
699 /*
700  * This returns a pointer for the current ENGINE structure that
701  * is (by default) performing any RSA operations. The value returned
702  * is an incremented reference, so it should be free'd (ENGINE_finish)
703  * before it is discarded.
704  */
705 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_default_RSA();
706 /* Same for the other "methods" */
707 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_default_DSA();
708 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_default_ECDH();
709 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_default_ECDSA();
710 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_default_EC();
711 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_default_DH();
712 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_default_RAND();
713 /*
714  * These functions can be used to get a functional reference to perform
715  * ciphering or digesting corresponding to "nid".
716  */
717 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_cipher_engine(int nid);
718 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_digest_engine(int nid);
719 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_pkey_meth_engine(int nid);
720 libressl_d.openssl.ossl_typ.ENGINE* ENGINE_get_pkey_asn1_meth_engine(int nid);
721 
722 /*
723  * This sets a new default ENGINE structure for performing RSA
724  * operations. If the result is non-zero (success) then the ENGINE
725  * structure will have had its reference count up'd so the caller
726  * should still free their own reference 'e'.
727  */
728 int ENGINE_set_default_RSA(libressl_d.openssl.ossl_typ.ENGINE* e);
729 int ENGINE_set_default_string(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* def_list);
730 /* Same for the other "methods" */
731 int ENGINE_set_default_DSA(libressl_d.openssl.ossl_typ.ENGINE* e);
732 int ENGINE_set_default_ECDH(libressl_d.openssl.ossl_typ.ENGINE* e);
733 int ENGINE_set_default_ECDSA(libressl_d.openssl.ossl_typ.ENGINE* e);
734 int ENGINE_set_default_EC(libressl_d.openssl.ossl_typ.ENGINE* e);
735 int ENGINE_set_default_DH(libressl_d.openssl.ossl_typ.ENGINE* e);
736 int ENGINE_set_default_RAND(libressl_d.openssl.ossl_typ.ENGINE* e);
737 int ENGINE_set_default_ciphers(libressl_d.openssl.ossl_typ.ENGINE* e);
738 int ENGINE_set_default_digests(libressl_d.openssl.ossl_typ.ENGINE* e);
739 int ENGINE_set_default_pkey_meths(libressl_d.openssl.ossl_typ.ENGINE* e);
740 int ENGINE_set_default_pkey_asn1_meths(libressl_d.openssl.ossl_typ.ENGINE* e);
741 
742 /**
743  * The combination "set" - the flags are bitwise "OR"d from the
744  * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()"
745  * function, this function can result in unnecessary static linkage. If your
746  * application requires only specific functionality, consider using more
747  * selective functions.
748  */
749 int ENGINE_set_default(libressl_d.openssl.ossl_typ.ENGINE* e, uint flags);
750 
751 void ENGINE_add_conf_module();
752 
753 /* Deprecated functions ... */
754 /* int ENGINE_clear_defaults(); */
755 
756 /* *************************/
757 /* DYNAMIC ENGINE SUPPORT */
758 /* *************************/
759 
760 /**
761  * Binary/behaviour compatibility levels
762  */
763 enum core.stdc.config.c_ulong OSSL_DYNAMIC_VERSION = 0x00020000;
764 
765 /**
766  * Binary versions older than this are too old for us (whether we're a loader or
767  * a loadee)
768  */
769 enum core.stdc.config.c_ulong OSSL_DYNAMIC_OLDEST = 0x00020000;
770 
771 /*
772  * When compiling an ENGINE entirely as an external shared library, loadable by
773  * the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' structure
774  * type provides the calling application's (or library's) error functionality
775  * and memory management function pointers to the loaded library. These should
776  * be used/set in the loaded library code so that the loading application's
777  * 'state' will be used/changed in all operations. The 'static_state' pointer
778  * allows the loaded library to know if it shares the same static data as the
779  * calling application (or library), and thus whether these callbacks need to be
780  * set or not.
781  */
782 alias dyn_MEM_malloc_cb = extern (C) nothrow @nogc void* function(size_t);
783 alias dyn_MEM_realloc_cb = extern (C) nothrow @nogc void* function(void*, size_t);
784 alias dyn_MEM_free_cb = extern (C) nothrow @nogc void function(void*);
785 
786 struct st_dynamic_MEM_fns
787 {
788 	.dyn_MEM_malloc_cb malloc_cb;
789 	.dyn_MEM_realloc_cb realloc_cb;
790 	.dyn_MEM_free_cb free_cb;
791 }
792 
793 alias dynamic_MEM_fns = .st_dynamic_MEM_fns;
794 /*
795  * FIXME: Perhaps the memory and locking code (crypto.h) should declare and use
796  * these types so we (and any other dependant code) can simplify a bit??
797  */
798 alias dyn_lock_locking_cb = extern (C) nothrow @nogc void function(int, int, const (char)*, int);
799 alias dyn_lock_add_lock_cb = extern (C) nothrow @nogc int function(int*, int, int, const (char)*, int);
800 struct CRYPTO_dynlock_value;
801 alias dyn_dynlock_create_cb = extern (C) nothrow @nogc .CRYPTO_dynlock_value* function(const (char)*, int);
802 alias dyn_dynlock_lock_cb = extern (C) nothrow @nogc void function(int, .CRYPTO_dynlock_value*, const (char)*, int);
803 alias dyn_dynlock_destroy_cb = extern (C) nothrow @nogc void function(.CRYPTO_dynlock_value*, const (char)*, int);
804 
805 struct st_dynamic_LOCK_fns
806 {
807 	.dyn_lock_locking_cb lock_locking_cb;
808 	.dyn_lock_add_lock_cb lock_add_lock_cb;
809 	.dyn_dynlock_create_cb dynlock_create_cb;
810 	.dyn_dynlock_lock_cb dynlock_lock_cb;
811 	.dyn_dynlock_destroy_cb dynlock_destroy_cb;
812 }
813 
814 alias dynamic_LOCK_fns = .st_dynamic_LOCK_fns;
815 
816 /**
817  * The top-level structure
818  */
819 struct st_dynamic_fns
820 {
821 	void* static_state;
822 	const (libressl_d.openssl.ossl_typ.ERR_FNS)* err_fns;
823 	const (libressl_d.openssl.crypto.CRYPTO_EX_DATA_IMPL)* ex_data_fns;
824 	.dynamic_MEM_fns mem_fns;
825 	.dynamic_LOCK_fns lock_fns;
826 }
827 
828 alias dynamic_fns = .st_dynamic_fns;
829 
830 /**
831  * The version checking function should be of this prototype. NB: The
832  * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading code.
833  * If this function returns zero, it indicates a (potential) version
834  * incompatibility and the loaded library doesn't believe it can proceed.
835  * Otherwise, the returned value is the (latest) version supported by the
836  * loading library. The loader may still decide that the loaded code's version
837  * is unsatisfactory and could veto the load. The function is expected to
838  * be implemented with the symbol name "v_check", and a default implementation
839  * can be fully instantiated with IMPLEMENT_DYNAMIC_CHECK_FN().
840  */
841 alias dynamic_v_check_fn = extern (C) nothrow @nogc core.stdc.config.c_ulong function(core.stdc.config.c_ulong ossl_version);
842 //#define IMPLEMENT_DYNAMIC_CHECK_FN() extern core.stdc.config.c_ulong v_check(core.stdc.config.c_ulong v); extern core.stdc.config.c_ulong v_check(core.stdc.config.c_ulong v) { if (v >= .OSSL_DYNAMIC_OLDEST) return .OSSL_DYNAMIC_VERSION; return 0; }
843 
844 /**
845  * This function is passed the ENGINE structure to initialise with its own
846  * function and command settings. It should not adjust the structural or
847  * functional reference counts. If this function returns zero, (a) the load will
848  * be aborted, (b) the previous ENGINE state will be memcpy'd back onto the
849  * structure, and (c) the shared library will be unloaded. So implementations
850  * should do their own internal cleanup in failure circumstances otherwise they
851  * could leak. The 'id' parameter, if non-null, represents the ENGINE id that
852  * the loader is looking for. If this is null, the shared library can choose to
853  * return failure or to initialise a 'default' ENGINE. If non-null, the shared
854  * library must initialise only an ENGINE matching the passed 'id'. The function
855  * is expected to be implemented with the symbol name "bind_engine". A standard
856  * implementation can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where
857  * the parameter 'fn' is a callback function that populates the ENGINE structure
858  * and returns an int value (zero for failure). 'fn' should have prototype;
859  *    [static] int fn(libressl_d.openssl.ossl_typ.ENGINE* , const (char)* id);
860  */
861 alias dynamic_bind_engine = extern (C) nothrow @nogc int function(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* id, const (.dynamic_fns)* fns);
862 //#define IMPLEMENT_DYNAMIC_BIND_FN(fn) extern int bind_engine(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* id, const (.dynamic_fns)* fns); extern int bind_engine(libressl_d.openssl.ossl_typ.ENGINE* e, const (char)* id, const (.dynamic_fns)* fns) { if (ENGINE_get_static_state() == fns.static_state) goto skip_cbs; if (!libressl_d.openssl.crypto.CRYPTO_set_mem_functions(fns.mem_fns.malloc_cb, fns.mem_fns.realloc_cb, fns.mem_fns.free_cb)) return 0; if (!libressl_d.openssl.crypto.CRYPTO_set_ex_data_implementation(fns.ex_data_fns)) return 0; if (!libressl_d.openssl.err.ERR_set_implementation(fns.err_fns)) return 0; skip_cbs: if (!fn(e, id)) return 0; return 1; }
863 
864 /**
865  * If the loading application (or library) and the loaded ENGINE library share
866  * the same static data (eg. they're both dynamically linked to the same
867  * libcrypto.so) we need a way to avoid trying to set system callbacks - this
868  * would fail, and for the same reason that it's unnecessary to try. If the
869  * loaded ENGINE has (or gets from through the loader) its own copy of the
870  * libcrypto static data, we will need to set the callbacks. The easiest way to
871  * detect this is to have a function that returns a pointer to some static data
872  * and let the loading application and loaded ENGINE compare their respective
873  * values.
874  */
875 void* ENGINE_get_static_state();
876 
877 /* BEGIN ERROR CODES */
878 /**
879  * The following lines are auto generated by the script mkerr.pl. Any changes
880  * made after this point may be overwritten when the script is next run.
881  */
882 void ERR_load_ENGINE_strings();
883 
884 /* Error codes for the ENGINE functions. */
885 
886 /* Function codes. */
887 enum ENGINE_F_DYNAMIC_CTRL = 180;
888 enum ENGINE_F_DYNAMIC_GET_DATA_CTX = 181;
889 enum ENGINE_F_DYNAMIC_LOAD = 182;
890 enum ENGINE_F_DYNAMIC_SET_DATA_CTX = 183;
891 enum ENGINE_F_ENGINE_ADD = 105;
892 enum ENGINE_F_ENGINE_BY_ID = 106;
893 enum ENGINE_F_ENGINE_CMD_IS_EXECUTABLE = 170;
894 enum ENGINE_F_ENGINE_CTRL = 142;
895 enum ENGINE_F_ENGINE_CTRL_CMD = 178;
896 enum ENGINE_F_ENGINE_CTRL_CMD_STRING = 171;
897 enum ENGINE_F_ENGINE_FINISH = 107;
898 enum ENGINE_F_ENGINE_FREE_UTIL = 108;
899 enum ENGINE_F_ENGINE_GET_CIPHER = 185;
900 enum ENGINE_F_ENGINE_GET_DEFAULT_TYPE = 177;
901 enum ENGINE_F_ENGINE_GET_DIGEST = 186;
902 enum ENGINE_F_ENGINE_GET_NEXT = 115;
903 enum ENGINE_F_ENGINE_GET_PKEY_ASN1_METH = 193;
904 enum ENGINE_F_ENGINE_GET_PKEY_METH = 192;
905 enum ENGINE_F_ENGINE_GET_PREV = 116;
906 enum ENGINE_F_ENGINE_INIT = 119;
907 enum ENGINE_F_ENGINE_LIST_ADD = 120;
908 enum ENGINE_F_ENGINE_LIST_REMOVE = 121;
909 enum ENGINE_F_ENGINE_LOAD_PRIVATE_KEY = 150;
910 enum ENGINE_F_ENGINE_LOAD_PUBLIC_KEY = 151;
911 enum ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT = 194;
912 enum ENGINE_F_ENGINE_NEW = 122;
913 enum ENGINE_F_ENGINE_REMOVE = 123;
914 enum ENGINE_F_ENGINE_SET_DEFAULT_STRING = 189;
915 enum ENGINE_F_ENGINE_SET_DEFAULT_TYPE = 126;
916 enum ENGINE_F_ENGINE_SET_ID = 129;
917 enum ENGINE_F_ENGINE_SET_NAME = 130;
918 enum ENGINE_F_ENGINE_TABLE_REGISTER = 184;
919 enum ENGINE_F_ENGINE_UNLOAD_KEY = 152;
920 enum ENGINE_F_ENGINE_UNLOCKED_FINISH = 191;
921 enum ENGINE_F_ENGINE_UP_REF = 190;
922 enum ENGINE_F_INT_CTRL_HELPER = 172;
923 enum ENGINE_F_INT_ENGINE_CONFIGURE = 188;
924 enum ENGINE_F_INT_ENGINE_MODULE_INIT = 187;
925 enum ENGINE_F_LOG_MESSAGE = 141;
926 
927 /* Reason codes. */
928 enum ENGINE_R_ALREADY_LOADED = 100;
929 enum ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER = 133;
930 enum ENGINE_R_CMD_NOT_EXECUTABLE = 134;
931 enum ENGINE_R_COMMAND_TAKES_INPUT = 135;
932 enum ENGINE_R_COMMAND_TAKES_NO_INPUT = 136;
933 enum ENGINE_R_CONFLICTING_ENGINE_ID = 103;
934 enum ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED = 119;
935 enum ENGINE_R_DH_NOT_IMPLEMENTED = 139;
936 enum ENGINE_R_DSA_NOT_IMPLEMENTED = 140;
937 enum ENGINE_R_DSO_FAILURE = 104;
938 enum ENGINE_R_DSO_NOT_FOUND = 132;
939 enum ENGINE_R_ENGINES_SECTION_ERROR = 148;
940 enum ENGINE_R_ENGINE_CONFIGURATION_ERROR = 102;
941 enum ENGINE_R_ENGINE_IS_NOT_IN_LIST = 105;
942 enum ENGINE_R_ENGINE_SECTION_ERROR = 149;
943 enum ENGINE_R_FAILED_LOADING_PRIVATE_KEY = 128;
944 enum ENGINE_R_FAILED_LOADING_PUBLIC_KEY = 129;
945 enum ENGINE_R_FINISH_FAILED = 106;
946 enum ENGINE_R_GET_HANDLE_FAILED = 107;
947 enum ENGINE_R_ID_OR_NAME_MISSING = 108;
948 enum ENGINE_R_INIT_FAILED = 109;
949 enum ENGINE_R_INTERNAL_LIST_ERROR = 110;
950 enum ENGINE_R_INVALID_ARGUMENT = 143;
951 enum ENGINE_R_INVALID_CMD_NAME = 137;
952 enum ENGINE_R_INVALID_CMD_NUMBER = 138;
953 enum ENGINE_R_INVALID_INIT_VALUE = 151;
954 enum ENGINE_R_INVALID_STRING = 150;
955 enum ENGINE_R_NOT_INITIALISED = 117;
956 enum ENGINE_R_NOT_LOADED = 112;
957 enum ENGINE_R_NO_CONTROL_FUNCTION = 120;
958 enum ENGINE_R_NO_INDEX = 144;
959 enum ENGINE_R_NO_LOAD_FUNCTION = 125;
960 enum ENGINE_R_NO_REFERENCE = 130;
961 enum ENGINE_R_NO_SUCH_ENGINE = 116;
962 enum ENGINE_R_NO_UNLOAD_FUNCTION = 126;
963 enum ENGINE_R_PROVIDE_PARAMETERS = 113;
964 enum ENGINE_R_RSA_NOT_IMPLEMENTED = 141;
965 enum ENGINE_R_UNIMPLEMENTED_CIPHER = 146;
966 enum ENGINE_R_UNIMPLEMENTED_DIGEST = 147;
967 enum ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD = 101;
968 enum ENGINE_R_VERSION_INCOMPATIBILITY = 145;