aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Freitas <nathan@freitas.net>2009-09-29 00:46:53 -0400
committerNick Mathewson <nickm@torproject.org>2009-09-29 00:53:10 -0400
commit76d26ae52d655e9fd0549eacbba9c7e2d5c05cc4 (patch)
tree8a6a58ee2d1ba02f0cb8c6c4c9cc75f38c17e465
parent8c585cce3987b04335acc6eebaa9ded3216b6e13 (diff)
downloadtor-76d26ae52d655e9fd0549eacbba9c7e2d5c05cc4.tar.gz
tor-76d26ae52d655e9fd0549eacbba9c7e2d5c05cc4.zip
Disable OpenSSL engines when building for Android.
Apparently the Android developers dumped OpenSSL's support for hardware acceleration in order to save some memory, so you can't build programs using engines on Android. [Patch revised by nickm]
-rw-r--r--src/common/crypto.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 2927aa2b5b..e9333bca2b 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -62,6 +62,11 @@
#include <openssl/engine.h>
+#ifdef ANDROID
+/* Android's OpenSSL seems to have removed all of its Engine support. */
+#define DISABLE_ENGINES
+#endif
+
#if OPENSSL_VERSION_NUMBER < 0x00908000l
/* On OpenSSL versions before 0.9.8, there is no working SHA256
* implementation, so we use Tom St Denis's nice speedy one, slightly adapted
@@ -174,6 +179,7 @@ crypto_log_errors(int severity, const char *doing)
}
}
+#ifndef DISABLE_ENGINES
/** Log any OpenSSL engines we're using at NOTICE. */
static void
log_engine(const char *fn, ENGINE *e)
@@ -188,7 +194,9 @@ log_engine(const char *fn, ENGINE *e)
log(LOG_INFO, LD_CRYPTO, "Using default implementation for %s", fn);
}
}
+#endif
+#ifndef DISABLE_ENGINES
/** Try to load an engine in a shared library via fully qualified path.
*/
static ENGINE *
@@ -206,6 +214,7 @@ try_load_engine(const char *path, const char *engine)
}
return e;
}
+#endif
/** Initialize the crypto library. Return 0 on success, -1 on failure.
*/
@@ -218,10 +227,17 @@ crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
_crypto_global_initialized = 1;
setup_openssl_threading();
if (useAccel > 0) {
+#ifdef DISABLE_ENGINES
+ (void)accelName;
+ (void)accelDir;
+ log_warn(LD_CRYPTO, "No OpenSSL hardware acceleration support enabled.");
+#else
ENGINE *e = NULL;
+
log_info(LD_CRYPTO, "Initializing OpenSSL engine support.");
ENGINE_load_builtin_engines();
ENGINE_register_all_complete();
+
if (accelName) {
if (accelDir) {
log_info(LD_CRYPTO, "Trying to load dynamic OpenSSL engine \"%s\""
@@ -251,6 +267,7 @@ crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
log_engine("SHA1", ENGINE_get_digest_engine(NID_sha1));
log_engine("3DES", ENGINE_get_cipher_engine(NID_des_ede3_ecb));
log_engine("AES", ENGINE_get_cipher_engine(NID_aes_128_ecb));
+#endif
} else {
log_info(LD_CRYPTO, "NOT using OpenSSL engine support.");
}
@@ -274,7 +291,11 @@ crypto_global_cleanup(void)
EVP_cleanup();
ERR_remove_state(0);
ERR_free_strings();
+
+#ifndef DISABLE_ENGINES
ENGINE_cleanup();
+#endif
+
CONF_modules_unload(1);
CRYPTO_cleanup_all_ex_data();
#ifdef TOR_IS_MULTITHREADED