Add Zip Archives password support#122093
Conversation
…assword and unprotected
… with cryptography lib
rzikm
left a comment
There was a problem hiding this comment.
LGTM, few ideas for making the code cleaner.
|
@alinpahontu2912 We signed off earlier this week on the security design you submitted. Thanks. :) Remember to update the public-facing docs so that consumers know what explicit promises (and non-promises!) the component intends to make here. |
| } | ||
| return WinZipAesKeyMaterial.GetSaltSize(keySizeBits); |
There was a problem hiding this comment.
| } | |
| return WinZipAesKeyMaterial.GetSaltSize(keySizeBits); | |
| } | |
| return WinZipAesKeyMaterial.GetSaltSize(keySizeBits); |
| if (OperatingSystem.IsBrowser()) | ||
| { | ||
| throw new PlatformNotSupportedException(SR.WinZipEncryptionNotSupportedOnBrowser); | ||
| } | ||
| ArgumentNullException.ThrowIfNull(baseStream); |
There was a problem hiding this comment.
Either a blank line after the close curly (to match the rest of the file style) or move this if/throw to a helper.
| if (OperatingSystem.IsBrowser()) | |
| { | |
| throw new PlatformNotSupportedException(SR.WinZipEncryptionNotSupportedOnBrowser); | |
| } | |
| ArgumentNullException.ThrowIfNull(baseStream); | |
| if (OperatingSystem.IsBrowser()) | |
| { | |
| throw new PlatformNotSupportedException(SR.WinZipEncryptionNotSupportedOnBrowser); | |
| } | |
| ArgumentNullException.ThrowIfNull(baseStream); |
or
| if (OperatingSystem.IsBrowser()) | |
| { | |
| throw new PlatformNotSupportedException(SR.WinZipEncryptionNotSupportedOnBrowser); | |
| } | |
| ArgumentNullException.ThrowIfNull(baseStream); | |
| CheckPlatformSupport(); | |
| ArgumentNullException.ThrowIfNull(baseStream); |
bartonjs
left a comment
There was a problem hiding this comment.
I never looked at the tests at all.
I skimmed the majority of the source code looking for places where the password might be mishandled.
I aggressively reviewed the crypto parts of WinZipAesStream and ZipCryptoStream.
Those parts LGTM.
Since I didn't do a full review I won't give a checkmark, but I also don't have any reason to hold.
| public System.Threading.Tasks.Task<System.IO.Stream> OpenAsync(System.IO.FileAccess access, System.ReadOnlySpan<char> password, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } | ||
| public System.Threading.Tasks.Task<System.IO.Stream> OpenAsync(System.IO.FileAccess access, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } | ||
| public System.Threading.Tasks.Task<System.IO.Stream> OpenAsync(System.ReadOnlySpan<char> password, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } | ||
| public System.Threading.Tasks.Task<System.IO.Stream> OpenAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } |
| ZipArchiveEntry lastEntry = _entries[_entries.Count - 1]; | ||
| if (lastEntry.IsEncrypted) | ||
| { | ||
| lastEntry.ReadEncryptionSaltIfNeeded(); | ||
| } |
Fixes #1545
Big Milestones and status: