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