If the window manager does not support _NET_ACTIVE_WINDOW, fall back to XGetInputFocus
[mono.git] / mcs / class / corlib / Test / System.Security.Cryptography / HMACRIPEMD160Test.cs
1 //
2 // HMACRIPEMD160Test.cs - NUnit Test Cases for HMACRIPEMD160
3 //      http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html
4 //
5 // Author:
6 //      Sebastien Pouliot (sebastien@ximian.com)
7 //
8 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
9 // Copyright (C) 2004, 2006, 2007 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30
31 #if NET_2_0
32
33 using NUnit.Framework;
34 using System;
35 using System.IO;
36 using System.Security.Cryptography;
37 using System.Text;
38
39 namespace MonoTests.System.Security.Cryptography {
40
41         public class HR160 : HMACRIPEMD160 {
42
43                 public int BlockSize {
44                         get { return base.BlockSizeValue; }
45                         set { base.BlockSizeValue = value; }
46                 }
47         }
48
49         [TestFixture]
50         public class HMACRIPEMD160Test : KeyedHashAlgorithmTest {
51
52                 protected HMACRIPEMD160 hmac;
53
54                 [SetUp]
55                 protected override void SetUp () 
56                 {
57                         hmac = new HMACRIPEMD160 ();
58                         hmac.Key = new byte [8];
59                         hash = hmac;
60                 }
61
62                 // the hash algorithm only exists as a managed implementation
63                 public override bool ManagedHashImplementation {
64                         get { return true; }
65                 }
66
67                 static byte[] key1 = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x01, 0x23, 0x45, 0x67 };
68
69                 // HMACRIPEMD160 (key1, "") = cf387677bfda8483e63b57e06c3b5ecd8b7fc055
70                 [Test]
71                 public void HMACRIPEMD160_Key1_Test1 () 
72                 {
73                         byte[] result = { 0xcf, 0x38, 0x76, 0x77, 0xbf, 0xda, 0x84, 0x83, 0xe6, 0x3b, 0x57, 0xe0, 0x6c, 0x3b, 0x5e, 0xcd, 0x8b, 0x7f, 0xc0, 0x55 };
74                         byte[] input = new byte [0];
75                 
76                         string testName = "HMACRIPEMD160 Key #1 Test #1";
77                         hmac.Key = key1;
78                         HMACRIPEMD160_a (testName, hmac, input, result);
79                         HMACRIPEMD160_b (testName, hmac, input, result);
80                         HMACRIPEMD160_c (testName, hmac, input, result);
81                         HMACRIPEMD160_d (testName, hmac, input, result);
82                         // N/A RIPEMD160_e (testName, hmac, input, result);
83                 }
84
85                 // HMACRIPEMD160 ("a") = 0d351d71b78e36dbb7391c810a0d2b6240ddbafc
86                 [Test]
87                 public void HMACRIPEMD160_Key1_Test2 () 
88                 {
89                         byte[] result = { 0x0d, 0x35, 0x1d, 0x71, 0xb7, 0x8e, 0x36, 0xdb, 0xb7, 0x39, 0x1c, 0x81, 0x0a, 0x0d, 0x2b, 0x62, 0x40, 0xdd, 0xba, 0xfc };
90                         byte[] input = Encoding.Default.GetBytes ("a");
91                 
92                         string testName = "HMACRIPEMD160 Key #1 Test #2";
93                         hmac.Key = key1;
94                         HMACRIPEMD160_a (testName, hmac, input, result);
95                         HMACRIPEMD160_b (testName, hmac, input, result);
96                         HMACRIPEMD160_c (testName, hmac, input, result);
97                         HMACRIPEMD160_d (testName, hmac, input, result);
98                         HMACRIPEMD160_e (testName, hmac, input, result);
99                 }
100
101                 // HMACRIPEMD160 ("abc") = f7ef288cb1bbcc6160d76507e0a3bbf712fb67d6
102                 [Test]
103                 public void HMACRIPEMD160_Key1_Test3 () 
104                 {
105                         byte[] result = { 0xf7, 0xef, 0x28, 0x8c, 0xb1, 0xbb, 0xcc, 0x61, 0x60, 0xd7, 0x65, 0x07, 0xe0, 0xa3, 0xbb, 0xf7, 0x12, 0xfb, 0x67, 0xd6 };
106                         byte[] input = Encoding.Default.GetBytes ("abc");
107                 
108                         string testName = "HMACRIPEMD160 Key #1 Test #3";
109                         hmac.Key = key1;
110                         HMACRIPEMD160_a (testName, hmac, input, result);
111                         HMACRIPEMD160_b (testName, hmac, input, result);
112                         HMACRIPEMD160_c (testName, hmac, input, result);
113                         HMACRIPEMD160_d (testName, hmac, input, result);
114                         HMACRIPEMD160_e (testName, hmac, input, result);
115                 }
116
117                 // RIPEMD160 ("message digest") = f83662cc8d339c227e600fcd636c57d2571b1c34
118                 [Test]
119                 public void HMACRIPEMD160_Key1_Test4 () 
120                 {
121                         byte[] result = { 0xf8, 0x36, 0x62, 0xcc, 0x8d, 0x33, 0x9c, 0x22, 0x7e, 0x60, 0x0f, 0xcd, 0x63, 0x6c, 0x57, 0xd2, 0x57, 0x1b, 0x1c, 0x34 };
122                         byte[] input = Encoding.Default.GetBytes ("message digest");
123                 
124                         string testName = "HMACRIPEMD160 Key #1 Test #4";
125                         hmac.Key = key1;
126                         HMACRIPEMD160_a (testName, hmac, input, result);
127                         HMACRIPEMD160_b (testName, hmac, input, result);
128                         HMACRIPEMD160_c (testName, hmac, input, result);
129                         HMACRIPEMD160_d (testName, hmac, input, result);
130                         HMACRIPEMD160_e (testName, hmac, input, result);
131                 }
132
133                 // RIPEMD160 ("abcdefghijklmnopqrstuvwxyz") = 843d1c4eb880ac8ac0c9c95696507957d0155ddb
134                 [Test]
135                 public void HMACRIPEMD160_Key1_Test5 () 
136                 {
137                         byte[] result = { 0x84, 0x3d, 0x1c, 0x4e, 0xb8, 0x80, 0xac, 0x8a, 0xc0, 0xc9, 0xc9, 0x56, 0x96, 0x50, 0x79, 0x57, 0xd0, 0x15, 0x5d, 0xdb };
138                         byte[] input = Encoding.Default.GetBytes ("abcdefghijklmnopqrstuvwxyz");
139                 
140                         string testName = "HMACRIPEMD160 Key #1 Test #5";
141                         hmac.Key = key1;
142                         HMACRIPEMD160_a (testName, hmac, input, result);
143                         HMACRIPEMD160_b (testName, hmac, input, result);
144                         HMACRIPEMD160_c (testName, hmac, input, result);
145                         HMACRIPEMD160_d (testName, hmac, input, result);
146                         HMACRIPEMD160_e (testName, hmac, input, result);
147                 }
148
149                 // RIPEMD160 ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") =
150                 //      60f5ef198a2dd5745545c1f0c47aa3fb5776f881
151                 [Test]
152                 public void HMACRIPEMD160_Key1_Test6 () 
153                 {
154                         byte[] result = { 0x60, 0xf5, 0xef, 0x19, 0x8a, 0x2d, 0xd5, 0x74, 0x55, 0x45, 0xc1, 0xf0, 0xc4, 0x7a, 0xa3, 0xfb, 0x57, 0x76, 0xf8, 0x81 };
155                         byte[] input = Encoding.Default.GetBytes ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
156                 
157                         string testName = "HMACRIPEMD160 Key #1 Test #6";
158                         hmac.Key = key1;
159                         HMACRIPEMD160_a (testName, hmac, input, result);
160                         HMACRIPEMD160_b (testName, hmac, input, result);
161                         HMACRIPEMD160_c (testName, hmac, input, result);
162                         HMACRIPEMD160_d (testName, hmac, input, result);
163                         HMACRIPEMD160_e (testName, hmac, input, result);
164                 }
165
166                 // RIPEMD160 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
167                 //      b0e20b6e3116640286ed3a87a5713079b21f5189
168                 [Test]
169                 public void HMACRIPEMD160_Key1_Test7 () 
170                 {
171                         byte[] result = { 0xe4, 0x9c, 0x13, 0x6a, 0x9e, 0x56, 0x27, 0xe0, 0x68, 0x1b, 0x80, 0x8a, 0x3b, 0x97, 0xe6, 0xa6, 0xe6, 0x61, 0xae, 0x79 };
172                         byte[] input = Encoding.Default.GetBytes ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
173                 
174                         string testName = "HMACRIPEMD160 Key #1 Test #7";
175                         hmac.Key = key1;
176                         HMACRIPEMD160_a (testName, hmac, input, result);
177                         HMACRIPEMD160_b (testName, hmac, input, result);
178                         HMACRIPEMD160_c (testName, hmac, input, result);
179                         HMACRIPEMD160_d (testName, hmac, input, result);
180                         HMACRIPEMD160_e (testName, hmac, input, result);
181                 }
182
183                 // RIPEMD160 ("123456789012345678901234567890123456789012345678901234567890123456
184                 //      78901234567890") = 9b752e45573d4b39f4dbd3323cab82bf63326bfb
185                 [Test]
186                 public void HMACRIPEMD160_Key1_Test8 () 
187                 {
188                         byte[] result = { 0x31, 0xbe, 0x3c, 0xc9, 0x8c, 0xee, 0x37, 0xb7, 0x9b, 0x06, 0x19, 0xe3, 0xe1, 0xc2, 0xbe, 0x4f, 0x1a, 0xa5, 0x6e, 0x6c };
189                         byte[] input = Encoding.Default.GetBytes ("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
190                 
191                         string testName = "HMACRIPEMD160 Key #1 Test #8";
192                         hmac.Key = key1;
193                         HMACRIPEMD160_a (testName, hmac, input, result);
194                         HMACRIPEMD160_b (testName, hmac, input, result);
195                         HMACRIPEMD160_c (testName, hmac, input, result);
196                         HMACRIPEMD160_d (testName, hmac, input, result);
197                         HMACRIPEMD160_e (testName, hmac, input, result);
198                 }
199
200                 // RIPEMD160 (1000000 x 'a') = 52783243c1697bdbe16d37f97f68f08325dc1528
201                 [Test]
202                 public void HMACRIPEMD160_Key1_Test9 () 
203                 {
204                         byte[] result = { 0xc2, 0xaa, 0x88, 0xc6, 0x40, 0x56, 0x58, 0xdc, 0x22, 0x5e, 0x48, 0x54, 0x88, 0x37, 0x1f, 0xb2, 0x43, 0x3f, 0xa7, 0x35 };
205                         byte[] input = new byte [1000000];
206                         for (int i = 0; i < 1000000; i++)
207                                 input[i] = 0x61; // a
208                 
209                         string testName = "HMACRIPEMD160 Key #1 Test #9";
210                         hmac.Key = key1;
211                         HMACRIPEMD160_a (testName, hmac, input, result);
212                         HMACRIPEMD160_b (testName, hmac, input, result);
213                         HMACRIPEMD160_c (testName, hmac, input, result);
214                         HMACRIPEMD160_d (testName, hmac, input, result);
215                         HMACRIPEMD160_e (testName, hmac, input, result);
216                 }
217
218                 static byte[] key2 = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x11, 0x22, 0x33 };
219
220                 // HMACRIPEMD160 (key2, "") = fe69a66c7423eea9c8fa2eff8d9dafb4f17a62f5
221                 [Test]
222                 public void HMACRIPEMD160_Key2_Test1 () 
223                 {
224                         byte[] result = { 0xfe, 0x69, 0xa6, 0x6c, 0x74, 0x23, 0xee, 0xa9, 0xc8, 0xfa, 0x2e, 0xff, 0x8d, 0x9d, 0xaf, 0xb4, 0xf1, 0x7a, 0x62, 0xf5 };
225                         byte[] input = new byte [0];
226                 
227                         string testName = "HMACRIPEMD160 Key #2 Test #1";
228                         hmac.Key = key2;
229                         HMACRIPEMD160_a (testName, hmac, input, result);
230                         HMACRIPEMD160_b (testName, hmac, input, result);
231                         HMACRIPEMD160_c (testName, hmac, input, result);
232                         HMACRIPEMD160_d (testName, hmac, input, result);
233                         // N/A RIPEMD160_e (testName, hmac, input, result);
234                 }
235
236                 // HMACRIPEMD160 ("a") = 85743e899bc82dbfa36faaa7a25b7cfd372432cd
237                 [Test]
238                 public void HMACRIPEMD160_Key2_Test2 () 
239                 {
240                         byte[] result = { 0x85, 0x74, 0x3e, 0x89, 0x9b, 0xc8, 0x2d, 0xbf, 0xa3, 0x6f, 0xaa, 0xa7, 0xa2, 0x5b, 0x7c, 0xfd, 0x37, 0x24, 0x32, 0xcd };
241                         byte[] input = Encoding.Default.GetBytes ("a");
242                 
243                         string testName = "HMACRIPEMD160 Key #2 Test #2";
244                         hmac.Key = key2;
245                         HMACRIPEMD160_a (testName, hmac, input, result);
246                         HMACRIPEMD160_b (testName, hmac, input, result);
247                         HMACRIPEMD160_c (testName, hmac, input, result);
248                         HMACRIPEMD160_d (testName, hmac, input, result);
249                         HMACRIPEMD160_e (testName, hmac, input, result);
250                 }
251
252                 // HMACRIPEMD160 ("abc") = 6e4afd501fa6b4a1823ca3b10bd9aa0ba97ba182
253                 [Test]
254                 public void HMACRIPEMD160_Key2_Test3 () 
255                 {
256                         byte[] result = { 0x6e, 0x4a, 0xfd, 0x50, 0x1f, 0xa6, 0xb4, 0xa1, 0x82, 0x3c, 0xa3, 0xb1, 0x0b, 0xd9, 0xaa, 0x0b, 0xa9, 0x7b, 0xa1, 0x82 };
257                         byte[] input = Encoding.Default.GetBytes ("abc");
258                 
259                         string testName = "HMACRIPEMD160 Key #2 Test #3";
260                         hmac.Key = key2;
261                         HMACRIPEMD160_a (testName, hmac, input, result);
262                         HMACRIPEMD160_b (testName, hmac, input, result);
263                         HMACRIPEMD160_c (testName, hmac, input, result);
264                         HMACRIPEMD160_d (testName, hmac, input, result);
265                         HMACRIPEMD160_e (testName, hmac, input, result);
266                 }
267
268                 // RIPEMD160 ("message digest") = 2e066e624badb76a184c8f90fba053330e650e92
269                 [Test]
270                 public void HMACRIPEMD160_Key2_Test4 () 
271                 {
272                         byte[] result = { 0x2e, 0x06, 0x6e, 0x62, 0x4b, 0xad, 0xb7, 0x6a, 0x18, 0x4c, 0x8f, 0x90, 0xfb, 0xa0, 0x53, 0x33, 0x0e, 0x65, 0x0e, 0x92 };
273                         byte[] input = Encoding.Default.GetBytes ("message digest");
274                 
275                         string testName = "HMACRIPEMD160 Key #2 Test #4";
276                         hmac.Key = key2;
277                         HMACRIPEMD160_a (testName, hmac, input, result);
278                         HMACRIPEMD160_b (testName, hmac, input, result);
279                         HMACRIPEMD160_c (testName, hmac, input, result);
280                         HMACRIPEMD160_d (testName, hmac, input, result);
281                         HMACRIPEMD160_e (testName, hmac, input, result);
282                 }
283
284                 // RIPEMD160 ("abcdefghijklmnopqrstuvwxyz") = 07e942aa4e3cd7c04dedc1d46e2e8cc4c741b3d9
285                 [Test]
286                 public void HMACRIPEMD160_Key2_Test5 () 
287                 {
288                         byte[] result = { 0x07, 0xe9, 0x42, 0xaa, 0x4e, 0x3c, 0xd7, 0xc0, 0x4d, 0xed, 0xc1, 0xd4, 0x6e, 0x2e, 0x8c, 0xc4, 0xc7, 0x41, 0xb3, 0xd9 };
289                         byte[] input = Encoding.Default.GetBytes ("abcdefghijklmnopqrstuvwxyz");
290                 
291                         string testName = "HMACRIPEMD160 Key #2 Test #5";
292                         hmac.Key = key2;
293                         HMACRIPEMD160_a (testName, hmac, input, result);
294                         HMACRIPEMD160_b (testName, hmac, input, result);
295                         HMACRIPEMD160_c (testName, hmac, input, result);
296                         HMACRIPEMD160_d (testName, hmac, input, result);
297                         HMACRIPEMD160_e (testName, hmac, input, result);
298                 }
299
300                 // RIPEMD160 ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq") =
301                 //      b6582318ddcfb67a53a67d676b8ad869aded629a
302                 [Test]
303                 public void HMACRIPEMD160_Key2_Test6 () 
304                 {
305                         byte[] result = { 0xb6, 0x58, 0x23, 0x18, 0xdd, 0xcf, 0xb6, 0x7a, 0x53, 0xa6, 0x7d, 0x67, 0x6b, 0x8a, 0xd8, 0x69, 0xad, 0xed, 0x62, 0x9a };
306                         byte[] input = Encoding.Default.GetBytes ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
307                 
308                         string testName = "HMACRIPEMD160 Key #2 Test #6";
309                         hmac.Key = key2;
310                         HMACRIPEMD160_a (testName, hmac, input, result);
311                         HMACRIPEMD160_b (testName, hmac, input, result);
312                         HMACRIPEMD160_c (testName, hmac, input, result);
313                         HMACRIPEMD160_d (testName, hmac, input, result);
314                         HMACRIPEMD160_e (testName, hmac, input, result);
315                 }
316
317                 // RIPEMD160 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
318                 //      f1be3ee877703140d34f97ea1ab3a07c141333e2
319                 [Test]
320                 public void HMACRIPEMD160_Key2_Test7 () 
321                 {
322                         byte[] result = { 0xf1, 0xbe, 0x3e, 0xe8, 0x77, 0x70, 0x31, 0x40, 0xd3, 0x4f, 0x97, 0xea, 0x1a, 0xb3, 0xa0, 0x7c, 0x14, 0x13, 0x33, 0xe2 };
323                         byte[] input = Encoding.Default.GetBytes ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
324                 
325                         string testName = "HMACRIPEMD160 Key #2 Test #7";
326                         hmac.Key = key2;
327                         HMACRIPEMD160_a (testName, hmac, input, result);
328                         HMACRIPEMD160_b (testName, hmac, input, result);
329                         HMACRIPEMD160_c (testName, hmac, input, result);
330                         HMACRIPEMD160_d (testName, hmac, input, result);
331                         HMACRIPEMD160_e (testName, hmac, input, result);
332                 }
333
334                 // RIPEMD160 ("123456789012345678901234567890123456789012345678901234567890123456
335                 //      78901234567890") = 85f164703e61a63131be7e45958e0794123904f9
336                 [Test]
337                 public void HMACRIPEMD160_Key2_Test8 () 
338                 {
339                         byte[] result = { 0x85, 0xf1, 0x64, 0x70, 0x3e, 0x61, 0xa6, 0x31, 0x31, 0xbe, 0x7e, 0x45, 0x95, 0x8e, 0x07, 0x94, 0x12, 0x39, 0x04, 0xf9 };
340                         byte[] input = Encoding.Default.GetBytes ("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
341                 
342                         string testName = "HMACRIPEMD160 Key #2 Test #8";
343                         hmac.Key = key2;
344                         HMACRIPEMD160_a (testName, hmac, input, result);
345                         HMACRIPEMD160_b (testName, hmac, input, result);
346                         HMACRIPEMD160_c (testName, hmac, input, result);
347                         HMACRIPEMD160_d (testName, hmac, input, result);
348                         HMACRIPEMD160_e (testName, hmac, input, result);
349                 }
350
351                 // RIPEMD160 (1000000 x 'a') = 82a504a002ba6e6c67f3cd67cedb66dc169bab7a
352                 [Test]
353                 public void HMACRIPEMD160_Key2_Test9 () 
354                 {
355                         byte[] result = { 0x82, 0xa5, 0x04, 0xa0, 0x02, 0xba, 0x6e, 0x6c, 0x67, 0xf3, 0xcd, 0x67, 0xce, 0xdb, 0x66, 0xdc, 0x16, 0x9b, 0xab, 0x7a };
356                         byte[] input = new byte [1000000];
357                         for (int i = 0; i < 1000000; i++)
358                                 input[i] = 0x61; // a
359                 
360                         string testName = "HMACRIPEMD160 Key #2 Test #9";
361                         hmac.Key = key2;
362                         HMACRIPEMD160_a (testName, hmac, input, result);
363                         HMACRIPEMD160_b (testName, hmac, input, result);
364                         HMACRIPEMD160_c (testName, hmac, input, result);
365                         HMACRIPEMD160_d (testName, hmac, input, result);
366                         HMACRIPEMD160_e (testName, hmac, input, result);
367                 }
368
369                 public void HMACRIPEMD160_a (string testName, HMACRIPEMD160 hmac, byte[] input, byte[] result) 
370                 {
371                         byte[] output = hmac.ComputeHash (input); 
372                         Assert.AreEqual (result, output, testName + ".a.1");
373                         Assert.AreEqual (result, hmac.Hash, testName + ".a.2");
374                         // required or next operation will still return old hash
375                         hmac.Initialize ();
376                 }
377
378                 public void HMACRIPEMD160_b (string testName, HMACRIPEMD160 hmac, byte[] input, byte[] result) 
379                 {
380                         byte[] output = hmac.ComputeHash (input, 0, input.Length); 
381                         Assert.AreEqual (result, output, testName + ".b.1");
382                         Assert.AreEqual (result, hmac.Hash, testName + ".b.2");
383                         // required or next operation will still return old hash
384                         hmac.Initialize ();
385                 }
386
387                 public void HMACRIPEMD160_c (string testName, HMACRIPEMD160 hmac, byte[] input, byte[] result) 
388                 {
389                         MemoryStream ms = new MemoryStream (input);
390                         byte[] output = hmac.ComputeHash (ms); 
391                         Assert.AreEqual (result, output, testName + ".c.1");
392                         Assert.AreEqual (result, hmac.Hash, testName + ".c.2");
393                         // required or next operation will still return old hash
394                         hmac.Initialize ();
395                 }
396
397                 public void HMACRIPEMD160_d (string testName, HMACRIPEMD160 hmac, byte[] input, byte[] result) 
398                 {
399                         hmac.TransformFinalBlock (input, 0, input.Length);
400                         Assert.AreEqual (result, hmac.Hash, testName + ".d");
401                         // required or next operation will still return old hash
402                         hmac.Initialize ();
403                 }
404
405                 public void HMACRIPEMD160_e (string testName, HMACRIPEMD160 hmac, byte[] input, byte[] result) 
406                 {
407                         byte[] copy = new byte [input.Length];
408                         for (int i=0; i < input.Length - 1; i++)
409                                 hmac.TransformBlock (input, i, 1, copy, i);
410                         hmac.TransformFinalBlock (input, input.Length - 1, 1);
411                         Assert.AreEqual (result, hmac.Hash, testName + ".e");
412                         // required or next operation will still return old hash
413                         hmac.Initialize ();
414                 }
415
416                 // none of those values changes for any implementation of RIPEMD160
417                 [Test]
418                 public void Invariants ()
419                 {
420                         Assert.IsTrue (hmac.CanReuseTransform, "HMACRIPEMD160.CanReuseTransform");
421                         Assert.IsTrue (hmac.CanTransformMultipleBlocks, "HMACRIPEMD160.CanTransformMultipleBlocks");
422                         Assert.AreEqual ("RIPEMD160", hmac.HashName, "HMACRIPEMD160.HashName");
423                         Assert.AreEqual (160, hmac.HashSize, "HMACRIPEMD160.HashSize");
424                         Assert.AreEqual (1, hmac.InputBlockSize, "HMACRIPEMD160.InputBlockSize");
425                         Assert.AreEqual (1, hmac.OutputBlockSize, "HMACRIPEMD160.OutputBlockSize");
426                         Assert.AreEqual ("System.Security.Cryptography.HMACRIPEMD160", hmac.ToString (), "HMACRIPEMD160.ToString()");
427                 }
428
429                 [Test]
430                 public void BlockSize ()
431                 {
432                         HR160 hmac = new HR160 ();
433                         Assert.AreEqual (64, hmac.BlockSize, "BlockSizeValue");
434                 }
435         }
436 }
437
438 #endif