Esempio n. 1
0
        public override Stream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream("EncryptedPackage");

            _length = dis.ReadLong();
            return(new ChunkedCipherInputStream(dis, _length, this));
        }
Esempio n. 2
0
        public override Stream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dr = dir.CreateDocumentInputStream("EncryptedPackage");
            long size = dr.ReadLong();

            return(new ChunkedCipherInputStream(dr, size, this));
        }
Esempio n. 3
0
        public EncryptionHeader(DocumentInputStream dr)
        {
            flags         = dr.ReadInt();
            sizeExtra     = dr.ReadInt();
            algorithm     = dr.ReadInt();
            hashAlgorithm = dr.ReadInt();
            keySize       = dr.ReadInt();
            providerType  = dr.ReadInt();

            dr.ReadLong();  //skip reserved.

            StringBuilder builder = new StringBuilder();

            while (true)
            {
                char c = (char)dr.ReadShort();

                if (c == 0)
                {
                    break;
                }
                builder.Append(c);
            }

            cspName    = builder.ToString();
            cipherMode = MODE_ECB;
            keySalt    = null;
        }
Esempio n. 4
0
        public EncryptionHeader(DocumentInputStream dr)
        {
            flags = dr.ReadInt();
            sizeExtra = dr.ReadInt();
            algorithm = dr.ReadInt();
            hashAlgorithm = dr.ReadInt();
            keySize = dr.ReadInt();
            providerType = dr.ReadInt();

            dr.ReadLong();  //skip reserved.

            StringBuilder builder = new StringBuilder();

            while (true)
            {
                char c = (char)dr.ReadShort();

                if (c == 0)
                    break;
                builder.Append(c);
            }

            cspName = builder.ToString();
            cipherMode = MODE_ECB;
            keySalt = null;
        }
Esempio n. 5
0
        public override Stream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dr = dir.CreateDocumentInputStream("EncryptedPackage");
            long size = dr.ReadLong();
            SymmetricAlgorithm cipher = GetCipher();

            return(new CryptoStream(dr, cipher.CreateDecryptor(cipher.Key, cipher.IV), CryptoStreamMode.Read));
        }
Esempio n. 6
0
        public override InputStream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream(DEFAULT_POIFS_ENTRY);

            _length = dis.ReadLong();
            BinaryRC4CipherInputStream cipherStream = new BinaryRC4CipherInputStream(dis, _length, this);

            //return cipherStream.GetStream();
            throw new NotImplementedException("BinaryRC4CipherInputStream should be derived from InputStream");
        }
Esempio n. 7
0
        public override InputStream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream(DEFAULT_POIFS_ENTRY);

            _length = dis.ReadLong();

            var stream = new AgileCipherInputStream(dis, _length, builder, this);

            stream.Position = 0;
            return(stream);
        }
Esempio n. 8
0
        public override InputStream GetDataStream(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream(Encryptor.DEFAULT_POIFS_ENTRY);

            _length = dis.ReadLong();

            // limit wrong calculated ole entries - (bug #57080)
            // standard encryption always uses aes encoding, so blockSize is always 16
            // http://stackoverflow.com/questions/3283787/size-of-data-after-aes-encryption
            int    blockSize = builder.GetHeader().CipherAlgorithm.blockSize;
            long   cipherLen = (_length / blockSize + 1) * blockSize;
            Cipher cipher    = GetCipher(GetSecretKey());


            ByteArrayInputStream boundedDis = new BoundedInputStream(dis, cipherLen);

            return(new BoundedInputStream(new CipherInputStream(boundedDis, cipher), _length));
        }