Exemplo n.º 1
0
        public void TestStreamAndArrayHashMatchOne()
        {
            LargeMemoryStream.Position = 0;
            ActualString   = HashInstance.ComputeStream(LargeMemoryStream).ToString();
            ExpectedString = HashInstance.ComputeBytes(LargeMemoryStream.ToArray()).ToString();

            AssertAreEqual(ExpectedString, ActualString);
        }
Exemplo n.º 2
0
        public void TestHMACWorkingKeyIsCorrectLongKey()
        {
            var key = GenerateByteArrayInRange(0x0, HMACInstance.BlockSize + 1);

            HMACInstance.Key = key;
            AssertAreEqual(HashInstance.ComputeBytes(key).GetBytes(), HMACInstance.WorkingKey,
                           $"Working key mismatch in '{HMACInstance.Name}'");
        }
Exemplo n.º 3
0
 public void TestCheckUnKeyedTestVectors()
 {
     for (var idx = 0; idx < UnKeyedTestVectors.Length; idx++)
     {
         ActualString   = HashInstance.ComputeBytes(GenerateByteArrayInRange(0, idx)).ToString();
         ExpectedString = UnKeyedTestVectors[idx];
         AssertAreEqual(ExpectedString, ActualString);
     }
 }
Exemplo n.º 4
0
 public unsafe void TestUntypedInterface()
 {
     fixed(byte *srcPtr = SmallLettersAToEBytes)
     {
         ExpectedString = HashInstance.ComputeBytes(SmallLettersAToEBytes).ToString();
         ActualString   = HashInstance.ComputeUntyped(srcPtr, SmallLettersAToEBytes.Length)
                          .ToString();
         AssertAreEqual(ExpectedString, ActualString);
     }
 }
Exemplo n.º 5
0
 public void TestHashOfOneToNine()
 {
     ExpectedString = HashOfOneToNine;
     ActualString   = HashInstance.ComputeBytes(OneToNineBytes).ToString();
     AssertAreEqual(ExpectedString, ActualString);
 }
Exemplo n.º 6
0
 public void TestHashOfSmallLettersAToE()
 {
     ExpectedString = HashOfSmallLettersAToE;
     ActualString   = HashInstance.ComputeBytes(SmallLettersAToEBytes).ToString();
     AssertAreEqual(ExpectedString, ActualString);
 }
Exemplo n.º 7
0
 public void TestHashOfDefaultData()
 {
     ExpectedString = HashOfDefaultData;
     ActualString   = HashInstance.ComputeBytes(DefaultDataBytes).ToString();
     AssertAreEqual(ExpectedString, ActualString);
 }
Exemplo n.º 8
0
 public void TestHashingReadOnlySpanVsArray() =>
 AssertAreEqual(HashInstance.ComputeByteSpan(new ReadOnlySpan <byte>(DefaultDataBytes)).ToString(),
                HashInstance.ComputeBytes(DefaultDataBytes).ToString());
Exemplo n.º 9
0
 public void TestHashingEmptyReadOnlySpanVsEmptyArray() => AssertAreEqual(
     HashInstance.ComputeByteSpan(ReadOnlySpan <byte> .Empty).ToString(),
     HashInstance.ComputeBytes(EmptyBytes).ToString());
Exemplo n.º 10
0
 public void TestHashingNullDataThrowsCorrectException() =>
 Assert.Throws <ArgumentNullException>(() => HashInstance.ComputeBytes(NullBytes));