Thread: [pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls SslClie
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2004-02-19 16:55:12
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32629 Modified Files: SslClientStream.cs TlsCipherSuiteFactory.cs Log Message: - Changes to the sync code. Index: SslClientStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SslClientStream.cs 19 Feb 2004 13:54:09 -0000 1.9 --- SslClientStream.cs 19 Feb 2004 16:44:38 -0000 1.10 *************** *** 77,82 **** private bool disposed; private bool checkCertRevocationStatus; ! private string read; ! private string write; #endregion --- 77,82 ---- private bool disposed; private bool checkCertRevocationStatus; ! private object read; ! private object write; #endregion *************** *** 446,492 **** } ! if (!this.context.HandshakeFinished) { ! this.doHandshake(); // Handshake negotiation } if (!Monitor.TryEnter(this.read)) { throw new InvalidOperationException("A read operation is already in progress."); } IAsyncResult asyncResult; ! try { ! System.Threading.Monitor.Enter(this.read); ! ! // If actual buffer is full readed reset it ! if (this.inputBuffer.Position == this.inputBuffer.Length && ! this.inputBuffer.Length > 0) ! { ! this.resetBuffer(); ! } ! ! // Check if we have space in the middle buffer ! // if not Read next TLS record and update the inputBuffer ! while ((this.inputBuffer.Length - this.inputBuffer.Position) < count) { ! // Read next record and write it into the inputBuffer ! long position = this.inputBuffer.Position; ! byte[] record = this.protocol.ReceiveRecord(); ! ! if (record != null && record.Length > 0) { ! // Write new data to the inputBuffer ! this.inputBuffer.Seek(0, SeekOrigin.End); ! this.inputBuffer.Write(record, 0, record.Length); ! ! // Restore buffer position ! this.inputBuffer.Seek(position, SeekOrigin.Begin); } ! else { ! if (record == null) { break; --- 446,509 ---- } ! lock (this) { ! if (!this.context.HandshakeFinished) ! { ! this.doHandshake(); // Handshake negotiation ! } } + /* if (!Monitor.TryEnter(this.read)) { throw new InvalidOperationException("A read operation is already in progress."); } + System.Threading.Monitor.Enter(this.read); + */ IAsyncResult asyncResult; ! lock (this.read) { ! try { ! // If actual buffer is full readed reset it ! if (this.inputBuffer.Position == this.inputBuffer.Length && ! this.inputBuffer.Length > 0) { ! this.resetBuffer(); } ! ! // Check if we have space in the middle buffer ! // if not Read next TLS record and update the inputBuffer ! while ((this.inputBuffer.Length - this.inputBuffer.Position) < count) { ! // Read next record and write it into the inputBuffer ! long position = this.inputBuffer.Position; ! byte[] record = this.protocol.ReceiveRecord(); ! ! if (record != null && record.Length > 0) ! { ! // Write new data to the inputBuffer ! this.inputBuffer.Seek(0, SeekOrigin.End); ! this.inputBuffer.Write(record, 0, record.Length); ! ! // Restore buffer position ! this.inputBuffer.Seek(position, SeekOrigin.Begin); ! } ! else ! { ! if (record == null) ! { ! break; ! } ! } ! ! // TODO: Review if we need to check the Length ! // property of the innerStream for other types ! // of streams, to check that there are data available ! // for read ! if (this.innerStream is NetworkStream && ! !((NetworkStream)this.innerStream).DataAvailable) { break; *************** *** 494,523 **** } ! // TODO: Review if we need to check the Length ! // property of the innerStream for other types ! // of streams, to check that there are data available ! // for read ! if (this.innerStream is NetworkStream && ! !((NetworkStream)this.innerStream).DataAvailable) ! { ! break; ! } } - - asyncResult = this.inputBuffer.BeginRead( - buffer, offset, count, callback, state); - } - catch (TlsException ex) - { - throw new IOException("The authentication or decryption has failed.", ex); - } - catch (Exception ex) - { - throw new IOException("IO exception during read.", ex); } finally { ! System.Threading.Monitor.Exit(this.read); } return asyncResult; --- 511,532 ---- } ! asyncResult = this.inputBuffer.BeginRead( ! buffer, offset, count, callback, state); ! } ! catch (TlsException ex) ! { ! throw new IOException("The authentication or decryption has failed.", ex); ! } ! catch (Exception ex) ! { ! throw new IOException("IO exception during read.", ex); } } + /* finally { ! Monitor.Exit(this.read); } + */ return asyncResult; *************** *** 554,593 **** } ! if (!this.context.HandshakeFinished) { ! // Start handshake negotiation ! this.doHandshake(); } if (!Monitor.TryEnter(this.write)) { throw new InvalidOperationException("A write operation is already in progress."); } IAsyncResult asyncResult; ! try { ! Monitor.Enter(this.write); ! ! // Send the buffer as a TLS record ! byte[] record = this.protocol.EncodeRecord( ! TlsContentType.ApplicationData, buffer, offset, count); ! asyncResult = this.innerStream.BeginWrite( ! record, 0, record.Length, callback, state); ! } ! catch (TlsException ex) ! { ! throw new IOException("The authentication or decryption has failed.", ex); ! } ! catch (Exception ex) ! { ! throw new IOException("IO exception during Write.", ex); } finally { Monitor.Exit(this.write); ! } return asyncResult; --- 563,613 ---- } ! lock (this) { ! if (!this.context.HandshakeFinished) ! { ! // Start handshake negotiation ! this.doHandshake(); ! } } + /* if (!Monitor.TryEnter(this.write)) { throw new InvalidOperationException("A write operation is already in progress."); } + Monitor.Enter(this.write); + */ IAsyncResult asyncResult; ! lock (this.write) { ! try ! { ! // Send the buffer as a TLS record ! byte[] record = this.protocol.EncodeRecord( ! TlsContentType.ApplicationData, buffer, offset, count); ! ! asyncResult = this.innerStream.BeginWrite( ! record, 0, record.Length, callback, state); ! } ! catch (TlsException ex) ! { ! throw new IOException("The authentication or decryption has failed.", ex); ! } ! catch (Exception ex) ! { ! throw new IOException("IO exception during Write.", ex); ! } } + + /* finally { Monitor.Exit(this.write); ! } ! */ return asyncResult; Index: TlsCipherSuiteFactory.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsCipherSuiteFactory.cs 17 Feb 2004 17:52:12 -0000 1.3 --- TlsCipherSuiteFactory.cs 19 Feb 2004 16:44:38 -0000 1.4 *************** *** 66,70 **** // scs.Add((0x00 << 0x08) | 0x01, "TLS_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); // scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSignKeyX, true, false, 5, 16, 40, 0, 0); // scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); // scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); --- 66,70 ---- // scs.Add((0x00 << 0x08) | 0x01, "TLS_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); // scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 5, 16, 40, 0, 0); // scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); // scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); |