[Mono-bugs] [Bug 51322][Maj] New - Problems using CryptoStream with NetworkStream

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 4 Feb 2004 16:48:17 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by spouliot@videotron.ca.


--- shadow/51322	2004-02-04 16:48:17.000000000 -0500
+++ shadow/51322.tmp.16931	2004-02-04 16:48:17.000000000 -0500
@@ -0,0 +1,126 @@
+Bug#: 51322
+Product: Mono/Class Libraries
+Version: unspecified
+OS: Mandrake 9.1
+OS Details: 
+Status: RESOLVED   
+Resolution: FIXED
+Severity: Unknown
+Priority: Major
+Component: CORLIB
+AssignedTo: spouliot@videotron.ca                            
+ReportedBy: brendan@brendanp.no-ip.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Problems using CryptoStream with NetworkStream
+Description of Problem:
+When using a CryptoStream with a network stream a OperationNotSupported
+exception occurs when trying to read from the CryptoStream
+Steps to reproduce the problem:
+1. NetWorkStream ns = new NetworkStream(socket);
+2. CyrptoStream cs = new CryptoStream(ns);
+3. cs.ReadByte(); //generates an exception
+4. Some details have been left out(like initializing the transform
+Actual Results:
+a OperationNotSupported error occures
+Expected Results:
+it should decrypt the data
+How often does this happen? 
+Additional Information:
+the CryptoStream tryis to use the Position propoery on the network stream,
+however the network stream does not support this. I would just change it
+but it seems the ReadBlock method needs to know when the end of the stream is
+------- Additional Comments From spouliot@videotron.ca  2003-12-15 10:20 -------
+Created an attachment (id=6243)
+CryptoStream patch with Position
+------- Additional Comments From spouliot@videotron.ca  2003-12-15 10:20 -------
+There is a patch that eliminates the Position uses in CryptoStream. 
+However I'm not sure how it could affect actual working code as I'm 
+not a big user of CryptoStream and current test coverage is weak.
+Carlos, can you try the patch with your TLS implementation.
+------- Additional Comments From carlosga@telefonica.net  2003-12-21 07:41 -------
+Sorry for the on testing this.
+For testing i have used a little test case using the PgSqlClient
+provider in TLS mode against a PostgreSQL DEV server in Fedora core 1
+(mono sources are two days old).
+- With the actual CVS version of CryptoStream.cs all runs fine.
+- With the patched version (i think i have patched it ok) i got an
+exception, here are the details:
+Unhandled Exception:
+System.Security.Cryptography.CryptographicException: invalid block
+lengthin <0x000ef>
+(byte[],int,int)in <0x0005a>
+(byte[],int,int)in <0x0008e>
+System.Security.Cryptography.CryptoStream:FlushFinalBlock ()
+in <0x0004f> (wrapper remoting-invoke-with-check)
+System.Security.Cryptography.CryptoStream:FlushFinalBlock ()in
+<0x001aa> Mono.Security.Protocol.Tls.CipherSuite:EncryptRecord
+(byte[],byte[])in <0x00078>
+in <0x0006d> (wrapper remoting-invoke-with-check)
+in <0x000df> Mono.Security.Protocol.Tls.SslClientStream:sendRecord
+(Mono.Security.Protocol.Tls.TlsContentType,byte[])in <0x0006b>
+(wrapper remoting-invoke-with-check)
+in <0x00031> Mono.Security.Protocol.Tls.SslClientStream:SendAlert
+(Mono.Security.Protocol.Tls.Alerts.TlsAlert)in <0x00056> (wrapper
+in <0x0007d> Mono.Security.Protocol.Tls.SslClientStream:Dispose (bool)
+in <0x00013>
+()in <0x00010> Mono.Security.Protocol.Tls.SslClientStream:Close ()
+in <0x00016> PostgreSql.Data.NPgClient.PgDbClient:detach ()
+in <0x00353> PostgreSql.Data.NPgClient.PgDbClient:Connect ()
+in <0x00063> PostgreSql.Data.PgSqlClient.PgDbConnection:Connect ()
+in <0x0004f> (wrapper remoting-invoke-with-check)
+PostgreSql.Data.PgSqlClient.PgDbConnection:Connect ()in <0x0011b>
+PostgreSql.Data.PgSqlClient.PgConnection:Open ()
+in <0x0004f> (wrapper remoting-invoke-with-check)
+PostgreSql.Data.PgSqlClient.PgConnection:Open ()in <0x0004a>
+PgTest.Class1:createTables (string)
+in <0x0008c> PgTest.Class1:Main (string[])
+Best regards
+Carlos Guzmán Álvarez
+------- Additional Comments From spouliot@videotron.ca  2004-02-04 16:48 -------
+The new CryptoStream implementation doesn't requires Stream.Length nor
+Stream.Position to work. This should enable CryptoStream to work with
+(almost) any type of Stream and match MS implementation.
+Note: patch applied after 0.30