[17] | 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 |
|
---|
[137] | 11 | #if defined(HAVE_PTHREAD) && defined(SH_STEALTH)
|
---|
[170] | 12 | extern void sh_g_init(void);
|
---|
[137] | 13 | #endif
|
---|
| 14 |
|
---|
| 15 |
|
---|
[170] | 16 | static void init(void) {
|
---|
[17] | 17 |
|
---|
| 18 | extern unsigned char TcpFlag[8][PW_LEN+1];
|
---|
| 19 | extern UINT32 ErrFlag[2];
|
---|
| 20 | unsigned char * dez = NULL;
|
---|
| 21 | int i;
|
---|
| 22 |
|
---|
[137] | 23 | #if defined(HAVE_PTHREAD) && defined(SH_STEALTH)
|
---|
| 24 | sh_g_init();
|
---|
| 25 | #endif
|
---|
[17] | 26 | skey = (sh_key_t *) malloc (sizeof(sh_key_t));
|
---|
[96] | 27 | if (skey != NULL)
|
---|
[17] | 28 | {
|
---|
[96] | 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 | {
|
---|
[17] | 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;
|
---|
[133] | 77 | char hashbuf[KEYBUF_SIZE];
|
---|
[17] | 78 |
|
---|
[137] | 79 | #if defined(HAVE_PTHREAD) && defined(SH_STEALTH)
|
---|
| 80 | sh_g_init();
|
---|
| 81 | #endif
|
---|
| 82 |
|
---|
[17] | 83 | input = "";
|
---|
[133] | 84 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 85 | expected = "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A";
|
---|
| 86 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 87 |
|
---|
| 88 | input = "abc";
|
---|
[133] | 89 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 90 | expected = "F258C1E88414AB2A527AB541FFC5B8BF935F7B951C132951";
|
---|
| 91 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 92 |
|
---|
| 93 | input = "Tiger";
|
---|
[133] | 94 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 95 | expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF";
|
---|
| 96 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 97 |
|
---|
| 98 | input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
|
---|
[133] | 99 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 100 | expected = "87FB2A9083851CF7470D2CF810E6DF9EB586445034A5A386";
|
---|
| 101 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 102 |
|
---|
| 103 | input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789";
|
---|
[133] | 104 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 105 | expected = "467DB80863EBCE488DF1CD1261655DE957896565975F9197";
|
---|
| 106 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 107 |
|
---|
| 108 | input = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham";
|
---|
[133] | 109 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 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.";
|
---|
[133] | 114 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 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.";
|
---|
[133] | 119 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 120 | expected = "3D9AEB03D1BD1A6357B2774DFD6D5B24DD68151D503974FC";
|
---|
| 121 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 122 |
|
---|
| 123 | input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-";
|
---|
[133] | 124 | actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf));
|
---|
[17] | 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;
|
---|
[133] | 136 | char hashbuf[KEYBUF_SIZE];
|
---|
[151] | 137 | UINT64 length;
|
---|
[17] | 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 | */
|
---|
[151] | 156 | length = TIGER_NOLIM;
|
---|
| 157 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 158 | expected = "0E9321614C966A33608C2A15F156E0435CACFD1213B9F095";
|
---|
| 159 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 160 |
|
---|
| 161 | rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
|
---|
| 162 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 163 |
|
---|
[151] | 164 | length = TIGER_NOLIM;
|
---|
| 165 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 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 ("cutest_foo", SL_YESPRIV);
|
---|
| 176 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 177 |
|
---|
| 178 | /* same result as GNU md5sum
|
---|
| 179 | */
|
---|
[151] | 180 | length = TIGER_NOLIM;
|
---|
| 181 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 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 ("cutest_foo", SL_YESPRIV);
|
---|
| 192 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 193 |
|
---|
| 194 | /* same result as gpg --print-md SHA1
|
---|
| 195 | */
|
---|
[151] | 196 | length = TIGER_NOLIM;
|
---|
| 197 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 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 | */
|
---|
[151] | 223 | length = TIGER_NOLIM;
|
---|
| 224 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 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 | */
|
---|
[151] | 247 | length = TIGER_NOLIM;
|
---|
| 248 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 249 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
| 250 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 251 |
|
---|
| 252 | result = remove("cutest_foo");
|
---|
| 253 | CuAssertTrue(tc, result == 0);
|
---|
| 254 |
|
---|
[19] | 255 | }
|
---|
[17] | 256 |
|
---|
[19] | 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;
|
---|
[133] | 266 | char hashbuf[KEYBUF_SIZE];
|
---|
[151] | 267 | UINT64 length;
|
---|
[19] | 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";
|
---|
[151] | 270 | size_t testlen = strlen(teststring);
|
---|
[19] | 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 | */
|
---|
[151] | 290 | length = 0;
|
---|
| 291 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[107] | 292 | expected = "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A";
|
---|
| 293 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 294 | CuAssertTrue(tc, 0 == length);
|
---|
[107] | 295 |
|
---|
[151] | 296 | length = testlen;
|
---|
| 297 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 298 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
| 299 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 300 | CuAssertTrue(tc, testlen == length);
|
---|
[19] | 301 |
|
---|
[151] | 302 | length = 2*testlen;
|
---|
| 303 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 304 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
| 305 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 306 | CuAssertTrue(tc, 2*testlen == length);
|
---|
[19] | 307 |
|
---|
[151] | 308 | length = TIGER_NOLIM;
|
---|
| 309 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 310 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
| 311 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 312 | CuAssertTrue(tc, 2*testlen == length);
|
---|
[19] | 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 |
|
---|
[151] | 321 | length = testlen;
|
---|
| 322 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 323 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
| 324 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 325 | CuAssertTrue(tc, testlen == length);
|
---|
[19] | 326 |
|
---|
[151] | 327 | length = 2*testlen;
|
---|
| 328 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 329 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
| 330 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 331 | CuAssertTrue(tc, 2*testlen == length);
|
---|
[19] | 332 |
|
---|
[151] | 333 | length = 3*testlen;
|
---|
| 334 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 335 | expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
|
---|
| 336 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 337 | CuAssertTrue(tc, 3*testlen == length);
|
---|
[19] | 338 |
|
---|
[151] | 339 | length = TIGER_NOLIM;
|
---|
| 340 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 341 | expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
|
---|
| 342 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 343 | CuAssertTrue(tc, 3*testlen == length);
|
---|
[19] | 344 |
|
---|
[151] | 345 | length = 5;
|
---|
| 346 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 347 | expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF";
|
---|
| 348 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 349 | CuAssertTrue(tc, 5 == length);
|
---|
[19] | 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 ("cutest_foo", SL_YESPRIV);
|
---|
| 357 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 358 |
|
---|
[151] | 359 | length = testlen;
|
---|
| 360 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 361 | expected = "11E7E7EA486136273606BEE57C71F34B0000000000000000";
|
---|
| 362 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 363 | CuAssertTrue(tc, testlen == length);
|
---|
[19] | 364 |
|
---|
| 365 | result = sl_rewind(rval_open);
|
---|
| 366 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 367 |
|
---|
[151] | 368 | length = 2*testlen;
|
---|
| 369 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 370 | expected = "D49DAD474095D467E2E5EFCB2DC23A770000000000000000";
|
---|
| 371 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 372 | CuAssertTrue(tc, 2*testlen == length);
|
---|
[19] | 373 |
|
---|
| 374 | result = sl_rewind(rval_open);
|
---|
| 375 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 376 |
|
---|
[151] | 377 | length = 3*testlen;
|
---|
| 378 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 379 | expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
|
---|
| 380 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 381 | CuAssertTrue(tc, 3*testlen == length);
|
---|
[19] | 382 |
|
---|
| 383 | result = sl_rewind(rval_open);
|
---|
| 384 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 385 |
|
---|
[151] | 386 | length = TIGER_NOLIM;
|
---|
| 387 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 388 | expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
|
---|
| 389 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 390 | CuAssertTrue(tc, 3*testlen == length);
|
---|
[19] | 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 |
|
---|
[151] | 401 | length = testlen;
|
---|
| 402 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 403 | expected = "F37DB4344CCD140EE315179E9A27512FB4704F0F00000000";
|
---|
| 404 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 405 | CuAssertTrue(tc, testlen == length);
|
---|
[19] | 406 |
|
---|
| 407 | result = sl_rewind(rval_open);
|
---|
| 408 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 409 |
|
---|
[151] | 410 | length = 2*testlen;
|
---|
| 411 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 412 | expected = "D2AD5FC366452D81400BAC31F96269DEEF314BC200000000";
|
---|
| 413 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 414 | CuAssertTrue(tc, 2*testlen == length);
|
---|
[19] | 415 |
|
---|
| 416 | result = sl_rewind(rval_open);
|
---|
| 417 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 418 |
|
---|
[151] | 419 | length = 3*testlen;
|
---|
| 420 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 421 | expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
|
---|
| 422 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 423 | CuAssertTrue(tc, 3*testlen == length);
|
---|
[19] | 424 |
|
---|
| 425 | result = sl_rewind(rval_open);
|
---|
| 426 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 427 |
|
---|
[151] | 428 | length = TIGER_NOLIM;
|
---|
| 429 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, &length, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 430 | expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
|
---|
| 431 | CuAssertStrEquals(tc, expected, actual);
|
---|
[151] | 432 | CuAssertTrue(tc, 3*testlen == length);
|
---|
[19] | 433 |
|
---|
| 434 | result = sl_close(rval_open);
|
---|
| 435 | CuAssertTrue(tc, result == 0);
|
---|
| 436 |
|
---|
| 437 | result = remove("cutest_foo");
|
---|
| 438 | CuAssertTrue(tc, result == 0);
|
---|
| 439 | }
|
---|