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

View File

@ -230,4 +230,9 @@ sub set_extension
my ($self, $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;