Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2699
Modified Files:
TlsClientHello.cs
Log Message:
2004-03-03 Carlos Guzman Alvarez <car...@te...>
* Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs:
- Initial implementation ( not finished )
Index: TlsClientHello.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TlsClientHello.cs 3 Mar 2004 16:15:43 -0000 1.3
--- TlsClientHello.cs 3 Mar 2004 17:32:14 -0000 1.4
***************
*** 30,33 ****
--- 30,42 ----
internal class TlsClientHello : HandshakeMessage
{
+ #region Private Fields
+
+ private byte[] random;
+ private byte[] sessionId;
+ private short[] cipherSuites;
+ private byte[] compressionMethods;
+
+ #endregion
+
#region Constructors
***************
*** 43,47 ****
public override void Update()
{
! throw new NotSupportedException();
}
--- 52,56 ----
public override void Update()
{
! this.selectCipherSuite();
}
***************
*** 57,61 ****
protected override void ProcessAsTls1()
{
! throw new NotSupportedException();
}
--- 66,140 ----
protected override void ProcessAsTls1()
{
! // Client Version
! this.processProtocol(this.ReadInt16());
!
! // Random bytes - Unix time + Radom bytes [28]
! this.random = this.ReadBytes(32);
!
! // Session id
! // Send the session ID empty
! byte[] sessionId = this.ReadBytes(this.ReadByte());
!
! // Read Supported Cipher Suites count
! this.cipherSuites = new short[this.ReadInt16()/2];
!
! // Read Cipher Suites
! for (int i = 0; i < this.cipherSuites.Length; i++)
! {
! this.cipherSuites[i] = this.ReadInt16();
! }
!
! // Compression methods length
! this.compressionMethods = new byte[this.ReadByte()];
!
! for (int i = 0; i < this.compressionMethods.Length; i++)
! {
! this.compressionMethods[i] = this.ReadByte();
! }
! }
!
! #endregion
!
! #region Private Methods
!
! private void processProtocol(short protocol)
! {
! SecurityProtocolType clientProtocol = this.Context.DecodeProtocolCode(protocol);
!
! if ((clientProtocol & this.Context.SecurityProtocolFlags) == clientProtocol ||
! (this.Context.SecurityProtocolFlags & SecurityProtocolType.Default) == SecurityProtocolType.Default)
! {
! this.Context.SecurityProtocol = clientProtocol;
! this.Context.SupportedCiphers.Clear();
! this.Context.SupportedCiphers = null;
! this.Context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(clientProtocol);
! }
! else
! {
! #warning "Send alert"
! throw this.Context.CreateException("Incorrect protocol version received from server");
! }
! }
!
! private void selectCipherSuite()
! {
! int index = 0;
! for (int i = 0; i < this.cipherSuites.Length; i++)
! {
! if ((index = this.Context.SupportedCiphers.IndexOf(this.cipherSuites[i])) != -1)
! {
! this.Context.Cipher = this.Context.SupportedCiphers[index];
! }
! }
!
! if (this.Context.Cipher == null)
! {
! #warning "Send an Alert and Throw and exception"
! }
! }
!
! private void selectCompressionMethod()
! {
! this.Context.CompressionMethod = SecurityCompressionType.None;
}
|