public void TestXfrmReuse(byte[] sk, byte[] iv, ZucVersion version, byte[] input) { var cipher = new Eea3Transform(sk, iv, true, version); var cipherText = cipher.TransformFinalBlock(input, 0, input.Length); var plaintext = cipher.TransformFinalBlock(cipherText, 0, cipherText.Length); Assert.Equal(input.AsEnumerable(), plaintext); }
public void TestVector(byte[] sk, uint count, byte bearer, byte direction, int bits, byte[] plaintext, byte[] ciphertext) { var iv = new byte[16]; iv[0] = (byte)(count >> 24); iv[1] = (byte)(count >> 16); iv[2] = (byte)(count >> 8); iv[3] = (byte)count; iv[4] = (byte)((bearer << 3) | (direction << 2)); iv[5] = iv[6] = iv[7] = 0; Array.Copy(iv, 0, iv, 8, 8); var cipher = new Eea3Transform(sk, iv); var cipherOutput = new byte[plaintext.Length]; cipher.TransformBits(plaintext, cipherOutput, bits); Assert.Equal(ciphertext.AsEnumerable(), cipherOutput); cipher.TransformFinalBlock(Array.Empty <byte>(), 0, 0); Assert.Throws <InvalidOperationException>(() => cipher.TransformBlock(plaintext, 0, bits, cipherOutput, 0)); }