kek[i] = (byte) i;
byte[] km = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
try
{
IKeyWrappingAlgorithm kwa = KeyWrappingAlgorithmFactory.getInstance("kw-aes");
Map attributes = new HashMap();
attributes.put(IKeyWrappingAlgorithm.KEY_ENCRYPTION_KEY_MATERIAL, kek);
kwa.init(attributes);
byte[] wrapped = new byte[km.length + 8];
int outputLength = kwa.wrap(km, 0, km.length, wrapped, 0);
harness.check(outputLength == 16,
"Wrapped 64-bit key material MUST produce 16 bytes");
byte[] unwrapped = new byte[8];
outputLength = kwa.unwrap(wrapped, 0, wrapped.length, unwrapped, 0);
harness.check(outputLength == 8,
"Unwrapped 128-bit key material MUST produce 8 bytes");
harness.check(Arrays.equals(km, unwrapped),
"Unwrapped key material MUST match original value");
}