@Test public void testHChaCha20TestVectors() { for (HChaCha20TestVector test : hChaCha20TestVectors) { int[] output = XChaCha20.hChaCha20(test.key, test.in); assertThat(output).isEqualTo(test.out); } }
static int[] hChaCha20(final int[] key, final int[] nonce) { int[] state = new int[ChaCha20Base.BLOCK_SIZE_IN_INTS]; ChaCha20Base.setSigmaAndKey(state, key); state[12] = nonce[0]; state[13] = nonce[1]; state[14] = nonce[2]; state[15] = nonce[3]; ChaCha20Base.shuffleState(state); state[4] = state[12]; state[5] = state[13]; state[6] = state[14]; state[7] = state[15]; return Arrays.copyOf(state, ChaCha20Base.KEY_SIZE_IN_INTS); }
XChaCha20 extends ChaCha20Base { static int[] hChaCha20(final int[] key, final int[] nonce) { int[] state = new int[ChaCha20Base.BLOCK_SIZE_IN_INTS]; ChaCha20Base.setSigmaAndKey(state, key); state[12] = nonce[0]; state[13] = nonce[1]; state[14] = nonce[2]; state[15] = nonce[3]; ChaCha20Base.shuffleState(state); state[4] = state[12]; state[5] = state[13]; state[6] = state[14]; state[7] = state[15]; return Arrays.copyOf(state, ChaCha20Base.KEY_SIZE_IN_INTS); } }
XChaCha20 extends ChaCha20Base { static int[] hChaCha20(final int[] key, final int[] nonce) { int[] state = new int[ChaCha20Base.BLOCK_SIZE_IN_INTS]; ChaCha20Base.setSigmaAndKey(state, key); state[12] = nonce[0]; state[13] = nonce[1]; state[14] = nonce[2]; state[15] = nonce[3]; ChaCha20Base.shuffleState(state); state[4] = state[12]; state[5] = state[13]; state[6] = state[14]; state[7] = state[15]; return Arrays.copyOf(state, ChaCha20Base.KEY_SIZE_IN_INTS); } XChaCha20(byte[] key, int initialCounter); }
XChaCha20 extends ChaCha20Base { static int[] hChaCha20(final int[] key, final int[] nonce) { int[] state = new int[ChaCha20Base.BLOCK_SIZE_IN_INTS]; ChaCha20Base.setSigmaAndKey(state, key); state[12] = nonce[0]; state[13] = nonce[1]; state[14] = nonce[2]; state[15] = nonce[3]; ChaCha20Base.shuffleState(state); state[4] = state[12]; state[5] = state[13]; state[6] = state[14]; state[7] = state[15]; return Arrays.copyOf(state, ChaCha20Base.KEY_SIZE_IN_INTS); } XChaCha20(byte[] key, int initialCounter);  }
XChaCha20 extends ChaCha20Base { static int[] hChaCha20(final int[] key, final int[] nonce) { int[] state = new int[ChaCha20Base.BLOCK_SIZE_IN_INTS]; ChaCha20Base.setSigmaAndKey(state, key); state[12] = nonce[0]; state[13] = nonce[1]; state[14] = nonce[2]; state[15] = nonce[3]; ChaCha20Base.shuffleState(state); state[4] = state[12]; state[5] = state[13]; state[6] = state[14]; state[7] = state[15]; return Arrays.copyOf(state, ChaCha20Base.KEY_SIZE_IN_INTS); } XChaCha20(byte[] key, int initialCounter);   }