CryptoCodec implements Configurable { public abstract void calculateIV(byte[] initIV, long counter, byte[] IV);  static CryptoCodec getInstance(Configuration conf, 
      CipherSuite cipherSuite); static CryptoCodec getInstance(Configuration conf); abstract CipherSuite getCipherSuite(); abstract Encryptor createEncryptor(); abstract Decryptor createDecryptor(); abstract void calculateIV(byte[] initIV, long counter, byte[] IV); abstract void generateSecureRandom(byte[] bytes); static Logger LOG; }
@Test(timeout=120000) public void testCalculateIV() throws Exception { JceAesCtrCryptoCodec codec = new JceAesCtrCryptoCodec(); codec.setConf(conf); SecureRandom sr = new SecureRandom(); byte[] initIV = new byte[16]; byte[] IV = new byte[16]; long iterations = 1000; long counter = 10000; for(int i = 0; i < 8; i++) { initIV[8 + i] = (byte)0xff; } for(long j = 0; j < counter; j++) { assertIVCalculation(codec, initIV, j, IV); } for(long i = 0; i < iterations; i++) { sr.nextBytes(initIV); for(long j = 0; j < counter; j++) { assertIVCalculation(codec, initIV, j, IV); } } for(long i = 0; i < iterations; i++) { sr.nextBytes(initIV); for(long j = 0; j < counter; j++) { long c = sr.nextLong(); assertIVCalculation(codec, initIV, c, IV); } } }