Add field to EntryInfo for whether the file is encrypted

Currently, an encrypted file will simply fail to extract. It is useful
for SafeBrowsing to be able to indicate that the file is encrypted,
instead of malformed.

Bug: 874621
Change-Id: Ie0b2448b0fd2340c554351d1131baa3854a73e44
Reviewed-on: https://chromium-review.googlesource.com/1176558
Reviewed-by: Varun Khaneja <vakh@chromium.org>
Reviewed-by: Satoru Takabayashi <satorux@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#585093}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 04f531f50c26ce40558416c67682c430f944b9c6
diff --git a/google/zip_reader_unittest.cc b/google/zip_reader_unittest.cc
index dabe9f6..7eba122 100644
--- a/google/zip_reader_unittest.cc
+++ b/google/zip_reader_unittest.cc
@@ -149,6 +149,7 @@
     ASSERT_TRUE(GetTestDataDirectory(&test_data_dir_));
 
     test_zip_file_ = test_data_dir_.AppendASCII("test.zip");
+    encrypted_zip_file_ = test_data_dir_.AppendASCII("test_encrypted.zip");
     evil_zip_file_ = test_data_dir_.AppendASCII("evil.zip");
     evil_via_invalid_utf8_zip_file_ = test_data_dir_.AppendASCII(
         "evil_via_invalid_utf8.zip");
@@ -201,6 +202,8 @@
   base::FilePath test_data_dir_;
   // The path to test.zip in the test data directory.
   base::FilePath test_zip_file_;
+  // The path to test_encrypted.zip in the test data directory.
+  base::FilePath encrypted_zip_file_;
   // The path to evil.zip in the test data directory.
   base::FilePath evil_zip_file_;
   // The path to evil_via_invalid_utf8.zip in the test data directory.
@@ -366,6 +369,20 @@
   EXPECT_TRUE(current_entry_info->is_directory());
 }
 
+TEST_F(ZipReaderTest, current_entry_info_EncryptedFile) {
+  ZipReader reader;
+  base::FilePath target_path(FILE_PATH_LITERAL("foo/bar/quux.txt"));
+
+  ASSERT_TRUE(reader.Open(encrypted_zip_file_));
+  ASSERT_TRUE(LocateAndOpenEntry(&reader, target_path));
+  EXPECT_TRUE(reader.current_entry_info()->is_encrypted());
+  reader.Close();
+
+  ASSERT_TRUE(reader.Open(test_zip_file_));
+  ASSERT_TRUE(LocateAndOpenEntry(&reader, target_path));
+  EXPECT_FALSE(reader.current_entry_info()->is_encrypted());
+}
+
 // Verifies that the ZipReader class can extract a file from a zip archive
 // stored in memory. This test opens a zip archive in a std::string object,
 // extracts its content, and verifies the content is the same as the expected