| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::CBC::PBKDF::randomiv; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This is for compatibility with early (pre v1.0) versions of OpenSSL |
|
4
|
|
|
|
|
|
|
# THE KEYS GENERATED BY THIS ALGORITHM ARE INSECURE!!! |
|
5
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
96
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use base 'Crypt::CBC::PBKDF'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
292
|
|
|
7
|
2
|
|
|
2
|
|
191
|
use Digest::MD5 'md5'; |
|
|
2
|
|
|
|
|
36
|
|
|
|
2
|
|
|
|
|
589
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '3.07'; |
|
10
|
|
|
|
|
|
|
# options: |
|
11
|
|
|
|
|
|
|
# salt_len => 8 default |
|
12
|
|
|
|
|
|
|
# key_len => 32 default |
|
13
|
|
|
|
|
|
|
# iv_len => 16 default |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub create { |
|
16
|
5
|
|
|
5
|
0
|
10
|
my $class = shift; |
|
17
|
5
|
|
|
|
|
21
|
my %options = @_; |
|
18
|
5
|
|
50
|
|
|
40
|
$options{salt_len} ||= 8; |
|
19
|
5
|
|
50
|
|
|
12
|
$options{key_len} ||= 32; |
|
20
|
5
|
|
50
|
|
|
13
|
$options{iv_len} ||= 16; |
|
21
|
5
|
|
|
|
|
42
|
return bless \%options,$class; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub generate_hash { |
|
25
|
5
|
|
|
5
|
0
|
7
|
my $self = shift; |
|
26
|
5
|
|
|
|
|
13
|
my ($salt,$passphrase) = @_; |
|
27
|
5
|
|
|
|
|
14
|
my $desired_len = $self->{key_len}; |
|
28
|
5
|
|
|
|
|
19
|
my $material = md5($passphrase); |
|
29
|
5
|
|
|
|
|
17
|
while (length($material) < $desired_len) { |
|
30
|
15
|
|
|
|
|
47
|
$material .= md5($material); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
5
|
|
|
|
|
11
|
substr($material,$desired_len) = ''; |
|
33
|
5
|
|
|
|
|
21
|
$material .= Crypt::CBC->_get_random_bytes($self->{iv_len}); |
|
34
|
5
|
|
|
|
|
16
|
return $material; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |