diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-05-31 13:36:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-05-31 13:36:50 -0400 |
commit | e84ddead349e5af8c183042d3de27ecb4b6d4e87 (patch) | |
tree | 24ed02fe7e2fbfa1c37cfadbb1d7d3fff5ef4d5b /src/or | |
parent | 3db64b501d62ff2a2807c8f43a12fbab52521e49 (diff) | |
parent | 3ca10bb62faaed6a5242ff760ed6c76330a750ef (diff) | |
download | tor-e84ddead349e5af8c183042d3de27ecb4b6d4e87.tar.gz tor-e84ddead349e5af8c183042d3de27ecb4b6d4e87.zip |
Merge branch 'hardware_accel_improvements'
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 19 | ||||
-rw-r--r-- | src/or/main.c | 4 | ||||
-rw-r--r-- | src/or/or.h | 2 | ||||
-rw-r--r-- | src/or/router.c | 4 | ||||
-rw-r--r-- | src/or/test.c | 2 |
5 files changed, 25 insertions, 6 deletions
diff --git a/src/or/config.c b/src/or/config.c index c0f473bf2d..daf50a1e2b 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -222,6 +222,8 @@ static config_var_t _option_vars[] = { #endif OBSOLETE("Group"), V(HardwareAccel, BOOL, "0"), + V(AccelName, STRING, NULL), + V(AccelDir, FILENAME, NULL), V(HashedControlPassword, LINELIST, NULL), V(HidServDirectoryV2, BOOL, "1"), VAR("HiddenServiceDir", LINELIST_S, RendConfigLines, NULL), @@ -444,6 +446,10 @@ static config_var_description_t options_description[] = { * FetchUselessDescriptors */ { "HardwareAccel", "If set, Tor tries to use hardware crypto accelerators " "when it can." }, + { "AccelName", "If set, try to use hardware crypto accelerator with this " + "specific ID." }, + { "AccelDir", "If set, look in this directory for the dynamic hardware " + "engine in addition to OpenSSL default path." }, /* HashedControlPassword */ { "HTTPProxy", "Force Tor to make all HTTP directory requests through this " "host:port (or host:80 if port is not set)." }, @@ -3611,6 +3617,11 @@ options_validate(or_options_t *old_options, or_options_t *options, "testing Tor network!"); } + if (options->AccelName && !options->HardwareAccel) + options->HardwareAccel = 1; + if (options->AccelDir && !options->AccelName) + REJECT("Can't use hardware crypto accelerator dir without engine name."); + return 0; #undef REJECT #undef COMPLAIN @@ -3668,9 +3679,11 @@ options_transition_allowed(or_options_t *old, or_options_t *new_val, return -1; } - if (old->HardwareAccel != new_val->HardwareAccel) { - *msg = tor_strdup("While Tor is running, changing HardwareAccel is " - "not allowed."); + if ((old->HardwareAccel != new_val->HardwareAccel) + || !opt_streq(old->AccelName, new_val->AccelName) + || !opt_streq(old->AccelDir, new_val->AccelDir)) { + *msg = tor_strdup("While Tor is running, changing OpenSSL hardware " + "acceleration engine is not allowed."); return -1; } diff --git a/src/or/main.c b/src/or/main.c index b21c00c9c7..25cb949a0c 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1810,7 +1810,9 @@ tor_init(int argc, char *argv[]) "and you probably shouldn't."); #endif - if (crypto_global_init(get_options()->HardwareAccel)) { + if (crypto_global_init(get_options()->HardwareAccel, + get_options()->AccelName, + get_options()->AccelDir)) { log_err(LD_BUG, "Unable to initialize OpenSSL. Exiting."); return -1; } diff --git a/src/or/or.h b/src/or/or.h index 0d906e0870..5f91cec89f 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2416,6 +2416,8 @@ typedef struct { * log whether it was DNS-leaking or not? */ int HardwareAccel; /**< Boolean: Should we enable OpenSSL hardware * acceleration where available? */ + char *AccelName; /**< Optional hardware acceleration engine name. */ + char *AccelDir; /**< Optional hardware acceleration engine search dir. */ int UseEntryGuards; /**< Boolean: Do we try to enter from a smallish number * of fixed nodes? */ int NumEntryGuards; /**< How many entry guards do we try to establish? */ diff --git a/src/or/router.c b/src/or/router.c index a1a56b0d01..e5f3b52ec9 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -442,7 +442,9 @@ init_keys(void) key_lock = tor_mutex_new(); /* There are a couple of paths that put us here before */ - if (crypto_global_init(get_options()->HardwareAccel)) { + if (crypto_global_init(get_options()->HardwareAccel, + get_options()->AccelName, + get_options()->AccelDir)) { log_err(LD_BUG, "Unable to initialize OpenSSL. Exiting."); return -1; } diff --git a/src/or/test.c b/src/or/test.c index d43eb8f225..b2a70eadb3 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -4793,7 +4793,7 @@ main(int c, char**v) } options->command = CMD_RUN_UNITTESTS; - crypto_global_init(0); + crypto_global_init(0, NULL, NULL); rep_hist_init(); network_init(); setup_directory(); |