$self->{p} = "";
$self->{g} = "";
$self->{pub_key} = "";
+ $self->{sigalg} = -1;
$self->{sig} = "";
return $self;
sub parse
{
my $self = shift;
+ my $sigalg = -1;
#Minimal SKE parsing. Only supports one known DHE ciphersuite at the moment
- return if (TLSProxy::Proxy->ciphersuite()
- != TLSProxy::Message::CIPHER_ADH_AES_128_SHA);
+ return if TLSProxy::Proxy->ciphersuite()
+ != TLSProxy::Message::CIPHER_ADH_AES_128_SHA
+ && TLSProxy::Proxy->ciphersuite()
+ != TLSProxy::Message::CIPHER_DHE_RSA_AES_128_SHA;
my $p_len = unpack('n', $self->data);
my $ptr = 2;
$ptr += $pub_key_len;
#We assume its signed
- my $sig_len = unpack('n', substr($self->data, $ptr));
+ my $record = ${$self->records}[0];
+
+ if (TLSProxy::Proxy->is_tls13()
+ || $record->version() == TLSProxy::Record::VERS_TLS_1_2) {
+ $sigalg = unpack('n', substr($self->data, $ptr));
+ $ptr += 2;
+ }
my $sig = "";
- if (defined $sig_len) {
- $ptr += 2;
- $sig = substr($self->data, $ptr, $sig_len);
- $ptr += $sig_len;
+ if (defined $sigalg) {
+ my $sig_len = unpack('n', substr($self->data, $ptr));
+ if (defined $sig_len) {
+ $ptr += 2;
+ $sig = substr($self->data, $ptr, $sig_len);
+ $ptr += $sig_len;
+ }
}
$self->p($p);
$self->g($g);
$self->pub_key($pub_key);
- $self->sig($sig);
+ $self->sigalg($sigalg) if defined $sigalg;
+ $self->signature($sig);
}
$data .= $self->g;
$data .= pack('n', length($self->pub_key));
$data .= $self->pub_key;
- if (length($self->sig) > 0) {
- $data .= pack('n', length($self->sig));
- $data .= $self->sig;
+ $data .= pack('n', $self->sigalg) if ($self->sigalg != -1);
+ if (length($self->signature) > 0) {
+ $data .= pack('n', length($self->signature));
+ $data .= $self->signature;
}
$self->data($data);
}
return $self->{pub_key};
}
-sub sig
+sub sigalg
+{
+ my $self = shift;
+ if (@_) {
+ $self->{sigalg} = shift;
+ }
+ return $self->{sigalg};
+}
+sub signature
{
my $self = shift;
if (@_) {