X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=engines%2Fe_chil.c;h=04f2a535de6bcee19095eef75d7f12dda0ceabf1;hp=14654a783325190f55090b4b997537927bab5c8f;hb=2e0c7db95002686b8b2eb8da6ba40fab1e7b93b1;hpb=a2c32e2d7fbd275d22b42532139ef237bc83aa06 diff --git a/engines/e_chil.c b/engines/e_chil.c index 14654a7833..04f2a535de 100644 --- a/engines/e_chil.c +++ b/engines/e_chil.c @@ -1,4 +1,4 @@ -/* crypto/engine/hw_ncipher.c -*- mode: C; c-file-style: "eay" -*- */ +/* crypto/engine/e_chil.c -*- mode: C; c-file-style: "eay" -*- */ /* Written by Richard Levitte (richard@levitte.org), Geoff Thorpe * (geoff@geoffthorpe.net) and Dr Stephen N Henson (shenson@bigfoot.com) * for the OpenSSL project 2000. @@ -65,12 +65,16 @@ #include #include #include +#ifndef OPENSSL_NO_RSA #include +#endif +#ifndef OPENSSL_NO_DH #include +#endif #include #ifndef OPENSSL_NO_HW -#ifndef OPENSSL_NO_HW_NCIPHER +#ifndef OPENSSL_NO_HW_CHIL /* Attribution notice: nCipher have said several times that it's OK for * us to implement a general interface to their boxes, and recently declared @@ -86,7 +90,7 @@ #include "vendor_defns/hwcryptohook.h" #endif -#define HWCRHK_LIB_NAME "hwcrhk engine" +#define HWCRHK_LIB_NAME "CHIL engine" #include "e_chil_err.c" static int hwcrhk_destroy(ENGINE *e); @@ -108,9 +112,11 @@ static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, /* RSA stuff */ static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); #endif +#ifndef OPENSSL_NO_RSA /* This function is aliased to mod_exp (with the mont stuff dropped). */ static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); +#endif #ifndef OPENSSL_NO_DH /* DH stuff */ @@ -129,8 +135,10 @@ static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id, UI_METHOD *ui_method, void *callback_data); static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id, UI_METHOD *ui_method, void *callback_data); +#ifndef OPENSSL_NO_RSA static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int ind,long argl, void *argp); +#endif /* Interaction stuff */ static int hwcrhk_insert_card(const char *prompt_info, @@ -177,7 +185,7 @@ static const ENGINE_CMD_DEFN hwcrhk_cmd_defns[] = { /* Our internal RSA_METHOD that we provide pointers to */ static RSA_METHOD hwcrhk_rsa = { - "nCipher RSA method", + "CHIL RSA method", NULL, NULL, NULL, @@ -198,7 +206,7 @@ static RSA_METHOD hwcrhk_rsa = /* Our internal DH_METHOD that we provide pointers to */ static DH_METHOD hwcrhk_dh = { - "nCipher DH method", + "CHIL DH method", NULL, NULL, hwcrhk_mod_exp_dh, @@ -212,7 +220,7 @@ static DH_METHOD hwcrhk_dh = static RAND_METHOD hwcrhk_rand = { - /* "nCipher RAND method", */ + /* "CHIL RAND method", */ NULL, hwcrhk_rand_bytes, NULL, @@ -223,9 +231,11 @@ static RAND_METHOD hwcrhk_rand = /* Constants used when creating the ENGINE */ static const char *engine_hwcrhk_id = "chil"; -static const char *engine_hwcrhk_name = "nCipher hardware engine support"; +static const char *engine_hwcrhk_name = "CHIL hardware engine support"; +#ifndef OPENSSL_NO_DYNAMIC_ENGINE /* Compatibility hack, the dynamic library uses this form in the path */ static const char *engine_hwcrhk_id_alt = "ncipher"; +#endif /* Internal stuff for HWCryptoHook */ @@ -325,7 +335,7 @@ static HWCryptoHook_InitInfo hwcrhk_globals = { /* Now, to our own code */ -/* This internal function is used by ENGINE_ncipher() and possibly by the +/* This internal function is used by ENGINE_chil() and possibly by the * "dynamic" ENGINE support too */ static int bind_helper(ENGINE *e) { @@ -381,7 +391,7 @@ static int bind_helper(ENGINE *e) } #ifdef OPENSSL_NO_DYNAMIC_ENGINE -static ENGINE *engine_ncipher(void) +static ENGINE *engine_chil(void) { ENGINE *ret = ENGINE_new(); if(!ret) @@ -397,7 +407,7 @@ static ENGINE *engine_ncipher(void) void ENGINE_load_chil(void) { /* Copied from eng_[openssl|dyn].c */ - ENGINE *toadd = engine_ncipher(); + ENGINE *toadd = engine_chil(); if(!toadd) return; ENGINE_add(toadd); ENGINE_free(toadd); @@ -493,7 +503,7 @@ static void release_context(HWCryptoHook_ContextHandle hac) p_hwcrhk_Finish(hac); } -/* Destructor (complements the "ENGINE_ncipher()" constructor) */ +/* Destructor (complements the "ENGINE_chil()" constructor) */ static int hwcrhk_destroy(ENGINE *e) { free_HWCRHK_LIBNAME(); @@ -760,8 +770,8 @@ static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id, #if !defined(OPENSSL_NO_RSA) char tempbuf[1024]; HWCryptoHook_ErrMsgBuf rmsg; -#endif HWCryptoHook_PassphraseContext ppctx; +#endif #if !defined(OPENSSL_NO_RSA) rmsg.buf = tempbuf; @@ -842,8 +852,6 @@ static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id, return res; err: - if (res) - EVP_PKEY_free(res); #ifndef OPENSSL_NO_RSA if (rtmp) RSA_free(rtmp); @@ -1069,12 +1077,14 @@ err: } #endif +#ifndef OPENSSL_NO_RSA /* This function is aliased to mod_exp (with the mont stuff dropped). */ static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx) { return hwcrhk_mod_exp(r, a, p, m, ctx); } +#endif #ifndef OPENSSL_NO_DH /* This function is aliased to mod_exp (with the dh and mont dropped). */ @@ -1133,7 +1143,7 @@ static int hwcrhk_rand_status(void) } /* This cleans up an RSA KM key, called when ex_data is freed */ - +#ifndef OPENSSL_NO_RSA static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, int ind,long argl, void *argp) { @@ -1158,6 +1168,7 @@ static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad, } #endif } +#endif /* Mutex calls: since the HWCryptoHook model closely follows the POSIX model * these just wrap the POSIX functions and add some logging. @@ -1356,5 +1367,5 @@ IMPLEMENT_DYNAMIC_CHECK_FN() IMPLEMENT_DYNAMIC_BIND_FN(bind_fn) #endif /* OPENSSL_NO_DYNAMIC_ENGINE */ -#endif /* !OPENSSL_NO_HW_NCIPHER */ +#endif /* !OPENSSL_NO_HW_CHIL */ #endif /* !OPENSSL_NO_HW */