mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-09-21 13:34:59 +02:00
Make hashed controller password encoding use hex not base64; this makes it possible to write a controller without base64
svn:r4279
This commit is contained in:
parent
eec9107093
commit
11a64692c3
@ -1555,7 +1555,7 @@ options_validate(or_options_t *options)
|
|||||||
|
|
||||||
if (options->HashedControlPassword) {
|
if (options->HashedControlPassword) {
|
||||||
if (decode_hashed_password(NULL, options->HashedControlPassword)<0) {
|
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;
|
result = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,10 +469,17 @@ int
|
|||||||
decode_hashed_password(char *buf, const char *hashed)
|
decode_hashed_password(char *buf, const char *hashed)
|
||||||
{
|
{
|
||||||
char decoded[64];
|
char decoded[64];
|
||||||
|
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))
|
if (base64_decode(decoded, sizeof(decoded), hashed, strlen(hashed))
|
||||||
!= S2K_SPECIFIER_LEN+DIGEST_LEN) {
|
!= S2K_SPECIFIER_LEN+DIGEST_LEN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (buf)
|
if (buf)
|
||||||
memcpy(buf, decoded, sizeof(decoded));
|
memcpy(buf, decoded, sizeof(decoded));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1317,11 +1317,8 @@ static void do_hash_password(void)
|
|||||||
secret_to_key(key+S2K_SPECIFIER_LEN, DIGEST_LEN,
|
secret_to_key(key+S2K_SPECIFIER_LEN, DIGEST_LEN,
|
||||||
get_options()->command_arg, strlen(get_options()->command_arg),
|
get_options()->command_arg, strlen(get_options()->command_arg),
|
||||||
key);
|
key);
|
||||||
if (base64_encode(output, sizeof(output), key, sizeof(key))<0) {
|
base16_encode(output, sizeof(output), key, sizeof(key));
|
||||||
log_fn(LOG_ERR, "Unable to compute base64");
|
printf("16:%s\n",output);
|
||||||
} else {
|
|
||||||
printf("%s",output);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MS_WINDOWS_SERVICE
|
#ifdef MS_WINDOWS_SERVICE
|
||||||
|
Loading…
Reference in New Issue
Block a user