@@ -3565,23 +3565,9 @@ private Stream CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry)
3565
3565
{
3566
3566
CryptoStream result = null ;
3567
3567
3568
- if ( ( entry . Version < ZipConstants . VersionStrongEncryption )
3569
- || ( entry . Flags & ( int ) GeneralBitFlags . StrongEncryption ) == 0 )
3570
- {
3571
- var classicManaged = new PkzipClassicManaged ( ) ;
3572
-
3573
- OnKeysRequired ( entry . Name ) ;
3574
- if ( HaveKeys == false )
3575
- {
3576
- throw new ZipException ( "No password available for encrypted stream" ) ;
3577
- }
3578
-
3579
- result = new CryptoStream ( baseStream , classicManaged . CreateDecryptor ( key , null ) , CryptoStreamMode . Read ) ;
3580
- CheckClassicPassword ( result , entry ) ;
3581
- }
3582
- else
3568
+ if ( entry . CompressionMethodForHeader == CompressionMethod . WinZipAES )
3583
3569
{
3584
- if ( entry . Version = = ZipConstants . VERSION_AES )
3570
+ if ( entry . Version > = ZipConstants . VERSION_AES )
3585
3571
{
3586
3572
//
3587
3573
OnKeysRequired ( entry . Name ) ;
@@ -3610,6 +3596,28 @@ private Stream CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry)
3610
3596
throw new ZipException ( "Decryption method not supported" ) ;
3611
3597
}
3612
3598
}
3599
+ else
3600
+ {
3601
+ if ( ( entry . Version < ZipConstants . VersionStrongEncryption )
3602
+ || ( entry . Flags & ( int ) GeneralBitFlags . StrongEncryption ) == 0 )
3603
+ {
3604
+ var classicManaged = new PkzipClassicManaged ( ) ;
3605
+
3606
+ OnKeysRequired ( entry . Name ) ;
3607
+ if ( HaveKeys == false )
3608
+ {
3609
+ throw new ZipException ( "No password available for encrypted stream" ) ;
3610
+ }
3611
+
3612
+ result = new CryptoStream ( baseStream , classicManaged . CreateDecryptor ( key , null ) , CryptoStreamMode . Read ) ;
3613
+ CheckClassicPassword ( result , entry ) ;
3614
+ }
3615
+ else
3616
+ {
3617
+ // We don't support PKWare strong encryption
3618
+ throw new ZipException ( "Decryption method not supported" ) ;
3619
+ }
3620
+ }
3613
3621
3614
3622
return result ;
3615
3623
}
0 commit comments