Changeset 133
- Timestamp:
- Oct 25, 2007, 12:19:05 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/samhain.h
r132 r133 62 62 #define KEY_LEN 48 63 63 #define KEY_BLOCK 24 64 #define KEYBUF_SIZE (KEY_LEN+1) 64 65 65 66 /* The length of the compiled-in password. -
trunk/include/sh_pthread.h
r132 r133 26 26 #define SH_MUTEX_UNLOCK_UNSAFE(M) pthread_mutex_unlock(&(M)) 27 27 28 /* 29 * ---- Global mutexes ---- 30 */ 31 SH_MUTEX_EXTERN(mutex_skey); 32 28 33 #else 29 34 -
trunk/include/sh_srp.h
r1 r133 21 21 void sh_srp_x (char * salt, char * password); 22 22 int sh_srp_make_a (void); 23 char * sh_srp_M (char * x1, char * x2, char * x3 );23 char * sh_srp_M (char * x1, char * x2, char * x3, char * buf, size_t size); 24 24 25 25 char * sh_srp_verifier (void); -
trunk/include/sh_tiger.h
r107 r133 7 7 #include "samhain.h" 8 8 9 typedef long int TigerType; 10 11 #define TIGER_FILE -1; 12 #define TIGER_DATA -2; 13 14 /**************** 9 15 typedef enum { 10 16 TIGER_FILE, … … 12 18 TIGER_DATA 13 19 } TigerType; 20 *****************/ 14 21 15 22 #define TIGER_NOLIM ((UINT64)-1) 16 17 extern SL_TICKET tiger_fd;18 23 19 24 /* the checksum function 20 25 */ 21 26 /*@owned@*/ char * sh_tiger_hash (const char * filename, TigerType what, 22 UINT64 Length );27 UINT64 Length, char * out, size_t len); 23 28 24 29 /* NEW Thu Oct 18 19:59:08 CEST 2001 … … 26 31 int sh_tiger_hashtype (const char * c); 27 32 char * sh_tiger_generic_hash (char * filename, TigerType what, 28 UINT64 Length, int timeout); 33 UINT64 Length, int timeout, 34 char * out, size_t len); 29 35 30 36 UINT32 * sh_tiger_hash_uint32 (char * filename, 31 37 TigerType what, 32 UINT64 Length );38 UINT64 Length, UINT32 * out, size_t len); 33 39 34 40 /* get the type of hash function used … … 37 43 int sh_tiger_get_hashtype (); 38 44 39 /* GnuPG-like format 45 /* GnuPG-like format, returns allocated memory 40 46 */ 41 47 /*@owned@*/ char * sh_tiger_hash_gpg (const char * filename, TigerType what, -
trunk/src/cutest_sh_tiger0.c
r107 r133 67 67 char * actual; 68 68 char * expected; 69 char hashbuf[KEYBUF_SIZE]; 69 70 70 71 input = ""; 71 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );72 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 72 73 expected = "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A"; 73 74 CuAssertStrEquals(tc, expected, actual); 74 75 75 76 input = "abc"; 76 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );77 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 77 78 expected = "F258C1E88414AB2A527AB541FFC5B8BF935F7B951C132951"; 78 79 CuAssertStrEquals(tc, expected, actual); 79 80 80 81 input = "Tiger"; 81 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );82 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 82 83 expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF"; 83 84 CuAssertStrEquals(tc, expected, actual); 84 85 85 86 input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; 86 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );87 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 87 88 expected = "87FB2A9083851CF7470D2CF810E6DF9EB586445034A5A386"; 88 89 CuAssertStrEquals(tc, expected, actual); 89 90 90 91 input = "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789"; 91 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );92 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 92 93 expected = "467DB80863EBCE488DF1CD1261655DE957896565975F9197"; 93 94 CuAssertStrEquals(tc, expected, actual); 94 95 95 96 input = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham"; 96 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );97 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 97 98 expected = "0C410A042968868A1671DA5A3FD29A725EC1E457D3CDB303"; 98 99 CuAssertStrEquals(tc, expected, actual); 99 100 100 101 input = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge."; 101 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );102 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 102 103 expected = "EBF591D5AFA655CE7F22894FF87F54AC89C811B6B0DA3193"; 103 104 CuAssertStrEquals(tc, expected, actual); 104 105 105 106 input = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996."; 106 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );107 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 107 108 expected = "3D9AEB03D1BD1A6357B2774DFD6D5B24DD68151D503974FC"; 108 109 CuAssertStrEquals(tc, expected, actual); 109 110 110 111 input = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-"; 111 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input) );112 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); 112 113 expected = "00B83EB4E53440C576AC6AAEE0A7485825FD15E70A59FFE4"; 113 114 CuAssertStrEquals(tc, expected, actual); … … 121 122 char * actual; 122 123 char * expected; 124 char hashbuf[KEYBUF_SIZE]; 123 125 124 126 init(); … … 139 141 /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192) 140 142 */ 141 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0 );143 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 142 144 expected = "0E9321614C966A33608C2A15F156E0435CACFD1213B9F095"; 143 145 CuAssertStrEquals(tc, expected, actual); … … 145 147 rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV); 146 148 CuAssertTrue(tc, rval_open >= 0); 147 tiger_fd = rval_open; 148 149 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, TIGER_NOLIM, 0); 149 150 actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 150 151 expected = "0E9321614C966A33608C2A15F156E0435CACFD1213B9F095"; 151 152 CuAssertStrEquals(tc, expected, actual); … … 159 160 rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV); 160 161 CuAssertTrue(tc, rval_open >= 0); 161 tiger_fd = rval_open;162 162 163 163 /* same result as GNU md5sum 164 164 */ 165 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, TIGER_NOLIM, 0);165 actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 166 166 expected = "AEEC4DDA496BCFBA691F4E8863BA84C00000000000000000"; 167 167 CuAssertStrEquals(tc, expected, actual); … … 175 175 rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV); 176 176 CuAssertTrue(tc, rval_open >= 0); 177 tiger_fd = rval_open;178 177 179 178 /* same result as gpg --print-md SHA1 180 179 */ 181 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, TIGER_NOLIM, 0);180 actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 182 181 expected = "2FE65D1D995B8F8BC8B13F798C07E7E935A787ED00000000"; 183 182 CuAssertStrEquals(tc, expected, actual); … … 205 204 /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192) 206 205 */ 207 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0 );206 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 208 207 expected = "F987845A0EA784367BF9E4DB09014995810F27C99C891734"; 209 208 CuAssertStrEquals(tc, expected, actual); … … 228 227 /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192) 229 228 */ 230 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0 );229 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 231 230 expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8"; 232 231 CuAssertStrEquals(tc, expected, actual); … … 246 245 char * actual; 247 246 char * expected; 247 char hashbuf[KEYBUF_SIZE]; 248 248 249 249 char * teststring = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.\n"; … … 268 268 /* same as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192) 269 269 */ 270 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0 );270 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0, hashbuf, sizeof(hashbuf)); 271 271 expected = "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A"; 272 272 CuAssertStrEquals(tc, expected, actual); 273 273 274 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0 );274 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0, hashbuf, sizeof(hashbuf)); 275 275 expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8"; 276 276 CuAssertStrEquals(tc, expected, actual); 277 277 278 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0 );278 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0, hashbuf, sizeof(hashbuf)); 279 279 expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90"; 280 280 CuAssertStrEquals(tc, expected, actual); 281 281 282 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0 );282 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 283 283 expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90"; 284 284 CuAssertStrEquals(tc, expected, actual); … … 291 291 CuAssertTrue(tc, result == 0); 292 292 293 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0 );293 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0, hashbuf, sizeof(hashbuf)); 294 294 expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8"; 295 295 CuAssertStrEquals(tc, expected, actual); 296 296 297 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0 );297 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0, hashbuf, sizeof(hashbuf)); 298 298 expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90"; 299 299 CuAssertStrEquals(tc, expected, actual); 300 300 301 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 3*testlen, 0 );301 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 3*testlen, 0, hashbuf, sizeof(hashbuf)); 302 302 expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F"; 303 303 CuAssertStrEquals(tc, expected, actual); 304 304 305 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0 );305 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 306 306 expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F"; 307 307 CuAssertStrEquals(tc, expected, actual); 308 308 309 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 5, 0 );309 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 5, 0, hashbuf, sizeof(hashbuf)); 310 310 expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF"; 311 311 CuAssertStrEquals(tc, expected, actual); … … 318 318 rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV); 319 319 CuAssertTrue(tc, rval_open >= 0); 320 tiger_fd = rval_open; 321 322 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, testlen, 0); 320 321 actual = sh_tiger_generic_hash("cutest_foo", rval_open, testlen, 0, hashbuf, sizeof(hashbuf)); 323 322 expected = "11E7E7EA486136273606BEE57C71F34B0000000000000000"; 324 323 CuAssertStrEquals(tc, expected, actual); … … 327 326 CuAssertTrue(tc, rval_open >= 0); 328 327 329 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 2*testlen, 0);328 actual = sh_tiger_generic_hash("cutest_foo", rval_open, 2*testlen, 0, hashbuf, sizeof(hashbuf)); 330 329 expected = "D49DAD474095D467E2E5EFCB2DC23A770000000000000000"; 331 330 CuAssertStrEquals(tc, expected, actual); … … 334 333 CuAssertTrue(tc, rval_open >= 0); 335 334 336 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 3*testlen, 0);335 actual = sh_tiger_generic_hash("cutest_foo", rval_open, 3*testlen, 0, hashbuf, sizeof(hashbuf)); 337 336 expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000"; 338 337 CuAssertStrEquals(tc, expected, actual); … … 341 340 CuAssertTrue(tc, rval_open >= 0); 342 341 343 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, TIGER_NOLIM, 0);342 actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 344 343 expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000"; 345 344 CuAssertStrEquals(tc, expected, actual); … … 354 353 CuAssertTrue(tc, rval_open >= 0); 355 354 356 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, testlen, 0);355 actual = sh_tiger_generic_hash("cutest_foo", rval_open, testlen, 0, hashbuf, sizeof(hashbuf)); 357 356 expected = "F37DB4344CCD140EE315179E9A27512FB4704F0F00000000"; 358 357 CuAssertStrEquals(tc, expected, actual); … … 361 360 CuAssertTrue(tc, rval_open >= 0); 362 361 363 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 2*testlen, 0);362 actual = sh_tiger_generic_hash("cutest_foo", rval_open, 2*testlen, 0, hashbuf, sizeof(hashbuf)); 364 363 expected = "D2AD5FC366452D81400BAC31F96269DEEF314BC200000000"; 365 364 CuAssertStrEquals(tc, expected, actual); … … 368 367 CuAssertTrue(tc, rval_open >= 0); 369 368 370 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, 3*testlen, 0);369 actual = sh_tiger_generic_hash("cutest_foo", rval_open, 3*testlen, 0, hashbuf, sizeof(hashbuf)); 371 370 expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000"; 372 371 CuAssertStrEquals(tc, expected, actual); … … 375 374 CuAssertTrue(tc, rval_open >= 0); 376 375 377 actual = sh_tiger_generic_hash("cutest_foo", TIGER_FD, TIGER_NOLIM, 0);376 actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf)); 378 377 expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000"; 379 378 CuAssertStrEquals(tc, expected, actual); -
trunk/src/samhain.c
r131 r133 1411 1411 if (0 != sl_strcmp(file_path('D', 'R'), _("REQ_FROM_SERVER"))) 1412 1412 { 1413 char hashbuf[KEYBUF_SIZE]; 1413 1414 (void) sl_strlcpy(sh.data.hash, 1414 1415 sh_tiger_hash (file_path('D', 'R'), 1415 TIGER_FILE, 0), 1416 TIGER_FILE, 0, 1417 hashbuf, sizeof(hashbuf)), 1416 1418 KEY_LEN+1); 1417 1419 } -
trunk/src/sh_entropy.c
r132 r133 315 315 int i, m_count = 0; 316 316 char * keybuf; 317 UINT32 kbuf[KEY_BYT/sizeof(UINT32)]; 317 318 char addbuf[2 * KEY_BYT]; 318 319 … … 366 367 addbuf[i+KEY_BYT] = skey->poolv[i]; 367 368 keybuf = (char *) sh_tiger_hash_uint32 (addbuf, 368 TIGER_DATA, 2 * KEY_BYT); 369 TIGER_DATA, 2 * KEY_BYT, 370 kbuf, KEY_BYT/sizeof(UINT32)); 369 371 memset(addbuf, '\0', sizeof(addbuf)); 370 372 … … 701 703 702 704 char * keybuf; 705 UINT32 kbuf[KEY_BYT/sizeof(UINT32)]; 703 706 char addbuf[2 * KEY_BYT]; 704 707 … … 885 888 { 886 889 keybuf = (char *) sh_tiger_hash_uint32 (buffer, 887 TIGER_DATA, sl_strlen(buffer)); 890 TIGER_DATA, sl_strlen(buffer), 891 kbuf, KEY_BYT/sizeof(UINT32)); 888 892 889 893 /* add previous entropy into the new pool … … 896 900 } 897 901 keybuf = (char *) sh_tiger_hash_uint32 (addbuf, 898 TIGER_DATA, sizeof(addbuf)); 902 TIGER_DATA, sizeof(addbuf), 903 kbuf, KEY_BYT/sizeof(UINT32)); 899 904 memset(addbuf, '\0', sizeof(addbuf)); 900 905 -
trunk/src/sh_err_log.c
r132 r133 145 145 char c_cont; 146 146 int chk_mode = CHK_KEY; 147 char hashbuf[KEYBUF_SIZE]; 147 148 148 149 sh_error_logoff(); … … 383 384 { 384 385 (void) sl_strlcpy(key, 385 sh_tiger_hash(NULL, TIGER_DATA, 0), 386 sh_tiger_hash(NULL, TIGER_DATA, 0, 387 hashbuf, sizeof(hashbuf)), 386 388 KEY_LEN+1); 387 389 chk_mode = CHK_NON; … … 428 430 */ 429 431 (void) sl_strlcpy (key, 430 sh_tiger_hash (key, TIGER_DATA, KEY_LEN), 432 sh_tiger_hash (key, TIGER_DATA, KEY_LEN, 433 hashbuf, sizeof(hashbuf)), 431 434 KEY_LEN+1); 432 435 } … … 440 443 status = sl_strncmp (signature, 441 444 sh_tiger_hash (buf, TIGER_DATA, 442 (unsigned long) sl_strlen(buf)), 445 (unsigned long) sl_strlen(buf), 446 hashbuf, sizeof(hashbuf)), 443 447 KEY_LEN); 444 448 … … 861 865 if (current->log_start == S_TRUE) 862 866 { 867 char hashbuf[KEYBUF_SIZE]; 868 863 869 if (sh.real.user[0] == '\0') 864 870 (void) sh_unix_getUser(); … … 871 877 */ 872 878 (void) sl_strlcpy(sigkey_new, 873 sh_tiger_hash (sigkey_old, TIGER_DATA, KEY_LEN), 879 sh_tiger_hash (sigkey_old, TIGER_DATA, KEY_LEN, 880 hashbuf, sizeof(hashbuf)), 874 881 KEY_LEN+1); 875 882 -
trunk/src/sh_error.c
r132 r133 124 124 { 125 125 char * foo; 126 char hashbuf[KEYBUF_SIZE]; 126 127 127 128 if (s[0] == '/') … … 135 136 fprintf (stdout, _("string=<%s>, hash=<%s>\n"), 136 137 s, sh_tiger_hash (s, TIGER_DATA, 137 (unsigned long) sl_strlen(s))); 138 (unsigned long) sl_strlen(s), 139 hashbuf, sizeof(hashbuf)) 140 ); 138 141 } 139 142 (void) fflush(stdout); -
trunk/src/sh_extern.c
r132 r133 184 184 if (task->checksum[0] != '\0') 185 185 { 186 char hashbuf[KEYBUF_SIZE]; 186 187 PDBG_S("checksum test"); 187 188 if (0 != sl_strcmp(task->checksum, 188 sh_tiger_hash (task->command, TIGER_FILE, 0)) 189 sh_tiger_hash (task->command, TIGER_FILE, 0, 190 hashbuf, sizeof(hashbuf)) 191 ) 189 192 ) 190 193 { … … 354 357 else 355 358 { 359 char hashbuf[KEYBUF_SIZE]; 360 356 361 fd = 357 362 sl_open_read(task->command, 358 363 task->privileged==0 ? SL_NOPRIV : SL_YESPRIV); 359 tiger_fd = fd; 364 360 365 if (0 != sl_strcmp(task->checksum, 361 366 sh_tiger_hash (task->command, 362 TIGER_FD, 0)))367 fd, 0, hashbuf, sizeof(hashbuf)))) 363 368 { 364 369 PDBGC_S("fexecve: checksum mismatch"); -
trunk/src/sh_forward.c
r132 r133 890 890 891 891 static time_t timeout_val = 1; 892 char hashbuf[KEYBUF_SIZE]; 893 char sigbuf[KEYBUF_SIZE]; 892 894 893 895 SL_ENTER(_("sh_forward_try_impl")); … … 1016 1018 sh_tiger_hash((char *) &ticks, 1017 1019 TIGER_DATA, 1018 (unsigned long)sizeof(UINT32)), 1020 (unsigned long)sizeof(UINT32), 1021 hashbuf, sizeof(hashbuf)), 1019 1022 KEY_LEN+1); 1020 1023 … … 1026 1029 sh_tiger_hash(temp, 1027 1030 TIGER_DATA, 1028 (unsigned long)sl_strlen(temp)), 1031 (unsigned long)sl_strlen(temp), 1032 hashbuf, sizeof(hashbuf)), 1029 1033 KEY_LEN+1); 1030 1034 sh_passwd (temp, NULL, NULL, foo_M1); … … 1163 1167 else /* if (0 != sh_srp_check_zero (answer)) */ 1164 1168 { 1165 sl_strlcpy(u_real, sh_tiger_hash(head_u, TIGER_DATA, 4), 1169 sl_strlcpy(u_real, sh_tiger_hash(head_u, TIGER_DATA, 4, 1170 hashbuf, sizeof(hashbuf)), 1166 1171 SH_CHALLENGE_SIZE); 1167 1172 foo_Sc = sh_srp_S_c (u_real, answer); … … 1176 1181 if (foo_Sc != NULL) 1177 1182 { 1178 sl_strlcpy(foo_M1, 1179 sh_srp_M(foo_A, 1180 answer, 1181 sh_tiger_hash(foo_Sc, 1182 TIGER_DATA, 1183 sl_strlen(foo_Sc))), 1184 KEY_LEN+1); 1183 sh_srp_M(foo_A, 1184 answer, 1185 sh_tiger_hash(foo_Sc, 1186 TIGER_DATA, 1187 sl_strlen(foo_Sc), 1188 hashbuf, sizeof(hashbuf)), 1189 foo_M1, KEY_LEN+1); 1190 1185 1191 1186 1192 TPT(( 0, FIL__, __LINE__, _("msg=<srp:M1 = %s>\n"), … … 1213 1219 /* ------ verify M2 = H(A, M1, K) -------- 1214 1220 */ 1221 char M_buf[KEY_LEN+1]; 1215 1222 M = sh_srp_M (foo_A, foo_M1, 1216 1223 sh_tiger_hash(foo_Sc, 1217 1224 TIGER_DATA, 1218 sl_strlen(foo_Sc))); 1225 sl_strlen(foo_Sc), 1226 hashbuf, sizeof(hashbuf)), 1227 M_buf, sizeof(M_buf) 1228 ); 1219 1229 if (M != NULL && 1220 1230 0 == sl_strncmp (answer, M, KEY_LEN+1)) … … 1223 1233 sh_tiger_hash(foo_Sc, 1224 1234 TIGER_DATA, 1225 sl_strlen(foo_Sc)), 1235 sl_strlen(foo_Sc), 1236 hashbuf, sizeof(hashbuf)), 1226 1237 KEY_LEN+1); 1227 1238 TPT(( 0, FIL__, __LINE__, … … 1301 1312 (void) sl_strlcpy (answer, sh_util_siggen(skey->session, 1302 1313 sh.host.name, 1303 sl_strlen(sh.host.name)), 1314 sl_strlen(sh.host.name), 1315 sigbuf, sizeof(sigbuf)), 1304 1316 KEY_LEN+1); 1305 1317 TPT((0, FIL__, __LINE__, _("msg=<host %s>\n"), sh.host.name)); … … 1373 1385 sh_util_siggen (skey->session, 1374 1386 buffer, 1375 sl_strlen(buffer)), 1387 sl_strlen(buffer), 1388 sigbuf, sizeof(sigbuf)), 1376 1389 KEY_LEN+1); 1377 1390 TPT((0, FIL__, __LINE__, _("msg=<sign %s.>\n"), 1378 1391 sh_util_siggen(skey->session, buffer, 1379 sl_strlen(buffer) )));1392 sl_strlen(buffer), sigbuf, sizeof(sigbuf)))); 1380 1393 1381 1394 (void) sl_strlcpy(buffer, errmsg, len); … … 1439 1452 sh_util_siggen(skey->session, 1440 1453 buffer, 1441 sl_strlen(buffer)), 1454 sl_strlen(buffer), 1455 sigbuf, sizeof(sigbuf)), 1442 1456 KEY_LEN); 1443 1457 TPT((0, FIL__, __LINE__, _("msg=<sign %s.>\n"), 1444 1458 sh_util_siggen(skey->session, buffer, 1445 sl_strlen(buffer) )));1459 sl_strlen(buffer), sigbuf, sizeof(sigbuf)))); 1446 1460 1447 1461 if (flag_err != 0) … … 1473 1487 sh_util_siggen(skey->session, 1474 1488 buffer, 1475 pos), 1489 pos, 1490 sigbuf, sizeof(sigbuf)), 1476 1491 KEY_LEN); 1477 1492 … … 1583 1598 sh_tiger_hash((char *) &ticks, 1584 1599 TIGER_DATA, 1585 (unsigned long)sizeof(UINT32)), 1600 (unsigned long)sizeof(UINT32), 1601 hashbuf, sizeof(hashbuf)), 1586 1602 KEY_LEN+1); 1587 1603 … … 1592 1608 (void)sl_strlcpy(foo_M1, 1593 1609 sh_tiger_hash(buffer, TIGER_DATA, 1594 (unsigned long)sl_strlen(buffer)), 1610 (unsigned long)sl_strlen(buffer), 1611 hashbuf, sizeof(hashbuf)), 1595 1612 KEY_LEN+1); 1596 1613 memset (buffer, 0, sl_strlen(buffer)); … … 1773 1790 unsigned char in[PW_LEN+1]; 1774 1791 int i = 0, j, k, l = 0; 1792 char hashbuf[KEYBUF_SIZE]; 1775 1793 1776 1794 if (sl_strlen(str) != (PW_LEN * 2)) … … 1800 1818 1801 1819 sl_strlcpy ((char *)key, 1802 sh_tiger_hash ((char*)in, TIGER_DATA, PW_LEN), 1820 sh_tiger_hash ((char*)in, TIGER_DATA, PW_LEN, 1821 hashbuf, sizeof(hashbuf)), 1803 1822 KEY_LEN+1); 1804 1823 key[KEY_LEN] = '\0'; … … 1822 1841 char in[PW_LEN]; 1823 1842 int i = 0, j, k, l = 0; 1843 char hashbuf[KEYBUF_SIZE]; 1824 1844 1825 1845 if (sl_strlen(str) != (PW_LEN*2)) … … 1851 1871 { 1852 1872 sh_util_keyinit(key, KEY_LEN); 1853 sl_strlcpy(salt, sh_tiger_hash(key, TIGER_DATA, KEY_LEN), 17); 1873 sl_strlcpy(salt, sh_tiger_hash(key, TIGER_DATA, KEY_LEN, 1874 hashbuf, sizeof(hashbuf)), 1875 17); 1854 1876 sh_srp_x (salt, in); 1855 1877 foo_v = sh_srp_verifier (); … … 1873 1895 UINT32 val[2]; 1874 1896 char output[KEY_LEN+1]; 1897 char hashbuf[KEYBUF_SIZE]; 1875 1898 1876 1899 val[0] = taus_get (&(skey->rng0[0]), &(skey->rng0[1]), &(skey->rng0[2])); … … 1878 1901 1879 1902 sl_strlcpy (output, 1880 sh_tiger_hash((char *)(&val[0]), TIGER_DATA, 2*sizeof(UINT32)), 1903 sh_tiger_hash((char *)(&val[0]), TIGER_DATA, 2*sizeof(UINT32), 1904 hashbuf, sizeof(hashbuf)), 1881 1905 KEY_LEN); 1882 1906 … … 2817 2841 char * foo_Ss; 2818 2842 #endif 2843 char hashbuf[KEYBUF_SIZE]; 2844 char sigbuf[KEYBUF_SIZE]; 2819 2845 2820 2846 SL_ENTER(_("check_protocol")); … … 2908 2934 sh_util_siggen(this_client->session_key, 2909 2935 &(conn->buf[KEY_LEN]), 2910 sl_strlen(&(conn->buf[KEY_LEN]))), 2936 sl_strlen(&(conn->buf[KEY_LEN])), 2937 sigbuf, sizeof(sigbuf)), 2911 2938 KEY_LEN+1); 2912 2939 TPT((0, FIL__, __LINE__, _("msg=<host %s>\n"), … … 2917 2944 sh_util_siggen(this_client->session_key, 2918 2945 &(conn->buf[KEY_LEN]), 2919 sl_strlen(&(conn->buf[KEY_LEN]))))); 2946 sl_strlen(&(conn->buf[KEY_LEN])), 2947 sigbuf, sizeof(sigbuf)))); 2920 2948 2921 2949 if (0 != sl_strncmp(conn->K, conn->buf, KEY_LEN)) … … 2953 2981 sl_strlcpy (conn->K, 2954 2982 sh_tiger_hash ((char *) &ticks, 2955 TIGER_DATA, sizeof(UINT32)), 2983 TIGER_DATA, sizeof(UINT32), 2984 hashbuf, sizeof(hashbuf)), 2956 2985 KEY_LEN+1); 2957 2986 … … 2985 3014 sl_strlcat(conn->A, conn->client_entry->session_key, 2986 3015 3*KEY_LEN+1); 2987 sl_strlcpy (conn->K, sh_tiger_hash(conn->A,TIGER_DATA,3*KEY_LEN), 3016 sl_strlcpy (conn->K, sh_tiger_hash(conn->A,TIGER_DATA,3*KEY_LEN, 3017 hashbuf, sizeof(hashbuf)), 2988 3018 KEY_LEN+1); 2989 3019 SH_FREE(conn->A); … … 3368 3398 sh_util_siggen(this_client->session_key, 3369 3399 &(conn->buf[KEY_LEN]), 3370 sl_strlen(&(conn->buf[KEY_LEN]))), 3400 sl_strlen(&(conn->buf[KEY_LEN])), 3401 sigbuf, sizeof(sigbuf)), 3371 3402 KEY_LEN+1); 3372 3403 TPT((0, FIL__, __LINE__, _("msg=<host %s>\n"), … … 3484 3515 sh_util_siggen(conn->client_entry->session_key, 3485 3516 buffer, 3486 sl_strlen(buffer)), 3517 sl_strlen(buffer), 3518 sigbuf, sizeof(sigbuf)), 3487 3519 KEY_LEN); 3488 3520 TPT((0, FIL__, __LINE__, _("msg=<sign %s.>\n"), 3489 3521 sh_util_siggen(conn->client_entry->session_key, 3490 3522 buffer, 3491 sl_strlen(buffer)))); 3523 sl_strlen(buffer), 3524 sigbuf, sizeof(sigbuf)))); 3492 3525 3493 3526 … … 3601 3634 sh_util_siggen ( conn->client_entry->session_key, 3602 3635 buffer, 3603 sl_strlen(buffer)), 3636 sl_strlen(buffer), 3637 sigbuf, sizeof(sigbuf)), 3604 3638 KEY_LEN+1); 3605 3639 … … 3615 3649 sh_util_siggen ( conn->client_entry->session_key, 3616 3650 &hash[KEY_LEN], 3617 sl_strlen(&hash[KEY_LEN])), 3651 sl_strlen(&hash[KEY_LEN]), 3652 sigbuf, sizeof(sigbuf)), 3618 3653 SH_MAXMSGLEN+KEY_LEN+1); 3619 3654 … … 3631 3666 sh_util_siggen(conn->client_entry->session_key, 3632 3667 buffer, 3633 sl_strlen(buffer)))); 3668 sl_strlen(buffer), 3669 sigbuf, sizeof(sigbuf)))); 3634 3670 3635 3671 #ifdef SH_ENCRYPT … … 3767 3803 sl_strlcpy(conn->A, 3768 3804 sh_tiger_hash((char *) &ticks, 3769 TIGER_DATA, sizeof(UINT32)), 3805 TIGER_DATA, sizeof(UINT32), 3806 hashbuf, sizeof(hashbuf)), 3770 3807 KEY_LEN+1); 3771 3808 u[0] = 'I'; u[1] = 'N'; u[2] = 'I'; u[3] = 'T'; u[4] = '\0'; … … 3849 3886 sl_strlcpy(hash, sh_tiger_hash (conn->M1, 3850 3887 TIGER_DATA, 3851 sl_strlen(conn->M1)), KEY_LEN+1); 3888 sl_strlen(conn->M1), 3889 hashbuf, sizeof(hashbuf)), 3890 KEY_LEN+1); 3852 3891 sh_passwd (hash, conn->client_entry->verifier, NULL, conn->M1); 3853 3892 … … 4084 4123 u[4] = '\0'; 4085 4124 sl_strlcpy(conn->challenge, 4086 sh_tiger_hash(u, TIGER_DATA, 4 ),4125 sh_tiger_hash(u, TIGER_DATA, 4, hashbuf, sizeof(hashbuf)), 4087 4126 SH_CHALLENGE_SIZE); 4088 4127 … … 4116 4155 sl_strlcpy(conn->K, 4117 4156 sh_tiger_hash(foo_Ss, TIGER_DATA, 4118 sl_strlen(foo_Ss)), 4157 sl_strlen(foo_Ss), 4158 hashbuf, sizeof(hashbuf)), 4119 4159 KEY_LEN+1); 4120 4160 … … 4125 4165 } 4126 4166 conn->M1 = SH_ALLOC(KEY_LEN+1); 4127 sl_strlcpy(conn->M1, 4128 sh_srp_M (conn->A, foo_B, conn->K), 4129 KEY_LEN+1); 4167 sh_srp_M (conn->A, foo_B, conn->K, conn->M1, KEY_LEN+1); 4130 4168 4131 4169 TPT((0, FIL__, __LINE__, _("msg=<srp:Ss = %s>\n"), foo_Ss)); … … 4196 4234 * send M2 4197 4235 */ 4236 char M_buf[KEY_LEN+1]; 4198 4237 sh_forward_prep_send (conn, 4199 sh_srp_M (conn->A, conn->M1, conn->K), 4238 sh_srp_M (conn->A, conn->M1, conn->K, 4239 M_buf, sizeof(M_buf)), 4200 4240 KEY_LEN+1, 4201 4241 _("PARP"), -
trunk/src/sh_gpg.c
r132 r133 128 128 SL_ENTER(_("sh_gpg_checksum")); 129 129 130 tiger_fd = checkfd;131 130 #if defined(WITH_PGP) 132 test_gpg = sh_tiger_hash_gpg (DEFAULT_PGP_PATH, TIGER_FD, 0);133 #else 134 test_gpg = sh_tiger_hash_gpg (DEFAULT_GPG_PATH, TIGER_FD, 0);131 test_gpg = sh_tiger_hash_gpg (DEFAULT_PGP_PATH, checkfd, 0); 132 #else 133 test_gpg = sh_tiger_hash_gpg (DEFAULT_GPG_PATH, checkfd, 0); 135 134 #endif 136 135 -
trunk/src/sh_hash.c
r132 r133 430 430 file_type * theFile; 431 431 char * str; 432 char hashbuf[KEYBUF_SIZE]; 432 433 433 434 /* -------- find the entry for the file ---------------- */ … … 438 439 p = hashsearch( sh_tiger_hash(fullpath, 439 440 TIGER_DATA, 440 sl_strlen(fullpath)) 441 sl_strlen(fullpath), 442 hashbuf, sizeof(hashbuf)) 441 443 ); 442 444 if (p == NULL) … … 1116 1118 SL_TICKET open_tmp (void); 1117 1119 #endif 1120 char hashbuf[KEYBUF_SIZE]; 1118 1121 1119 1122 SL_ENTER(_("sh_hash_init")); … … 1144 1147 sl_rewind (fd); 1145 1148 1146 tiger_fd = fd;1147 1149 sl_strlcpy (sh.data.hash, 1148 1150 sh_tiger_hash (file_path('C', 'R'), /*irrelevant, TIGER_FD*/ 1149 TIGER_FD, 0),1151 fd, 0, hashbuf, sizeof(hashbuf)), 1150 1152 KEY_LEN+1); 1151 1153 sl_rewind (fd); … … 1173 1175 file_path('D', 'R'))); 1174 1176 1175 tiger_fd = fd;1176 1177 if (0 != sl_strncmp(sh.data.hash, 1177 sh_tiger_hash (file_path('D', 'R'), TIGER_FD, 0), 1178 sh_tiger_hash (file_path('D', 'R'), fd, 0, 1179 hashbuf, sizeof(hashbuf)), 1178 1180 KEY_LEN) 1179 1181 && sh.flag.checkSum != SH_CHECK_INIT) … … 1550 1552 else 1551 1553 { 1554 char hashbuf[KEYBUF_SIZE]; 1555 1552 1556 sl_strlcpy(fullpath, 1553 1557 sh_tiger_hash (buf->fullpath, 1554 TIGER_DATA, old_len), 1558 TIGER_DATA, old_len, 1559 hashbuf, sizeof(hashbuf)), 1555 1560 KEY_LEN+1); 1556 1561 } … … 1587 1592 else 1588 1593 { 1594 char hashbuf[KEYBUF_SIZE]; 1589 1595 sl_strlcpy(linkpath, 1590 1596 sh_tiger_hash (buf->linkpath, 1591 TIGER_DATA, old_len), 1597 TIGER_DATA, old_len, 1598 hashbuf, sizeof(hashbuf)), 1592 1599 KEY_LEN+1); 1593 1600 } … … 1828 1835 { 1829 1836 sh_file_t * p; 1837 char hashbuf[KEYBUF_SIZE]; 1830 1838 1831 1839 SL_ENTER(_("sh_hash_have_it_int")); … … 1839 1847 p = hashsearch(newname); 1840 1848 else 1841 p = hashsearch ( sh_tiger_hash(newname, TIGER_DATA, sl_strlen(newname)) ); 1849 p = hashsearch ( sh_tiger_hash(newname, TIGER_DATA, sl_strlen(newname), 1850 hashbuf, sizeof(hashbuf)) ); 1842 1851 if (p == NULL) 1843 1852 SL_RETURN( (NULL), _("sh_hash_have_it_int")); … … 1919 1928 { 1920 1929 sh_file_t * p; 1930 char hashbuf[KEYBUF_SIZE]; 1921 1931 1922 1932 SL_ENTER(_("sh_hash_set_visited_int")); … … 1930 1940 p = hashsearch(newname); 1931 1941 else 1932 p = hashsearch (sh_tiger_hash(newname, TIGER_DATA, sl_strlen(newname))); 1942 p = hashsearch (sh_tiger_hash(newname, TIGER_DATA, sl_strlen(newname), 1943 hashbuf, sizeof(hashbuf))); 1933 1944 1934 1945 if (p == NULL) … … 2120 2131 char * linkpath; 2121 2132 char * attr_string = NULL; 2133 char hashbuf[KEYBUF_SIZE]; 2122 2134 2123 2135 SL_ENTER(_("sh_hash_push_int")); … … 2170 2182 fullpath = SH_ALLOC(KEY_LEN + 1); 2171 2183 sl_strlcpy(fullpath, 2172 sh_tiger_hash (buf->fullpath, TIGER_DATA, len), 2184 sh_tiger_hash (buf->fullpath, TIGER_DATA, len, 2185 hashbuf, sizeof(hashbuf)), 2173 2186 KEY_LEN+1); 2174 2187 } … … 2187 2200 linkpath = SH_ALLOC(KEY_LEN + 1); 2188 2201 sl_strlcpy(linkpath, 2189 sh_tiger_hash (buf->linkpath, TIGER_DATA, len), 2202 sh_tiger_hash (buf->linkpath, TIGER_DATA, len, 2203 hashbuf, sizeof(hashbuf)), 2190 2204 KEY_LEN+1); 2191 2205 } … … 2616 2630 char log_policy[32]; 2617 2631 int log_severity; 2632 char hashbuf[KEYBUF_SIZE]; 2618 2633 2619 2634 SL_ENTER(_("sh_hash_compdata")); … … 2636 2651 p = hashsearch( sh_tiger_hash(theFile->fullpath, 2637 2652 TIGER_DATA, 2638 sl_strlen(theFile->fullpath)) 2653 sl_strlen(theFile->fullpath), 2654 hashbuf, sizeof(hashbuf)) 2639 2655 ); 2640 2656 … … 2739 2755 sh_tiger_hash(theFile->linkpath, 2740 2756 TIGER_DATA, 2741 sl_strlen(theFile->linkpath)), 2757 sl_strlen(theFile->linkpath), 2758 hashbuf, sizeof(hashbuf)), 2742 2759 MAX_PATH_STORE+1); 2743 2760 maxcomp = MAX_PATH_STORE; -
trunk/src/sh_mail.c
r132 r133 223 223 else 224 224 { 225 char sigbuf[KEYBUF_SIZE]; 226 225 227 /* iterate key 226 228 */ … … 228 230 for (i = 0; i < numsig; ++i) 229 231 { 232 char hashbuf[KEYBUF_SIZE]; 230 233 (void) sl_strlcpy (key2, 231 sh_tiger_hash (key2, TIGER_DATA, KEY_LEN), 234 sh_tiger_hash (key2, TIGER_DATA, KEY_LEN, 235 hashbuf, sizeof(hashbuf)), 232 236 KEY_LEN+1); 233 237 } 234 238 235 239 236 theSig = sh_util_siggen (key2, bufc, sl_strlen(bufc) );240 theSig = sh_util_siggen (key2, bufc, sl_strlen(bufc), sigbuf, sizeof(sigbuf)); 237 241 if (sl_strncmp (key, 238 242 theSig, … … 811 815 size_t combufsize = SH_MAILBUF; 812 816 char timebuf[81]; 817 char hashbuf[KEYBUF_SIZE]; 813 818 814 819 SL_ENTER(_("sh_mail_msg")); … … 1004 1009 */ 1005 1010 (void) sl_strlcpy(skey->mailkey_new, 1006 sh_tiger_hash (skey->mailkey_old, TIGER_DATA, KEY_LEN), 1011 sh_tiger_hash (skey->mailkey_old, TIGER_DATA, KEY_LEN, 1012 hashbuf, sizeof(hashbuf)), 1007 1013 KEY_LEN+1); 1008 1014 1009 1015 if (isfirst == 0) 1010 1016 { 1017 char sigbuf[KEYBUF_SIZE]; 1018 1011 1019 /* Sign the message with the signature key. 1012 1020 */ 1013 1021 theSig = sh_util_siggen (skey->mailkey_new, 1014 bufcompress, sl_strlen(bufcompress)); 1022 bufcompress, sl_strlen(bufcompress), 1023 sigbuf, sizeof(sigbuf)); 1015 1024 (void) sl_strlcat (mailMsg, 1016 1025 theSig, -
trunk/src/sh_prelink.c
r132 r133 112 112 SL_TICKET ticket; 113 113 char * tmp; 114 char hashbuf[KEYBUF_SIZE]; 114 115 115 116 if (task->com_ti != (-1)) … … 128 129 return; 129 130 } 130 tiger_fd = ticket; 131 131 132 if (*(task->checksum) == '\0' || 132 133 0 == sl_strcmp(task->checksum, 133 sh_tiger_hash (task->command, TIGER_FD, 0)))134 sh_tiger_hash (task->command, ticket, 0, hashbuf, sizeof(hashbuf)))) 134 135 { 135 136 task->com_fd = get_the_fd(ticket); … … 256 257 /* read from pipe 257 258 */ 258 tiger_fd = task.pipeTI;259 260 259 sl_read_timeout_prep (task.pipeTI); 261 260 262 sl_strlcpy(file_hash, 263 sh_tiger_generic_hash (path, TIGER_FD, TIGER_NOLIM, alert_timeout), 264 KEY_LEN+1); 261 { 262 char hashbuf[KEYBUF_SIZE]; 263 sl_strlcpy(file_hash, 264 sh_tiger_generic_hash (path, task.pipeTI, TIGER_NOLIM, alert_timeout, 265 hashbuf, sizeof(hashbuf)), 266 KEY_LEN+1); 267 } 265 268 266 269 /* restore old signal handler -
trunk/src/sh_readconf.c
r77 r133 191 191 #endif 192 192 uid_t euid; 193 char hashbuf[KEYBUF_SIZE]; 193 194 194 195 SL_ENTER(_("sh_readconf_read")); … … 251 252 /* Compute the checksum of the open file. 252 253 */ 253 tiger_fd = fd;254 254 sl_strlcpy(sh.conf.hash, 255 sh_tiger_hash(file_path('C',local_flag), TIGER_FD, 0),255 sh_tiger_hash(file_path('C',local_flag), fd, 0, hashbuf, sizeof(hashbuf)), 256 256 KEY_LEN+1); 257 257 sl_rewind (fd); -
trunk/src/sh_srp.c
r34 r133 200 200 register int i; 201 201 unsigned char * dez = NULL; 202 char hashbuf[KEYBUF_SIZE]; 202 203 203 204 SL_ENTER(_("sh_srp_x")); … … 218 219 219 220 (void) sl_strlcpy (skey->vernam, 220 sh_tiger_hash(skey->vernam, TIGER_DATA, PW_LEN), KEY_LEN); 221 sh_tiger_hash(skey->vernam, TIGER_DATA, PW_LEN, 222 hashbuf, sizeof(hashbuf)), 223 KEY_LEN); 221 224 skey->vernam[KEY_LEN] = '\0'; 222 225 … … 233 236 (void) sl_strlcpy (sh_srp.x, 234 237 sh_tiger_hash(combi, TIGER_DATA, 235 (unsigned long) sl_strlen(combi)), 238 (unsigned long) sl_strlen(combi), 239 hashbuf, sizeof(hashbuf)), 236 240 KEY_LEN+1); 237 241 SH_FREE (combi); … … 240 244 } 241 245 242 char * sh_srp_M (char * x1, char * x2, char * x3 )246 char * sh_srp_M (char * x1, char * x2, char * x3, char * hash, size_t size) 243 247 { 244 248 char *combi; 245 249 size_t len, l2, l3; 246 static char hash[KEY_LEN+1];247 250 248 251 SL_ENTER(_("sh_srp_M")); … … 266 269 (void) sl_strlcat (combi, x2, len); 267 270 (void) sl_strlcat (combi, x3, len); 268 (void) sl_strlcpy (hash, 269 sh_tiger_hash(combi, TIGER_DATA, (unsigned long) (len-1)), 270 KEY_LEN+1); 271 (void) sh_tiger_hash(combi, TIGER_DATA, (unsigned long) (len-1), 272 hash, size); 271 273 SH_FREE (combi); 272 274 -
trunk/src/sh_tiger0.c
r131 r133 99 99 * implementation 100 100 */ 101 SL_TICKET tiger_fd = (-1);102 101 103 102 static sh_byte buffer[PRIV_MAX + 72]; … … 106 105 static 107 106 word64 * sh_tiger_hash_val (const char * filename, TigerType what, 108 UINT64 Length, int timeout )107 UINT64 Length, int timeout, word64 * res) 109 108 #else 110 109 static 111 110 sh_word32 * sh_tiger_hash_val (const char * filename, TigerType what, 112 UINT64 Length, int timeout )111 UINT64 Length, int timeout, sh_word32 * res) 113 112 #endif 114 113 { … … 138 137 #if defined(TIGER_64_BIT) 139 138 #define TIGER_CAST (word64*) 140 static word64 res[3];139 /* word64 res[3]; */ 141 140 res[0]= (word64) 0x0123456789ABCDEFLL; 142 141 res[1]= (word64) 0xFEDCBA9876543210LL; … … 144 143 #else 145 144 #define TIGER_CAST (sh_word32*) 146 static sh_word32 res[6];145 /* sh_word32 res[6]; */ 147 146 res[0]= (sh_word32) 0x89ABCDEF; 148 147 res[1]= (sh_word32) 0x01234567; … … 155 154 SL_ENTER(_("sh_tiger_hash_val")); 156 155 157 if (what == TIGER_FD || what == TIGER_FILE)156 if (what >= TIGER_FILE) 158 157 { 159 if (what ==TIGER_FD)158 if (what > TIGER_FD) 160 159 { 161 fd = tiger_fd;162 TPT((0,FIL__, __LINE__, _("msg=<TIGER_FD>, fd=<%ld>\n"), tiger_fd));160 fd = what; 161 TPT((0,FIL__, __LINE__, _("msg=<TIGER_FD>, fd=<%ld>\n"), fd)); 163 162 } 164 163 else … … 171 170 if (SL_ISERROR (fd)) 172 171 { 173 TPT((0, FIL__, __LINE__, _("msg=<SL_ISERROR (%ld)>\n"), tiger_fd));172 TPT((0, FIL__, __LINE__, _("msg=<SL_ISERROR (%ld)>\n"), fd)); 174 173 tmp = sh_util_safe_name (filename); 175 174 (void) sl_get_euid(&euid); … … 179 178 SL_RETURN( NULL, _("sh_tiger_hash_val")); 180 179 } 181 180 181 SH_MUTEX_LOCK(mutex_skey); 182 182 #if defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK) 183 183 if ((lockflag == SL_FALSE) && (skey->mlock_failed == SL_FALSE)) … … 196 196 } 197 197 #endif 198 SH_MUTEX_UNLOCK(mutex_skey); 198 199 199 200 #ifdef TIGER_DBG … … 254 255 255 256 nblocks += blk; 257 /* MAY_LOCK */ 256 258 sh.statistics.bytes_hashed += tt; 257 259 … … 331 333 bbuf[j++] = (sh_byte) 0; 332 334 tiger_t(TIGER_CAST bbuf, 64, res); 335 /* MAY_LOCK */ 333 336 sh.statistics.bytes_hashed += 64; 334 337 ++nblocks; ncount = 0; … … 361 364 if (what == TIGER_FILE) 362 365 (void) sl_close (fd); 363 else364 tiger_fd = (-1);365 366 366 367 SL_RETURN( res, _("sh_tiger_hash_val")); … … 807 808 beginning at RESBLOCK. */ 808 809 static int md5_stream(char * filename, void *resblock, 809 UINT64 Length, int timeout )810 UINT64 Length, int timeout, SL_TICKET fd) 810 811 { 811 812 /* Important: BLOCKSIZE must be a multiple of 64. */ … … 830 831 (void) md5Reset (&ctx); 831 832 832 fd = tiger_fd;833 834 833 if (SL_ISERROR (fd)) 835 834 { 836 TPT((0, FIL__, __LINE__, _("msg=<SL_ISERROR (%ld)>\n"), tiger_fd));835 TPT((0, FIL__, __LINE__, _("msg=<SL_ISERROR (%ld)>\n"), fd)); 837 836 tmp = sh_util_safe_name (filename); 838 837 (void) sl_get_euid(&euid); … … 932 931 static 933 932 char * sh_tiger_md5_hash (char * filename, TigerType what, 934 UINT64 Length, int timeout )933 UINT64 Length, int timeout, char * out, size_t len) 935 934 { 936 935 int cnt; 937 static char out[KEY_LEN+1];936 char outbuf[KEY_LEN+1]; 938 937 unsigned char md5buffer[16]; 939 938 940 if (what != TIGER_FD) 941 { 942 sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__, 0, 943 MSG_E_SUBGEN, _("Not TIGER_FD"), 944 _("sh_tiger_md5_hash")); 945 out[0] = '\0'; 946 return out; 947 } 948 949 (void) md5_stream (filename, md5buffer, Length, timeout); 939 (void) md5_stream (filename, md5buffer, Length, timeout, what); 950 940 951 941 /*@-bufferoverflowhigh -usedef@*/ 952 942 for (cnt = 0; cnt < 16; ++cnt) 953 sprintf (&out [cnt*2], _("%02X"), /* known to fit */943 sprintf (&outbuf[cnt*2], _("%02X"), /* known to fit */ 954 944 (unsigned int) md5buffer[cnt]); 955 945 /*@+bufferoverflowhigh +usedef@*/ 956 946 for (cnt = 32; cnt < KEY_LEN; ++cnt) 957 out[cnt] = '0'; 958 out[KEY_LEN] = '\0'; 959 947 outbuf[cnt] = '0'; 948 outbuf[KEY_LEN] = '\0'; 949 950 sl_strlcpy(out, outbuf, len); 960 951 return out; 961 952 } … … 1328 1319 beginning at RESBLOCK. */ 1329 1320 static int sha1_stream(char * filename, void *resblock, 1330 UINT64 Length, int timeout )1321 UINT64 Length, int timeout, SL_TICKET fd) 1331 1322 { 1332 1323 /* Important: BLOCKSIZE must be a multiple of 64. */ … … 1350 1341 (void) sha_init(&ctx); 1351 1342 1352 fd = tiger_fd;1353 1354 1343 if (SL_ISERROR (fd)) 1355 1344 { 1356 TPT((0, FIL__, __LINE__, _("msg=<SL_ISERROR (%ld)>\n"), tiger_fd));1345 TPT((0, FIL__, __LINE__, _("msg=<SL_ISERROR (%ld)>\n"), fd)); 1357 1346 tmp = sh_util_safe_name (filename); 1358 1347 (void) sl_get_euid(&euid); … … 1457 1446 1458 1447 static char * sh_tiger_sha1_hash (char * filename, TigerType what, 1459 UINT64 Length, int timeout) 1448 UINT64 Length, int timeout, 1449 char * out, size_t len) 1460 1450 { 1461 1451 int cnt = (int) Length; /* fix compiler warning */ 1462 static char out[KEY_LEN+1];1452 char outbuf[KEY_LEN+1]; 1463 1453 unsigned char sha1buffer[20]; 1464 1454 1465 if (what != TIGER_FD) 1466 { 1467 sh_error_handle (ShDFLevel[SH_ERR_T_FILE], FIL__, __LINE__, 0, 1468 MSG_E_SUBGEN, _("Not TIGER_FD"), 1469 _("sh_tiger_sha1_hash")); 1470 out[0] = '\0'; 1471 return out; 1472 } 1473 1474 (void) sha1_stream (filename, sha1buffer, Length, timeout); 1455 (void) sha1_stream (filename, sha1buffer, Length, timeout, what); 1475 1456 1476 1457 /*@-bufferoverflowhigh -usedef@*/ 1477 1458 for (cnt = 0; cnt < 20; ++cnt) 1478 sprintf (&out [cnt*2], _("%02X"),/* known to fit */1459 sprintf (&outbuf[cnt*2], _("%02X"), /* known to fit */ 1479 1460 (unsigned int) sha1buffer[cnt]); 1480 1461 /*@+bufferoverflowhigh +usedef@*/ 1481 1462 for (cnt = 40; cnt < KEY_LEN; ++cnt) 1482 out[cnt] = '0'; 1483 out[KEY_LEN] = '\0'; 1484 1463 outbuf[cnt] = '0'; 1464 outbuf[KEY_LEN] = '\0'; 1465 1466 sl_strlcpy(out, outbuf, len); 1485 1467 return out; 1486 1468 } … … 1523 1505 1524 1506 static char * sh_tiger_hash_internal (const char * filename, TigerType what, 1525 UINT64 Length, int timeout); 1507 UINT64 Length, int timeout, 1508 char * out, size_t len); 1526 1509 1527 1510 char * sh_tiger_hash (const char * filename, TigerType what, 1528 UINT64 Length )1529 { 1530 return sh_tiger_hash_internal (filename, what, Length, 0 );1511 UINT64 Length, char * out, size_t len) 1512 { 1513 return sh_tiger_hash_internal (filename, what, Length, 0, out,len); 1531 1514 } 1532 1515 1533 1516 char * sh_tiger_generic_hash (char * filename, TigerType what, 1534 UINT64 Length, int timeout) 1517 UINT64 Length, int timeout, 1518 char * out, size_t len) 1535 1519 { 1536 1520 #ifdef USE_SHA1 1537 1521 if (hash_type == 1) 1538 return sh_tiger_sha1_hash (filename, what, Length, timeout );1522 return sh_tiger_sha1_hash (filename, what, Length, timeout, out, len); 1539 1523 #endif 1540 1524 #ifdef USE_MD5 1541 1525 if (hash_type == 2) 1542 return sh_tiger_md5_hash (filename, what, Length, timeout );1543 #endif 1544 return sh_tiger_hash_internal (filename, what, Length, timeout );1526 return sh_tiger_md5_hash (filename, what, Length, timeout, out, len); 1527 #endif 1528 return sh_tiger_hash_internal (filename, what, Length, timeout, out, len); 1545 1529 } 1546 1530 … … 1549 1533 1550 1534 static char * sh_tiger_hash_internal (const char * filename, TigerType what, 1551 UINT64 Length, int timeout) 1535 UINT64 Length, int timeout, 1536 char * out, size_t len) 1552 1537 { 1553 1538 #if defined(TIGER_64_BIT) 1554 word64 * res;1539 word64 res[3]; 1555 1540 #else 1556 sh_word32 * res; 1557 #endif 1558 static char out[KEY_LEN+1]; 1541 sh_word32 res[6]; 1542 #endif 1559 1543 1560 1544 SL_ENTER( _("sh_tiger_hash_internal")); 1561 1545 1562 res = sh_tiger_hash_val (filename, what, Length, timeout);1563 1564 if ( res != NULL)1546 SH_VALIDATE_GE(len, (KEY_LEN+1)); 1547 1548 if (NULL != sh_tiger_hash_val (filename, what, Length, timeout, res)) 1565 1549 { 1566 1550 #if defined(TIGER_64_BIT) 1567 sl_snprintf(out, 1568 sizeof(out), 1551 sl_snprintf(out, len, 1569 1552 MYFORMAT, 1570 1553 (sh_word32)(res[0]>>32), … … 1575 1558 (sh_word32)(res[2]) ); 1576 1559 #else 1577 sl_snprintf(out, 1578 sizeof(out), 1560 sl_snprintf(out, len, 1579 1561 MYFORMAT, 1580 1562 (sh_word32)(res[1]), … … 1585 1567 (sh_word32)(res[4]) ); 1586 1568 #endif 1587 out[ sizeof(out)-1] = '\0';1569 out[len-1] = '\0'; 1588 1570 SL_RETURN( out, _("sh_tiger_hash_internal")); 1589 1571 … … 1600 1582 char outhash[48+6+1]; 1601 1583 #if defined(TIGER_64_BIT) 1602 word64 * res;1584 word64 res[3]; 1603 1585 #else 1604 sh_word32 * res;1586 sh_word32 res[6]; 1605 1587 #endif 1606 1588 1607 1589 SL_ENTER(_("sh_tiger_hash_gpg")); 1608 1590 1609 res = sh_tiger_hash_val (filename, what, Length, 0); 1610 if (res != NULL) 1591 if (NULL != sh_tiger_hash_val (filename, what, Length, 0, res)) 1611 1592 { 1612 1593 #if defined(TIGER_64_BIT) … … 1663 1644 UINT32 * sh_tiger_hash_uint32 (char * filename, 1664 1645 TigerType what, 1665 UINT64 Length )1646 UINT64 Length, UINT32 * out, size_t len) 1666 1647 { 1667 1648 #if defined(TIGER_64_BIT) 1668 word64 * res;1649 word64 res[3]; 1669 1650 #else 1670 sh_word32 * res; 1671 #endif 1672 1673 static UINT32 out[6]; 1651 sh_word32 res[6]; 1652 #endif 1674 1653 1675 1654 SL_ENTER(_("sh_tiger_hash_uint32")); 1655 1656 SH_VALIDATE_GE(len, 6); 1676 1657 1677 1658 out[0] = 0; out[1] = 0; out[2] = 0; 1678 1659 out[3] = 0; out[4] = 0; out[5] = 0; 1679 1660 1680 res = sh_tiger_hash_val (filename, what, Length, 0); 1681 1682 if (res != NULL) 1661 if (NULL != sh_tiger_hash_val (filename, what, Length, 0, res)) 1683 1662 { 1684 1663 #if defined(TIGER_64_BIT) -
trunk/src/sh_tools.c
r132 r133 1344 1344 { 1345 1345 char * theSig; 1346 char sigbuf[KEYBUF_SIZE]; 1346 1347 1347 1348 SL_ENTER(_("sh_tools_hash_add")); 1348 1349 1349 theSig = sh_util_siggen (key, buf, buflen );1350 theSig = sh_util_siggen (key, buf, buflen, sigbuf, sizeof(sigbuf)); 1350 1351 sl_strlcat(buf, theSig, buflen + KEY_LEN + 1); 1351 1352 … … 1361 1362 register int i; 1362 1363 char * theSig; 1364 char sigbuf[KEYBUF_SIZE]; 1363 1365 1364 1366 SL_ENTER(_("sh_tools_hash_vfy")); 1365 1367 1366 theSig = sh_util_siggen (key, buf, buflen );1368 theSig = sh_util_siggen (key, buf, buflen, sigbuf, sizeof(sigbuf)); 1367 1369 sl_strlcpy(hash, theSig, KEY_LEN+1); 1368 1370 … … 1389 1391 int total = 0; 1390 1392 char * theSig; 1393 char sigbuf[KEYBUF_SIZE]; 1391 1394 1392 1395 … … 1402 1405 ASSERT_RET((buflen >= 0), _("buflen >= 0"), (NULL)); 1403 1406 1404 theSig = sh_util_siggen (key, buf, buflen );1407 theSig = sh_util_siggen (key, buf, buflen, sigbuf, sizeof(sigbuf)); 1405 1408 sl_strlcpy(hash, theSig, KEY_LEN+1); 1406 1409 … … 1437 1440 register int i; 1438 1441 char * theSig; 1442 char sigbuf[KEYBUF_SIZE]; 1439 1443 1440 1444 SL_ENTER(_("hash_check")); … … 1444 1448 (key == NULL) ? "NULL" : key, buflen); 1445 1449 #endif 1446 theSig = sh_util_siggen (key, &buf[KEY_LEN], buflen-KEY_LEN); 1450 theSig = sh_util_siggen (key, &buf[KEY_LEN], buflen-KEY_LEN, 1451 sigbuf, sizeof(sigbuf)); 1447 1452 sl_strlcpy(hash, theSig, KEY_LEN+1); 1448 1453 … … 1597 1602 int status = BAD; 1598 1603 char * my_tmp_dir; 1604 char hashbuf[KEYBUF_SIZE]; 1599 1605 1600 1606 SL_ENTER(_("open_tmp")); … … 1629 1635 if (my_tmp_dir[0] == '/' && my_tmp_dir[1] == '\0') 1630 1636 file = sh_util_strconcat (my_tmp_dir, 1631 sh_tiger_hash( (char *) &ticks, TIGER_DATA, 4), 1637 sh_tiger_hash( (char *) &ticks, TIGER_DATA, 4, 1638 hashbuf, sizeof(hashbuf)), 1632 1639 NULL); 1633 1640 else 1634 1641 file = sh_util_strconcat (my_tmp_dir, 1635 1642 "/", 1636 sh_tiger_hash( (char *) &ticks, TIGER_DATA, 4), 1643 sh_tiger_hash( (char *) &ticks, TIGER_DATA, 4, 1644 hashbuf, sizeof(hashbuf)), 1637 1645 NULL); 1638 1646 -
trunk/src/sh_unix.c
r132 r133 883 883 { 884 884 char message[512]; 885 char hashbuf[KEYBUF_SIZE]; 885 886 886 887 SL_ENTER(_("sh_unix_self_hash")); … … 894 895 895 896 sl_strlcpy(sh.exec.hash, 896 sh_tiger_hash (c, TIGER_FILE, 0 ),897 sh_tiger_hash (c, TIGER_FILE, 0, hashbuf, sizeof(hashbuf)), 897 898 KEY_LEN+1); 898 899 sl_snprintf(message, 512, _("%s has checksum: %s"), … … 917 918 char newhash[KEY_LEN+1]; 918 919 char message[512]; 920 char hashbuf[KEYBUF_SIZE]; 919 921 920 922 SL_ENTER(_("sh_unix_self_check")); … … 922 924 SL_RETURN((0), _("sh_unix_self_check")); 923 925 924 sl_strlcpy(newhash, sh_tiger_hash (sh.exec.path, TIGER_FILE, 0), KEY_LEN+1); 926 sl_strlcpy(newhash, 927 sh_tiger_hash (sh.exec.path, TIGER_FILE, 0, hashbuf, sizeof(hashbuf)), 928 KEY_LEN+1); 925 929 if (0 == sl_strncmp(sh.exec.hash, 926 930 newhash, … … 2357 2361 } 2358 2362 2359 SH_MUTEX_STATIC( getUIDname, PTHREAD_MUTEX_INITIALIZER);2363 SH_MUTEX_STATIC(mutex_getUIDname, PTHREAD_MUTEX_INITIALIZER); 2360 2364 2361 2365 char * sh_unix_getUIDname (int level, uid_t uid, char * out, size_t len) … … 2375 2379 if ((uid == old_uid) && (name[0] != '\0')) { 2376 2380 out[0] = '\0'; 2377 SH_MUTEX_LOCK_UNSAFE( getUIDname);2381 SH_MUTEX_LOCK_UNSAFE(mutex_getUIDname); 2378 2382 if ((uid == old_uid) && (name[0] != '\0')) { 2379 2383 sl_strlcpy(out, name, len); 2380 2384 } 2381 SH_MUTEX_UNLOCK_UNSAFE( getUIDname);2385 SH_MUTEX_UNLOCK_UNSAFE(mutex_getUIDname); 2382 2386 if (out[0] != '\0') 2383 2387 SL_RETURN( out, _("sh_unix_getUIDname")); … … 2401 2405 2402 2406 if (tempres->pw_name != NULL) { 2403 SH_MUTEX_LOCK_UNSAFE( getUIDname);2407 SH_MUTEX_LOCK_UNSAFE(mutex_getUIDname); 2404 2408 sl_strlcpy(name, tempres->pw_name, sizeof(name)); 2405 2409 old_uid = uid; 2406 2410 sl_strlcpy(out, name, len); 2407 SH_MUTEX_UNLOCK_UNSAFE( getUIDname);2411 SH_MUTEX_UNLOCK_UNSAFE(mutex_getUIDname); 2408 2412 SL_RETURN( out, _("sh_unix_getUIDname")); 2409 2413 } else { … … 2415 2419 } 2416 2420 2417 SH_MUTEX_STATIC( getGIDname, PTHREAD_MUTEX_INITIALIZER);2421 SH_MUTEX_STATIC(mutex_getGIDname, PTHREAD_MUTEX_INITIALIZER); 2418 2422 2419 2423 char * sh_unix_getGIDname (int level, gid_t gid, char * out, size_t len) … … 2434 2438 if ((gid == old_gid) && (name[0] != '\0')) { 2435 2439 out[0] = '\0'; 2436 SH_MUTEX_LOCK_UNSAFE( getGIDname);2440 SH_MUTEX_LOCK_UNSAFE(mutex_getGIDname); 2437 2441 if ((gid == old_gid) && (name[0] != '\0')) { 2438 2442 sl_strlcpy(out, name, len); 2439 2443 } 2440 SH_MUTEX_UNLOCK_UNSAFE( getGIDname);2444 SH_MUTEX_UNLOCK_UNSAFE(mutex_getGIDname); 2441 2445 if (out[0] != '\0') 2442 2446 SL_RETURN( out, _("sh_unix_getGIDname")); … … 2459 2463 } 2460 2464 2461 /* FIXME: need to return caller-supplied buffer */2462 2465 if (tempres->gr_name != NULL) { 2463 SH_MUTEX_LOCK_UNSAFE( getGIDname);2466 SH_MUTEX_LOCK_UNSAFE(mutex_getGIDname); 2464 2467 sl_strlcpy(name, tempres->gr_name, sizeof(name)); 2465 2468 old_gid = gid; 2466 2469 sl_strlcpy(out, name, len); 2467 SH_MUTEX_UNLOCK_UNSAFE( getGIDname);2470 SH_MUTEX_UNLOCK_UNSAFE(mutex_getGIDname); 2468 2471 SL_RETURN( out, _("sh_unix_getGIDname")); 2469 2472 } else { … … 2993 2996 2994 2997 int sh_unix_checksum_size (char * filename, struct stat * fbuf, 2995 char * fileHash, int alert_timeout )2998 char * fileHash, int alert_timeout, SL_TICKET fd) 2996 2999 { 2997 3000 file_type tmpFile; … … 3016 3019 if (tmpFile.size < fbuf->st_size) 3017 3020 { 3021 char hashbuf[KEYBUF_SIZE]; 3018 3022 sl_strlcpy(fileHash, 3019 sh_tiger_generic_hash (filename, TIGER_FD, tmpFile.size,3020 alert_timeout ),3023 sh_tiger_generic_hash (filename, fd, tmpFile.size, 3024 alert_timeout, hashbuf, sizeof(hashbuf)), 3021 3025 KEY_LEN+1); 3022 3026 … … 3355 3359 else 3356 3360 { 3357 tiger_fd = rval_open;3361 char hashbuf[KEYBUF_SIZE]; 3358 3362 sl_strlcpy(fileHash, 3359 3363 sh_tiger_generic_hash (theFile->fullpath, 3360 TIGER_FD, TIGER_NOLIM, 3361 alert_timeout), 3364 rval_open, TIGER_NOLIM, 3365 alert_timeout, 3366 hashbuf, sizeof(hashbuf)), 3362 3367 KEY_LEN+1); 3363 3368 if ((theFile->check_mask & MODI_SGROW) != 0) 3364 3369 { 3365 3370 sl_rewind(rval_open); 3366 tiger_fd = rval_open;3367 3371 sh_unix_checksum_size (theFile->fullpath, &fbuf, 3368 3372 &fileHash[KEY_LEN + 1], 3369 alert_timeout );3373 alert_timeout, rval_open); 3370 3374 } 3371 3375 } … … 3395 3399 else 3396 3400 { 3397 tiger_fd = rval_open;3401 char hashbuf[KEYBUF_SIZE]; 3398 3402 sl_strlcpy(fileHash, 3399 sh_tiger_generic_hash (theFile->fullpath, TIGER_FD, TIGER_NOLIM, 3400 alert_timeout), 3403 sh_tiger_generic_hash (theFile->fullpath, rval_open, 3404 TIGER_NOLIM, 3405 alert_timeout, 3406 hashbuf, sizeof(hashbuf)), 3401 3407 KEY_LEN + 1); 3402 3408 if ((theFile->check_mask & MODI_SGROW) != 0) 3403 3409 { 3404 3410 sl_rewind(rval_open); 3405 tiger_fd = rval_open;3406 3411 sh_unix_checksum_size (theFile->fullpath, &fbuf, 3407 3412 &fileHash[KEY_LEN + 1], 3408 alert_timeout );3413 alert_timeout, rval_open); 3409 3414 } 3410 3415 } -
trunk/src/sh_utils.c
r93 r133 642 642 */ 643 643 static char * sh_util_hmac_tiger (char * hexkey, 644 char * text, size_t textlen) 644 char * text, size_t textlen, 645 char * res, size_t len) 645 646 { 646 647 static char opad[KEY_BLOCK] = { … … 669 670 UINT32 cc[KEY_LEN/4]; 670 671 char * res; 672 UINT32 kbuf[KEY_BYT/sizeof(UINT32)]; 673 char hashbuf[KEYBUF_SIZE]; 674 671 675 672 676 size_t i; … … 677 681 if (KEY_BLOCK > (KEY_LEN/2)) 678 682 { 679 res = sh_tiger_hash (NULL, TIGER_DATA, 0 );683 res = sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 680 684 SL_RETURN(res, _("sh_util_hmac_tiger")); 681 685 } … … 685 689 if (sh_util_hextobinary (K, hexkey, KEY_LEN) < 0) 686 690 { 687 res = sh_tiger_hash (NULL, TIGER_DATA, 0 );691 res = sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 688 692 SL_RETURN(res, _("sh_util_hmac_tiger")); 689 693 } … … 708 712 _("integer overflow"), 709 713 _("sh_util_hmac_tiger")); 710 res = sh_tiger_hash (NULL, TIGER_DATA, 0 );714 res = sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 711 715 SL_RETURN(res, _("sh_util_hmac_tiger")); 712 716 } … … 716 720 h1 = sh_tiger_hash_uint32 ( outer, 717 721 TIGER_DATA, 718 KEY_BLOCK); 722 KEY_BLOCK, 723 kbuf, KEY_BYT/sizeof(UINT32)); 719 724 for (i = 0; i < (KEY_LEN/8); ++i) 720 725 { … … 725 730 h2 = sh_tiger_hash_uint32 ( inner, 726 731 TIGER_DATA, 727 (unsigned long) KEY_BLOCK+textlen); 732 (unsigned long) KEY_BLOCK+textlen, 733 kbuf, KEY_BYT/sizeof(UINT32)); 728 734 for (i = KEY_LEN/8; i < (KEY_LEN/4); ++i) 729 735 { … … 733 739 SH_FREE(inner); 734 740 735 res = sh_tiger_hash ((char *) &cc[0], 736 TIGER_DATA, 737 (unsigned long) (KEY_LEN/4 * sizeof(UINT32))); 738 741 (void) sh_tiger_hash ((char *) &cc[0], 742 TIGER_DATA, 743 (unsigned long) (KEY_LEN/4 * sizeof(UINT32)), 744 hashbuf, sizeof(hashbuf)); 745 746 sl_strlcpy(res, hashbuf, len); 739 747 SL_RETURN(res, _("sh_util_hmac_tiger")); 740 748 } 741 749 742 750 static char * sh_util_hash_tiger ( char * hexkey, 743 char * text, size_t textlen )744 { 745 char * res; 751 char * text, size_t textlen 752 char * res, size_t len) 753 { 746 754 char h2[2*KEY_LEN+1]; 747 755 SL_ENTER(_("sh_util_hash_tiger")); 748 756 749 757 (void) sl_strlcpy(h2, hexkey, KEY_LEN+1); 750 (void) sl_strlcat(h2, sh_tiger_hash(text, TIGER_DATA, 751 (unsigned long) textlen), 2*KEY_LEN+1); 752 753 res = sh_tiger_hash(h2, TIGER_DATA, 2*KEY_LEN); 754 758 (void) sl_strlcat(h2, 759 sh_tiger_hash(text, TIGER_DATA, 760 (unsigned long) textlen, 761 hashbuf, sizeof(hashbuf)), 762 2*KEY_LEN+1, 763 ); 764 765 (void) sh_tiger_hash(h2, TIGER_DATA, 2*KEY_LEN, hashbuf, sizeof(hashbuf)); 766 767 sl_strlcpy(res, hashbuf, len); 755 768 SL_RETURN(res, _("sh_util_hash_tiger")); 756 769 } … … 780 793 781 794 char * sh_util_siggen (char * hexkey, 782 char * text, size_t textlen) 795 char * text, size_t textlen, 796 char * res, size_t len) 783 797 { 784 798 char * p; … … 787 801 if (sigtype == TYPE_HMAC) 788 802 p = sh_util_hmac_tiger (hexkey, 789 text, textlen );803 text, textlen, res, len); 790 804 else 791 805 p = sh_util_hash_tiger (hexkey, 792 text, textlen );806 text, textlen, res, len); 793 807 SL_RETURN(p, _("sh_util_siggen")); 794 808 } … … 927 941 static int res_num = 0; 928 942 register int i; 943 UINT32 kbuf[KEY_BYT/sizeof(UINT32)]; 929 944 930 945 if (res_num > 0) … … 944 959 res = sh_tiger_hash_uint32 ( (char *) &taus_svec[0], 945 960 TIGER_DATA, 946 (unsigned long)(6 * sizeof(UINT32))); 961 (unsigned long)(6 * sizeof(UINT32)), 962 kbuf, KEY_BYT/sizeof(UINT32)); 947 963 948 964 for (i = 1; i < 6; ++i) … … 1180 1196 image[k+7] == new_key[7]) 1181 1197 { 1198 UINT32 kbuf[KEY_BYT/sizeof(UINT32)]; 1199 1182 1200 printf(_("old key found\n")); 1183 1201 h1 = sh_tiger_hash_uint32 (key, TIGER_DATA, 1184 (unsigned long)strlen(key)); 1202 (unsigned long)strlen(key), 1203 kbuf, KEY_BYT/sizeof(UINT32)); 1185 1204 copy_four( (unsigned char *) &(image[k]), h1[0]); 1186 1205 copy_four( (unsigned char *) &(image[k+4]), h1[1]); … … 1229 1248 register int i, j, j1 = 0, j2 = 0, j3; 1230 1249 char * dez; 1250 char hashbuf[KEYBUF_SIZE]; 1231 1251 1232 1252 SL_ENTER(_("sh_util_encode")); … … 1248 1268 1249 1269 (void) sl_strlcpy(skey->vernam, 1250 sh_tiger_hash(skey->vernam, TIGER_DATA, KEY_LEN), 1270 sh_tiger_hash(skey->vernam, TIGER_DATA, KEY_LEN, 1271 hashbuf, sizeof(hashbuf)), 1251 1272 KEY_LEN+1); 1252 1273 1253 1274 (void) sl_strlcpy(skey->vernam, 1254 sh_util_hmac_tiger (skey->vernam, salt, strlen(salt)), 1255 KEY_LEN+1); 1275 sh_util_hmac_tiger (skey->vernam, salt, strlen(salt), 1276 hashbuf, sizeof(hashbuf)), 1277 KEY_LEN+1); 1256 1278 1257 1279 (void) sl_strlcpy(skey->vernam, 1258 sh_util_hmac_tiger (skey->vernam, (char*) new_key, 8), 1280 sh_util_hmac_tiger (skey->vernam, (char*) new_key, 8, 1281 hashbuf, sizeof(hashbuf)), 1259 1282 KEY_LEN+1); 1260 1283 … … 1413 1436 int status = 0; 1414 1437 char * p; 1438 char hashbuf[KEYBUF_SIZE]; 1415 1439 1416 1440 SL_ENTER(_("sh_util_keyinit")); … … 1433 1457 1434 1458 p = sh_tiger_hash ((char *) bufy, TIGER_DATA, 1435 (unsigned long)(6*sizeof(UINT32)) );1436 p[size-1] = '\0';1459 (unsigned long)(6*sizeof(UINT32)), 1460 hashbuf, sizeof(hashbuf)); 1437 1461 1438 1462 i = sl_strlcpy(buf, p, (size_t)size);
Note:
See TracChangeset
for help on using the changeset viewer.