… | |
… | |
18 | |
18 | |
19 | use common::sense; |
19 | use common::sense; |
20 | |
20 | |
21 | use Digest::SHA; |
21 | use Digest::SHA; |
22 | |
22 | |
|
|
23 | # helepr function to wrok around bugs in Digest::SHA |
|
|
24 | sub dgst { |
|
|
25 | my $s = shift; |
|
|
26 | utf8::downgrade $s; |
|
|
27 | Digest::SHA::sha512 $s |
|
|
28 | } |
|
|
29 | |
23 | =item Deliantra::Util::hash_pw $cleartext |
30 | =item Deliantra::Util::hash_pw $cleartext |
24 | |
31 | |
25 | Hashes a cleartext password into the binary password used in the protocol. |
32 | Hashes a cleartext password into the binary password used in the protocol. |
26 | |
33 | |
27 | =cut |
34 | =cut |
… | |
… | |
33 | |
40 | |
34 | my $pw = shift; |
41 | my $pw = shift; |
35 | |
42 | |
36 | for (0..10) { |
43 | for (0..10) { |
37 | $pw = "deliantrakdf$pw" x 32; |
44 | $pw = "deliantrakdf$pw" x 32; |
38 | $pw = Digest::SHA::sha512 $pw; |
45 | $pw = dgst $pw; |
39 | } |
46 | } |
40 | |
47 | |
41 | $pw |
48 | $pw |
42 | } |
49 | } |
43 | |
50 | |
… | |
… | |
49 | |
56 | |
50 | sub auth_pw($$$) { |
57 | sub auth_pw($$$) { |
51 | my ($hash, $nonce1, $nonce2) = @_; |
58 | my ($hash, $nonce1, $nonce2) = @_; |
52 | |
59 | |
53 | # simple HMAC application |
60 | # simple HMAC application |
54 | Digest::SHA::sha512 $nonce1 . Digest::SHA::sha512 $nonce2 . $hash |
61 | dgst $nonce1 . dgst $nonce2 . $hash |
55 | } |
62 | } |
56 | |
63 | |
57 | =back |
64 | =back |
58 | |
65 | |
59 | =head1 AUTHOR |
66 | =head1 AUTHOR |