// Path: src/main/java/com/github/aelstad/keccakj/fips202/Shake128.java
// public final class Shake128 extends KeccakSponge {
// 	private final static byte DOMAIN_PADDING = 0xf;
// 	private final static int DOMMAIN_PADDING_LENGTH = 4;
// 	
// 	public Shake128() {
// 		super(256, DOMAIN_PADDING, DOMMAIN_PADDING_LENGTH);
// 	}
// 	
// 	
// 	
// }
// 
// Path: src/main/java/com/github/aelstad/keccakj/spi/Shake128Key.java
// public class Shake128Key extends RawKey {
// 
// 	@Override
// 	public String getAlgorithm() {		
// 		return Constants.SHAKE128_STREAM_CIPHER;
// 	}
// 
// }
// 
// Path: src/main/java/com/github/aelstad/keccakj/spi/Shake128StreamCipher.java
// public final class Shake128StreamCipher extends AbstractSpongeStreamCipher {
// 	private Shake128 sponge;
// 
// 	@Override
// 	KeccakSponge getSponge() {
// 		if(sponge == null) {
// 			sponge = new Shake128();
// 		}
// 		return sponge;
// 	}
// 
// }


import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import org.junit.Assert;
import org.junit.Test;
import com.github.aelstad.keccakj.fips202.Shake128;
import com.github.aelstad.keccakj.spi.Shake128Key;
import com.github.aelstad.keccakj.spi.Shake128StreamCipher;
			byte[] nonce = new byte[128];
			keyRandom.nextBytes(nonce);
			dataRandom.nextBytes(data);

			shake128.getAbsorbStream().write(key);
			shake128.getAbsorbStream().write(nonce);
			ByteArrayOutputStream bos = new ByteArrayOutputStream();
			FilterOutputStream fos = shake128.getTransformingSqueezeStream(bos);
			fos.write(data);
			fos.close();
			Assert.assertTrue(bos.size()==data.length);
			Assert.assertTrue(!Arrays.equals(data, bos.toByteArray()));

			byte[] encrypted = bos.toByteArray();

			shake128.reset();
			shake128.getAbsorbStream().write(key);
			shake128.getAbsorbStream().write(nonce);
			bos.reset();
			fos = shake128.getTransformingSqueezeStream(bos);
			fos.write(encrypted);
			fos.close();
			byte[] decrypted = bos.toByteArray();
			Assert.assertTrue(data != decrypted);
			Assert.assertTrue(Arrays.equals(decrypted, data));

			// Using the SPI impl. getCipher not available unless Jar is signed
			IvParameterSpec ivParameterSpec = new IvParameterSpec(nonce);
			Shake128Key shakeKey = new Shake128Key();
			shakeKey.setRaw(key);
// Path: src/main/java/com/github/aelstad/keccakj/fips202/Shake128.java
// public final class Shake128 extends KeccakSponge {
// 	private final static byte DOMAIN_PADDING = 0xf;
// 	private final static int DOMMAIN_PADDING_LENGTH = 4;
// 	
// 	public Shake128() {
// 		super(256, DOMAIN_PADDING, DOMMAIN_PADDING_LENGTH);
// 	}
// 	
// 	
// 	
// }
// 
// Path: src/main/java/com/github/aelstad/keccakj/spi/Shake128Key.java
// public class Shake128Key extends RawKey {
// 
// 	@Override
// 	public String getAlgorithm() {		
// 		return Constants.SHAKE128_STREAM_CIPHER;
// 	}
// 
// }
// 
// Path: src/main/java/com/github/aelstad/keccakj/spi/Shake128StreamCipher.java
// public final class Shake128StreamCipher extends AbstractSpongeStreamCipher {
// 	private Shake128 sponge;
// 
// 	@Override
// 	KeccakSponge getSponge() {
// 		if(sponge == null) {
// 			sponge = new Shake128();
// 		}
// 		return sponge;
// 	}
// 
// }


// Path: src/test/java/com/github/aelstad/keccakj/fips202/TestStreamEncryption.java
import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import org.junit.Assert;
import org.junit.Test;
import com.github.aelstad.keccakj.fips202.Shake128;
import com.github.aelstad.keccakj.spi.Shake128Key;
import com.github.aelstad.keccakj.spi.Shake128StreamCipher;

			byte[] nonce = new byte[128];
			keyRandom.nextBytes(nonce);
			dataRandom.nextBytes(data);

			shake128.getAbsorbStream().write(key);
			shake128.getAbsorbStream().write(nonce);
			ByteArrayOutputStream bos = new ByteArrayOutputStream();
			FilterOutputStream fos = shake128.getTransformingSqueezeStream(bos);
			fos.write(data);
			fos.close();
			Assert.assertTrue(bos.size()==data.length);
			Assert.assertTrue(!Arrays.equals(data, bos.toByteArray()));

			byte[] encrypted = bos.toByteArray();

			shake128.reset();
			shake128.getAbsorbStream().write(key);
			shake128.getAbsorbStream().write(nonce);
			bos.reset();
			fos = shake128.getTransformingSqueezeStream(bos);
			fos.write(encrypted);
			fos.close();
			byte[] decrypted = bos.toByteArray();
			Assert.assertTrue(data != decrypted);
			Assert.assertTrue(Arrays.equals(decrypted, data));

			// Using the SPI impl. getCipher not available unless Jar is signed
			IvParameterSpec ivParameterSpec = new IvParameterSpec(nonce);
			Shake128Key shakeKey = new Shake128Key();
			shakeKey.setRaw(key);
			Shake128StreamCipher c  = new Shake128StreamCipher();