diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-03 19:49:03 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-03 19:49:03 +0000 |
commit | cea9125d71ad35535b967680a64ee4695c79172e (patch) | |
tree | 3c0acdaf8cf4d083c175a24a2459d076a1786093 /src/or/main.c | |
parent | 871bf904ae7f6cfce3f254397df1da03c8920a61 (diff) | |
download | tor-cea9125d71ad35535b967680a64ee4695c79172e.tar tor-cea9125d71ad35535b967680a64ee4695c79172e.tar.gz |
Implement two flavors of authentication for control connections: one for trusted FS, one for untrusted FS.
svn:r2664
Diffstat (limited to 'src/or/main.c')
-rw-r--r-- | src/or/main.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/or/main.c b/src/or/main.c index 812f8c96a..87e729bea 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1373,6 +1373,25 @@ static void do_list_fingerprint(void) } } +/** DOCDOC **/ +static void do_hash_password(void) +{ + + char output[256]; + char key[S2K_SPECIFIER_LEN+DIGEST_LEN]; + + crypto_rand(key, S2K_SPECIFIER_LEN-1); + key[S2K_SPECIFIER_LEN-1] = (uint8_t)96; /* Hash 64 K of data. */ + secret_to_key(key+S2K_SPECIFIER_LEN, DIGEST_LEN, + options.command_arg, strlen(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); + } +} + #ifdef MS_WINDOWS_SERVICE void nt_service_control(DWORD request) { @@ -1449,6 +1468,9 @@ int tor_main(int argc, char *argv[]) { case CMD_LIST_FINGERPRINT: do_list_fingerprint(); break; + case CMD_HASH_PASSWORD: + do_hash_password(); + break; default: log_fn(LOG_ERR, "Illegal command number %d: internal error.", options.command); |