line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::CBC::PBKDF::pbkdf2; |
2
|
5
|
|
|
5
|
|
37
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
216
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
32
|
use base 'Crypt::CBC::PBKDF'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
994
|
|
5
|
5
|
|
|
5
|
|
2888
|
use Crypt::PBKDF2; |
|
5
|
|
|
|
|
749989
|
|
|
5
|
|
|
|
|
968
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# options: |
8
|
|
|
|
|
|
|
# key_len => 32 default |
9
|
|
|
|
|
|
|
# iv_len => 16 default |
10
|
|
|
|
|
|
|
# iterations => 10000 default |
11
|
|
|
|
|
|
|
# hash_class => 'HMACSHA2' default |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub create { |
14
|
123
|
|
|
123
|
0
|
368
|
my $class = shift; |
15
|
123
|
|
|
|
|
530
|
my %options = @_; |
16
|
123
|
|
100
|
|
|
569
|
$options{key_len} ||= 32; |
17
|
123
|
|
100
|
|
|
432
|
$options{iv_len} ||= 16; |
18
|
123
|
|
100
|
|
|
481
|
$options{iterations} ||= 10_000; |
19
|
123
|
|
100
|
|
|
864
|
$options{hash_class} ||= 'HMACSHA2'; |
20
|
123
|
|
|
|
|
1045
|
return bless \%options,$class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub generate_hash { |
24
|
122
|
|
|
122
|
0
|
194
|
my $self = shift; |
25
|
122
|
|
|
|
|
343
|
my ($salt,$passphrase) = @_; |
26
|
|
|
|
|
|
|
my $pbkdf2 = Crypt::PBKDF2->new(%$self, |
27
|
122
|
|
|
|
|
3249
|
output_len => $self->{key_len} + $self->{iv_len}); |
28
|
122
|
|
|
|
|
207583
|
return $pbkdf2->PBKDF2($salt,$passphrase); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |