throws Exception
{
Key key;
Cipher in, out;
CipherInputStream cIn;
CipherOutputStream cOut;
ByteArrayInputStream bIn;
ByteArrayOutputStream bOut;
key = new SecretKeySpec(keyBytes, "Camellia");
in = Cipher.getInstance("Camellia/ECB/NoPadding", "BC");
out = Cipher.getInstance("Camellia/ECB/NoPadding", "BC");
try
{
out.init(Cipher.ENCRYPT_MODE, key);
}
catch (Exception e)
{
fail("Camellia failed initialisation - " + e.toString(), e);
}
try
{
in.init(Cipher.DECRYPT_MODE, key);
}
catch (Exception e)
{
fail("Camellia failed initialisation - " + e.toString(), e);
}
//
// encryption pass
//
bOut = new ByteArrayOutputStream();
cOut = new CipherOutputStream(bOut, out);
try
{
for (int i = 0; i != input.length / 2; i++)
{
cOut.write(input[i]);
}
cOut.write(input, input.length / 2, input.length - input.length / 2);
cOut.close();
}
catch (IOException e)
{
fail("Camellia failed encryption - " + e.toString(), e);
}