Thread: [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-03-05 23:36:22
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25946 Modified Files: CipherSuite.cs ClientRecordProtocol.cs Context.cs RecordProtocol.cs ServerContext.cs ServerRecordProtocol.cs SslServerStream.cs Log Message: Added implementation for some server side handshake messages Index: CipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/CipherSuite.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CipherSuite.cs 3 Mar 2004 16:22:36 -0000 1.6 --- CipherSuite.cs 5 Mar 2004 23:21:55 -0000 1.7 *************** *** 58,62 **** private byte ivSize; private byte blockSize; ! private Context context; private SymmetricAlgorithm encryptionAlgorithm; private ICryptoTransform encryptionCipher; --- 58,62 ---- private byte ivSize; private byte blockSize; ! private Context context; private SymmetricAlgorithm encryptionAlgorithm; private ICryptoTransform encryptionCipher; *************** *** 198,202 **** { get { return this.context; } ! set { this.context = value; } } --- 198,205 ---- { get { return this.context; } ! set ! { ! this.context = value; ! } } *************** *** 354,359 **** { TlsStream stream = new TlsStream(); ! ClientContext context = (ClientContext)this.Context; ! // Write protocol version // We need to send here the protocol version used in --- 357,362 ---- { TlsStream stream = new TlsStream(); ! ClientContext context = (ClientContext)this.context; ! // Write protocol version // We need to send here the protocol version used in Index: ClientRecordProtocol.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/ClientRecordProtocol.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ClientRecordProtocol.cs 3 Mar 2004 16:22:36 -0000 1.4 --- ClientRecordProtocol.cs 5 Mar 2004 23:21:55 -0000 1.5 *************** *** 79,82 **** --- 79,85 ---- message = this.createServerHandshakeMessage(handshakeType, data); + // Update the last handshake message + this.Context.LastHandshakeMsg = handshakeType; + // Update session if (message != null) Index: Context.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/Context.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Context.cs 3 Mar 2004 16:22:36 -0000 1.3 --- Context.cs 5 Mar 2004 23:21:55 -0000 1.4 *************** *** 211,215 **** { get { return this.cipher; } ! set { this.cipher = value; } } --- 211,219 ---- { get { return this.cipher; } ! set ! { ! this.cipher = value; ! this.cipher.Context = this; ! } } Index: RecordProtocol.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RecordProtocol.cs 3 Mar 2004 16:22:36 -0000 1.6 --- RecordProtocol.cs 5 Mar 2004 23:21:55 -0000 1.7 *************** *** 108,112 **** // Check that the message has a valid protocol version ! if (protocol != this.context.Protocol && this.context.ProtocolNegotiated) { throw this.context.CreateException("Invalid protocol version on message received from server"); --- 108,113 ---- // Check that the message has a valid protocol version ! if (protocol != this.context.Protocol && ! this.context.ProtocolNegotiated) { throw this.context.CreateException("Invalid protocol version on message received from server"); *************** *** 128,134 **** } byte[] result = message.ToArray(); - // Process record switch (contentType) { --- 129,138 ---- } + // Set last handshake message received to None + this.context.LastHandshakeMsg = HandshakeType.None; + + // Process record byte[] result = message.ToArray(); switch (contentType) { Index: ServerContext.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/ServerContext.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ServerContext.cs 23 Feb 2004 12:16:08 -0000 1.1 --- ServerContext.cs 5 Mar 2004 23:21:55 -0000 1.2 *************** *** 24,31 **** using System; - using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; namespace Mono.Security.Protocol.Tls { --- 24,32 ---- using System; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; + using MonoX509 = Mono.Security.X509; + namespace Mono.Security.Protocol.Tls { *************** *** 64,68 **** this.sslStream = stream; this.clientCertificateRequired = clientCertificateRequired; ! // this.ServerSettings.Certificates.Add(serverCertificate); } --- 65,75 ---- this.sslStream = stream; this.clientCertificateRequired = clientCertificateRequired; ! ! // Convert the System.Security cert to a Mono Cert ! MonoX509.X509Certificate cert = new MonoX509.X509Certificate(serverCertificate.GetRawCertData()); ! ! // Add server certificate to the certificate collection ! this.ServerSettings.Certificates = new MonoX509.X509CertificateCollection(); ! this.ServerSettings.Certificates.Add(cert); } Index: ServerRecordProtocol.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/ServerRecordProtocol.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ServerRecordProtocol.cs 3 Mar 2004 16:22:36 -0000 1.2 --- ServerRecordProtocol.cs 5 Mar 2004 23:21:55 -0000 1.3 *************** *** 79,82 **** --- 79,85 ---- message = this.createClientHandshakeMessage(handshakeType, data); + // Update the last handshake message + this.Context.LastHandshakeMsg = handshakeType; + // Update session if (message != null) Index: SslServerStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/SslServerStream.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SslServerStream.cs 3 Mar 2004 16:22:36 -0000 1.5 --- SslServerStream.cs 5 Mar 2004 23:21:55 -0000 1.6 *************** *** 639,642 **** --- 639,648 ---- try { + // Reset the context if needed + if (this.context.HandshakeState != HandshakeState.None) + { + this.context.Clear(); + } + // Obtain supported cipher suites this.context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(this.context.SecurityProtocol); *************** *** 662,669 **** // If the negotiated cipher is a KeyEx cipher send ServerKeyExchange - // and Certificate request messages if (this.context.Cipher.ExchangeAlgorithmType == ExchangeAlgorithmType.RsaKeyX) { this.protocol.SendRecord(HandshakeType.ServerKeyExchange); this.protocol.SendRecord(HandshakeType.CertificateRequest); } --- 668,682 ---- // If the negotiated cipher is a KeyEx cipher send ServerKeyExchange if (this.context.Cipher.ExchangeAlgorithmType == ExchangeAlgorithmType.RsaKeyX) { this.protocol.SendRecord(HandshakeType.ServerKeyExchange); + + } + + // If the negotiated cipher is a KeyEx cipher or + // the client certificate is required send the CertificateRequest message + if (this.context.Cipher.ExchangeAlgorithmType == ExchangeAlgorithmType.RsaKeyX || + this.context.ClientCertificateRequired) + { this.protocol.SendRecord(HandshakeType.CertificateRequest); } |