summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-08-02 17:24:54 +0100
committerMatt Caswell <matt@openssl.org>2016-08-15 23:14:30 +0100
commita2a0c86bb0d602253d02ded2a848ed69e8cc425a (patch)
tree55052ad87615adcd3848bd0ff2abfc9c87d227dd /util
parenta01c86a25198921c5b8adb45c9379088ace4e42e (diff)
Add some SSLv2 ClientHello tests
Test that we handle a TLS ClientHello in an SSLv2 record correctly. Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'util')
-rw-r--r--util/TLSProxy/Message.pm3
-rw-r--r--util/TLSProxy/Record.pm14
-rw-r--r--util/TLSProxy/ServerHello.pm20
3 files changed, 31 insertions, 6 deletions
diff --git a/util/TLSProxy/Message.pm b/util/TLSProxy/Message.pm
index b8db22fb85..321e080ea3 100644
--- a/util/TLSProxy/Message.pm
+++ b/util/TLSProxy/Message.pm
@@ -37,7 +37,8 @@ use constant {
#Alert descriptions
use constant {
AL_DESC_CLOSE_NOTIFY => 0,
- AL_DESC_UNEXPECTED_MESSAGE => 10
+ AL_DESC_UNEXPECTED_MESSAGE => 10,
+ AL_DESC_NO_RENEGOTIATION => 100
};
my %message_type = (
diff --git a/util/TLSProxy/Record.pm b/util/TLSProxy/Record.pm
index 2a605e33a7..423bad3bf1 100644
--- a/util/TLSProxy/Record.pm
+++ b/util/TLSProxy/Record.pm
@@ -98,6 +98,7 @@ sub get_records
$content_type,
$version,
$len,
+ 0,
$len_real,
$decrypt_len,
substr($packet, TLS_RECORD_HEADER_LENGTH, $len_real),
@@ -167,6 +168,7 @@ sub new
$content_type,
$version,
$len,
+ $sslv2,
$len_real,
$decrypt_len,
$data,
@@ -177,6 +179,7 @@ sub new
content_type => $content_type,
version => $version,
len => $len,
+ sslv2 => $sslv2,
len_real => $len_real,
decrypt_len => $decrypt_len,
data => $data,
@@ -247,7 +250,11 @@ sub reconstruct_record
my $self = shift;
my $data;
- $data = pack('Cnn', $self->content_type, $self->version, $self->len);
+ if ($self->sslv2) {
+ $data = pack('n', $self->len | 0x8000);
+ } else {
+ $data = pack('Cnn', $self->content_type, $self->version, $self->len);
+ }
$data .= $self->data;
return $data;
@@ -269,6 +276,11 @@ sub version
my $self = shift;
return $self->{version};
}
+sub sslv2
+{
+ my $self = shift;
+ return $self->{sslv2};
+}
sub len_real
{
my $self = shift;
diff --git a/util/TLSProxy/ServerHello.pm b/util/TLSProxy/ServerHello.pm
index ee2fd727d2..79a8be9a89 100644
--- a/util/TLSProxy/ServerHello.pm
+++ b/util/TLSProxy/ServerHello.pm
@@ -56,13 +56,25 @@ sub parse
my $comp_meth = unpack('C', substr($self->data, $ptr));
$ptr++;
my $extensions_len = unpack('n', substr($self->data, $ptr));
- $ptr += 2;
+ if (!defined $extensions_len) {
+ $extensions_len = 0;
+ } else {
+ $ptr += 2;
+ }
#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);
+ my $extension_data;
+ if ($extensions_len != 0) {
+ $extension_data = substr($self->data, $ptr);
- if (length($extension_data) != $extensions_len) {
- die "Invalid extension length\n";
+ if (length($extension_data) != $extensions_len) {
+ die "Invalid extension length\n";
+ }
+ } else {
+ if (length($self->data) != $ptr) {
+ die "Invalid extension length\n";
+ }
+ $extension_data = "";
}
my %extensions = ();
while (length($extension_data) >= 4) {