ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/Deliantra/Util.pm
(Generate patch)

Comparing deliantra/Deliantra/Deliantra/Util.pm (file contents):
Revision 1.7 by root, Fri Nov 16 10:47:34 2012 UTC vs.
Revision 1.8 by root, Fri Nov 16 12:02:49 2012 UTC

18 18
19use common::sense; 19use common::sense;
20 20
21use Digest::SHA; 21use Digest::SHA;
22 22
23# helepr function to wrok around bugs in Digest::SHA
24sub 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
25Hashes a cleartext password into the binary password used in the protocol. 32Hashes 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
50sub auth_pw($$$) { 57sub 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines