@Test public void testQuarterRound2() { int buf[] = { 0x879531e0, 0xc5ecf37d, 0x516461b1, 0xc9a62f8a, 0x44c20ef3, 0x3390af7f, 0xd9fc690b, 0x2a5f714c, 0x53372767, 0xb00a5631, 0x974c541a, 0x359e9963, 0x5c971061, 0x3d631689, 0x2098d9d6, 0x91dbd320 }; int expected[] = { 0x879531e0, 0xc5ecf37d, 0xbdb886dc, 0xc9a62f8a, 0x44c20ef3, 0x3390af7f, 0xd9fc690b, 0xcfacafd2, 0xe46bea80, 0xb00a5631, 0x974c541a, 0x359e9963, 0x5c971061, 0xccc07c79, 0x2098d9d6, 0x91dbd320 }; ChaCha20.quarterRound(buf, 2, 7, 8, 13); assertTrue(Arrays.equals(buf, expected)); }
protected static void quarterRound(int[] x, int a, int b, int c, int d) { x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 16); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 12); x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 8); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 7); }
ChaCha20 { protected static void quarterRound(int[] x, int a, int b, int c, int d) { x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 16); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 12); x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 8); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 7); } }
ChaCha20 { protected static void quarterRound(int[] x, int a, int b, int c, int d) { x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 16); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 12); x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 8); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 7); } ChaCha20(byte[] key, byte[] nonce, int counter); }
ChaCha20 { protected static void quarterRound(int[] x, int a, int b, int c, int d) { x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 16); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 12); x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 8); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 7); } ChaCha20(byte[] key, byte[] nonce, int counter); void encrypt(byte[] dst, byte[] src, int len); void decrypt(byte[] dst, byte[] src, int len); }
ChaCha20 { protected static void quarterRound(int[] x, int a, int b, int c, int d) { x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 16); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 12); x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 8); x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 7); } ChaCha20(byte[] key, byte[] nonce, int counter); void encrypt(byte[] dst, byte[] src, int len); void decrypt(byte[] dst, byte[] src, int len); static final int KEY_SIZE; static final int NONCE_SIZE_REF; static final int NONCE_SIZE_IETF; }