[pgsqlclient-checkins] pgsqlclient_10/PgSqlClient.Security.Tls/source TlsCipherSuite.cs,1.5,1.6 TlsC
Status: Inactive
Brought to you by:
carlosga_fb
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source
In directory sc8-pr-cvs1:/tmp/cvs-serv6121
Modified Files:
TlsCipherSuite.cs TlsCipherSuiteCollection.cs TlsReader.cs
TlsSession.cs
Log Message:
- Updated files.
- Fixed problem processing alerts in TlsReader.cs
Index: TlsCipherSuite.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsCipherSuite.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TlsCipherSuite.cs 24 Aug 2003 21:08:07 -0000 1.5
--- TlsCipherSuite.cs 29 Aug 2003 23:54:35 -0000 1.6
***************
*** 22,28 ****
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
! using PgSqlClient.Security.TLS.Cryptography;
using Mono.Security;
using Mono.Security.Cryptography;
namespace PgSqlClient.Security.TLS
--- 22,29 ----
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
!
using Mono.Security;
using Mono.Security.Cryptography;
+ using PgSqlClient.Security.TLS.Cryptography;
namespace PgSqlClient.Security.TLS
Index: TlsCipherSuiteCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsCipherSuiteCollection.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TlsCipherSuiteCollection.cs 25 Aug 2003 16:40:43 -0000 1.5
--- TlsCipherSuiteCollection.cs 29 Aug 2003 23:54:35 -0000 1.6
***************
*** 54,57 ****
--- 54,63 ----
TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection();
+ // Supported ciphers
+ scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA", false, true, 24, 24, 168, 8, 8);
+ scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", "DES", "SHA", false, true, 8, 8, 56, 8, 8);
+ scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", "RC4", "SHA", false, false, 16, 16, 128, 0, 0);
+ scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
+
// Default CipherSuite
// scs.Add(0, "TLS_NULL_WITH_NULL_NULL", "", "", true, false, 0, 0, 0, 0, 0);
***************
*** 61,71 ****
// scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", "", "SHA", true, false, 0, 0, 0, 0, 0);
// scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", "RC4", "MD5", true, false, 5, 16, 40, 0, 0);
! scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", "RC4", "SHA", false, false, 16, 16, 128, 0, 0);
! scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
// scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", "RC2", "MD5", true, true, 5, 16, 40, 8, 8);
// scs.Add((0x00 << 0x08) | 0x07, "TLS_RSA_WITH_IDEA_CBC_SHA", "IDEA", "SHA", false, true, 16, 16, 128, 8, 8);
// scs.Add((0x00 << 0x08) | 0x08, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA", true, true, 5, 8, 40, 8, 8);
! scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", "DES", "SHA", false, true, 8, 8, 56, 8, 8);
! scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA", false, true, 24, 24, 168, 8, 8);
// Diffie-Hellman Cipher Suites
--- 67,77 ----
// scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", "", "SHA", true, false, 0, 0, 0, 0, 0);
// scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", "RC4", "MD5", true, false, 5, 16, 40, 0, 0);
! // scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", "RC4", "SHA", false, false, 16, 16, 128, 0, 0);
! // scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", "RC4", "MD5", false, false, 16, 16, 128, 0, 0);
// scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", "RC2", "MD5", true, true, 5, 16, 40, 8, 8);
// scs.Add((0x00 << 0x08) | 0x07, "TLS_RSA_WITH_IDEA_CBC_SHA", "IDEA", "SHA", false, true, 16, 16, 128, 8, 8);
// scs.Add((0x00 << 0x08) | 0x08, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA", true, true, 5, 8, 40, 8, 8);
! // scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", "DES", "SHA", false, true, 8, 8, 56, 8, 8);
! // scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA", false, true, 24, 24, 168, 8, 8);
// Diffie-Hellman Cipher Suites
Index: TlsReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsReader.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** TlsReader.cs 25 Aug 2003 10:22:03 -0000 1.6
--- TlsReader.cs 29 Aug 2003 23:54:35 -0000 1.7
***************
*** 72,79 ****
// Decrypt message contents if needed
! if (session.State.IsActual &&
! contentType != TlsContentType.ChangeCipherSpec)
{
! message = processCipherTextRecord(contentType, protocol, message);
}
--- 72,86 ----
// Decrypt message contents if needed
! if (contentType != TlsContentType.Alert &&
! length == 2)
{
! }
! else
! {
! if (session.State.IsActual &&
! contentType != TlsContentType.ChangeCipherSpec)
! {
! message = processCipherTextRecord(contentType, protocol, message);
! }
}
***************
*** 140,147 ****
{
case TlsAlertLevel.Fatal:
! throw new TlsException(
! alertLevel,
! alertDesc,
! TlsAlert.GetAlertMessage(alertDesc));
case TlsAlertLevel.Warning:
--- 147,152 ----
{
case TlsAlertLevel.Fatal:
! session.ThrowException(alertLevel, alertDesc);
! break;
case TlsAlertLevel.Warning:
Index: TlsSession.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSession.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** TlsSession.cs 25 Aug 2003 16:40:43 -0000 1.6
--- TlsSession.cs 29 Aug 2003 23:54:35 -0000 1.7
***************
*** 98,101 ****
--- 98,128 ----
#endregion
+ #region EXCEPTION_METHODS
+
+ internal void ThrowException(TlsAlertLevel alertLevel, TlsAlertDescription alertDesc)
+ {
+ // Throw an exception will made the connection unavailable
+ // for this both streams will be closed
+ closeStreams();
+
+ // Throw exception
+ throw new TlsException(
+ alertLevel,
+ alertDesc,
+ TlsAlert.GetAlertMessage(alertDesc));
+ }
+
+ internal void ThrowException(string message)
+ {
+ // Throw an exception will made the connection unavailable
+ // for this both streams will be closed
+ closeStreams();
+
+ // Throw exception
+ throw new TlsException(message);
+ }
+
+ #endregion
+
#region METHODS
***************
*** 198,201 ****
--- 225,231 ----
writer.WriteAlert(alert);
+ // Close streams
+ closeStreams();
+
// Check that the session is finished by the client and by server
if (!state.ConnectionEnd)
***************
*** 203,208 ****
throw new TlsException("Invalid session termination");
}
-
- State.IsActual = false;
}
--- 233,236 ----
***************
*** 271,274 ****
--- 299,317 ----
{
this.sessionId = sessionId;
+ }
+
+ #endregion
+
+ #region PRIVATE_METHODS
+
+ private void closeStreams()
+ {
+ // Reset session state
+ state.IsActual = false;
+
+ // Close read and write streams this will close
+ // subyacent streams too
+ reader.Close();
+ writer.Close();
}
|