#region Properties
- public Stream InnerStream
- {
- get { return this.innerStream; }
- set { this.innerStream = value; }
- }
-
public Context Context
{
get { return this.context; }
buffer, received, buffer.Length - received);
}
+ DebugHelper.WriteLine(
+ ">>>> Read record ({0}|{1})",
+ this.context.DecodeProtocolCode(protocol),
+ contentType);
+ DebugHelper.WriteLine("Record data", buffer);
+
TlsStream message = new TlsStream(buffer);
// Check that the message has a valid protocol version
message = this.decryptRecordFragment(
contentType,
message.ToArray());
+
+ DebugHelper.WriteLine("Decrypted record data", message.ToArray());
}
}
}
public void SendAlert(Alert alert)
- {
+ {
+ DebugHelper.WriteLine(">>>> Write Alert ({0}|{1})", alert.Description, alert.Message);
+
// Write record
this.SendRecord(
ContentType.Alert,
public void SendChangeCipherSpec()
{
+ DebugHelper.WriteLine(">>>> Write Change Cipher Spec");
+
// Send Change Cipher Spec message as a plain message
this.context.IsActual = false;
record.Write((short)fragment.Length);
record.Write(fragment);
+ DebugHelper.WriteLine("Record data", fragment);
+
// Update buffer position
position += fragmentLength;
}
mac = this.context.Cipher.ComputeServerRecordMAC(contentType, fragment);
}
+ DebugHelper.WriteLine(">>>> Record MAC", mac);
+
// Encrypt the message
byte[] ecr = this.context.Cipher.EncryptRecord(fragment, mac);
mac = this.context.Cipher.ComputeClientRecordMAC(contentType, dcrFragment);
}
+ DebugHelper.WriteLine(">>>> Record MAC", mac);
+
// Check record MAC
if (mac.Length != dcrMAC.Length)
{
if (badRecordMac)
{
- if (this.context is ServerContext)
- {
- this.Context.RecordProtocol.SendAlert(AlertDescription.BadRecordMAC);
- }
-
- throw new TlsException("Bad record MAC");
+ throw new TlsException(AlertDescription.BadRecordMAC, "Bad record MAC");
}
// Update sequence number