import javax.crypto.Cipher; 
import javax.crypto.SecretKey; 
import javax.crypto.spec.GCMParameterSpec; 
import javax.crypto.spec.SecretKeySpec; 
import java.util.Random; 

public class JI9059629 {

	public static byte[] bugGCM() throws Exception { 
		// AES-GCM parameters 
		int GCM_NONCE_LENGTH = 12; // in bytes 
		int GCM_TAG_LENGTH = 16; // in bytes 

		int inputSize = 100001; 
		//int inputSize = 65536 + 1; // 2^16 == 65536 

		// init input 
		byte[] inputArray = new byte[inputSize]; 
		for (int i=0; i < inputArray.length; i++) { 
			inputArray[i] = (byte)i; 
		} 

		// init cipher 
		Cipher cipher; 
		cipher = Cipher.getInstance("AES/GCM/NoPadding"); 

		// init nonce 
		final byte[] nonce = new byte[GCM_NONCE_LENGTH]; 
		Random random = new Random(); 
		random.nextBytes(nonce); 
		GCMParameterSpec spec = new GCMParameterSpec(GCM_TAG_LENGTH * 8, nonce); 

		byte[] key_code = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; 
		SecretKey key = new SecretKeySpec(key_code, "AES"); 
		cipher.init(Cipher.ENCRYPT_MODE, key, spec); 
		byte[] outputArray = cipher.doFinal(inputArray); 
		return outputArray; 
	} 

	public static void main(String[] args) throws Exception { 
		bugGCM(); 
	} 

}
