line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Passphrase::Pepper::Simple; |
2
|
|
|
|
|
|
|
$Crypt::Passphrase::Pepper::Simple::VERSION = '0.015'; |
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use parent 'Crypt::Passphrase::Pepper::Base'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
49
|
use Crypt::Passphrase -encoder; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
10
|
1
|
|
|
1
|
|
502
|
use Digest::SHA; |
|
1
|
|
|
|
|
3086
|
|
|
1
|
|
|
|
|
142
|
|
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
|
5
|
my ($class, %args) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
6
|
my $peppers = $args{peppers} or croak('No peppers given'); |
24
|
1
|
0
|
33
|
1
|
|
9
|
$args{active} //= (sort {; no warnings 'numeric'; $b <=> $a || $b cmp $a } keys %{ $peppers })[0]; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
243
|
|
|
1
|
|
|
|
|
6
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
8
|
|
25
|
1
|
|
50
|
|
|
7
|
$args{algorithm} //= 'sha512-hmac'; |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
10
|
return $class->SUPER::new(%args); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub prehash_password { |
31
|
2
|
|
|
2
|
1
|
6
|
my ($self, $password, $algorithm, $id) = @_; |
32
|
2
|
50
|
|
|
|
7
|
my $secret = $self->{peppers}{$id} or croak "No such pepper $id"; |
33
|
2
|
50
|
|
|
|
7
|
my $func = $algorithms{$algorithm} or croak "No such algorithm $algorithm"; |
34
|
2
|
|
|
|
|
29
|
return $func->($password, $secret); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#ABSTRACT: A pepper-wrapper for Crypt::Passphrase |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |