Ignore:
Timestamp:
Feb 12, 2006, 10:49:56 PM (19 years ago)
Author:
rainer
Message:

Rewrite of test suite, checksum for growing logs, fix for minor bug with dead client detection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cutest_sh_tiger0.c

    r17 r19  
    233233  CuAssertTrue(tc, result == 0);
    234234
    235 
    236235
     236
     237/* test checksum of file upto some given length
     238 */
     239void Test_tiger_file_with_length(CuTest *tc) {
     240
     241  SL_TICKET     rval_open;
     242  FILE * fp;
     243  int result;
     244  char * actual;
     245  char * expected;
     246
     247  char * teststring = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.\n";
     248  int    testlen = strlen(teststring);
     249
     250  init();
     251
     252  fp = fopen("cutest_foo", "w");
     253  CuAssertPtrNotNull(tc, fp);
     254
     255  result = fprintf(fp, "%s", teststring);
     256  CuAssertTrue(tc, result >= 0);
     257  result = fprintf(fp, "%s", teststring);
     258  CuAssertTrue(tc, result >= 0);
     259
     260  result = fclose(fp);
     261  CuAssertTrue(tc, result == 0);
     262 
     263  result = sh_tiger_hashtype("TIGER192");
     264  CuAssertTrue(tc, result == 0);
     265
     266  /* same as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
     267   */
     268  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0);
     269  expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
     270  CuAssertStrEquals(tc, expected, actual);
     271
     272  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0);
     273  expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
     274  CuAssertStrEquals(tc, expected, actual);
     275
     276  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0);
     277  expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
     278  CuAssertStrEquals(tc, expected, actual);
     279
     280  fp = fopen("cutest_foo", "a");
     281  CuAssertPtrNotNull(tc, fp);
     282  result = fprintf(fp, "%s", teststring);
     283  CuAssertTrue(tc, result >= 0);
     284  result = fclose(fp);
     285  CuAssertTrue(tc, result == 0);
     286
     287  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0);
     288  expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
     289  CuAssertStrEquals(tc, expected, actual);
     290
     291  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0);
     292  expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
     293  CuAssertStrEquals(tc, expected, actual);
     294
     295  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 3*testlen, 0);
     296  expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
     297  CuAssertStrEquals(tc, expected, actual);
     298
     299  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0);
     300  expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
     301  CuAssertStrEquals(tc, expected, actual);
     302
     303  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 5, 0);
     304  expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF";
     305  CuAssertStrEquals(tc, expected, actual);
     306
     307  /* same results as GNU md5sum */
     308
     309  result = sh_tiger_hashtype("MD5");
     310  CuAssertTrue(tc, result == 0);
     311
     312  rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
     313  CuAssertTrue(tc, rval_open >= 0);
     314  tiger_fd  = rval_open;
     315
     316  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, testlen, 0);
     317  expected = "11E7E7EA486136273606BEE57C71F34B0000000000000000";
     318  CuAssertStrEquals(tc, expected, actual);
     319
     320  result = sl_rewind(rval_open);
     321  CuAssertTrue(tc, rval_open >= 0);
     322
     323  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 2*testlen, 0);
     324  expected = "D49DAD474095D467E2E5EFCB2DC23A770000000000000000";
     325  CuAssertStrEquals(tc, expected, actual);
     326
     327  result = sl_rewind(rval_open);
     328  CuAssertTrue(tc, rval_open >= 0);
     329
     330  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 3*testlen, 0);
     331  expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
     332  CuAssertStrEquals(tc, expected, actual);
     333
     334  result = sl_rewind(rval_open);
     335  CuAssertTrue(tc, rval_open >= 0);
     336
     337  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 0, 0);
     338  expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
     339  CuAssertStrEquals(tc, expected, actual);
     340
     341  /* same result as gpg --print-md SHA1
     342   */
     343
     344  result = sh_tiger_hashtype("SHA1");
     345  CuAssertTrue(tc, result == 0);
     346
     347  result = sl_rewind(rval_open);
     348  CuAssertTrue(tc, rval_open >= 0);
     349
     350  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, testlen, 0);
     351  expected = "F37DB4344CCD140EE315179E9A27512FB4704F0F00000000";
     352  CuAssertStrEquals(tc, expected, actual);
     353
     354  result = sl_rewind(rval_open);
     355  CuAssertTrue(tc, rval_open >= 0);
     356
     357  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 2*testlen, 0);
     358  expected = "D2AD5FC366452D81400BAC31F96269DEEF314BC200000000";
     359  CuAssertStrEquals(tc, expected, actual);
     360
     361  result = sl_rewind(rval_open);
     362  CuAssertTrue(tc, rval_open >= 0);
     363
     364  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 3*testlen, 0);
     365  expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
     366  CuAssertStrEquals(tc, expected, actual);
     367
     368  result = sl_rewind(rval_open);
     369  CuAssertTrue(tc, rval_open >= 0);
     370
     371  actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 0, 0);
     372  expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
     373  CuAssertStrEquals(tc, expected, actual);
     374
     375  result = sl_close(rval_open);
     376  CuAssertTrue(tc, result == 0);
     377
     378  result = remove("cutest_foo");
     379  CuAssertTrue(tc, result == 0);
     380}
Note: See TracChangeset for help on using the changeset viewer.