line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::CBC::PBKDF::opensslv1; |
2
|
7
|
|
|
7
|
|
56
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
248
|
|
3
|
7
|
|
|
7
|
|
38
|
use base 'Crypt::CBC::PBKDF'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
937
|
|
4
|
7
|
|
|
7
|
|
51
|
use Digest::MD5 'md5'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
1824
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# options: |
7
|
|
|
|
|
|
|
# salt_len => 8 default |
8
|
|
|
|
|
|
|
# key_len => 32 default |
9
|
|
|
|
|
|
|
# iv_len => 16 default |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub create { |
12
|
1639
|
|
|
1639
|
0
|
2994
|
my $class = shift; |
13
|
1639
|
|
|
|
|
4706
|
my %options = @_; |
14
|
1639
|
|
50
|
|
|
7016
|
$options{salt_len} ||= 8; |
15
|
1639
|
|
100
|
|
|
3031
|
$options{key_len} ||= 32; |
16
|
1639
|
|
100
|
|
|
2695
|
$options{iv_len} ||= 16; |
17
|
1639
|
|
|
|
|
9291
|
return bless \%options,$class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub generate_hash { |
21
|
8
|
|
|
8
|
0
|
11
|
my $self = shift; |
22
|
8
|
|
|
|
|
16
|
my ($salt,$passphrase) = @_; |
23
|
8
|
|
|
|
|
22
|
my $desired_len = $self->{key_len} + $self->{iv_len}; |
24
|
8
|
|
|
|
|
10
|
my $data = ''; |
25
|
8
|
|
|
|
|
11
|
my $d = ''; |
26
|
8
|
|
|
|
|
21
|
while (length $data < $desired_len) { |
27
|
31
|
|
|
|
|
98
|
$d = md5($d . $passphrase . $salt); |
28
|
31
|
|
|
|
|
70
|
$data .= $d; |
29
|
|
|
|
|
|
|
} |
30
|
8
|
|
|
|
|
20
|
return $data; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |