System.arraycopy(AESWrapper.DEFAULT_IV, 0, IV, 0,
AESWrapper.DEFAULT_IV.length);
}
if (IV.length != 8) {
throw new XMLSecurityException("empty");
}
int inLen = keyToBeWrapped.length;
int n = inLen / 8;
if ((keyToBeWrapped.length % 8) != 0) {
throw new XMLSecurityException(
"wrap data must be a multiple of 8 bytes");
}
byte[] block = new byte[keyToBeWrapped.length + IV.length];
byte[] buf = new byte[8 + IV.length];
System.arraycopy(IV, 0, block, 0, IV.length);
System.arraycopy(keyToBeWrapped, 0, block, IV.length,
keyToBeWrapped.length);
this._cipher.init(Cipher.ENCRYPT_MODE, wrapKey);
for (int j = 0; j != 6; j++) {
for (int i = 1; i <= n; i++) {
System.arraycopy(block, 0, buf, 0, IV.length);
System.arraycopy(block, 8 * i, buf, IV.length, 8);
this._cipher.update(buf, 0, buf.length, buf, 0);
int t = n * j + i;
for (int k = 1; t != 0; k++) {
byte v = (byte) t;
buf[IV.length - k] ^= v;
t >>>= 8;
}
System.arraycopy(buf, 0, block, 0, 8);
System.arraycopy(buf, 8, block, 8 * i, 8);
}
}
return block;
} catch (InvalidKeyException ex) {
throw new XMLSecurityException("empty", ex);
} catch (ShortBufferException ex) {
throw new XMLSecurityException("empty", ex);
}
}