Beispiel #1
0
        private void ZipOk(DirectoryNode root, Decryptor d)
        {
            ZipInputStream zin = new ZipInputStream(d.GetDataStream(root));

            while (true)
            {
                ZipEntry entry = zin.GetNextEntry();
                if (entry == null)
                {
                    break;
                }
                // crc32 is Checked within zip-stream
                if (entry.IsDirectory)
                {
                    continue;
                }
                zin.Skip(entry.Size);
                byte[] buf       = new byte[10];
                int    ReadBytes = zin.Read(buf, 0, buf.Length);
                // zin.Available() doesn't work for entries
                Assert.AreEqual(-1, ReadBytes, "size failed for " + entry.Name);
            }

            zin.Close();
        }
Beispiel #2
0
        private void ZipOk(POIFSFileSystem fs, Decryptor d)
        {
            ZipInputStream zin = new ZipInputStream(d.GetDataStream(fs));

            while (true)
            {
                ZipEntry entry = zin.GetNextEntry();
                if (entry == null)
                {
                    break;
                }

                while (zin.Available > 0)
                {
                    zin.Skip(zin.Available);
                }
            }
        }
Beispiel #3
0
        public void DataLength()
        {
            POIFSFileSystem fs = new POIFSFileSystem(POIDataSamples.GetPOIFSInstance().OpenResourceAsStream("protected_agile.docx"));

            EncryptionInfo info = new EncryptionInfo(fs);

            Decryptor d = Decryptor.GetInstance(info);

            d.VerifyPassword(Decryptor.DEFAULT_PASSWORD);

            Stream is1 = d.GetDataStream(fs);

            long len = d.GetLength();

            Assert.AreEqual(12810, len);

            byte[] buf = new byte[(int)len];

            is1.Read(buf, 0, buf.Length);

            ZipInputStream zin = new ZipInputStream(new MemoryStream(buf));

            while (true)
            {
                ZipEntry entry = zin.GetNextEntry();
                if (entry == null)
                {
                    break;
                }

                while (zin.Available > 0)
                {
                    zin.Skip(zin.Available);
                }
            }
        }