@@ -72,6 +72,44 @@ public void ZipFileAesDecryption()
7272 }
7373 }
7474
75+ /// <summary>
76+ /// Tests for reading encrypted entries using ZipInputStream.
77+ /// </summary>
78+ /// <param name="aesKeySize"></param>
79+ [ Test ]
80+ [ Category ( "Encryption" ) ]
81+ [ Category ( "Zip" ) ]
82+ [ TestCase ( 0 , CompressionMethod . Deflated ) ]
83+ [ TestCase ( 0 , CompressionMethod . Stored ) ]
84+ [ TestCase ( 128 , CompressionMethod . Deflated ) ]
85+ [ TestCase ( 128 , CompressionMethod . Stored ) ]
86+ [ TestCase ( 256 , CompressionMethod . Deflated ) ]
87+ [ TestCase ( 256 , CompressionMethod . Stored ) ]
88+ public void ZipInputStreamDecryption ( int aesKeySize , CompressionMethod compressionMethod )
89+ {
90+ var password = "password" ;
91+
92+ using ( var ms = new MemoryStream ( ) )
93+ {
94+ WriteEncryptedZipToStream ( ms , password , aesKeySize , compressionMethod ) ;
95+ ms . Seek ( 0 , SeekOrigin . Begin ) ;
96+
97+ using ( var zis = new ZipInputStream ( ms ) )
98+ {
99+ zis . IsStreamOwner = false ;
100+ zis . Password = password ;
101+
102+ var hmm = zis . GetNextEntry ( ) ;
103+
104+ using ( var sr = new StreamReader ( zis , Encoding . UTF8 ) )
105+ {
106+ var content = sr . ReadToEnd ( ) ;
107+ Assert . AreEqual ( DummyDataString , content , "Decompressed content does not match input data" ) ;
108+ }
109+ }
110+ }
111+ }
112+
75113 [ Test ]
76114 [ Category ( "Encryption" ) ]
77115 [ Category ( "Zip" ) ]
0 commit comments