TLSProxy update

Add function to delete extensions and fix ClientHello repacking.

Reviewed-by: Matt Caswell <matt@openssl.org>
This commit is contained in:
Dr. Stephen Henson 2015-12-08 02:07:43 +00:00
parent 4160936143
commit 040c878350
2 changed files with 20 additions and 6 deletions

View File

@ -70,7 +70,7 @@ sub new
$records, $records,
$startoffset, $startoffset,
$message_frag_lens) = @_; $message_frag_lens) = @_;
my $self = $class->SUPER::new( my $self = $class->SUPER::new(
$server, $server,
1, 1,
@ -118,7 +118,7 @@ sub parse
#For now we just deal with this as a block of data. In the future we will #For now we just deal with this as a block of data. In the future we will
#want to parse this #want to parse this
my $extension_data = substr($self->data, $ptr); my $extension_data = substr($self->data, $ptr);
if (length($extension_data) != $extensions_len) { if (length($extension_data) != $extensions_len) {
die "Invalid extension length\n"; die "Invalid extension length\n";
} }
@ -169,6 +169,7 @@ sub set_message_contents
{ {
my $self = shift; my $self = shift;
my $data; my $data;
my $extensions = "";
$data = pack('n', $self->client_version); $data = pack('n', $self->client_version);
$data .= $self->random; $data .= $self->random;
@ -178,14 +179,17 @@ sub set_message_contents
$data .= pack("n*", @{$self->ciphersuites}); $data .= pack("n*", @{$self->ciphersuites});
$data .= pack('C', $self->comp_meth_len); $data .= pack('C', $self->comp_meth_len);
$data .= pack("C*", @{$self->comp_meths}); $data .= pack("C*", @{$self->comp_meths});
$data .= pack('n', $self->extensions_len);
foreach my $key (keys %{$self->extension_data}) { foreach my $key (keys %{$self->extension_data}) {
my $extdata = ${$self->extension_data}{$key}; my $extdata = ${$self->extension_data}{$key};
$data .= pack("n", $key); $extensions .= pack("n", $key);
$data .= pack("n", length($extdata)); $extensions .= pack("n", length($extdata));
$data .= $extdata; $extensions .= $extdata;
} }
$data .= pack('n', length($extensions));
$data .= $extensions;
$self->data($data); $self->data($data);
} }
@ -270,4 +274,9 @@ sub extension_data
} }
return $self->{extension_data}; return $self->{extension_data};
} }
sub delete_extension
{
my ($self, $ext_type) = @_;
delete $self->{extension_data}{$ext_type};
}
1; 1;

View File

@ -230,4 +230,9 @@ sub set_extension
my ($self, $ext_type, $ext_data) = @_; my ($self, $ext_type, $ext_data) = @_;
$self->{extension_data}{$ext_type} = $ext_data; $self->{extension_data}{$ext_type} = $ext_data;
} }
sub delete_extension
{
my ($self, $ext_type) = @_;
delete $self->{extension_data}{$ext_type};
}
1; 1;