line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Argon2; |
2
|
|
|
|
|
|
|
$Crypt::Argon2::VERSION = '0.018'; |
3
|
1
|
|
|
1
|
|
68605
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Exporter 5.57 'import'; |
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
64
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ |
8
|
|
|
|
|
|
|
argon2_raw argon2_pass argon2_verify |
9
|
|
|
|
|
|
|
argon2id_raw argon2id_pass argon2id_verify |
10
|
|
|
|
|
|
|
argon2i_raw argon2i_pass argon2i_verify |
11
|
|
|
|
|
|
|
argon2d_raw argon2_pass argon2_verify |
12
|
|
|
|
|
|
|
argon2_needs_rehash argon2_types/; |
13
|
1
|
|
|
1
|
|
7
|
use XSLoader; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
413
|
|
14
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, __PACKAGE__->VERSION || 0); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $type_regex = qr/argon2(?:i|d|id)/; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %multiplier = ( |
19
|
|
|
|
|
|
|
k => 1, |
20
|
|
|
|
|
|
|
M => 1024, |
21
|
|
|
|
|
|
|
G => 1024 * 1024, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $regex = qr/ ^ \$ (argon2(?:i|d|id)) \$ v=(\d+) \$ m=(\d+), t=(\d+), p=(\d+) \$ ([^\$]+) \$ (.*) $ /x; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub argon2_needs_rehash { |
27
|
7
|
|
|
7
|
1
|
136421752
|
my ($encoded, $type, $t_cost, $m_cost, $parallelism, $output_length, $salt_length) = @_; |
28
|
7
|
|
|
|
|
1630
|
$m_cost =~ s/ \A (\d+) ([kMG]) \z / $1 * $multiplier{$2} * 1024 /xmse; |
|
7
|
|
|
|
|
94
|
|
29
|
7
|
|
|
|
|
797
|
$m_cost /= 1024; |
30
|
7
|
50
|
|
|
|
179
|
my ($name, $version, $m_got, $t_got, $parallel_got, $salt, $hash) = $encoded =~ $regex or return 1; |
31
|
7
|
100
|
66
|
|
|
5901
|
return 1 if $name ne $type or $version != 19 or $t_got != $t_cost or $m_got != $m_cost or $parallel_got != $parallelism; |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
32
|
3
|
100
|
100
|
|
|
791
|
return 1 if int(3 / 4 * length $salt) != $salt_length or int(3 / 4 * length $hash) != $output_length; |
33
|
1
|
|
|
|
|
1543
|
return 0; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub argon2_types { |
37
|
0
|
|
|
0
|
1
|
|
return qw/argon2id argon2i argon2d/; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# ABSTRACT: Perl interface to the Argon2 key derivation functions |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |