public void init(byte[] iv) throws IllegalArgumentException { init(iv, 0, iv.length); }
ctr.init(hash, 0, 16); System.arraycopy(hash, 0, header, 2, hash.length); byte[] cdata = new byte[data.length];
cipher.init(hash, 0, 16); byte[] plaintext = new byte[data.length]; cipher.processBytes(data, 0, data.length, plaintext, 0);
private void checkNIST(int bits, byte[] key, byte[] iv, byte[] plaintext, byte[] ciphertext) throws UnsupportedCipherException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IllegalBlockSizeException, BadPaddingException { // First test it with JCA. if (TEST_JCA) { SecretKeySpec k = new SecretKeySpec(key, "AES"); Cipher c = Cipher.getInstance("AES/CTR/NOPADDING", Rijndael.AesCtrProvider); c.init(Cipher.ENCRYPT_MODE, k, new IvParameterSpec(iv)); byte[] output = c.doFinal(plaintext); assertTrue(Arrays.equals(output, ciphertext)); } Rijndael cipher = new Rijndael(bits, 128); cipher.initialize(key); CTRBlockCipher ctr = new CTRBlockCipher(cipher); ctr.init(iv); byte[] output = new byte[plaintext.length]; ctr.processBytes(plaintext, 0, plaintext.length, output, 0); assertTrue(Arrays.equals(output, ciphertext)); }
cipher.initialize(key); CTRBlockCipher ctr = new CTRBlockCipher(cipher); ctr.init(iv); byte[] ciphertext = new byte[plaintext.length]; ctr.processBytes(plaintext, 0, plaintext.length, ciphertext, 0); ctr.init(iv); byte[] finalPlaintext = new byte[plaintext.length]; ctr.processBytes(ciphertext, 0, ciphertext.length, finalPlaintext, 0); ctr.init(iv); byte[] output = new byte[plaintext.length]; MersenneTwister random = new MersenneTwister(mt.nextLong());
cipher.initialize(key); CTRBlockCipher ctr = new CTRBlockCipher(cipher); ctr.init(iv); byte[] output = new byte[plaintext.length]; MersenneTwister random = new MersenneTwister(seed);