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
|
3
|
|
|
3
|
|
1270
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
84
|
|
5
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
32
|
|
|
3
|
|
|
|
|
62
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
689
|
use Crypt::Mode::CBC; |
|
3
|
|
|
|
|
455
|
|
|
3
|
|
|
|
|
65
|
|
8
|
3
|
|
|
3
|
|
17
|
use File::KDBX::Error; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
131
|
|
9
|
3
|
|
|
3
|
|
15
|
use File::KDBX::Util qw(:class); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
280
|
|
10
|
3
|
|
|
3
|
|
17
|
use namespace::clean; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
13
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
extends 'File::KDBX::Cipher'; |
13
|
0
|
0
|
|
0
|
1
|
0
|
|
14
|
0
|
0
|
|
|
|
0
|
our $VERSION = '0.904'; # VERSION |
15
|
0
|
|
0
|
|
|
0
|
|
16
|
|
|
|
|
|
|
has key_size => 32; |
17
|
0
|
|
|
0
|
1
|
0
|
sub iv_size { 16 } |
18
|
0
|
|
|
0
|
1
|
0
|
sub block_size { 16 } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub encrypt { |
21
|
10
|
|
|
10
|
1
|
16
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
10
|
|
66
|
|
|
32
|
my $mode = $self->{mode} ||= do { |
24
|
3
|
|
|
|
|
15
|
my $m = Crypt::Mode::CBC->new($self->algorithm); |
25
|
3
|
|
|
|
|
49
|
$m->start_encrypt($self->key, $self->iv); |
26
|
3
|
|
|
|
|
14
|
$m; |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
|
29
|
10
|
50
|
|
|
|
19
|
return join('', map { $mode->add(ref $_ ? $$_ : $_) } grep { defined } @_); |
|
10
|
|
|
|
|
98
|
|
|
10
|
|
|
|
|
24
|
|
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub decrypt { |
33
|
9
|
|
|
9
|
1
|
17
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
9
|
|
33
|
|
|
36
|
my $mode = $self->{mode} ||= do { |
36
|
9
|
|
|
|
|
29
|
my $m = Crypt::Mode::CBC->new($self->algorithm); |
37
|
9
|
|
|
|
|
36
|
$m->start_decrypt($self->key, $self->iv); |
38
|
9
|
|
|
|
|
33
|
$m; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
9
|
50
|
|
|
|
22
|
return join('', map { $mode->add(ref $_ ? $$_ : $_) } grep { defined } @_); |
|
9
|
|
|
|
|
217
|
|
|
9
|
|
|
|
|
25
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub finish { |
45
|
12
|
|
|
12
|
1
|
17
|
my $self = shift; |
46
|
12
|
50
|
|
|
|
27
|
return '' if !$self->{mode}; |
47
|
12
|
|
|
|
|
68
|
my $out = $self->{mode}->finish; |
48
|
11
|
|
|
|
|
47
|
delete $self->{mode}; |
49
|
11
|
|
|
|
|
35
|
return $out; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |