Fix various incorrect error function codes.
[openssl.git] / crypto / ecdh / ech_lib.c
index a0e4ef45f0d5ddd5fc776582acf9e6be2a83acd6..7e36cbdab732a532bb98bb0c5d67cc8895edee98 100644 (file)
@@ -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 @@ int ECDH_set_method(EC_KEY *eckey, const ECDH_METHOD *meth)
         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) 
@@ -130,7 +134,7 @@ ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine)
        ret=(ECDH_DATA *)OPENSSL_malloc(sizeof(ECDH_DATA));
        if (ret == NULL)
                {
-               ECDHerr(ECDH_F_ECDH_DATA_NEW, ERR_R_MALLOC_FAILURE);
+               ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_MALLOC_FAILURE);
                return(NULL);
                }
 
@@ -139,6 +143,7 @@ ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine)
 
        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)
@@ -146,12 +151,13 @@ ECDH_DATA *ECDH_DATA_new_method(ENGINE *engine)
                ret->meth = ENGINE_get_ECDH(ret->engine);
                if (!ret->meth)
                        {
-                       ECDHerr(ECDH_F_ECDH_DATA_NEW, ERR_R_ENGINE_LIB);
+                       ECDHerr(ECDH_F_ECDH_DATA_NEW_METHOD, ERR_R_ENGINE_LIB);
                        ENGINE_finish(ret->engine);
                        OPENSSL_free(ret);
                        return NULL;
                        }
                }
+#endif
 
        ret->flags = ret->meth->flags;
        CRYPTO_new_ex_data(CRYPTO_EX_INDEX_ECDH, ret, &ret->ex_data);
@@ -172,8 +178,10 @@ void ECDH_DATA_free(ECDH_DATA *r)
        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);