Update ECDSA and ECDH for OPENSSL_NO_ENGINE.

Reported by: Maxim Masiutin
Submitted by: Nils Larsch
diff --git a/apps/ec.c b/apps/ec.c
index 7d57341..392e6a2 100644
--- a/apps/ec.c
+++ b/apps/ec.c
@@ -84,7 +84,9 @@
 
 int MAIN(int argc, char **argv)
 {
+#ifndef OPENSSL_NO_ENGINE
 	ENGINE 	*e = NULL;
+#endif
 	int 	ret = 1;
 	EC_KEY 	*eckey = NULL;
 	int 	i, badops = 0;
@@ -249,7 +251,9 @@
 
 	ERR_load_crypto_strings();
 
+#ifndef OPENSSL_NO_ENGINE
         e = setup_engine(bio_err, engine, 0);
+#endif
 
 	if(!app_passwd(bio_err, passargin, passargout, &passin, &passout)) 
 		{
diff --git a/apps/ecparam.c b/apps/ecparam.c
index ae046f9..29d215e 100644
--- a/apps/ecparam.c
+++ b/apps/ecparam.c
@@ -127,7 +127,9 @@
 	char	*infile = NULL, *outfile = NULL, *prog;
 	BIO 	*in = NULL, *out = NULL;
 	int 	informat, outformat, noout = 0, C = 0, ret = 1;
+#ifndef OPENSSL_NO_ENGINE
 	ENGINE	*e = NULL;
+#endif
 	char	*engine = NULL;
 
 	BIGNUM	*ec_p = NULL, *ec_a = NULL, *ec_b = NULL,
@@ -335,7 +337,9 @@
 			}
 		}
 
+#ifndef OPENSSL_NO_ENGINE
 	e = setup_engine(bio_err, engine, 0);
+#endif
 
 	if (list_curves)
 		{
diff --git a/crypto/ecdh/ech_key.c b/crypto/ecdh/ech_key.c
index 923a7e9..7d1bb32 100644
--- a/crypto/ecdh/ech_key.c
+++ b/crypto/ecdh/ech_key.c
@@ -68,7 +68,9 @@
  */
 
 #include "ecdh.h"
+#ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
+#endif
 
 int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, EC_KEY *eckey,
                      void *(*KDF)(void *in, size_t inlen, void *out, size_t outlen))
diff --git a/crypto/ecdh/ech_lib.c b/crypto/ecdh/ech_lib.c
index a0e4ef4..f2abfed 100644
--- a/crypto/ecdh/ech_lib.c
+++ b/crypto/ecdh/ech_lib.c
@@ -69,7 +69,9 @@
 
 #include "ecdh.h"
 #include <string.h>
+#ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
+#endif
 #include <openssl/err.h>
 
 const char *ECDH_version="ECDH" OPENSSL_VERSION_PTEXT;
@@ -105,11 +107,13 @@
         if (mtmp->finish)
 		mtmp->finish(eckey);
 #endif
+#ifndef OPENSSL_NO_ENGINE
 	if (ecdh->engine)
 		{
 		ENGINE_finish(ecdh->engine);
 		ecdh->engine = NULL;
 		}
+#endif
         ecdh->meth = meth;
 #if 0
         if (meth->init) 
@@ -139,6 +143,7 @@
 
 	ret->meth = ECDH_get_default_method();
 	ret->engine = engine;
+#ifndef OPENSSL_NO_ENGINE
 	if (!ret->engine)
 		ret->engine = ENGINE_get_default_ECDH();
 	if (ret->engine)
@@ -152,6 +157,7 @@
 			return NULL;
 			}
 		}
+#endif
 
 	ret->flags = ret->meth->flags;
 	CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDH, ret, &ret->ex_data);
@@ -172,8 +178,10 @@
 	if (r->meth->finish)
 		r->meth->finish(r);
 #endif
+#ifndef OPENSSL_NO_ENGINE
 	if (r->engine)
 		ENGINE_finish(r->engine);
+#endif
 
 	CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDH, r, &r->ex_data);
 
diff --git a/crypto/ecdsa/ecs_lib.c b/crypto/ecdsa/ecs_lib.c
index d553ea1..e355a35 100644
--- a/crypto/ecdsa/ecs_lib.c
+++ b/crypto/ecdsa/ecs_lib.c
@@ -55,7 +55,9 @@
 
 #include <string.h>
 #include "ecdsa.h"
+#ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
+#endif
 #include <openssl/err.h>
 #include <openssl/bn.h>
 
@@ -92,11 +94,13 @@
         if (mtmp->finish)
 		mtmp->finish(eckey);
 #endif
+#ifndef OPENSSL_NO_ENGINE
 	if (ecdsa->engine)
 	{
 		ENGINE_finish(ecdsa->engine);
 		ecdsa->engine = NULL;
 	}
+#endif
         ecdsa->meth = meth;
 #if 0
         if (meth->init) 
@@ -129,6 +133,7 @@
 
 	ret->meth = ECDSA_get_default_method();
 	ret->engine = engine;
+#ifndef OPENSSL_NO_ENGINE
 	if (!ret->engine)
 		ret->engine = ENGINE_get_default_ECDSA();
 	if (ret->engine)
@@ -142,6 +147,7 @@
 			return NULL;
 		}
 	}
+#endif
 
 	ret->flags = ret->meth->flags;
 	CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDSA, ret, &ret->ex_data);
@@ -167,8 +173,10 @@
 	if (r->meth->finish)
 		r->meth->finish(r);
 #endif
+#ifndef OPENSSL_NO_ENGINE
 	if (r->engine)
 		ENGINE_finish(r->engine);
+#endif
 
 	CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data);
 
diff --git a/crypto/ecdsa/ecs_sign.c b/crypto/ecdsa/ecs_sign.c
index 215da12..4667c8c 100644
--- a/crypto/ecdsa/ecs_sign.c
+++ b/crypto/ecdsa/ecs_sign.c
@@ -54,7 +54,9 @@
  */
 
 #include "ecdsa.h"
+#ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
+#endif
 
 ECDSA_SIG * ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
 {
diff --git a/crypto/ecdsa/ecs_vrf.c b/crypto/ecdsa/ecs_vrf.c
index 269671b..15a6ab4 100644
--- a/crypto/ecdsa/ecs_vrf.c
+++ b/crypto/ecdsa/ecs_vrf.c
@@ -54,7 +54,9 @@
  */
 
 #include "ecdsa.h"
+#ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
+#endif
 
 /* returns
  *      1: correct signature