line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::KDBX::Cipher::CBC; |
2
|
|
|
|
|
|
|
# ABSTRACT: A CBC block cipher mode encrypter/decrypter |
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
2834
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
176
|
|
5
|
6
|
|
|
6
|
|
25
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
112
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
767
|
use Crypt::Mode::CBC; |
|
6
|
|
|
|
|
473
|
|
|
6
|
|
|
|
|
128
|
|
8
|
6
|
|
|
6
|
|
32
|
use File::KDBX::Error; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
266
|
|
9
|
6
|
|
|
6
|
|
32
|
use File::KDBX::Util qw(:class); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
611
|
|
10
|
6
|
|
|
6
|
|
38
|
use namespace::clean; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
54
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
extends 'File::KDBX::Cipher'; |
13
|
0
|
0
|
|
0
|
1
|
0
|
|
14
|
0
|
0
|
|
|
|
0
|
our $VERSION = '0.906'; # VERSION |
15
|
0
|
|
0
|
|
|
0
|
|
16
|
|
|
|
|
|
|
has key_size => 32; |
17
|
14
|
|
|
14
|
1
|
32
|
sub iv_size { 16 } |
18
|
0
|
|
|
0
|
1
|
0
|
sub block_size { 16 } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub encrypt { |
21
|
80
|
|
|
80
|
1
|
112
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
80
|
|
66
|
|
|
189
|
my $mode = $self->{mode} ||= do { |
24
|
17
|
|
|
|
|
79
|
my $m = Crypt::Mode::CBC->new($self->algorithm); |
25
|
17
|
|
|
|
|
112
|
$m->start_encrypt($self->key, $self->iv); |
26
|
17
|
|
|
|
|
65
|
$m; |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
80
|
50
|
|
|
|
149
|
return join('', map { $mode->add(ref $_ ? $$_ : $_) } grep { defined } @_); |
|
80
|
|
|
|
|
798
|
|
|
80
|
|
|
|
|
186
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub decrypt { |
33
|
25
|
|
|
25
|
1
|
51
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
25
|
|
33
|
|
|
99
|
my $mode = $self->{mode} ||= do { |
36
|
25
|
|
|
|
|
85
|
my $m = Crypt::Mode::CBC->new($self->algorithm); |
37
|
25
|
|
|
|
|
99
|
$m->start_decrypt($self->key, $self->iv); |
38
|
25
|
|
|
|
|
78
|
$m; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
25
|
50
|
|
|
|
61
|
return join('', map { $mode->add(ref $_ ? $$_ : $_) } grep { defined } @_); |
|
25
|
|
|
|
|
560
|
|
|
25
|
|
|
|
|
87
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub finish { |
45
|
37
|
|
|
37
|
1
|
63
|
my $self = shift; |
46
|
37
|
50
|
|
|
|
103
|
return '' if !$self->{mode}; |
47
|
37
|
|
|
|
|
232
|
my $out = $self->{mode}->finish; |
48
|
36
|
|
|
|
|
147
|
delete $self->{mode}; |
49
|
36
|
|
|
|
|
124
|
return $out; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |