File tree 1 file changed +34
-0
lines changed
test/ICSharpCode.SharpZipLib.Tests/Zip
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,40 @@ public void ZipFileStoreAesPartialRead()
206
206
}
207
207
}
208
208
209
+ /// <summary>
210
+ /// ZipInputStream can't decrypt AES encrypted entries, but it should repot that to the caller
211
+ /// rather than just failing.
212
+ /// </summary>
213
+ [ Test ]
214
+ [ Category ( "Zip" ) ]
215
+ public void ZipinputStreamShouldGracefullyFailWithAESStreams ( )
216
+ {
217
+ string password = "password" ;
218
+
219
+ using ( var memoryStream = new MemoryStream ( ) )
220
+ {
221
+ // Try to create a zip stream
222
+ WriteEncryptedZipToStream ( memoryStream , password , 256 ) ;
223
+
224
+ // reset
225
+ memoryStream . Seek ( 0 , SeekOrigin . Begin ) ;
226
+
227
+ // Try to read
228
+ using ( var inputStream = new ZipInputStream ( memoryStream ) )
229
+ {
230
+ inputStream . Password = password ;
231
+ var entry = inputStream . GetNextEntry ( ) ;
232
+ Assert . That ( entry . AESKeySize , Is . EqualTo ( 256 ) , "Test entry should be AES256 encrypted." ) ;
233
+
234
+ // CanDecompressEntry should be false.
235
+ Assert . That ( inputStream . CanDecompressEntry , Is . False , "CanDecompressEntry should be false for AES encrypted entries" ) ;
236
+
237
+ // Should throw on read.
238
+ Assert . Throws < ZipException > ( ( ) => inputStream . ReadByte ( ) ) ;
239
+ }
240
+ }
241
+ }
242
+
209
243
private static readonly string [ ] possible7zPaths = new [ ] {
210
244
// Check in PATH
211
245
"7z" , "7za" ,
You can’t perform that action at this time.
0 commit comments