[pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls CipherS
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2004-02-17 18:01:14
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10160 Modified Files: CipherSuite.cs SecurityProtocolType.cs SslClientStream.cs TlsCipherSuite.cs TlsCipherSuiteCollection.cs TlsCipherSuiteFactory.cs TlsContext.cs Log Message: 2004-02-17 Carlos Guzmán Álvarez <car...@te...> * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs: - Raise the Client Certificate event. * Mono.Security.Protocol.Tls/CipherSuite.cs: * Mono.Security.Protocol.Tls/SslClientStream.cs: * Mono.Security.Protocol.Tls/SecurityProtocolType.cs: * Mono.Security.Protocol.Tls/TlsCipherSuite.cs: * Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs: * Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs: * Mono.Security.Protocol.Tls/TlsContext.cs: * Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessage.cs: * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs: - Change the SecurityProtocolType enum to mtch .NET 1.2 documentation definition. * Mono.Security.Protocol.Tls/SslClientStream.cs: - Impement SelectedClientCertificate and ServerCertificate properties. Index: CipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CipherSuite.cs 10 Feb 2004 09:43:42 -0000 1.1 --- CipherSuite.cs 17 Feb 2004 17:52:12 -0000 1.2 *************** *** 350,354 **** // Write protocol version ! stream.Write((short)this.Context.Protocol); // Generate random bytes --- 350,354 ---- // Write protocol version ! stream.Write(this.Context.Protocol); // Generate random bytes Index: SecurityProtocolType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/SecurityProtocolType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SecurityProtocolType.cs 10 Feb 2004 09:43:42 -0000 1.1 --- SecurityProtocolType.cs 17 Feb 2004 17:52:12 -0000 1.2 *************** *** 27,35 **** namespace Mono.Security.Protocol.Tls { ! public enum SecurityProtocolType : short { ! Default = (0x03 << 8) | 0x01, ! Ssl3 = (0x03 << 8) | 0x00, ! Tls = (0x03 << 8) | 0x01 } } \ No newline at end of file --- 27,37 ---- namespace Mono.Security.Protocol.Tls { ! [Flags] ! public enum SecurityProtocolType { ! Default = -1073741824, ! Ssl2 = 12, ! Ssl3 = 48, ! Tls = 192 } } \ No newline at end of file Index: SslClientStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SslClientStream.cs 17 Feb 2004 16:52:53 -0000 1.5 --- SslClientStream.cs 17 Feb 2004 17:52:12 -0000 1.6 *************** *** 165,169 **** public SecurityProtocolType SecurityProtocol { ! get { return this.context.Protocol; } } --- 165,169 ---- public SecurityProtocolType SecurityProtocol { ! get { return this.context.SecurityProtocol; } } *************** *** 643,649 **** } ! TlsContentType contentType = (TlsContentType)type; ! SecurityProtocolType protocol = (SecurityProtocolType)this.ReadShort(); ! short length = this.ReadShort(); // Read Record data --- 643,649 ---- } ! TlsContentType contentType = (TlsContentType)type; ! short protocol = this.ReadShort(); ! short length = this.ReadShort(); // Read Record data *************** *** 675,679 **** message = this.decryptRecordFragment( contentType, - protocol, message.ToArray()); } --- 675,678 ---- *************** *** 821,825 **** // Write tls message record.Write((byte)contentType); ! record.Write((short)this.context.Protocol); record.Write((short)fragment.Length); record.Write(fragment); --- 820,824 ---- // Write tls message record.Write((byte)contentType); ! record.Write(this.context.Protocol); record.Write((short)fragment.Length); record.Write(fragment); *************** *** 861,867 **** private TlsStream decryptRecordFragment( ! TlsContentType contentType, ! SecurityProtocolType protocol, ! byte[] fragment) { byte[] dcrFragment = null; --- 860,865 ---- private TlsStream decryptRecordFragment( ! TlsContentType contentType, ! byte[] fragment) { byte[] dcrFragment = null; *************** *** 1008,1012 **** { // Obtain supported cipher suite collection ! this.context.SupportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(context.Protocol); // Send client hello --- 1006,1010 ---- { // Obtain supported cipher suite collection ! this.context.SupportedCiphers = TlsCipherSuiteFactory.GetSupportedCiphers(context.SecurityProtocol); // Send client hello Index: TlsCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuite.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsCipherSuite.cs 10 Feb 2004 09:43:42 -0000 1.1 --- TlsCipherSuite.cs 17 Feb 2004 17:52:12 -0000 1.2 *************** *** 61,65 **** data.Write(this.Context.ReadSequenceNumber); data.Write((byte)contentType); ! data.Write((short)this.Context.Protocol); data.Write((short)fragment.Length); data.Write(fragment); --- 61,65 ---- data.Write(this.Context.ReadSequenceNumber); data.Write((byte)contentType); ! data.Write(this.Context.Protocol); data.Write((short)fragment.Length); data.Write(fragment); *************** *** 79,83 **** data.Write(this.Context.WriteSequenceNumber); data.Write((byte)contentType); ! data.Write((short)this.Context.Protocol); data.Write((short)fragment.Length); data.Write(fragment); --- 79,83 ---- data.Write(this.Context.WriteSequenceNumber); data.Write((byte)contentType); ! data.Write(this.Context.Protocol); data.Write((short)fragment.Length); data.Write(fragment); Index: TlsCipherSuiteCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsCipherSuiteCollection.cs 10 Feb 2004 09:43:42 -0000 1.1 --- TlsCipherSuiteCollection.cs 17 Feb 2004 17:52:12 -0000 1.2 *************** *** 118,137 **** switch (this.protocol) { ! case SecurityProtocolType.Ssl3: return this.add( ! new TlsSslCipherSuite( code, name, cipherType, hashType, exchangeType, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)); ! case SecurityProtocolType.Tls: return this.add( ! new TlsCipherSuite( code, name, cipherType, hashType, exchangeType, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)); default: ! throw new NotSupportedException(); } } --- 118,139 ---- switch (this.protocol) { ! case SecurityProtocolType.Default: ! case SecurityProtocolType.Tls: return this.add( ! new TlsCipherSuite( code, name, cipherType, hashType, exchangeType, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)); ! case SecurityProtocolType.Ssl3: return this.add( ! new TlsSslCipherSuite( code, name, cipherType, hashType, exchangeType, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize)); + case SecurityProtocolType.Ssl2: default: ! throw new NotSupportedException("Unsupported security protocol type."); } } Index: TlsCipherSuiteFactory.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsCipherSuiteFactory.cs 16 Feb 2004 15:28:40 -0000 1.2 --- TlsCipherSuiteFactory.cs 17 Feb 2004 17:52:12 -0000 1.3 *************** *** 33,44 **** switch (protocol) { case SecurityProtocolType.Ssl3: return TlsCipherSuiteFactory.GetSsl3SupportedCiphers(); ! case SecurityProtocolType.Tls: ! return TlsCipherSuiteFactory.GetTls1SupportedCiphers(); ! default: ! throw new NotSupportedException(); } } --- 33,46 ---- switch (protocol) { + case SecurityProtocolType.Default: + case SecurityProtocolType.Tls: + return TlsCipherSuiteFactory.GetTls1SupportedCiphers(); + case SecurityProtocolType.Ssl3: return TlsCipherSuiteFactory.GetSsl3SupportedCiphers(); ! case SecurityProtocolType.Ssl2: default: ! throw new NotSupportedException("Unsupported security protocol type"); } } Index: TlsContext.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/TlsContext.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsContext.cs 10 Feb 2004 09:43:42 -0000 1.1 --- TlsContext.cs 17 Feb 2004 17:52:12 -0000 1.2 *************** *** 43,47 **** // Protocol version ! private SecurityProtocolType protocol; // Sesison ID --- 43,47 ---- // Protocol version ! private SecurityProtocolType securityProtocol; // Sesison ID *************** *** 91,97 **** #endregion ! #region INTERNAL_CONSTANTS ! internal const short MAX_FRAGMENT_SIZE = 16384; // 2^14 #endregion --- 91,99 ---- #endregion ! #region Internal Constants ! internal const short MAX_FRAGMENT_SIZE = 16384; // 2^14 ! internal const short TLS1_PROTOCOL_CODE = (0x03 << 8) | 0x01; ! internal const short SSL3_PROTOCOL_CODE = (0x03 << 8) | 0x00; #endregion *************** *** 104,111 **** } ! public SecurityProtocolType Protocol { ! get { return this.protocol; } ! set { this.protocol = value; } } --- 106,133 ---- } ! public SecurityProtocolType SecurityProtocol { ! get { return this.securityProtocol; } ! set { this.securityProtocol = value; } ! } ! ! public short Protocol ! { ! get ! { ! switch (this.securityProtocol) ! { ! case SecurityProtocolType.Tls: ! case SecurityProtocolType.Default: ! return TLS1_PROTOCOL_CODE; ! ! case SecurityProtocolType.Ssl3: ! return SSL3_PROTOCOL_CODE; ! ! case SecurityProtocolType.Ssl2: ! default: ! throw new NotSupportedException("Unsupported security protocol type"); ! } ! } } *************** *** 258,268 **** public TlsContext( ! SslClientStream sslStream, ! SecurityProtocolType securityProtocolType, ! string targetHost, ! X509CertificateCollection clientCertificates) { this.sslStream = sslStream; ! this.protocol = securityProtocolType; this.compressionMethod = SecurityCompressionType.None; this.serverSettings = new TlsServerSettings(); --- 280,290 ---- public TlsContext( ! SslClientStream sslStream, ! SecurityProtocolType securityProtocolType, ! string targetHost, ! X509CertificateCollection clientCertificates) { this.sslStream = sslStream; ! this.securityProtocol = securityProtocolType; this.compressionMethod = SecurityCompressionType.None; this.serverSettings = new TlsServerSettings(); *************** *** 318,322 **** // Clear MAC keys if protocol is different than Ssl3 ! if (this.protocol != SecurityProtocolType.Ssl3) { this.clientWriteMAC = null; --- 340,344 ---- // Clear MAC keys if protocol is different than Ssl3 ! if (this.securityProtocol != SecurityProtocolType.Ssl3) { this.clientWriteMAC = null; |