aboutsummaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-03-31 22:51:28 -0400
committerNick Mathewson <nickm@torproject.org>2012-04-01 00:42:04 -0400
commit9a69c24150965e54322ed9616638d4f1939b1289 (patch)
treea28e0c4d406c63356d95460d77930a6a700c229f /src/or/config.c
parent9740f067c4bed47beb63483be4f4636167a04019 (diff)
downloadtor-9a69c24150965e54322ed9616638d4f1939b1289.tar.gz
tor-9a69c24150965e54322ed9616638d4f1939b1289.zip
Do not use strcmp() to compare an http authenticator to its expected value
This fixes a side-channel attack on the (fortunately unused!) BridgePassword option for bridge authorities. Fix for bug 5543; bugfix on 0.2.0.14-alpha.
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/config.c b/src/or/config.c
index c3e285dc44..1e7bd5844b 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -713,6 +713,7 @@ or_options_free(or_options_t *options)
return;
routerset_free(options->_ExcludeExitNodesUnion);
+ tor_free(options->BridgePassword_AuthDigest);
config_free(&options_format, options);
}
@@ -1298,6 +1299,24 @@ options_act(or_options_t *old_options)
/* Change the cell EWMA settings */
cell_ewma_set_scale_factor(options, networkstatus_get_latest_consensus());
+ /* Update the BridgePassword's hashed version as needed. We store this as a
+ * digest so that we can do side-channel-proof comparisons on it.
+ */
+ if (options->BridgePassword) {
+ char *http_authenticator;
+ http_authenticator = alloc_http_authenticator(options->BridgePassword);
+ if (!http_authenticator) {
+ log_warn(LD_BUG, "Unable to allocate HTTP authenticator. Not setting "
+ "BridgePassword.");
+ return -1;
+ }
+ options->BridgePassword_AuthDigest = tor_malloc(DIGEST256_LEN);
+ crypto_digest256(options->BridgePassword_AuthDigest,
+ http_authenticator, strlen(http_authenticator),
+ DIGEST_SHA256);
+ tor_free(http_authenticator);
+ }
+
/* Check for transitions that need action. */
if (old_options) {
int revise_trackexithosts = 0;