Examples of EncryptionHeader


Examples of org.apache.poi.poifs.crypt.EncryptionHeader

       }
       return result;
    }

    private Cipher getCipher(SecretKey key) {
        EncryptionHeader em = info.getHeader();
        ChainingMode cm = em.getChainingMode();
        assert(cm == ChainingMode.ecb);
        return CryptoFunctions.getCipher(key, em.getCipherAlgorithm(), cm, null, Cipher.DECRYPT_MODE);
    }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionHeader

        public ChunkedCipherOutputStream(DirectoryNode dir) throws IOException {
            super(null);
            fileOut = TempFile.createTempFile("encrypted_package", "crypt");
            this.out = new FileOutputStream(fileOut);
            this.dir = dir;
            EncryptionHeader header = builder.getHeader();
            _cipher = getCipher(getSecretKey(), header.getCipherAlgorithm(), header.getChainingMode(), null, Cipher.ENCRYPT_MODE);
        }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionHeader

                }
            }
        }

        private void writeChunk() throws IOException {
            EncryptionHeader header = builder.getHeader();
            int blockSize = header.getBlockSize();

            int posInChunk = (int)(_pos & 0xfff);
            // normally posInChunk is 0, i.e. on the next chunk (-> index-1)
            // but if called on close(), posInChunk is somewhere within the chunk data
            int index = (int)(_pos >> 12);
            if (posInChunk==0) {
                index--;
                posInChunk = 4096;
            } else {
                // pad the last chunk
                _cipher = getCipher(getSecretKey(), header.getCipherAlgorithm(), header.getChainingMode(), null, Cipher.ENCRYPT_MODE, "PKCS5Padding");
            }

            byte[] blockKey = new byte[4];
            LittleEndian.putInt(blockKey, 0, index);
            byte[] iv = generateIv(header.getHashAlgorithmEx(), header.getKeySalt(), blockKey, blockSize);
            try {
                AlgorithmParameterSpec aps;
                if (header.getCipherAlgorithm() == CipherAlgorithm.rc2) {
                    aps = new RC2ParameterSpec(getSecretKey().getEncoded().length*8, iv);
                } else {
                    aps = new IvParameterSpec(iv);
                }
               
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionHeader

       }
       return result;
    }

    private Cipher getCipher(SecretKey key) {
        EncryptionHeader em = info.getHeader();
        ChainingMode cm = em.getChainingMode();
        assert(cm == ChainingMode.ecb);
        return CryptoFunctions.getCipher(key, em.getCipherAlgorithm(), cm, null, Cipher.DECRYPT_MODE);
    }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionHeader

        public ChunkedCipherOutputStream(DirectoryNode dir) throws IOException {
            super(null);
            fileOut = TempFile.createTempFile("encrypted_package", "crypt");
            this.out = new FileOutputStream(fileOut);
            this.dir = dir;
            EncryptionHeader header = builder.getHeader();
            _cipher = getCipher(getSecretKey(), header.getCipherAlgorithm(), header.getChainingMode(), null, Cipher.ENCRYPT_MODE);
        }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionHeader

                }
            }
        }

        private void writeChunk() throws IOException {
            EncryptionHeader header = builder.getHeader();
            int blockSize = header.getBlockSize();

            int posInChunk = (int)(_pos & 0xfff);
            // normally posInChunk is 0, i.e. on the next chunk (-> index-1)
            // but if called on close(), posInChunk is somewhere within the chunk data
            int index = (int)(_pos >> 12);
            if (posInChunk==0) {
                index--;
                posInChunk = 4096;
            } else {
                // pad the last chunk
                _cipher = getCipher(getSecretKey(), header.getCipherAlgorithm(), header.getChainingMode(), null, Cipher.ENCRYPT_MODE, "PKCS5Padding");
            }

            byte[] blockKey = new byte[4];
            LittleEndian.putInt(blockKey, 0, index);
            byte[] iv = generateIv(header.getHashAlgorithmEx(), header.getKeySalt(), blockKey, blockSize);
            try {
                AlgorithmParameterSpec aps;
                if (header.getCipherAlgorithm() == CipherAlgorithm.rc2) {
                    aps = new RC2ParameterSpec(getSecretKey().getEncoded().length*8, iv);
                } else {
                    aps = new IvParameterSpec(iv);
                }
               
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionHeader

        private byte[] _chunk;
        private Cipher _cipher;

        public ChunkedCipherInputStream(DocumentInputStream stream, long size)
            throws GeneralSecurityException {
            EncryptionHeader header = info.getHeader();
            _size = size;
            _stream = stream;
            _cipher = getCipher(getSecretKey(), header.getCipherAlgorithm(), header.getChainingMode(), header.getKeySalt(), Cipher.DECRYPT_MODE);
        }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionHeader

        private byte[] nextChunk() throws GeneralSecurityException, IOException {
            int index = (int)(_pos >> 12);
            byte[] blockKey = new byte[4];
            LittleEndian.putInt(blockKey, 0, index);
            EncryptionHeader header = info.getHeader();
            byte[] iv = generateIv(header.getHashAlgorithmEx(), header.getKeySalt(), blockKey, getBlockSizeInBytes());
            AlgorithmParameterSpec aps;
            if (header.getCipherAlgorithm() == CipherAlgorithm.rc2) {
                aps = new RC2ParameterSpec(getSecretKey().getEncoded().length*8, iv);
            } else {
                aps = new IvParameterSpec(iv);
            }
           
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionHeader

       }
       return result;
    }

    private Cipher getCipher(SecretKey key) {
        EncryptionHeader em = info.getHeader();
        ChainingMode cm = em.getChainingMode();
        assert(cm == ChainingMode.ecb);
        return CryptoFunctions.getCipher(key, em.getCipherAlgorithm(), cm, null, Cipher.DECRYPT_MODE);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.