line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::Verifier; |
2
|
6
|
|
|
6
|
|
15649
|
use base 'Crypt::Keyczar'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
849
|
|
3
|
6
|
|
|
6
|
|
37
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
113
|
|
4
|
6
|
|
|
6
|
|
25
|
use warnings; |
|
6
|
|
|
|
|
31
|
|
|
6
|
|
|
|
|
114
|
|
5
|
6
|
|
|
6
|
|
26
|
use Carp; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1313
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub verify { |
9
|
24
|
|
|
24
|
0
|
5673
|
my $self = shift; |
10
|
24
|
|
|
|
|
57
|
my ($data, $signature, $hidden) = @_; |
11
|
|
|
|
|
|
|
|
12
|
24
|
50
|
33
|
|
|
132
|
if (!defined $signature || length $signature < Crypt::Keyczar::HEADER_SIZE()) { |
13
|
0
|
|
|
|
|
0
|
croak "signature is short"; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
24
|
|
|
|
|
42
|
my $hash_size = Crypt::Keyczar::KEY_HASH_SIZE(); |
17
|
24
|
|
|
|
|
114
|
my ($v, $hash, $mac) = unpack "C1 a$hash_size a*", $signature; |
18
|
24
|
50
|
|
|
|
71
|
if ($v != Crypt::Keyczar::FORMAT_VERSION()) { |
19
|
0
|
|
|
|
|
0
|
croak "bad format version: $v"; |
20
|
|
|
|
|
|
|
} |
21
|
24
|
|
|
|
|
87
|
my $key = $self->get_key($hash); |
22
|
24
|
50
|
|
|
|
70
|
if (!$key) { |
23
|
0
|
|
|
|
|
0
|
croak "key not found"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
24
|
|
|
|
|
67
|
my $engine = $key->get_engine(); |
27
|
24
|
|
|
|
|
51
|
my $expiration_time; |
28
|
24
|
100
|
66
|
|
|
169
|
if ($key->can('digest_size') && length $mac > $key->digest_size) { |
29
|
12
|
|
|
|
|
46
|
($expiration_time, $mac) = unpack "N1 a*", $mac; |
30
|
12
|
|
|
|
|
60
|
$engine->update(pack 'N1', $expiration_time); |
31
|
|
|
|
|
|
|
} |
32
|
24
|
50
|
33
|
|
|
80
|
if (defined $hidden && length $hidden > 0) { |
33
|
0
|
|
|
|
|
0
|
$engine->update($hidden); |
34
|
|
|
|
|
|
|
} |
35
|
24
|
|
|
|
|
102
|
$engine->update($data); |
36
|
24
|
|
|
|
|
68
|
$engine->update(Crypt::Keyczar::FORMAT_BYTES()); |
37
|
24
|
|
|
|
|
504
|
my $result = $engine->verify($mac); |
38
|
24
|
100
|
|
|
|
80
|
return $result if !$result; |
39
|
22
|
100
|
|
|
|
52
|
if (defined $expiration_time) { |
40
|
12
|
|
|
|
|
101
|
return time() < $expiration_time; |
41
|
|
|
|
|
|
|
} |
42
|
10
|
|
|
|
|
95
|
return $result; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |