GetMac() public method

public GetMac ( ) : byte[]
return byte[]
Example #1
0
		private void runCheckVectors(
			int				count,
			EaxBlockCipher	encEax,
			EaxBlockCipher	decEax,
            string          additionalDataType,
            byte[]          sa,
            byte[]          p,
			byte[]			t,
			byte[]			c)
		{
			byte[] enc = new byte[c.Length];

            if (sa != null)
            {
                encEax.ProcessAadBytes(sa, 0, sa.Length);
            }

			int len = encEax.ProcessBytes(p, 0, p.Length, enc, 0);

			len += encEax.DoFinal(enc, len);

			if (!AreEqual(c, enc))
			{
                Fail("encrypted stream fails to match in test " + count + " with " + additionalDataType);
            }

			byte[] tmp = new byte[enc.Length];

            if (sa != null)
            {
                decEax.ProcessAadBytes(sa, 0, sa.Length);
            }

            len = decEax.ProcessBytes(enc, 0, enc.Length, tmp, 0);

			len += decEax.DoFinal(tmp, len);

			byte[] dec = new byte[len];

			Array.Copy(tmp, 0, dec, 0, len);

			if (!AreEqual(p, dec))
			{
                Fail("decrypted stream fails to match in test " + count + " with " + additionalDataType);
            }

			if (!AreEqual(t, decEax.GetMac()))
			{
                Fail("MAC fails to match in test " + count + " with " + additionalDataType);
            }
		}
Example #2
0
        private void runCheckVectors(
			int				count,
			EaxBlockCipher	encEax,
			EaxBlockCipher	decEax,
			byte[]			p,
			byte[]			t,
			byte[]			c)
        {
            byte[] enc = new byte[c.Length];

            int len = encEax.ProcessBytes(p, 0, p.Length, enc, 0);

            len += encEax.DoFinal(enc, len);

            if (!AreEqual(c, enc))
            {
                Fail("encrypted stream fails to match in test " + count);
            }

            byte[] tmp = new byte[enc.Length];

            len = decEax.ProcessBytes(enc, 0, enc.Length, tmp, 0);

            len += decEax.DoFinal(tmp, len);

            byte[] dec = new byte[len];

            Array.Copy(tmp, 0, dec, 0, len);

            if (!AreEqual(p, dec))
            {
                Fail("decrypted stream fails to match in test " + count);
            }

            if (!AreEqual(t, decEax.GetMac()))
            {
                Fail("MAC fails to match in test " + count);
            }
        }