php hex code for cookie authentication to controller?

Wesley Kenzie wkenzie at gmail.com
Tue Oct 21 23:29:08 UTC 2008


>>What's the actual length of $auth_value?  If it's not
>>AUTHENTICATION_COOKIE_LEN (32, I think), that's when I'd expect that
>>error.
Thanks, Nick.  The length of $auth_value is 32 though, and the length of
bin2hex($auth_value) is 64.

>>Also, I don't know PHP so well, but maybe you should specify 'rb'
>>instead of 'r'.
I do not see that 'rb' is an option in php for the fopen() function ...

. . . . .
Wesley

On Tue, Oct 21, 2008 at 2:57 PM, Nick Mathewson <nickm at freehaven.net> wrote:

>  On Tue, Oct 21, 2008 at 11:52:33AM -0700, Wesley Kenzie wrote:
> > per 5.1 Authentication in control-spec.txt: "To authenticate, the
> controller
> > must send the contents of this file, encoded in hexadecimal."
> >
> > Fine, but when using the following in PHP:
> >
> > $ch = fopen('cookiefilename', 'r');
> > $auth_value = fread($ch, 128);
> > $send_auth_value = "AUTHENTICATE \"". bin2hex($auth_value) . "\"\r\n";
> > $fh = fsockopen('127.0.0.1', controlportnumber);
> > fwrite($fh, $send_auth_value);
> > $buf = fgets($fh);
> >
> > ... I get 515 Authentication failed: Wrong length on authentication
> cookie.
>
> What's the actual length of $auth_value?  If it's not
> AUTHENTICATION_COOKIE_LEN (32, I think), that's when I'd expect that
> error.
>
> Also, I don't know PHP so well, but maybe you should specify 'rb'
> instead of 'r'.
>
> --
> Nick
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-talk/attachments/20081021/67fa2b2e/attachment.htm>


More information about the tor-talk mailing list