#include <openssl/crypto.h>
#include "cryptlib.h"
#include <openssl/dso.h>
-#include "engine_int.h"
#include <openssl/engine.h>
#ifndef OPENSSL_NO_HW
#include "vendor_defns/hw_ubsec.h"
#endif
-static int ubsec_init(void);
-static int ubsec_finish(void);
+static int ubsec_init(ENGINE *e);
+static int ubsec_finish(ENGINE *e);
static int ubsec_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx);
static int ubsec_mod_exp_crt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
NULL
};
-/* Our ENGINE structure. */
-static ENGINE engine_ubsec =
- {
- "ubsec",
- "UBSEC hardware engine support",
- &ubsec_rsa,
- &ubsec_dsa,
- &ubsec_dh,
- NULL,
- ubsec_mod_exp,
- ubsec_mod_exp_crt,
- ubsec_init,
- ubsec_finish,
- NULL, /* no ctrl() */
- NULL, /* no load_privkey() */
- NULL, /* no load_pubkey() */
- 0, /* no flags */
- 0, 0, /* no references */
- NULL, NULL /* unlinked */
- };
+/* Constants used when creating the ENGINE */
+static const char *engine_ubsec_id = "ubsec";
+static const char *engine_ubsec_name = "UBSEC hardware engine support";
/* As this is only ever called once, there's no need for locking
* (indeed - the lock will already be held by our caller!!!) */
#ifndef HAVE_UBSEC_DH
const DH_METHOD *meth3;
#endif /* HAVE_UBSEC_DH */
+ ENGINE *ret = ENGINE_new();
+ if(!ret)
+ return NULL;
+ if(!ENGINE_set_id(ret, engine_ubsec_id) ||
+ !ENGINE_set_name(ret, engine_ubsec_name) ||
+ !ENGINE_set_RSA(ret, &ubsec_rsa) ||
+ !ENGINE_set_DSA(ret, &ubsec_dsa) ||
+ !ENGINE_set_DH(ret, &ubsec_dh) ||
+ !ENGINE_set_BN_mod_exp(ret, ubsec_mod_exp) ||
+ !ENGINE_set_BN_mod_exp_crt(ret, ubsec_mod_exp_crt) ||
+ !ENGINE_set_init_function(ret, ubsec_init) ||
+ !ENGINE_set_finish_function(ret, ubsec_finish))
+ {
+ ENGINE_free(ret);
+ return NULL;
+ }
/* We know that the "PKCS1_SSLeay()" functions hook properly
* to the Broadcom-specific mod_exp and mod_exp_crt so we use
ubsec_dh.compute_key = meth3->compute_key;
#endif /* HAVE_UBSEC_DH */
- return &engine_ubsec;
+ return ret;
}
/* This is a process-global DSO handle used for loading and unloading
static t_UBSEC_math_accelerate_ioctl *p_UBSEC_math_accelerate_ioctl = NULL;
static t_UBSEC_rng_ioctl *p_UBSEC_rng_ioctl = NULL;
+/*
+ * These are the static string constants for the DSO file name and the function
+ * symbol names to bind to.
+ */
+
+static const char *UBSEC_LIBNAME = "ubsec";
+static const char *UBSEC_F1 = "ubsec_bytes_to_bits";
+static const char *UBSEC_F2 = "ubsec_bits_to_bytes";
+static const char *UBSEC_F3 = "ubsec_open";
+static const char *UBSEC_F4 = "ubsec_close";
+static const char *UBSEC_F5 = "diffie_hellman_generate_ioctl";
+static const char *UBSEC_F6 = "diffie_hellman_agree_ioctl";
+static const char *UBSEC_F7 = "rsa_mod_exp_ioctl";
+static const char *UBSEC_F8 = "rsa_mod_exp_crt_ioctl";
+static const char *UBSEC_F9 = "dsa_sign_ioctl";
+static const char *UBSEC_F10 = "dsa_verify_ioctl";
+static const char *UBSEC_F11 = "math_accelerate_ioctl";
+static const char *UBSEC_F12 = "rng_ioctl";
+
/* (de)initialisation functions. */
-static int ubsec_init()
+static int ubsec_init(ENGINE *e)
{
t_UBSEC_ubsec_bytes_to_bits *p1;
t_UBSEC_ubsec_bits_to_bytes *p2;
return 0;
}
-static int ubsec_finish()
+static int ubsec_finish(ENGINE *e)
{
if(ubsec_dso == NULL)
{