line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Passphrase::Pepper::Simple; |
2
|
|
|
|
|
|
|
$Crypt::Passphrase::Pepper::Simple::VERSION = '0.016'; |
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use parent 'Crypt::Passphrase::Pepper::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
52
|
use Crypt::Passphrase -encoder; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
10
|
1
|
|
|
1
|
|
611
|
use Digest::SHA; |
|
1
|
|
|
|
|
3147
|
|
|
1
|
|
|
|
|
114
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %algorithms = ( |
13
|
|
|
|
|
|
|
'sha1-hmac' => \&Digest::SHA::hmac_sha1, |
14
|
|
|
|
|
|
|
'sha224-hmac' => \&Digest::SHA::hmac_sha224, |
15
|
|
|
|
|
|
|
'sha256-hmac' => \&Digest::SHA::hmac_sha256, |
16
|
|
|
|
|
|
|
'sha384-hmac' => \&Digest::SHA::hmac_sha384, |
17
|
|
|
|
|
|
|
'sha512-hmac' => \&Digest::SHA::hmac_sha512, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
1
|
|
|
1
|
1
|
359
|
my ($class, %args) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
9
|
my $peppers = $args{peppers} or croak('No peppers given'); |
24
|
1
|
0
|
33
|
1
|
|
8
|
$args{active} //= (sort {; no warnings 'numeric'; $b <=> $a || $b cmp $a } keys %{ $peppers })[0]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
285
|
|
|
1
|
|
|
|
|
5
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
8
|
|
25
|
1
|
|
50
|
|
|
6
|
$args{algorithm} //= 'sha512-hmac'; |
26
|
1
|
|
50
|
|
|
7
|
$args{supported_hashes} //= [ keys %algorithms ]; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
10
|
return $class->SUPER::new(%args); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub prehash_password { |
32
|
2
|
|
|
2
|
1
|
6
|
my ($self, $password, $algorithm, $id) = @_; |
33
|
2
|
50
|
|
|
|
7
|
my $secret = $self->{peppers}{$id} or croak "No such pepper $id"; |
34
|
2
|
50
|
|
|
|
6
|
my $func = $algorithms{$algorithm} or croak "No such algorithm $algorithm"; |
35
|
2
|
|
|
|
|
30
|
return $func->($password, $secret); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#ABSTRACT: A pepper-wrapper for Crypt::Passphrase |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |