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 @@ -399,6 +399,40 @@ public void ZipFileAESReadWithEmptyPassword()
399
399
}
400
400
}
401
401
402
+ /// <summary>
403
+ /// ZipInputStream can't decrypt AES encrypted entries, but it should repot that to the caller
404
+ /// rather than just failing.
405
+ /// </summary>
406
+ [ Test ]
407
+ [ Category ( "Zip" ) ]
408
+ public void ZipinputStreamShouldGracefullyFailWithAESStreams ( )
409
+ {
410
+ string password = "password" ;
411
+
412
+ using ( var memoryStream = new MemoryStream ( ) )
413
+ {
414
+ // Try to create a zip stream
415
+ WriteEncryptedZipToStream ( memoryStream , password , 256 ) ;
416
+
417
+ // reset
418
+ memoryStream . Seek ( 0 , SeekOrigin . Begin ) ;
419
+
420
+ // Try to read
421
+ using ( var inputStream = new ZipInputStream ( memoryStream ) )
422
+ {
423
+ inputStream . Password = password ;
424
+ var entry = inputStream . GetNextEntry ( ) ;
425
+ Assert . That ( entry . AESKeySize , Is . EqualTo ( 256 ) , "Test entry should be AES256 encrypted." ) ;
426
+
427
+ // CanDecompressEntry should be false.
428
+ Assert . That ( inputStream . CanDecompressEntry , Is . False , "CanDecompressEntry should be false for AES encrypted entries" ) ;
429
+
430
+ // Should throw on read.
431
+ Assert . Throws < ZipException > ( ( ) => inputStream . ReadByte ( ) ) ;
432
+ }
433
+ }
434
+ }
435
+
402
436
private static readonly string [ ] possible7zPaths = new [ ] {
403
437
// Check in PATH
404
438
"7z" , "7za" ,
You can’t perform that action at this time.
0 commit comments