// Path: src/main/java/me/lightspeed7/mongofs/crypto/Crypto.java
// public interface Crypto {
// 
//     /**
//      * The size of the buffer of data to encrypt
//      * 
//      * NOTE : This value must be <= the chunkSize for the collection to keep the system performant.
//      * 
//      * @return the ChunkSize
//      */
//     ChunkSize getChunkSize();
// 
//     /**
//      * Return the given bytes in their encrypted form
//      * 
//      * @param dataIn
//      * @param offset
//      * @param length
//      * @return the encrypted bytes
//      * @throws GeneralSecurityException
//      */
//     byte[] encrypt(byte[] dataIn, int offset, int length) throws GeneralSecurityException;
// 
//     /**
//      * Return the given encrypted bytes back in their original form
//      * 
//      * @param dataIn
//      * @param offset
//      * @param length
//      * @return the un-encrypted bytes
//      * @throws GeneralSecurityException
//      */
//     byte[] decrypt(byte[] dataIn, int offset, int length) throws GeneralSecurityException;
// 
// }


import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import me.lightspeed7.mongofs.crypto.Crypto;
package me.lightspeed7.mongofs;



public class DecryptInputStream extends InputStream {

    private Crypto crypto;
    private DataInputStream inputStream;
    private int offset = 0;
    private byte[] buffer = null;
    private long remainingBytes;

// Path: src/main/java/me/lightspeed7/mongofs/crypto/Crypto.java
// public interface Crypto {
// 
//     /**
//      * The size of the buffer of data to encrypt
//      * 
//      * NOTE : This value must be <= the chunkSize for the collection to keep the system performant.
//      * 
//      * @return the ChunkSize
//      */
//     ChunkSize getChunkSize();
// 
//     /**
//      * Return the given bytes in their encrypted form
//      * 
//      * @param dataIn
//      * @param offset
//      * @param length
//      * @return the encrypted bytes
//      * @throws GeneralSecurityException
//      */
//     byte[] encrypt(byte[] dataIn, int offset, int length) throws GeneralSecurityException;
// 
//     /**
//      * Return the given encrypted bytes back in their original form
//      * 
//      * @param dataIn
//      * @param offset
//      * @param length
//      * @return the un-encrypted bytes
//      * @throws GeneralSecurityException
//      */
//     byte[] decrypt(byte[] dataIn, int offset, int length) throws GeneralSecurityException;
// 
// }


// Path: src/main/java/me/lightspeed7/mongofs/DecryptInputStream.java
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import me.lightspeed7.mongofs.crypto.Crypto;

package me.lightspeed7.mongofs;



public class DecryptInputStream extends InputStream {

    private Crypto crypto;
    private DataInputStream inputStream;
    private int offset = 0;
    private byte[] buffer = null;
    private long remainingBytes;

    public DecryptInputStream(final Crypto crypto, final MongoFile file, final InputStream inputStream) {