line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::CBC::PBKDF::pbkdf2; |
2
|
5
|
|
|
5
|
|
32
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
173
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
27
|
use base 'Crypt::CBC::PBKDF'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
499
|
|
5
|
5
|
|
|
5
|
|
2704
|
use Crypt::PBKDF2; |
|
5
|
|
|
|
|
688892
|
|
|
5
|
|
|
|
|
853
|
|
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
|
315
|
my $class = shift; |
15
|
123
|
|
|
|
|
509
|
my %options = @_; |
16
|
123
|
|
100
|
|
|
535
|
$options{key_len} ||= 32; |
17
|
123
|
|
100
|
|
|
387
|
$options{iv_len} ||= 16; |
18
|
123
|
|
100
|
|
|
429
|
$options{iterations} ||= 10_000; |
19
|
123
|
|
100
|
|
|
785
|
$options{hash_class} ||= 'HMACSHA2'; |
20
|
123
|
|
|
|
|
927
|
return bless \%options,$class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub generate_hash { |
24
|
122
|
|
|
122
|
0
|
207
|
my $self = shift; |
25
|
122
|
|
|
|
|
327
|
my ($salt,$passphrase) = @_; |
26
|
|
|
|
|
|
|
my $pbkdf2 = Crypt::PBKDF2->new(%$self, |
27
|
122
|
|
|
|
|
3046
|
output_len => $self->{key_len} + $self->{iv_len}); |
28
|
122
|
|
|
|
|
194727
|
return $pbkdf2->PBKDF2($salt,$passphrase); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |