line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1276
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
2
|
|
|
|
|
|
|
package Web::Authenticate::Digest; |
3
|
|
|
|
|
|
|
$Web::Authenticate::Digest::VERSION = '0.003'; |
4
|
1
|
|
|
1
|
|
425
|
use Mouse; |
|
1
|
|
|
|
|
19237
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
280
|
use Mouse::Util::TypeConstraints; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
577
|
use Crypt::PBKDF2; |
|
1
|
|
|
|
|
103395
|
|
|
1
|
|
|
|
|
149
|
|
7
|
|
|
|
|
|
|
#ABSTRACT: The default implementation of Web::Authenticate::Digest::Role. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Web::Authenticate::Digest::Role'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has crypt => ( |
13
|
|
|
|
|
|
|
isa => 'Crypt::PBKDF2', |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
required => 1, |
16
|
|
|
|
|
|
|
default => sub { |
17
|
|
|
|
|
|
|
Crypt::PBKDF2->new( |
18
|
|
|
|
|
|
|
hash_class => 'HMACSHA2', |
19
|
|
|
|
|
|
|
hash_args => { |
20
|
|
|
|
|
|
|
sha_size => 512, |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
iterations => 10000, |
23
|
|
|
|
|
|
|
salt_len => 10, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub generate { |
30
|
1
|
|
|
1
|
1
|
2
|
my ($self, $password) = @_; |
31
|
1
|
|
|
|
|
7
|
return $self->crypt->generate($password); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub validate { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, $hash, $password) = @_; |
37
|
0
|
|
|
|
|
|
return $self->crypt->validate($hash, $password); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=encoding UTF-8 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Web::Authenticate::Digest - The default implementation of Web::Authenticate::Digest::Role. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 VERSION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
version 0.003 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 crypt |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Sets the L<Crypt::PBKDF2> object that is used to create and validate digests. Below is the default: |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Crypt::PBKDF2->new( |
63
|
|
|
|
|
|
|
hash_class => 'HMACSHA2', |
64
|
|
|
|
|
|
|
hash_args => { |
65
|
|
|
|
|
|
|
sha_size => 512, |
66
|
|
|
|
|
|
|
}, |
67
|
|
|
|
|
|
|
iterations => 10000, |
68
|
|
|
|
|
|
|
salt_len => 10, |
69
|
|
|
|
|
|
|
) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 generate |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Accepts a password and returns the hex digest of that password using L</crypt>. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $password_digest = $digest->generate($password); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Uses L<Crypt::PBKDF2/"validate">. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $validate_success = $digest->validate($hash, $password); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Adam Hopkins <srchulo@cpan.org> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Adam Hopkins. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
92
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |