public void FIPS186_Test1 (SHA224 hash) { string className = hash.ToString (); byte[] result = { 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22, 0x86, 0x42, 0xA4, 0x77, 0xBD, 0xA2, 0x55, 0xB3, 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3, 0xF7, 0xE3, 0x6C, 0x9D, 0xA7 }; byte[] input = Encoding.Default.GetBytes (input1); string testName = className + " 1"; FIPS186_a (testName, hash, input, result); FIPS186_b (testName, hash, input, result); FIPS186_c (testName, hash, input, result); FIPS186_d (testName, hash, input, result); FIPS186_e (testName, hash, input, result); }
public new static SHA224 Create() { return(SHA224.Create("SHA224")); }
public void FIPS186_Test2 (SHA224 hash) { string className = hash.ToString (); byte[] result = { 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27, 0x76, 0xCC, 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50, 0xB0, 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19, 0x52, 0x52, 0x25, 0x25 }; byte[] input = Encoding.Default.GetBytes (input2); string testName = className + " 2"; FIPS186_a (testName, hash, input, result); FIPS186_b (testName, hash, input, result); FIPS186_c (testName, hash, input, result); FIPS186_d (testName, hash, input, result); FIPS186_e (testName, hash, input, result); }
public void FIPS186_e (string testName, SHA224 hash, byte[] input, byte[] result) { byte[] copy = new byte [input.Length]; for (int i=0; i < input.Length - 1; i++) hash.TransformBlock (input, i, 1, copy, i); hash.TransformFinalBlock (input, input.Length - 1, 1); // Note: TransformFinalBlock doesn't return HashValue ! // AssertEquals (testName + ".e.1", result, output); AssertEquals (testName + ".e", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); }
public void FIPS186_d (string testName, SHA224 hash, byte[] input, byte[] result) { hash.TransformFinalBlock (input, 0, input.Length); // Note: TransformFinalBlock doesn't return HashValue ! // AssertEquals( testName + ".d.1", result, output ); AssertEquals (testName + ".d", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); }
public void FIPS186_c (string testName, SHA224 hash, byte[] input, byte[] result) { MemoryStream ms = new MemoryStream (input); byte[] output = hash.ComputeHash (ms); AssertEquals (testName + ".c.1", result, output); AssertEquals (testName + ".c.2", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); }
public void FIPS186_b (string testName, SHA224 hash, byte[] input, byte[] result) { byte[] output = hash.ComputeHash (input, 0, input.Length); AssertEquals (testName + ".b.1", result, output); AssertEquals (testName + ".b.2", result, hash.Hash); // required or next operation will still return old hash hash.Initialize (); }
public void FIPS186_Test3 (SHA224 hash) { string className = hash.ToString (); byte [] result = { 0x20, 0x79, 0x46, 0x55, 0x98, 0x0C, 0x91, 0xD8, 0xBB, 0xB4, 0xC1, 0xEA, 0x97, 0x61, 0x8A, 0x4B, 0xF0, 0x3F, 0x42, 0x58, 0x19, 0x48, 0xB2, 0xEE, 0x4E, 0xE7, 0xAD, 0x67 }; byte[] input = new byte [1000000]; for (int i = 0; i < 1000000; i++) input[i] = 0x61; // a string testName = className + " 3"; FIPS186_a (testName, hash, input, result); FIPS186_b (testName, hash, input, result); FIPS186_c (testName, hash, input, result); FIPS186_d (testName, hash, input, result); FIPS186_e (testName, hash, input, result); }
public new static SHA224 Create() { return(SHA224.Create(nameof(SHA224))); }