On Thu, 15 Jan 2004, Antonio Manfreda wrote:

> Thank you very much for the clue.
> How can I turn on auth debugging in squid and what file does it use for
> logging?
> 
> Anyway, I don't understand why, following RFC specs, I cant build the digest
> created by the client (after all it is a client side calculation). Is there
> some base64 encoding I am missing?

Attached you can find a small perl program implementing the Digest 
algorithm. I use this when testing the Digest implementation in Squid and 
other Digest applications (browsers etc).

Regards
Henrik
#!/usr/bin/perl

use Digest::MD5 qw(md5_hex); 

if (@ARGV != 8) {
    die("usage: user pass realm uri nonce nc cnonce [response]\n");
}

my ($user, $pass, $realm, $uri, $nonce, $nc, $cnonce, $oldresponse) = @ARGV;

my ($method) = ("GET");

sub KD(@)
{
   return md5_hex(join(":", @_));
}

# 3.2.2.2 H(A1)
my $HA1 = KD($user , $realm , $pass);

# 3.2.2.3 H(A2)
my $HA2 = KD($method ,$uri);

my $response = KD($HA1, $nonce, $nc, $cnonce, "auth", $HA2);

print "User='$user' pass='$pass' realm='$realm' nonce='$nonce', count='$nc', 
cnonce='$cnonce' method='$method' uri='$uri'\n";

if ($response eq $oldresponse) {
    print "OK\n";
} else {
    print "H(A1)=\"${HA1}\"\n";
    print "Proxy-Authorization: digest username=\"$user\", realm=\"$realm\", 
nonce=\"$nonce\", uri=\"$uri\", qop=auth, nc=$nc, cnonce=\"$cnonce\", 
response=\"$response\"\n";
}

Reply via email to