line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::CBC::PBKDF::opensslv1; |
2
|
7
|
|
|
7
|
|
51
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
231
|
|
3
|
7
|
|
|
7
|
|
32
|
use base 'Crypt::CBC::PBKDF'; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
745
|
|
4
|
7
|
|
|
7
|
|
41
|
use Digest::MD5 'md5'; |
|
7
|
|
|
|
|
20
|
|
|
7
|
|
|
|
|
1634
|
|
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
|
2475
|
my $class = shift; |
13
|
1639
|
|
|
|
|
3850
|
my %options = @_; |
14
|
1639
|
|
50
|
|
|
5723
|
$options{salt_len} ||= 8; |
15
|
1639
|
|
100
|
|
|
2419
|
$options{key_len} ||= 32; |
16
|
1639
|
|
100
|
|
|
2175
|
$options{iv_len} ||= 16; |
17
|
1639
|
|
|
|
|
7843
|
return bless \%options,$class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub generate_hash { |
21
|
8
|
|
|
8
|
0
|
11
|
my $self = shift; |
22
|
8
|
|
|
|
|
14
|
my ($salt,$passphrase) = @_; |
23
|
8
|
|
|
|
|
19
|
my $desired_len = $self->{key_len} + $self->{iv_len}; |
24
|
8
|
|
|
|
|
9
|
my $data = ''; |
25
|
8
|
|
|
|
|
11
|
my $d = ''; |
26
|
8
|
|
|
|
|
19
|
while (length $data < $desired_len) { |
27
|
31
|
|
|
|
|
90
|
$d = md5($d . $passphrase . $salt); |
28
|
31
|
|
|
|
|
98
|
$data .= $d; |
29
|
|
|
|
|
|
|
} |
30
|
8
|
|
|
|
|
20
|
return $data; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |