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 @@ -365,6 +365,40 @@ public void ZipFileAesDelete()
365
365
}
366
366
}
367
367
368
+ /// <summary>
369
+ /// ZipInputStream can't decrypt AES encrypted entries, but it should repot that to the caller
370
+ /// rather than just failing.
371
+ /// </summary>
372
+ [ Test ]
373
+ [ Category ( "Zip" ) ]
374
+ public void ZipinputStreamShouldGracefullyFailWithAESStreams ( )
375
+ {
376
+ string password = "password" ;
377
+
378
+ using ( var memoryStream = new MemoryStream ( ) )
379
+ {
380
+ // Try to create a zip stream
381
+ WriteEncryptedZipToStream ( memoryStream , password , 256 ) ;
382
+
383
+ // reset
384
+ memoryStream . Seek ( 0 , SeekOrigin . Begin ) ;
385
+
386
+ // Try to read
387
+ using ( var inputStream = new ZipInputStream ( memoryStream ) )
388
+ {
389
+ inputStream . Password = password ;
390
+ var entry = inputStream . GetNextEntry ( ) ;
391
+ Assert . That ( entry . AESKeySize , Is . EqualTo ( 256 ) , "Test entry should be AES256 encrypted." ) ;
392
+
393
+ // CanDecompressEntry should be false.
394
+ Assert . That ( inputStream . CanDecompressEntry , Is . False , "CanDecompressEntry should be false for AES encrypted entries" ) ;
395
+
396
+ // Should throw on read.
397
+ Assert . Throws < ZipException > ( ( ) => inputStream . ReadByte ( ) ) ;
398
+ }
399
+ }
400
+ }
401
+
368
402
private static readonly string [ ] possible7zPaths = new [ ] {
369
403
// Check in PATH
370
404
"7z" , "7za" ,
You can’t perform that action at this time.
0 commit comments