| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::CBC::PBKDF::opensslv1; |
|
2
|
8
|
|
|
8
|
|
65
|
use strict; |
|
|
8
|
|
|
|
|
18
|
|
|
|
8
|
|
|
|
|
380
|
|
|
3
|
8
|
|
|
8
|
|
40
|
use base 'Crypt::CBC::PBKDF'; |
|
|
8
|
|
|
|
|
14
|
|
|
|
8
|
|
|
|
|
1334
|
|
|
4
|
8
|
|
|
8
|
|
56
|
use Digest::MD5 'md5'; |
|
|
8
|
|
|
|
|
12
|
|
|
|
8
|
|
|
|
|
2489
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '3.07'; |
|
7
|
|
|
|
|
|
|
# options: |
|
8
|
|
|
|
|
|
|
# salt_len => 8 default |
|
9
|
|
|
|
|
|
|
# key_len => 32 default |
|
10
|
|
|
|
|
|
|
# iv_len => 16 default |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub create { |
|
13
|
3209
|
|
|
3209
|
0
|
6080
|
my $class = shift; |
|
14
|
3209
|
|
|
|
|
11774
|
my %options = @_; |
|
15
|
3209
|
|
50
|
|
|
16827
|
$options{salt_len} ||= 8; |
|
16
|
3209
|
|
100
|
|
|
6629
|
$options{key_len} ||= 32; |
|
17
|
3209
|
|
100
|
|
|
5513
|
$options{iv_len} ||= 16; |
|
18
|
3209
|
|
|
|
|
27956
|
return bless \%options,$class; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub generate_hash { |
|
22
|
66
|
|
|
66
|
0
|
127
|
my $self = shift; |
|
23
|
66
|
|
|
|
|
197
|
my ($salt,$passphrase) = @_; |
|
24
|
66
|
|
|
|
|
140
|
my $desired_len = $self->{key_len} + $self->{iv_len}; |
|
25
|
66
|
|
|
|
|
104
|
my $data = ''; |
|
26
|
66
|
|
|
|
|
93
|
my $d = ''; |
|
27
|
66
|
|
|
|
|
194
|
while (length $data < $desired_len) { |
|
28
|
263
|
|
|
|
|
827
|
$d = md5($d . $passphrase . $salt); |
|
29
|
263
|
|
|
|
|
734
|
$data .= $d; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
66
|
|
|
|
|
183
|
return $data; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |