Thread: [pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls CipherS
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos G. Á. <car...@us...> - 2004-11-17 13:50:35
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17721 Modified Files: CipherSuiteFactory.cs RecordProtocol.cs Log Message: 2004-11-17 Carlos Guzman Alvarez <car...@te...> * Add a fix for the ClientHelloV2 message (Thanks to Sebastien Pouliot) Index: CipherSuiteFactory.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteFactory.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CipherSuiteFactory.cs 18 Mar 2004 14:06:31 -0000 1.2 --- CipherSuiteFactory.cs 17 Nov 2004 13:50:21 -0000 1.3 *************** *** 132,137 **** // Supported ciphers ! scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); ! scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8); --- 132,138 ---- // Supported ciphers ! scs.Add((0x00 << 0x08) | 0x35, "SSL_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 32, 32, 256, 16, 16); ! scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); ! scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8); Index: RecordProtocol.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** RecordProtocol.cs 24 Sep 2004 21:33:34 -0000 1.20 --- RecordProtocol.cs 17 Nov 2004 13:50:23 -0000 1.21 *************** *** 140,165 **** default: ! return null; ! } return result; } - private byte[] ReadRecordBuffer(int contentType) - { - switch (contentType) - { - case 0x80: - return this.ReadClientHelloV2(); - - default: - if (!Enum.IsDefined(typeof(ContentType), (ContentType)contentType)) - { - throw new TlsException(AlertDescription.DecodeError); - } - return this.ReadStandardRecordBuffer(); - } - } - private short ReadShort() { --- 140,151 ---- default: ! throw new TlsException( ! AlertDescription.UnexpectedMessage, ! "Unknown record received from server."); ! } return result; } private short ReadShort() { *************** *** 195,198 **** --- 181,200 ---- #region Record Buffer read + private byte[] ReadRecordBuffer(int contentType) + { + switch (contentType) + { + case 0x80: + return this.ReadClientHelloV2(); + + default: + if (!Enum.IsDefined(typeof(ContentType), (ContentType)contentType)) + { + throw new TlsException(AlertDescription.DecodeError); + } + return this.ReadStandardRecordBuffer(); + } + } + private byte[] ReadClientHelloV2() { *************** *** 200,210 **** // Read the message contents ! byte[] tmp = new byte[msgLength]; ! this.innerStream.Read(tmp, 0, tmp.Length); ! // Add them to a TlsStream ! TlsStream stream = new TlsStream(tmp); ! ! int msgType = stream.ReadByte(); if (msgType != 1) { --- 202,212 ---- // Read the message contents ! byte[] message = new byte[msgLength]; ! this.innerStream.Read(message, 0, message.Length); ! // Add them to a TlsStream ! TlsStream stream = new TlsStream(message); ! ! int msgType = stream.ReadByte(); if (msgType != 1) { *************** *** 245,258 **** // Updated the Client Random ! this.context.ClientRandom = new byte[32]; ! Buffer.BlockCopy(challenge, 0, this.context.ClientRandom, 0, length); ! // Update the Handshake Hashes ! this.Context.HandshakeMessages.Write(tmp); ! // Updated the LastHandshake message this.context.LastHandshakeMsg = HandshakeType.ClientHello; ! return new byte[0]; } --- 247,262 ---- // Updated the Client Random ! this.context.ClientRandom = new byte[32]; ! Buffer.BlockCopy(challenge, challenge.Length - length, this.context.ClientRandom, 32 - length, length); ! // Update the Handshake Hashes ! this.Context.HandshakeMessages.Write(new byte[] { 0x80 }); ! this.Context.HandshakeMessages.Write(message); ! // Updated the LastHandshake message this.context.LastHandshakeMsg = HandshakeType.ClientHello; + this.context.ProtocolNegotiated = true; ! return new byte[0]; } |