diff options
author | Matt Caswell <matt@openssl.org> | 2016-11-07 13:50:43 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-12-08 17:16:23 +0000 |
commit | 71728dd8aa3acc0bc9d621f8c4a4032aa3325fe4 (patch) | |
tree | 4b1a34bee452b160332b4453e33fc9df939061f9 /util | |
parent | c901bccec6f747467e1af31473655c8290e32309 (diff) |
Send and Receive a TLSv1.3 format ServerHello
There are some minor differences in the format of a ServerHello in TLSv1.3.
Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/TLSProxy/ServerHello.pm | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/util/TLSProxy/ServerHello.pm b/util/TLSProxy/ServerHello.pm index a1bc7b3d48..40f04c2313 100644 --- a/util/TLSProxy/ServerHello.pm +++ b/util/TLSProxy/ServerHello.pm @@ -45,16 +45,30 @@ sub parse my $self = shift; my $ptr = 2; my ($server_version) = unpack('n', $self->data); + + # TODO(TLS1.3): Replace this reference to draft version before release + if ($server_version == TLSProxy::Record::VERS_TLS_1_3_DRAFT) { + $server_version = TLSProxy::Record::VERS_TLS_1_3; + TLSProxy::Proxy->is_tls13(1); + } + my $random = substr($self->data, $ptr, 32); $ptr += 32; - my $session_id_len = unpack('C', substr($self->data, $ptr)); - $ptr++; - my $session = substr($self->data, $ptr, $session_id_len); - $ptr += $session_id_len; + my $session_id_len = 0; + my $session = ""; + if (!TLSProxy::Proxy->is_tls13()) { + $session_id_len = unpack('C', substr($self->data, $ptr)); + $ptr++; + $session = substr($self->data, $ptr, $session_id_len); + $ptr += $session_id_len; + } my $ciphersuite = unpack('n', substr($self->data, $ptr)); $ptr += 2; - my $comp_meth = unpack('C', substr($self->data, $ptr)); - $ptr++; + my $comp_meth = 0; + if (!TLSProxy::Proxy->is_tls13()) { + $comp_meth = unpack('C', substr($self->data, $ptr)); + $ptr++; + } my $extensions_len = unpack('n', substr($self->data, $ptr)); if (!defined $extensions_len) { $extensions_len = 0; @@ -94,11 +108,9 @@ sub parse $self->process_data(); - # TODO(TLS1.3): Replace this reference to draft version before release - if ($server_version == TLSProxy::Record::VERS_TLS_1_3_DRAFT) { + if (TLSProxy::Proxy->is_tls13()) { TLSProxy::Record->server_encrypting(1); TLSProxy::Record->client_encrypting(1); - TLSProxy::Proxy->is_tls13(1); } print " Server Version:".$server_version."\n"; @@ -125,10 +137,14 @@ sub set_message_contents $data = pack('n', $self->server_version); $data .= $self->random; - $data .= pack('C', $self->session_id_len); - $data .= $self->session; + if (!TLSProxy::Proxy->is_tls13()) { + $data .= pack('C', $self->session_id_len); + $data .= $self->session; + } $data .= pack('n', $self->ciphersuite); - $data .= pack('C', $self->comp_meth); + if (!TLSProxy::Proxy->is_tls13()) { + $data .= pack('C', $self->comp_meth); + } foreach my $key (keys %{$self->extension_data}) { my $extdata = ${$self->extension_data}{$key}; @@ -152,9 +168,9 @@ sub server_version { my $self = shift; if (@_) { - $self->{client_version} = shift; + $self->{server_version} = shift; } - return $self->{client_version}; + return $self->{server_version}; } sub random { |