line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Passphrase::Argon2::AES; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
495
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
404
|
use parent 'Crypt::Passphrase::Argon2::Encrypted'; |
|
1
|
|
|
|
|
244
|
|
|
1
|
|
|
|
|
4
|
|
9
|
1
|
|
|
1
|
|
9746
|
use Crypt::Passphrase 0.010 -encoder; |
|
1
|
|
|
|
|
23
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
50
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
12
|
1
|
|
|
1
|
|
380
|
use Crypt::Rijndael 1.16; |
|
1
|
|
|
|
|
373
|
|
|
1
|
|
|
|
|
73
|
|
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
|
15
|
my ($class, %args) = @_; |
24
|
1
|
50
|
|
|
|
8
|
my $peppers = $args{peppers} or croak('No peppers given'); |
25
|
1
|
50
|
33
|
1
|
|
6
|
$args{active} //= (sort {; no warnings 'numeric'; $b <=> $a || $b cmp $a } keys %{ $peppers })[0]; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
365
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
6
|
|
26
|
1
|
|
50
|
|
|
5
|
my $mode = delete $args{mode} // 'cbc'; |
27
|
1
|
|
|
|
|
2
|
my $cipher = "aes-$mode"; |
28
|
1
|
50
|
|
|
|
5
|
croak("No such mode $mode") if not exists $mode{$cipher}; |
29
|
1
|
|
|
|
|
8
|
my $self = $class->SUPER::new(%args, cipher => $cipher); |
30
|
1
|
|
|
|
|
44
|
$self->{peppers} = $peppers; |
31
|
1
|
|
|
|
|
5
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub encrypt_hash { |
35
|
1
|
|
|
1
|
0
|
60430
|
my ($self, $cipher, $id, $iv, $raw) = @_; |
36
|
1
|
50
|
|
|
|
9
|
my $mode = $mode{$cipher} or croak "No such cipher $cipher"; |
37
|
1
|
50
|
|
|
|
7
|
my $secret = $self->{peppers}{$id} or croak "No such pepper $id"; |
38
|
1
|
|
|
|
|
46
|
return Crypt::Rijndael->new($secret, $mode)->encrypt($raw, $iv); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub decrypt_hash { |
42
|
2
|
|
|
2
|
0
|
140739
|
my ($self, $cipher, $id, $iv, $raw) = @_; |
43
|
2
|
50
|
|
|
|
18
|
my $mode = $mode{$cipher} or croak "No such cipher $cipher"; |
44
|
2
|
50
|
|
|
|
14
|
my $secret = $self->{peppers}{$id} or croak "No such pepper $id"; |
45
|
2
|
|
|
|
|
64
|
return Crypt::Rijndael->new($secret, $mode)->decrypt($raw, $iv); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub supported_ciphers { |
49
|
1
|
|
|
1
|
0
|
101
|
return keys %mode; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |