1 |
|
---|
2 | #include "config_xor.h"
|
---|
3 |
|
---|
4 | #include <string.h>
|
---|
5 | #include <stdlib.h>
|
---|
6 | #include <stdio.h>
|
---|
7 | #include "CuTest.h"
|
---|
8 |
|
---|
9 | #include "sh_tiger.h"
|
---|
10 |
|
---|
11 | #if defined(HAVE_PTHREAD) && defined(SH_STEALTH)
|
---|
12 | extern void sh_g_init(void);
|
---|
13 | #endif
|
---|
14 |
|
---|
15 |
|
---|
16 | static void init(void) {
|
---|
17 |
|
---|
18 | extern unsigned char TcpFlag[8][PW_LEN+1];
|
---|
19 | extern UINT32 ErrFlag[2];
|
---|
20 | unsigned char * dez = NULL;
|
---|
21 | int i;
|
---|
22 |
|
---|
23 | #if defined(HAVE_PTHREAD) && defined(SH_STEALTH)
|
---|
24 | sh_g_init();
|
---|
25 | #endif
|
---|
26 | skey = (sh_key_t *) malloc (sizeof(sh_key_t));
|
---|
27 | if (skey != NULL)
|
---|
28 | {
|
---|
29 | skey->mlock_failed = SL_FALSE;
|
---|
30 | skey->rngI = BAD;
|
---|
31 | /* properly initialized later
|
---|
32 | */
|
---|
33 | skey->rng0[0] = 0x03; skey->rng0[1] = 0x09; skey->rng0[2] = 0x17;
|
---|
34 | skey->rng1[0] = 0x03; skey->rng1[1] = 0x09; skey->rng1[2] = 0x17;
|
---|
35 | skey->rng2[0] = 0x03; skey->rng2[1] = 0x09; skey->rng2[2] = 0x17;
|
---|
36 |
|
---|
37 | for (i = 0; i < KEY_BYT; ++i)
|
---|
38 | skey->poolv[i] = '\0';
|
---|
39 |
|
---|
40 | skey->poolc = 0;
|
---|
41 |
|
---|
42 | skey->ErrFlag[0] = ErrFlag[0];
|
---|
43 | ErrFlag[0] = 0;
|
---|
44 | skey->ErrFlag[1] = ErrFlag[1];
|
---|
45 | ErrFlag[1] = 0;
|
---|
46 |
|
---|
47 | dez = &(TcpFlag[POS_TF-1][0]);
|
---|
48 | for (i = 0; i < PW_LEN; ++i)
|
---|
49 | {
|
---|
50 | skey->pw[i] = (char) (*dez);
|
---|
51 | (*dez) = '\0';
|
---|
52 | ++dez;
|
---|
53 | }
|
---|
54 |
|
---|
55 | skey->sh_sockpass[0] = '\0';
|
---|
56 | skey->sigkey_old[0] = '\0';
|
---|
57 | skey->sigkey_new[0] = '\0';
|
---|
58 | skey->mailkey_old[0] = '\0';
|
---|
59 | skey->mailkey_new[0] = '\0';
|
---|
60 | skey->crypt[0] = '\0';
|
---|
61 | skey->session[0] = '\0';
|
---|
62 | skey->vernam[0] = '\0';
|
---|
63 | }
|
---|
64 | else
|
---|
65 | {
|
---|
66 | perror(_("sh_init"));
|
---|
67 | _exit (EXIT_FAILURE);
|
---|
68 | }
|
---|
69 |
|
---|
70 | }
|
---|
71 |
|
---|
72 | void Test_tiger(CuTest *tc) {
|
---|
73 |
|
---|
74 | char * input;
|
---|
75 | char * actual;
|
---|
76 | char * expected;
|
---|
77 | char hashbuf[KEYBUF_SIZE];
|
---|
78 |
|
---|
79 | #if defined(HAVE_PTHREAD) && defined(SH_STEALTH)
|
---|
80 | sh_g_init();
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | input = "";
|
---|
84 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
85 | expected = "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A";
|
---|
86 | CuAssertStrEquals(tc, expected, actual);
|
---|
87 |
|
---|
88 | input = "abc";
|
---|
89 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
90 | expected = "F258C1E88414AB2A527AB541FFC5B8BF935F7B951C132951";
|
---|
91 | CuAssertStrEquals(tc, expected, actual);
|
---|
92 |
|
---|
93 | input = "Tiger";
|
---|
94 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
95 | expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF";
|
---|
96 | CuAssertStrEquals(tc, expected, actual);
|
---|
97 |
|
---|
98 | input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
|
---|
99 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
100 | expected = "87FB2A9083851CF7470D2CF810E6DF9EB586445034A5A386";
|
---|
101 | CuAssertStrEquals(tc, expected, actual);
|
---|
102 |
|
---|
103 | input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789";
|
---|
104 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
105 | expected = "467DB80863EBCE488DF1CD1261655DE957896565975F9197";
|
---|
106 | CuAssertStrEquals(tc, expected, actual);
|
---|
107 |
|
---|
108 | input = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham";
|
---|
109 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
110 | expected = "0C410A042968868A1671DA5A3FD29A725EC1E457D3CDB303";
|
---|
111 | CuAssertStrEquals(tc, expected, actual);
|
---|
112 |
|
---|
113 | input = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge.";
|
---|
114 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
115 | expected = "EBF591D5AFA655CE7F22894FF87F54AC89C811B6B0DA3193";
|
---|
116 | CuAssertStrEquals(tc, expected, actual);
|
---|
117 |
|
---|
118 | input = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.";
|
---|
119 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
120 | expected = "3D9AEB03D1BD1A6357B2774DFD6D5B24DD68151D503974FC";
|
---|
121 | CuAssertStrEquals(tc, expected, actual);
|
---|
122 |
|
---|
123 | input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
|
---|
124 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
125 | expected = "00B83EB4E53440C576AC6AAEE0A7485825FD15E70A59FFE4";
|
---|
126 | CuAssertStrEquals(tc, expected, actual);
|
---|
127 | }
|
---|
128 |
|
---|
129 | void Test_tiger_file(CuTest *tc) {
|
---|
130 |
|
---|
131 | SL_TICKET rval_open;
|
---|
132 | FILE * fp;
|
---|
133 | int result;
|
---|
134 | char * actual;
|
---|
135 | char * expected;
|
---|
136 | char hashbuf[KEYBUF_SIZE];
|
---|
137 | UINT64 length;
|
---|
138 |
|
---|
139 | init();
|
---|
140 |
|
---|
141 | fp = fopen("cutest_foo", "w");
|
---|
142 | CuAssertPtrNotNull(tc, fp);
|
---|
143 |
|
---|
144 | result = fprintf(fp, "%s\n",
|
---|
145 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789");
|
---|
146 | CuAssertTrue(tc, result >= 0);
|
---|
147 |
|
---|
148 | result = fclose(fp);
|
---|
149 | CuAssertTrue(tc, result == 0);
|
---|
150 |
|
---|
151 | result = sh_tiger_hashtype("TIGER192");
|
---|
152 | CuAssertTrue(tc, result == 0);
|
---|
153 |
|
---|
154 | /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
|
---|
155 | */
|
---|
156 | length = TIGER_NOLIM;
|
---|
157 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
158 | expected = "0E9321614C966A33608C2A15F156E0435CACFD1213B9F095";
|
---|
159 | CuAssertStrEquals(tc, expected, actual);
|
---|
160 |
|
---|
161 | rval_open = sl_open_fastread (__FILE__, __LINE__, "cutest_foo", SL_YESPRIV);
|
---|
162 | CuAssertTrue(tc, rval_open >= 0);
|
---|
163 |
|
---|
164 | length = TIGER_NOLIM;
|
---|
165 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
166 | expected = "0E9321614C966A33608C2A15F156E0435CACFD1213B9F095";
|
---|
167 | CuAssertStrEquals(tc, expected, actual);
|
---|
168 |
|
---|
169 | result = sl_close(rval_open);
|
---|
170 | CuAssertTrue(tc, result == 0);
|
---|
171 |
|
---|
172 | result = sh_tiger_hashtype("MD5");
|
---|
173 | CuAssertTrue(tc, result == 0);
|
---|
174 |
|
---|
175 | rval_open = sl_open_fastread (__FILE__, __LINE__, "cutest_foo", SL_YESPRIV);
|
---|
176 | CuAssertTrue(tc, rval_open >= 0);
|
---|
177 |
|
---|
178 | /* same result as GNU md5sum
|
---|
179 | */
|
---|
180 | length = TIGER_NOLIM;
|
---|
181 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
182 | expected = "AEEC4DDA496BCFBA691F4E8863BA84C00000000000000000";
|
---|
183 | CuAssertStrEquals(tc, expected, actual);
|
---|
184 |
|
---|
185 | result = sl_close(rval_open);
|
---|
186 | CuAssertTrue(tc, result == 0);
|
---|
187 |
|
---|
188 | result = sh_tiger_hashtype("SHA1");
|
---|
189 | CuAssertTrue(tc, result == 0);
|
---|
190 |
|
---|
191 | rval_open = sl_open_fastread (__FILE__, __LINE__, "cutest_foo", SL_YESPRIV);
|
---|
192 | CuAssertTrue(tc, rval_open >= 0);
|
---|
193 |
|
---|
194 | /* same result as gpg --print-md SHA1
|
---|
195 | */
|
---|
196 | length = TIGER_NOLIM;
|
---|
197 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
198 | expected = "2FE65D1D995B8F8BC8B13F798C07E7E935A787ED00000000";
|
---|
199 | CuAssertStrEquals(tc, expected, actual);
|
---|
200 |
|
---|
201 | result = sl_close(rval_open);
|
---|
202 | CuAssertTrue(tc, result == 0);
|
---|
203 |
|
---|
204 | result = remove("cutest_foo");
|
---|
205 | CuAssertTrue(tc, result == 0);
|
---|
206 |
|
---|
207 | /* --------------------------------------------------- */
|
---|
208 |
|
---|
209 | fp = fopen("cutest_foo", "w");
|
---|
210 | CuAssertPtrNotNull(tc, fp);
|
---|
211 |
|
---|
212 | result = fprintf(fp, "\n");
|
---|
213 | CuAssertTrue(tc, result >= 0);
|
---|
214 |
|
---|
215 | result = fclose(fp);
|
---|
216 | CuAssertTrue(tc, result == 0);
|
---|
217 |
|
---|
218 | result = sh_tiger_hashtype("TIGER192");
|
---|
219 | CuAssertTrue(tc, result == 0);
|
---|
220 |
|
---|
221 | /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
|
---|
222 | */
|
---|
223 | length = TIGER_NOLIM;
|
---|
224 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
225 | expected = "F987845A0EA784367BF9E4DB09014995810F27C99C891734";
|
---|
226 | CuAssertStrEquals(tc, expected, actual);
|
---|
227 |
|
---|
228 | result = remove("cutest_foo");
|
---|
229 | CuAssertTrue(tc, result == 0);
|
---|
230 |
|
---|
231 | /* --------------------------------------------------- */
|
---|
232 |
|
---|
233 | fp = fopen("cutest_foo", "w");
|
---|
234 | CuAssertPtrNotNull(tc, fp);
|
---|
235 |
|
---|
236 | result = fprintf(fp, "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.\n");
|
---|
237 | CuAssertTrue(tc, result >= 0);
|
---|
238 |
|
---|
239 | result = fclose(fp);
|
---|
240 | CuAssertTrue(tc, result == 0);
|
---|
241 |
|
---|
242 | result = sh_tiger_hashtype("TIGER192");
|
---|
243 | CuAssertTrue(tc, result == 0);
|
---|
244 |
|
---|
245 | /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
|
---|
246 | */
|
---|
247 | length = TIGER_NOLIM;
|
---|
248 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
249 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
250 | CuAssertStrEquals(tc, expected, actual);
|
---|
251 |
|
---|
252 | result = remove("cutest_foo");
|
---|
253 | CuAssertTrue(tc, result == 0);
|
---|
254 |
|
---|
255 | }
|
---|
256 |
|
---|
257 | /* test checksum of file upto some given length
|
---|
258 | */
|
---|
259 | void Test_tiger_file_with_length(CuTest *tc) {
|
---|
260 |
|
---|
261 | SL_TICKET rval_open;
|
---|
262 | FILE * fp;
|
---|
263 | int result;
|
---|
264 | char * actual;
|
---|
265 | char * expected;
|
---|
266 | char hashbuf[KEYBUF_SIZE];
|
---|
267 | UINT64 length;
|
---|
268 |
|
---|
269 | char * teststring = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.\n";
|
---|
270 | size_t testlen = strlen(teststring);
|
---|
271 |
|
---|
272 | init();
|
---|
273 |
|
---|
274 | fp = fopen("cutest_foo", "w");
|
---|
275 | CuAssertPtrNotNull(tc, fp);
|
---|
276 |
|
---|
277 | result = fprintf(fp, "%s", teststring);
|
---|
278 | CuAssertTrue(tc, result >= 0);
|
---|
279 | result = fprintf(fp, "%s", teststring);
|
---|
280 | CuAssertTrue(tc, result >= 0);
|
---|
281 |
|
---|
282 | result = fclose(fp);
|
---|
283 | CuAssertTrue(tc, result == 0);
|
---|
284 |
|
---|
285 | result = sh_tiger_hashtype("TIGER192");
|
---|
286 | CuAssertTrue(tc, result == 0);
|
---|
287 |
|
---|
288 | /* same as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
|
---|
289 | */
|
---|
290 | length = 0;
|
---|
291 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
292 | expected = "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A";
|
---|
293 | CuAssertStrEquals(tc, expected, actual);
|
---|
294 | CuAssertTrue(tc, 0 == length);
|
---|
295 |
|
---|
296 | length = testlen;
|
---|
297 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
298 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
299 | CuAssertStrEquals(tc, expected, actual);
|
---|
300 | CuAssertTrue(tc, testlen == length);
|
---|
301 |
|
---|
302 | length = 2*testlen;
|
---|
303 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
304 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
305 | CuAssertStrEquals(tc, expected, actual);
|
---|
306 | CuAssertTrue(tc, 2*testlen == length);
|
---|
307 |
|
---|
308 | length = TIGER_NOLIM;
|
---|
309 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
310 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
311 | CuAssertStrEquals(tc, expected, actual);
|
---|
312 | CuAssertTrue(tc, 2*testlen == length);
|
---|
313 |
|
---|
314 | fp = fopen("cutest_foo", "a");
|
---|
315 | CuAssertPtrNotNull(tc, fp);
|
---|
316 | result = fprintf(fp, "%s", teststring);
|
---|
317 | CuAssertTrue(tc, result >= 0);
|
---|
318 | result = fclose(fp);
|
---|
319 | CuAssertTrue(tc, result == 0);
|
---|
320 |
|
---|
321 | length = testlen;
|
---|
322 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
323 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
324 | CuAssertStrEquals(tc, expected, actual);
|
---|
325 | CuAssertTrue(tc, testlen == length);
|
---|
326 |
|
---|
327 | length = 2*testlen;
|
---|
328 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
329 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
330 | CuAssertStrEquals(tc, expected, actual);
|
---|
331 | CuAssertTrue(tc, 2*testlen == length);
|
---|
332 |
|
---|
333 | length = 3*testlen;
|
---|
334 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
335 | expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
|
---|
336 | CuAssertStrEquals(tc, expected, actual);
|
---|
337 | CuAssertTrue(tc, 3*testlen == length);
|
---|
338 |
|
---|
339 | length = TIGER_NOLIM;
|
---|
340 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
341 | expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
|
---|
342 | CuAssertStrEquals(tc, expected, actual);
|
---|
343 | CuAssertTrue(tc, 3*testlen == length);
|
---|
344 |
|
---|
345 | length = 5;
|
---|
346 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
347 | expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF";
|
---|
348 | CuAssertStrEquals(tc, expected, actual);
|
---|
349 | CuAssertTrue(tc, 5 == length);
|
---|
350 |
|
---|
351 | /* same results as GNU md5sum */
|
---|
352 |
|
---|
353 | result = sh_tiger_hashtype("MD5");
|
---|
354 | CuAssertTrue(tc, result == 0);
|
---|
355 |
|
---|
356 | rval_open = sl_open_fastread (__FILE__, __LINE__, "cutest_foo", SL_YESPRIV);
|
---|
357 | CuAssertTrue(tc, rval_open >= 0);
|
---|
358 |
|
---|
359 | length = testlen;
|
---|
360 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
361 | expected = "11E7E7EA486136273606BEE57C71F34B0000000000000000";
|
---|
362 | CuAssertStrEquals(tc, expected, actual);
|
---|
363 | CuAssertTrue(tc, testlen == length);
|
---|
364 |
|
---|
365 | result = sl_rewind(rval_open);
|
---|
366 | CuAssertTrue(tc, rval_open >= 0);
|
---|
367 |
|
---|
368 | length = 2*testlen;
|
---|
369 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
370 | expected = "D49DAD474095D467E2E5EFCB2DC23A770000000000000000";
|
---|
371 | CuAssertStrEquals(tc, expected, actual);
|
---|
372 | CuAssertTrue(tc, 2*testlen == length);
|
---|
373 |
|
---|
374 | result = sl_rewind(rval_open);
|
---|
375 | CuAssertTrue(tc, rval_open >= 0);
|
---|
376 |
|
---|
377 | length = 3*testlen;
|
---|
378 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
379 | expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
|
---|
380 | CuAssertStrEquals(tc, expected, actual);
|
---|
381 | CuAssertTrue(tc, 3*testlen == length);
|
---|
382 |
|
---|
383 | result = sl_rewind(rval_open);
|
---|
384 | CuAssertTrue(tc, rval_open >= 0);
|
---|
385 |
|
---|
386 | length = TIGER_NOLIM;
|
---|
387 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
388 | expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
|
---|
389 | CuAssertStrEquals(tc, expected, actual);
|
---|
390 | CuAssertTrue(tc, 3*testlen == length);
|
---|
391 |
|
---|
392 | /* same result as gpg --print-md SHA1
|
---|
393 | */
|
---|
394 |
|
---|
395 | result = sh_tiger_hashtype("SHA1");
|
---|
396 | CuAssertTrue(tc, result == 0);
|
---|
397 |
|
---|
398 | result = sl_rewind(rval_open);
|
---|
399 | CuAssertTrue(tc, rval_open >= 0);
|
---|
400 |
|
---|
401 | length = testlen;
|
---|
402 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
403 | expected = "F37DB4344CCD140EE315179E9A27512FB4704F0F00000000";
|
---|
404 | CuAssertStrEquals(tc, expected, actual);
|
---|
405 | CuAssertTrue(tc, testlen == length);
|
---|
406 |
|
---|
407 | result = sl_rewind(rval_open);
|
---|
408 | CuAssertTrue(tc, rval_open >= 0);
|
---|
409 |
|
---|
410 | length = 2*testlen;
|
---|
411 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
412 | expected = "D2AD5FC366452D81400BAC31F96269DEEF314BC200000000";
|
---|
413 | CuAssertStrEquals(tc, expected, actual);
|
---|
414 | CuAssertTrue(tc, 2*testlen == length);
|
---|
415 |
|
---|
416 | result = sl_rewind(rval_open);
|
---|
417 | CuAssertTrue(tc, rval_open >= 0);
|
---|
418 |
|
---|
419 | length = 3*testlen;
|
---|
420 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
421 | expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
|
---|
422 | CuAssertStrEquals(tc, expected, actual);
|
---|
423 | CuAssertTrue(tc, 3*testlen == length);
|
---|
424 |
|
---|
425 | result = sl_rewind(rval_open);
|
---|
426 | CuAssertTrue(tc, rval_open >= 0);
|
---|
427 |
|
---|
428 | length = TIGER_NOLIM;
|
---|
429 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
430 | expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
|
---|
431 | CuAssertStrEquals(tc, expected, actual);
|
---|
432 | CuAssertTrue(tc, 3*testlen == length);
|
---|
433 |
|
---|
434 | result = sl_close(rval_open);
|
---|
435 | CuAssertTrue(tc, result == 0);
|
---|
436 |
|
---|
437 | result = remove("cutest_foo");
|
---|
438 | CuAssertTrue(tc, result == 0);
|
---|
439 | }
|
---|