[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)
|
---|
| 12 | extern void sh_g_init();
|
---|
| 13 | #endif
|
---|
| 14 |
|
---|
| 15 |
|
---|
[17] | 16 | static void init() {
|
---|
| 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];
|
---|
[17] | 137 |
|
---|
| 138 | init();
|
---|
| 139 |
|
---|
| 140 | fp = fopen("cutest_foo", "w");
|
---|
| 141 | CuAssertPtrNotNull(tc, fp);
|
---|
| 142 |
|
---|
| 143 | result = fprintf(fp, "%s\n",
|
---|
| 144 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ=abcdefghijklmnopqrstuvwxyz+0123456789");
|
---|
| 145 | CuAssertTrue(tc, result >= 0);
|
---|
| 146 |
|
---|
| 147 | result = fclose(fp);
|
---|
| 148 | CuAssertTrue(tc, result == 0);
|
---|
| 149 |
|
---|
| 150 | result = sh_tiger_hashtype("TIGER192");
|
---|
| 151 | CuAssertTrue(tc, result == 0);
|
---|
| 152 |
|
---|
| 153 | /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
|
---|
| 154 | */
|
---|
[133] | 155 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 156 | expected = "0E9321614C966A33608C2A15F156E0435CACFD1213B9F095";
|
---|
| 157 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 158 |
|
---|
| 159 | rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
|
---|
| 160 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 161 |
|
---|
[133] | 162 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 163 | expected = "0E9321614C966A33608C2A15F156E0435CACFD1213B9F095";
|
---|
| 164 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 165 |
|
---|
| 166 | result = sl_close(rval_open);
|
---|
| 167 | CuAssertTrue(tc, result == 0);
|
---|
| 168 |
|
---|
| 169 | result = sh_tiger_hashtype("MD5");
|
---|
| 170 | CuAssertTrue(tc, result == 0);
|
---|
| 171 |
|
---|
| 172 | rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
|
---|
| 173 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 174 |
|
---|
| 175 | /* same result as GNU md5sum
|
---|
| 176 | */
|
---|
[133] | 177 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 178 | expected = "AEEC4DDA496BCFBA691F4E8863BA84C00000000000000000";
|
---|
| 179 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 180 |
|
---|
| 181 | result = sl_close(rval_open);
|
---|
| 182 | CuAssertTrue(tc, result == 0);
|
---|
| 183 |
|
---|
| 184 | result = sh_tiger_hashtype("SHA1");
|
---|
| 185 | CuAssertTrue(tc, result == 0);
|
---|
| 186 |
|
---|
| 187 | rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
|
---|
| 188 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 189 |
|
---|
| 190 | /* same result as gpg --print-md SHA1
|
---|
| 191 | */
|
---|
[133] | 192 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 193 | expected = "2FE65D1D995B8F8BC8B13F798C07E7E935A787ED00000000";
|
---|
| 194 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 195 |
|
---|
| 196 | result = sl_close(rval_open);
|
---|
| 197 | CuAssertTrue(tc, result == 0);
|
---|
| 198 |
|
---|
| 199 | result = remove("cutest_foo");
|
---|
| 200 | CuAssertTrue(tc, result == 0);
|
---|
| 201 |
|
---|
| 202 | /* --------------------------------------------------- */
|
---|
| 203 |
|
---|
| 204 | fp = fopen("cutest_foo", "w");
|
---|
| 205 | CuAssertPtrNotNull(tc, fp);
|
---|
| 206 |
|
---|
| 207 | result = fprintf(fp, "\n");
|
---|
| 208 | CuAssertTrue(tc, result >= 0);
|
---|
| 209 |
|
---|
| 210 | result = fclose(fp);
|
---|
| 211 | CuAssertTrue(tc, result == 0);
|
---|
| 212 |
|
---|
| 213 | result = sh_tiger_hashtype("TIGER192");
|
---|
| 214 | CuAssertTrue(tc, result == 0);
|
---|
| 215 |
|
---|
| 216 | /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
|
---|
| 217 | */
|
---|
[133] | 218 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 219 | expected = "F987845A0EA784367BF9E4DB09014995810F27C99C891734";
|
---|
| 220 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 221 |
|
---|
| 222 | result = remove("cutest_foo");
|
---|
| 223 | CuAssertTrue(tc, result == 0);
|
---|
| 224 |
|
---|
| 225 | /* --------------------------------------------------- */
|
---|
| 226 |
|
---|
| 227 | fp = fopen("cutest_foo", "w");
|
---|
| 228 | CuAssertPtrNotNull(tc, fp);
|
---|
| 229 |
|
---|
| 230 | result = fprintf(fp, "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.\n");
|
---|
| 231 | CuAssertTrue(tc, result >= 0);
|
---|
| 232 |
|
---|
| 233 | result = fclose(fp);
|
---|
| 234 | CuAssertTrue(tc, result == 0);
|
---|
| 235 |
|
---|
| 236 | result = sh_tiger_hashtype("TIGER192");
|
---|
| 237 | CuAssertTrue(tc, result == 0);
|
---|
| 238 |
|
---|
| 239 | /* same result as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
|
---|
| 240 | */
|
---|
[133] | 241 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[17] | 242 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
| 243 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 244 |
|
---|
| 245 | result = remove("cutest_foo");
|
---|
| 246 | CuAssertTrue(tc, result == 0);
|
---|
| 247 |
|
---|
[19] | 248 | }
|
---|
[17] | 249 |
|
---|
[19] | 250 | /* test checksum of file upto some given length
|
---|
| 251 | */
|
---|
| 252 | void Test_tiger_file_with_length(CuTest *tc) {
|
---|
| 253 |
|
---|
| 254 | SL_TICKET rval_open;
|
---|
| 255 | FILE * fp;
|
---|
| 256 | int result;
|
---|
| 257 | char * actual;
|
---|
| 258 | char * expected;
|
---|
[133] | 259 | char hashbuf[KEYBUF_SIZE];
|
---|
[19] | 260 |
|
---|
| 261 | char * teststring = "Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996.\n";
|
---|
| 262 | int testlen = strlen(teststring);
|
---|
| 263 |
|
---|
| 264 | init();
|
---|
| 265 |
|
---|
| 266 | fp = fopen("cutest_foo", "w");
|
---|
| 267 | CuAssertPtrNotNull(tc, fp);
|
---|
| 268 |
|
---|
| 269 | result = fprintf(fp, "%s", teststring);
|
---|
| 270 | CuAssertTrue(tc, result >= 0);
|
---|
| 271 | result = fprintf(fp, "%s", teststring);
|
---|
| 272 | CuAssertTrue(tc, result >= 0);
|
---|
| 273 |
|
---|
| 274 | result = fclose(fp);
|
---|
| 275 | CuAssertTrue(tc, result == 0);
|
---|
| 276 |
|
---|
| 277 | result = sh_tiger_hashtype("TIGER192");
|
---|
| 278 | CuAssertTrue(tc, result == 0);
|
---|
| 279 |
|
---|
| 280 | /* same as GnuPG 1.0.6 (gpg --load-extension tiger --print-md TIGER192)
|
---|
| 281 | */
|
---|
[133] | 282 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 0, 0, hashbuf, sizeof(hashbuf));
|
---|
[107] | 283 | expected = "24F0130C63AC933216166E76B1BB925FF373DE2D49584E7A";
|
---|
| 284 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 285 |
|
---|
[133] | 286 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 287 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
| 288 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 289 |
|
---|
[133] | 290 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 291 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
| 292 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 293 |
|
---|
[133] | 294 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 295 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
| 296 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 297 |
|
---|
| 298 | fp = fopen("cutest_foo", "a");
|
---|
| 299 | CuAssertPtrNotNull(tc, fp);
|
---|
| 300 | result = fprintf(fp, "%s", teststring);
|
---|
| 301 | CuAssertTrue(tc, result >= 0);
|
---|
| 302 | result = fclose(fp);
|
---|
| 303 | CuAssertTrue(tc, result == 0);
|
---|
| 304 |
|
---|
[133] | 305 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 306 | expected = "75B98A7AE257A230189828A40792E30B4038D286479CC7B8";
|
---|
| 307 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 308 |
|
---|
[133] | 309 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 2*testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 310 | expected = "B5B4FB97B01ADB58794D87A6A01B2368852FA764BD93AB90";
|
---|
| 311 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 312 |
|
---|
[133] | 313 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 3*testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 314 | expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
|
---|
| 315 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 316 |
|
---|
[133] | 317 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 318 | expected = "D0EE1A9956CAB22D84B51A5E0C093B724828C6A1F9CBDB7F";
|
---|
| 319 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 320 |
|
---|
[133] | 321 | actual = sh_tiger_generic_hash("cutest_foo", TIGER_FILE, 5, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 322 | expected = "9F00F599072300DD276ABB38C8EB6DEC37790C116F9D2BDF";
|
---|
| 323 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 324 |
|
---|
| 325 | /* same results as GNU md5sum */
|
---|
| 326 |
|
---|
| 327 | result = sh_tiger_hashtype("MD5");
|
---|
| 328 | CuAssertTrue(tc, result == 0);
|
---|
| 329 |
|
---|
| 330 | rval_open = sl_open_fastread ("cutest_foo", SL_YESPRIV);
|
---|
| 331 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 332 |
|
---|
[133] | 333 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 334 | expected = "11E7E7EA486136273606BEE57C71F34B0000000000000000";
|
---|
| 335 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 336 |
|
---|
| 337 | result = sl_rewind(rval_open);
|
---|
| 338 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 339 |
|
---|
[133] | 340 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, 2*testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 341 | expected = "D49DAD474095D467E2E5EFCB2DC23A770000000000000000";
|
---|
| 342 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 343 |
|
---|
| 344 | result = sl_rewind(rval_open);
|
---|
| 345 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 346 |
|
---|
[133] | 347 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, 3*testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 348 | expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
|
---|
| 349 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 350 |
|
---|
| 351 | result = sl_rewind(rval_open);
|
---|
| 352 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 353 |
|
---|
[133] | 354 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 355 | expected = "00A1F1C5EDDCCFC430D3862FDA94593E0000000000000000";
|
---|
| 356 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 357 |
|
---|
| 358 | /* same result as gpg --print-md SHA1
|
---|
| 359 | */
|
---|
| 360 |
|
---|
| 361 | result = sh_tiger_hashtype("SHA1");
|
---|
| 362 | CuAssertTrue(tc, result == 0);
|
---|
| 363 |
|
---|
| 364 | result = sl_rewind(rval_open);
|
---|
| 365 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 366 |
|
---|
[133] | 367 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 368 | expected = "F37DB4344CCD140EE315179E9A27512FB4704F0F00000000";
|
---|
| 369 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 370 |
|
---|
| 371 | result = sl_rewind(rval_open);
|
---|
| 372 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 373 |
|
---|
[133] | 374 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, 2*testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 375 | expected = "D2AD5FC366452D81400BAC31F96269DEEF314BC200000000";
|
---|
| 376 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 377 |
|
---|
| 378 | result = sl_rewind(rval_open);
|
---|
| 379 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 380 |
|
---|
[133] | 381 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, 3*testlen, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 382 | expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
|
---|
| 383 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 384 |
|
---|
| 385 | result = sl_rewind(rval_open);
|
---|
| 386 | CuAssertTrue(tc, rval_open >= 0);
|
---|
| 387 |
|
---|
[133] | 388 | actual = sh_tiger_generic_hash("cutest_foo", rval_open, TIGER_NOLIM, 0, hashbuf, sizeof(hashbuf));
|
---|
[19] | 389 | expected = "FAA937EF3389C7E786EB0F1006D049D7AEA7B7B600000000";
|
---|
| 390 | CuAssertStrEquals(tc, expected, actual);
|
---|
| 391 |
|
---|
| 392 | result = sl_close(rval_open);
|
---|
| 393 | CuAssertTrue(tc, result == 0);
|
---|
| 394 |
|
---|
| 395 | result = remove("cutest_foo");
|
---|
| 396 | CuAssertTrue(tc, result == 0);
|
---|
| 397 | }
|
---|