1# This file is dual licensed under the terms of the Apache License, Version
2# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3# for complete details.
4
5from __future__ import absolute_import, division, print_function
6
7INCLUDES = """
8#include <openssl/engine.h>
9"""
10
11TYPES = """
12typedef ... ENGINE;
13typedef ... RSA_METHOD;
14typedef ... DSA_METHOD;
15typedef ... DH_METHOD;
16typedef struct {
17    int (*bytes)(unsigned char *, int);
18    int (*pseudorand)(unsigned char *, int);
19    int (*status)();
20    ...;
21} RAND_METHOD;
22typedef int (*ENGINE_GEN_INT_FUNC_PTR)(ENGINE *);
23typedef ... *ENGINE_CTRL_FUNC_PTR;
24typedef ... *ENGINE_LOAD_KEY_PTR;
25typedef ... *ENGINE_CIPHERS_PTR;
26typedef ... *ENGINE_DIGESTS_PTR;
27typedef ... ENGINE_CMD_DEFN;
28typedef ... UI_METHOD;
29
30static const unsigned int ENGINE_METHOD_RSA;
31static const unsigned int ENGINE_METHOD_DSA;
32static const unsigned int ENGINE_METHOD_RAND;
33static const unsigned int ENGINE_METHOD_CIPHERS;
34static const unsigned int ENGINE_METHOD_DIGESTS;
35static const unsigned int ENGINE_METHOD_ALL;
36static const unsigned int ENGINE_METHOD_NONE;
37
38static const int ENGINE_R_CONFLICTING_ENGINE_ID;
39"""
40
41FUNCTIONS = """
42ENGINE *ENGINE_get_first(void);
43ENGINE *ENGINE_get_last(void);
44ENGINE *ENGINE_get_next(ENGINE *);
45ENGINE *ENGINE_get_prev(ENGINE *);
46int ENGINE_add(ENGINE *);
47int ENGINE_remove(ENGINE *);
48ENGINE *ENGINE_by_id(const char *);
49int ENGINE_init(ENGINE *);
50int ENGINE_finish(ENGINE *);
51void ENGINE_load_builtin_engines(void);
52ENGINE *ENGINE_get_default_RSA(void);
53ENGINE *ENGINE_get_default_DSA(void);
54ENGINE *ENGINE_get_default_DH(void);
55ENGINE *ENGINE_get_default_RAND(void);
56ENGINE *ENGINE_get_cipher_engine(int);
57ENGINE *ENGINE_get_digest_engine(int);
58int ENGINE_set_default_RSA(ENGINE *);
59int ENGINE_set_default_DSA(ENGINE *);
60int ENGINE_set_default_DH(ENGINE *);
61int ENGINE_set_default_RAND(ENGINE *);
62int ENGINE_set_default_ciphers(ENGINE *);
63int ENGINE_set_default_digests(ENGINE *);
64int ENGINE_set_default_string(ENGINE *, const char *);
65int ENGINE_set_default(ENGINE *, unsigned int);
66unsigned int ENGINE_get_table_flags(void);
67void ENGINE_set_table_flags(unsigned int);
68int ENGINE_register_RSA(ENGINE *);
69void ENGINE_unregister_RSA(ENGINE *);
70void ENGINE_register_all_RSA(void);
71int ENGINE_register_DSA(ENGINE *);
72void ENGINE_unregister_DSA(ENGINE *);
73void ENGINE_register_all_DSA(void);
74int ENGINE_register_DH(ENGINE *);
75void ENGINE_unregister_DH(ENGINE *);
76void ENGINE_register_all_DH(void);
77int ENGINE_register_RAND(ENGINE *);
78void ENGINE_unregister_RAND(ENGINE *);
79void ENGINE_register_all_RAND(void);
80int ENGINE_register_ciphers(ENGINE *);
81void ENGINE_unregister_ciphers(ENGINE *);
82void ENGINE_register_all_ciphers(void);
83int ENGINE_register_digests(ENGINE *);
84void ENGINE_unregister_digests(ENGINE *);
85void ENGINE_register_all_digests(void);
86int ENGINE_register_complete(ENGINE *);
87int ENGINE_register_all_complete(void);
88int ENGINE_ctrl(ENGINE *, int, long, void *, void (*)(void));
89int ENGINE_cmd_is_executable(ENGINE *, int);
90int ENGINE_ctrl_cmd(ENGINE *, const char *, long, void *, void (*)(void), int);
91int ENGINE_ctrl_cmd_string(ENGINE *, const char *, const char *, int);
92
93ENGINE *ENGINE_new(void);
94int ENGINE_free(ENGINE *);
95int ENGINE_up_ref(ENGINE *);
96int ENGINE_set_id(ENGINE *, const char *);
97int ENGINE_set_name(ENGINE *, const char *);
98int ENGINE_set_RSA(ENGINE *, const RSA_METHOD *);
99int ENGINE_set_DSA(ENGINE *, const DSA_METHOD *);
100int ENGINE_set_DH(ENGINE *, const DH_METHOD *);
101int ENGINE_set_RAND(ENGINE *, const RAND_METHOD *);
102int ENGINE_set_destroy_function(ENGINE *, ENGINE_GEN_INT_FUNC_PTR);
103int ENGINE_set_init_function(ENGINE *, ENGINE_GEN_INT_FUNC_PTR);
104int ENGINE_set_finish_function(ENGINE *, ENGINE_GEN_INT_FUNC_PTR);
105int ENGINE_set_ctrl_function(ENGINE *, ENGINE_CTRL_FUNC_PTR);
106int ENGINE_set_load_privkey_function(ENGINE *, ENGINE_LOAD_KEY_PTR);
107int ENGINE_set_load_pubkey_function(ENGINE *, ENGINE_LOAD_KEY_PTR);
108int ENGINE_set_ciphers(ENGINE *, ENGINE_CIPHERS_PTR);
109int ENGINE_set_digests(ENGINE *, ENGINE_DIGESTS_PTR);
110int ENGINE_set_flags(ENGINE *, int);
111int ENGINE_set_cmd_defns(ENGINE *, const ENGINE_CMD_DEFN *);
112const char *ENGINE_get_id(const ENGINE *);
113const char *ENGINE_get_name(const ENGINE *);
114const RSA_METHOD *ENGINE_get_RSA(const ENGINE *);
115const DSA_METHOD *ENGINE_get_DSA(const ENGINE *);
116const DH_METHOD *ENGINE_get_DH(const ENGINE *);
117const RAND_METHOD *ENGINE_get_RAND(const ENGINE *);
118
119const EVP_CIPHER *ENGINE_get_cipher(ENGINE *, int);
120const EVP_MD *ENGINE_get_digest(ENGINE *, int);
121int ENGINE_get_flags(const ENGINE *);
122const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *);
123EVP_PKEY *ENGINE_load_private_key(ENGINE *, const char *, UI_METHOD *, void *);
124EVP_PKEY *ENGINE_load_public_key(ENGINE *, const char *, UI_METHOD *, void *);
125void ENGINE_add_conf_module(void);
126/* these became macros in 1.1.0 */
127void ENGINE_load_openssl(void);
128void ENGINE_load_dynamic(void);
129void ENGINE_cleanup(void);
130"""
131
132CUSTOMIZATIONS = """
133"""
134