line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Argon2; |
2
|
|
|
|
|
|
|
$Crypt::Argon2::VERSION = '0.017'; |
3
|
1
|
|
|
1
|
|
70166
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Exporter 5.57 'import'; |
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
68
|
|
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
|
|
9
|
use XSLoader; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
431
|
|
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
|
128073022
|
my ($encoded, $type, $t_cost, $m_cost, $parallelism, $output_length, $salt_length) = @_; |
28
|
7
|
|
|
|
|
135
|
$m_cost =~ s/ \A (\d+) ([kMG]) \z / $1 * $multiplier{$2} * 1024 /xmse; |
|
7
|
|
|
|
|
93
|
|
29
|
7
|
|
|
|
|
964
|
$m_cost /= 1024; |
30
|
7
|
50
|
|
|
|
171
|
my ($name, $version, $m_got, $t_got, $parallel_got, $salt, $hash) = $encoded =~ $regex or return 1; |
31
|
7
|
100
|
66
|
|
|
5031
|
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
|
|
|
1998
|
return 1 if int(3 / 4 * length $salt) != $salt_length or int(3 / 4 * length $hash) != $output_length; |
33
|
1
|
|
|
|
|
2101
|
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__ |