[pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handsha
Status: Inactive
Brought to you by:
carlosga_fb
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19645 Modified Files: TlsClientFinished.cs TlsClientKeyExchange.cs TlsServerFinished.cs Log Message: 2004-03-09 Carlos Guzman Alvarez <car...@te...> * Mono.Security.Protocol.Tls/Ciphersuite.cs: - Added generation of the Server encryption algorithms. * Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs: - Finished processing of the message contents. * Mono.Security.Protocol.Tls/RecordProtocol.cs: * Mono.Security.Protocol.Tls/ClientRecordProtocol.cs: * Mono.Security.Protocol.Tls/ServerRecordProtocol.cs: - Added new ProcessChangeCipherSpec method. * Mono.Security.Protocol.Tls/Context.cs: - Added new PrintBuffer method ( for debug ). Index: TlsClientFinished.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsClientFinished.cs 4 Mar 2004 15:41:55 -0000 1.4 --- TlsClientFinished.cs 9 Mar 2004 20:01:41 -0000 1.5 *************** *** 41,53 **** #endregion - #region Methods - - public override void Update() - { - throw new NotSupportedException(); - } - - #endregion - #region Protected Methods --- 41,44 ---- *************** *** 73,76 **** --- 64,68 ---- throw new TlsException("Invalid ServerFinished message received."); } + for (int i = 0; i < clientHash.Length; i++) { *************** *** 92,96 **** (int)this.Context.HandshakeMessages.Length); ! byte[] serverPRF = this.Context.Cipher.PRF(this.Context.MasterSecret, "client finished", hash.Hash, 12); // Check client prf against server prf --- 84,89 ---- (int)this.Context.HandshakeMessages.Length); ! byte[] serverPRF = this.Context.Cipher.PRF( ! this.Context.MasterSecret, "client finished", hash.Hash, 12); // Check client prf against server prf *************** *** 99,102 **** --- 92,96 ---- throw new TlsException("Invalid ServerFinished message received."); } + for (int i = 0; i < serverPRF.Length; i++) { Index: TlsClientKeyExchange.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TlsClientKeyExchange.cs 5 Mar 2004 23:22:57 -0000 1.5 --- TlsClientKeyExchange.cs 9 Mar 2004 20:01:41 -0000 1.6 *************** *** 26,29 **** --- 26,30 ---- using System.IO; using System.Security.Cryptography; + using System.Security.Cryptography.X509Certificates; namespace Mono.Security.Protocol.Tls.Handshake.Server *************** *** 46,65 **** protected override void ProcessAsSsl3() { ! throw new NotSupportedException(); } protected override void ProcessAsTls1() { // Read client premaster secret byte[] clientSecret = this.ReadBytes(this.ReadInt16()); - // Create a new RSA key - RSA rsa = this.Context.Cipher.CertificateRSA(); - // Decrypt premaster secret RSAPKCS1KeyExchangeDeformatter deformatter = new RSAPKCS1KeyExchangeDeformatter(rsa); byte[] preMasterSecret = deformatter.DecryptKeyExchange(clientSecret); ! // Create master secret this.Context.Cipher.ComputeMasterSecret(preMasterSecret); --- 47,95 ---- protected override void ProcessAsSsl3() { ! ServerContext context = (ServerContext)this.Context; ! ! // Select the private key information ! RSA rsa = (RSA)context.SslStream.PrivateKeyCertSelectionDelegate( ! new X509Certificate(context.ServerSettings.Certificates[0].RawData), ! null); ! ! // Read client premaster secret ! byte[] clientSecret = this.ReadBytes((int)this.Length); ! ! // Decrypt premaster secret ! RSAPKCS1KeyExchangeDeformatter deformatter = new RSAPKCS1KeyExchangeDeformatter(rsa); ! ! byte[] preMasterSecret = deformatter.DecryptKeyExchange(clientSecret); ! ! // Create master secret ! this.Context.Cipher.ComputeMasterSecret(preMasterSecret); ! ! // Create keys ! this.Context.Cipher.ComputeKeys(); ! ! // Initialize Cipher Suite ! this.Context.Cipher.InitializeCipher(); ! ! // Clear resources ! rsa.Clear(); } protected override void ProcessAsTls1() { + ServerContext context = (ServerContext)this.Context; + + // Select the private key information + RSA rsa = (RSA)context.SslStream.PrivateKeyCertSelectionDelegate( + new X509Certificate(context.ServerSettings.Certificates[0].RawData), + null); + // Read client premaster secret byte[] clientSecret = this.ReadBytes(this.ReadInt16()); // Decrypt premaster secret RSAPKCS1KeyExchangeDeformatter deformatter = new RSAPKCS1KeyExchangeDeformatter(rsa); byte[] preMasterSecret = deformatter.DecryptKeyExchange(clientSecret); ! // Create master secret this.Context.Cipher.ComputeMasterSecret(preMasterSecret); *************** *** 68,71 **** --- 98,104 ---- this.Context.Cipher.ComputeKeys(); + // Initialize Cipher Suite + this.Context.Cipher.InitializeCipher(); + // Clear resources rsa.Clear(); Index: TlsServerFinished.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TlsServerFinished.cs 4 Mar 2004 15:41:55 -0000 1.4 --- TlsServerFinished.cs 9 Mar 2004 20:01:41 -0000 1.5 *************** *** 41,53 **** #endregion - #region Methods - - public override void Update() - { - throw new NotSupportedException(); - } - - #endregion - #region Protected Methods --- 41,44 ---- *************** *** 78,82 **** // Write message ! this.Write(this.Context.Cipher.PRF(this.Context.MasterSecret, "server finished", hash.Hash, 12)); } --- 69,74 ---- // Write message ! this.Write(this.Context.Cipher.PRF( ! this.Context.MasterSecret, "server finished", hash.Hash, 12)); } |