line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Protocol::TLS::Extension::ServerName; |
2
|
2
|
|
|
2
|
|
1440
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
73
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
184
|
|
5
|
2
|
|
|
2
|
|
13
|
use Protocol::TLS::Trace qw(tracer); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
718
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# RFC 6066 - server_name extension |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my %name_types = ( |
10
|
|
|
|
|
|
|
0 => { |
11
|
|
|
|
|
|
|
decode => \&host_name_decode, |
12
|
|
|
|
|
|
|
encode => \&host_name_encode, |
13
|
|
|
|
|
|
|
}, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
4
|
|
|
4
|
0
|
25
|
bless {}, shift; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub type { |
21
|
4
|
|
|
4
|
0
|
28
|
0x0; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub name { |
25
|
0
|
|
|
0
|
0
|
0
|
'server_name'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub decode { |
29
|
1
|
|
|
1
|
0
|
2
|
my ( $self, $ctx, $result_ref, $buf_ref, $buf_offset, $length ) = @_; |
30
|
1
|
50
|
|
|
|
3
|
return undef if $length < 2; |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
4
|
my $l = unpack 'n', substr $$buf_ref, $buf_offset, 2; |
33
|
1
|
|
|
|
|
2
|
my $offset = 2; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
10
|
while ( $offset - 2 + 1 < $l ) { |
36
|
1
|
|
|
|
|
3
|
my $name_type = unpack 'C', substr $$buf_ref, $buf_offset + $offset, 1; |
37
|
1
|
|
|
|
|
2
|
$offset += 1; |
38
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
4
|
if ( exists $name_types{$name_type} ) { |
40
|
|
|
|
|
|
|
my $len = $name_types{$name_type}{decode}->( |
41
|
1
|
|
|
|
|
5
|
$ctx, \$$result_ref->{$name_type}, |
42
|
|
|
|
|
|
|
$buf_ref, |
43
|
|
|
|
|
|
|
$buf_offset + $offset, |
44
|
|
|
|
|
|
|
$l - $offset |
45
|
|
|
|
|
|
|
); |
46
|
1
|
50
|
|
|
|
4
|
return undef unless defined $len; |
47
|
1
|
|
|
|
|
4
|
$offset += $len; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
1
|
|
|
|
|
3
|
return $offset; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub host_name_decode { |
54
|
1
|
|
|
1
|
0
|
2
|
my ( $ctx, $result_ref, $buf_ref, $buf_offset, $length ) = @_; |
55
|
1
|
|
|
|
|
4
|
my $l = unpack 'n', substr $$buf_ref, $buf_offset, 2; |
56
|
1
|
50
|
|
|
|
3
|
return undef if $l > $length; |
57
|
1
|
|
|
|
|
4
|
$$result_ref = substr $$buf_ref, $buf_offset + 2, $l; |
58
|
1
|
|
|
|
|
3
|
return $l + 2; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub host_name_encode { |
62
|
0
|
|
|
0
|
0
|
|
croak "not implemented"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub encode { |
66
|
0
|
|
|
0
|
0
|
|
croak "not implemented"; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1 |