// Path: src/main/java/trabe/AbeDecryptionException.java
// public class AbeDecryptionException extends DecryptionException {
// 
// 	private static final long serialVersionUID = 2848983353356933397L;
// 
// 	public AbeDecryptionException(String msg) {
// 		super(msg);
// 	}
// 
// 	public AbeDecryptionException(String msg, Throwable t) {
// 		super(msg, t);
// 	}
// }
// 
// Path: src/main/java/trabe/AbeEncryptionException.java
// public class AbeEncryptionException extends GeneralSecurityException {
// 
//     private static final long serialVersionUID = 1043863535572140323L;
// 
//     public AbeEncryptionException(String msg) {
//         super(msg);
//     }
//     
//     public AbeEncryptionException(String msg, Throwable t) {
//         super(msg, t);
//     }
// 
// }


import java.io.*;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import trabe.AbeDecryptionException;
import trabe.AbeEncryptionException;

            byte[] buffer = new byte[BUFFERSIZE];
            while ((read = cis.read(buffer)) >= 0) {
            	output.write(buffer, 0, read);
            }
            output.close();
            cis.close();
        } catch (GeneralSecurityException e) {
            throw new AbeEncryptionException(e.getMessage(), e);
        }
	}

    public static byte[] encrypt(byte[] cpabeKey, byte[] lbeKey, byte[] iv, byte[] data) throws IOException, AbeEncryptionException {
        ByteArrayInputStream bais = new ByteArrayInputStream(data);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        encrypt(cpabeKey, lbeKey, iv, bais, baos);
        return baos.toByteArray();
    }
	
	public static CipherInputStream encrypt(byte[] cpabeKey, byte[] lbeKey, byte[] iv, InputStream input) throws IOException, AbeEncryptionException {
        try {
            SecretKeySpec skeySpec = new SecretKeySpec(combine(cpabeKey, lbeKey), KEY_ALGORITHM);
            Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(iv));
            CipherInputStream cis = new CipherInputStream(input, cipher);
            return cis;
        } catch (GeneralSecurityException e) {
            throw new AbeEncryptionException(e.getMessage(), e);
        }
	}
	

// Path: src/main/java/trabe/AbeDecryptionException.java
// public class AbeDecryptionException extends DecryptionException {
// 
// 	private static final long serialVersionUID = 2848983353356933397L;
// 
// 	public AbeDecryptionException(String msg) {
// 		super(msg);
// 	}
// 
// 	public AbeDecryptionException(String msg, Throwable t) {
// 		super(msg, t);
// 	}
// }
// 
// Path: src/main/java/trabe/AbeEncryptionException.java
// public class AbeEncryptionException extends GeneralSecurityException {
// 
//     private static final long serialVersionUID = 1043863535572140323L;
// 
//     public AbeEncryptionException(String msg) {
//         super(msg);
//     }
//     
//     public AbeEncryptionException(String msg, Throwable t) {
//         super(msg, t);
//     }
// 
// }


// Path: src/main/java/trabe/aes/AesEncryption.java
import java.io.*;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import trabe.AbeDecryptionException;
import trabe.AbeEncryptionException;

            byte[] buffer = new byte[BUFFERSIZE];
            while ((read = cis.read(buffer)) >= 0) {
            	output.write(buffer, 0, read);
            }
            output.close();
            cis.close();
        } catch (GeneralSecurityException e) {
            throw new AbeEncryptionException(e.getMessage(), e);
        }
	}

    public static byte[] encrypt(byte[] cpabeKey, byte[] lbeKey, byte[] iv, byte[] data) throws IOException, AbeEncryptionException {
        ByteArrayInputStream bais = new ByteArrayInputStream(data);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        encrypt(cpabeKey, lbeKey, iv, bais, baos);
        return baos.toByteArray();
    }
	
	public static CipherInputStream encrypt(byte[] cpabeKey, byte[] lbeKey, byte[] iv, InputStream input) throws IOException, AbeEncryptionException {
        try {
            SecretKeySpec skeySpec = new SecretKeySpec(combine(cpabeKey, lbeKey), KEY_ALGORITHM);
            Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(iv));
            CipherInputStream cis = new CipherInputStream(input, cipher);
            return cis;
        } catch (GeneralSecurityException e) {
            throw new AbeEncryptionException(e.getMessage(), e);
        }
	}
	

	public static CipherInputStream decrypt(byte[] cpabeKey, byte[] lbeKey, byte[] iv, InputStream input) throws IOException, AbeDecryptionException {
