line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::PBE; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1547
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
103
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
105
|
|
5
|
3
|
|
|
3
|
|
1239
|
use utf8; |
|
3
|
|
|
|
|
31
|
|
|
3
|
|
|
|
|
18
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
86
|
use Carp; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
211
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
874
|
use Crypt::PBE::PBES1; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
144
|
|
10
|
3
|
|
|
3
|
|
959
|
use Crypt::PBE::PBES2; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
201
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.102'; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
22
|
use Exporter qw(import); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
668
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @JCE_PBE_ALGORITHMS = qw( |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
PBEWithMD5AndDES |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
PBEWithHmacSHA1AndAES_128 |
21
|
|
|
|
|
|
|
PBEWithHmacSHA1AndAES_192 |
22
|
|
|
|
|
|
|
PBEWithHmacSHA1AndAES_256 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
PBEWithHmacSHA224AndAES_128 |
25
|
|
|
|
|
|
|
PBEWithHmacSHA224AndAES_192 |
26
|
|
|
|
|
|
|
PBEWithHmacSHA224AndAES_256 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
PBEWithHmacSHA256AndAES_128 |
29
|
|
|
|
|
|
|
PBEWithHmacSHA256AndAES_192 |
30
|
|
|
|
|
|
|
PBEWithHmacSHA256AndAES_256 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
PBEWithHmacSHA384AndAES_128 |
33
|
|
|
|
|
|
|
PBEWithHmacSHA384AndAES_192 |
34
|
|
|
|
|
|
|
PBEWithHmacSHA384AndAES_256 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
PBEWithHmacSHA512AndAES_128 |
37
|
|
|
|
|
|
|
PBEWithHmacSHA512AndAES_192 |
38
|
|
|
|
|
|
|
PBEWithHmacSHA512AndAES_256 |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our @EXPORT_OK = @JCE_PBE_ALGORITHMS; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'jce' => \@JCE_PBE_ALGORITHMS ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# JCE algorithm PBEWithAnd |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $pbes1_map = { |
48
|
|
|
|
|
|
|
'PBEWithMD2AndDES' => { hash => 'md2', encryption => 'des' }, |
49
|
|
|
|
|
|
|
'PBEWithMD5AndDES' => { hash => 'md5', encryption => 'des' }, |
50
|
|
|
|
|
|
|
'PBEWithSHA1AndDES' => { hash => 'sha1', encryption => 'des' }, |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $pbes2_map = { |
54
|
|
|
|
|
|
|
'PBEWithHmacSHA1AndAES_128' => { hmac => 'hmac-sha1', encryption => 'aes-128' }, |
55
|
|
|
|
|
|
|
'PBEWithHmacSHA1AndAES_192' => { hmac => 'hmac-sha1', encryption => 'aes-192' }, |
56
|
|
|
|
|
|
|
'PBEWithHmacSHA1AndAES_256' => { hmac => 'hmac-sha1', encryption => 'aes-256' }, |
57
|
|
|
|
|
|
|
'PBEWithHmacSHA224AndAES_128' => { hmac => 'hmac-sha224', encryption => 'aes-128' }, |
58
|
|
|
|
|
|
|
'PBEWithHmacSHA224AndAES_192' => { hmac => 'hmac-sha224', encryption => 'aes-192' }, |
59
|
|
|
|
|
|
|
'PBEWithHmacSHA224AndAES_256' => { hmac => 'hmac-sha224', encryption => 'aes-256' }, |
60
|
|
|
|
|
|
|
'PBEWithHmacSHA256AndAES_128' => { hmac => 'hmac-sha256', encryption => 'aes-128' }, |
61
|
|
|
|
|
|
|
'PBEWithHmacSHA256AndAES_192' => { hmac => 'hmac-sha256', encryption => 'aes-192' }, |
62
|
|
|
|
|
|
|
'PBEWithHmacSHA256AndAES_256' => { hmac => 'hmac-sha256', encryption => 'aes-256' }, |
63
|
|
|
|
|
|
|
'PBEWithHmacSHA384AndAES_128' => { hmac => 'hmac-sha384', encryption => 'aes-128' }, |
64
|
|
|
|
|
|
|
'PBEWithHmacSHA384AndAES_192' => { hmac => 'hmac-sha384', encryption => 'aes-192' }, |
65
|
|
|
|
|
|
|
'PBEWithHmacSHA384AndAES_256' => { hmac => 'hmac-sha384', encryption => 'aes-256' }, |
66
|
|
|
|
|
|
|
'PBEWithHmacSHA512AndAES_128' => { hmac => 'hmac-sha512', encryption => 'aes-128' }, |
67
|
|
|
|
|
|
|
'PBEWithHmacSHA512AndAES_192' => { hmac => 'hmac-sha512', encryption => 'aes-192' }, |
68
|
|
|
|
|
|
|
'PBEWithHmacSHA512AndAES_256' => { hmac => 'hmac-sha512', encryption => 'aes-256' }, |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# PBES1 + PBDKF1 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
foreach ( keys %{$pbes1_map} ) { |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $params = $pbes1_map->{$_}; |
76
|
|
|
|
|
|
|
my $sub_name = $_; |
77
|
|
|
|
|
|
|
|
78
|
3
|
|
|
3
|
|
23
|
no strict 'refs'; ## no critic |
|
3
|
|
|
|
|
51
|
|
|
3
|
|
|
|
|
517
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
*{$sub_name} = sub { |
81
|
1
|
|
|
1
|
|
592
|
my ( $password, $count ) = @_; |
82
|
|
|
|
|
|
|
my $pbes1 = Crypt::PBE::PBES1->new( |
83
|
|
|
|
|
|
|
password => $password, |
84
|
|
|
|
|
|
|
count => $count || 1_000, |
85
|
|
|
|
|
|
|
hash => $params->{hash}, |
86
|
|
|
|
|
|
|
encryption => $params->{encryption}, |
87
|
1
|
|
50
|
|
|
11
|
); |
88
|
1
|
|
|
|
|
3
|
return $pbes1; |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# PBES2 + PBDKF2 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
foreach ( keys %{$pbes2_map} ) { |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $params = $pbes2_map->{$_}; |
98
|
|
|
|
|
|
|
my $sub_name = $_; |
99
|
|
|
|
|
|
|
|
100
|
3
|
|
|
3
|
|
22
|
no strict 'refs'; ## no critic |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
410
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
*{$sub_name} = sub { |
103
|
15
|
|
|
15
|
|
49
|
my ( $password, $count ) = @_; |
104
|
|
|
|
|
|
|
my $pbes2 = Crypt::PBE::PBES2->new( |
105
|
|
|
|
|
|
|
password => $password, |
106
|
|
|
|
|
|
|
count => $count || 1_000, |
107
|
|
|
|
|
|
|
hmac => $params->{hmac}, |
108
|
|
|
|
|
|
|
encryption => $params->{encryption}, |
109
|
15
|
|
50
|
|
|
49
|
); |
110
|
15
|
|
|
|
|
27
|
return $pbes2; |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
__END__ |