line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Keyczar::Verifier; |
2
|
6
|
|
|
6
|
|
30006
|
use base 'Crypt::Keyczar'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
1394
|
|
3
|
6
|
|
|
6
|
|
29
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
151
|
|
4
|
6
|
|
|
6
|
|
27
|
use warnings; |
|
6
|
|
|
|
|
1518
|
|
|
6
|
|
|
|
|
147
|
|
5
|
6
|
|
|
6
|
|
27
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
2095
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub verify { |
9
|
24
|
|
|
24
|
0
|
6989
|
my $self = shift; |
10
|
24
|
|
|
|
|
67
|
my ($data, $signature, $hidden) = @_; |
11
|
|
|
|
|
|
|
|
12
|
24
|
50
|
33
|
|
|
158
|
if (!defined $signature || length $signature < Crypt::Keyczar::HEADER_SIZE()) { |
13
|
0
|
|
|
|
|
0
|
croak "signature is short"; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
24
|
|
|
|
|
46
|
my $hash_size = Crypt::Keyczar::KEY_HASH_SIZE(); |
17
|
24
|
|
|
|
|
151
|
my ($v, $hash, $mac) = unpack "C1 a$hash_size a*", $signature; |
18
|
24
|
50
|
|
|
|
83
|
if ($v != Crypt::Keyczar::FORMAT_VERSION()) { |
19
|
0
|
|
|
|
|
0
|
croak "bad format version: $v"; |
20
|
|
|
|
|
|
|
} |
21
|
24
|
|
|
|
|
113
|
my $key = $self->get_key($hash); |
22
|
24
|
50
|
|
|
|
73
|
if (!$key) { |
23
|
0
|
|
|
|
|
0
|
croak "key not found"; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
24
|
|
|
|
|
87
|
my $engine = $key->get_engine(); |
27
|
24
|
|
|
|
|
48
|
my $expiration_time; |
28
|
24
|
100
|
66
|
|
|
246
|
if ($key->can('digest_size') && length $mac > $key->digest_size) { |
29
|
12
|
|
|
|
|
41
|
($expiration_time, $mac) = unpack "N1 a*", $mac; |
30
|
12
|
|
|
|
|
69
|
$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
|
|
|
|
|
10628
|
$engine->update($data); |
36
|
24
|
|
|
|
|
63
|
$engine->update(Crypt::Keyczar::FORMAT_BYTES()); |
37
|
24
|
|
|
|
|
822
|
my $result = $engine->verify($mac); |
38
|
24
|
100
|
|
|
|
84
|
return $result if !$result; |
39
|
22
|
100
|
|
|
|
53
|
if (defined $expiration_time) { |
40
|
12
|
|
|
|
|
101
|
return time() < $expiration_time; |
41
|
|
|
|
|
|
|
} |
42
|
10
|
|
|
|
|
114
|
return $result; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |