| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::Passphrase::Yescrypt; |
|
2
|
|
|
|
|
|
|
$Crypt::Passphrase::Yescrypt::VERSION = '0.002'; |
|
3
|
2
|
|
|
2
|
|
620504
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
118
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
172
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
17
|
use parent 'Crypt::Passphrase::Encoder'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
10482
|
use Crypt::Yescrypt qw/yescrypt yescrypt_needs_rehash yescrypt_check/; |
|
|
2
|
|
|
|
|
833
|
|
|
|
2
|
|
|
|
|
1119
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
1
|
|
|
1
|
1
|
21
|
my ($class, %args) = @_; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
return bless { |
|
14
|
|
|
|
|
|
|
flags => $args{flags} // 0xb6, |
|
15
|
|
|
|
|
|
|
block_count => $args{block_count} // 16, |
|
16
|
|
|
|
|
|
|
block_size => $args{block_size} // 32, |
|
17
|
|
|
|
|
|
|
parallelism => $args{parallelism} // 1, |
|
18
|
|
|
|
|
|
|
time => $args{time} // 0, |
|
19
|
|
|
|
|
|
|
upgrades => $args{upgrades} // 0, |
|
20
|
1
|
|
50
|
|
|
31
|
salt_size => $args{salt_size} // 16, |
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
21
|
|
|
|
|
|
|
}, $class; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my @attributes = qw/flags block_count block_size parallelism time upgrades/; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub hash_password { |
|
27
|
1
|
|
|
1
|
1
|
152
|
my ($self, $password) = @_; |
|
28
|
1
|
|
|
|
|
14
|
my $salt = $self->random_bytes($self->{salt_size}); |
|
29
|
1
|
|
|
|
|
15
|
my $result = yescrypt($password, $salt, @{$self}{@attributes}); |
|
|
1
|
|
|
|
|
55302
|
|
|
30
|
1
|
|
33
|
|
|
23
|
return $result // Carp::croak("Can't hash password"); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub needs_rehash { |
|
34
|
4
|
|
|
4
|
1
|
48
|
my ($self, $hash) = @_; |
|
35
|
4
|
|
|
|
|
15
|
return yescrypt_needs_rehash($hash, @{$self}{@attributes}); |
|
|
4
|
|
|
|
|
56
|
|
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub crypt_subtypes { |
|
39
|
1
|
|
|
1
|
1
|
53
|
return qw/y 7/; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub verify_password { |
|
43
|
4
|
|
|
4
|
1
|
595
|
my ($class, $password, $hash) = @_; |
|
44
|
4
|
|
|
|
|
176998
|
return yescrypt_check($password, $hash); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#ABSTRACT: A yescrypt encoder for Crypt::Passphrase |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |