line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Application::Plugin::Authentication::Driver::Filter::sha1; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2137
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
105
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
134
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
793
|
use UNIVERSAL::require; |
|
3
|
|
|
|
|
1616
|
|
|
3
|
|
|
|
|
33
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub check { |
10
|
12
|
|
|
12
|
1
|
22
|
my $class = shift; |
11
|
12
|
|
|
|
|
19
|
my $param = shift; |
12
|
12
|
|
|
|
|
15
|
my $plain = shift; |
13
|
12
|
|
|
|
|
15
|
my $filtered = shift; |
14
|
|
|
|
|
|
|
|
15
|
12
|
100
|
|
|
|
38
|
if ($param) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
16
|
6
|
100
|
|
|
|
16
|
return ( $class->filter( $param, $plain ) eq $filtered ) ? 1 : 0; |
17
|
|
|
|
|
|
|
} elsif ( length($filtered) == 20 ) { |
18
|
2
|
100
|
|
|
|
7
|
return ( $class->filter( 'binary', $plain ) eq $filtered ) ? 1 : 0; |
19
|
|
|
|
|
|
|
} elsif ( length($filtered) == 27 ) { |
20
|
2
|
100
|
|
|
|
8
|
return ( $class->filter( 'base64', $plain ) eq $filtered ) ? 1 : 0; |
21
|
|
|
|
|
|
|
} else { |
22
|
2
|
100
|
|
|
|
8
|
return ( $class->filter( undef, $plain ) eq $filtered ) ? 1 : 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub filter { |
27
|
18
|
|
|
18
|
1
|
831
|
my $class = shift; |
28
|
18
|
|
100
|
|
|
489
|
my $param = lc shift || 'hex'; |
29
|
18
|
|
|
|
|
27
|
my $plain = shift; |
30
|
|
|
|
|
|
|
|
31
|
18
|
100
|
|
|
|
90
|
Digest::SHA->require || die "Digest::SHA is required to check SHA1 passwords"; |
32
|
17
|
100
|
|
|
|
614
|
if ( $param eq 'hex' ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
33
|
6
|
|
|
|
|
66
|
return Digest::SHA::sha1_hex($plain); |
34
|
|
|
|
|
|
|
} elsif ( $param eq 'base64' ) { |
35
|
5
|
|
|
|
|
64
|
return Digest::SHA::sha1_base64($plain); |
36
|
|
|
|
|
|
|
} elsif ( $param eq 'binary' ) { |
37
|
5
|
|
|
|
|
65
|
return Digest::SHA::sha1($plain); |
38
|
|
|
|
|
|
|
} |
39
|
1
|
|
|
|
|
14
|
die "Unknown SHA1 format $param"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
__END__ |