Add the possibility to build without the ENGINE framework.
[openssl.git] / crypto / rsa / rsa_lib.c
index 93235744f7a9e365ec03a244e739ac02a6637b0d..889c36d3a6f4b5ddc3e3829c0b02c8192366e4ab 100644 (file)
@@ -62,7 +62,9 @@
 #include <openssl/lhash.h>
 #include <openssl/bn.h>
 #include <openssl/rsa.h>
+#ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
+#endif
 
 const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT;
 
@@ -108,11 +110,13 @@ int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
        const RSA_METHOD *mtmp;
        mtmp = rsa->meth;
        if (mtmp->finish) mtmp->finish(rsa);
+#ifndef OPENSSL_NO_ENGINE
        if (rsa->engine)
                {
                ENGINE_finish(rsa->engine);
                rsa->engine = NULL;
                }
+#endif
        rsa->meth = meth;
        if (meth->init) meth->init(rsa);
        return 1;
@@ -130,6 +134,7 @@ RSA *RSA_new_method(ENGINE *engine)
                }
 
        ret->meth = RSA_get_default_method();
+#ifndef OPENSSL_NO_ENGINE
        if (engine)
                {
                if (!ENGINE_init(engine))
@@ -154,6 +159,7 @@ RSA *RSA_new_method(ENGINE *engine)
                        return NULL;
                        }
                }
+#endif
 
        ret->pad=0;
        ret->version=0;
@@ -175,8 +181,10 @@ RSA *RSA_new_method(ENGINE *engine)
        CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
        if ((ret->meth->init != NULL) && !ret->meth->init(ret))
                {
+#ifndef OPENSSL_NO_ENGINE
                if (ret->engine)
                        ENGINE_finish(ret->engine);
+#endif
                CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
                OPENSSL_free(ret);
                ret=NULL;
@@ -205,8 +213,10 @@ void RSA_free(RSA *r)
 
        if (r->meth->finish)
                r->meth->finish(r);
+#ifndef OPENSSL_NO_ENGINE
        if (r->engine)
                ENGINE_finish(r->engine);
+#endif
 
        CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);