int id,
byte[] kek,
byte[] in,
byte[] out)
{
Wrapper wrapper = new AESWrapEngine();
wrapper.init(true, new KeyParameter(kek));
try
{
byte[] cText = wrapper.wrap(in, 0, in.length);
if (!Arrays.areEqual(cText, out))
{
return new SimpleTestResult(false, getName() + ": failed wrap test " + id + " expected " + new String(Hex.encode(out)) + " got " + new String(Hex.encode(cText)));
}
}
catch (Exception e)
{
return new SimpleTestResult(false, getName() + ": failed wrap test exception " + e.toString());
}
wrapper.init(false, new KeyParameter(kek));
try
{
byte[] pText = wrapper.unwrap(out, 0, out.length);
if (!Arrays.areEqual(pText, in))
{
return new SimpleTestResult(false, getName() + ": failed unwrap test " + id + " expected " + new String(Hex.encode(in)) + " got " + new String(Hex.encode(pText)));
}
}