Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source
In directory sc8-pr-cvs1:/tmp/cvs-serv32692
Modified Files:
TlsReader.cs
Log Message:
Changed received messages parsing, not finished and needs testing
Index: TlsReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsReader.cs,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** TlsReader.cs 12 Sep 2003 23:49:21 -0000 1.14
--- TlsReader.cs 13 Sep 2003 07:48:49 -0000 1.15
***************
*** 330,385 ****
}
! byte[] result = null;
!
! TlsContentType contentType = (TlsContentType)base.ReadByte();
! TlsProtocol protocol = (TlsProtocol)this.ReadShort();
! int length = this.ReadShort();
! TlsStreamReader message = new TlsStreamReader(base.ReadBytes(length));
! // Check that the message as a valid protocol version
! if (protocol != TlsProtocol.Tls1)
{
! session.ThrowException("Invalid protocol version on message received from server");
! }
! // Decrypt message contents if needed
! if (contentType == TlsContentType.Alert &&
! length == 2)
! {
! }
! else
! {
! if (session.State.IsActual &&
! contentType != TlsContentType.ChangeCipherSpec)
{
! message = new TlsStreamReader(processCipherTextRecord(contentType, protocol, message.GetBytes()));
}
- }
! // Process record
! switch (contentType)
! {
! case TlsContentType.Alert:
! processAlert((TlsAlertLevel)message.ReadByte(),
! (TlsAlertDescription)message.ReadByte());
! break;
! case TlsContentType.ChangeCipherSpec:
! // Reset sequence numbers
! session.State.ReadSequenceNumber = 0;
! break;
! case TlsContentType.ApplicationData:
! result = message.GetBytes();
! break;
! case TlsContentType.Handshake:
! processHandshakeMessage(message);
! break;
! default:
! session.ThrowException("Unknown record received from server.");
! break;
}
--- 330,395 ----
}
! byte[] result = null;
! TlsStreamReader buffer = new TlsStreamReader(this.ReadBytes());
! while (!buffer.EOF)
{
! TlsContentType contentType = (TlsContentType)buffer.ReadByte();
! TlsProtocol protocol = (TlsProtocol)buffer.ReadShort();
! int length = buffer.ReadShort();
! TlsStreamReader message = new TlsStreamReader(buffer.ReadBytes(length));
!
! // Check that the message as a valid protocol version
! if (protocol != TlsProtocol.Tls1)
{
! session.ThrowException("Invalid protocol version on message received from server");
}
! // Decrypt message contents if needed
! if (contentType == TlsContentType.Alert &&
! length == 2)
! {
! }
! else
! {
! if (session.State.IsActual &&
! contentType != TlsContentType.ChangeCipherSpec)
! {
! message = new TlsStreamReader(processCipherTextRecord(contentType, protocol, message.GetBytes()));
! }
! }
! // Process record
! switch (contentType)
! {
! case TlsContentType.Alert:
! processAlert((TlsAlertLevel)message.ReadByte(),
! (TlsAlertDescription)message.ReadByte());
! break;
! case TlsContentType.ChangeCipherSpec:
! // Reset sequence numbers
! session.State.ReadSequenceNumber = 0;
! break;
! case TlsContentType.ApplicationData:
! result = message.GetBytes();
! break;
! case TlsContentType.Handshake:
! while (!message.EOF)
! {
! processHandshakeMessage(message);
! }
! break;
!
! default:
! session.ThrowException("Unknown record received from server.");
! break;
! }
!
! message.Reset();
}
|