Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to use AES encryption with no password throws unhelpful exception #507

Closed
piksel opened this issue Aug 12, 2020 · 1 comment
Closed
Assignees
Labels
encryption zip Related to ZIP file format

Comments

@piksel
Copy link
Member

piksel commented Aug 12, 2020

I tried turning off the password in one of the zip output stream unit tests and got

Message: 
  System.ArgumentNullException : Buffer cannot be null.
  Parameter name: buffer
Stack Trace: 
  MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
  ZipOutputStream.CloseEntry() line 534
  ZipOutputStream.Finish() line 772
  DeflaterOutputStream.Dispose(Boolean disposing) line 404
  Stream.Close()
  ZipEncryptionHandling.WriteEncryptedZipToStream(Stream stream, String password, Int32 keySize, CompressionMethod compressionMethod) line 497
  ZipEncryptionHandling.CreateZipWithEncryptedEntries(String password, Int32 keySize, CompressionMethod compressionMethod) line 540

Because AESAuthCode is null.

Looks to be because some of the logic goes off entry.AESKeySize being set to a non-zero value (deciding whether to write the > AES extra data etc), but them some of it goes off Entry.IsCrypted being true, which is only done automatically if a password has already been specified when the entry is added, so some of the other crypto bits get skipped.

Gets itself in a bit of a mess basically.
Possibly PutNextEntry should throw if you try to add an entry with AESKeySize set, but no password set?

Originally posted by @Numpsy in #506 (comment)

@piksel
Copy link
Member Author

piksel commented Nov 21, 2020

Fixed by #509

@piksel piksel closed this as completed Nov 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
encryption zip Related to ZIP file format
Projects
None yet
Development

No branches or pull requests

2 participants