[pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls ClientR
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos Guzm?n ?l. <car...@us...> - 2004-04-21 12:50:38
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17374 Modified Files: ClientRecordProtocol.cs Context.cs RecordProtocol.cs ServerContext.cs SslCipherSuite.cs SslClientStream.cs TlsCipherSuite.cs Log Message: 2004-04-22 Carlos Guzman Alvarez <car...@te...> * Mono.Security.Protocol.Tls/ClientRecordProtocol.cs: * Mono.Security.Protocol.Tls/RecordProtocol.cs: * Mono.Security.Protocol.Tls/Context.cs: * Mono.Security.Protocol.Tls/Context.cs: * Mono.Security.Protocol.Tls/SslCipherSuite.cs: * Mono.Security.Protocol.Tls/TlsCipherSuite.cs: * Mono.Security.Protocol.Tls/SslClientStream.cs: - Added debug capabilities. * Mono.Security.Protocol.Tls/ServerContext.cs: - Added initialization of requested CertificateTypes and CA's Index: RecordProtocol.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** RecordProtocol.cs 10 Apr 2004 11:16:24 -0000 1.15 --- RecordProtocol.cs 21 Apr 2004 12:49:17 -0000 1.16 *************** *** 109,112 **** --- 109,118 ---- } + DebugHelper.WriteLine( + ">>>> Read record ({0}|{1})", + this.context.DecodeProtocolCode(protocol), + contentType); + DebugHelper.WriteLine("Record data", buffer); + TlsStream message = new TlsStream(buffer); *************** *** 132,135 **** --- 138,143 ---- contentType, message.ToArray()); + + DebugHelper.WriteLine("Decrypted record data", message.ToArray()); } } *************** *** 223,227 **** public void SendAlert(Alert alert) ! { // Write record this.SendRecord( --- 231,237 ---- public void SendAlert(Alert alert) ! { ! DebugHelper.WriteLine(">>>> Write Alert ({0}|{1})", alert.Description, alert.Message); ! // Write record this.SendRecord( *************** *** 241,244 **** --- 251,256 ---- public void SendChangeCipherSpec() { + DebugHelper.WriteLine(">>>> Write Change Cipher Spec"); + // Send Change Cipher Spec message as a plain message this.context.IsActual = false; *************** *** 327,330 **** --- 339,344 ---- record.Write(fragment); + DebugHelper.WriteLine("Record data", fragment); + // Update buffer position position += fragmentLength; *************** *** 354,357 **** --- 368,373 ---- } + DebugHelper.WriteLine(">>>> Record MAC", mac); + // Encrypt the message byte[] ecr = this.context.Cipher.EncryptRecord(fragment, mac); *************** *** 406,409 **** --- 422,427 ---- } + DebugHelper.WriteLine(">>>> Record MAC", mac); + // Check record MAC if (mac.Length != dcrMAC.Length) *************** *** 425,434 **** if (badRecordMac) { ! if (this.context is ServerContext) ! { ! this.Context.RecordProtocol.SendAlert(AlertDescription.BadRecordMAC); ! } ! ! throw new TlsException("Bad record MAC"); } --- 443,447 ---- if (badRecordMac) { ! throw new TlsException(AlertDescription.BadRecordMAC, "Bad record MAC"); } Index: Context.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/Context.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Context.cs 10 Apr 2004 21:44:02 -0000 1.8 --- Context.cs 21 Apr 2004 12:49:17 -0000 1.9 *************** *** 409,422 **** } - public void PrintBuffer(string title, byte[] buffer) - { - Console.WriteLine("{0}\n", title); - for (int i = 0; i < buffer.Length; i++) - { - Console.Write(buffer[i].ToString("x2")); - } - Console.WriteLine("\n\n"); - } - #endregion } --- 409,412 ---- Index: ServerContext.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/ServerContext.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ServerContext.cs 19 Mar 2004 22:44:47 -0000 1.3 --- ServerContext.cs 21 Apr 2004 12:49:17 -0000 1.4 *************** *** 27,30 **** --- 27,31 ---- using System.Security.Cryptography.X509Certificates; + using Mono.Security.Protocol.Tls.Handshake; using MonoX509 = Mono.Security.X509; *************** *** 74,77 **** --- 75,85 ---- this.ServerSettings.UpdateCertificateRSA(); + + // Add requested certificate types + this.ServerSettings.CertificateTypes = new ClientCertificateType[1]; + this.ServerSettings.CertificateTypes[0] = ClientCertificateType.RSA; + + // Add certificate authorities + this.ServerSettings.DistinguisedNames = new string[0]; } Index: SslClientStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SslClientStream.cs 10 Apr 2004 11:16:24 -0000 1.20 --- SslClientStream.cs 21 Apr 2004 12:49:18 -0000 1.21 *************** *** 482,487 **** buffer, offset, count, callback, state); } ! catch (TlsException) { throw new IOException("The authentication or decryption has failed."); } --- 482,490 ---- buffer, offset, count, callback, state); } ! catch (TlsException ex) { + this.protocol.SendAlert(ex.Alert); + this.Close(); + throw new IOException("The authentication or decryption has failed."); } *************** *** 547,552 **** record, 0, record.Length, callback, state); } ! catch (TlsException) { throw new IOException("The authentication or decryption has failed."); } --- 550,558 ---- record, 0, record.Length, callback, state); } ! catch (TlsException ex) { + this.protocol.SendAlert(ex.Alert); + this.Close(); + throw new IOException("The authentication or decryption has failed."); } Index: SslCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/SslCipherSuite.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SslCipherSuite.cs 10 Apr 2004 21:44:02 -0000 1.4 --- SslCipherSuite.cs 21 Apr 2004 12:49:17 -0000 1.5 *************** *** 159,162 **** --- 159,164 ---- this.Context.MasterSecret = masterSecret.ToArray(); + + DebugHelper.WriteLine(">>>> MasterSecret", this.Context.MasterSecret); } *************** *** 251,254 **** --- 253,264 ---- } + DebugHelper.WriteLine(">>>> KeyBlock", keyBlock.ToArray()); + DebugHelper.WriteLine(">>>> ClientWriteKey", this.Context.ClientWriteKey); + DebugHelper.WriteLine(">>>> ClientWriteIV", this.Context.ClientWriteIV); + DebugHelper.WriteLine(">>>> ClientWriteMAC", this.Context.ClientWriteMAC); + DebugHelper.WriteLine(">>>> ServerWriteKey", this.Context.ServerWriteKey); + DebugHelper.WriteLine(">>>> ServerWriteIV", this.Context.ServerWriteIV); + DebugHelper.WriteLine(">>>> ServerWriteMAC", this.Context.ServerWriteMAC); + // Clear no more needed data keyBlock.Reset(); Index: TlsCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TlsCipherSuite.cs 18 Mar 2004 14:06:31 -0000 1.8 --- TlsCipherSuite.cs 21 Apr 2004 12:49:21 -0000 1.9 *************** *** 116,119 **** --- 116,121 ---- this.Context.MasterSecret = this.PRF( preMasterSecret, "master secret", this.Context.RandomCS, 48); + + DebugHelper.WriteLine(">>>> MasterSecret", this.Context.MasterSecret); } *************** *** 174,177 **** --- 176,187 ---- } + DebugHelper.WriteLine(">>>> KeyBlock", keyBlock.ToArray()); + DebugHelper.WriteLine(">>>> ClientWriteKey", this.Context.ClientWriteKey); + DebugHelper.WriteLine(">>>> ClientWriteIV", this.Context.ClientWriteIV); + DebugHelper.WriteLine(">>>> ClientWriteMAC", this.Context.ClientWriteMAC); + DebugHelper.WriteLine(">>>> ServerWriteKey", this.Context.ServerWriteKey); + DebugHelper.WriteLine(">>>> ServerWriteIV", this.Context.ServerWriteIV); + DebugHelper.WriteLine(">>>> ServerWriteMAC", this.Context.ServerWriteMAC); + // Clear no more needed data keyBlock.Reset(); Index: ClientRecordProtocol.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ClientRecordProtocol.cs 10 Apr 2004 11:16:24 -0000 1.7 --- ClientRecordProtocol.cs 21 Apr 2004 12:49:06 -0000 1.8 *************** *** 50,53 **** --- 50,55 ---- HandshakeMessage msg = this.createClientHandshakeMessage(type); + DebugHelper.WriteLine(">>>> Write handshake record ({0}|{1})", context.Protocol, msg.ContentType); + // Write record this.SendRecord(msg.ContentType, msg.EncodeMessage()); *************** *** 75,78 **** --- 77,82 ---- HandshakeMessage message = null; + DebugHelper.WriteLine(">>>> Processing Handshake record ({0})", handshakeType); + // Read message length int length = handMsg.ReadInt24(); *************** *** 99,104 **** #region Client Handshake Message Factories ! private HandshakeMessage createClientHandshakeMessage( ! HandshakeType type) { switch (type) --- 103,107 ---- #region Client Handshake Message Factories ! private HandshakeMessage createClientHandshakeMessage(HandshakeType type) { switch (type) |