pgsqlclient-checkins Mailing List for PostgreSqlClient (Page 47)
Status: Inactive
Brought to you by:
carlosga_fb
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(120) |
Aug
(95) |
Sep
(95) |
Oct
(213) |
Nov
(114) |
Dec
(64) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(6) |
Feb
(134) |
Mar
(88) |
Apr
(28) |
May
(22) |
Jun
(15) |
Jul
(23) |
Aug
(2) |
Sep
(15) |
Oct
(2) |
Nov
(6) |
Dec
|
| 2005 |
Jan
(8) |
Feb
(6) |
Mar
|
Apr
(42) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(84) |
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
(84) |
Apr
(46) |
May
(40) |
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <car...@us...> - 2003-08-30 11:11:31
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source
In directory sc8-pr-cvs1:/tmp/cvs-serv23498
Modified Files:
TlsReader.cs
Log Message:
Fix for an error in latest commit
Index: TlsReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsReader.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** TlsReader.cs 29 Aug 2003 23:54:35 -0000 1.7
--- TlsReader.cs 30 Aug 2003 11:11:28 -0000 1.8
***************
*** 72,76 ****
// Decrypt message contents if needed
! if (contentType != TlsContentType.Alert &&
length == 2)
{
--- 72,76 ----
// Decrypt message contents if needed
! if (contentType == TlsContentType.Alert &&
length == 2)
{
|
|
From: <car...@us...> - 2003-08-29 23:57:01
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Handshake In directory sc8-pr-cvs1:/tmp/cvs-serv6374 Modified Files: TlsServerKeyExchange.cs Log Message: - Updated files. - Fixed problem processing alerts in TlsReader.cs Index: TlsServerKeyExchange.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Handshake/TlsServerKeyExchange.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsServerKeyExchange.cs 20 Aug 2003 11:51:31 -0000 1.1 --- TlsServerKeyExchange.cs 29 Aug 2003 23:56:58 -0000 1.2 *************** *** 107,111 **** #warning "Verify Signature here" ! //RSAPKCS1SignatureDeformatter rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa); } --- 107,111 ---- #warning "Verify Signature here" ! // RSAPKCS1SignatureDeformatter rsaDeformatter = new RSAPKCS1SignatureDeformatter(rsa); } |
|
From: <car...@us...> - 2003-08-29 23:55:58
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Handshake In directory sc8-pr-cvs1:/tmp/cvs-serv6253 Modified Files: TlsServerCertificate.cs Log Message: - Updated files. - Fixed problem processing alerts in TlsReader.cs Index: TlsServerCertificate.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Handshake/TlsServerCertificate.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsServerCertificate.cs 20 Aug 2003 11:51:31 -0000 1.1 --- TlsServerCertificate.cs 29 Aug 2003 23:55:54 -0000 1.2 *************** *** 29,33 **** #region FIELDS ! private X509CertificateCollection certificates; #endregion --- 29,33 ---- #region FIELDS ! private X509CertificateCollection certificates; #endregion |
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();
}
|
|
From: <car...@us...> - 2003-08-26 09:38:16
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Alerts
In directory sc8-pr-cvs1:/tmp/cvs-serv14857
Modified Files:
TlsAlert.cs TlsCloseNotifyAlert.cs TlsWarningAlertEventArgs.cs
Log Message:
Simplified exception handling
Index: TlsAlert.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Alerts/TlsAlert.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TlsAlert.cs 20 Aug 2003 11:49:27 -0000 1.1
--- TlsAlert.cs 25 Aug 2003 10:22:36 -0000 1.2
***************
*** 109,112 ****
--- 109,194 ----
#endregion
+
+ #region STATIC_METHODS
+
+ internal static string GetAlertMessage(TlsAlertDescription description)
+ {
+ switch (description)
+ {
+ case TlsAlertDescription.AccessDenied:
+ return "An inappropriate message was received.";
+
+ case TlsAlertDescription.BadCertificate:
+ return "TLSCiphertext decrypted in an invalid way.";
+
+ case TlsAlertDescription.BadRecordMAC:
+ return "Record with an incorrect MAC.";
+
+ case TlsAlertDescription.CertificateExpired:
+ return "Certificate has expired or is not currently valid";
+
+ case TlsAlertDescription.CertificateRevoked:
+ return "Certificate was revoked by its signer.";
+
+ case TlsAlertDescription.CertificateUnknown:
+ return "Certificate Unknown.";
+
+ case TlsAlertDescription.CloseNotify:
+ return "Connection closed";
+
+ case TlsAlertDescription.DecodeError:
+ return "A message could not be decoded because some field was out of the specified range or the length of the message was incorrect.";
+
+ case TlsAlertDescription.DecompressionFailiure:
+ return "The decompression function received improper input (e.g. data that would expand to excessive length).";
+
+ case TlsAlertDescription.DecryptError:
+ return "TLSCiphertext decrypted in an invalid way: either it wasn`t an even multiple of the block length or its padding values, when checked, weren`t correct.";
+
+ case TlsAlertDescription.DecryptionFailed:
+ return "Handshake cryptographic operation failed, including being unable to correctly verify a signature, decrypt a key exchange, or validate finished message.";
+
+ case TlsAlertDescription.ExportRestriction:
+ return "Negotiation not in compliance with export restrictions was detected.";
+
+ case TlsAlertDescription.HandshakeFailiure:
+ return "Unable to negotiate an acceptable set of security parameters given the options available.";
+
+ case TlsAlertDescription.IlegalParameter:
+ return "A field in the handshake was out of range or inconsistent with other fields.";
+
+ case TlsAlertDescription.InsuficientSecurity:
+ return "Negotiation has failed specifically because the server requires ciphers more secure than those supported by the client.";
+
+ case TlsAlertDescription.InternalError:
+ return "Internal error unrelated to the peer or the correctness of the protocol makes it impossible to continue.";
+
+ case TlsAlertDescription.NoRenegotiation:
+ return "Invalid renegotiation.";
+
+ case TlsAlertDescription.ProtocolVersion:
+ return "Unsupported protocol version.";
+
+ case TlsAlertDescription.RecordOverflow:
+ return "Invalid length on TLSCiphertext record or TLSCompressed record.";
+
+ case TlsAlertDescription.UnexpectedMessage:
+ return "Invalid message receive.";
+
+ case TlsAlertDescription.UnknownCA:
+ return "CA can't be identified as a trusted CA.";
+
+ case TlsAlertDescription.UnsupportedCertificate:
+ return "Certificate was of an unsupported type.";
+
+ case TlsAlertDescription.UserCancelled:
+ return "Handshake cancelled by user.";
+
+ default:
+ return "";
+ }
+ }
+
+ #endregion
}
}
Index: TlsCloseNotifyAlert.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Alerts/TlsCloseNotifyAlert.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TlsCloseNotifyAlert.cs 20 Aug 2003 11:49:27 -0000 1.1
--- TlsCloseNotifyAlert.cs 25 Aug 2003 10:22:36 -0000 1.2
***************
*** 34,38 ****
public override void UpdateSession()
{
! this.Session.State.ClientConnectionEnd = true;
}
}
--- 34,38 ----
public override void UpdateSession()
{
! this.Session.State.ConnectionEnd = true;
}
}
Index: TlsWarningAlertEventArgs.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Alerts/TlsWarningAlertEventArgs.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TlsWarningAlertEventArgs.cs 20 Aug 2003 11:49:27 -0000 1.1
--- TlsWarningAlertEventArgs.cs 25 Aug 2003 10:22:36 -0000 1.2
***************
*** 29,32 ****
--- 29,33 ----
private TlsAlertLevel level;
private TlsAlertDescription description;
+ private string message;
#endregion
***************
*** 39,47 ****
}
! private TlsAlertDescription Description
{
get { return description; }
}
#endregion
--- 40,53 ----
}
! public TlsAlertDescription Description
{
get { return description; }
}
+ public string Message
+ {
+ get { return message; }
+ }
+
#endregion
***************
*** 52,55 ****
--- 58,62 ----
this.level = level;
this.description = description;
+ this.message = TlsAlert.GetAlertMessage(description);
}
|
|
From: <car...@us...> - 2003-08-26 09:38:15
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source
In directory sc8-pr-cvs1:/tmp/cvs-serv14793
Modified Files:
TlsReader.cs
Log Message:
Simplified exception handling
Index: TlsReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsReader.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TlsReader.cs 24 Aug 2003 21:08:07 -0000 1.5
--- TlsReader.cs 25 Aug 2003 10:22:03 -0000 1.6
***************
*** 140,297 ****
{
case TlsAlertLevel.Fatal:
! switch (alertDesc)
! {
! case TlsAlertDescription.AccessDenied:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "An inappropriate message was received.");
!
! case TlsAlertDescription.BadCertificate:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "TLSCiphertext decrypted in an invalid way.");
!
! case TlsAlertDescription.BadRecordMAC:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Record with an incorrect MAC.");
!
! case TlsAlertDescription.CertificateExpired:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Certificate has expired or is not currently valid");
!
! case TlsAlertDescription.CertificateRevoked:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Certificate was revoked by its signer.");
!
! case TlsAlertDescription.CertificateUnknown:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Certificate Unknown.");
!
! case TlsAlertDescription.CloseNotify:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "");
!
! case TlsAlertDescription.DecodeError:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "A message could not be decoded because some field was out of the specified range or the length of the message was incorrect.");
!
! case TlsAlertDescription.DecompressionFailiure:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "The decompression function received improper input (e.g. data that would expand to excessive length).");
!
! case TlsAlertDescription.DecryptError:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "TLSCiphertext decrypted in an invalid way: either it wasn`t an even multiple of the block length or its padding values, when checked, weren`t correct.");
!
! case TlsAlertDescription.DecryptionFailed:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Handshake cryptographic operation failed, including being unable to correctly verify a signature, decrypt a key exchange, or validate finished message.");
!
! case TlsAlertDescription.ExportRestriction:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Negotiation not in compliance with export restrictions was detected.");
!
! case TlsAlertDescription.HandshakeFailiure:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Unable to negotiate an acceptable set of security parameters given the options available.");
!
! case TlsAlertDescription.IlegalParameter:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "A field in the handshake was out of range or inconsistent with other fields");
!
! case TlsAlertDescription.InsuficientSecurity:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Negotiation has failed specifically because the server requires ciphers more secure than those supported by the client.");
!
! case TlsAlertDescription.InternalError:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Internal error unrelated to the peer or the correctness of the protocol makes it impossible to continue.");
!
! case TlsAlertDescription.NoRenegotiation:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Invalid renegotiation.");
!
! case TlsAlertDescription.ProtocolVersion:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Unsupported protocol version.");
!
! case TlsAlertDescription.RecordOverflow:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Invalid length on TLSCiphertext record or TLSCompressed record.");
!
! case TlsAlertDescription.UnexpectedMessage:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Invalid message receive.");
!
! case TlsAlertDescription.UnknownCA:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "CA can't be identified as a trusted CA.");
!
! case TlsAlertDescription.UnsupportedCertificate:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Certificate was of an unsupported type.");
!
! case TlsAlertDescription.UserCancelled:
! throw new TlsException(
! alertLevel,
! alertDesc,
! "Handshake cancelled by user.");
! }
! break;
case TlsAlertLevel.Warning:
default:
! switch (alertDesc)
! {
! case TlsAlertDescription.CloseNotify:
! session.State.ConnectionEnd = true;
! break;
! default:
! session.RaiseWarningAlert(alertLevel, alertDesc);
! break;
! }
break;
}
--- 140,160 ----
{
case TlsAlertLevel.Fatal:
! throw new TlsException(
! alertLevel,
! alertDesc,
! TlsAlert.GetAlertMessage(alertDesc));
case TlsAlertLevel.Warning:
default:
! switch (alertDesc)
! {
! case TlsAlertDescription.CloseNotify:
! session.State.ConnectionEnd = true;
! break;
! default:
! session.RaiseWarningAlert(alertLevel, alertDesc);
! break;
! }
break;
}
|
|
From: <car...@us...> - 2003-08-25 23:07:45
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source
In directory sc8-pr-cvs1:/tmp/cvs-serv20381
Modified Files:
TlsCipherSuiteCollection.cs TlsSession.cs TlsSessionState.cs
Log Message:
Moved Key generation methods to TlsSessionState class
Index: TlsCipherSuiteCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsCipherSuiteCollection.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TlsCipherSuiteCollection.cs 24 Aug 2003 21:08:07 -0000 1.4
--- TlsCipherSuiteCollection.cs 25 Aug 2003 16:40:43 -0000 1.5
***************
*** 61,65 ****
// 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) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA", false, true, 24, 24, 168, 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);
--- 61,64 ----
Index: TlsSession.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSession.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TlsSession.cs 24 Aug 2003 21:08:07 -0000 1.5
--- TlsSession.cs 25 Aug 2003 16:40:43 -0000 1.6
***************
*** 258,437 ****
#endregion
- #region KEY_GENERATION_METODS
-
- internal byte[] CreatePremasterSecret()
- {
- TlsStreamWriter stream = new TlsStreamWriter();
-
- // Write protocol version
- stream.WriteShort((short)TlsProtocol.Tls1);
-
- // Generate random bytes
- byte[] random = new byte[46];
- RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
- rng.GetNonZeroBytes(random);
- stream.Write(random);
-
- byte[] preMasterSecret = stream.GetBytes();
-
- stream.Reset();
-
- return preMasterSecret;
- }
-
- internal void CreateMasterSecret(byte[] preMasterSecret)
- {
- TlsCipherSuite cipherSuite = state.Cipher;
- byte[] masterSecret = new byte[preMasterSecret.Length];
-
- TlsStreamWriter seed = new TlsStreamWriter();
-
- // Seed
- seed.Write(this.State.ClientRandom);
- seed.Write(this.State.ServerRandom);
-
- // Create master secret
- this.State.MasterSecret = PRF(preMasterSecret, "master secret", seed.GetBytes(), 48);
-
- seed.Reset();
- }
-
- internal void CreateKeys()
- {
- TlsStreamWriter seed = new TlsStreamWriter();
-
- // Seed
- seed.Write(state.ServerRandom);
- seed.Write(state.ClientRandom);
-
- // Create keyblock
- TlsStreamReader keyBlock = new TlsStreamReader(
- PRF(state.MasterSecret,
- "key expansion",
- seed.GetBytes(),
- state.Cipher.GetKeyBlockSize()));
-
- state.ClientWriteMAC = keyBlock.ReadBytes(state.Cipher.HashSize);
- state.ServerWriteMAC = keyBlock.ReadBytes(state.Cipher.HashSize);
- byte[] clientWriteKey = keyBlock.ReadBytes(state.Cipher.KeyMaterialSize);
- byte[] serverWriteKey = keyBlock.ReadBytes(state.Cipher.KeyMaterialSize);
-
- // Seed
- seed.Reset();
- seed.Write(state.ClientRandom);
- seed.Write(state.ServerRandom);
-
- if (!state.Cipher.IsExportable)
- {
- state.ClientWriteKey = clientWriteKey;
- state.ServerWriteKey = serverWriteKey;
-
- if (state.Cipher.IvSize != 0)
- {
- state.ClientWriteIV = keyBlock.ReadBytes(state.Cipher.IvSize);
- state.ServerWriteIV = keyBlock.ReadBytes(state.Cipher.IvSize);
- }
- }
- else
- {
- // Generate final write keys
- byte[] finalClientWriteKey = PRF(clientWriteKey, "client write key", seed.GetBytes(), state.Cipher.KeyMaterialSize);
- byte[] finalServerWriteKey = PRF(serverWriteKey, "server write key", seed.GetBytes(), state.Cipher.KeyMaterialSize);
-
- state.ClientWriteKey = finalClientWriteKey;
- state.ServerWriteKey = finalServerWriteKey;
-
- // Generate IV block
- byte[] ivBlock = PRF(new byte[]{}, "IV block", seed.GetBytes(), state.Cipher.IvSize*2);
- // Generate IV keys
- byte[] clientWriteIV = new byte[state.Cipher.IvSize];
- System.Array.Copy(ivBlock, 0, clientWriteIV, 0, clientWriteIV.Length);
- byte[] serverWriteIV = new byte[state.Cipher.IvSize];
- System.Array.Copy(ivBlock, state.Cipher.IvSize, serverWriteIV, 0, serverWriteIV.Length);
-
- state.ClientWriteIV = clientWriteIV;
- state.ServerWriteIV = serverWriteIV;
- }
-
- // Clear no more needed data
- seed.Reset();
- keyBlock.Reset();
- }
-
- internal byte[] PRF(byte[] secret, string label, byte[] data, int length)
- {
- MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
- SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
-
- int secretLen = secret.Length / 2;
-
- // Seed
- TlsStreamWriter seedStream = new TlsStreamWriter();
- seedStream.Write(Encoding.ASCII.GetBytes(label));
- seedStream.Write(data);
- byte[] seed = seedStream.GetBytes();
- seedStream.Reset();
-
- // Secret 1
- byte[] secret1 = new byte[secretLen];
- System.Array.Copy(secret, 0, secret1, 0, secretLen);
-
- // Secret2
- byte[] secret2 = new byte[secretLen];
- System.Array.Copy(secret, secretLen, secret2, 0, secretLen);
-
- // Secret 1 processing
- byte[] p_md5 = expand("MD5", secret1, seed, length);
-
- // Secret 2 processing
- byte[] p_sha = expand("SHA1", secret2, seed, length);
-
- // Perfor XOR of both results
- byte[] masterSecret = new byte[length];
- for (int i = 0; i < masterSecret.Length; i++)
- {
- masterSecret[i] = (byte)(p_md5[i] ^ p_sha[i]);
- }
-
- return masterSecret;
- }
-
- private byte[] expand(string hashName, byte[] secret, byte[] seed, int length)
- {
- int hashLength = hashName == "MD5" ? 16 : 20;
- int iterations = (int)(length / hashLength);
- if ((length % hashLength) > 0)
- {
- iterations++;
- }
-
- HMAC hmac = new HMAC(hashName, secret);
- TlsStreamWriter resMacs = new TlsStreamWriter();
-
- byte[][] hmacs = new byte[iterations + 1][];
- hmacs[0] = seed;
- for (int i = 1; i <= iterations; i++)
- {
- TlsStreamWriter hcseed = new TlsStreamWriter();
- hmac.TransformFinalBlock(hmacs[i-1], 0, hmacs[i-1].Length);
- hmacs[i] = hmac.Hash;
- hcseed.Write(hmacs[i]);
- hcseed.Write(seed);
- hmac.TransformFinalBlock(hcseed.GetBytes(), 0, hcseed.GetBytes().Length);
- resMacs.Write(hmac.Hash);
- hcseed.Reset();
- }
-
- byte[] res = new byte[length];
-
- System.Array.Copy(resMacs.GetBytes(), 0, res, 0, res.Length);
-
- resMacs.Reset();
-
- return res;
- }
-
- #endregion
-
#region INTERNAL_METHODS
--- 258,261 ----
Index: TlsSessionState.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSessionState.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TlsSessionState.cs 24 Aug 2003 21:08:07 -0000 1.3
--- TlsSessionState.cs 25 Aug 2003 16:40:43 -0000 1.4
***************
*** 18,21 ****
--- 18,25 ----
using System;
+ using System.Text;
+ using System.Security.Cryptography;
+
+ using PgSqlClient.Security.TLS.Cryptography;
namespace PgSqlClient.Security.TLS
***************
*** 157,171 ****
#endregion
#region METHODS
public void ClearKeyInfo()
{
// Clear client keys
! clientWriteKey = null;
clientWriteIV = null;
clientWriteMAC = null;
// Clear server keys
! serverWriteKey = null;
serverWriteIV = null;
serverWriteMAC = null;
--- 161,356 ----
#endregion
+ #region KEY_GENERATION_METODS
+
+ public byte[] CreatePremasterSecret()
+ {
+ TlsStreamWriter stream = new TlsStreamWriter();
+
+ // Write protocol version
+ stream.WriteShort((short)TlsProtocol.Tls1);
+
+ // Generate random bytes
+ byte[] random = new byte[46];
+ RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
+ rng.GetNonZeroBytes(random);
+ stream.Write(random);
+
+ byte[] preMasterSecret = stream.GetBytes();
+
+ stream.Reset();
+
+ return preMasterSecret;
+ }
+
+ public void CreateMasterSecret(byte[] preMasterSecret)
+ {
+ TlsCipherSuite cipherSuite = cipher;
+ TlsStreamWriter seed = new TlsStreamWriter();
+
+ // Seed
+ seed.Write(clientRandom);
+ seed.Write(serverRandom);
+
+ // Create master secret
+ masterSecret = new byte[preMasterSecret.Length];
+ masterSecret = PRF(preMasterSecret, "master secret", seed.GetBytes(), 48);
+
+ seed.Reset();
+ }
+
+ public void CreateKeys()
+ {
+ TlsStreamWriter seed = new TlsStreamWriter();
+
+ // Seed
+ seed.Write(serverRandom);
+ seed.Write(clientRandom);
+
+ // Create keyblock
+ TlsStreamReader keyBlock = new TlsStreamReader(
+ PRF(masterSecret,
+ "key expansion",
+ seed.GetBytes(),
+ cipher.GetKeyBlockSize()));
+
+ clientWriteMAC = keyBlock.ReadBytes(cipher.HashSize);
+ serverWriteMAC = keyBlock.ReadBytes(cipher.HashSize);
+ clientWriteKey = keyBlock.ReadBytes(cipher.KeyMaterialSize);
+ serverWriteKey = keyBlock.ReadBytes(cipher.KeyMaterialSize);
+
+ if (!cipher.IsExportable)
+ {
+ if (cipher.IvSize != 0)
+ {
+ clientWriteIV = keyBlock.ReadBytes(cipher.IvSize);
+ serverWriteIV = keyBlock.ReadBytes(cipher.IvSize);
+ }
+ else
+ {
+ clientWriteIV = new byte[0];
+ serverWriteIV = new byte[0];
+ }
+ }
+ else
+ {
+ // Seed
+ seed.Reset();
+ seed.Write(clientRandom);
+ seed.Write(serverRandom);
+
+ // Generate final write keys
+ byte[] finalClientWriteKey = PRF(clientWriteKey, "client write key", seed.GetBytes(), cipher.KeyMaterialSize);
+ byte[] finalServerWriteKey = PRF(serverWriteKey, "server write key", seed.GetBytes(), cipher.KeyMaterialSize);
+
+ clientWriteKey = finalClientWriteKey;
+ serverWriteKey = finalServerWriteKey;
+
+ // Generate IV block
+ byte[] ivBlock = PRF(new byte[]{}, "IV block", seed.GetBytes(), cipher.IvSize*2);
+ // Generate IV keys
+ clientWriteIV = new byte[cipher.IvSize];
+ System.Array.Copy(ivBlock, 0, clientWriteIV, 0, clientWriteIV.Length);
+ serverWriteIV = new byte[cipher.IvSize];
+ System.Array.Copy(ivBlock, cipher.IvSize, serverWriteIV, 0, serverWriteIV.Length);
+ }
+
+ // Clear no more needed data
+ seed.Reset();
+ keyBlock.Reset();
+ }
+
+ public byte[] PRF(byte[] secret, string label, byte[] data, int length)
+ {
+ MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
+ SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
+
+ int secretLen = secret.Length / 2;
+
+ // Seed
+ TlsStreamWriter seedStream = new TlsStreamWriter();
+ seedStream.Write(Encoding.ASCII.GetBytes(label));
+ seedStream.Write(data);
+ byte[] seed = seedStream.GetBytes();
+ seedStream.Reset();
+
+ // Secret 1
+ byte[] secret1 = new byte[secretLen];
+ System.Array.Copy(secret, 0, secret1, 0, secretLen);
+
+ // Secret2
+ byte[] secret2 = new byte[secretLen];
+ System.Array.Copy(secret, secretLen, secret2, 0, secretLen);
+
+ // Secret 1 processing
+ byte[] p_md5 = Expand("MD5", secret1, seed, length);
+
+ // Secret 2 processing
+ byte[] p_sha = Expand("SHA1", secret2, seed, length);
+
+ // Perfor XOR of both results
+ byte[] masterSecret = new byte[length];
+ for (int i = 0; i < masterSecret.Length; i++)
+ {
+ masterSecret[i] = (byte)(p_md5[i] ^ p_sha[i]);
+ }
+
+ return masterSecret;
+ }
+
+ public byte[] Expand(string hashName, byte[] secret, byte[] seed, int length)
+ {
+ int hashLength = hashName == "MD5" ? 16 : 20;
+ int iterations = (int)(length / hashLength);
+ if ((length % hashLength) > 0)
+ {
+ iterations++;
+ }
+
+ HMAC hmac = new HMAC(hashName, secret);
+ TlsStreamWriter resMacs = new TlsStreamWriter();
+
+ byte[][] hmacs = new byte[iterations + 1][];
+ hmacs[0] = seed;
+ for (int i = 1; i <= iterations; i++)
+ {
+ TlsStreamWriter hcseed = new TlsStreamWriter();
+ hmac.TransformFinalBlock(hmacs[i-1], 0, hmacs[i-1].Length);
+ hmacs[i] = hmac.Hash;
+ hcseed.Write(hmacs[i]);
+ hcseed.Write(seed);
+ hmac.TransformFinalBlock(hcseed.GetBytes(), 0, hcseed.GetBytes().Length);
+ resMacs.Write(hmac.Hash);
+ hcseed.Reset();
+ }
+
+ byte[] res = new byte[length];
+
+ System.Array.Copy(resMacs.GetBytes(), 0, res, 0, res.Length);
+
+ resMacs.Reset();
+
+ return res;
+ }
+
+ #endregion
+
#region METHODS
public void ClearKeyInfo()
{
+ // Clear Master Secret
+ masterSecret = null;
+
+ // Clear client and server random
+ clientRandom = null;
+ serverRandom = null;
+
// Clear client keys
! clientWriteKey = null;
clientWriteIV = null;
clientWriteMAC = null;
// Clear server keys
! serverWriteKey = null;
serverWriteIV = null;
serverWriteMAC = null;
|
|
From: <car...@us...> - 2003-08-25 23:07:45
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Handshake
In directory sc8-pr-cvs1:/tmp/cvs-serv20455
Modified Files:
TlsClientFinished.cs TlsClientKeyExchange.cs
TlsServerFinished.cs
Log Message:
Moved Key generation methods to TlsSessionState class
Index: TlsClientFinished.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Handshake/TlsClientFinished.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TlsClientFinished.cs 20 Aug 2003 11:51:31 -0000 1.1
--- TlsClientFinished.cs 25 Aug 2003 16:41:02 -0000 1.2
***************
*** 54,58 ****
hashes.Write(Session.HandshakeHashes.GetSHAHash());
! Write(Session.PRF(Session.State.MasterSecret, "client finished", hashes.GetBytes(), 12));
hashes.Reset();
--- 54,58 ----
hashes.Write(Session.HandshakeHashes.GetSHAHash());
! Write(Session.State.PRF(Session.State.MasterSecret, "client finished", hashes.GetBytes(), 12));
hashes.Reset();
Index: TlsClientKeyExchange.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Handshake/TlsClientKeyExchange.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TlsClientKeyExchange.cs 20 Aug 2003 15:45:05 -0000 1.2
--- TlsClientKeyExchange.cs 25 Aug 2003 16:41:02 -0000 1.3
***************
*** 41,45 ****
{
// Compute pre master secret
! byte[] preMasterSecret = Session.CreatePremasterSecret();
// Create a new RSA key
--- 41,45 ----
{
// Compute pre master secret
! byte[] preMasterSecret = Session.State.CreatePremasterSecret();
// Create a new RSA key
***************
*** 61,68 ****
// Create master secret
! Session.CreateMasterSecret(preMasterSecret);
// Create keys
! Session.CreateKeys();
// Clear resources
--- 61,68 ----
// Create master secret
! Session.State.CreateMasterSecret(preMasterSecret);
// Create keys
! Session.State.CreateKeys();
// Clear resources
Index: TlsServerFinished.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Handshake/TlsServerFinished.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TlsServerFinished.cs 20 Aug 2003 11:51:31 -0000 1.1
--- TlsServerFinished.cs 25 Aug 2003 16:41:02 -0000 1.2
***************
*** 56,60 ****
hashes.Write(Session.HandshakeHashes.GetSHAHash());
! byte[] clientPRF = Session.PRF(Session.State.MasterSecret, "server finished", hashes.GetBytes(), 12);
hashes.Reset();
--- 56,60 ----
hashes.Write(Session.HandshakeHashes.GetSHAHash());
! byte[] clientPRF = Session.State.PRF(Session.State.MasterSecret, "server finished", hashes.GetBytes(), 12);
hashes.Reset();
|
|
From: <car...@us...> - 2003-08-24 21:09:29
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/Cryptography In directory sc8-pr-cvs1:/tmp/cvs-serv4956 Added Files: HMAC.cs Log Message: - Update dencryption/decryption of CBC ciphers. - Converted TlsSession.hmac function into a class derived from KeyedHashAlgorithm. - Improved hmac generation. --- NEW FILE: HMAC.cs --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source
In directory sc8-pr-cvs1:/tmp/cvs-serv4681
Modified Files:
TlsCipherSuite.cs TlsCipherSuiteCollection.cs TlsReader.cs
TlsSession.cs TlsSessionState.cs TlsWriter.cs
Log Message:
- Update dencryption/decryption of CBC ciphers.
- Converted TlsSession.hmac function into a class derived
from KeyedHashAlgorithm.
- Improved hmac generation.
Index: TlsCipherSuite.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsCipherSuite.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TlsCipherSuite.cs 24 Aug 2003 10:46:54 -0000 1.4
--- TlsCipherSuite.cs 24 Aug 2003 21:08:07 -0000 1.5
***************
*** 22,25 ****
--- 22,26 ----
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
+ using PgSqlClient.Security.TLS.Cryptography;
using Mono.Security;
using Mono.Security.Cryptography;
***************
*** 47,50 ****
--- 48,53 ----
private SymmetricAlgorithm decryptionAlgorithm;
private ICryptoTransform decryptionCipher;
+ private KeyedHashAlgorithm clientHMAC;
+ private KeyedHashAlgorithm serverHMAC;
#endregion
***************
*** 183,186 ****
--- 186,213 ----
}
+ public void UpdateClientCipherIV(byte[] iv)
+ {
+ if (cipherMode == CipherMode.CBC)
+ {
+ // Set the new IV
+ encryptionAlgorithm.IV = iv;
+
+ // Create encryption cipher with the new IV
+ encryptionCipher = encryptionAlgorithm.CreateEncryptor();
+ }
+ }
+
+ public void UpdateServerCipherIV(byte[] iv)
+ {
+ if (cipherMode == CipherMode.CBC)
+ {
+ // Set the new IV
+ decryptionAlgorithm.IV = iv;
+
+ // Create encryption cipher with the new IV
+ decryptionCipher = decryptionAlgorithm.CreateDecryptor();
+ }
+ }
+
public byte[] EncryptRecord(byte[] fragment, byte[] mac)
{
***************
*** 200,204 ****
cs.WriteByte((byte)paddingLength);
}
- cs.Flush();
cs.Close();
--- 227,230 ----
***************
*** 231,234 ****
--- 257,274 ----
}
+ public byte[] ComputeClientMAC(byte[] data)
+ {
+ clientHMAC.TransformFinalBlock(data, 0, data.Length);
+
+ return clientHMAC.Hash;
+ }
+
+ public byte[] ComputeServerMAC(byte[] data)
+ {
+ serverHMAC.TransformFinalBlock(data, 0, data.Length);
+
+ return serverHMAC.Hash;
+ }
+
public int GetKeyBlockSize()
{
***************
*** 282,293 ****
encryptionAlgorithm.BlockSize = this.blockSize * 8;
}
! encryptionCipher = encryptionAlgorithm.CreateEncryptor(
! sessionState.ClientWriteKey,
! sessionState.ClientWriteIV);
! // Clear server keys
! sessionState.ClientWriteKey = null;
! sessionState.ClientWriteIV = null;
}
--- 322,335 ----
encryptionAlgorithm.BlockSize = this.blockSize * 8;
}
+
+ // Set the key and IV for the algorithm
+ encryptionAlgorithm.Key = sessionState.ClientWriteKey;
+ encryptionAlgorithm.IV = sessionState.ClientWriteIV;
! // Create encryption cipher
! encryptionCipher = encryptionAlgorithm.CreateEncryptor();
! // Create the HMAC algorithm for the client
! clientHMAC = new HMAC(hashName, sessionState.ClientWriteMAC);
}
***************
*** 315,326 ****
decryptionAlgorithm.BlockSize = this.blockSize * 8;
}
!
! decryptionCipher = decryptionAlgorithm.CreateDecryptor(
! sessionState.ServerWriteKey,
! sessionState.ServerWriteIV);
!
! // Clear server keys
! sessionState.ServerWriteKey = null;
! sessionState.ServerWriteIV = null;
}
--- 357,370 ----
decryptionAlgorithm.BlockSize = this.blockSize * 8;
}
!
! // Set the key and IV for the algorithm
! decryptionAlgorithm.Key = sessionState.ServerWriteKey;
! decryptionAlgorithm.IV = sessionState.ServerWriteIV;
!
! // Create decryption cipher
! decryptionCipher = decryptionAlgorithm.CreateDecryptor();
!
! // Create the HMAC algorithm for the server
! serverHMAC = new HMAC(hashName, sessionState.ServerWriteMAC);
}
Index: TlsCipherSuiteCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsCipherSuiteCollection.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TlsCipherSuiteCollection.cs 20 Aug 2003 20:29:35 -0000 1.3
--- TlsCipherSuiteCollection.cs 24 Aug 2003 21:08:07 -0000 1.4
***************
*** 61,64 ****
--- 61,65 ----
// 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) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA", false, true, 24, 24, 168, 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);
Index: TlsReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsReader.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TlsReader.cs 24 Aug 2003 10:46:54 -0000 1.4
--- TlsReader.cs 24 Aug 2003 21:08:07 -0000 1.5
***************
*** 307,310 ****
--- 307,318 ----
// Decrypt message
session.State.Cipher.DecryptRecord(fragment, ref dcrFragment, ref dcrMAC);
+
+ // Set new IV
+ if (session.State.Cipher.CipherMode == CipherMode.CBC)
+ {
+ byte[] iv = new byte[session.State.Cipher.IvSize];
+ System.Array.Copy(fragment, fragment.Length - iv.Length, iv, 0, iv.Length);
+ session.State.Cipher.UpdateServerCipherIV(iv);
+ }
// Check MAC code
***************
*** 341,347 ****
--- 349,358 ----
data.Write(fragment);
+ /*
result = session.hmac(session.State.Cipher.HashName,
session.State.ServerWriteMAC,
data.GetBytes());
+ */
+ result = session.State.Cipher.ComputeServerMAC(data.GetBytes());
data.Reset();
Index: TlsSession.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSession.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TlsSession.cs 24 Aug 2003 10:46:54 -0000 1.4
--- TlsSession.cs 24 Aug 2003 21:08:07 -0000 1.5
***************
*** 23,26 ****
--- 23,27 ----
using System.Security.Cryptography;
+ using PgSqlClient.Security.TLS.Cryptography;
using PgSqlClient.Security.TLS.Alerts;
using PgSqlClient.Security.TLS.Handshake;
***************
*** 171,176 ****
state.Cipher.InitializeCipher();
- #warning "Clear key info that is no more needed"
-
// Send certificate verify if requested
if (state.ServerSettings.CertificateRequest)
--- 172,175 ----
***************
*** 187,190 ****
--- 186,192 ----
// Read server finished
reader.ReadRecord();
+
+ // Clear Key Info
+ state.ClearKeyInfo();
}
***************
*** 404,407 ****
--- 406,410 ----
}
+ HMAC hmac = new HMAC(hashName, secret);
TlsStreamWriter resMacs = new TlsStreamWriter();
***************
*** 411,418 ****
{
TlsStreamWriter hcseed = new TlsStreamWriter();
! hmacs[i] = hmac(hashName, secret, hmacs[i-1]);
hcseed.Write(hmacs[i]);
hcseed.Write(seed);
! resMacs.Write(hmac(hashName, secret, hcseed.GetBytes()));
hcseed.Reset();
}
--- 414,423 ----
{
TlsStreamWriter hcseed = new TlsStreamWriter();
! hmac.TransformFinalBlock(hmacs[i-1], 0, hmacs[i-1].Length);
! hmacs[i] = hmac.Hash;
hcseed.Write(hmacs[i]);
hcseed.Write(seed);
! hmac.TransformFinalBlock(hcseed.GetBytes(), 0, hcseed.GetBytes().Length);
! resMacs.Write(hmac.Hash);
hcseed.Reset();
}
***************
*** 427,487 ****
}
- /*
- * References:
- * RFC 2104
- * RFC 2202
- */
- #warning "Think on implement this as a class derived from KeyedHashAlgorithm"
- public byte[] hmac(string hashName, byte[] key, byte[] text)
- {
- HashAlgorithm hash = HashAlgorithm.Create(hashName);
-
- byte[] tmp = new byte[64];
- byte[] buff = new byte[64];
-
- /* if key is longer than 64 bytes reset it to key=Hash(key) */
- if (key.Length > 64)
- {
- hash.Initialize();
- key = hash.ComputeHash(key);
- }
-
- /* Pad the key for inner digest */
- for (int i = 0 ; i < key.Length; ++i)
- {
- buff[i] = (byte)(key[i] ^ 0x36);
- }
- for (int i = key.Length; i < 64; ++i)
- {
- buff[i] = 0x36;
- }
-
- byte[] hash1 = new byte[hash.HashSize];
-
- /* First pass */
- hash.Initialize();
- hash.TransformBlock(buff, 0, 64, tmp, 0);
- hash.TransformFinalBlock(text, 0, text.Length);
-
- /* Second pass */
- for (int i = 0 ; i < key.Length; ++i)
- {
- buff[i] = (byte)(key[i] ^ 0x5C);
- }
- for (int i = key.Length ; i < 64; ++i)
- {
- buff[i] = 0x5C;
- }
-
- /* The result of the first pass */
- byte[] firstResult = hash.Hash;
-
- hash.Initialize();
- hash.TransformBlock(buff, 0, 64, tmp, 0);
- hash.TransformFinalBlock(firstResult, 0, firstResult.Length);
-
- return hash.Hash;
- }
-
#endregion
--- 432,435 ----
***************
*** 502,557 ****
#endregion
-
- /*
- public void PrintArray(string text, byte[] array)
- {
- Console.WriteLine(text);
- int count = 0;
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write("{0} ", array[i].ToString("x2").ToUpper());
- if (count == 15)
- {
- count = 0;
- Console.WriteLine("");
- }
- else
- {
- count++;
- }
- }
- Console.WriteLine("");
- }
-
- public static void SaveToFile(string file, byte[] data)
- {
- string fileName = "d:\\test\\" + file;
-
- FileStream stream = new FileStream(
- fileName, FileMode.Create, FileAccess.Write);
- if (data != null)
- {
- stream.Write(data, 0, data.Length);
- }
- else
- {
- stream.Write(new byte[0], 0, 0);
- }
- stream.Close();
- }
-
- public static byte[] ReadFromFile(string file)
- {
- string fileName = "d:\\test\\" + file;
-
- FileStream stream = new FileStream(
- fileName, FileMode.Open, FileAccess.Read);
- byte[] data = new byte[stream.Length];
- stream.Read(data, 0, data.Length);
- stream.Close();
-
- return data;
- }
- */
}
}
--- 450,453 ----
Index: TlsSessionState.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSessionState.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TlsSessionState.cs 24 Aug 2003 10:46:54 -0000 1.2
--- TlsSessionState.cs 24 Aug 2003 21:08:07 -0000 1.3
***************
*** 156,159 ****
--- 156,176 ----
#endregion
+
+ #region METHODS
+
+ public void ClearKeyInfo()
+ {
+ // Clear client keys
+ clientWriteKey = null;
+ clientWriteIV = null;
+ clientWriteMAC = null;
+
+ // Clear server keys
+ serverWriteKey = null;
+ serverWriteIV = null;
+ serverWriteMAC = null;
+ }
+
+ #endregion
}
}
Index: TlsWriter.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsWriter.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** TlsWriter.cs 23 Aug 2003 19:25:31 -0000 1.4
--- TlsWriter.cs 24 Aug 2003 21:08:07 -0000 1.5
***************
*** 184,187 ****
--- 184,195 ----
byte[] ecr = session.State.Cipher.EncryptRecord(fragment, mac);
+ // Set new IV
+ if (session.State.Cipher.CipherMode == CipherMode.CBC)
+ {
+ byte[] iv = new byte[session.State.Cipher.IvSize];
+ System.Array.Copy(ecr, ecr.Length - iv.Length, iv, 0, iv.Length);
+ session.State.Cipher.UpdateClientCipherIV(iv);
+ }
+
// Update sequence number
session.State.WriteSequenceNumber++;
***************
*** 200,207 ****
data.WriteShort((short)fragment.Length);
data.Write(fragment);
!
! result = session.hmac(session.State.Cipher.HashName,
! session.State.ClientWriteMAC,
! data.GetBytes());
data.Reset();
--- 208,213 ----
data.WriteShort((short)fragment.Length);
data.Write(fragment);
!
! result = session.State.Cipher.ComputeClientMAC(data.GetBytes());
data.Reset();
|
|
From: <car...@us...> - 2003-08-24 10:46:57
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source
In directory sc8-pr-cvs1:/tmp/cvs-serv11302
Modified Files:
TlsCipherSuite.cs TlsReader.cs TlsSession.cs
TlsSessionState.cs
Log Message:
no message
Index: TlsCipherSuite.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsCipherSuite.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TlsCipherSuite.cs 23 Aug 2003 19:25:31 -0000 1.3
--- TlsCipherSuite.cs 24 Aug 2003 10:46:54 -0000 1.4
***************
*** 200,204 ****
cs.WriteByte((byte)paddingLength);
}
! // cs.FlushFinalBlock();
cs.Close();
--- 200,204 ----
cs.WriteByte((byte)paddingLength);
}
! cs.Flush();
cs.Close();
***************
*** 208,212 ****
public void DecryptRecord(byte[] fragment, ref byte[] dcrFragment, ref byte[] dcrMAC)
{
! int fragmentSize = 0;
// Decrypt message fragment ( fragment + mac [+ padding + padding_length] )
--- 208,212 ----
public void DecryptRecord(byte[] fragment, ref byte[] dcrFragment, ref byte[] dcrMAC)
{
! int fragmentSize = 0;
// Decrypt message fragment ( fragment + mac [+ padding + padding_length] )
***************
*** 217,221 ****
if (cipherMode == CipherMode.CBC)
{
! fragmentSize = (buffer.Length - 1) - HashSize;
}
else
--- 217,221 ----
if (cipherMode == CipherMode.CBC)
{
! fragmentSize = (buffer.Length - (buffer[buffer.Length - 1] + 1)) - HashSize;
}
else
***************
*** 259,263 ****
}
-
private void createEncryptionCipher()
{
--- 259,262 ----
***************
*** 287,290 ****
--- 286,293 ----
sessionState.ClientWriteKey,
sessionState.ClientWriteIV);
+
+ // Clear server keys
+ sessionState.ClientWriteKey = null;
+ sessionState.ClientWriteIV = null;
}
***************
*** 308,312 ****
// Configure encrypt algorithm
decryptionAlgorithm.Mode = this.cipherMode;
! decryptionAlgorithm.Padding = PaddingMode.PKCS7;
decryptionAlgorithm.KeySize = this.keyMaterialSize * 8;
decryptionAlgorithm.BlockSize = this.blockSize * 8;
--- 311,315 ----
// Configure encrypt algorithm
decryptionAlgorithm.Mode = this.cipherMode;
! decryptionAlgorithm.Padding = PaddingMode.None;
decryptionAlgorithm.KeySize = this.keyMaterialSize * 8;
decryptionAlgorithm.BlockSize = this.blockSize * 8;
***************
*** 316,319 ****
--- 319,326 ----
sessionState.ServerWriteKey,
sessionState.ServerWriteIV);
+
+ // Clear server keys
+ sessionState.ServerWriteKey = null;
+ sessionState.ServerWriteIV = null;
}
Index: TlsReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsReader.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TlsReader.cs 23 Aug 2003 19:25:31 -0000 1.3
--- TlsReader.cs 24 Aug 2003 10:46:54 -0000 1.4
***************
*** 287,291 ****
{
case TlsAlertDescription.CloseNotify:
! session.State.ServerConnectionEnd = true;
break;
--- 287,291 ----
{
case TlsAlertDescription.CloseNotify:
! session.State.ConnectionEnd = true;
break;
Index: TlsSession.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSession.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TlsSession.cs 23 Aug 2003 19:25:31 -0000 1.3
--- TlsSession.cs 24 Aug 2003 10:46:54 -0000 1.4
***************
*** 196,204 ****
writer.WriteAlert(alert);
- // Read Close Notify
- reader.ReadRecord();
-
// Check that the session is finished by the client and by server
! if (!state.ClientConnectionEnd || !state.ServerConnectionEnd)
{
throw new TlsException("Invalid session termination");
--- 196,201 ----
writer.WriteAlert(alert);
// Check that the session is finished by the client and by server
! if (!state.ConnectionEnd)
{
throw new TlsException("Invalid session termination");
Index: TlsSessionState.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSessionState.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TlsSessionState.cs 20 Aug 2003 11:48:20 -0000 1.1
--- TlsSessionState.cs 24 Aug 2003 10:46:54 -0000 1.2
***************
*** 27,32 ****
private TlsServerSettings serverSettings;
! private bool serverConnectionEnd;
! private bool clientConnectionEnd;
private TlsCipherSuite cipher;
private int compressionMethod;
--- 27,31 ----
private TlsServerSettings serverSettings;
! private bool connectionEnd;
private TlsCipherSuite cipher;
private int compressionMethod;
***************
*** 57,70 ****
}
! public bool ServerConnectionEnd
! {
! get { return serverConnectionEnd; }
! set { serverConnectionEnd = value; }
! }
!
! public bool ClientConnectionEnd
{
! get { return clientConnectionEnd; }
! set { clientConnectionEnd = value; }
}
--- 56,63 ----
}
! public bool ConnectionEnd
{
! get { return connectionEnd; }
! set { connectionEnd = value; }
}
|
|
From: <car...@us...> - 2003-08-23 19:25:34
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source In directory sc8-pr-cvs1:/tmp/cvs-serv5194 Modified Files: TlsCipherSuite.cs TlsReader.cs TlsSession.cs TlsWriter.cs Log Message: Added changes for correct encryption/decryption of TLS records Index: TlsCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsCipherSuite.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsCipherSuite.cs 20 Aug 2003 15:44:47 -0000 1.2 --- TlsCipherSuite.cs 23 Aug 2003 19:25:31 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- using System; + using System.IO; using System.Text; using System.Security.Cryptography; *************** *** 42,46 **** private byte blockSize; private TlsSessionState sessionState; ! #endregion --- 43,51 ---- private byte blockSize; private TlsSessionState sessionState; ! private SymmetricAlgorithm encryptionAlgorithm; ! private ICryptoTransform encryptionCipher; ! private SymmetricAlgorithm decryptionAlgorithm; ! private ICryptoTransform decryptionCipher; ! #endregion *************** *** 172,202 **** } ! public SymmetricAlgorithm CreateCipherAlgorithm() { ! SymmetricAlgorithm cipher; ! // Create and configure the symmetric algorithm ! switch (this.algName) { ! case "RC4": ! cipher = new ARC4Managed(); ! break; ! default: ! cipher = SymmetricAlgorithm.Create(algName); ! break; } ! // If it's a block cipher if (cipherMode == CipherMode.CBC) { ! // Configure encrypt algorithm ! cipher.Mode = this.cipherMode; ! cipher.Padding = PaddingMode.PKCS7; ! cipher.KeySize = this.keyMaterialSize * 8; ! cipher.BlockSize = this.blockSize * 8; } ! return cipher; } --- 177,232 ---- } ! public void InitializeCipher() { ! createEncryptionCipher(); ! createDecryptionCipher(); ! } ! public byte[] EncryptRecord(byte[] fragment, byte[] mac) ! { ! // Encryption ( fragment + mac [+ padding + padding_length] ) ! MemoryStream ms = new MemoryStream(); ! CryptoStream cs = new CryptoStream(ms, encryptionCipher, CryptoStreamMode.Write); ! ! cs.Write(fragment, 0, fragment.Length); ! cs.Write(mac, 0, mac.Length); ! if (cipherMode == CipherMode.CBC) { ! // Calculate padding_length ! int fragmentLength = fragment.Length + mac.Length + 1; ! int paddingLength = (((fragmentLength/blockSize)*8) + blockSize) - fragmentLength; ! // Write padding length byte ! cs.WriteByte((byte)paddingLength); } + // cs.FlushFinalBlock(); + cs.Close(); ! return ms.ToArray(); ! } ! ! public void DecryptRecord(byte[] fragment, ref byte[] dcrFragment, ref byte[] dcrMAC) ! { ! int fragmentSize = 0; ! ! // Decrypt message fragment ( fragment + mac [+ padding + padding_length] ) ! byte[] buffer = new byte[fragment.Length]; ! decryptionCipher.TransformBlock(fragment, 0, fragment.Length, buffer, 0); ! ! // Calculate fragment size if (cipherMode == CipherMode.CBC) + { + fragmentSize = (buffer.Length - 1) - HashSize; + } + else { ! fragmentSize = buffer.Length - HashSize; } ! dcrFragment = new byte[fragmentSize]; ! dcrMAC = new byte[HashSize]; ! ! System.Array.Copy(buffer, 0, dcrFragment, 0, dcrFragment.Length); ! System.Array.Copy(buffer, dcrFragment.Length, dcrMAC, 0, dcrMAC.Length); } *************** *** 227,230 **** --- 257,319 ---- return integer; } + } + + + private void createEncryptionCipher() + { + // Create and configure the symmetric algorithm + switch (this.algName) + { + case "RC4": + encryptionAlgorithm = new ARC4Managed(); + break; + + default: + encryptionAlgorithm = SymmetricAlgorithm.Create(algName); + break; + } + + // If it's a block cipher + if (cipherMode == CipherMode.CBC) + { + // Configure encrypt algorithm + encryptionAlgorithm.Mode = this.cipherMode; + encryptionAlgorithm.Padding = PaddingMode.PKCS7; + encryptionAlgorithm.KeySize = this.keyMaterialSize * 8; + encryptionAlgorithm.BlockSize = this.blockSize * 8; + } + + encryptionCipher = encryptionAlgorithm.CreateEncryptor( + sessionState.ClientWriteKey, + sessionState.ClientWriteIV); + } + + private void createDecryptionCipher() + { + // Create and configure the symmetric algorithm + switch (this.algName) + { + case "RC4": + decryptionAlgorithm = new ARC4Managed(); + break; + + default: + decryptionAlgorithm = SymmetricAlgorithm.Create(algName); + break; + } + + // If it's a block cipher + if (cipherMode == CipherMode.CBC) + { + // Configure encrypt algorithm + decryptionAlgorithm.Mode = this.cipherMode; + decryptionAlgorithm.Padding = PaddingMode.PKCS7; + decryptionAlgorithm.KeySize = this.keyMaterialSize * 8; + decryptionAlgorithm.BlockSize = this.blockSize * 8; + } + + decryptionCipher = decryptionAlgorithm.CreateDecryptor( + sessionState.ServerWriteKey, + sessionState.ServerWriteIV); } Index: TlsReader.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsReader.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsReader.cs 20 Aug 2003 15:15:50 -0000 1.2 --- TlsReader.cs 23 Aug 2003 19:25:31 -0000 1.3 *************** *** 302,333 **** byte[] fragment) { - TlsSessionState state = session.State; - int fragmentSize = 0; byte[] dcrFragment = null; byte[] dcrMAC = null; ! SymmetricAlgorithm cipher = session.State.Cipher.CreateCipherAlgorithm(); ! ICryptoTransform decryptor = cipher.CreateDecryptor( ! state.ServerWriteKey, ! state.ServerWriteIV); ! ! // Decrypt message fragment ( fragment + mac [+ padding + padding_length] ) ! byte[] buffer = decryptor.TransformFinalBlock(fragment, 0, fragment.Length); ! ! if (session.State.Cipher.CipherMode == CipherMode.CBC) ! { ! fragmentSize = (buffer.Length - 1) - session.State.Cipher.HashSize; ! } ! else ! { ! fragmentSize = buffer.Length - session.State.Cipher.HashSize; ! } ! ! dcrFragment = new byte[fragmentSize]; ! dcrMAC = new byte[session.State.Cipher.HashSize]; ! ! System.Array.Copy(buffer, 0, dcrFragment, 0, dcrFragment.Length); ! System.Array.Copy(buffer, dcrFragment.Length, dcrMAC, 0, dcrMAC.Length); ! // Check MAC code byte[] mac = encodeRecordMAC(contentType, dcrFragment); --- 302,311 ---- byte[] fragment) { byte[] dcrFragment = null; byte[] dcrMAC = null; ! // Decrypt message ! session.State.Cipher.DecryptRecord(fragment, ref dcrFragment, ref dcrMAC); ! // Check MAC code byte[] mac = encodeRecordMAC(contentType, dcrFragment); *************** *** 348,354 **** // Update sequence number session.State.ReadSequenceNumber++; - - // Clear resources - cipher.Clear(); return dcrFragment; --- 326,329 ---- Index: TlsSession.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsSession.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsSession.cs 20 Aug 2003 15:44:47 -0000 1.2 --- TlsSession.cs 23 Aug 2003 19:25:31 -0000 1.3 *************** *** 168,171 **** --- 168,176 ---- writer.WriteRecord(TlsHandshakeType.ClientKeyExchange); + // Now initialize session cipher with the generated keys + state.Cipher.InitializeCipher(); + + #warning "Clear key info that is no more needed" + // Send certificate verify if requested if (state.ServerSettings.CertificateRequest) *************** *** 350,353 **** --- 355,359 ---- } + // Clear no more needed data seed.Reset(); keyBlock.Reset(); *************** *** 430,434 **** */ #warning "Think on implement this as a class derived from KeyedHashAlgorithm" ! internal byte[] hmac(string hashName, byte[] key, byte[] text) { HashAlgorithm hash = HashAlgorithm.Create(hashName); --- 436,440 ---- */ #warning "Think on implement this as a class derived from KeyedHashAlgorithm" ! public byte[] hmac(string hashName, byte[] key, byte[] text) { HashAlgorithm hash = HashAlgorithm.Create(hashName); *************** *** 499,502 **** --- 505,560 ---- #endregion + + /* + public void PrintArray(string text, byte[] array) + { + Console.WriteLine(text); + int count = 0; + for (int i = 0; i < array.Length; i++) + { + Console.Write("{0} ", array[i].ToString("x2").ToUpper()); + if (count == 15) + { + count = 0; + Console.WriteLine(""); + } + else + { + count++; + } + } + Console.WriteLine(""); + } + + public static void SaveToFile(string file, byte[] data) + { + string fileName = "d:\\test\\" + file; + + FileStream stream = new FileStream( + fileName, FileMode.Create, FileAccess.Write); + if (data != null) + { + stream.Write(data, 0, data.Length); + } + else + { + stream.Write(new byte[0], 0, 0); + } + stream.Close(); + } + + public static byte[] ReadFromFile(string file) + { + string fileName = "d:\\test\\" + file; + + FileStream stream = new FileStream( + fileName, FileMode.Open, FileAccess.Read); + byte[] data = new byte[stream.Length]; + stream.Read(data, 0, data.Length); + stream.Close(); + + return data; + } + */ } } Index: TlsWriter.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsWriter.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsWriter.cs 20 Aug 2003 20:29:35 -0000 1.3 --- TlsWriter.cs 23 Aug 2003 19:25:31 -0000 1.4 *************** *** 178,216 **** private byte[] encodeCipherTextRecord(TlsContentType contentType, byte[] fragment) { ! TlsSessionState state = session.State; ! ! byte[] mac = encodeRecordMAC(contentType, fragment); ! ! SymmetricAlgorithm cipher = session.State.Cipher.CreateCipherAlgorithm(); ! ICryptoTransform encryptor = cipher.CreateEncryptor( ! state.ClientWriteKey, ! state.ClientWriteIV); ! ! // Encryption ( fragment + mac [+ padding + padding_length] ) ! MemoryStream ms = new MemoryStream(); ! CryptoStream cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write); ! ! cs.Write(fragment, 0, fragment.Length); ! cs.Write(mac, 0, mac.Length); ! if (session.State.Cipher.CipherMode == CipherMode.CBC) ! { ! // Calculate padding_length ! int fragmentLength = fragment.Length + mac.Length + 1; ! int blockSize = session.State.Cipher.BlockSize; ! int paddingLength = (((fragmentLength/blockSize)*8) + blockSize) - fragmentLength; ! // Write padding length byte ! cs.WriteByte((byte)paddingLength); ! } ! cs.FlushFinalBlock(); ! cs.Close(); // Update sequence number session.State.WriteSequenceNumber++; ! // Clear resources ! cipher.Clear(); ! ! return ms.ToArray(); } --- 178,191 ---- private byte[] encodeCipherTextRecord(TlsContentType contentType, byte[] fragment) { ! // Calculate message MAC ! byte[] mac = encodeRecordMAC(contentType, fragment); ! // Encrypt the message ! byte[] ecr = session.State.Cipher.EncryptRecord(fragment, mac); // Update sequence number session.State.WriteSequenceNumber++; ! return ecr; } *************** *** 224,229 **** data.WriteShort((short)TlsProtocol.Tls1); data.WriteShort((short)fragment.Length); ! data.Write(fragment); ! result = session.hmac(session.State.Cipher.HashName, session.State.ClientWriteMAC, --- 199,204 ---- data.WriteShort((short)TlsProtocol.Tls1); data.WriteShort((short)fragment.Length); ! data.Write(fragment); ! result = session.hmac(session.State.Cipher.HashName, session.State.ClientWriteMAC, |
|
From: <car...@us...> - 2003-08-22 23:22:47
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source
In directory sc8-pr-cvs1:/tmp/cvs-serv24924
Modified Files:
PgDataReader.cs PgErrorCollection.cs PgParameterCollection.cs
Log Message:
Added changes for allow cultureAwareCompare method of some classes to work with mono
Index: PgDataReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgDataReader.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** PgDataReader.cs 7 Aug 2003 10:58:32 -0000 1.6
--- PgDataReader.cs 22 Aug 2003 15:13:50 -0000 1.7
***************
*** 775,779 ****
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (NotSupportedException)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
--- 775,779 ----
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (Exception)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
Index: PgErrorCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgErrorCollection.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgErrorCollection.cs 2 Aug 2003 19:43:01 -0000 1.1.1.1
--- PgErrorCollection.cs 22 Aug 2003 15:13:50 -0000 1.2
***************
*** 106,110 ****
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (NotSupportedException)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
--- 106,110 ----
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (Exception)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
Index: PgParameterCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgParameterCollection.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgParameterCollection.cs 12 Aug 2003 14:25:05 -0000 1.2
--- PgParameterCollection.cs 22 Aug 2003 15:13:50 -0000 1.3
***************
*** 257,261 ****
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (NotSupportedException)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
--- 257,261 ----
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (Exception)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient
In directory sc8-pr-cvs1:/tmp/cvs-serv24452
Modified Files:
PgCharSetCollection.cs PgClientErrorCollection.cs
PgTypeCollection.cs
Log Message:
Added changes for allow cultureAwareCompare method of some classes to work with mono
Index: PgCharSetCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgCharSetCollection.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgCharSetCollection.cs 2 Aug 2003 19:43:02 -0000 1.1.1.1
--- PgCharSetCollection.cs 22 Aug 2003 15:13:36 -0000 1.2
***************
*** 99,103 ****
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (NotSupportedException)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
--- 99,103 ----
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (Exception)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
Index: PgClientErrorCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgClientErrorCollection.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgClientErrorCollection.cs 2 Aug 2003 19:43:02 -0000 1.1.1.1
--- PgClientErrorCollection.cs 22 Aug 2003 15:13:36 -0000 1.2
***************
*** 87,91 ****
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (NotSupportedException)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
--- 87,91 ----
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (Exception)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
Index: PgTypeCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgTypeCollection.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgTypeCollection.cs 2 Aug 2003 21:12:16 -0000 1.2
--- PgTypeCollection.cs 22 Aug 2003 15:13:36 -0000 1.3
***************
*** 124,128 ****
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (NotSupportedException)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
--- 124,128 ----
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false;
}
! catch (Exception)
{
return strA.ToUpper() == strB.ToUpper() ? true : false;
|
|
From: <car...@us...> - 2003-08-22 22:22:44
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv27221 Modified Files: changelog.txt Log Message: Updated CHANGELOG.TXT Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changelog.txt,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** changelog.txt 20 Aug 2003 11:57:54 -0000 1.19 --- changelog.txt 22 Aug 2003 15:14:32 -0000 1.20 *************** *** 3,6 **** --- 3,11 ---- + 2003-08-22 Carlos Guzmán Álvarez <car...@te...> + + * Added changes for allow cultureAwareCompare method of some classes to work with mono. + + 2003-08-20 Carlos Guzmán Álvarez <car...@te...> |
|
From: <car...@us...> - 2003-08-22 20:15:28
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source
In directory sc8-pr-cvs1:/tmp/cvs-serv12401
Modified Files:
TlsCipherSuiteCollection.cs TlsWriter.cs
Log Message:
Cleanup
Index: TlsCipherSuiteCollection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsCipherSuiteCollection.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TlsCipherSuiteCollection.cs 20 Aug 2003 15:15:50 -0000 1.2
--- TlsCipherSuiteCollection.cs 20 Aug 2003 20:29:35 -0000 1.3
***************
*** 61,65 ****
// 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) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", "3DES", "SHA", false, true, 24, 24, 168, 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);
--- 61,64 ----
***************
*** 68,73 ****
// 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);
-
// Diffie-Hellman Cipher Suites
// scs.Add((0x00 << 0x08) | 0x0B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA", true, true, 5, 8, 40, 8, 8);
--- 67,72 ----
// 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
// scs.Add((0x00 << 0x08) | 0x0B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", "DES", "SHA", true, true, 5, 8, 40, 8, 8);
Index: TlsWriter.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PgSqlClient.Security.Tls/source/TlsWriter.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TlsWriter.cs 20 Aug 2003 15:15:50 -0000 1.2
--- TlsWriter.cs 20 Aug 2003 20:29:35 -0000 1.3
***************
*** 178,190 ****
private byte[] encodeCipherTextRecord(TlsContentType contentType, byte[] fragment)
{
- TlsStreamWriter record = new TlsStreamWriter();
TlsSessionState state = session.State;
byte[] mac = encodeRecordMAC(contentType, fragment);
!
! SymmetricAlgorithm cipher = session.State.Cipher.CreateCipherAlgorithm();
! ICryptoTransform encryptor = cipher.CreateEncryptor(
! state.ClientWriteKey,
! state.ClientWriteIV);
// Encryption ( fragment + mac [+ padding + padding_length] )
--- 178,189 ----
private byte[] encodeCipherTextRecord(TlsContentType contentType, byte[] fragment)
{
TlsSessionState state = session.State;
byte[] mac = encodeRecordMAC(contentType, fragment);
!
! SymmetricAlgorithm cipher = session.State.Cipher.CreateCipherAlgorithm();
! ICryptoTransform encryptor = cipher.CreateEncryptor(
! state.ClientWriteKey,
! state.ClientWriteIV);
// Encryption ( fragment + mac [+ padding + padding_length] )
***************
*** 207,212 ****
cs.Close();
- record.Write(ms.ToArray());
-
// Update sequence number
session.State.WriteSequenceNumber++;
--- 206,209 ----
***************
*** 215,219 ****
cipher.Clear();
! return record.GetBytes();
}
--- 212,216 ----
cipher.Clear();
! return ms.ToArray();
}
***************
*** 223,228 ****
byte[] result = null;
- byte[] b = BitConverter.GetBytes(session.State.WriteSequenceNumber);
- bool le = BitConverter.IsLittleEndian;
data.WriteLong(session.State.WriteSequenceNumber);
data.Write((byte)contentType);
--- 220,223 ----
|
|
From: <car...@us...> - 2003-08-22 20:02:58
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient
In directory sc8-pr-cvs1:/tmp/cvs-serv6217
Modified Files:
PgDbClient.cs
Log Message:
Added fix for work with mono
Index: PgDbClient.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDbClient.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PgDbClient.cs 20 Aug 2003 14:27:50 -0000 1.5
--- PgDbClient.cs 22 Aug 2003 15:53:31 -0000 1.6
***************
*** 720,726 ****
charSets = new PgCharSetCollection();
! charSets.Add("SQL_ASCII", "ascii"); // ASCII
! charSets.Add("EUC_JP" , "euc-jp"); // Japanese EUC
! charSets.Add("EUC_CN" , "euc-cn"); // Chinese EUC
charSets.Add("UNICODE" , "UTF-8"); // Unicode (UTF-8)
charSets.Add("LATIN1" , "iso-8859-1"); // ISO 8859-1/ECMA 94 (Latin alphabet no.1)
--- 720,732 ----
charSets = new PgCharSetCollection();
! charSets.Add("SQL_ASCII", "ascii"); // ASCII
! try
! {
! charSets.Add("EUC_JP" , "euc-jp"); // Japanese EUC
! charSets.Add("EUC_CN" , "euc-cn"); // Chinese EUC
! }
! catch (Exception)
! {
! }
charSets.Add("UNICODE" , "UTF-8"); // Unicode (UTF-8)
charSets.Add("LATIN1" , "iso-8859-1"); // ISO 8859-1/ECMA 94 (Latin alphabet no.1)
|
|
From: <car...@us...> - 2003-08-22 19:50:37
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv964 Modified Files: changes.txt Log Message: Updated changes.txt Index: changes.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changes.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** changes.txt 7 Aug 2003 21:44:39 -0000 1.5 --- changes.txt 22 Aug 2003 19:50:31 -0000 1.6 *************** *** 3,11 **** ! Alpha 3 ( XX-08-2003 ) ----- - - -- -- ---- - * Improved PgDataReader.GetSchemaTable method using prepared statemets for retrieve column and primary key information. --- 3,17 ---- ! Alpha 4 ( XX-08-2003 ) ----- - - -- -- ---- - + * Better fit to ADO.NET. + + * Improved Command Builder implementation. + * Improved PgDataReader.GetSchemaTable method using prepared statemets for retrieve column and primary key information. + + * Added SQL Server like Stored Procedure calls. |
|
From: <car...@us...> - 2003-08-22 19:42:12
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv30710 Modified Files: changelog.txt Log Message: Updated changelog.txt Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changelog.txt,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** changelog.txt 22 Aug 2003 15:14:32 -0000 1.20 --- changelog.txt 22 Aug 2003 19:42:07 -0000 1.21 *************** *** 7,10 **** --- 7,17 ---- * Added changes for allow cultureAwareCompare method of some classes to work with mono. + * Added new test case for PgCommandBuilder class. + + * source/PgConnection.cs: + * source/PgCommandBuilder.cs: + + - Added changes for better fit to ADO.NET. + 2003-08-20 Carlos Guzmán Álvarez <car...@te...> |
|
From: <car...@us...> - 2003-08-22 19:40:42
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient.UnitTests/source
In directory sc8-pr-cvs1:/tmp/cvs-serv30441
Modified Files:
PgCommandBuilderTest.cs
Log Message:
Added a new test case for PgCommandBuilder
Index: PgCommandBuilderTest.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient.UnitTests/source/PgCommandBuilderTest.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgCommandBuilderTest.cs 15 Aug 2003 17:51:20 -0000 1.2
--- PgCommandBuilderTest.cs 22 Aug 2003 19:40:36 -0000 1.3
***************
*** 146,149 ****
--- 146,181 ----
}
}
+
+ [Test]
+ public void TestWithClosedConnection()
+ {
+ Connection.Close();
+
+ PgCommand command = new PgCommand("select * from public.test_table where int4_field = @int4_field and varchar_field = @varchar_field", Connection);
+ PgDataAdapter adapter = new PgDataAdapter(command);
+ PgCommandBuilder builder = new PgCommandBuilder(adapter);
+
+ Console.WriteLine();
+ Console.WriteLine("\r\nPgCommandBuilder - RefreshSchema Method Test - Commands for original SQL statement: ");
+
+ Console.WriteLine(builder.GetInsertCommand().CommandText);
+ Console.WriteLine(builder.GetUpdateCommand().CommandText);
+ Console.WriteLine(builder.GetDeleteCommand().CommandText);
+
+ adapter.SelectCommand.CommandText = "select int4_field, date_field from public.test_table where int4_field = @int4_field";
+
+ builder.RefreshSchema();
+
+ Console.WriteLine();
+ Console.WriteLine("\r\nPgCommandBuilder - RefreshSchema Method Test - Commands for new SQL statement: ");
+
+ Console.WriteLine(builder.GetInsertCommand().CommandText);
+ Console.WriteLine(builder.GetUpdateCommand().CommandText);
+ Console.WriteLine(builder.GetDeleteCommand().CommandText);
+
+ builder.Dispose();
+ adapter.Dispose();
+ command.Dispose();
+ }
}
}
|
|
From: <car...@us...> - 2003-08-22 19:40:02
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source
In directory sc8-pr-cvs1:/tmp/cvs-serv30315
Modified Files:
PgCommand.cs PgCommandBuilder.cs
Log Message:
Fixed error with latest commit
Index: PgCommand.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommand.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PgCommand.cs 15 Aug 2003 17:49:05 -0000 1.4
--- PgCommand.cs 22 Aug 2003 19:39:58 -0000 1.5
***************
*** 244,248 ****
if (disposing)
{
! connection.ActiveCommands.Remove(this);
// release any managed resources
--- 244,251 ----
if (disposing)
{
! if (connection.ActiveCommands != null)
! {
! connection.ActiveCommands.Remove(this);
! }
// release any managed resources
Index: PgCommandBuilder.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommandBuilder.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PgCommandBuilder.cs 22 Aug 2003 19:17:31 -0000 1.4
--- PgCommandBuilder.cs 22 Aug 2003 19:39:58 -0000 1.5
***************
*** 233,237 ****
try
{
- bool mustClose = false;
if (dataAdapter.SelectCommand.Connection.State == ConnectionState.Closed)
{
--- 233,236 ----
***************
*** 266,270 ****
try
{
- bool mustClose = false;
if (dataAdapter.SelectCommand.Connection.State == ConnectionState.Closed)
{
--- 265,268 ----
***************
*** 299,303 ****
try
{
- bool mustClose = false;
if (dataAdapter.SelectCommand.Connection.State == ConnectionState.Closed)
{
--- 297,300 ----
|
|
From: <car...@us...> - 2003-08-22 19:18:20
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source In directory sc8-pr-cvs1:/tmp/cvs-serv26774 Modified Files: PgConnection.cs Log Message: - Added changes for better fit to ADO.NET. Index: PgConnection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgConnection.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PgConnection.cs 2 Aug 2003 19:43:00 -0000 1.1.1.1 --- PgConnection.cs 22 Aug 2003 19:18:12 -0000 1.2 *************** *** 216,219 **** --- 216,220 ---- Close(); + dbConnection = null; connectionString = null; } *************** *** 437,441 **** { dbConnection.Disconnect(); - dbConnection = null; } } --- 438,441 ---- |
|
From: <car...@us...> - 2003-08-22 19:17:38
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source In directory sc8-pr-cvs1:/tmp/cvs-serv26642 Modified Files: PgCommandBuilder.cs Log Message: - Added changes for better fit to ADO.NET. Index: PgCommandBuilder.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommandBuilder.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PgCommandBuilder.cs 15 Aug 2003 17:49:05 -0000 1.3 --- PgCommandBuilder.cs 22 Aug 2003 19:17:31 -0000 1.4 *************** *** 230,235 **** if (insertCommand == null) { ! buildSchemaTable(); ! buildInsertCommand(null, null); } --- 230,257 ---- if (insertCommand == null) { ! bool mustClose = false; ! try ! { ! bool mustClose = false; ! if (dataAdapter.SelectCommand.Connection.State == ConnectionState.Closed) ! { ! mustClose = true; ! dataAdapter.SelectCommand.Connection.Open(); ! } ! ! buildSchemaTable(); ! buildInsertCommand(null, null); ! } ! catch (Exception ex) ! { ! throw ex; ! } ! finally ! { ! if (mustClose) ! { ! dataAdapter.SelectCommand.Connection.Close(); ! } ! } } *************** *** 241,246 **** if (updateCommand == null) { ! buildSchemaTable(); ! buildUpdateCommand(null, null); } --- 263,290 ---- if (updateCommand == null) { ! bool mustClose = false; ! try ! { ! bool mustClose = false; ! if (dataAdapter.SelectCommand.Connection.State == ConnectionState.Closed) ! { ! mustClose = true; ! dataAdapter.SelectCommand.Connection.Open(); ! } ! ! buildSchemaTable(); ! buildUpdateCommand(null, null); ! } ! catch (Exception ex) ! { ! throw ex; ! } ! finally ! { ! if (mustClose) ! { ! dataAdapter.SelectCommand.Connection.Close(); ! } ! } } *************** *** 252,257 **** if (deleteCommand == null) { ! buildSchemaTable(); ! buildDeleteCommand(null, null); } --- 296,323 ---- if (deleteCommand == null) { ! bool mustClose = false; ! try ! { ! bool mustClose = false; ! if (dataAdapter.SelectCommand.Connection.State == ConnectionState.Closed) ! { ! mustClose = true; ! dataAdapter.SelectCommand.Connection.Open(); ! } ! ! buildSchemaTable(); ! buildDeleteCommand(null, null); ! } ! catch (Exception ex) ! { ! throw ex; ! } ! finally ! { ! if (mustClose) ! { ! dataAdapter.SelectCommand.Connection.Close(); ! } ! } } *************** *** 686,690 **** } ! try { buildSchemaTable(); --- 752,757 ---- } ! bool mustClose = false; ! try { buildSchemaTable(); *************** *** 718,721 **** --- 785,795 ---- e.Errors = exception; e.Status = UpdateStatus.ErrorsOccurred; + } + finally + { + if (mustClose) + { + dataAdapter.SelectCommand.Connection.Close(); + } } } |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient
In directory sc8-pr-cvs1:/tmp/cvs-serv21067
Modified Files:
PgDbClient.cs PgInetReader.cs PgInetWriter.cs
PgResponsePacket.cs PgStatement.cs
Log Message:
Added initial release of a simple TLS protocol implementation,
it uses tree files from the Mono project that are under the MIT X11
license.
Index: PgDbClient.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDbClient.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PgDbClient.cs 15 Aug 2003 17:50:09 -0000 1.3
--- PgDbClient.cs 20 Aug 2003 11:53:19 -0000 1.4
***************
*** 25,29 ****
using System.Text;
! //using PgSqlClient.Security.TLS;
namespace PostgreSql.Data.NPgClient
--- 25,30 ----
using System.Text;
! using PgSqlClient.Security.TLS;
! using PgSqlClient.Security.TLS.Alerts;
namespace PostgreSql.Data.NPgClient
***************
*** 52,59 ****
private Socket socket;
private NetworkStream networkStream;
! private PgInetWriter send;
! private PgInetReader receive;
private PgConnectionParams settings;
private char transactionStatus;
#endregion
--- 53,61 ----
private Socket socket;
private NetworkStream networkStream;
! private TlsWriter send;
! private TlsReader receive;
private PgConnectionParams settings;
private char transactionStatus;
+ private TlsSession session;
#endregion
***************
*** 100,109 ****
}
! public PgInetReader Receive
{
get { return receive; }
}
! public PgInetWriter Send
{
get { return send; }
--- 102,111 ----
}
! public TlsReader Receive
{
get { return receive; }
}
! public TlsWriter Send
{
get { return send; }
***************
*** 140,148 ****
PgDbClient.InitializeTypes();
PgDbClient.InitializeCharSets();
-
- InitializeSocket();
lock (this)
{
if (settings.SSL)
{
--- 142,152 ----
PgDbClient.InitializeTypes();
PgDbClient.InitializeCharSets();
lock (this)
{
+ session = new TlsSession(new TlsSessionSettings(TlsProtocol.Tls1));
+
+ initializeSocket();
+
if (settings.SSL)
{
***************
*** 152,165 ****
if (settings.SSL)
{
- /*
- TlsSession session = new TlsSession(new TlsSessionSettings(TlsProtocol.Tls1));
-
- TlsWriter tlsSend = session.GetWriter(new BufferedStream(this.networkStream));
- TlsReader tlsRead = session.GetReader(new BufferedStream(this.networkStream));
-
try
{
// Start TLS Session
session.StartSession();
}
catch (TlsException ex)
--- 156,170 ----
if (settings.SSL)
{
try
{
// Start TLS Session
session.StartSession();
+
+ send.WriteRecord(Encoding.Default.GetBytes("GET / HTTP/1.0"));
+
+ byte[] r = receive.ReadRecord();
+
+ // End TLS Session
+ session.EndSession();
}
catch (TlsException ex)
***************
*** 172,176 ****
throw new PgClientException(ex.Message);
}
- */
}
}
--- 177,180 ----
***************
*** 189,194 ****
packet.Write((byte)0); // Terminator
! send.Write(packet.GetSimplePacketBytes());
! send.Flush();
PgResponsePacket response = new PgResponsePacket();
--- 193,197 ----
packet.Write((byte)0); // Terminator
! SendData(packet.GetSimplePacketBytes());
PgResponsePacket response = new PgResponsePacket();
***************
*** 216,221 ****
PgOutputPacket packet = new PgOutputPacket();
! send.Write(packet.GetPacketBytes(PgFrontEndCodes.TERMINATE));
! send.Flush();
// Close socket and streams
--- 219,223 ----
PgOutputPacket packet = new PgOutputPacket();
! SendData(packet.GetPacketBytes(PgFrontEndCodes.TERMINATE));
// Close socket and streams
***************
*** 236,239 ****
--- 238,254 ----
}
+ internal void SendData(byte[] data)
+ {
+ if (settings.SSL)
+ {
+ send.WriteRecord(data);
+ }
+ else
+ {
+ send.Write(data);
+ }
+
+ send.Flush();
+ }
#endregion
***************
*** 245,299 ****
char type;
int length;
! PgResponsePacket responsePacket;
lock (this)
{
length = 0;
! type = (char)receive.ReadByte();
! if ((sslRequest.Length > 0 && !sslRequest[0]) || type == PgBackendCodes.ERROR_RESPONSE)
! {
! length = receive.ReadInt() - 4;
! }
!
! if (length != 0)
{
! responsePacket = new PgResponsePacket(type, receive.ReadBytes(length));
}
else
{
! responsePacket = new PgResponsePacket(type, new byte[0]);
! }
! responsePacket.Encoding = Settings.Encoding;
! }
! switch (type)
! {
! case PgBackendCodes.ERROR_RESPONSE:
! {
! // Read the error message and trow the exception
! PgClientException ex = processErrorPacket(responsePacket);
! throw ex;
! }
! case PgBackendCodes.NOTICE_RESPONSE:
! {
! // Read the notice message and raise an InfoMessage event
! PgClientException ex = processErrorPacket(responsePacket);
! this.InfoMessage(this, new PgClientMessageEventArgs(ex));
! }
! break;
! case PgBackendCodes.NOTIFICATION_RESPONSE:
! {
! processNotificationResponse(responsePacket);
}
- break;
! default:
! break;
! }
return responsePacket;
--- 260,338 ----
char type;
int length;
! PgResponsePacket responsePacket = null;
lock (this)
{
length = 0;
! if ((sslRequest.Length > 0 && sslRequest[0]))
{
! type = receive.ReadChar();
! return new PgResponsePacket(type, new byte[0]);
}
else
{
! if (settings.SSL)
! {
! // TLS/SSL Application data contents
! PgResponsePacket tmpPacket = new PgResponsePacket(receive.ReadRecord());
! type = tmpPacket.ReadChar();
! length = tmpPacket.ReadInt() - 4;
! if (length != 0)
! {
! responsePacket = new PgResponsePacket(type, tmpPacket.ReadBytes(length));
! }
! tmpPacket.Reset();
! }
! else
! {
! type = (char)receive.ReadByte();
! length = IPAddress.HostToNetworkOrder(receive.ReadInt32()) - 4;
! if (length != 0)
! {
! responsePacket = new PgResponsePacket(type, receive.ReadBytes(length));
! }
! }
! if (length == 0)
! {
! responsePacket = new PgResponsePacket(type, new byte[0]);
! }
! switch (type)
! {
! case PgBackendCodes.ERROR_RESPONSE:
! {
! // Read the error message and trow the exception
! PgClientException ex = processErrorPacket(responsePacket);
!
! throw ex;
! }
!
! case PgBackendCodes.NOTICE_RESPONSE:
! {
! // Read the notice message and raise an InfoMessage event
! PgClientException ex = processErrorPacket(responsePacket);
!
! this.InfoMessage(this, new PgClientMessageEventArgs(ex));
! }
! break;
!
! case PgBackendCodes.NOTIFICATION_RESPONSE:
! {
! processNotificationResponse(responsePacket);
! }
! break;
!
! default:
! break;
! }
}
! responsePacket.Encoding = Settings.Encoding;
! }
return responsePacket;
***************
*** 393,398 ****
// Send the packet to the server
! send.Write(outPacket.GetPacketBytes(PgFrontEndCodes.PASSWORD_MESSAGE));
! send.Flush();
}
--- 432,436 ----
// Send the packet to the server
! SendData(outPacket.GetPacketBytes(PgFrontEndCodes.PASSWORD_MESSAGE));
}
***************
*** 541,546 ****
// Send packet to the server
! send.Write(packet.GetPacketBytes(PgFrontEndCodes.FLUSH));
! send.Flush();
}
catch (Exception ex)
--- 579,583 ----
// Send packet to the server
! SendData(packet.GetPacketBytes(PgFrontEndCodes.FLUSH));
}
catch (Exception ex)
***************
*** 560,565 ****
// Send packet to the server
! send.Write(packet.GetPacketBytes(PgFrontEndCodes.SYNC));
! send.Flush();
}
catch (Exception ex)
--- 597,601 ----
// Send packet to the server
! SendData(packet.GetPacketBytes(PgFrontEndCodes.SYNC));
}
catch (Exception ex)
***************
*** 584,589 ****
// Send packet to the server
! send.Write(packet.GetSimplePacketBytes());
! send.Flush();
}
catch (Exception ex)
--- 620,624 ----
// Send packet to the server
! SendData(packet.GetSimplePacketBytes());
}
catch (Exception ex)
***************
*** 598,601 ****
--- 633,638 ----
lock (this)
{
+ settings.SSL = false;
+
try
{
***************
*** 605,610 ****
// Send packet to the server
! send.Write(packet.GetSimplePacketBytes());
! send.Flush();
// Receive server response
--- 642,646 ----
// Send packet to the server
! SendData(packet.GetSimplePacketBytes());
// Receive server response
***************
*** 735,739 ****
}
! public void InitializeSocket()
{
IPAddress hostadd = Dns.Resolve(settings.ServerName).AddressList[0];
--- 771,779 ----
}
! #endregion
!
! #region PRIVATE_METHODS
!
! private void initializeSocket()
{
IPAddress hostadd = Dns.Resolve(settings.ServerName).AddressList[0];
***************
*** 748,753 ****
networkStream = new NetworkStream(socket, true);
! send = new PgInetWriter(new BufferedStream(networkStream));
! receive = new PgInetReader(new BufferedStream(networkStream));
}
--- 788,794 ----
networkStream = new NetworkStream(socket, true);
! // Create streams for read/write operations
! send = session.GetWriter(networkStream);
! receive = session.GetReader(networkStream);
}
Index: PgInetReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgInetReader.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgInetReader.cs 2 Aug 2003 19:43:02 -0000 1.1.1.1
--- PgInetReader.cs 20 Aug 2003 11:53:19 -0000 1.2
***************
*** 22,37 ****
using System.Net;
namespace PostgreSql.Data.NPgClient
{
! internal class PgInetReader : BinaryReader
{
- #region CONTRUCTORS
-
- public PgInetReader(Stream input) : base(input)
- {
- }
-
- #endregion
-
#region METHODS
--- 22,31 ----
using System.Net;
+ using PgSqlClient.Security.TLS;
+
namespace PostgreSql.Data.NPgClient
{
! internal class PgInetReader : TlsReader
{
#region METHODS
Index: PgInetWriter.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgInetWriter.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgInetWriter.cs 15 Aug 2003 17:50:09 -0000 1.2
--- PgInetWriter.cs 20 Aug 2003 11:53:19 -0000 1.3
***************
*** 22,65 ****
using System.Net;
namespace PostgreSql.Data.NPgClient
{
! internal class PgInetWriter : BinaryWriter
{
- #region CONSTRUCTORS
-
- public PgInetWriter(Stream output) : base(output)
- {
- }
-
- #endregion
-
- #region METHODS
-
- /*
- public void WriteSimplePacket(PgOutputPacket packet)
- {
- // Write packet contents
- packet.Position = 0;
- packet.WriteInt(packet.GetByteCount() + 1);
- Write(packet.GetBytes());
-
- Flush();
- }
-
- public void WritePacket(char format, PgOutputPacket packet)
- {
- // Update packet Length
- packet.Position = 0;
-
- packet.Write((byte)format);
- packet.WriteInt(packet.GetByteCount());
-
- // Write packet contents
- Write(packet.GetBytes());
-
- Flush();
- }
- */
- #endregion
}
}
--- 22,31 ----
using System.Net;
+ using PgSqlClient.Security.TLS;
+
namespace PostgreSql.Data.NPgClient
{
! internal class PgInetWriter : TlsWriter
{
}
}
Index: PgResponsePacket.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgResponsePacket.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgResponsePacket.cs 2 Aug 2003 19:43:02 -0000 1.1.1.1
--- PgResponsePacket.cs 20 Aug 2003 11:53:19 -0000 1.2
***************
*** 57,63 ****
--- 57,77 ----
}
+ public PgResponsePacket(byte[] contents) : base(new MemoryStream(contents))
+ {
+ }
+
public PgResponsePacket(char message, byte[] contents) : base(new MemoryStream(contents))
{
this.message = message;
+ }
+
+ #endregion
+
+ #region STREAM_METHODS
+
+ public void Reset()
+ {
+ ((MemoryStream)BaseStream).SetLength(0);
+ ((MemoryStream)BaseStream).Position = 0;
}
Index: PgStatement.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgStatement.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgStatement.cs 15 Aug 2003 17:50:09 -0000 1.2
--- PgStatement.cs 20 Aug 2003 11:53:19 -0000 1.3
***************
*** 190,196 ****
// Send packet to the server
! db.Send.Write(packet.GetPacketBytes(PgFrontEndCodes.PARSE));
! db.Send.Flush();
!
// Sync server and client
db.Flush();
--- 190,195 ----
// Send packet to the server
! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.PARSE));
!
// Sync server and client
db.Flush();
***************
*** 240,246 ****
// Send packet to the server
! db.Send.Write(packet.GetPacketBytes(PgFrontEndCodes.DESCRIBE));
! db.Send.Flush();
!
// Sync server and client
db.Flush();
--- 239,244 ----
// Send packet to the server
! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.DESCRIBE));
!
// Sync server and client
db.Flush();
***************
*** 309,315 ****
// Send packet to the server
! db.Send.Write(packet.GetPacketBytes(PgFrontEndCodes.BIND));
! db.Send.Flush();
!
// Sync server and client
db.Flush();
--- 307,312 ----
// Send packet to the server
! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.BIND));
!
// Sync server and client
db.Flush();
***************
*** 344,349 ****
// Send packet to the server
! db.Send.Write(packet.GetPacketBytes(PgFrontEndCodes.EXECUTE));
! db.Send.Flush();
// Sync server and client
--- 341,345 ----
// Send packet to the server
! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.EXECUTE));
// Sync server and client
***************
*** 400,406 ****
// Send packet to the server
! db.Send.Write(packet.GetPacketBytes(PgFrontEndCodes.FUNCTION_CALL));
! db.Send.Flush();
!
// Receive response
PgResponsePacket response = db.ReceiveResponsePacket();
--- 396,401 ----
// Send packet to the server
! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.FUNCTION_CALL));
!
// Receive response
PgResponsePacket response = db.ReceiveResponsePacket();
***************
*** 431,436 ****
// Send packet to the server
! db.Send.Write(packet.GetPacketBytes(PgFrontEndCodes.QUERY));
! db.Send.Flush();
// Receive response
--- 426,430 ----
// Send packet to the server
! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.QUERY));
// Receive response
***************
*** 503,508 ****
// Send packet to the server
! db.Send.Write(packet.GetPacketBytes(PgFrontEndCodes.CLOSE));
! db.Send.Flush();
// Sync server and client
--- 497,501 ----
// Send packet to the server
! db.SendData(packet.GetPacketBytes(PgFrontEndCodes.CLOSE));
// Sync server and client
|
|
From: <car...@us...> - 2003-08-20 18:02:06
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1:/tmp/cvs-serv21346 Removed Files: PgInetReader.cs PgInetWriter.cs Log Message: Removed no more needed files --- PgInetReader.cs DELETED --- --- PgInetWriter.cs DELETED --- |