[pgsqlclient-checkins] pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Sec
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-10-21 20:49:38
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client In directory sc8-pr-cvs1:/tmp/cvs-serv7785 Modified Files: TlsClientFinished.cs TlsClientHello.cs TlsServerFinished.cs TlsServerHello.cs TlsServerHelloDone.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsClientFinished.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsClientFinished.cs 20 Oct 2003 10:01:19 -0000 1.5 --- TlsClientFinished.cs 21 Oct 2003 20:06:28 -0000 1.6 *************** *** 51,57 **** #region PROTECTED_METHODS protected override void ProcessAsSsl3() { ! throw new NotSupportedException(); } --- 51,98 ---- #region PROTECTED_METHODS + private byte[] computeSslHash(string hashName, byte[] hashes, int sender) + { + HashAlgorithm hash = HashAlgorithm.Create(hashName); + TlsStream block = new TlsStream(); + TlsSslCipherSuite cipher = (TlsSslCipherSuite)this.Session.Context.Cipher; + byte[] pad1 = null; + byte[] pad2 = null; + + cipher.GeneratePad(hashName, ref pad1, ref pad2); + + block.Write(hashes); + block.Write(sender); + block.Write(this.Session.Context.MasterSecret); + block.Write(cipher.Pad1); + + block.Reset(); + + byte[] blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); + + block.Write(this.Session.Context.MasterSecret); + block.Write(cipher.Pad2); + block.Write(blockHash); + + hash.TransformFinalBlock(block.ToArray(), 0, (int)block.Length); + + block.Reset(); + + return hash.Hash; + } + protected override void ProcessAsSsl3() { ! // Get hashes of handshake messages ! TlsStream hashes = new TlsStream(); ! ! hashes.Write(computeSslHash("MD5", Session.Context.HandshakeHashes.Messages, 0x434C4E54)); ! hashes.Write(computeSslHash("SHA1", Session.Context.HandshakeHashes.Messages, 0x434C4E54)); ! ! // Write message contents ! Write(hashes.ToArray()); ! ! // Reset data ! hashes.Reset(); ! Session.Context.HandshakeHashes.Reset(); } Index: TlsClientHello.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsClientHello.cs 21 Oct 2003 16:06:15 -0000 1.7 --- TlsClientHello.cs 21 Oct 2003 20:06:28 -0000 1.8 *************** *** 95,104 **** // Write length of Cipher suites ! Write((short)(this.Session.SupportedCiphers.Count*2)); // Write Supported Cipher suites ! for (int i = 0; i < this.Session.SupportedCiphers.Count; i++) { ! Write((short)this.Session.SupportedCiphers[i].Code); } --- 95,104 ---- // Write length of Cipher suites ! Write((short)(this.Session.Context.SupportedCiphers.Count*2)); // Write Supported Cipher suites ! for (int i = 0; i < this.Session.Context.SupportedCiphers.Count; i++) { ! Write((short)this.Session.Context.SupportedCiphers[i].Code); } Index: TlsServerFinished.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsServerFinished.cs 20 Oct 2003 10:01:19 -0000 1.6 --- TlsServerFinished.cs 21 Oct 2003 20:06:28 -0000 1.7 *************** *** 45,49 **** base.UpdateSession(); ! Session.HandshakeFinished = true; } --- 45,49 ---- base.UpdateSession(); ! this.Session.Context.HandshakeFinished = true; } Index: TlsServerHello.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TlsServerHello.cs 21 Oct 2003 17:50:35 -0000 1.8 --- TlsServerHello.cs 21 Oct 2003 20:06:28 -0000 1.9 *************** *** 35,39 **** private byte[] random; private byte[] sessionId; ! private TlsAbstractCipherSuite cipherSuite; #endregion --- 35,39 ---- private byte[] random; private byte[] sessionId; ! private CipherSuite cipherSuite; #endregion *************** *** 55,58 **** --- 55,62 ---- this.Session.SetSessionId(this.sessionId); + if (this.protocol != this.Session.Context.Protocol) + { + this.Session.Context.SupportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(this.protocol); + } this.Session.Context.Protocol = this.protocol; this.Session.Context.ServerRandom = this.random; *************** *** 98,107 **** // Read cipher suite short cipherCode = this.ReadInt16(); ! if (this.Session.SupportedCiphers.IndexOf(cipherCode) == -1) { // The server has sent an invalid ciphersuite throw new TlsException("Invalid cipher suite received from server"); } ! this.cipherSuite = this.Session.SupportedCiphers[cipherCode]; // Read compression methods ( always 0 ) --- 102,111 ---- // Read cipher suite short cipherCode = this.ReadInt16(); ! if (this.Session.Context.SupportedCiphers.IndexOf(cipherCode) == -1) { // The server has sent an invalid ciphersuite throw new TlsException("Invalid cipher suite received from server"); } ! this.cipherSuite = this.Session.Context.SupportedCiphers[cipherCode]; // Read compression methods ( always 0 ) *************** *** 126,135 **** // Read cipher suite short cipherCode = this.ReadInt16(); ! if (this.Session.SupportedCiphers.IndexOf(cipherCode) == -1) { // The server has sent an invalid ciphersuite throw new TlsException("Invalid cipher suite received from server"); } ! this.cipherSuite = this.Session.SupportedCiphers[cipherCode]; // Read compression methods ( always 0 ) --- 130,139 ---- // Read cipher suite short cipherCode = this.ReadInt16(); ! if (this.Session.Context.SupportedCiphers.IndexOf(cipherCode) == -1) { // The server has sent an invalid ciphersuite throw new TlsException("Invalid cipher suite received from server"); } ! this.cipherSuite = this.Session.Context.SupportedCiphers[cipherCode]; // Read compression methods ( always 0 ) Index: TlsServerHelloDone.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHelloDone.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsServerHelloDone.cs 16 Oct 2003 14:25:57 -0000 1.4 --- TlsServerHelloDone.cs 21 Oct 2003 20:06:28 -0000 1.5 *************** *** 44,48 **** base.UpdateSession(); ! Session.HelloDone = true; } --- 44,48 ---- base.UpdateSession(); ! this.Session.Context.HelloDone = true; } |