+
+sub not_on_record_boundary
+{
+ my $proxy = shift;
+ my $data;
+
+ #Find server's first flight
+ if ($proxy->flight != 1) {
+ return;
+ }
+
+ if ($boundary_test_type == DATA_AFTER_SERVER_HELLO) {
+ #Merge the ServerHello and EncryptedExtensions records into one
+ my $i;
+ for ($i = 0; ${$proxy->record_list}[$i]->flight() < 1; $i++) {
+ next;
+ }
+ $data = ${$proxy->record_list}[$i]->data();
+ $data .= ${$proxy->record_list}[$i + 1]->decrypt_data();
+ ${$proxy->record_list}[$i]->data($data);
+ ${$proxy->record_list}[$i]->len(length $data);
+
+ #Delete the old EncryptedExtensions record
+ splice @{$proxy->record_list}, $i + 1, 1;
+ } elsif ($boundary_test_type == DATA_AFTER_FINISHED) {
+ $data = ${$proxy->record_list}[-1]->decrypt_data;
+
+ #Add a KeyUpdate message onto the end of the Finished record
+ my $keyupdate = pack "C5",
+ 0x18, # KeyUpdate
+ 0x00, 0x00, 0x01, # Message length
+ 0x00; # Update not requested
+
+ $data .= $keyupdate;
+
+ #Add content type and tag
+ $data .= pack("C", TLSProxy::Record::RT_HANDSHAKE).("\0"x16);
+
+ #Update the record
+ ${$proxy->record_list}[-1]->data($data);
+ ${$proxy->record_list}[-1]->len(length $data);
+ } else {
+ #KeyUpdates must end on a record boundary
+
+ my $record = TLSProxy::Record->new(
+ 1,
+ TLSProxy::Record::RT_APPLICATION_DATA,
+ TLSProxy::Record::VERS_TLS_1_0,
+ 0,
+ 0,
+ 0,
+ 0,
+ "",
+ ""
+ );
+
+ #Add two KeyUpdate messages into a single record
+ my $keyupdate = pack "C5",
+ 0x18, # KeyUpdate
+ 0x00, 0x00, 0x01, # Message length
+ 0x00; # Update not requested
+
+ $data = $keyupdate.$keyupdate;
+
+ #Add content type and tag
+ $data .= pack("C", TLSProxy::Record::RT_HANDSHAKE).("\0"x16);
+
+ $record->data($data);
+ $record->len(length $data);
+ push @{$proxy->record_list}, $record;
+ }
+}