| 1 | package CGI::Application::Plugin::Authentication::Driver::Filter::sha1; | ||||||||||||||||||
| 2 | 3 | $CGI::Application::Plugin::Authentication::Driver::Filter::sha1::VERSION = '0.21'; | |||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | 3 | ▶ | use UNIVERSAL::require; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | sub check { | ||||||||||||||||||
| 9 | 12 | ▶ | my $class = shift; | ||||||||||||||||
|
Subroutine
check: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||
| 10 | 12 | my $param = shift; | |||||||||||||||||
| 11 | 12 | my $plain = shift; | |||||||||||||||||
| 12 | 12 | my $filtered = shift; | |||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | 12 | ▶ | if ($param) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 15 | 6 | ▶ | return ( $class->filter( $param, $plain ) eq $filtered ) ? 1 : 0; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 16 | } elsif ( length($filtered) == 20 ) { | ||||||||||||||||||
| 17 | 2 | ▶ | return ( $class->filter( 'binary', $plain ) eq $filtered ) ? 1 : 0; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 18 | } elsif ( length($filtered) == 27 ) { | ||||||||||||||||||
| 19 | 2 | ▶ | return ( $class->filter( 'base64', $plain ) eq $filtered ) ? 1 : 0; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 20 | } else { | ||||||||||||||||||
| 21 | 2 | ▶ | return ( $class->filter( undef, $plain ) eq $filtered ) ? 1 : 0; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 22 | } | ||||||||||||||||||
| 23 | } | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | sub filter { | ||||||||||||||||||
| 26 | 18 | ▶ | my $class = shift; | ||||||||||||||||
|
Subroutine
filter: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||
| 27 | 18 | ▶ | my $param = lc (shift || 'hex'); | ||||||||||||||||
|
Condition100%2/2
shift() || 'hex'
MC/DC100%1/1
shift() || 'hex'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||
| 28 | 18 | my $plain = shift; | |||||||||||||||||
| 29 | |||||||||||||||||||
| 30 | 18 | ▶ | Digest::SHA->require || die "Digest::SHA is required to check SHA1 passwords"; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 31 | 17 | ▶ | if ( $param eq 'hex' ) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 32 | 6 | return Digest::SHA::sha1_hex($plain); | |||||||||||||||||
| 33 | } elsif ( $param eq 'base64' ) { | ||||||||||||||||||
| 34 | 5 | return Digest::SHA::sha1_base64($plain); | |||||||||||||||||
| 35 | } elsif ( $param eq 'binary' ) { | ||||||||||||||||||
| 36 | 5 | return Digest::SHA::sha1($plain); | |||||||||||||||||
| 37 | } | ||||||||||||||||||
| 38 | 1 | die "Unknown SHA1 format $param"; | |||||||||||||||||
| 39 | } | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 3 | 1; | |||||||||||||||||
| 42 | __END__ | ||||||||||||||||||