pgsqlclient-checkins Mailing List for PostgreSqlClient (Page 36)
Status: Inactive
Brought to you by:
carlosga_fb
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(120) |
Aug
(95) |
Sep
(95) |
Oct
(213) |
Nov
(114) |
Dec
(64) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(6) |
Feb
(134) |
Mar
(88) |
Apr
(28) |
May
(22) |
Jun
(15) |
Jul
(23) |
Aug
(2) |
Sep
(15) |
Oct
(2) |
Nov
(6) |
Dec
|
2005 |
Jan
(8) |
Feb
(6) |
Mar
|
Apr
(42) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(84) |
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
(84) |
Apr
(46) |
May
(40) |
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <car...@us...> - 2003-10-22 13:12:58
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv25051 Modified Files: TlsSocket.cs TlsSslCipherSuite.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsSocket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSocket.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TlsSocket.cs 21 Oct 2003 20:04:10 -0000 1.8 --- TlsSocket.cs 22 Oct 2003 11:47:44 -0000 1.9 *************** *** 55,59 **** internal BufferedStream InputBuffer { ! get { return inputBuffer; } } --- 55,59 ---- internal BufferedStream InputBuffer { ! get { return this.inputBuffer; } } *************** *** 113,117 **** public new int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags) { ! if (!session.IsSecure) { return base.Receive(buffer, offset, size, socketFlags); --- 113,117 ---- public new int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags) { ! if (!this.session.IsSecure) { return base.Receive(buffer, offset, size, socketFlags); *************** *** 119,123 **** // If actual buffer is full readed reset it ! if (inputBuffer.Position == inputBuffer.Length) { this.resetBuffer(); --- 119,123 ---- // If actual buffer is full readed reset it ! if (this.inputBuffer.Position == this.inputBuffer.Length) { this.resetBuffer(); *************** *** 126,133 **** // Check if we have space in the middle buffer // if not Read next TLS record and update the inputBuffer ! while ((inputBuffer.Length - inputBuffer.Position) < size) { // Read next record and write it into the inputBuffer ! long position = inputBuffer.Position; byte[] record = this.receiveRecord(); --- 126,133 ---- // Check if we have space in the middle buffer // if not Read next TLS record and update the inputBuffer ! while ((this.inputBuffer.Length - this.inputBuffer.Position) < size) { // Read next record and write it into the inputBuffer ! long position = this.inputBuffer.Position; byte[] record = this.receiveRecord(); *************** *** 135,143 **** { // Write new data to the inputBuffer ! inputBuffer.Seek(0, SeekOrigin.End); ! inputBuffer.Write(record, 0, record.Length); // Restore buffer position ! inputBuffer.Seek(position, SeekOrigin.Begin); } --- 135,143 ---- { // Write new data to the inputBuffer ! this.inputBuffer.Seek(0, SeekOrigin.End); ! this.inputBuffer.Write(record, 0, record.Length); // Restore buffer position ! this.inputBuffer.Seek(position, SeekOrigin.Begin); } *************** *** 148,152 **** } ! return inputBuffer.Read(buffer, offset, size); } --- 148,152 ---- } ! return this.inputBuffer.Read(buffer, offset, size); } *************** *** 168,172 **** public new int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags) { ! if (!session.IsSecure) { return base.Send(buffer, offset, size, socketFlags); --- 168,172 ---- public new int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags) { ! if (!this.session.IsSecure) { return base.Send(buffer, offset, size, socketFlags); *************** *** 186,192 **** private byte[] receiveRecord() { ! if (session.Context.ConnectionEnd) { ! throw session.CreateException("The session is finished and it's no longer valid."); } --- 186,192 ---- private byte[] receiveRecord() { ! if (this.session.Context.ConnectionEnd) { ! throw this.session.CreateException("The session is finished and it's no longer valid."); } *************** *** 206,212 **** TlsStream message = new TlsStream(buffer); ! // Check that the message as a valid protocol version ! if ((protocol != this.session.Context.Protocol && this.session.Context.HelloDone) || ! (protocol != TlsProtocol.Tls1 && protocol != TlsProtocol.Ssl3 )) { throw session.CreateException("Invalid protocol version on message received from server"); --- 206,211 ---- TlsStream message = new TlsStream(buffer); ! // Check that the message has a valid protocol version ! if (protocol != this.session.Context.Protocol) { throw session.CreateException("Invalid protocol version on message received from server"); *************** *** 222,228 **** contentType != TlsContentType.ChangeCipherSpec) { ! message = decryptRecordFragment( contentType, ! protocol, message.ToArray()); } --- 221,227 ---- contentType != TlsContentType.ChangeCipherSpec) { ! message = this.decryptRecordFragment( contentType, ! protocol, message.ToArray()); } *************** *** 235,239 **** { case TlsContentType.Alert: ! processAlert((TlsAlertLevel)message.ReadByte(), (TlsAlertDescription)message.ReadByte()); break; --- 234,238 ---- { case TlsContentType.Alert: ! this.processAlert((TlsAlertLevel)message.ReadByte(), (TlsAlertDescription)message.ReadByte()); break; *************** *** 241,245 **** case TlsContentType.ChangeCipherSpec: // Reset sequence numbers ! session.Context.ReadSequenceNumber = 0; break; --- 240,244 ---- case TlsContentType.ChangeCipherSpec: // Reset sequence numbers ! this.session.Context.ReadSequenceNumber = 0; break; *************** *** 250,254 **** while (!message.EOF) { ! processHandshakeMessage(message); } // Update handshakes of current messages --- 249,253 ---- while (!message.EOF) { ! this.processHandshakeMessage(message); } // Update handshakes of current messages *************** *** 273,288 **** // Encrypt the message ! byte[] ecr = session.Context.Cipher.EncryptRecord(fragment, mac); // Set new IV ! if (session.Context.Cipher.CipherMode == CipherMode.CBC) { ! byte[] iv = new byte[session.Context.Cipher.IvSize]; System.Array.Copy(ecr, ecr.Length - iv.Length, iv, 0, iv.Length); ! session.Context.Cipher.UpdateClientCipherIV(iv); } // Update sequence number ! session.Context.WriteSequenceNumber++; return ecr; --- 272,287 ---- // Encrypt the message ! byte[] ecr = this.session.Context.Cipher.EncryptRecord(fragment, mac); // Set new IV ! if (this.session.Context.Cipher.CipherMode == CipherMode.CBC) { ! byte[] iv = new byte[this.session.Context.Cipher.IvSize]; System.Array.Copy(ecr, ecr.Length - iv.Length, iv, 0, iv.Length); ! this.session.Context.Cipher.UpdateClientCipherIV(iv); } // Update sequence number ! this.session.Context.WriteSequenceNumber++; return ecr; *************** *** 297,308 **** // Decrypt message ! session.Context.Cipher.DecryptRecord(fragment, ref dcrFragment, ref dcrMAC); // Set new IV ! if (session.Context.Cipher.CipherMode == CipherMode.CBC) { byte[] iv = new byte[session.Context.Cipher.IvSize]; System.Array.Copy(fragment, fragment.Length - iv.Length, iv, 0, iv.Length); ! session.Context.Cipher.UpdateServerCipherIV(iv); } --- 296,307 ---- // Decrypt message ! this.session.Context.Cipher.DecryptRecord(fragment, ref dcrFragment, ref dcrMAC); // Set new IV ! if (this.session.Context.Cipher.CipherMode == CipherMode.CBC) { byte[] iv = new byte[session.Context.Cipher.IvSize]; System.Array.Copy(fragment, fragment.Length - iv.Length, iv, 0, iv.Length); ! this.session.Context.Cipher.UpdateServerCipherIV(iv); } *************** *** 324,328 **** // Update sequence number ! session.Context.ReadSequenceNumber++; return new TlsStream(dcrFragment); --- 323,327 ---- // Update sequence number ! this.session.Context.ReadSequenceNumber++; return new TlsStream(dcrFragment); *************** *** 369,376 **** // Reset sequence numbers ! session.Context.WriteSequenceNumber = 0; // Make the pending state to be the current state ! session.Context.IsActual = true; // Send Finished message --- 368,375 ---- // Reset sequence numbers ! this.session.Context.WriteSequenceNumber = 0; // Make the pending state to be the current state ! this.session.Context.IsActual = true; // Send Finished message *************** *** 382,388 **** private int sendRecord(TlsContentType contentType, byte[] recordData) { ! if (session.Context.ConnectionEnd) { ! throw session.CreateException("The session is finished and it's no longer valid."); } --- 381,387 ---- private int sendRecord(TlsContentType contentType, byte[] recordData) { ! if (this.session.Context.ConnectionEnd) { ! throw this.session.CreateException("The session is finished and it's no longer valid."); } *************** *** 393,400 **** byte[] fragment = fragments[i]; ! if (session.Context.IsActual) { // Encrypt fragment ! fragment = encryptRecordFragment(contentType, fragment); } --- 392,399 ---- byte[] fragment = fragments[i]; ! if (this.session.Context.IsActual) { // Encrypt fragment ! fragment = this.encryptRecordFragment(contentType, fragment); } *************** *** 469,473 **** // Create and process the server message ! message = createServerHandshakeMessage(handshakeType, data); // Update session --- 468,472 ---- // Create and process the server message ! message = this.createServerHandshakeMessage(handshakeType, data); // Update session *************** *** 478,488 **** } ! private void processAlert(TlsAlertLevel alertLevel, ! TlsAlertDescription alertDesc) { switch (alertLevel) { case TlsAlertLevel.Fatal: ! throw session.CreateException(alertLevel, alertDesc); case TlsAlertLevel.Warning: --- 477,486 ---- } ! private void processAlert(TlsAlertLevel alertLevel, TlsAlertDescription alertDesc) { switch (alertLevel) { case TlsAlertLevel.Fatal: ! throw this.session.CreateException(alertLevel, alertDesc); case TlsAlertLevel.Warning: *************** *** 491,502 **** { case TlsAlertDescription.CloseNotify: ! session.Context.ConnectionEnd = true; break; default: ! session.RaiseWarningAlert(alertLevel, alertDesc); break; } ! break; } } --- 489,500 ---- { case TlsAlertDescription.CloseNotify: ! this.session.Context.ConnectionEnd = true; break; default: ! this.session.RaiseWarningAlert(alertLevel, alertDesc); break; } ! break; } } *************** *** 658,662 **** default: ! throw session.CreateException("Unknown server handshake message received ({0})", type.ToString()); } } --- 656,660 ---- default: ! throw this.session.CreateException("Unknown server handshake message received ({0})", type.ToString()); } } Index: TlsSslCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsSslCipherSuite.cs 21 Oct 2003 20:04:10 -0000 1.6 --- TlsSslCipherSuite.cs 22 Oct 2003 11:47:44 -0000 1.7 *************** *** 149,157 **** block.Write((short)fragment.Length); block.Write(fragment); block.Reset(); - byte[] blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); - block.Write(this.Context.ServerWriteMAC); block.Write(this.pad2); --- 149,157 ---- block.Write((short)fragment.Length); block.Write(fragment); + + byte[] blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); block.Reset(); block.Write(this.Context.ServerWriteMAC); block.Write(this.pad2); *************** *** 176,183 **** block.Write((short)fragment.Length); block.Write(fragment); block.Reset(); - - byte[] blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); block.Write(this.Context.ClientWriteMAC); --- 176,183 ---- block.Write((short)fragment.Length); block.Write(fragment); + + byte[] blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); block.Reset(); block.Write(this.Context.ClientWriteMAC); |
From: <car...@us...> - 2003-10-22 03:52:46
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv14862 Modified Files: CipherSuite.cs TlsCipherSuiteFactory.cs Log Message: Added partial implementation of SSL3 protocol Index: CipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/CipherSuite.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CipherSuite.cs 21 Oct 2003 20:06:03 -0000 1.1 --- CipherSuite.cs 21 Oct 2003 23:07:19 -0000 1.2 *************** *** 59,62 **** --- 59,64 ---- #endregion + #region PROTECTED_PROPERTIES + protected ICryptoTransform EncryptionCipher { *************** *** 78,81 **** --- 80,85 ---- get { return serverHMAC; } } + + #endregion #region PROPERTIES Index: TlsCipherSuiteFactory.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsCipherSuiteFactory.cs 21 Oct 2003 16:05:12 -0000 1.3 --- TlsCipherSuiteFactory.cs 21 Oct 2003 23:07:19 -0000 1.4 *************** *** 120,125 **** // Supported ciphers ! scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA", false, true, 24, 24, 168, 8, 8); ! scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", "DES", "SHA", false, true, 8, 8, 56, 8, 8); scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", "RC4", "SHA", false, false, 16, 16, 128, 0, 0); scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0); --- 120,125 ---- // Supported ciphers ! // scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA", false, true, 24, 24, 168, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", "DES", "SHA", false, true, 8, 8, 56, 8, 8); scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", "RC4", "SHA", false, false, 16, 16, 128, 0, 0); scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0); |
From: <car...@us...> - 2003-10-22 02:58:31
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv7658 Added Files: CipherSuite.cs Log Message: Added partial implementation of SSL3 protocol --- NEW FILE: CipherSuite.cs --- (This appears to be a binary file; contents omitted.) |
From: <car...@us...> - 2003-10-21 23:11:36
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv14979 Modified Files: changelog.txt Log Message: Updated CHANGELOG.TXT Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changelog.txt,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** changelog.txt 21 Oct 2003 12:17:29 -0000 1.57 --- changelog.txt 21 Oct 2003 23:08:11 -0000 1.58 *************** *** 7,10 **** --- 7,12 ---- * TLS implementation: + * Added partial implementation of SSL3 protocol. + * TlsCipherSuiteFactory.cs: |
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-serv14895 Modified Files: TlsClientKeyExchange.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsClientKeyExchange.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/TlsClientKeyExchange.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsClientKeyExchange.cs 21 Oct 2003 16:06:15 -0000 1.5 --- TlsClientKeyExchange.cs 21 Oct 2003 23:07:37 -0000 1.6 *************** *** 46,50 **** protected override void ProcessAsSsl3() { ! this.ProcessAsTls1(); } --- 46,78 ---- protected override void ProcessAsSsl3() { ! // Compute pre master secret ! byte[] preMasterSecret = Session.Context.Cipher.CreatePremasterSecret(); ! ! // Create a new RSA key ! RSACryptoServiceProvider rsa = null; ! if (Session.Context.ServerSettings.ServerKeyExchange) ! { ! rsa = Session.Context.Cipher.CreateRSA(Session.Context.ServerSettings.RsaParameters); ! } ! else ! { ! rsa = Session.Context.Cipher.CreateRSA(Session.Context.ServerSettings.ServerCertificates[0]); ! } ! ! // Encrypt premaster_sercret ! RSAPKCS1KeyExchangeFormatter formatter = new RSAPKCS1KeyExchangeFormatter(rsa); ! ! // Write the preMasterSecret encrypted ! byte[] buffer = formatter.CreateKeyExchange(preMasterSecret); ! Write(buffer); ! ! // Create master secret ! Session.Context.Cipher.CreateMasterSecret(preMasterSecret); ! ! // Create keys ! Session.Context.Cipher.CreateKeys(); ! ! // Clear resources ! rsa.Clear(); } |
From: <car...@us...> - 2003-10-21 21:56:59
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv7580 Removed Files: TlsAbstractCipherSuite.cs Log Message: Added partial implementation of SSL3 protocol --- TlsAbstractCipherSuite.cs DELETED --- |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv11690 Modified Files: TlsAbstractCipherSuite.cs TlsCipherSuite.cs TlsSocket.cs TlsSslCipherSuite.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsAbstractCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsAbstractCipherSuite.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsAbstractCipherSuite.cs 21 Oct 2003 12:17:10 -0000 1.2 --- TlsAbstractCipherSuite.cs 21 Oct 2003 17:48:27 -0000 1.3 *************** *** 257,261 **** // Write protocol version ! stream.Write((short)this.context.Protocol); // Generate random bytes --- 257,261 ---- // Write protocol version ! stream.Write((short)this.Context.Protocol); // Generate random bytes Index: TlsCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuite.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsCipherSuite.cs 21 Oct 2003 16:05:12 -0000 1.5 --- TlsCipherSuite.cs 21 Oct 2003 17:48:27 -0000 1.6 *************** *** 123,127 **** data.Write(context.ReadSequenceNumber); data.Write((byte)contentType); ! data.Write((short)TlsProtocol.Tls1); data.Write((short)fragment.Length); data.Write(fragment); --- 123,127 ---- data.Write(context.ReadSequenceNumber); data.Write((byte)contentType); ! data.Write((short)this.Context.Protocol); data.Write((short)fragment.Length); data.Write(fragment); *************** *** 141,145 **** data.Write(context.WriteSequenceNumber); data.Write((byte)contentType); ! data.Write((short)TlsProtocol.Tls1); data.Write((short)fragment.Length); data.Write(fragment); --- 141,145 ---- data.Write(context.WriteSequenceNumber); data.Write((byte)contentType); ! data.Write((short)this.Context.Protocol); data.Write((short)fragment.Length); data.Write(fragment); Index: TlsSocket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSocket.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsSocket.cs 21 Oct 2003 12:17:10 -0000 1.6 --- TlsSocket.cs 21 Oct 2003 17:48:27 -0000 1.7 *************** *** 204,211 **** } ! TlsStream message = new TlsStream(buffer); // Check that the message as a valid protocol version ! if (protocol != session.Context.Protocol) { throw session.CreateException("Invalid protocol version on message received from server"); --- 204,213 ---- } ! TlsStream message = new TlsStream(buffer); // Check that the message as a valid protocol version ! if ((protocol != this.session.Context.Protocol && ! this.session.HelloDone) || ! (protocol != TlsProtocol.Tls1 && protocol != TlsProtocol.Ssl3 )) { throw session.CreateException("Invalid protocol version on message received from server"); *************** *** 402,406 **** TlsStream record = new TlsStream(); record.Write((byte)contentType); ! record.Write((short)TlsProtocol.Tls1); record.Write((short)fragment.Length); record.Write(fragment); --- 404,408 ---- TlsStream record = new TlsStream(); record.Write((byte)contentType); ! record.Write((short)this.session.Context.Protocol); record.Write((short)fragment.Length); record.Write(fragment); Index: TlsSslCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsSslCipherSuite.cs 21 Oct 2003 16:05:12 -0000 1.4 --- TlsSslCipherSuite.cs 21 Oct 2003 17:48:27 -0000 1.5 *************** *** 36,39 **** --- 36,46 ---- internal class TlsSslCipherSuite : TlsAbstractCipherSuite { + #region FIELDS + + private byte[] pad1; + private byte[] pad2; + + #endregion + #region CONSTRUCTORS *************** *** 46,49 **** --- 53,57 ---- ivSize, blockSize) { + this.initializePad(); } *************** *** 118,127 **** public override byte[] GenerateServerRecordMAC(TlsContentType contentType, byte[] fragment) { ! throw new NotSupportedException(); } public override byte[] GenerateClientRecordMAC(TlsContentType contentType, byte[] fragment) { ! throw new NotSupportedException(); } --- 126,181 ---- public override byte[] GenerateServerRecordMAC(TlsContentType contentType, byte[] fragment) { ! HashAlgorithm hash = HashAlgorithm.Create(this.hashName); ! TlsStream block = new TlsStream(); ! byte[] result = null; ! ! block.Write(this.Context.ServerWriteMAC); ! block.Write(this.pad1); ! block.Write(context.ReadSequenceNumber); ! block.Write((byte)contentType); ! block.Write((short)fragment.Length); ! block.Write(fragment); ! ! block.Reset(); ! ! byte[] blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); ! ! block.Write(this.Context.ServerWriteMAC); ! block.Write(this.pad2); ! block.Write(blockHash); ! ! hash.TransformFinalBlock(block.ToArray(), 0, (int)block.Length); ! ! block.Reset(); ! ! return hash.Hash; } public override byte[] GenerateClientRecordMAC(TlsContentType contentType, byte[] fragment) { ! HashAlgorithm hash = HashAlgorithm.Create(this.hashName); ! TlsStream block = new TlsStream(); ! byte[] result = null; ! ! block.Write(this.Context.ClientWriteMAC); ! block.Write(this.pad1); ! block.Write(context.WriteSequenceNumber); ! block.Write((byte)contentType); ! block.Write((short)fragment.Length); ! block.Write(fragment); ! ! block.Reset(); ! ! byte[] blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); ! ! block.Write(this.Context.ClientWriteMAC); ! block.Write(this.pad2); ! block.Write(blockHash); ! ! hash.TransformFinalBlock(block.ToArray(), 0, (int)block.Length); ! ! block.Reset(); ! ! return hash.Hash; } *************** *** 217,220 **** --- 271,296 ---- #region PRIVATE_METHODS + + private void initializePad() + { + switch (hashName) + { + case "MD5": + pad1 = new byte[48]; + pad2 = new byte[48]; + break; + + case "SHA": + pad1 = new byte[40]; + pad2 = new byte[40]; + break; + } + + for (int i = 0; i < pad1.Length; i++) + { + pad1[i] = (byte)0x36; + pad2[i] = (byte)0x5C; + } + } private byte[] prf(byte[] secret, string label, byte[] random) |
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; } |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv7205 Modified Files: TlsCipherSuite.cs TlsCipherSuiteCollection.cs TlsSession.cs TlsSessionContext.cs TlsSocket.cs TlsSslCipherSuite.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuite.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsCipherSuite.cs 21 Oct 2003 17:48:27 -0000 1.6 --- TlsCipherSuite.cs 21 Oct 2003 20:04:09 -0000 1.7 *************** *** 34,38 **** namespace Mono.Security.Protocol.Tls { ! internal class TlsCipherSuite : TlsAbstractCipherSuite { #region CONSTRUCTORS --- 34,38 ---- namespace Mono.Security.Protocol.Tls { ! internal class TlsCipherSuite : CipherSuite { #region CONSTRUCTORS *************** *** 56,68 **** // Encryption ( fragment + mac [+ padding + padding_length] ) MemoryStream ms = new MemoryStream(); ! CryptoStream cs = new CryptoStream(ms, encryptionCipher, CryptoStreamMode.Write); cs.Write(fragment, 0, fragment.Length); cs.Write(mac, 0, mac.Length); ! if (cipherMode == CipherMode.CBC) { // Calculate padding_length int fragmentLength = fragment.Length + mac.Length + 1; ! int paddingLength = (((fragmentLength/blockSize)*blockSize) + blockSize) - fragmentLength; // Write padding length byte --- 56,68 ---- // Encryption ( fragment + mac [+ padding + padding_length] ) MemoryStream ms = new MemoryStream(); ! CryptoStream cs = new CryptoStream(ms, this.EncryptionCipher, CryptoStreamMode.Write); cs.Write(fragment, 0, fragment.Length); cs.Write(mac, 0, mac.Length); ! if (this.CipherMode == CipherMode.CBC) { // Calculate padding_length int fragmentLength = fragment.Length + mac.Length + 1; ! int paddingLength = (((fragmentLength/this.BlockSize)*this.BlockSize) + this.BlockSize) - fragmentLength; // Write padding length byte *************** *** 82,89 **** // Decrypt message fragment ( fragment + mac [+ padding + padding_length] ) byte[] buffer = new byte[fragment.Length]; ! decryptionCipher.TransformBlock(fragment, 0, fragment.Length, buffer, 0); // Calculate fragment size ! if (cipherMode == CipherMode.CBC) { // Calculate padding_length --- 82,89 ---- // Decrypt message fragment ( fragment + mac [+ padding + padding_length] ) byte[] buffer = new byte[fragment.Length]; ! this.DecryptionCipher.TransformBlock(fragment, 0, fragment.Length, buffer, 0); // Calculate fragment size ! if (this.CipherMode == CipherMode.CBC) { // Calculate padding_length *************** *** 121,125 **** byte[] result = null; ! data.Write(context.ReadSequenceNumber); data.Write((byte)contentType); data.Write((short)this.Context.Protocol); --- 121,125 ---- byte[] result = null; ! data.Write(this.Context.ReadSequenceNumber); data.Write((byte)contentType); data.Write((short)this.Context.Protocol); *************** *** 127,131 **** data.Write(fragment); ! result = serverHMAC.ComputeHash(data.ToArray()); data.Reset(); --- 127,131 ---- data.Write(fragment); ! result = this.ServerHMAC.ComputeHash(data.ToArray()); data.Reset(); *************** *** 139,143 **** byte[] result = null; ! data.Write(context.WriteSequenceNumber); data.Write((byte)contentType); data.Write((short)this.Context.Protocol); --- 139,143 ---- byte[] result = null; ! data.Write(this.Context.WriteSequenceNumber); data.Write((byte)contentType); data.Write((short)this.Context.Protocol); *************** *** 145,149 **** data.Write(fragment); ! result = clientHMAC.ComputeHash(data.ToArray()); data.Reset(); --- 145,149 ---- data.Write(fragment); ! result = this.ClientHMAC.ComputeHash(data.ToArray()); data.Reset(); *************** *** 160,164 **** // Create master secret this.Context.MasterSecret = new byte[preMasterSecret.Length]; ! this.Context.MasterSecret = PRF( preMasterSecret, "master secret", this.Context.RandomCS, 48); } --- 160,164 ---- // Create master secret this.Context.MasterSecret = new byte[preMasterSecret.Length]; ! this.Context.MasterSecret = this.PRF( preMasterSecret, "master secret", this.Context.RandomCS, 48); } *************** *** 168,172 **** // Create keyblock TlsStream keyBlock = new TlsStream( ! PRF(this.Context.MasterSecret, "key expansion", this.Context.RandomSC, --- 168,173 ---- // Create keyblock TlsStream keyBlock = new TlsStream( ! this.PRF( ! this.Context.MasterSecret, "key expansion", this.Context.RandomSC, *************** *** 206,209 **** --- 207,211 ---- this.Context.ClientWriteIV = new byte[this.IvSize]; System.Array.Copy(ivBlock, 0, this.Context.ClientWriteIV, 0, this.Context.ClientWriteIV.Length); + this.Context.ServerWriteIV = new byte[this.IvSize]; System.Array.Copy(ivBlock, this.IvSize, this.Context.ServerWriteIV, 0, this.Context.ServerWriteIV.Length); Index: TlsCipherSuiteCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsCipherSuiteCollection.cs 21 Oct 2003 16:05:12 -0000 1.3 --- TlsCipherSuiteCollection.cs 21 Oct 2003 20:04:09 -0000 1.4 *************** *** 40,59 **** #region PROPERTIES ! public TlsAbstractCipherSuite this[string name] { ! get { return (TlsAbstractCipherSuite)this[IndexOf(name)]; } ! set { this[IndexOf(name)] = (TlsAbstractCipherSuite)value; } } ! public TlsAbstractCipherSuite this[short code] { ! get { return (TlsAbstractCipherSuite)base[IndexOf(code)]; } ! set { base[IndexOf(code)] = (TlsAbstractCipherSuite)value; } } ! public new TlsAbstractCipherSuite this[int code] { ! get { return (TlsAbstractCipherSuite)base[code]; } ! set { base[code] = (TlsAbstractCipherSuite)value; } } --- 40,59 ---- #region PROPERTIES ! public CipherSuite this[string name] { ! get { return (CipherSuite)this[IndexOf(name)]; } ! set { this[IndexOf(name)] = (CipherSuite)value; } } ! public CipherSuite this[short code] { ! get { return (CipherSuite)base[IndexOf(code)]; } ! set { base[IndexOf(code)] = (CipherSuite)value; } } ! public new CipherSuite this[int code] { ! get { return (CipherSuite)base[code]; } ! set { base[code] = (CipherSuite)value; } } *************** *** 79,83 **** { int index = 0; ! foreach (TlsAbstractCipherSuite suite in this) { if (cultureAwareCompare(suite.Name, name)) --- 79,83 ---- { int index = 0; ! foreach (CipherSuite suite in this) { if (cultureAwareCompare(suite.Name, name)) *************** *** 93,97 **** { int index = 0; ! foreach (TlsAbstractCipherSuite suite in this) { if (suite.Code == code) --- 93,97 ---- { int index = 0; ! foreach (CipherSuite suite in this) { if (suite.Code == code) *************** *** 109,113 **** } ! public TlsAbstractCipherSuite Add(short code, string name, string algName, string hashName, bool exportable, bool blockMode, byte keyMaterialSize, byte expandedKeyMaterialSize, short effectiveKeyBytes, byte ivSize, byte blockSize) { switch (this.protocol) --- 109,113 ---- } ! public CipherSuite Add(short code, string name, string algName, string hashName, bool exportable, bool blockMode, byte keyMaterialSize, byte expandedKeyMaterialSize, short effectiveKeyBytes, byte ivSize, byte blockSize) { switch (this.protocol) Index: TlsSession.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSession.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsSession.cs 21 Oct 2003 16:05:12 -0000 1.7 --- TlsSession.cs 21 Oct 2003 20:04:09 -0000 1.8 *************** *** 47,54 **** private byte[] sessionId; private TlsSessionContext context; - private bool helloDone; - private bool handshakeFinished; private TlsSessionSettings settings; - private TlsCipherSuiteCollection supportedCiphers; private TlsSocket socket; private TlsNetworkStream networkStream; --- 47,51 ---- *************** *** 84,104 **** } - internal TlsCipherSuiteCollection SupportedCiphers - { - get { return supportedCiphers; } - } - - internal bool HelloDone - { - get { return helloDone; } - set { helloDone = value; } - } - - internal bool HandshakeFinished - { - get { return handshakeFinished; } - set { handshakeFinished = value; } - } - internal bool IsSecure { --- 81,84 ---- *************** *** 164,169 **** this.context.Protocol = settings.Protocol; this.context.CompressionMethod = settings.CompressionMethod; ! this.state = TlsSessionState.OpeningSecure; ! this.supportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(context.Protocol); this.socket.DoHandshake(); this.state = TlsSessionState.OpenSecure; --- 144,149 ---- this.context.Protocol = settings.Protocol; this.context.CompressionMethod = settings.CompressionMethod; ! this.context.SupportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(context.Protocol); ! this.state = TlsSessionState.OpeningSecure; this.socket.DoHandshake(); this.state = TlsSessionState.OpenSecure; *************** *** 277,282 **** // Reset session information this.isSecure = false; - this.helloDone = false; - this.handshakeFinished = false; this.context = new TlsSessionContext(); this.sessionId = new byte[0]; --- 257,260 ---- Index: TlsSessionContext.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSessionContext.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TlsSessionContext.cs 21 Oct 2003 16:05:12 -0000 1.8 --- TlsSessionContext.cs 21 Oct 2003 20:04:10 -0000 1.9 *************** *** 45,53 **** private TlsServerSettings serverSettings; // Misc private bool isActual; private bool connectionEnd; ! private TlsAbstractCipherSuite cipher; ! // Sequence numbers private long writeSequenceNumber; --- 45,58 ---- private TlsServerSettings serverSettings; + // Cipher suite information + private CipherSuite cipher; + private TlsCipherSuiteCollection supportedCiphers; + // Misc private bool isActual; + private bool helloDone; + private bool handshakeFinished; private bool connectionEnd; ! // Sequence numbers private long writeSequenceNumber; *************** *** 106,109 **** --- 111,126 ---- } + public bool HelloDone + { + get { return helloDone; } + set { helloDone = value; } + } + + public bool HandshakeFinished + { + get { return handshakeFinished; } + set { handshakeFinished = value; } + } + public bool ConnectionEnd { *************** *** 112,119 **** } ! public TlsAbstractCipherSuite Cipher { get { return this.cipher; } set { this.cipher = value; } } --- 129,142 ---- } ! public CipherSuite Cipher { get { return this.cipher; } set { this.cipher = value; } + } + + public TlsCipherSuiteCollection SupportedCiphers + { + get { return supportedCiphers; } + set { supportedCiphers = value; } } Index: TlsSocket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSocket.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsSocket.cs 21 Oct 2003 17:48:27 -0000 1.7 --- TlsSocket.cs 21 Oct 2003 20:04:10 -0000 1.8 *************** *** 193,197 **** TlsContentType contentType = (TlsContentType)this.ReadByte(); TlsProtocol protocol = (TlsProtocol)this.ReadShort(); ! int length = this.ReadShort(); // Read Record data --- 193,197 ---- TlsContentType contentType = (TlsContentType)this.ReadByte(); TlsProtocol protocol = (TlsProtocol)this.ReadShort(); ! short length = this.ReadShort(); // Read Record data *************** *** 207,212 **** // Check that the message as a valid protocol version ! if ((protocol != this.session.Context.Protocol && ! this.session.HelloDone) || (protocol != TlsProtocol.Tls1 && protocol != TlsProtocol.Ssl3 )) { --- 207,211 ---- // Check that the message as a valid protocol version ! if ((protocol != this.session.Context.Protocol && this.session.Context.HelloDone) || (protocol != TlsProtocol.Tls1 && protocol != TlsProtocol.Ssl3 )) { *************** *** 215,220 **** // Decrypt message contents if needed ! if (contentType == TlsContentType.Alert && ! length == 2) { } --- 214,218 ---- // Decrypt message contents if needed ! if (contentType == TlsContentType.Alert && length == 2) { } *************** *** 566,570 **** // Read server response ! while (!session.HelloDone) { // Read next record --- 564,568 ---- // Read server response ! while (!this.session.Context.HelloDone) { // Read next record *************** *** 573,577 **** // Send client certificate if requested ! if (session.Context.ServerSettings.CertificateRequest) { this.sendRecord(TlsHandshakeType.Certificate); --- 571,575 ---- // Send client certificate if requested ! if (this.session.Context.ServerSettings.CertificateRequest) { this.sendRecord(TlsHandshakeType.Certificate); *************** *** 585,589 **** // Send certificate verify if requested ! if (session.Context.ServerSettings.CertificateRequest) { this.sendRecord(TlsHandshakeType.CertificateVerify); --- 583,587 ---- // Send certificate verify if requested ! if (this.session.Context.ServerSettings.CertificateRequest) { this.sendRecord(TlsHandshakeType.CertificateVerify); *************** *** 597,601 **** // Read server finished ! if (!session.HandshakeFinished) { this.receiveRecord(); --- 595,599 ---- // Read server finished ! if (!this.session.Context.HandshakeFinished) { this.receiveRecord(); Index: TlsSslCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsSslCipherSuite.cs 21 Oct 2003 17:48:27 -0000 1.5 --- TlsSslCipherSuite.cs 21 Oct 2003 20:04:10 -0000 1.6 *************** *** 34,38 **** namespace Mono.Security.Protocol.Tls { ! internal class TlsSslCipherSuite : TlsAbstractCipherSuite { #region FIELDS --- 34,38 ---- namespace Mono.Security.Protocol.Tls { ! internal class TlsSslCipherSuite : CipherSuite { #region FIELDS *************** *** 43,46 **** --- 43,60 ---- #endregion + #region PROPERTIES + + public byte[] Pad1 + { + get { return pad1; } + } + + public byte[] Pad2 + { + get { return pad2; } + } + + #endregion + #region CONSTRUCTORS *************** *** 53,57 **** ivSize, blockSize) { ! this.initializePad(); } --- 67,71 ---- ivSize, blockSize) { ! this.GeneratePad(hashName, ref this.pad1, ref this.pad2); } *************** *** 64,76 **** // Encryption ( fragment + mac [+ padding + padding_length] ) MemoryStream ms = new MemoryStream(); ! CryptoStream cs = new CryptoStream(ms, encryptionCipher, CryptoStreamMode.Write); cs.Write(fragment, 0, fragment.Length); cs.Write(mac, 0, mac.Length); ! if (cipherMode == CipherMode.CBC) { // Calculate padding_length int fragmentLength = fragment.Length + mac.Length + 1; ! int paddingLength = (((fragmentLength/blockSize)*8) + blockSize) - fragmentLength; // Write padding length byte --- 78,90 ---- // Encryption ( fragment + mac [+ padding + padding_length] ) MemoryStream ms = new MemoryStream(); ! CryptoStream cs = new CryptoStream(ms, this.EncryptionCipher, CryptoStreamMode.Write); cs.Write(fragment, 0, fragment.Length); cs.Write(mac, 0, mac.Length); ! if (this.CipherMode == CipherMode.CBC) { // Calculate padding_length int fragmentLength = fragment.Length + mac.Length + 1; ! int paddingLength = (((fragmentLength/this.BlockSize)*8) + this.BlockSize) - fragmentLength; // Write padding length byte *************** *** 90,97 **** // Decrypt message fragment ( fragment + mac [+ padding + padding_length] ) byte[] buffer = new byte[fragment.Length]; ! decryptionCipher.TransformBlock(fragment, 0, fragment.Length, buffer, 0); // Calculate fragment size ! if (cipherMode == CipherMode.CBC) { // Calculate padding_length --- 104,111 ---- // Decrypt message fragment ( fragment + mac [+ padding + padding_length] ) byte[] buffer = new byte[fragment.Length]; ! this.DecryptionCipher.TransformBlock(fragment, 0, fragment.Length, buffer, 0); // Calculate fragment size ! if (this.CipherMode == CipherMode.CBC) { // Calculate padding_length *************** *** 126,136 **** public override byte[] GenerateServerRecordMAC(TlsContentType contentType, byte[] fragment) { ! HashAlgorithm hash = HashAlgorithm.Create(this.hashName); TlsStream block = new TlsStream(); - byte[] result = null; block.Write(this.Context.ServerWriteMAC); block.Write(this.pad1); ! block.Write(context.ReadSequenceNumber); block.Write((byte)contentType); block.Write((short)fragment.Length); --- 140,149 ---- public override byte[] GenerateServerRecordMAC(TlsContentType contentType, byte[] fragment) { ! HashAlgorithm hash = HashAlgorithm.Create(this.HashName); TlsStream block = new TlsStream(); block.Write(this.Context.ServerWriteMAC); block.Write(this.pad1); ! block.Write(this.Context.ReadSequenceNumber); block.Write((byte)contentType); block.Write((short)fragment.Length); *************** *** 154,164 **** public override byte[] GenerateClientRecordMAC(TlsContentType contentType, byte[] fragment) { ! HashAlgorithm hash = HashAlgorithm.Create(this.hashName); TlsStream block = new TlsStream(); - byte[] result = null; block.Write(this.Context.ClientWriteMAC); block.Write(this.pad1); ! block.Write(context.WriteSequenceNumber); block.Write((byte)contentType); block.Write((short)fragment.Length); --- 167,176 ---- public override byte[] GenerateClientRecordMAC(TlsContentType contentType, byte[] fragment) { ! HashAlgorithm hash = HashAlgorithm.Create(this.HashName); TlsStream block = new TlsStream(); block.Write(this.Context.ClientWriteMAC); block.Write(this.pad1); ! block.Write(this.Context.WriteSequenceNumber); block.Write((byte)contentType); block.Write((short)fragment.Length); *************** *** 180,183 **** --- 192,218 ---- } + public void GeneratePad(string hashName, ref byte[] pad1, ref byte[] pad2) + { + switch (hashName) + { + case "MD5": + pad1 = new byte[48]; + pad2 = new byte[48]; + break; + + case "SHA": + case "SHA1": + pad1 = new byte[40]; + pad2 = new byte[40]; + break; + } + + for (int i = 0; i < pad1.Length; i++) + { + pad1[i] = (byte)0x36; + pad2[i] = (byte)0x5C; + } + } + #endregion *************** *** 192,196 **** masterSecret.Write(this.prf(preMasterSecret, "CCC", this.Context.RandomCS)); ! this.context.MasterSecret = masterSecret.ToArray(); } --- 227,231 ---- masterSecret.Write(this.prf(preMasterSecret, "CCC", this.Context.RandomCS)); ! this.Context.MasterSecret = masterSecret.ToArray(); } *************** *** 271,296 **** #region PRIVATE_METHODS - - private void initializePad() - { - switch (hashName) - { - case "MD5": - pad1 = new byte[48]; - pad2 = new byte[48]; - break; - - case "SHA": - pad1 = new byte[40]; - pad2 = new byte[40]; - break; - } - - for (int i = 0; i < pad1.Length; i++) - { - pad1[i] = (byte)0x36; - pad2[i] = (byte)0x5C; - } - } private byte[] prf(byte[] secret, string label, byte[] random) --- 306,309 ---- |
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-serv12086 Modified Files: TlsServerHello.cs Log Message: Added partial implementation of SSL3 protocol 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.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsServerHello.cs 21 Oct 2003 16:06:15 -0000 1.7 --- TlsServerHello.cs 21 Oct 2003 17:50:35 -0000 1.8 *************** *** 54,75 **** base.UpdateSession(); ! Session.SetSessionId(this.sessionId); ! Session.Context.ServerRandom = this.random; ! Session.Context.Cipher = this.cipherSuite; ! Session.Context.CompressionMethod = this.compressionMethod; ! Session.Context.Cipher.Context = this.Session.Context; // Compute ClientRandom + ServerRandom TlsStream random = new TlsStream(); ! random.Write(Session.Context.ClientRandom); ! random.Write(Session.Context.ServerRandom); ! Session.Context.RandomCS = random.ToArray(); // Server Random + Client Random random.Reset(); ! random.Write(Session.Context.ServerRandom); ! random.Write(Session.Context.ClientRandom); ! Session.Context.RandomSC = random.ToArray(); random.Reset(); } --- 54,76 ---- base.UpdateSession(); ! this.Session.SetSessionId(this.sessionId); ! this.Session.Context.Protocol = this.protocol; ! this.Session.Context.ServerRandom = this.random; ! this.Session.Context.Cipher = this.cipherSuite; ! this.Session.Context.CompressionMethod = this.compressionMethod; ! this.Session.Context.Cipher.Context = this.Session.Context; // Compute ClientRandom + ServerRandom TlsStream random = new TlsStream(); ! random.Write(this.Session.Context.ClientRandom); ! random.Write(this.Session.Context.ServerRandom); ! this.Session.Context.RandomCS = random.ToArray(); // Server Random + Client Random random.Reset(); ! random.Write(this.Session.Context.ServerRandom); ! random.Write(this.Session.Context.ClientRandom); ! this.Session.Context.RandomSC = random.ToArray(); random.Reset(); } *************** *** 81,84 **** --- 82,86 ---- protected override void ProcessAsSsl3() { + #warning "Check that the protocol sent by the server is supported" // Read protocol version this.protocol = (TlsProtocol)this.ReadInt16(); |
From: <car...@us...> - 2003-10-21 20:16:55
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake In directory sc8-pr-cvs1:/tmp/cvs-serv7714 Modified Files: TlsHandshakeHashes.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsHandshakeHashes.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeHashes.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsHandshakeHashes.cs 14 Oct 2003 10:14:10 -0000 1.2 --- TlsHandshakeHashes.cs 21 Oct 2003 20:06:14 -0000 1.3 *************** *** 38,41 **** --- 38,50 ---- #endregion + #region PROPERTIES + + internal byte[] Messages + { + get { return messages.ToArray(); } + } + + #endregion + #region CONSTRUCTORS |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv8391 Modified Files: TlsAbstractCipherSuite.cs TlsCipherSuite.cs TlsSocket.cs TlsSslCipherSuite.cs Log Message: * TlsSocket.cs: * TlsAbstractCipherSuite.cs: * TlsCipherSuite.cs: * TlsSslCipherSuite.cs: - Moved MAC generation methods to specific CipherSuite classes. Index: TlsAbstractCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsAbstractCipherSuite.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsAbstractCipherSuite.cs 20 Oct 2003 10:00:20 -0000 1.1 --- TlsAbstractCipherSuite.cs 21 Oct 2003 12:17:10 -0000 1.2 *************** *** 236,239 **** --- 236,243 ---- #region ABSTRACT_METHODS + public abstract byte[] GenerateClientRecordMAC(TlsContentType contentType, byte[] fragment); + + public abstract byte[] GenerateServerRecordMAC(TlsContentType contentType, byte[] fragment); + public abstract byte[] EncryptRecord(byte[] fragment, byte[] mac); Index: TlsCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuite.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsCipherSuite.cs 20 Oct 2003 09:58:29 -0000 1.3 --- TlsCipherSuite.cs 21 Oct 2003 12:17:10 -0000 1.4 *************** *** 114,117 **** --- 114,157 ---- #endregion + #region MAC_GENERATION_METHOD + + public override byte[] GenerateServerRecordMAC(TlsContentType contentType, byte[] fragment) + { + TlsStream data = new TlsStream(); + byte[] result = null; + + data.Write(context.ReadSequenceNumber); + data.Write((byte)contentType); + data.Write((short)TlsProtocol.Tls1); + data.Write((short)fragment.Length); + data.Write(fragment); + + result = serverHMAC.ComputeHash(data.ToArray()); + + data.Reset(); + + return result; + } + + public override byte[] GenerateClientRecordMAC(TlsContentType contentType, byte[] fragment) + { + TlsStream data = new TlsStream(); + byte[] result = null; + + data.Write(context.WriteSequenceNumber); + data.Write((byte)contentType); + data.Write((short)TlsProtocol.Tls1); + data.Write((short)fragment.Length); + data.Write(fragment); + + result = clientHMAC.ComputeHash(data.ToArray()); + + data.Reset(); + + return result; + } + + #endregion + #region KEY_GENERATION_METODS Index: TlsSocket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSocket.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsSocket.cs 20 Oct 2003 22:00:32 -0000 1.5 --- TlsSocket.cs 21 Oct 2003 12:17:10 -0000 1.6 *************** *** 270,274 **** { // Calculate message MAC ! byte[] mac = encodeClientRecordMAC(contentType, fragment); // Encrypt the message --- 270,274 ---- { // Calculate message MAC ! byte[] mac = this.session.Context.Cipher.GenerateClientRecordMAC(contentType, fragment); // Encrypt the message *************** *** 308,312 **** // Check MAC code ! byte[] mac = this.encodeServerRecordMAC(contentType, dcrFragment); // Check that the mac is correct --- 308,312 ---- // Check MAC code ! byte[] mac = this.session.Context.Cipher.GenerateServerRecordMAC(contentType, dcrFragment); // Check that the mac is correct *************** *** 510,549 **** this.inputBuffer.SetLength(0); this.inputBuffer.Position = 0; - } - - private byte[] encodeServerRecordMAC(TlsContentType contentType, byte[] fragment) - { - TlsStream data = new TlsStream(); - byte[] result = null; - - data.Write(session.Context.ReadSequenceNumber); - data.Write((byte)contentType); - data.Write((short)TlsProtocol.Tls1); - data.Write((short)fragment.Length); - data.Write(fragment); - - result = session.Context.Cipher.ServerHMAC.ComputeHash(data.ToArray()); - - data.Reset(); - - return result; - } - - private byte[] encodeClientRecordMAC(TlsContentType contentType, byte[] fragment) - { - TlsStream data = new TlsStream(); - byte[] result = null; - - data.Write(session.Context.WriteSequenceNumber); - data.Write((byte)contentType); - data.Write((short)TlsProtocol.Tls1); - data.Write((short)fragment.Length); - data.Write(fragment); - - result = session.Context.Cipher.ClientHMAC.ComputeHash(data.ToArray()); - - data.Reset(); - - return result; } --- 510,513 ---- Index: TlsSslCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsSslCipherSuite.cs 21 Oct 2003 09:31:41 -0000 1.2 --- TlsSslCipherSuite.cs 21 Oct 2003 12:17:10 -0000 1.3 *************** *** 114,117 **** --- 114,131 ---- #endregion + #region MAC_GENERATION_METHOD + + public override byte[] GenerateServerRecordMAC(TlsContentType contentType, byte[] fragment) + { + throw new NotSupportedException(); + } + + public override byte[] GenerateClientRecordMAC(TlsContentType contentType, byte[] fragment) + { + throw new NotSupportedException(); + } + + #endregion + #region KEY_GENERATION_METODS |
From: <car...@us...> - 2003-10-21 16:09:48
|
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-serv25886 Modified Files: TlsClientHello.cs TlsClientKeyExchange.cs TlsServerCertificate.cs TlsServerHello.cs Log Message: Added partial implementation of SSL3 protocol 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.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsClientHello.cs 20 Oct 2003 18:22:57 -0000 1.6 --- TlsClientHello.cs 21 Oct 2003 16:06:15 -0000 1.7 *************** *** 39,45 **** public TlsClientHello(TlsSession session) ! : base(session, ! TlsHandshakeType.ClientHello, ! TlsContentType.Handshake) { } --- 39,43 ---- public TlsClientHello(TlsSession session) ! : base(session, TlsHandshakeType.ClientHello, TlsContentType.Handshake) { } *************** *** 64,68 **** protected override void ProcessAsSsl3() { ! throw new NotSupportedException(); } --- 62,66 ---- protected override void ProcessAsSsl3() { ! this.ProcessAsTls1(); } Index: TlsClientKeyExchange.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/TlsClientKeyExchange.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsClientKeyExchange.cs 20 Oct 2003 10:01:19 -0000 1.4 --- TlsClientKeyExchange.cs 21 Oct 2003 16:06:15 -0000 1.5 *************** *** 46,50 **** protected override void ProcessAsSsl3() { ! throw new NotSupportedException(); } --- 46,50 ---- protected override void ProcessAsSsl3() { ! this.ProcessAsTls1(); } Index: TlsServerCertificate.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/TlsServerCertificate.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsServerCertificate.cs 16 Oct 2003 14:25:57 -0000 1.4 --- TlsServerCertificate.cs 21 Oct 2003 16:06:15 -0000 1.5 *************** *** 71,75 **** protected override void ProcessAsSsl3() { ! throw new NotSupportedException(); } --- 71,75 ---- protected override void ProcessAsSsl3() { ! this.ProcessAsTls1(); } 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.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsServerHello.cs 20 Oct 2003 18:22:57 -0000 1.6 --- TlsServerHello.cs 21 Oct 2003 16:06:15 -0000 1.7 *************** *** 35,39 **** private byte[] random; private byte[] sessionId; ! private TlsCipherSuite cipherSuite; #endregion --- 35,39 ---- private byte[] random; private byte[] sessionId; ! private TlsAbstractCipherSuite cipherSuite; #endregion *************** *** 59,62 **** --- 59,76 ---- Session.Context.CompressionMethod = this.compressionMethod; Session.Context.Cipher.Context = this.Session.Context; + + // Compute ClientRandom + ServerRandom + TlsStream random = new TlsStream(); + random.Write(Session.Context.ClientRandom); + random.Write(Session.Context.ServerRandom); + Session.Context.RandomCS = random.ToArray(); + + // Server Random + Client Random + random.Reset(); + random.Write(Session.Context.ServerRandom); + random.Write(Session.Context.ClientRandom); + + Session.Context.RandomSC = random.ToArray(); + random.Reset(); } *************** *** 67,71 **** protected override void ProcessAsSsl3() { ! throw new NotSupportedException(); } --- 81,108 ---- protected override void ProcessAsSsl3() { ! // Read protocol version ! this.protocol = (TlsProtocol)this.ReadInt16(); ! ! // Read random - Unix time + Random bytes ! this.random = this.ReadBytes(32); ! ! // Read Session id ! int length = (int)ReadByte(); ! if (length > 0) ! { ! this.sessionId = this.ReadBytes(length); ! } ! ! // 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 ) ! this.compressionMethod = (TlsCompressionMethod)this.ReadByte(); } |
From: <car...@us...> - 2003-10-21 16:09:33
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake In directory sc8-pr-cvs1:/tmp/cvs-serv25799 Modified Files: TlsHandshakeType.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsHandshakeType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsHandshakeType.cs 11 Oct 2003 10:08:57 -0000 1.1 --- TlsHandshakeType.cs 21 Oct 2003 16:05:54 -0000 1.2 *************** *** 39,43 **** ClientKeyExchange = 16, Finished = 20, - Unknown = 255 } } --- 39,42 ---- |
From: <car...@us...> - 2003-10-21 16:06:17
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv25618 Modified Files: TlsCipherSuite.cs TlsCipherSuiteCollection.cs TlsCipherSuiteFactory.cs TlsContentType.cs TlsSession.cs TlsSessionContext.cs TlsSessionSettings.cs TlsSslCipherSuite.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuite.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsCipherSuite.cs 21 Oct 2003 12:17:10 -0000 1.4 --- TlsCipherSuite.cs 21 Oct 2003 16:05:12 -0000 1.5 *************** *** 158,187 **** public override void CreateMasterSecret(byte[] preMasterSecret) { - TlsStream seed = new TlsStream(); - - // Seed - seed.Write(context.ClientRandom); - seed.Write(context.ServerRandom); - // Create master secret ! context.MasterSecret = new byte[preMasterSecret.Length]; ! context.MasterSecret = PRF(preMasterSecret, "master secret", seed.ToArray(), 48); ! ! seed.Reset(); } public override void CreateKeys() { - TlsStream seed = new TlsStream(); - - // Seed - seed.Write(context.ServerRandom); - seed.Write(context.ClientRandom); - // Create keyblock TlsStream keyBlock = new TlsStream( PRF(this.Context.MasterSecret, "key expansion", ! seed.ToArray(), this.KeyBlockSize)); --- 158,174 ---- public override void CreateMasterSecret(byte[] preMasterSecret) { // Create master secret ! this.Context.MasterSecret = new byte[preMasterSecret.Length]; ! this.Context.MasterSecret = PRF( ! preMasterSecret, "master secret", this.Context.RandomCS, 48); } public override void CreateKeys() { // Create keyblock TlsStream keyBlock = new TlsStream( PRF(this.Context.MasterSecret, "key expansion", ! this.Context.RandomSC, this.KeyBlockSize)); *************** *** 206,217 **** else { - // Seed - seed.Reset(); - seed.Write(this.Context.ClientRandom); - seed.Write(this.Context.ServerRandom); - // Generate final write keys ! byte[] finalClientWriteKey = PRF(this.Context.ClientWriteKey, "client write key", seed.ToArray(), this.KeyMaterialSize); ! byte[] finalServerWriteKey = PRF(this.Context.ServerWriteKey, "server write key", seed.ToArray(), this.KeyMaterialSize); this.Context.ClientWriteKey = finalClientWriteKey; --- 193,199 ---- else { // Generate final write keys ! byte[] finalClientWriteKey = PRF(this.Context.ClientWriteKey, "client write key", this.Context.RandomCS, this.KeyMaterialSize); ! byte[] finalServerWriteKey = PRF(this.Context.ServerWriteKey, "server write key", this.Context.RandomCS, this.KeyMaterialSize); this.Context.ClientWriteKey = finalClientWriteKey; *************** *** 219,223 **** // Generate IV block ! byte[] ivBlock = PRF(new byte[]{}, "IV block", seed.ToArray(), this.IvSize*2); // Generate IV keys --- 201,205 ---- // Generate IV block ! byte[] ivBlock = PRF(new byte[]{}, "IV block", this.Context.RandomCS, this.IvSize*2); // Generate IV keys *************** *** 229,233 **** // Clear no more needed data - seed.Reset(); keyBlock.Reset(); } --- 211,214 ---- Index: TlsCipherSuiteCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsCipherSuiteCollection.cs 20 Oct 2003 09:58:29 -0000 1.2 --- TlsCipherSuiteCollection.cs 21 Oct 2003 16:05:12 -0000 1.3 *************** *** 32,53 **** internal sealed class TlsCipherSuiteCollection : ArrayList { #region PROPERTIES ! public TlsCipherSuite this[string name] { ! get { return (TlsCipherSuite)this[IndexOf(name)]; } ! set { this[IndexOf(name)] = (TlsCipherSuite)value; } } ! public TlsCipherSuite this[short code] { ! get { return (TlsCipherSuite)base[IndexOf(code)]; } ! set { base[IndexOf(code)] = (TlsCipherSuite)value; } } ! public new TlsCipherSuite this[int code] { ! get { return (TlsCipherSuite)base[code]; } ! set { base[code] = (TlsCipherSuite)value; } } --- 32,68 ---- internal sealed class TlsCipherSuiteCollection : ArrayList { + #region FIELDS + + private TlsProtocol protocol; + + #endregion + #region PROPERTIES ! public TlsAbstractCipherSuite this[string name] { ! get { return (TlsAbstractCipherSuite)this[IndexOf(name)]; } ! set { this[IndexOf(name)] = (TlsAbstractCipherSuite)value; } } ! public TlsAbstractCipherSuite this[short code] { ! get { return (TlsAbstractCipherSuite)base[IndexOf(code)]; } ! set { base[IndexOf(code)] = (TlsAbstractCipherSuite)value; } } ! public new TlsAbstractCipherSuite this[int code] { ! get { return (TlsAbstractCipherSuite)base[code]; } ! set { base[code] = (TlsAbstractCipherSuite)value; } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public TlsCipherSuiteCollection(TlsProtocol protocol) : base() ! { ! this.protocol = protocol; } *************** *** 64,68 **** { int index = 0; ! foreach(TlsCipherSuite suite in this) { if (cultureAwareCompare(suite.Name, name)) --- 79,83 ---- { int index = 0; ! foreach (TlsAbstractCipherSuite suite in this) { if (cultureAwareCompare(suite.Name, name)) *************** *** 78,82 **** { int index = 0; ! foreach(TlsCipherSuite suite in this) { if (suite.Code == code) --- 93,97 ---- { int index = 0; ! foreach (TlsAbstractCipherSuite suite in this) { if (suite.Code == code) *************** *** 94,98 **** } ! public TlsCipherSuite Add(TlsCipherSuite cipherSuite) { base.Add(cipherSuite); --- 109,130 ---- } ! public TlsAbstractCipherSuite Add(short code, string name, string algName, string hashName, bool exportable, bool blockMode, byte keyMaterialSize, byte expandedKeyMaterialSize, short effectiveKeyBytes, byte ivSize, byte blockSize) ! { ! switch (this.protocol) ! { ! case TlsProtocol.Tls1: ! return this.add( ! new TlsCipherSuite(code, name, algName, hashName, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)); ! ! case TlsProtocol.Ssl3: ! return this.add( ! new TlsSslCipherSuite(code, name, algName, hashName, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)); ! ! default: ! throw new NotSupportedException(); ! } ! } ! ! private TlsCipherSuite add(TlsCipherSuite cipherSuite) { base.Add(cipherSuite); *************** *** 101,109 **** } ! public TlsCipherSuite Add(short code, string name, string algName, string hashName, bool exportable, bool blockMode, byte keyMaterialSize, byte expandedKeyMaterialSize, short effectiveKeyBytes, byte ivSize, byte blockSize) { ! TlsCipherSuite cipherSuite = new TlsCipherSuite(code, name, algName, hashName, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize); ! return Add(cipherSuite); } --- 133,141 ---- } ! private TlsSslCipherSuite add(TlsSslCipherSuite cipherSuite) { ! base.Add(cipherSuite); ! return cipherSuite; } Index: TlsCipherSuiteFactory.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsCipherSuiteFactory.cs 21 Oct 2003 09:31:41 -0000 1.2 --- TlsCipherSuiteFactory.cs 21 Oct 2003 16:05:12 -0000 1.3 *************** *** 48,52 **** private static TlsCipherSuiteCollection GetTls1SupportedCiphers() { ! TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(); // Supported ciphers --- 48,52 ---- private static TlsCipherSuiteCollection GetTls1SupportedCiphers() { ! TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(TlsProtocol.Tls1); // Supported ciphers *************** *** 117,121 **** private static TlsCipherSuiteCollection GetSsl3SupportedCiphers() { ! TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(); // Supported ciphers --- 117,121 ---- private static TlsCipherSuiteCollection GetSsl3SupportedCiphers() { ! TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(TlsProtocol.Ssl3); // Supported ciphers Index: TlsContentType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsContentType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsContentType.cs 11 Oct 2003 10:04:20 -0000 1.1 --- TlsContentType.cs 21 Oct 2003 16:05:12 -0000 1.2 *************** *** 33,37 **** Handshake = 22, ApplicationData = 23, - Unknown = 255 } } --- 33,36 ---- Index: TlsSession.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSession.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsSession.cs 20 Oct 2003 22:00:28 -0000 1.6 --- TlsSession.cs 21 Oct 2003 16:05:12 -0000 1.7 *************** *** 167,171 **** this.supportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(context.Protocol); this.socket.DoHandshake(); ! this.state = TlsSessionState.OpenSecure; } catch (TlsException ex) --- 167,171 ---- this.supportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(context.Protocol); this.socket.DoHandshake(); ! this.state = TlsSessionState.OpenSecure; } catch (TlsException ex) Index: TlsSessionContext.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSessionContext.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsSessionContext.cs 20 Oct 2003 22:00:29 -0000 1.7 --- TlsSessionContext.cs 21 Oct 2003 16:05:12 -0000 1.8 *************** *** 48,52 **** private bool isActual; private bool connectionEnd; ! private TlsCipherSuite cipher; // Sequence numbers --- 48,52 ---- private bool isActual; private bool connectionEnd; ! private TlsAbstractCipherSuite cipher; // Sequence numbers *************** *** 57,60 **** --- 57,62 ---- private byte[] clientRandom; private byte[] serverRandom; + private byte[] randomCS; + private byte[] randomSC; // Key information *************** *** 82,188 **** public TlsProtocol Protocol { ! get { return protocol; } ! set { protocol = value; } } public TlsCompressionMethod CompressionMethod { ! get { return compressionMethod; } ! set { compressionMethod = value; } } public TlsServerSettings ServerSettings { ! get { return serverSettings; } ! set { serverSettings = value; } } public bool IsActual { ! get { return isActual; } ! set { isActual = value; } } public bool ConnectionEnd { ! get { return connectionEnd; } ! set { connectionEnd = value; } } ! public TlsCipherSuite Cipher { ! get { return cipher; } ! set { cipher = value; } } public TlsHandshakeHashes HandshakeHashes { ! get { return handshakeHashes; } } public long WriteSequenceNumber { ! get { return writeSequenceNumber; } ! set { writeSequenceNumber = value; } } public long ReadSequenceNumber { ! get { return readSequenceNumber; } ! set { readSequenceNumber = value; } } public byte[] ClientRandom { ! get { return clientRandom; } ! set { clientRandom = value; } } public byte[] ServerRandom { ! get { return serverRandom; } ! set { serverRandom = value; } } public byte[] MasterSecret { ! get { return masterSecret; } ! set { masterSecret = value; } } public byte[] ClientWriteMAC { ! get { return clientWriteMAC; } ! set { clientWriteMAC = value; } } public byte[] ServerWriteMAC { ! get { return serverWriteMAC; } ! set { serverWriteMAC = value; } } public byte[] ClientWriteKey { ! get { return clientWriteKey; } ! set { clientWriteKey = value; } } public byte[] ServerWriteKey { ! get { return serverWriteKey; } ! set { serverWriteKey = value; } } public byte[] ClientWriteIV { ! get { return clientWriteIV; } ! set { clientWriteIV = value; } } public byte[] ServerWriteIV { ! get { return serverWriteIV; } ! set { serverWriteIV = value; } } --- 84,202 ---- public TlsProtocol Protocol { ! get { return this.protocol; } ! set { this.protocol = value; } } public TlsCompressionMethod CompressionMethod { ! get { return this.compressionMethod; } ! set { this.compressionMethod = value; } } public TlsServerSettings ServerSettings { ! get { return this.serverSettings; } ! set { this.serverSettings = value; } } public bool IsActual { ! get { return this.isActual; } ! set { this.isActual = value; } } public bool ConnectionEnd { ! get { return this.connectionEnd; } ! set { this.connectionEnd = value; } } ! public TlsAbstractCipherSuite Cipher { ! get { return this.cipher; } ! set { this.cipher = value; } } public TlsHandshakeHashes HandshakeHashes { ! get { return this.handshakeHashes; } } public long WriteSequenceNumber { ! get { return this.writeSequenceNumber; } ! set { this.writeSequenceNumber = value; } } public long ReadSequenceNumber { ! get { return this.readSequenceNumber; } ! set { this.readSequenceNumber = value; } } public byte[] ClientRandom { ! get { return this.clientRandom; } ! set { this.clientRandom = value; } } public byte[] ServerRandom { ! get { return this.serverRandom; } ! set { this.serverRandom = value; } ! } ! ! public byte[] RandomCS ! { ! get { return this.randomCS; } ! set { this.randomCS = value; } ! } ! ! public byte[] RandomSC ! { ! get { return this.randomSC; } ! set { this.randomSC = value; } } public byte[] MasterSecret { ! get { return this.masterSecret; } ! set { this.masterSecret = value; } } public byte[] ClientWriteMAC { ! get { return this.clientWriteMAC; } ! set { this.clientWriteMAC = value; } } public byte[] ServerWriteMAC { ! get { return this.serverWriteMAC; } ! set { this.serverWriteMAC = value; } } public byte[] ClientWriteKey { ! get { return this.clientWriteKey; } ! set { this.clientWriteKey = value; } } public byte[] ServerWriteKey { ! get { return this.serverWriteKey; } ! set { this.serverWriteKey = value; } } public byte[] ClientWriteIV { ! get { return this.clientWriteIV; } ! set { this.clientWriteIV = value; } } public byte[] ServerWriteIV { ! get { return this.serverWriteIV; } ! set { this.serverWriteIV = value; } } *************** *** 224,244 **** { // Clear Master Secret ! masterSecret = null; // Clear client and server random ! clientRandom = null; ! serverRandom = null; // Clear client keys ! clientWriteKey = null; ! clientWriteIV = null; ! clientWriteMAC = null; // Clear server keys ! serverWriteKey = null; ! serverWriteIV = null; ! serverWriteMAC = null; ! ! // Force the GC to recollect the memory ?? } --- 238,258 ---- { // Clear Master Secret ! this.masterSecret = null; // Clear client and server random ! this.clientRandom = null; ! this.serverRandom = null; ! this.randomCS = null; ! this.randomSC = null; // Clear client keys ! this.clientWriteKey = null; ! this.clientWriteIV = null; ! this.clientWriteMAC = null; // Clear server keys ! this.serverWriteKey = null; ! this.serverWriteIV = null; ! this.serverWriteMAC = null; } Index: TlsSessionSettings.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSessionSettings.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsSessionSettings.cs 20 Oct 2003 18:21:43 -0000 1.2 --- TlsSessionSettings.cs 21 Oct 2003 16:05:12 -0000 1.3 *************** *** 67,71 **** set { ! if (value != TlsProtocol.Tls1) { throw new NotSupportedException("Specified protocol is not supported"); --- 67,72 ---- set { ! if (value != TlsProtocol.Tls1 && ! value != TlsProtocol.Ssl3) { throw new NotSupportedException("Specified protocol is not supported"); Index: TlsSslCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsSslCipherSuite.cs 21 Oct 2003 12:17:10 -0000 1.3 --- TlsSslCipherSuite.cs 21 Oct 2003 16:05:12 -0000 1.4 *************** *** 132,141 **** public override void CreateMasterSecret(byte[] preMasterSecret) { ! throw new NotSupportedException(); } public override void CreateKeys() { ! throw new NotSupportedException(); } --- 132,246 ---- public override void CreateMasterSecret(byte[] preMasterSecret) { ! TlsStream masterSecret = new TlsStream(); ! ! masterSecret.Write(this.prf(preMasterSecret, "A", this.Context.RandomCS)); ! masterSecret.Write(this.prf(preMasterSecret, "BB", this.Context.RandomCS)); ! masterSecret.Write(this.prf(preMasterSecret, "CCC", this.Context.RandomCS)); ! ! this.context.MasterSecret = masterSecret.ToArray(); } public override void CreateKeys() { ! // Compute KeyBlock ! TlsStream tmp = new TlsStream(); ! ! char labelChar = 'A'; ! int count = 1; ! while (tmp.Length < this.KeyBlockSize) ! { ! string label = String.Empty; ! ! for (int i = 0; i < count; i++) ! { ! label += labelChar.ToString(); ! } ! ! byte[] block = this.prf(this.Context.MasterSecret, label.ToString(), this.Context.RandomSC); ! ! int size = (tmp.Length + block.Length) > this.KeyBlockSize ? (this.KeyBlockSize - (int)tmp.Length) : block.Length; ! ! tmp.Write(block, 0, size); ! ! labelChar++; ! count++; ! } ! ! // Create keyblock ! TlsStream keyBlock = new TlsStream(tmp.ToArray()); ! ! this.Context.ClientWriteMAC = keyBlock.ReadBytes(this.HashSize); ! this.Context.ServerWriteMAC = keyBlock.ReadBytes(this.HashSize); ! this.Context.ClientWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize); ! this.Context.ServerWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize); ! ! if (!this.IsExportable) ! { ! if (this.IvSize != 0) ! { ! this.Context.ClientWriteIV = keyBlock.ReadBytes(this.IvSize); ! this.Context.ServerWriteIV = keyBlock.ReadBytes(this.IvSize); ! } ! else ! { ! this.Context.ClientWriteIV = new byte[0]; ! this.Context.ServerWriteIV = new byte[0]; ! } ! } ! else ! { ! MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); ! ! // Generate final write keys ! byte[] finalClientWriteKey = new byte[md5.HashSize]; ! md5.TransformBlock(this.Context.ClientWriteKey, 0, this.Context.ClientWriteKey.Length, finalClientWriteKey, 0); ! finalClientWriteKey = md5.TransformFinalBlock(this.Context.RandomCS, 0, this.Context.RandomCS.Length); ! ! byte[] finalServerWriteKey = new byte[md5.HashSize]; ! md5.TransformBlock(this.Context.ServerWriteKey, 0, this.Context.ServerWriteKey.Length, finalServerWriteKey, 0); ! finalClientWriteKey = md5.TransformFinalBlock(this.Context.RandomSC, 0, this.Context.RandomSC.Length); ! ! this.Context.ClientWriteKey = finalClientWriteKey; ! this.Context.ServerWriteKey = finalServerWriteKey; ! ! // Generate IV keys ! this.Context.ClientWriteIV = md5.TransformFinalBlock(this.Context.RandomCS, 0, this.Context.RandomCS.Length); ! this.Context.ServerWriteIV = md5.TransformFinalBlock(this.Context.RandomSC, 0, this.Context.RandomSC.Length); ! } ! ! // Clear no more needed data ! keyBlock.Reset(); ! tmp.Reset(); ! } ! ! #endregion ! ! #region PRIVATE_METHODS ! ! private byte[] prf(byte[] secret, string label, byte[] random) ! { ! MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); ! SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider(); ! ! // Compute SHA hash ! TlsStream block = new TlsStream(); ! block.Write(Encoding.ASCII.GetBytes(label)); ! block.Write(secret); ! block.Write(random); ! ! byte[] shaHash = sha.ComputeHash(block.ToArray(), 0, (int)block.Length); ! ! block.Reset(); ! ! // Compute MD5 hash ! block.Write(secret); ! block.Write(shaHash); ! ! byte[] result = md5.ComputeHash(block.ToArray(), 0, (int)block.Length); ! ! // Free resources ! block.Reset(); ! ! return result; } |
From: <car...@us...> - 2003-10-21 16:05:41
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv8448 Modified Files: PgSqlClient.build Log Message: Updated build file Index: PgSqlClient.build =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.build,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PgSqlClient.build 15 Oct 2003 14:35:05 -0000 1.8 --- PgSqlClient.build 21 Oct 2003 12:17:47 -0000 1.9 *************** *** 71,74 **** --- 71,80 ---- <!-- Build target for all existing platforms --> <target name="build-all" depends="check-build-config"> + <call target="net-1.0" /> + <call target="net-1.1" /> + <call target="mono-1.0" /> + </target> + + <target name="net-1.0"> <!-- .NET Framework 1.0 --> <available type="Framework" resource="net-1.0" property="temp.framework.available" /> *************** *** 79,92 **** <property name="nant.settings.currentframework" value="net-1.0" /> <echo message="Building using .NET Framework 1.0." /> ! <call target="build-provider" /> <if propertyexists="htmlhelp.compiler"> ! <!-- call target="build-sdk" / --> </if> <if propertyexists="nunit.framework.dll"> ! <call target="build-nunit-tests" /> </if> ! <call target="distribution" /> </if> ! <!-- .NET Framework 1.1 --> <available type="Framework" resource="net-1.1" property="temp.framework.available" /> --- 85,100 ---- <property name="nant.settings.currentframework" value="net-1.0" /> <echo message="Building using .NET Framework 1.0." /> ! <call target="build-provider" force="true" /> <if propertyexists="htmlhelp.compiler"> ! <!-- call target="build-sdk" force="true" /--> </if> <if propertyexists="nunit.framework.dll"> ! <call target="build-nunit-tests" force="true" /> </if> ! <call target="distribution" force="true" /> </if> ! </target> ! ! <target name="net-1.1"> <!-- .NET Framework 1.1 --> <available type="Framework" resource="net-1.1" property="temp.framework.available" /> *************** *** 97,110 **** <property name="nant.settings.currentframework" value="net-1.1" /> <echo message="Building using .NET Framework 1.1." /> ! <call target="build-provider" /> <if propertyexists="htmlhelp.compiler"> ! <!-- call target="build-sdk" / --> </if> <if propertyexists="nunit.framework.dll"> ! <call target="build-nunit-tests" /> </if> ! <call target="distribution" /> </if> ! <!-- Mono 1.0 --> <available type="Framework" resource="mono-1.0" property="temp.framework.available" /> --- 105,120 ---- <property name="nant.settings.currentframework" value="net-1.1" /> <echo message="Building using .NET Framework 1.1." /> ! <call target="build-provider" force="true" /> <if propertyexists="htmlhelp.compiler"> ! <!-- call target="build-sdk" force="true" /--> </if> <if propertyexists="nunit.framework.dll"> ! <call target="build-nunit-tests" force="true" /> </if> ! <call target="distribution" force="true" /> </if> ! </target> ! ! <target name="mono-1.0"> <!-- Mono 1.0 --> <available type="Framework" resource="mono-1.0" property="temp.framework.available" /> *************** *** 115,122 **** <property name="nant.settings.currentframework" value="mono-1.0" /> <echo message="Building using Mono 1.0." /> ! <call target="build-provider-mono" /> </if> </target> ! <!-- Taget for build TLS Assembly (Microsoft .NET) --> <target name="build-tls"> --- 125,134 ---- <property name="nant.settings.currentframework" value="mono-1.0" /> <echo message="Building using Mono 1.0." /> ! <property name="build.define" value="_MONO"/> ! <call target="build-provider-mono" force="true" /> </if> </target> ! ! <!-- Taget for build TLS Assembly (Microsoft .NET) --> <target name="build-tls"> |
From: <car...@us...> - 2003-10-21 13:14:13
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv8423 Modified Files: changelog.txt Log Message: Updated CHANGELOG.TXT Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changelog.txt,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** changelog.txt 21 Oct 2003 09:32:02 -0000 1.56 --- changelog.txt 21 Oct 2003 12:17:29 -0000 1.57 *************** *** 16,19 **** --- 16,26 ---- a throw new NotSupportedException() + * TlsSocket.cs: + * TlsAbstractCipherSuite.cs: + * TlsCipherSuite.cs: + * TlsSslCipherSuite.cs: + + - Moved MAC generation methods to specific CipherSuite classes. + 2003-10-20 Carlos Guzmán Álvarez <car...@te...> |
From: <car...@us...> - 2003-10-21 10:07:28
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv16397 Modified Files: changelog.txt Log Message: Updated CHANGELOG.TXT Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changelog.txt,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** changelog.txt 20 Oct 2003 21:59:53 -0000 1.55 --- changelog.txt 21 Oct 2003 09:32:02 -0000 1.56 *************** *** 3,6 **** --- 3,20 ---- + 2003-10-21 Carlos Guzmán Álvarez <car...@te...> + + * TLS implementation: + + * TlsCipherSuiteFactory.cs: + + - Changed names of private methods. + + * TlsSslCipherSuite.cs: + + - Replaced implementations of key generation methods with + a throw new NotSupportedException() + + 2003-10-20 Carlos Guzmán Álvarez <car...@te...> |
From: <car...@us...> - 2003-10-21 10:06:28
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv16314 Modified Files: TlsCipherSuiteFactory.cs TlsSslCipherSuite.cs Log Message: * TLS implementation: * TlsCipherSuiteFactory.cs: - Changed names of private methods. * TlsSslCipherSuite.cs: - Replaced implementations of key generation methods with a throw new NotSupportedException() Index: TlsCipherSuiteFactory.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsCipherSuiteFactory.cs 20 Oct 2003 10:00:20 -0000 1.1 --- TlsCipherSuiteFactory.cs 21 Oct 2003 09:31:41 -0000 1.2 *************** *** 34,41 **** { case TlsProtocol.Tls1: ! return TlsCipherSuiteFactory.GetTlsSupportedCiphers(); case TlsProtocol.Ssl3: ! return TlsCipherSuiteFactory.GetSslSupportedCiphers(); default: --- 34,41 ---- { case TlsProtocol.Tls1: ! return TlsCipherSuiteFactory.GetTls1SupportedCiphers(); case TlsProtocol.Ssl3: ! return TlsCipherSuiteFactory.GetSsl3SupportedCiphers(); default: *************** *** 46,50 **** #region PRIVATE_STATIC_METHODS ! private static TlsCipherSuiteCollection GetTlsSupportedCiphers() { TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(); --- 46,50 ---- #region PRIVATE_STATIC_METHODS ! private static TlsCipherSuiteCollection GetTls1SupportedCiphers() { TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(); *************** *** 115,119 **** } ! private static TlsCipherSuiteCollection GetSslSupportedCiphers() { TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(); --- 115,119 ---- } ! private static TlsCipherSuiteCollection GetSsl3SupportedCiphers() { TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(); Index: TlsSslCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsSslCipherSuite.cs 20 Oct 2003 10:00:20 -0000 1.1 --- TlsSslCipherSuite.cs 21 Oct 2003 09:31:41 -0000 1.2 *************** *** 118,194 **** public override void CreateMasterSecret(byte[] preMasterSecret) { ! TlsStream seed = new TlsStream(); ! ! // Seed ! seed.Write(context.ClientRandom); ! seed.Write(context.ServerRandom); ! ! // Create master secret ! context.MasterSecret = new byte[preMasterSecret.Length]; ! context.MasterSecret = PRF(preMasterSecret, "master secret", seed.ToArray(), 48); ! ! seed.Reset(); } public override void CreateKeys() { ! TlsStream seed = new TlsStream(); ! ! // Seed ! seed.Write(context.ServerRandom); ! seed.Write(context.ClientRandom); ! ! // Create keyblock ! TlsStream keyBlock = new TlsStream( ! PRF(this.Context.MasterSecret, ! "key expansion", ! seed.ToArray(), ! this.KeyBlockSize)); ! ! this.Context.ClientWriteMAC = keyBlock.ReadBytes(this.HashSize); ! this.Context.ServerWriteMAC = keyBlock.ReadBytes(this.HashSize); ! this.Context.ClientWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize); ! this.Context.ServerWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize); ! ! if (!this.IsExportable) ! { ! if (this.IvSize != 0) ! { ! this.Context.ClientWriteIV = keyBlock.ReadBytes(this.IvSize); ! this.Context.ServerWriteIV = keyBlock.ReadBytes(this.IvSize); ! } ! else ! { ! this.Context.ClientWriteIV = new byte[0]; ! this.Context.ServerWriteIV = new byte[0]; ! } ! } ! else ! { ! // Seed ! seed.Reset(); ! seed.Write(this.Context.ClientRandom); ! seed.Write(this.Context.ServerRandom); ! ! // Generate final write keys ! byte[] finalClientWriteKey = PRF(this.Context.ClientWriteKey, "client write key", seed.ToArray(), this.KeyMaterialSize); ! byte[] finalServerWriteKey = PRF(this.Context.ServerWriteKey, "server write key", seed.ToArray(), this.KeyMaterialSize); ! ! this.Context.ClientWriteKey = finalClientWriteKey; ! this.Context.ServerWriteKey = finalServerWriteKey; ! ! // Generate IV block ! byte[] ivBlock = PRF(new byte[]{}, "IV block", seed.ToArray(), this.IvSize*2); ! ! // Generate IV keys ! this.Context.ClientWriteIV = new byte[this.IvSize]; ! System.Array.Copy(ivBlock, 0, this.Context.ClientWriteIV, 0, this.Context.ClientWriteIV.Length); ! this.Context.ServerWriteIV = new byte[this.IvSize]; ! System.Array.Copy(ivBlock, this.IvSize, this.Context.ServerWriteIV, 0, this.Context.ServerWriteIV.Length); ! } ! ! // Clear no more needed data ! seed.Reset(); ! keyBlock.Reset(); } --- 118,127 ---- public override void CreateMasterSecret(byte[] preMasterSecret) { ! throw new NotSupportedException(); } public override void CreateKeys() { ! throw new NotSupportedException(); } |
From: <car...@us...> - 2003-10-21 00:39:09
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv8701 Modified Files: changelog.txt Log Message: Updated CHANGELOG.TXT Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changelog.txt,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** changelog.txt 20 Oct 2003 20:31:16 -0000 1.54 --- changelog.txt 20 Oct 2003 21:59:53 -0000 1.55 *************** *** 11,14 **** --- 11,27 ---- * TLS implementation: + * TlsSessionContext.cs: + + - Added new MAX_FRAGMENT_SIZE constant. + + * TlsSession.cs: + + - Removed MaxFragmentSize property. + + * TlsSocket.cs: + + - Replaced use of TlsSesison.MaxFragmentSize by TlsSessionContext.MAX_FAGMENT_SIZE + + - Fixed padding length calculation on record encryption. |
From: <car...@us...> - 2003-10-20 22:56:53
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv8934 Modified Files: TlsSession.cs TlsSessionContext.cs TlsSocket.cs Log Message: * TlsSessionContext.cs: - Added new MAX_FRAGMENT_SIZE constant. * TlsSession.cs: - Removed MaxFragmentSize property. * TlsSocket.cs: - Replaced use of TlsSesison.MaxFragmentSize by TlsSessionContext.MAX_FAGMENT_SIZE Index: TlsSession.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSession.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsSession.cs 20 Oct 2003 21:38:01 -0000 1.5 --- TlsSession.cs 20 Oct 2003 22:00:28 -0000 1.6 *************** *** 112,120 **** } - internal short MaxFragmentSize - { - get { return (short)System.Math.Pow(2, 14); } - } - #endregion --- 112,115 ---- Index: TlsSessionContext.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSessionContext.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsSessionContext.cs 20 Oct 2003 18:21:43 -0000 1.6 --- TlsSessionContext.cs 20 Oct 2003 22:00:29 -0000 1.7 *************** *** 72,75 **** --- 72,81 ---- #endregion + #region INTERNAL_CONSTANTS + + internal const short MAX_FRAGMENT_SIZE = 16384; // 2^14 + + #endregion + #region PROPERTIES Index: TlsSocket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSocket.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsSocket.cs 14 Oct 2003 10:13:58 -0000 1.4 --- TlsSocket.cs 20 Oct 2003 22:00:32 -0000 1.5 *************** *** 426,432 **** short fragmentLength = 0; byte[] fragmentData; ! if ((messageData.Length - position) > session.MaxFragmentSize) { ! fragmentLength = session.MaxFragmentSize; } else --- 426,432 ---- short fragmentLength = 0; byte[] fragmentData; ! if ((messageData.Length - position) > TlsSessionContext.MAX_FRAGMENT_SIZE) { ! fragmentLength = TlsSessionContext.MAX_FRAGMENT_SIZE; } else |
From: <car...@us...> - 2003-10-20 22:03:21
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1:/tmp/cvs-serv22522 Modified Files: PgType.cs Log Message: Fixed little problem returning system type for PostgreSQL Float data type. Index: PgType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgType.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PgType.cs 19 Oct 2003 14:08:22 -0000 1.7 --- PgType.cs 20 Oct 2003 20:30:29 -0000 1.8 *************** *** 192,196 **** case PgDataType.Float: ! return Type.GetType("System.Float"); case PgDataType.Int2: --- 192,196 ---- case PgDataType.Float: ! return Type.GetType("System.Single"); case PgDataType.Int2: |
From: <car...@us...> - 2003-10-20 22:00:55
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv4325 Modified Files: TlsSession.cs Log Message: Minor change Index: TlsSession.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsSession.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsSession.cs 20 Oct 2003 18:21:43 -0000 1.4 --- TlsSession.cs 20 Oct 2003 21:38:01 -0000 1.5 *************** *** 114,118 **** internal short MaxFragmentSize { ! get { return (short)Math.Pow(2, 14); } } --- 114,118 ---- internal short MaxFragmentSize { ! get { return (short)System.Math.Pow(2, 14); } } |
From: <car...@us...> - 2003-10-20 21:48:17
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTypes In directory sc8-pr-cvs1:/tmp/cvs-serv4688 Modified Files: PgLSeg.cs PgPath.cs PgPolygon.cs Log Message: Updated files Index: PgLSeg.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTypes/PgLSeg.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PgLSeg.cs 18 Oct 2003 13:11:18 -0000 1.2 --- PgLSeg.cs 20 Oct 2003 21:39:41 -0000 1.3 *************** *** 89,93 **** { System.Text.StringBuilder b = new System.Text.StringBuilder(); ! b.AppendFormat("(({0},{1}),({2},{3}))", this.startPoint.X , this.startPoint.Y, this.endPoint.X , this.endPoint.Y); --- 89,93 ---- { System.Text.StringBuilder b = new System.Text.StringBuilder(); ! b.AppendFormat("[({0},{1}),({2},{3})]", this.startPoint.X , this.startPoint.Y, this.endPoint.X , this.endPoint.Y); Index: PgPath.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTypes/PgPath.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PgPath.cs 18 Oct 2003 11:57:37 -0000 1.1 --- PgPath.cs 20 Oct 2003 21:39:41 -0000 1.2 *************** *** 23,29 **** public class PgPath { ! public PgPath() { } } } --- 23,141 ---- public class PgPath { ! #region FIELDS ! ! private PgPoint[] points; ! private bool isClosedPath; ! ! #endregion ! ! #region PROPERTIES ! ! public PgPoint[] Points ! { ! get { return points; } ! } ! ! public bool IsClosedPath ! { ! get { return isClosedPath; } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public PgPath(bool isClosedPath, PgPoint[] points) ! { ! this.isClosedPath = isClosedPath; ! this.points = (PgPoint[])points.Clone(); ! } ! ! #endregion ! ! #region OPERATORS ! ! public static bool operator ==(PgPath left, PgPath right) ! { ! bool equals = false; ! ! if (left.Points.Length == right.Points.Length) ! { ! equals = true; ! for (int i = 0; i < left.Points.Length; i++) ! { ! if (left.Points[i] != right.Points[i]) ! { ! equals = false; ! break; ! } ! } ! } ! ! return equals; ! } ! ! public static bool operator !=(PgPath left, PgPath right) ! { ! bool notequals = true; ! ! if (left.Points.Length == right.Points.Length) ! { ! notequals = false; ! for (int i = 0; i < left.Points.Length; i++) ! { ! if (left.Points[i] != right.Points[i]) ! { ! notequals = true; ! break; ! } ! } ! } ! ! return notequals; ! } ! ! #endregion ! ! #region OVERRIDEN_METHODS ! ! public override string ToString() { + System.Text.StringBuilder b = new System.Text.StringBuilder(); + + b.Append(this.isClosedPath ? "(" : "["); + + for (int i = 0; i < this.points.Length; i++) + { + if (b.Length > 1) + { + b.Append(","); + } + b.Append(this.points[i].ToString()); + } + + b.Append(this.isClosedPath ? ")" : "]"); + + return b.ToString(); + } + + public override int GetHashCode() + { + return base.GetHashCode(); } + + public override bool Equals(object obj) + { + if (obj is PgPath) + { + return (obj as PgPath) == this; + } + else + { + return false; + } + } + + #endregion } } Index: PgPolygon.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTypes/PgPolygon.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PgPolygon.cs 18 Oct 2003 13:38:40 -0000 1.2 --- PgPolygon.cs 20 Oct 2003 21:39:41 -0000 1.3 *************** *** 97,111 **** System.Text.StringBuilder b = new System.Text.StringBuilder(); for (int i = 0; i < this.points.Length; i++) { ! if (b.Length > 0) { b.Append(","); } ! b.AppendFormat("({0},{1}),({2},{3})", ! this.points[0].X, this.points[i].Y); } ! b.AppendFormat("( {0} )", b.ToString()); return b.ToString(); --- 97,112 ---- System.Text.StringBuilder b = new System.Text.StringBuilder(); + b.Append("("); + for (int i = 0; i < this.points.Length; i++) { ! if (b.Length > 1) { b.Append(","); } ! b.Append(this.points[i].ToString()); } ! b.Append(")"); return b.ToString(); |
From: <car...@us...> - 2003-10-20 21:00:40
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv22659 Modified Files: changelog.txt Log Message: Updated CHANGELOG.TXT Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changelog.txt,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** changelog.txt 20 Oct 2003 18:23:31 -0000 1.53 --- changelog.txt 20 Oct 2003 20:31:16 -0000 1.54 *************** *** 5,8 **** --- 5,12 ---- 2003-10-20 Carlos Guzmán Álvarez <car...@te...> + * source/NPgClient/PgType.cs: + + - Fixed little problem returning system type for PostgreSQL Float data type. + * TLS implementation: |