The error is because key.length returns a value of 128. It should be 16 because the AES 128 key is 16 bytes long.I changed this value
final int keyLen =revision == 2 ? 5 : (keyBitLength / 8);
to
final int keyLen =16;
it will only work for AES 128