line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Passphrase::Argon2::AES; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1384
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
580
|
use parent 'Crypt::Passphrase::Argon2::Encrypted'; |
|
1
|
|
|
|
|
323
|
|
|
1
|
|
|
|
|
5
|
|
9
|
1
|
|
|
1
|
|
18457
|
use Crypt::Passphrase 0.010 -encoder; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
6
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
55
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
12
|
1
|
|
|
1
|
|
1127
|
use Crypt::Rijndael 1.16; |
|
1
|
|
|
|
|
2038
|
|
|
1
|
|
|
|
|
116
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %mode = ( |
15
|
|
|
|
|
|
|
'aes-cbc' => Crypt::Rijndael::MODE_CBC, |
16
|
|
|
|
|
|
|
'aes-ecb' => Crypt::Rijndael::MODE_ECB, |
17
|
|
|
|
|
|
|
'aes-cfb' => Crypt::Rijndael::MODE_CFB, |
18
|
|
|
|
|
|
|
'aes-ofb' => Crypt::Rijndael::MODE_OFB, |
19
|
|
|
|
|
|
|
'aes-ctr' => Crypt::Rijndael::MODE_CTR, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
1
|
|
|
1
|
1
|
16
|
my ($class, %args) = @_; |
24
|
1
|
50
|
|
|
|
9
|
my $peppers = $args{peppers} or croak('No peppers given'); |
25
|
1
|
50
|
33
|
1
|
|
7
|
$args{active} //= (sort {; no warnings 'numeric'; $b <=> $a || $b cmp $a } keys %{ $peppers })[0]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
427
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
5
|
|
26
|
1
|
|
50
|
|
|
6
|
my $mode = delete $args{mode} // 'cbc'; |
27
|
1
|
|
|
|
|
2
|
my $cipher = "aes-$mode"; |
28
|
1
|
50
|
|
|
|
3
|
croak("No such mode $mode") if not exists $mode{$cipher}; |
29
|
1
|
|
|
|
|
9
|
my $self = $class->SUPER::new(%args, cipher => $cipher); |
30
|
1
|
|
|
|
|
59
|
$self->{peppers} = $peppers; |
31
|
1
|
|
|
|
|
7
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub encrypt_hash { |
35
|
2
|
|
|
2
|
0
|
132622
|
my ($self, $cipher, $id, $iv, $raw) = @_; |
36
|
2
|
50
|
|
|
|
19
|
my $mode = $mode{$cipher} or croak "No such cipher $cipher"; |
37
|
2
|
50
|
|
|
|
14
|
my $secret = $self->{peppers}{$id} or croak "No such pepper $id"; |
38
|
2
|
|
|
|
|
122
|
return Crypt::Rijndael->new($secret, $mode)->encrypt($raw, $iv); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub decrypt_hash { |
42
|
0
|
|
|
0
|
0
|
|
my ($self, $cipher, $id, $iv, $raw) = @_; |
43
|
0
|
0
|
|
|
|
|
my $mode = $mode{$cipher} or croak "No such cipher $cipher"; |
44
|
0
|
0
|
|
|
|
|
my $secret = $self->{peppers}{$id} or croak "No such pepper $id"; |
45
|
0
|
|
|
|
|
|
return Crypt::Rijndael->new($secret, $mode)->decrypt($raw, $iv); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |