1ebfedea0SLionel Sambuc /* crypto/engine/hw_atalla.c */
2*0a6a1f1dSLionel Sambuc /*
3*0a6a1f1dSLionel Sambuc * Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
4*0a6a1f1dSLionel Sambuc * 2000.
5ebfedea0SLionel Sambuc */
6ebfedea0SLionel Sambuc /* ====================================================================
7ebfedea0SLionel Sambuc * Copyright (c) 1999-2001 The OpenSSL Project. All rights reserved.
8ebfedea0SLionel Sambuc *
9ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
10ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
11ebfedea0SLionel Sambuc * are met:
12ebfedea0SLionel Sambuc *
13ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
14ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer.
15ebfedea0SLionel Sambuc *
16ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
17ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in
18ebfedea0SLionel Sambuc * the documentation and/or other materials provided with the
19ebfedea0SLionel Sambuc * distribution.
20ebfedea0SLionel Sambuc *
21ebfedea0SLionel Sambuc * 3. All advertising materials mentioning features or use of this
22ebfedea0SLionel Sambuc * software must display the following acknowledgment:
23ebfedea0SLionel Sambuc * "This product includes software developed by the OpenSSL Project
24ebfedea0SLionel Sambuc * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25ebfedea0SLionel Sambuc *
26ebfedea0SLionel Sambuc * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27ebfedea0SLionel Sambuc * endorse or promote products derived from this software without
28ebfedea0SLionel Sambuc * prior written permission. For written permission, please contact
29ebfedea0SLionel Sambuc * licensing@OpenSSL.org.
30ebfedea0SLionel Sambuc *
31ebfedea0SLionel Sambuc * 5. Products derived from this software may not be called "OpenSSL"
32ebfedea0SLionel Sambuc * nor may "OpenSSL" appear in their names without prior written
33ebfedea0SLionel Sambuc * permission of the OpenSSL Project.
34ebfedea0SLionel Sambuc *
35ebfedea0SLionel Sambuc * 6. Redistributions of any form whatsoever must retain the following
36ebfedea0SLionel Sambuc * acknowledgment:
37ebfedea0SLionel Sambuc * "This product includes software developed by the OpenSSL Project
38ebfedea0SLionel Sambuc * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39ebfedea0SLionel Sambuc *
40ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41ebfedea0SLionel Sambuc * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43ebfedea0SLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
44ebfedea0SLionel Sambuc * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45ebfedea0SLionel Sambuc * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46ebfedea0SLionel Sambuc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47ebfedea0SLionel Sambuc * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49ebfedea0SLionel Sambuc * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50ebfedea0SLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51ebfedea0SLionel Sambuc * OF THE POSSIBILITY OF SUCH DAMAGE.
52ebfedea0SLionel Sambuc * ====================================================================
53ebfedea0SLionel Sambuc *
54ebfedea0SLionel Sambuc * This product includes cryptographic software written by Eric Young
55ebfedea0SLionel Sambuc * (eay@cryptsoft.com). This product includes software written by Tim
56ebfedea0SLionel Sambuc * Hudson (tjh@cryptsoft.com).
57ebfedea0SLionel Sambuc *
58ebfedea0SLionel Sambuc */
59ebfedea0SLionel Sambuc
60ebfedea0SLionel Sambuc #include <stdio.h>
61ebfedea0SLionel Sambuc #include <string.h>
62ebfedea0SLionel Sambuc #include <openssl/crypto.h>
63ebfedea0SLionel Sambuc #include <openssl/buffer.h>
64ebfedea0SLionel Sambuc #include <openssl/dso.h>
65ebfedea0SLionel Sambuc #include <openssl/engine.h>
66ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_RSA
67ebfedea0SLionel Sambuc # include <openssl/rsa.h>
68ebfedea0SLionel Sambuc #endif
69ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_DSA
70ebfedea0SLionel Sambuc # include <openssl/dsa.h>
71ebfedea0SLionel Sambuc #endif
72ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_DH
73ebfedea0SLionel Sambuc # include <openssl/dh.h>
74ebfedea0SLionel Sambuc #endif
75ebfedea0SLionel Sambuc #include <openssl/bn.h>
76ebfedea0SLionel Sambuc
77ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_HW
78ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_HW_ATALLA
79ebfedea0SLionel Sambuc
80ebfedea0SLionel Sambuc # ifdef FLAT_INC
81ebfedea0SLionel Sambuc # include "atalla.h"
82ebfedea0SLionel Sambuc # else
83ebfedea0SLionel Sambuc # include "vendor_defns/atalla.h"
84ebfedea0SLionel Sambuc # endif
85ebfedea0SLionel Sambuc
86ebfedea0SLionel Sambuc # define ATALLA_LIB_NAME "atalla engine"
87ebfedea0SLionel Sambuc # include "e_atalla_err.c"
88ebfedea0SLionel Sambuc
89ebfedea0SLionel Sambuc static int atalla_destroy(ENGINE *e);
90ebfedea0SLionel Sambuc static int atalla_init(ENGINE *e);
91ebfedea0SLionel Sambuc static int atalla_finish(ENGINE *e);
92ebfedea0SLionel Sambuc static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void));
93ebfedea0SLionel Sambuc
94ebfedea0SLionel Sambuc /* BIGNUM stuff */
95ebfedea0SLionel Sambuc static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
96ebfedea0SLionel Sambuc const BIGNUM *m, BN_CTX *ctx);
97ebfedea0SLionel Sambuc
98ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
99ebfedea0SLionel Sambuc /* RSA stuff */
100*0a6a1f1dSLionel Sambuc static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa,
101*0a6a1f1dSLionel Sambuc BN_CTX *ctx);
102ebfedea0SLionel Sambuc /* This function is aliased to mod_exp (with the mont stuff dropped). */
103ebfedea0SLionel Sambuc static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
104*0a6a1f1dSLionel Sambuc const BIGNUM *m, BN_CTX *ctx,
105*0a6a1f1dSLionel Sambuc BN_MONT_CTX *m_ctx);
106ebfedea0SLionel Sambuc # endif
107ebfedea0SLionel Sambuc
108ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
109ebfedea0SLionel Sambuc /* DSA stuff */
110ebfedea0SLionel Sambuc static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
111ebfedea0SLionel Sambuc BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
112ebfedea0SLionel Sambuc BN_CTX *ctx, BN_MONT_CTX *in_mont);
113ebfedea0SLionel Sambuc static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
114ebfedea0SLionel Sambuc const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
115ebfedea0SLionel Sambuc BN_MONT_CTX *m_ctx);
116ebfedea0SLionel Sambuc # endif
117ebfedea0SLionel Sambuc
118ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DH
119ebfedea0SLionel Sambuc /* DH stuff */
120ebfedea0SLionel Sambuc /* This function is alised to mod_exp (with the DH and mont dropped). */
121ebfedea0SLionel Sambuc static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
122ebfedea0SLionel Sambuc const BIGNUM *a, const BIGNUM *p,
123*0a6a1f1dSLionel Sambuc const BIGNUM *m, BN_CTX *ctx,
124*0a6a1f1dSLionel Sambuc BN_MONT_CTX *m_ctx);
125ebfedea0SLionel Sambuc # endif
126ebfedea0SLionel Sambuc
127ebfedea0SLionel Sambuc /* The definitions for control commands specific to this engine */
128ebfedea0SLionel Sambuc # define ATALLA_CMD_SO_PATH ENGINE_CMD_BASE
129ebfedea0SLionel Sambuc static const ENGINE_CMD_DEFN atalla_cmd_defns[] = {
130ebfedea0SLionel Sambuc {ATALLA_CMD_SO_PATH,
131ebfedea0SLionel Sambuc "SO_PATH",
132ebfedea0SLionel Sambuc "Specifies the path to the 'atasi' shared library",
133ebfedea0SLionel Sambuc ENGINE_CMD_FLAG_STRING},
134ebfedea0SLionel Sambuc {0, NULL, NULL, 0}
135ebfedea0SLionel Sambuc };
136ebfedea0SLionel Sambuc
137ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
138ebfedea0SLionel Sambuc /* Our internal RSA_METHOD that we provide pointers to */
139*0a6a1f1dSLionel Sambuc static RSA_METHOD atalla_rsa = {
140ebfedea0SLionel Sambuc "Atalla RSA method",
141ebfedea0SLionel Sambuc NULL,
142ebfedea0SLionel Sambuc NULL,
143ebfedea0SLionel Sambuc NULL,
144ebfedea0SLionel Sambuc NULL,
145ebfedea0SLionel Sambuc atalla_rsa_mod_exp,
146ebfedea0SLionel Sambuc atalla_mod_exp_mont,
147ebfedea0SLionel Sambuc NULL,
148ebfedea0SLionel Sambuc NULL,
149ebfedea0SLionel Sambuc 0,
150ebfedea0SLionel Sambuc NULL,
151ebfedea0SLionel Sambuc NULL,
152ebfedea0SLionel Sambuc NULL,
153ebfedea0SLionel Sambuc NULL
154ebfedea0SLionel Sambuc };
155ebfedea0SLionel Sambuc # endif
156ebfedea0SLionel Sambuc
157ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
158ebfedea0SLionel Sambuc /* Our internal DSA_METHOD that we provide pointers to */
159*0a6a1f1dSLionel Sambuc static DSA_METHOD atalla_dsa = {
160ebfedea0SLionel Sambuc "Atalla DSA method",
161ebfedea0SLionel Sambuc NULL, /* dsa_do_sign */
162ebfedea0SLionel Sambuc NULL, /* dsa_sign_setup */
163ebfedea0SLionel Sambuc NULL, /* dsa_do_verify */
164ebfedea0SLionel Sambuc atalla_dsa_mod_exp, /* dsa_mod_exp */
165ebfedea0SLionel Sambuc atalla_mod_exp_dsa, /* bn_mod_exp */
166ebfedea0SLionel Sambuc NULL, /* init */
167ebfedea0SLionel Sambuc NULL, /* finish */
168ebfedea0SLionel Sambuc 0, /* flags */
169ebfedea0SLionel Sambuc NULL, /* app_data */
170ebfedea0SLionel Sambuc NULL, /* dsa_paramgen */
171ebfedea0SLionel Sambuc NULL /* dsa_keygen */
172ebfedea0SLionel Sambuc };
173ebfedea0SLionel Sambuc # endif
174ebfedea0SLionel Sambuc
175ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DH
176ebfedea0SLionel Sambuc /* Our internal DH_METHOD that we provide pointers to */
177*0a6a1f1dSLionel Sambuc static DH_METHOD atalla_dh = {
178ebfedea0SLionel Sambuc "Atalla DH method",
179ebfedea0SLionel Sambuc NULL,
180ebfedea0SLionel Sambuc NULL,
181ebfedea0SLionel Sambuc atalla_mod_exp_dh,
182ebfedea0SLionel Sambuc NULL,
183ebfedea0SLionel Sambuc NULL,
184ebfedea0SLionel Sambuc 0,
185ebfedea0SLionel Sambuc NULL,
186ebfedea0SLionel Sambuc NULL
187ebfedea0SLionel Sambuc };
188ebfedea0SLionel Sambuc # endif
189ebfedea0SLionel Sambuc
190ebfedea0SLionel Sambuc /* Constants used when creating the ENGINE */
191ebfedea0SLionel Sambuc static const char *engine_atalla_id = "atalla";
192ebfedea0SLionel Sambuc static const char *engine_atalla_name = "Atalla hardware engine support";
193ebfedea0SLionel Sambuc
194*0a6a1f1dSLionel Sambuc /*
195*0a6a1f1dSLionel Sambuc * This internal function is used by ENGINE_atalla() and possibly by the
196*0a6a1f1dSLionel Sambuc * "dynamic" ENGINE support too
197*0a6a1f1dSLionel Sambuc */
bind_helper(ENGINE * e)198ebfedea0SLionel Sambuc static int bind_helper(ENGINE *e)
199ebfedea0SLionel Sambuc {
200ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
201ebfedea0SLionel Sambuc const RSA_METHOD *meth1;
202ebfedea0SLionel Sambuc # endif
203ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
204ebfedea0SLionel Sambuc const DSA_METHOD *meth2;
205ebfedea0SLionel Sambuc # endif
206ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DH
207ebfedea0SLionel Sambuc const DH_METHOD *meth3;
208ebfedea0SLionel Sambuc # endif
209ebfedea0SLionel Sambuc if (!ENGINE_set_id(e, engine_atalla_id) ||
210ebfedea0SLionel Sambuc !ENGINE_set_name(e, engine_atalla_name) ||
211ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
212ebfedea0SLionel Sambuc !ENGINE_set_RSA(e, &atalla_rsa) ||
213ebfedea0SLionel Sambuc # endif
214ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
215ebfedea0SLionel Sambuc !ENGINE_set_DSA(e, &atalla_dsa) ||
216ebfedea0SLionel Sambuc # endif
217ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DH
218ebfedea0SLionel Sambuc !ENGINE_set_DH(e, &atalla_dh) ||
219ebfedea0SLionel Sambuc # endif
220ebfedea0SLionel Sambuc !ENGINE_set_destroy_function(e, atalla_destroy) ||
221ebfedea0SLionel Sambuc !ENGINE_set_init_function(e, atalla_init) ||
222ebfedea0SLionel Sambuc !ENGINE_set_finish_function(e, atalla_finish) ||
223ebfedea0SLionel Sambuc !ENGINE_set_ctrl_function(e, atalla_ctrl) ||
224ebfedea0SLionel Sambuc !ENGINE_set_cmd_defns(e, atalla_cmd_defns))
225ebfedea0SLionel Sambuc return 0;
226ebfedea0SLionel Sambuc
227ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
228*0a6a1f1dSLionel Sambuc /*
229*0a6a1f1dSLionel Sambuc * We know that the "PKCS1_SSLeay()" functions hook properly to the
230*0a6a1f1dSLionel Sambuc * atalla-specific mod_exp and mod_exp_crt so we use those functions. NB:
231*0a6a1f1dSLionel Sambuc * We don't use ENGINE_openssl() or anything "more generic" because
232*0a6a1f1dSLionel Sambuc * something like the RSAref code may not hook properly, and if you own
233*0a6a1f1dSLionel Sambuc * one of these cards then you have the right to do RSA operations on it
234*0a6a1f1dSLionel Sambuc * anyway!
235*0a6a1f1dSLionel Sambuc */
236ebfedea0SLionel Sambuc meth1 = RSA_PKCS1_SSLeay();
237ebfedea0SLionel Sambuc atalla_rsa.rsa_pub_enc = meth1->rsa_pub_enc;
238ebfedea0SLionel Sambuc atalla_rsa.rsa_pub_dec = meth1->rsa_pub_dec;
239ebfedea0SLionel Sambuc atalla_rsa.rsa_priv_enc = meth1->rsa_priv_enc;
240ebfedea0SLionel Sambuc atalla_rsa.rsa_priv_dec = meth1->rsa_priv_dec;
241ebfedea0SLionel Sambuc # endif
242ebfedea0SLionel Sambuc
243ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
244*0a6a1f1dSLionel Sambuc /*
245*0a6a1f1dSLionel Sambuc * Use the DSA_OpenSSL() method and just hook the mod_exp-ish bits.
246*0a6a1f1dSLionel Sambuc */
247ebfedea0SLionel Sambuc meth2 = DSA_OpenSSL();
248ebfedea0SLionel Sambuc atalla_dsa.dsa_do_sign = meth2->dsa_do_sign;
249ebfedea0SLionel Sambuc atalla_dsa.dsa_sign_setup = meth2->dsa_sign_setup;
250ebfedea0SLionel Sambuc atalla_dsa.dsa_do_verify = meth2->dsa_do_verify;
251ebfedea0SLionel Sambuc # endif
252ebfedea0SLionel Sambuc
253ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DH
254ebfedea0SLionel Sambuc /* Much the same for Diffie-Hellman */
255ebfedea0SLionel Sambuc meth3 = DH_OpenSSL();
256ebfedea0SLionel Sambuc atalla_dh.generate_key = meth3->generate_key;
257ebfedea0SLionel Sambuc atalla_dh.compute_key = meth3->compute_key;
258ebfedea0SLionel Sambuc # endif
259ebfedea0SLionel Sambuc
260ebfedea0SLionel Sambuc /* Ensure the atalla error handling is set up */
261ebfedea0SLionel Sambuc ERR_load_ATALLA_strings();
262ebfedea0SLionel Sambuc return 1;
263ebfedea0SLionel Sambuc }
264ebfedea0SLionel Sambuc
265ebfedea0SLionel Sambuc # ifdef OPENSSL_NO_DYNAMIC_ENGINE
engine_atalla(void)266ebfedea0SLionel Sambuc static ENGINE *engine_atalla(void)
267ebfedea0SLionel Sambuc {
268ebfedea0SLionel Sambuc ENGINE *ret = ENGINE_new();
269ebfedea0SLionel Sambuc if (!ret)
270ebfedea0SLionel Sambuc return NULL;
271*0a6a1f1dSLionel Sambuc if (!bind_helper(ret)) {
272ebfedea0SLionel Sambuc ENGINE_free(ret);
273ebfedea0SLionel Sambuc return NULL;
274ebfedea0SLionel Sambuc }
275ebfedea0SLionel Sambuc return ret;
276ebfedea0SLionel Sambuc }
277ebfedea0SLionel Sambuc
ENGINE_load_atalla(void)278ebfedea0SLionel Sambuc void ENGINE_load_atalla(void)
279ebfedea0SLionel Sambuc {
280ebfedea0SLionel Sambuc /* Copied from eng_[openssl|dyn].c */
281ebfedea0SLionel Sambuc ENGINE *toadd = engine_atalla();
282*0a6a1f1dSLionel Sambuc if (!toadd)
283*0a6a1f1dSLionel Sambuc return;
284ebfedea0SLionel Sambuc ENGINE_add(toadd);
285ebfedea0SLionel Sambuc ENGINE_free(toadd);
286ebfedea0SLionel Sambuc ERR_clear_error();
287ebfedea0SLionel Sambuc }
288ebfedea0SLionel Sambuc # endif
289ebfedea0SLionel Sambuc
290*0a6a1f1dSLionel Sambuc /*
291*0a6a1f1dSLionel Sambuc * This is a process-global DSO handle used for loading and unloading the
292*0a6a1f1dSLionel Sambuc * Atalla library. NB: This is only set (or unset) during an init() or
293*0a6a1f1dSLionel Sambuc * finish() call (reference counts permitting) and they're operating with
294*0a6a1f1dSLionel Sambuc * global locks, so this should be thread-safe implicitly.
295*0a6a1f1dSLionel Sambuc */
296ebfedea0SLionel Sambuc static DSO *atalla_dso = NULL;
297ebfedea0SLionel Sambuc
298*0a6a1f1dSLionel Sambuc /*
299*0a6a1f1dSLionel Sambuc * These are the function pointers that are (un)set when the library has
300*0a6a1f1dSLionel Sambuc * successfully (un)loaded.
301*0a6a1f1dSLionel Sambuc */
302ebfedea0SLionel Sambuc static tfnASI_GetHardwareConfig *p_Atalla_GetHardwareConfig = NULL;
303ebfedea0SLionel Sambuc static tfnASI_RSAPrivateKeyOpFn *p_Atalla_RSAPrivateKeyOpFn = NULL;
304*0a6a1f1dSLionel Sambuc static tfnASI_GetPerformanceStatistics *p_Atalla_GetPerformanceStatistics =
305*0a6a1f1dSLionel Sambuc NULL;
306ebfedea0SLionel Sambuc
307*0a6a1f1dSLionel Sambuc /*
308*0a6a1f1dSLionel Sambuc * These are the static string constants for the DSO file name and the
309*0a6a1f1dSLionel Sambuc * function symbol names to bind to. Regrettably, the DSO name on *nix
310*0a6a1f1dSLionel Sambuc * appears to be "atasi.so" rather than something more consistent like
311*0a6a1f1dSLionel Sambuc * "libatasi.so". At the time of writing, I'm not sure what the file name on
312*0a6a1f1dSLionel Sambuc * win32 is but clearly native name translation is not possible (eg
313*0a6a1f1dSLionel Sambuc * libatasi.so on *nix, and atasi.dll on win32). For the purposes of testing,
314*0a6a1f1dSLionel Sambuc * I have created a symbollic link called "libatasi.so" so that we can use
315*0a6a1f1dSLionel Sambuc * native name-translation - a better solution will be needed.
316*0a6a1f1dSLionel Sambuc */
317ebfedea0SLionel Sambuc static const char *ATALLA_LIBNAME = NULL;
get_ATALLA_LIBNAME(void)318ebfedea0SLionel Sambuc static const char *get_ATALLA_LIBNAME(void)
319ebfedea0SLionel Sambuc {
320ebfedea0SLionel Sambuc if (ATALLA_LIBNAME)
321ebfedea0SLionel Sambuc return ATALLA_LIBNAME;
322ebfedea0SLionel Sambuc return "atasi";
323ebfedea0SLionel Sambuc }
324*0a6a1f1dSLionel Sambuc
free_ATALLA_LIBNAME(void)325ebfedea0SLionel Sambuc static void free_ATALLA_LIBNAME(void)
326ebfedea0SLionel Sambuc {
327ebfedea0SLionel Sambuc if (ATALLA_LIBNAME)
328ebfedea0SLionel Sambuc OPENSSL_free((void *)ATALLA_LIBNAME);
329ebfedea0SLionel Sambuc ATALLA_LIBNAME = NULL;
330ebfedea0SLionel Sambuc }
331*0a6a1f1dSLionel Sambuc
set_ATALLA_LIBNAME(const char * name)332ebfedea0SLionel Sambuc static long set_ATALLA_LIBNAME(const char *name)
333ebfedea0SLionel Sambuc {
334ebfedea0SLionel Sambuc free_ATALLA_LIBNAME();
335ebfedea0SLionel Sambuc return (((ATALLA_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
336ebfedea0SLionel Sambuc }
337*0a6a1f1dSLionel Sambuc
338ebfedea0SLionel Sambuc static const char *ATALLA_F1 = "ASI_GetHardwareConfig";
339ebfedea0SLionel Sambuc static const char *ATALLA_F2 = "ASI_RSAPrivateKeyOpFn";
340ebfedea0SLionel Sambuc static const char *ATALLA_F3 = "ASI_GetPerformanceStatistics";
341ebfedea0SLionel Sambuc
342ebfedea0SLionel Sambuc /* Destructor (complements the "ENGINE_atalla()" constructor) */
atalla_destroy(ENGINE * e)343ebfedea0SLionel Sambuc static int atalla_destroy(ENGINE *e)
344ebfedea0SLionel Sambuc {
345ebfedea0SLionel Sambuc free_ATALLA_LIBNAME();
346*0a6a1f1dSLionel Sambuc /*
347*0a6a1f1dSLionel Sambuc * Unload the atalla error strings so any error state including our
348ebfedea0SLionel Sambuc * functs or reasons won't lead to a segfault (they simply get displayed
349*0a6a1f1dSLionel Sambuc * without corresponding string data because none will be found).
350*0a6a1f1dSLionel Sambuc */
351ebfedea0SLionel Sambuc ERR_unload_ATALLA_strings();
352ebfedea0SLionel Sambuc return 1;
353ebfedea0SLionel Sambuc }
354ebfedea0SLionel Sambuc
355ebfedea0SLionel Sambuc /* (de)initialisation functions. */
atalla_init(ENGINE * e)356ebfedea0SLionel Sambuc static int atalla_init(ENGINE *e)
357ebfedea0SLionel Sambuc {
358ebfedea0SLionel Sambuc tfnASI_GetHardwareConfig *p1;
359ebfedea0SLionel Sambuc tfnASI_RSAPrivateKeyOpFn *p2;
360ebfedea0SLionel Sambuc tfnASI_GetPerformanceStatistics *p3;
361*0a6a1f1dSLionel Sambuc /*
362*0a6a1f1dSLionel Sambuc * Not sure of the origin of this magic value, but Ben's code had it and
363*0a6a1f1dSLionel Sambuc * it seemed to have been working for a few people. :-)
364*0a6a1f1dSLionel Sambuc */
365ebfedea0SLionel Sambuc unsigned int config_buf[1024];
366ebfedea0SLionel Sambuc
367*0a6a1f1dSLionel Sambuc if (atalla_dso != NULL) {
368ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_ALREADY_LOADED);
369ebfedea0SLionel Sambuc goto err;
370ebfedea0SLionel Sambuc }
371*0a6a1f1dSLionel Sambuc /*
372*0a6a1f1dSLionel Sambuc * Attempt to load libatasi.so/atasi.dll/whatever. Needs to be changed
373*0a6a1f1dSLionel Sambuc * unfortunately because the Atalla drivers don't have standard library
374*0a6a1f1dSLionel Sambuc * names that can be platform-translated well.
375*0a6a1f1dSLionel Sambuc */
376*0a6a1f1dSLionel Sambuc /*
377*0a6a1f1dSLionel Sambuc * TODO: Work out how to actually map to the names the Atalla drivers
378*0a6a1f1dSLionel Sambuc * really use - for now a symbollic link needs to be created on the host
379*0a6a1f1dSLionel Sambuc * system from libatasi.so to atasi.so on unix variants.
380*0a6a1f1dSLionel Sambuc */
381ebfedea0SLionel Sambuc atalla_dso = DSO_load(NULL, get_ATALLA_LIBNAME(), NULL, 0);
382*0a6a1f1dSLionel Sambuc if (atalla_dso == NULL) {
383ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_NOT_LOADED);
384ebfedea0SLionel Sambuc goto err;
385ebfedea0SLionel Sambuc }
386*0a6a1f1dSLionel Sambuc if (!
387*0a6a1f1dSLionel Sambuc (p1 =
388*0a6a1f1dSLionel Sambuc (tfnASI_GetHardwareConfig *) DSO_bind_func(atalla_dso, ATALLA_F1))
389*0a6a1f1dSLionel Sambuc || !(p2 = (tfnASI_RSAPrivateKeyOpFn *) DSO_bind_func(atalla_dso, ATALLA_F2))
390*0a6a1f1dSLionel Sambuc || !(p3 =
391*0a6a1f1dSLionel Sambuc (tfnASI_GetPerformanceStatistics *) DSO_bind_func(atalla_dso,
392*0a6a1f1dSLionel Sambuc ATALLA_F3))) {
393ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_NOT_LOADED);
394ebfedea0SLionel Sambuc goto err;
395ebfedea0SLionel Sambuc }
396ebfedea0SLionel Sambuc /* Copy the pointers */
397ebfedea0SLionel Sambuc p_Atalla_GetHardwareConfig = p1;
398ebfedea0SLionel Sambuc p_Atalla_RSAPrivateKeyOpFn = p2;
399ebfedea0SLionel Sambuc p_Atalla_GetPerformanceStatistics = p3;
400*0a6a1f1dSLionel Sambuc /*
401*0a6a1f1dSLionel Sambuc * Perform a basic test to see if there's actually any unit running.
402*0a6a1f1dSLionel Sambuc */
403*0a6a1f1dSLionel Sambuc if (p1(0L, config_buf) != 0) {
404ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_UNIT_FAILURE);
405ebfedea0SLionel Sambuc goto err;
406ebfedea0SLionel Sambuc }
407ebfedea0SLionel Sambuc /* Everything's fine. */
408ebfedea0SLionel Sambuc return 1;
409ebfedea0SLionel Sambuc err:
410ebfedea0SLionel Sambuc if (atalla_dso)
411ebfedea0SLionel Sambuc DSO_free(atalla_dso);
412ebfedea0SLionel Sambuc atalla_dso = NULL;
413ebfedea0SLionel Sambuc p_Atalla_GetHardwareConfig = NULL;
414ebfedea0SLionel Sambuc p_Atalla_RSAPrivateKeyOpFn = NULL;
415ebfedea0SLionel Sambuc p_Atalla_GetPerformanceStatistics = NULL;
416ebfedea0SLionel Sambuc return 0;
417ebfedea0SLionel Sambuc }
418ebfedea0SLionel Sambuc
atalla_finish(ENGINE * e)419ebfedea0SLionel Sambuc static int atalla_finish(ENGINE *e)
420ebfedea0SLionel Sambuc {
421ebfedea0SLionel Sambuc free_ATALLA_LIBNAME();
422*0a6a1f1dSLionel Sambuc if (atalla_dso == NULL) {
423ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_FINISH, ATALLA_R_NOT_LOADED);
424ebfedea0SLionel Sambuc return 0;
425ebfedea0SLionel Sambuc }
426*0a6a1f1dSLionel Sambuc if (!DSO_free(atalla_dso)) {
427ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_FINISH, ATALLA_R_UNIT_FAILURE);
428ebfedea0SLionel Sambuc return 0;
429ebfedea0SLionel Sambuc }
430ebfedea0SLionel Sambuc atalla_dso = NULL;
431ebfedea0SLionel Sambuc p_Atalla_GetHardwareConfig = NULL;
432ebfedea0SLionel Sambuc p_Atalla_RSAPrivateKeyOpFn = NULL;
433ebfedea0SLionel Sambuc p_Atalla_GetPerformanceStatistics = NULL;
434ebfedea0SLionel Sambuc return 1;
435ebfedea0SLionel Sambuc }
436ebfedea0SLionel Sambuc
atalla_ctrl(ENGINE * e,int cmd,long i,void * p,void (* f)(void))437ebfedea0SLionel Sambuc static int atalla_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
438ebfedea0SLionel Sambuc {
439ebfedea0SLionel Sambuc int initialised = ((atalla_dso == NULL) ? 0 : 1);
440*0a6a1f1dSLionel Sambuc switch (cmd) {
441ebfedea0SLionel Sambuc case ATALLA_CMD_SO_PATH:
442*0a6a1f1dSLionel Sambuc if (p == NULL) {
443ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_CTRL, ERR_R_PASSED_NULL_PARAMETER);
444ebfedea0SLionel Sambuc return 0;
445ebfedea0SLionel Sambuc }
446*0a6a1f1dSLionel Sambuc if (initialised) {
447ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_CTRL, ATALLA_R_ALREADY_LOADED);
448ebfedea0SLionel Sambuc return 0;
449ebfedea0SLionel Sambuc }
450ebfedea0SLionel Sambuc return set_ATALLA_LIBNAME((const char *)p);
451ebfedea0SLionel Sambuc default:
452ebfedea0SLionel Sambuc break;
453ebfedea0SLionel Sambuc }
454ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_CTRL, ATALLA_R_CTRL_COMMAND_NOT_IMPLEMENTED);
455ebfedea0SLionel Sambuc return 0;
456ebfedea0SLionel Sambuc }
457ebfedea0SLionel Sambuc
atalla_mod_exp(BIGNUM * r,const BIGNUM * a,const BIGNUM * p,const BIGNUM * m,BN_CTX * ctx)458ebfedea0SLionel Sambuc static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
459ebfedea0SLionel Sambuc const BIGNUM *m, BN_CTX *ctx)
460ebfedea0SLionel Sambuc {
461*0a6a1f1dSLionel Sambuc /*
462*0a6a1f1dSLionel Sambuc * I need somewhere to store temporary serialised values for use with the
463*0a6a1f1dSLionel Sambuc * Atalla API calls. A neat cheat - I'll use BIGNUMs from the BN_CTX but
464*0a6a1f1dSLionel Sambuc * access their arrays directly as byte arrays <grin>. This way I don't
465*0a6a1f1dSLionel Sambuc * have to clean anything up.
466*0a6a1f1dSLionel Sambuc */
467ebfedea0SLionel Sambuc BIGNUM *modulus;
468ebfedea0SLionel Sambuc BIGNUM *exponent;
469ebfedea0SLionel Sambuc BIGNUM *argument;
470ebfedea0SLionel Sambuc BIGNUM *result;
471ebfedea0SLionel Sambuc RSAPrivateKey keydata;
472ebfedea0SLionel Sambuc int to_return, numbytes;
473ebfedea0SLionel Sambuc
474ebfedea0SLionel Sambuc modulus = exponent = argument = result = NULL;
475ebfedea0SLionel Sambuc to_return = 0; /* expect failure */
476ebfedea0SLionel Sambuc
477*0a6a1f1dSLionel Sambuc if (!atalla_dso) {
478ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_MOD_EXP, ATALLA_R_NOT_LOADED);
479ebfedea0SLionel Sambuc goto err;
480ebfedea0SLionel Sambuc }
481ebfedea0SLionel Sambuc /* Prepare the params */
482ebfedea0SLionel Sambuc BN_CTX_start(ctx);
483ebfedea0SLionel Sambuc modulus = BN_CTX_get(ctx);
484ebfedea0SLionel Sambuc exponent = BN_CTX_get(ctx);
485ebfedea0SLionel Sambuc argument = BN_CTX_get(ctx);
486ebfedea0SLionel Sambuc result = BN_CTX_get(ctx);
487*0a6a1f1dSLionel Sambuc if (!result) {
488ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_MOD_EXP, ATALLA_R_BN_CTX_FULL);
489ebfedea0SLionel Sambuc goto err;
490ebfedea0SLionel Sambuc }
491ebfedea0SLionel Sambuc if (!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, m->top) ||
492*0a6a1f1dSLionel Sambuc !bn_wexpand(argument, m->top) || !bn_wexpand(result, m->top)) {
493ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_MOD_EXP, ATALLA_R_BN_EXPAND_FAIL);
494ebfedea0SLionel Sambuc goto err;
495ebfedea0SLionel Sambuc }
496ebfedea0SLionel Sambuc /* Prepare the key-data */
497ebfedea0SLionel Sambuc memset(&keydata, 0, sizeof keydata);
498ebfedea0SLionel Sambuc numbytes = BN_num_bytes(m);
499ebfedea0SLionel Sambuc memset(exponent->d, 0, numbytes);
500ebfedea0SLionel Sambuc memset(modulus->d, 0, numbytes);
501ebfedea0SLionel Sambuc BN_bn2bin(p, (unsigned char *)exponent->d + numbytes - BN_num_bytes(p));
502ebfedea0SLionel Sambuc BN_bn2bin(m, (unsigned char *)modulus->d + numbytes - BN_num_bytes(m));
503ebfedea0SLionel Sambuc keydata.privateExponent.data = (unsigned char *)exponent->d;
504ebfedea0SLionel Sambuc keydata.privateExponent.len = numbytes;
505ebfedea0SLionel Sambuc keydata.modulus.data = (unsigned char *)modulus->d;
506ebfedea0SLionel Sambuc keydata.modulus.len = numbytes;
507ebfedea0SLionel Sambuc /* Prepare the argument */
508ebfedea0SLionel Sambuc memset(argument->d, 0, numbytes);
509ebfedea0SLionel Sambuc memset(result->d, 0, numbytes);
510ebfedea0SLionel Sambuc BN_bn2bin(a, (unsigned char *)argument->d + numbytes - BN_num_bytes(a));
511ebfedea0SLionel Sambuc /* Perform the operation */
512ebfedea0SLionel Sambuc if (p_Atalla_RSAPrivateKeyOpFn(&keydata, (unsigned char *)result->d,
513ebfedea0SLionel Sambuc (unsigned char *)argument->d,
514*0a6a1f1dSLionel Sambuc keydata.modulus.len) != 0) {
515ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_MOD_EXP, ATALLA_R_REQUEST_FAILED);
516ebfedea0SLionel Sambuc goto err;
517ebfedea0SLionel Sambuc }
518ebfedea0SLionel Sambuc /* Convert the response */
519ebfedea0SLionel Sambuc BN_bin2bn((unsigned char *)result->d, numbytes, r);
520ebfedea0SLionel Sambuc to_return = 1;
521ebfedea0SLionel Sambuc err:
522ebfedea0SLionel Sambuc BN_CTX_end(ctx);
523ebfedea0SLionel Sambuc return to_return;
524ebfedea0SLionel Sambuc }
525ebfedea0SLionel Sambuc
526ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
atalla_rsa_mod_exp(BIGNUM * r0,const BIGNUM * I,RSA * rsa,BN_CTX * ctx)527*0a6a1f1dSLionel Sambuc static int atalla_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa,
528*0a6a1f1dSLionel Sambuc BN_CTX *ctx)
529ebfedea0SLionel Sambuc {
530ebfedea0SLionel Sambuc int to_return = 0;
531ebfedea0SLionel Sambuc
532*0a6a1f1dSLionel Sambuc if (!atalla_dso) {
533ebfedea0SLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP, ATALLA_R_NOT_LOADED);
534ebfedea0SLionel Sambuc goto err;
535ebfedea0SLionel Sambuc }
536*0a6a1f1dSLionel Sambuc if (!rsa->d || !rsa->n) {
537*0a6a1f1dSLionel Sambuc ATALLAerr(ATALLA_F_ATALLA_RSA_MOD_EXP,
538*0a6a1f1dSLionel Sambuc ATALLA_R_MISSING_KEY_COMPONENTS);
539ebfedea0SLionel Sambuc goto err;
540ebfedea0SLionel Sambuc }
541ebfedea0SLionel Sambuc to_return = atalla_mod_exp(r0, I, rsa->d, rsa->n, ctx);
542ebfedea0SLionel Sambuc err:
543ebfedea0SLionel Sambuc return to_return;
544ebfedea0SLionel Sambuc }
545ebfedea0SLionel Sambuc # endif
546ebfedea0SLionel Sambuc
547ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DSA
548*0a6a1f1dSLionel Sambuc /*
549*0a6a1f1dSLionel Sambuc * This code was liberated and adapted from the commented-out code in
550*0a6a1f1dSLionel Sambuc * dsa_ossl.c. Because of the unoptimised form of the Atalla acceleration (it
551*0a6a1f1dSLionel Sambuc * doesn't have a CRT form for RSA), this function means that an Atalla
552*0a6a1f1dSLionel Sambuc * system running with a DSA server certificate can handshake around 5 or 6
553*0a6a1f1dSLionel Sambuc * times faster/more than an equivalent system running with RSA. Just check
554*0a6a1f1dSLionel Sambuc * out the "signs" statistics from the RSA and DSA parts of "openssl speed
555*0a6a1f1dSLionel Sambuc * -engine atalla dsa1024 rsa1024".
556*0a6a1f1dSLionel Sambuc */
atalla_dsa_mod_exp(DSA * dsa,BIGNUM * rr,BIGNUM * a1,BIGNUM * p1,BIGNUM * a2,BIGNUM * p2,BIGNUM * m,BN_CTX * ctx,BN_MONT_CTX * in_mont)557ebfedea0SLionel Sambuc static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
558ebfedea0SLionel Sambuc BIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
559ebfedea0SLionel Sambuc BN_CTX *ctx, BN_MONT_CTX *in_mont)
560ebfedea0SLionel Sambuc {
561ebfedea0SLionel Sambuc BIGNUM t;
562ebfedea0SLionel Sambuc int to_return = 0;
563ebfedea0SLionel Sambuc
564ebfedea0SLionel Sambuc BN_init(&t);
565ebfedea0SLionel Sambuc /* let rr = a1 ^ p1 mod m */
566*0a6a1f1dSLionel Sambuc if (!atalla_mod_exp(rr, a1, p1, m, ctx))
567*0a6a1f1dSLionel Sambuc goto end;
568ebfedea0SLionel Sambuc /* let t = a2 ^ p2 mod m */
569*0a6a1f1dSLionel Sambuc if (!atalla_mod_exp(&t, a2, p2, m, ctx))
570*0a6a1f1dSLionel Sambuc goto end;
571ebfedea0SLionel Sambuc /* let rr = rr * t mod m */
572*0a6a1f1dSLionel Sambuc if (!BN_mod_mul(rr, rr, &t, m, ctx))
573*0a6a1f1dSLionel Sambuc goto end;
574ebfedea0SLionel Sambuc to_return = 1;
575ebfedea0SLionel Sambuc end:
576ebfedea0SLionel Sambuc BN_free(&t);
577ebfedea0SLionel Sambuc return to_return;
578ebfedea0SLionel Sambuc }
579ebfedea0SLionel Sambuc
atalla_mod_exp_dsa(DSA * dsa,BIGNUM * r,BIGNUM * a,const BIGNUM * p,const BIGNUM * m,BN_CTX * ctx,BN_MONT_CTX * m_ctx)580ebfedea0SLionel Sambuc static int atalla_mod_exp_dsa(DSA *dsa, BIGNUM *r, BIGNUM *a,
581ebfedea0SLionel Sambuc const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
582ebfedea0SLionel Sambuc BN_MONT_CTX *m_ctx)
583ebfedea0SLionel Sambuc {
584ebfedea0SLionel Sambuc return atalla_mod_exp(r, a, p, m, ctx);
585ebfedea0SLionel Sambuc }
586ebfedea0SLionel Sambuc # endif
587ebfedea0SLionel Sambuc
588ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_RSA
589ebfedea0SLionel Sambuc /* This function is aliased to mod_exp (with the mont stuff dropped). */
atalla_mod_exp_mont(BIGNUM * r,const BIGNUM * a,const BIGNUM * p,const BIGNUM * m,BN_CTX * ctx,BN_MONT_CTX * m_ctx)590ebfedea0SLionel Sambuc static int atalla_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
591*0a6a1f1dSLionel Sambuc const BIGNUM *m, BN_CTX *ctx,
592*0a6a1f1dSLionel Sambuc BN_MONT_CTX *m_ctx)
593ebfedea0SLionel Sambuc {
594ebfedea0SLionel Sambuc return atalla_mod_exp(r, a, p, m, ctx);
595ebfedea0SLionel Sambuc }
596ebfedea0SLionel Sambuc # endif
597ebfedea0SLionel Sambuc
598ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DH
599ebfedea0SLionel Sambuc /* This function is aliased to mod_exp (with the dh and mont dropped). */
atalla_mod_exp_dh(const DH * dh,BIGNUM * r,const BIGNUM * a,const BIGNUM * p,const BIGNUM * m,BN_CTX * ctx,BN_MONT_CTX * m_ctx)600ebfedea0SLionel Sambuc static int atalla_mod_exp_dh(const DH *dh, BIGNUM *r,
601ebfedea0SLionel Sambuc const BIGNUM *a, const BIGNUM *p,
602ebfedea0SLionel Sambuc const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx)
603ebfedea0SLionel Sambuc {
604ebfedea0SLionel Sambuc return atalla_mod_exp(r, a, p, m, ctx);
605ebfedea0SLionel Sambuc }
606ebfedea0SLionel Sambuc # endif
607ebfedea0SLionel Sambuc
608*0a6a1f1dSLionel Sambuc /*
609*0a6a1f1dSLionel Sambuc * This stuff is needed if this ENGINE is being compiled into a
610*0a6a1f1dSLionel Sambuc * self-contained shared-library.
611*0a6a1f1dSLionel Sambuc */
612ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DYNAMIC_ENGINE
bind_fn(ENGINE * e,const char * id)613ebfedea0SLionel Sambuc static int bind_fn(ENGINE *e, const char *id)
614ebfedea0SLionel Sambuc {
615ebfedea0SLionel Sambuc if (id && (strcmp(id, engine_atalla_id) != 0))
616ebfedea0SLionel Sambuc return 0;
617ebfedea0SLionel Sambuc if (!bind_helper(e))
618ebfedea0SLionel Sambuc return 0;
619ebfedea0SLionel Sambuc return 1;
620ebfedea0SLionel Sambuc }
621*0a6a1f1dSLionel Sambuc
622ebfedea0SLionel Sambuc IMPLEMENT_DYNAMIC_CHECK_FN()
623ebfedea0SLionel Sambuc IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
624ebfedea0SLionel Sambuc # endif /* OPENSSL_NO_DYNAMIC_ENGINE */
625ebfedea0SLionel Sambuc # endif /* !OPENSSL_NO_HW_ATALLA */
626ebfedea0SLionel Sambuc #endif /* !OPENSSL_NO_HW */
627