-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathSHA3_224_Tests.cs
More file actions
76 lines (64 loc) · 2.28 KB
/
SHA3_224_Tests.cs
File metadata and controls
76 lines (64 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Waher.Security.SHA3.Test
{
[TestClass]
public partial class SHA3_224_Tests
{
[TestMethod]
public void Test_01_0_bits()
{
SHA3_224 H = new();
int i = 0;
H.NewState += (Sender, e) =>
{
string Expected = States0Bits[i++].Replace(" ", string.Empty);
string Actual = Hashes.BinaryToString(H.GetState()).ToUpper();
Assert.AreEqual(Expected, Actual);
};
byte[] Digest = H.ComputeVariable([]);
string s = Hashes.BinaryToString(Digest);
Assert.AreEqual("6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7", s);
Assert.AreEqual(States0Bits.Length, i);
}
[TestMethod]
public void Test_02_1600_bits()
{
SHA3_224 H = new();
int i = 0;
H.NewState += (Sender, e) =>
{
string Expected = States1600Bits[i++].Replace(" ", string.Empty);
string Actual = Hashes.BinaryToString(H.GetState()).ToUpper();
Assert.AreEqual(Expected, Actual);
};
byte[] Input = new byte[200];
int j;
for (j = 0; j < 200; j++)
Input[j] = 0xa3;
byte[] Digest = H.ComputeVariable(Input);
string s = Hashes.BinaryToString(Digest);
Assert.AreEqual("9376816aba503f72f96ce7eb65ac095deee3be4bf9bbc2a1cb7e11e0", s);
Assert.AreEqual(States1600Bits.Length, i);
}
[TestMethod]
public void Test_03_1600_bits_Stream()
{
SHA3_224 H = new();
byte[] Input = new byte[200];
int j;
for (j = 0; j < 200; j++)
Input[j] = 0xa3;
byte[] Digest = H.ComputeVariable(new MemoryStream(Input));
string s = Hashes.BinaryToString(Digest);
Assert.AreEqual("9376816aba503f72f96ce7eb65ac095deee3be4bf9bbc2a1cb7e11e0", s);
}
[TestMethod]
public void Test_04_Performance()
{
byte[] Data = new byte[80 * 1024 * 1024];
SHA3_224 H = new();
H.ComputeVariable(Data);
}
}
}