| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Protocol::TLS::Extension; |
|
2
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
52
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
47
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
112
|
|
|
5
|
2
|
|
|
2
|
|
1657
|
use Module::Runtime qw(require_module); |
|
|
2
|
|
|
|
|
3549
|
|
|
|
2
|
|
|
|
|
12
|
|
|
6
|
2
|
|
|
2
|
|
99
|
use Protocol::TLS::Trace qw(tracer); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
738
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub ext_decode { |
|
9
|
1
|
|
|
1
|
0
|
3
|
my ( $ctx, $result_ref, $buf_ref, $buf_offset, $length ) = @_; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Length error |
|
12
|
1
|
50
|
|
|
|
5
|
if ( $length < 2 ) { |
|
13
|
0
|
|
|
|
|
0
|
tracer->debug("Extensions length error: MUST be at least 2 bytes\n"); |
|
14
|
0
|
|
|
|
|
0
|
$ctx->error(); |
|
15
|
0
|
|
|
|
|
0
|
return undef; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
5
|
my $ext_l = unpack 'n', substr $$buf_ref, $buf_offset, 2; |
|
19
|
1
|
|
|
|
|
2
|
my $offset = 2; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Length error |
|
22
|
1
|
50
|
|
|
|
5
|
if ( $offset + $ext_l > $length ) { |
|
23
|
0
|
|
|
|
|
0
|
tracer->debug("Extensions length error: $ext_l\n"); |
|
24
|
0
|
|
|
|
|
0
|
$ctx->error(); |
|
25
|
0
|
|
|
|
|
0
|
return undef; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
4
|
while ( $offset + 4 < $length ) { |
|
29
|
1
|
|
|
|
|
5
|
my ( $type, $l ) = unpack 'n2', substr $$buf_ref, |
|
30
|
|
|
|
|
|
|
$buf_offset + $offset, 4; |
|
31
|
1
|
|
|
|
|
2
|
$offset += 4; |
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
50
|
|
|
|
4
|
if ( $offset + $l > $length ) { |
|
34
|
0
|
|
|
|
|
0
|
tracer->debug("Extension $type length error: $l\n"); |
|
35
|
0
|
|
|
|
|
0
|
$ctx->error(); |
|
36
|
0
|
|
|
|
|
0
|
return undef; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
6
|
if ( exists $ctx->{extensions}->{$type} ) { |
|
40
|
1
|
|
|
|
|
13
|
$ctx->{extensions}->{$type}->decode( $ctx, \$$result_ref->{$type}, |
|
41
|
|
|
|
|
|
|
$buf_ref, $buf_offset + $offset, $l ); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
1
|
|
|
|
|
4
|
$offset += $l; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
4
|
return $offset; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub ext_encode { |
|
50
|
0
|
|
|
0
|
0
|
0
|
croak "not implemented"; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub load_extensions { |
|
54
|
4
|
|
|
4
|
0
|
10
|
my $ctx = shift; |
|
55
|
4
|
|
|
|
|
15
|
for my $ext (@_) { |
|
56
|
4
|
|
|
|
|
13
|
my $m = 'Protocol::TLS::Extension::' . $ext; |
|
57
|
4
|
|
|
|
|
21
|
require_module($m); |
|
58
|
4
|
|
|
|
|
77
|
$ctx->{extensions}->{ $m->type } = $m->new; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1 |