[pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handsha
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos Guzm?n ?l. <car...@us...> - 2004-03-17 16:43:05
|
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-serv15202 Modified Files: TlsClientCertificate.cs TlsServerKeyExchange.cs Log Message: 2004-03-17 Carlos Guzman Alvarez <car...@te...> * Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs: * Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs: - Initial implementation. Index: TlsClientCertificate.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsClientCertificate.cs 3 Mar 2004 16:15:42 -0000 1.3 --- TlsClientCertificate.cs 17 Mar 2004 16:33:36 -0000 1.4 *************** *** 31,34 **** --- 31,40 ---- internal class TlsClientCertificate : HandshakeMessage { + #region Fields + + private X509Certificate clientCertificate; + + #endregion + #region Constructors *************** *** 44,48 **** public override void Update() { ! throw new NotSupportedException(); } --- 50,54 ---- public override void Update() { ! this.Context.ClientSettings.Certificates.Add(clientCertificate); } *************** *** 58,62 **** protected override void ProcessAsTls1() { ! throw new NotSupportedException(); } --- 64,71 ---- protected override void ProcessAsTls1() { ! int length = this.ReadInt24(); ! this.clientCertificate = new X509Certificate(this.ReadBytes(length)); ! ! #warning "Is client certificate validation needed ??" } Index: TlsServerKeyExchange.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsServerKeyExchange.cs 3 Mar 2004 16:15:43 -0000 1.3 --- TlsServerKeyExchange.cs 17 Mar 2004 16:33:36 -0000 1.4 *************** *** 26,29 **** --- 26,31 ---- using System.Security.Cryptography; + using SX509 = System.Security.Cryptography.X509Certificates; + using Mono.Security.Cryptography; using Mono.Security.X509; *************** *** 60,64 **** protected override void ProcessAsTls1() { ! throw new NotSupportedException(); } --- 62,107 ---- protected override void ProcessAsTls1() { ! ServerContext context = (ServerContext)this.Context; ! ! // Select the private key information ! RSA rsa = (RSA)context.SslStream.PrivateKeyCertSelectionDelegate( ! new SX509.X509Certificate(context.ServerSettings.Certificates[0].RawData), ! null); ! ! RSAParameters rsaParams = rsa.ExportParameters(false); ! ! // Write Modulus ! this.WriteInt24(rsaParams.Modulus.Length); ! this.Write(rsaParams.Modulus, 0, rsaParams.Modulus.Length); ! ! // Write exponent ! this.WriteInt24(rsaParams.Exponent.Length); ! this.Write(rsaParams.Exponent, 0, rsaParams.Exponent.Length); ! ! // Write signed params ! byte[] signature = this.createSignature(rsa, this.ToArray()); ! this.WriteInt24(signature.Length); ! this.Write(signature); ! } ! ! #endregion ! ! #region Private Methods ! ! private byte[] createSignature(RSA rsa, byte[] buffer) ! { ! MD5SHA1 hash = new MD5SHA1(); ! ! // Create server params array ! TlsStream stream = new TlsStream(); ! ! stream.Write(this.Context.RandomCS); ! stream.Write(buffer, 0, buffer.Length); ! ! hash.ComputeHash(stream.ToArray()); ! ! stream.Reset(); ! ! return hash.CreateSignature(rsa); } |