[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-serv17834
Modified Files:
TlsClientCertificate.cs TlsClientCertificateVerify.cs
TlsClientFinished.cs TlsClientHello.cs TlsClientKeyExchange.cs
TlsServerCertificate.cs TlsServerCertificateRequest.cs
TlsServerFinished.cs TlsServerHello.cs TlsServerHelloDone.cs
TlsServerKeyExchange.cs
Log Message:
2003-11-13 Carlos Guzmán Álvarez <car...@te...>
* Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
The next files are no more needed:
- TlsSession.cs
- TlsNetworkStream.cs
- TlsSocket.cs
- TlsSessionState.cs
The next files are renamed:
- TlsSessionSettings.cs -> TlsClientSettings.cs
- TlsSessionContext.cs -> TlsContext.cs
The next files are new:
- SslClientStream.cs ( the name is non definitive yet )
The next files where changed to reflect the new canges:
- TlsHandshakeMessage.cs
- TlsClientCertificate.cs
- TlsClientCertificateVerify.cs
- TlsClientFinished.cs
- TlsClientHello.cs
- TlsClientKeyExchange.cs
- TlsServerCertificate.cs
- TlsServerCertificateRequest.cs
- TlsServerFinished.cs
- TlsServerHello.cs
- TlsServerHelloDone.cs
- TlsServerKeyExchange.cs
- TlsAlert.cs
- TlsCloseNotifyAlert.cs
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.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** TlsClientCertificate.cs 3 Nov 2003 16:21:25 -0000 1.9
--- TlsClientCertificate.cs 14 Nov 2003 13:42:54 -0000 1.10
***************
*** 33,38 ****
#region CONSTRUCTORS
! public TlsClientCertificate(TlsSession session)
! : base(session, TlsHandshakeType.Certificate, TlsContentType.Handshake)
{
}
--- 33,38 ----
#region CONSTRUCTORS
! public TlsClientCertificate(TlsContext context)
! : base(context, TlsHandshakeType.Certificate, TlsContentType.Handshake)
{
}
***************
*** 59,71 ****
protected override void ProcessAsTls1()
{
! if (Session.Settings.Certificates == null ||
! Session.Settings.Certificates.Count == 0)
{
! throw this.Session.CreateException("Client certificate requested by the server and no client certificate specified.");
}
// Write client certificates information to a stream
TlsStream stream = new TlsStream();
! foreach (X509Certificate cert in Session.Settings.Certificates)
{
stream.WriteInt24(cert.GetRawCertData().Length);
--- 59,71 ----
protected override void ProcessAsTls1()
{
! if (this.Context.ClientSettings.Certificates == null ||
! this.Context.ClientSettings.Certificates.Count == 0)
{
! throw this.Context.CreateException("Client certificate requested by the server and no client certificate specified.");
}
// Write client certificates information to a stream
TlsStream stream = new TlsStream();
! foreach (X509Certificate cert in this.Context.ClientSettings.Certificates)
{
stream.WriteInt24(cert.GetRawCertData().Length);
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.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** TlsClientCertificateVerify.cs 13 Nov 2003 09:23:50 -0000 1.11
--- TlsClientCertificateVerify.cs 14 Nov 2003 13:42:54 -0000 1.12
***************
*** 35,40 ****
#region CONSTRUCTORS
! public TlsClientCertificateVerify(TlsSession session)
! : base(session, TlsHandshakeType.Finished, TlsContentType.Handshake)
{
}
--- 35,40 ----
#region CONSTRUCTORS
! public TlsClientCertificateVerify(TlsContext context)
! : base(context, TlsHandshakeType.Finished, TlsContentType.Handshake)
{
}
***************
*** 61,65 ****
protected override void ProcessAsTls1()
{
! foreach (X509Certificate cert in Session.Settings.Certificates)
{
MD5SHA1 hash = new MD5SHA1();
--- 61,65 ----
protected override void ProcessAsTls1()
{
! foreach (X509Certificate cert in this.Context.ClientSettings.Certificates)
{
MD5SHA1 hash = new MD5SHA1();
***************
*** 69,73 ****
TlsStream data = new TlsStream();
! data.Write(this.Session.Context.RandomCS);
data.Write((short)p.Modulus.Length);
data.Write(p.Modulus);
--- 69,73 ----
TlsStream data = new TlsStream();
! data.Write(this.Context.RandomCS);
data.Write((short)p.Modulus.Length);
data.Write(p.Modulus);
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.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** TlsClientFinished.cs 13 Nov 2003 09:23:50 -0000 1.11
--- TlsClientFinished.cs 14 Nov 2003 13:42:54 -0000 1.12
***************
*** 34,39 ****
#region CONSTRUCTORS
! public TlsClientFinished(TlsSession session)
! : base(session, TlsHandshakeType.Finished, TlsContentType.Handshake)
{
}
--- 34,39 ----
#region CONSTRUCTORS
! public TlsClientFinished(TlsContext context)
! : base(context, TlsHandshakeType.Finished, TlsContentType.Handshake)
{
}
***************
*** 56,63 ****
{
// Compute handshake messages hashes
! HashAlgorithm hash = new TlsSslHandshakeHash(this.Session.Context.MasterSecret);
TlsStream data = new TlsStream();
! data.Write(this.Session.Context.HandshakeMessages.ToArray());
data.Write((int)0x434C4E54);
--- 56,63 ----
{
// Compute handshake messages hashes
! HashAlgorithm hash = new TlsSslHandshakeHash(this.Context.MasterSecret);
TlsStream data = new TlsStream();
! data.Write(this.Context.HandshakeMessages.ToArray());
data.Write((int)0x434C4E54);
***************
*** 74,83 ****
HashAlgorithm hash = new MD5SHA1();
hash.ComputeHash(
! Session.Context.HandshakeMessages.ToArray(),
0,
! (int)Session.Context.HandshakeMessages.Length);
// Write message
! Write(Session.Context.Cipher.PRF(Session.Context.MasterSecret, "client finished", hash.Hash, 12));
}
--- 74,83 ----
HashAlgorithm hash = new MD5SHA1();
hash.ComputeHash(
! this.Context.HandshakeMessages.ToArray(),
0,
! (int)this.Context.HandshakeMessages.Length);
// Write message
! Write(this.Context.Cipher.PRF(this.Context.MasterSecret, "client finished", hash.Hash, 12));
}
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.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** TlsClientHello.cs 22 Oct 2003 11:48:08 -0000 1.9
--- TlsClientHello.cs 14 Nov 2003 13:42:54 -0000 1.10
***************
*** 38,43 ****
#region CONSTRUCTORS
! public TlsClientHello(TlsSession session)
! : base(session, TlsHandshakeType.ClientHello, TlsContentType.Handshake)
{
}
--- 38,43 ----
#region CONSTRUCTORS
! public TlsClientHello(TlsContext context)
! : base(context, TlsHandshakeType.ClientHello, TlsContentType.Handshake)
{
}
***************
*** 51,55 ****
base.UpdateSession();
! Session.Context.ClientRandom = random;
random = null;
--- 51,55 ----
base.UpdateSession();
! this.Context.ClientRandom = random;
random = null;
***************
*** 68,77 ****
{
// Client Version
! this.Write((short)this.Session.Context.Protocol);
// Random bytes - Unix time + Radom bytes [28]
TlsStream clientRandom = new TlsStream();
! clientRandom.Write(this.Session.Context.GetUnixTime());
! clientRandom.Write(this.Session.Context.GetSecureRandomBytes(28));
this.random = clientRandom.ToArray();
clientRandom.Reset();
--- 68,77 ----
{
// Client Version
! this.Write((short)this.Context.Protocol);
// Random bytes - Unix time + Radom bytes [28]
TlsStream clientRandom = new TlsStream();
! clientRandom.Write(this.Context.GetUnixTime());
! clientRandom.Write(this.Context.GetSecureRandomBytes(28));
this.random = clientRandom.ToArray();
clientRandom.Reset();
***************
*** 81,90 ****
// Session id
// Send the session ID empty
! if (this.Session.SessionId != null)
{
! this.Write((byte)this.Session.SessionId.Length);
! if (this.Session.SessionId.Length > 0)
{
! this.Write(this.Session.SessionId);
}
}
--- 81,90 ----
// Session id
// Send the session ID empty
! if (this.Context.SessionId != null)
{
! this.Write((byte)this.Context.SessionId.Length);
! if (this.Context.SessionId.Length > 0)
{
! this.Write(this.Context.SessionId);
}
}
***************
*** 95,104 ****
// 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);
}
--- 95,104 ----
// Write length of Cipher suites
! this.Write((short)(this.Context.SupportedCiphers.Count*2));
// Write Supported Cipher suites
! for (int i = 0; i < this.Context.SupportedCiphers.Count; i++)
{
! this.Write((short)this.Context.SupportedCiphers[i].Code);
}
***************
*** 107,111 ****
// Compression methods ( 0 = none )
! this.Write((byte)this.Session.Context.CompressionMethod);
}
--- 107,111 ----
// Compression methods ( 0 = none )
! this.Write((byte)this.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.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** TlsClientKeyExchange.cs 28 Oct 2003 16:12:30 -0000 1.9
--- TlsClientKeyExchange.cs 14 Nov 2003 13:42:54 -0000 1.10
***************
*** 33,38 ****
#region CONSTRUCTORS
! public TlsClientKeyExchange (TlsSession session) :
! base(session,
TlsHandshakeType.ClientKeyExchange,
TlsContentType.Handshake)
--- 33,38 ----
#region CONSTRUCTORS
! public TlsClientKeyExchange (TlsContext context) :
! base(context,
TlsHandshakeType.ClientKeyExchange,
TlsContentType.Handshake)
***************
*** 47,54 ****
{
// Compute pre master secret
! byte[] preMasterSecret = this.Session.Context.Cipher.CreatePremasterSecret();
// Create a new RSA key
! RSA rsa = this.Session.Context.Cipher.CreateRSA();
// Encrypt premaster_sercret
--- 47,54 ----
{
// Compute pre master secret
! byte[] preMasterSecret = this.Context.Cipher.CreatePremasterSecret();
// Create a new RSA key
! RSA rsa = this.Context.Cipher.CreateRSA();
// Encrypt premaster_sercret
***************
*** 60,67 ****
// Create master secret
! this.Session.Context.Cipher.ComputeMasterSecret(preMasterSecret);
// Create keys
! this.Session.Context.Cipher.ComputeKeys();
// Clear resources
--- 60,67 ----
// Create master secret
! this.Context.Cipher.ComputeMasterSecret(preMasterSecret);
// Create keys
! this.Context.Cipher.ComputeKeys();
// Clear resources
***************
*** 72,79 ****
{
// Compute pre master secret
! byte[] preMasterSecret = this.Session.Context.Cipher.CreatePremasterSecret();
// Create a new RSA key
! RSA rsa = this.Session.Context.Cipher.CreateRSA();
// Encrypt premaster_sercret
--- 72,79 ----
{
// Compute pre master secret
! byte[] preMasterSecret = this.Context.Cipher.CreatePremasterSecret();
// Create a new RSA key
! RSA rsa = this.Context.Cipher.CreateRSA();
// Encrypt premaster_sercret
***************
*** 86,93 ****
// Create master secret
! this.Session.Context.Cipher.ComputeMasterSecret(preMasterSecret);
// Create keys
! this.Session.Context.Cipher.ComputeKeys();
// Clear resources
--- 86,93 ----
// Create master secret
! this.Context.Cipher.ComputeMasterSecret(preMasterSecret);
// Create keys
! this.Context.Cipher.ComputeKeys();
// 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.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** TlsServerCertificate.cs 13 Nov 2003 09:23:50 -0000 1.10
--- TlsServerCertificate.cs 14 Nov 2003 13:42:54 -0000 1.11
***************
*** 24,28 ****
--- 24,31 ----
using System;
+ using System.Collections;
+ using System.Text.RegularExpressions;
using System.Security.Cryptography;
+ using X509Cert = System.Security.Cryptography.X509Certificates;
using Mono.Security.Protocol.Tls.Alerts;
***************
*** 35,39 ****
#region FIELDS
! private X509CertificateCollection certificates;
#endregion
--- 38,42 ----
#region FIELDS
! private X509CertificateCollection certificates;
#endregion
***************
*** 41,46 ****
#region CONSTRUCTORS
! public TlsServerCertificate(TlsSession session, byte[] buffer)
! : base(session, TlsHandshakeType.Certificate, buffer)
{
}
--- 44,49 ----
#region CONSTRUCTORS
! public TlsServerCertificate(TlsContext context, byte[] buffer)
! : base(context, TlsHandshakeType.Certificate, buffer)
{
}
***************
*** 53,57 ****
{
base.UpdateSession();
! this.Session.Context.ServerSettings.Certificates = certificates;
}
--- 56,60 ----
{
base.UpdateSession();
! this.Context.ServerSettings.Certificates = certificates;
}
***************
*** 99,108 ****
private void validateCertificate(X509Certificate certificate)
{
#warning "Check validity of certificates"
// 1 step : Validate dates
! if (!certificate.WasCurrent(DateTime.Now))
{
! throw Session.CreateException("Certificate received from the server expired.");
}
--- 102,113 ----
private void validateCertificate(X509Certificate certificate)
{
+ int[] certificateErrors = new int[0];
+
#warning "Check validity of certificates"
// 1 step : Validate dates
! if (!certificate.IsCurrent)
{
! #warning "Add error to the list"
}
***************
*** 114,123 ****
if (!certificate.VerifySignature(certificate.RSA))
{
! throw Session.CreateException("Certificate received from the server has invalid signature.");
}
*/
// 4 step: Validate domain name
! string name = certificate.SubjectName;
}
--- 119,161 ----
if (!certificate.VerifySignature(certificate.RSA))
{
! throw this.Context.CreateException("Certificate received from the server has invalid signature.");
}
*/
// 4 step: Validate domain name
! if (!this.checkDomainName(certificate.SubjectName))
! {
! #warning "Add error to the list"
! }
!
! if (certificateErrors.Length > 0)
! {
! if (!this.Context.SslStream.RaiseServerCertificateValidation(
! new X509Cert.X509Certificate(certificate.RawData),
! new int[]{}))
! {
! throw this.Context.CreateException("Invalid certificate received form server.");
! }
! }
! }
!
! private bool checkDomainName(string subjectName)
! {
! string domainName = String.Empty;
! Regex search = new Regex(@"([\w\s\d]*)\s*=\s*([^,]*)");
!
! MatchCollection elements = search.Matches(subjectName);
!
! foreach (Match element in elements)
! {
! switch (element.Groups[1].Value.Trim().ToUpper())
! {
! case "CN":
! domainName = element.Groups[2].Value;
! break;
! }
! }
!
! return (this.Context.ClientSettings.TargetHost == domainName);
}
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.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** TlsServerCertificateRequest.cs 3 Nov 2003 12:35:56 -0000 1.6
--- TlsServerCertificateRequest.cs 14 Nov 2003 13:42:54 -0000 1.7
***************
*** 40,45 ****
#region CONSTRUCTORS
! public TlsServerCertificateRequest(TlsSession session, byte[] buffer)
! : base(session, TlsHandshakeType.ServerHello, buffer)
{
}
--- 40,45 ----
#region CONSTRUCTORS
! public TlsServerCertificateRequest(TlsContext context, byte[] buffer)
! : base(context, TlsHandshakeType.ServerHello, buffer)
{
}
***************
*** 53,59 ****
base.UpdateSession();
! this.Session.Context.ServerSettings.CertificateTypes = this.certificateTypes;
! this.Session.Context.ServerSettings.DistinguisedNames = this.distinguisedNames;
! this.Session.Context.ServerSettings.CertificateRequest = true;
}
--- 53,59 ----
base.UpdateSession();
! this.Context.ServerSettings.CertificateTypes = this.certificateTypes;
! this.Context.ServerSettings.DistinguisedNames = this.distinguisedNames;
! this.Context.ServerSettings.CertificateRequest = true;
}
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.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** TlsServerFinished.cs 13 Nov 2003 09:23:50 -0000 1.11
--- TlsServerFinished.cs 14 Nov 2003 13:42:54 -0000 1.12
***************
*** 34,39 ****
#region CONSTRUCTORS
! public TlsServerFinished(TlsSession session, byte[] buffer)
! : base(session, TlsHandshakeType.ServerHello, buffer)
{
}
--- 34,39 ----
#region CONSTRUCTORS
! public TlsServerFinished(TlsContext context, byte[] buffer)
! : base(context, TlsHandshakeType.ServerHello, buffer)
{
}
***************
*** 48,55 ****
// Reset Hahdshake messages information
! this.Session.Context.HandshakeMessages.Reset();
// Hahdshake is finished
! this.Session.Context.HandshakeFinished = true;
}
--- 48,55 ----
// Reset Hahdshake messages information
! this.Context.HandshakeMessages.Reset();
// Hahdshake is finished
! this.Context.HandshakeFinished = true;
}
***************
*** 61,68 ****
{
// Compute handshake messages hashes
! HashAlgorithm hash = new TlsSslHandshakeHash(this.Session.Context.MasterSecret);
TlsStream data = new TlsStream();
! data.Write(this.Session.Context.HandshakeMessages.ToArray());
data.Write((int)0x53525652);
--- 61,68 ----
{
// Compute handshake messages hashes
! HashAlgorithm hash = new TlsSslHandshakeHash(this.Context.MasterSecret);
TlsStream data = new TlsStream();
! data.Write(this.Context.HandshakeMessages.ToArray());
data.Write((int)0x53525652);
***************
*** 94,102 ****
hash.ComputeHash(
! Session.Context.HandshakeMessages.ToArray(),
0,
! (int)Session.Context.HandshakeMessages.Length);
! byte[] clientPRF = this.Session.Context.Cipher.PRF(this.Session.Context.MasterSecret, "server finished", hash.Hash, 12);
// Check server prf against client prf
--- 94,102 ----
hash.ComputeHash(
! this.Context.HandshakeMessages.ToArray(),
0,
! (int)this.Context.HandshakeMessages.Length);
! byte[] clientPRF = this.Context.Cipher.PRF(this.Context.MasterSecret, "server finished", hash.Hash, 12);
// Check server prf against client prf
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.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** TlsServerHello.cs 13 Nov 2003 09:23:50 -0000 1.11
--- TlsServerHello.cs 14 Nov 2003 13:42:54 -0000 1.12
***************
*** 41,46 ****
#region CONSTRUCTORS
! public TlsServerHello(TlsSession session, byte[] buffer)
! : base(session, TlsHandshakeType.ServerHello, buffer)
{
}
--- 41,46 ----
#region CONSTRUCTORS
! public TlsServerHello(TlsContext context, byte[] buffer)
! : base(context, TlsHandshakeType.ServerHello, buffer)
{
}
***************
*** 54,75 ****
base.UpdateSession();
! this.Session.SetSessionId(this.sessionId);
! this.Session.Context.ServerRandom = this.random;
! this.Session.Context.Cipher = this.cipherSuite;
! this.Session.Context.CompressionMethod = this.compressionMethod;
! this.Session.Context.Cipher.Context = this.Session.Context;
// Compute ClientRandom + ServerRandom
TlsStream random = new TlsStream();
! random.Write(this.Session.Context.ClientRandom);
! random.Write(this.Session.Context.ServerRandom);
! this.Session.Context.RandomCS = random.ToArray();
// Server Random + Client Random
random.Reset();
! random.Write(this.Session.Context.ServerRandom);
! random.Write(this.Session.Context.ClientRandom);
! this.Session.Context.RandomSC = random.ToArray();
random.Reset();
}
--- 54,75 ----
base.UpdateSession();
! this.Context.SessionId = this.sessionId;
! this.Context.ServerRandom = this.random;
! this.Context.Cipher = this.cipherSuite;
! this.Context.CompressionMethod = this.compressionMethod;
! this.Context.Cipher.Context = this.Context;
// Compute ClientRandom + ServerRandom
TlsStream random = new TlsStream();
! random.Write(this.Context.ClientRandom);
! random.Write(this.Context.ServerRandom);
! this.Context.RandomCS = random.ToArray();
// Server Random + Client Random
random.Reset();
! random.Write(this.Context.ServerRandom);
! random.Write(this.Context.ClientRandom);
! this.Context.RandomSC = random.ToArray();
random.Reset();
}
***************
*** 97,106 ****
// Read cipher suite
short cipherCode = this.ReadInt16();
! if (this.Session.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
{
// The server has sent an invalid ciphersuite
throw new TlsException("Invalid cipher suite received from server");
}
! this.cipherSuite = this.Session.Context.SupportedCiphers[cipherCode];
// Read compression methods ( always 0 )
--- 97,106 ----
// Read cipher suite
short cipherCode = this.ReadInt16();
! if (this.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
{
// The server has sent an invalid ciphersuite
throw new TlsException("Invalid cipher suite received from server");
}
! this.cipherSuite = this.Context.SupportedCiphers[cipherCode];
// Read compression methods ( always 0 )
***************
*** 125,134 ****
// Read cipher suite
short cipherCode = this.ReadInt16();
! if (this.Session.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
{
// The server has sent an invalid ciphersuite
throw new TlsException("Invalid cipher suite received from server");
}
! this.cipherSuite = this.Session.Context.SupportedCiphers[cipherCode];
// Read compression methods ( always 0 )
--- 125,134 ----
// Read cipher suite
short cipherCode = this.ReadInt16();
! if (this.Context.SupportedCiphers.IndexOf(cipherCode) == -1)
{
// The server has sent an invalid ciphersuite
throw new TlsException("Invalid cipher suite received from server");
}
! this.cipherSuite = this.Context.SupportedCiphers[cipherCode];
// Read compression methods ( always 0 )
Index: TlsServerHelloDone.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/TlsServerHelloDone.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TlsServerHelloDone.cs 21 Oct 2003 20:06:28 -0000 1.5
--- TlsServerHelloDone.cs 14 Nov 2003 13:42:54 -0000 1.6
***************
*** 31,36 ****
#region CONSTRUCTORS
! public TlsServerHelloDone(TlsSession session, byte[] buffer)
! : base(session, TlsHandshakeType.ServerHello, buffer)
{
}
--- 31,36 ----
#region CONSTRUCTORS
! public TlsServerHelloDone(TlsContext context, byte[] buffer)
! : base(context, TlsHandshakeType.ServerHello, buffer)
{
}
***************
*** 44,48 ****
base.UpdateSession();
! this.Session.Context.HelloDone = true;
}
--- 44,48 ----
base.UpdateSession();
! this.Context.HelloDone = true;
}
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.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** TlsServerKeyExchange.cs 13 Nov 2003 09:23:50 -0000 1.12
--- TlsServerKeyExchange.cs 14 Nov 2003 13:42:54 -0000 1.13
***************
*** 42,47 ****
#region CONSTRUCTORS
! public TlsServerKeyExchange(TlsSession session, byte[] buffer)
! : base(session, TlsHandshakeType.ServerKeyExchange, buffer)
{
this.verifySignature();
--- 42,47 ----
#region CONSTRUCTORS
! public TlsServerKeyExchange(TlsContext context, byte[] buffer)
! : base(context, TlsHandshakeType.ServerKeyExchange, buffer)
{
this.verifySignature();
***************
*** 56,62 ****
base.UpdateSession();
! this.Session.Context.ServerSettings.ServerKeyExchange = true;
! this.Session.Context.ServerSettings.RsaParameters = this.rsaParams;
! this.Session.Context.ServerSettings.SignedParams = this.signedParams;
}
--- 56,62 ----
base.UpdateSession();
! this.Context.ServerSettings.ServerKeyExchange = true;
! this.Context.ServerSettings.RsaParameters = this.rsaParams;
! this.Context.ServerSettings.SignedParams = this.signedParams;
}
***************
*** 95,99 ****
TlsStream stream = new TlsStream();
! stream.Write(this.Session.Context.RandomCS);
stream.Write(rsaParams.Modulus.Length);
stream.Write(rsaParams.Modulus);
--- 95,99 ----
TlsStream stream = new TlsStream();
! stream.Write(this.Context.RandomCS);
stream.Write(rsaParams.Modulus.Length);
stream.Write(rsaParams.Modulus);
***************
*** 106,110 ****
// Verify Signature
! X509Certificate certificate = this.Session.Context.ServerSettings.Certificates[0];
RSA rsa = RSA.Create();
--- 106,110 ----
// Verify Signature
! X509Certificate certificate = this.Context.ServerSettings.Certificates[0];
RSA rsa = RSA.Create();
|