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