Ejemplo n.º 1
0
		public override void PerformTest()
		{
			for (int i = 0; i < TEST_VECTORS.Length; i++)
			{
				TestCase testCase = TEST_VECTORS[i];

				IMac mac = new GMac(new GcmBlockCipher(new AesFastEngine()), testCase.getTag().Length * 8);
				ICipherParameters key = new KeyParameter(testCase.getKey());
				mac.Init(new ParametersWithIV(key, testCase.getIv()));

				testSingleByte(mac, testCase);
				testMultibyte(mac, testCase);
			}

			// Invalid mac size
			testInvalidMacSize(97);
			testInvalidMacSize(136);
			testInvalidMacSize(88);
			testInvalidMacSize(64);
		}
Ejemplo n.º 2
0
		private void testInvalidMacSize(int size)
		{
			try
			{
				GMac mac = new GMac(new GcmBlockCipher(new AesFastEngine()), size);
				mac.Init(new ParametersWithIV(null, new byte[16]));
				Fail("Expected failure for illegal mac size " + size);
			}
			catch (ArgumentException)
			{
			}
		}
Ejemplo n.º 3
0
 private void testInvalidMacSize(int size)
 {
     try
     {
         GMac mac = new GMac(new GcmBlockCipher(new AesFastEngine()), size);
         mac.Init(new ParametersWithIV(null, new byte[16]));
         Fail("Expected failure for illegal mac size " + size);
     }
     catch (ArgumentException e)
     {
         if (!e.Message.StartsWith("Invalid value for MAC size"))
         {
             Fail("Illegal mac size failed with unexpected message");
         }
     }
 }