- Timestamp:
- Feb 26, 2007 2:33:14 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util-test/encryption.c
r1001 r1002 384 384 } 385 385 386 /* CRC32 test data, generated from crc32 test on a Linux box */ 387 struct 388 { 389 char *input; 390 pj_uint32_t crc; 391 } crc32_test_data[] = 392 { 393 { 394 "", 395 0x0 396 }, 397 { 398 "Hello World", 399 0x4a17b156 400 }, 401 { 402 /* Something read from /dev/random */ 403 "\x21\x21\x98\x10\x62\x59\xbc\x58\x42\x24\xe5\xf3\x92\x0a\x68\x3c\xa7\x67\x73\xc3", 404 0x506693be 405 }, 406 { 407 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 408 0xcab11777 409 }, 410 { 411 "123456789", 412 0xCBF43926 413 } 414 }; 415 416 /* 417 * CRC32 test 418 */ 419 static int crc32_test(void) 420 { 421 unsigned i; 422 423 PJ_LOG(3, (THIS_FILE, " crc32 test..")); 424 425 for (i=0; i<PJ_ARRAY_SIZE(crc32_test_data); ++i) { 426 pj_uint32_t crc; 427 428 crc = pj_crc32_calc((pj_uint8_t*)crc32_test_data[i].input, 429 pj_ansi_strlen(crc32_test_data[i].input)); 430 if (crc != crc32_test_data[i].crc) { 431 PJ_LOG(3,(THIS_FILE, " error: crc mismatch on test %d", i)); 432 return -80; 433 } 434 } 435 return 0; 436 } 437 386 438 387 439 int encryption_test() … … 401 453 return rc; 402 454 455 rc = crc32_test(); 456 if (rc != 0) 457 return rc; 458 403 459 return 0; 404 460 }
Note: See TracChangeset
for help on using the changeset viewer.