summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/or/config.c2
-rw-r--r--src/or/control.c13
-rw-r--r--src/or/main.c7
3 files changed, 13 insertions, 9 deletions
diff --git a/src/or/config.c b/src/or/config.c
index a161c980c2..d29de30800 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1555,7 +1555,7 @@ options_validate(or_options_t *options)
if (options->HashedControlPassword) {
if (decode_hashed_password(NULL, options->HashedControlPassword)<0) {
- log_fn(LOG_WARN,"Bad HashedControlPassword: wrong length or bad base64");
+ log_fn(LOG_WARN,"Bad HashedControlPassword: wrong length or bad encoding");
result = -1;
}
}
diff --git a/src/or/control.c b/src/or/control.c
index 42db20098d..564bb1b396 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -469,9 +469,16 @@ int
decode_hashed_password(char *buf, const char *hashed)
{
char decoded[64];
- if (base64_decode(decoded, sizeof(decoded), hashed, strlen(hashed))
- != S2K_SPECIFIER_LEN+DIGEST_LEN) {
- return -1;
+ if (!strcmpstart(hashed, "16:")) {
+ if (base16_decode(decoded, sizeof(decoded), hashed+3, strlen(hashed+3))<0
+ || strlen(hashed+3) != (S2K_SPECIFIER_LEN+DIGEST_LEN)*2) {
+ return -1;
+ }
+ } else {
+ if (base64_decode(decoded, sizeof(decoded), hashed, strlen(hashed))
+ != S2K_SPECIFIER_LEN+DIGEST_LEN) {
+ return -1;
+ }
}
if (buf)
memcpy(buf, decoded, sizeof(decoded));
diff --git a/src/or/main.c b/src/or/main.c
index fdaaddbb72..51f18c0e6e 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1317,11 +1317,8 @@ static void do_hash_password(void)
secret_to_key(key+S2K_SPECIFIER_LEN, DIGEST_LEN,
get_options()->command_arg, strlen(get_options()->command_arg),
key);
- if (base64_encode(output, sizeof(output), key, sizeof(key))<0) {
- log_fn(LOG_ERR, "Unable to compute base64");
- } else {
- printf("%s",output);
- }
+ base16_encode(output, sizeof(output), key, sizeof(key));
+ printf("16:%s\n",output);
}
#ifdef MS_WINDOWS_SERVICE