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