| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::CBC::PBKDF::opensslv1; |
|
2
|
7
|
|
|
7
|
|
53
|
use strict; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
251
|
|
|
3
|
7
|
|
|
7
|
|
38
|
use base 'Crypt::CBC::PBKDF'; |
|
|
7
|
|
|
|
|
10
|
|
|
|
7
|
|
|
|
|
926
|
|
|
4
|
7
|
|
|
7
|
|
49
|
use Digest::MD5 'md5'; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
1974
|
|
|
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
|
2882
|
my $class = shift; |
|
13
|
1639
|
|
|
|
|
4702
|
my %options = @_; |
|
14
|
1639
|
|
50
|
|
|
6723
|
$options{salt_len} ||= 8; |
|
15
|
1639
|
|
100
|
|
|
2735
|
$options{key_len} ||= 32; |
|
16
|
1639
|
|
100
|
|
|
2618
|
$options{iv_len} ||= 16; |
|
17
|
1639
|
|
|
|
|
8968
|
return bless \%options,$class; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub generate_hash { |
|
21
|
8
|
|
|
8
|
0
|
15
|
my $self = shift; |
|
22
|
8
|
|
|
|
|
15
|
my ($salt,$passphrase) = @_; |
|
23
|
8
|
|
|
|
|
21
|
my $desired_len = $self->{key_len} + $self->{iv_len}; |
|
24
|
8
|
|
|
|
|
12
|
my $data = ''; |
|
25
|
8
|
|
|
|
|
12
|
my $d = ''; |
|
26
|
8
|
|
|
|
|
21
|
while (length $data < $desired_len) { |
|
27
|
31
|
|
|
|
|
93
|
$d = md5($d . $passphrase . $salt); |
|
28
|
31
|
|
|
|
|
70
|
$data .= $d; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
8
|
|
|
|
|
20
|
return $data; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |