[pgsqlclient-checkins] pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Sec
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-11-03 08:53:23
|
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-serv17711/Mono.Security.Protocol.Tls.Handshake.Client Modified Files: TlsClientCertificateVerify.cs TlsClientFinished.cs TlsServerFinished.cs TlsServerKeyExchange.cs Log Message: 2003-11-03 Carlos Guzmán Álvarez <car...@te...> * TlsHandshakeMessages.cs: - Removed file. * Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs: - New class for md5-sha hash calculation. * Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs: * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs: * Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs: * Mono.Security.Protocol.Tls.Handshake.Client/TlsHandshakeMessage.cs: - Make use of new MD5SHA1CryptoServiceProvider class. * TlsSessionContext.cs: - Changed handshakeHashes member to be an TlsStream. Index: TlsClientCertificateVerify.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/TlsClientCertificateVerify.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsClientCertificateVerify.cs 28 Oct 2003 16:12:30 -0000 1.3 --- TlsClientCertificateVerify.cs 3 Nov 2003 08:53:20 -0000 1.4 *************** *** 53,62 **** protected override void ProcessAsSsl3() { ! this.ProcessAsTls1(); } protected override void ProcessAsTls1() { - #warning "Process message here" throw new NotSupportedException(); } --- 53,61 ---- protected override void ProcessAsSsl3() { ! throw new NotSupportedException(); } protected override void ProcessAsTls1() { throw new NotSupportedException(); } 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.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsClientFinished.cs 22 Oct 2003 11:48:08 -0000 1.7 --- TlsClientFinished.cs 3 Nov 2003 08:53:20 -0000 1.8 *************** *** 26,29 **** --- 26,31 ---- using System.Security.Cryptography; + using Mono.Security.Cryptography; + namespace Mono.Security.Protocol.Tls.Handshake.Client { *************** *** 83,106 **** 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(); } protected override void ProcessAsTls1() { ! // Get hashes of handshake messages ! TlsStream hashes = new TlsStream(); ! ! hashes.Write(Session.Context.HandshakeHashes.GetMD5Hash()); ! hashes.Write(Session.Context.HandshakeHashes.GetSHAHash()); // Write message contents ! Write(Session.Context.Cipher.PRF(Session.Context.MasterSecret, "client finished", hashes.ToArray(), 12)); ! ! // Reset data ! hashes.Reset(); ! Session.Context.HandshakeHashes.Reset(); } --- 85,102 ---- protected override void ProcessAsSsl3() { ! this.Write(computeSslHash("MD5", Session.Context.HandshakeHashes.ToArray(), 0x434C4E54)); ! this.Write(computeSslHash("SHA1", Session.Context.HandshakeHashes.ToArray(), 0x434C4E54)); } protected override void ProcessAsTls1() { ! HashAlgorithm hash = new MD5SHA1CryptoServiceProvider(); ! hash.ComputeHash( ! Session.Context.HandshakeHashes.ToArray(), ! 0, ! (int)Session.Context.HandshakeHashes.Length); // Write message contents ! Write(Session.Context.Cipher.PRF(Session.Context.MasterSecret, "client finished", hash.Hash, 12)); } 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.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TlsServerFinished.cs 22 Oct 2003 11:48:08 -0000 1.8 --- TlsServerFinished.cs 3 Nov 2003 08:53:20 -0000 1.9 *************** *** 26,29 **** --- 26,31 ---- using System.Security.Cryptography; + using Mono.Security.Cryptography; + namespace Mono.Security.Protocol.Tls.Handshake.Client { *************** *** 59,71 **** 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(); // Check server prf against client prf --- 61,73 ---- protected override void ProcessAsTls1() { ! byte[] serverPRF = this.ReadBytes((int)Length); ! HashAlgorithm hash = new MD5SHA1CryptoServiceProvider(); ! hash.ComputeHash( ! Session.Context.HandshakeHashes.ToArray(), ! 0, ! (int)Session.Context.HandshakeHashes.Length); ! byte[] clientPRF = this.Session.Context.Cipher.PRF(this.Session.Context.MasterSecret, "server finished", hash.Hash, 12); // Check server prf against client prf *************** *** 82,86 **** } ! this.Session.Context.HandshakeHashes.Clear(); } --- 84,89 ---- } ! // Reset Hahdshake messages information ! this.Session.Context.HandshakeHashes.Reset(); } 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.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsServerKeyExchange.cs 28 Oct 2003 16:12:30 -0000 1.7 --- TlsServerKeyExchange.cs 3 Nov 2003 08:53:20 -0000 1.8 *************** *** 26,29 **** --- 26,30 ---- using System.Security.Cryptography; + using Mono.Security.Cryptography; using Mono.Security.X509; *************** *** 92,97 **** private void verify() { ! HashAlgorithm md5 = new MD5CryptoServiceProvider(); ! HashAlgorithm sha = new SHA1CryptoServiceProvider(); // Create server params array --- 93,97 ---- private void verify() { ! HashAlgorithm hash = new MD5SHA1CryptoServiceProvider(); // Create server params array *************** *** 103,114 **** stream.Write(rsaParams.Exponent.Length); stream.Write(rsaParams.Exponent); - byte[] serverParams = stream.ToArray(); - stream.Reset(); ! // Compute md5 and sha hashes ! TlsStream hash = new TlsStream(); ! hash.Write(md5.ComputeHash(serverParams, 0, serverParams.Length)); ! hash.Write(sha.ComputeHash(serverParams, 0, serverParams.Length)); // Calculate signature --- 103,110 ---- stream.Write(rsaParams.Exponent.Length); stream.Write(rsaParams.Exponent); ! hash.ComputeHash(stream.ToArray()); ! stream.Reset(); // Calculate signature *************** *** 118,122 **** // Verify Signature X509Certificate certificate = this.Session.Context.ServerSettings.ServerCertificates[0]; ! certificate.CheckSignature(hash.ToArray(), "SHA1", this.signedParams); } --- 114,118 ---- // Verify Signature X509Certificate certificate = this.Session.Context.ServerSettings.ServerCertificates[0]; ! certificate.CheckSignature(hash.Hash, "SHA1", this.signedParams); } |