[pgsqlclient-checkins] pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Sec
Status: Inactive
Brought to you by:
carlosga_fb
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-serv25125 Modified Files: TlsClientCertificate.cs TlsClientFinished.cs TlsClientHello.cs TlsClientKeyExchange.cs TlsServerCertificate.cs TlsServerCertificateRequest.cs TlsServerFinished.cs TlsServerHello.cs TlsServerKeyExchange.cs Log Message: Added partial implementation of SSL3 protocol Index: TlsClientCertificate.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/TlsClientCertificate.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsClientCertificate.cs 16 Oct 2003 14:25:57 -0000 1.4 --- TlsClientCertificate.cs 22 Oct 2003 11:48:08 -0000 1.5 *************** *** 70,75 **** // Compose the message ! WriteInt24((int)stream.Length); ! Write(stream.ToArray()); } --- 70,75 ---- // Compose the message ! this.WriteInt24((int)stream.Length); ! this.Write(stream.ToArray()); } 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.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsClientFinished.cs 21 Oct 2003 20:06:28 -0000 1.6 --- TlsClientFinished.cs 22 Oct 2003 11:48:08 -0000 1.7 *************** *** 66,97 **** 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(); } --- 66,89 ---- block.Write(cipher.Pad1); byte[] blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); + block.Reset(); + block.Write(this.Session.Context.MasterSecret); block.Write(cipher.Pad2); block.Write(blockHash); ! blockHash = hash.ComputeHash(block.ToArray(), 0, (int)block.Length); block.Reset(); ! return blockHash; } protected override void ProcessAsSsl3() { ! this.Write(computeSslHash("MD5", Session.Context.HandshakeHashes.Messages, 0x434C4E54)); ! this.Write(computeSslHash("SHA1", Session.Context.HandshakeHashes.Messages, 0x434C4E54)); 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.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TlsClientHello.cs 21 Oct 2003 20:06:28 -0000 1.8 --- TlsClientHello.cs 22 Oct 2003 11:48:08 -0000 1.9 *************** *** 68,72 **** { // Client Version ! Write((short)this.Session.Context.Protocol); // Random bytes - Unix time + Radom bytes [28] --- 68,72 ---- { // Client Version ! this.Write((short)this.Session.Context.Protocol); // Random bytes - Unix time + Radom bytes [28] *************** *** 77,81 **** clientRandom.Reset(); ! Write(this.random); // Session id --- 77,81 ---- clientRandom.Reset(); ! this.Write(this.random); // Session id *************** *** 83,111 **** if (this.Session.SessionId != null) { ! Write((byte)this.Session.SessionId.Length); if (this.Session.SessionId.Length > 0) { ! Write(this.Session.SessionId); } } else { ! Write((byte)0); } // 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); } // Compression methods length ! Write((byte)1); // Compression methods ( 0 = none ) ! Write((byte)TlsCompressionMethod.None); } --- 83,111 ---- if (this.Session.SessionId != null) { ! this.Write((byte)this.Session.SessionId.Length); if (this.Session.SessionId.Length > 0) { ! this.Write(this.Session.SessionId); } } else { ! this.Write((byte)0); } // Write length of Cipher suites ! this.Write((short)(this.Session.Context.SupportedCiphers.Count*2)); // Write Supported Cipher suites for (int i = 0; i < this.Session.Context.SupportedCiphers.Count; i++) { ! this.Write((short)this.Session.Context.SupportedCiphers[i].Code); } // Compression methods length ! this.Write((byte)1); // Compression methods ( 0 = none ) ! this.Write((byte)this.Session.Context.CompressionMethod); } 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.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsClientKeyExchange.cs 21 Oct 2003 23:07:37 -0000 1.6 --- TlsClientKeyExchange.cs 22 Oct 2003 11:48:08 -0000 1.7 *************** *** 47,61 **** { // 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]); } --- 47,61 ---- { // Compute pre master secret ! byte[] preMasterSecret = this.Session.Context.Cipher.CreatePremasterSecret(); // Create a new RSA key RSACryptoServiceProvider rsa = null; ! if (this.Session.Context.ServerSettings.ServerKeyExchange) { ! rsa = this.Session.Context.Cipher.CreateRSA(this.Session.Context.ServerSettings.RsaParameters); } else { ! rsa = this.Session.Context.Cipher.CreateRSA(this.Session.Context.ServerSettings.ServerCertificates[0]); } *************** *** 65,75 **** // 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 --- 65,75 ---- // Write the preMasterSecret encrypted byte[] buffer = formatter.CreateKeyExchange(preMasterSecret); ! this.Write(buffer); // Create master secret ! this.Session.Context.Cipher.CreateMasterSecret(preMasterSecret); // Create keys ! this.Session.Context.Cipher.CreateKeys(); // Clear resources *************** *** 80,94 **** { // 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]); } --- 80,94 ---- { // Compute pre master secret ! byte[] preMasterSecret = this.Session.Context.Cipher.CreatePremasterSecret(); // Create a new RSA key RSACryptoServiceProvider rsa = null; ! if (this.Session.Context.ServerSettings.ServerKeyExchange) { ! rsa = this.Session.Context.Cipher.CreateRSA(this.Session.Context.ServerSettings.RsaParameters); } else { ! rsa = this.Session.Context.Cipher.CreateRSA(this.Session.Context.ServerSettings.ServerCertificates[0]); } *************** *** 98,109 **** // Write the preMasterSecret encrypted byte[] buffer = formatter.CreateKeyExchange(preMasterSecret); ! Write((short)buffer.Length); ! Write(buffer); // Create master secret ! Session.Context.Cipher.CreateMasterSecret(preMasterSecret); // Create keys ! Session.Context.Cipher.CreateKeys(); // Clear resources --- 98,109 ---- // Write the preMasterSecret encrypted byte[] buffer = formatter.CreateKeyExchange(preMasterSecret); ! this.Write((short)buffer.Length); ! this.Write(buffer); // Create master secret ! this.Session.Context.Cipher.CreateMasterSecret(preMasterSecret); // Create keys ! this.Session.Context.Cipher.CreateKeys(); // Clear resources 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.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsServerCertificate.cs 21 Oct 2003 16:06:15 -0000 1.5 --- TlsServerCertificate.cs 22 Oct 2003 11:48:08 -0000 1.6 *************** *** 79,83 **** int readed = 0; ! int length = ReadInt24(); while (readed < length) --- 79,83 ---- int readed = 0; ! int length = this.ReadInt24(); while (readed < length) *************** *** 92,101 **** { // Read certificate ! X509Certificate certificate = new X509Certificate(ReadBytes(certLength)); certificates.Add(certificate); readed += certLength; ! validateCertificate(certificate); } } --- 92,101 ---- { // Read certificate ! X509Certificate certificate = new X509Certificate(this.ReadBytes(certLength)); certificates.Add(certificate); readed += certLength; ! this.validateCertificate(certificate); } } Index: TlsServerCertificateRequest.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/TlsServerCertificateRequest.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsServerCertificateRequest.cs 16 Oct 2003 14:25:57 -0000 1.4 --- TlsServerCertificateRequest.cs 22 Oct 2003 11:48:08 -0000 1.5 *************** *** 53,59 **** base.UpdateSession(); ! Session.Context.ServerSettings.CertificateTypes = this.certificateTypes; ! Session.Context.ServerSettings.DistinguisedNames = this.distinguisedNames; ! Session.Context.ServerSettings.CertificateRequest = true; } --- 53,59 ---- base.UpdateSession(); ! this.Session.Context.ServerSettings.CertificateTypes = this.certificateTypes; ! this.Session.Context.ServerSettings.DistinguisedNames = this.distinguisedNames; ! this.Session.Context.ServerSettings.CertificateRequest = true; } *************** *** 70,74 **** { // Read requested certificate types ! int typesCount = ReadByte(); certificateTypes = new TlsClientCertificateType[typesCount]; --- 70,74 ---- { // Read requested certificate types ! int typesCount = this.ReadByte(); certificateTypes = new TlsClientCertificateType[typesCount]; *************** *** 76,80 **** for (int i = 0; i < typesCount; i++) { ! certificateTypes[i] = (TlsClientCertificateType)ReadByte(); } --- 76,80 ---- for (int i = 0; i < typesCount; i++) { ! certificateTypes[i] = (TlsClientCertificateType)this.ReadByte(); } *************** *** 90,95 **** * attributeValue ANY } */ ! int tmp = ReadInt16(); ! ASN1 rdn = new ASN1(ReadBytes(ReadInt16())); distinguisedNames = new string[rdn.Count]; --- 90,95 ---- * attributeValue ANY } */ ! int tmp = this.ReadInt16(); ! ASN1 rdn = new ASN1(this.ReadBytes(this.ReadInt16())); distinguisedNames = new string[rdn.Count]; 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.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsServerFinished.cs 21 Oct 2003 20:06:28 -0000 1.7 --- TlsServerFinished.cs 22 Oct 2003 11:48:08 -0000 1.8 *************** *** 59,69 **** protected override void ProcessAsTls1() { ! byte[] serverPRF = ReadBytes((int)Length); TlsStream hashes = new TlsStream(); ! hashes.Write(Session.Context.HandshakeHashes.GetMD5Hash()); ! hashes.Write(Session.Context.HandshakeHashes.GetSHAHash()); ! byte[] clientPRF = Session.Context.Cipher.PRF(Session.Context.MasterSecret, "server finished", hashes.ToArray(), 12); hashes.Reset(); --- 59,69 ---- protected override void ProcessAsTls1() { ! byte[] serverPRF = this.ReadBytes((int)Length); TlsStream hashes = new TlsStream(); ! hashes.Write(this.Session.Context.HandshakeHashes.GetMD5Hash()); ! hashes.Write(this.Session.Context.HandshakeHashes.GetSHAHash()); ! byte[] clientPRF = this.Session.Context.Cipher.PRF(this.Session.Context.MasterSecret, "server finished", hashes.ToArray(), 12); hashes.Reset(); *************** *** 82,86 **** } ! Session.Context.HandshakeHashes.Clear(); } --- 82,86 ---- } ! this.Session.Context.HandshakeHashes.Clear(); } 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.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TlsServerHello.cs 21 Oct 2003 20:06:28 -0000 1.9 --- TlsServerHello.cs 22 Oct 2003 11:48:08 -0000 1.10 *************** *** 55,63 **** 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; this.Session.Context.Cipher = this.cipherSuite; --- 55,58 ---- Index: TlsServerKeyExchange.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/TlsServerKeyExchange.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsServerKeyExchange.cs 16 Oct 2003 14:25:57 -0000 1.5 --- TlsServerKeyExchange.cs 22 Oct 2003 11:48:08 -0000 1.6 *************** *** 70,86 **** protected override void ProcessAsTls1() { ! rsaParams = new RSAParameters(); // Read modulus ! short length = ReadInt16(); ! rsaParams.Modulus = ReadBytes(length); // Read exponent ! length = ReadInt16(); ! rsaParams.Exponent = ReadBytes(length); // Read signed params ! length = ReadInt16(); ! signedParams = ReadBytes(length); } --- 70,86 ---- protected override void ProcessAsTls1() { ! this.rsaParams = new RSAParameters(); // Read modulus ! short length = this.ReadInt16(); ! rsaParams.Modulus = this.ReadBytes(length); // Read exponent ! length = this.ReadInt16(); ! rsaParams.Exponent = this.ReadBytes(length); // Read signed params ! length = this.ReadInt16(); ! signedParams = this.ReadBytes(length); } *************** *** 97,102 **** TlsStream stream = new TlsStream(); ! stream.Write(Session.Context.ClientRandom); ! stream.Write(Session.Context.ServerRandom); stream.Write(rsaParams.Modulus.Length); stream.Write(rsaParams.Modulus); --- 97,101 ---- TlsStream stream = new TlsStream(); ! stream.Write(this.Session.Context.RandomCS); stream.Write(rsaParams.Modulus.Length); stream.Write(rsaParams.Modulus); |