@@ -3565,23 +3565,9 @@ private Stream CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry)
35653565 {
35663566 CryptoStream result = null ;
35673567
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 )
35833569 {
3584- if ( entry . Version = = ZipConstants . VERSION_AES )
3570+ if ( entry . Version > = ZipConstants . VERSION_AES )
35853571 {
35863572 //
35873573 OnKeysRequired ( entry . Name ) ;
@@ -3610,6 +3596,28 @@ private Stream CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry)
36103596 throw new ZipException ( "Decryption method not supported" ) ;
36113597 }
36123598 }
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+ }
36133621
36143622 return result ;
36153623 }
0 commit comments