- Timestamp:
- Apr 27, 2006, 10:40:32 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cutest_sh_unix.c
r24 r30 9 9 void Test_sh_unix_lookup_page (CuTest *tc) { 10 10 11 intpagesize = sh_unix_pagesize();11 long pagesize = sh_unix_pagesize(); 12 12 13 unsigned intbase;13 unsigned long base; 14 14 int num_pages; 15 15 -
trunk/src/sh_database.c
r27 r30 225 225 typedef unsigned char uint8; 226 226 227 typedef struct 228 { 229 uint32 h[4]; 230 uint32 data[16]; 231 uint8 offset; 232 uint32 nblocks; 233 int count; 227 typedef struct md5_ctx 228 { 229 uint32 A; 230 uint32 B; 231 uint32 C; 232 uint32 D; 233 234 uint32 total[2]; 235 uint32 buflen; 236 char buffer[128]; 234 237 } md5Param; 235 236 238 237 239 -
trunk/src/sh_entropy.c
r22 r30 478 478 static 479 479 char * com_path[] = { 480 N_("/usr/bin/xpg4/"), 480 481 N_("/usr/ucb/"), 481 482 N_("/bin/"), -
trunk/src/sh_suidchk.c
r29 r30 524 524 */ 525 525 fs = filesystem_type (tmpcat, tmpcat, &buf); 526 if (fs != NULL && 526 if (fs != NULL 527 #ifndef SH_SUIDTESTDIR 528 && 527 529 0 != strncmp (_("afs"), fs, 3) && 528 530 0 != strncmp (_("devfs"), fs, 5) && … … 534 536 0 != strncmp (_("nosuid"), fs, 6) && 535 537 0 != strncmp (_("proc"), fs, 4) && 536 0 != strncmp (_("vfat"), fs, 4) 538 0 != strncmp (_("vfat"), fs, 4) 539 #endif 537 540 ) 538 541 { -
trunk/src/sh_tiger0.c
r22 r30 404 404 #ifdef USE_MD5 405 405 /*@-type@*/ 406 /************************************************************************ 406 /* md5.c - Functions to compute MD5 message digest of files or memory blocks 407 * according to the definition of MD5 in RFC 1321 from April 1992. 408 * Copyright (C) 1995, 1996 Free Software Foundation, Inc. 407 409 * 408 * md5.h - Declaration of functions and data types used for MD5 sum409 * computing library functions.410 * NOTE: The canonical source of this file is maintained with the GNU C 411 * Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. 410 412 * 411 ************************************************************************/ 412 413 /* Written Bob Deblier <bob@virtualunlimited.com> */ 413 * This program is free software; you can redistribute it and/or modify it 414 * under the terms of the GNU General Public License as published by the 415 * Free Software Foundation; either version 2, or (at your option) any 416 * later version. 417 * 418 * This program is distributed in the hope that it will be useful, 419 * but WITHOUT ANY WARRANTY; without even the implied warranty of 420 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 421 * GNU General Public License for more details. 422 * 423 * You should have received a copy of the GNU General Public License 424 * along with this program; if not, write to the Free Software Foundation, 425 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 426 */ 427 428 /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */ 429 414 430 /* Hacked to work with samhain by R. Wichmann */ 415 /* Need for 64bit type removed, fix for Mac OS X compiler */ 416 417 typedef sh_word32 uint32; 418 typedef unsigned char uint8; 419 420 421 431 432 typedef UINT32 md5_uint32; 422 433 423 434 424 435 /* Structure to save state of computation between the single steps. */ 425 typedef struct 426 { 427 uint32 h[4]; 428 uint32 data[16]; 429 uint8 offset; 430 uint32 nblocks; 431 int count; 436 typedef struct md5_ctx 437 { 438 md5_uint32 A; 439 md5_uint32 B; 440 md5_uint32 C; 441 md5_uint32 D; 442 443 md5_uint32 total[2]; 444 md5_uint32 buflen; 445 char buffer[128]; 432 446 } md5Param; 433 447 434 static uint32 md5hinit[4] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 }; 448 /* 449 * The following three functions are build up the low level used in 450 * the functions `md5_stream' and `md5_buffer'. 451 */ 452 453 /* Initialize structure containing state of computation. 454 (RFC 1321, 3.3: Step 3) */ 455 static void md5_init_ctx (struct md5_ctx *ctx); 456 457 /* Starting with the result of former calls of this function (or the 458 initialization function update the context for the next LEN bytes 459 starting at BUFFER. 460 It is necessary that LEN is a multiple of 64!!! */ 461 static void md5_process_block (const void *buffer, size_t len, 462 struct md5_ctx *ctx); 463 464 /* Starting with the result of former calls of this function (or the 465 initialization function update the context for the next LEN bytes 466 starting at BUFFER. 467 It is NOT required that LEN is a multiple of 64. */ 468 static void md5_process_bytes (const void *buffer, size_t len, 469 struct md5_ctx *ctx); 470 471 /* Process the remaining bytes in the buffer and put result from CTX 472 in first 16 bytes following RESBUF. The result is always in little 473 endian byte order, so that a byte-wise output yields to the wanted 474 ASCII representation of the message digest. 475 476 IMPORTANT: On some systems it is required that RESBUF is correctly 477 aligned for a 32 bits value. */ 478 static void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf); 479 480 481 /* Put result from CTX in first 16 bytes following RESBUF. The result is 482 always in little endian byte order, so that a byte-wise output yields 483 to the wanted ASCII representation of the message digest. 484 485 IMPORTANT: On some systems it is required that RESBUF is correctly 486 aligned for a 32 bits value. */ 487 static void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf); 488 489 #if WORDS_BIGENDIAN 490 static md5_uint32 swapu32(md5_uint32 n) 491 { 492 return ( ((n & 0xffU) << 24) | 493 ((n & 0xff00U) << 8) | 494 ((n & 0xff0000U) >> 8) | 495 ((n & 0xff000000U) >> 24) ); 496 } 497 #define SWAP(n) swapu32(n) 498 #else 499 #define SWAP(n) (n) 500 #endif 501 502 /* This array contains the bytes used to pad the buffer to the next 503 64-byte boundary. (RFC 1321, 3.1: Step 1) */ 504 static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; 505 506 /* Initialize structure containing state of computation. 507 (RFC 1321, 3.3: Step 3) */ 508 static void md5_init_ctx(struct md5_ctx *ctx) 509 { 510 ctx->A = 0x67452301; 511 ctx->B = 0xefcdab89; 512 ctx->C = 0x98badcfe; 513 ctx->D = 0x10325476; 514 515 ctx->total[0] = ctx->total[1] = 0; 516 ctx->buflen = 0; 517 } 518 519 /* Put result from CTX in first 16 bytes following RESBUF. The result 520 must be in little endian byte order. 521 522 IMPORTANT: On some systems it is required that RESBUF is correctly 523 aligned for a 32 bits value. */ 524 static void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf) 525 { 526 ((md5_uint32 *) resbuf)[0] = SWAP(ctx->A); 527 ((md5_uint32 *) resbuf)[1] = SWAP(ctx->B); 528 ((md5_uint32 *) resbuf)[2] = SWAP(ctx->C); 529 ((md5_uint32 *) resbuf)[3] = SWAP(ctx->D); 530 531 return resbuf; 532 } 533 534 /* Process the remaining bytes in the internal buffer and the usual 535 prolog according to the standard and write the result to RESBUF. 536 537 IMPORTANT: On some systems it is required that RESBUF is correctly 538 aligned for a 32 bits value. */ 539 static void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf) 540 { 541 /* Take yet unprocessed bytes into account. */ 542 md5_uint32 bytes = ctx->buflen; 543 size_t pad; 544 545 /* Now count remaining bytes. */ 546 ctx->total[0] += bytes; 547 if (ctx->total[0] < bytes) 548 ++ctx->total[1]; 549 550 pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; 551 memcpy(&ctx->buffer[bytes], fillbuf, pad); 552 553 /* Put the 64-bit file length in *bits* at the end of the buffer. */ 554 *(md5_uint32 *) & ctx->buffer[bytes + pad] = SWAP(ctx->total[0] << 3); 555 *(md5_uint32 *) & ctx->buffer[bytes + pad + 4] = 556 SWAP((ctx->total[1] << 3) | (ctx->total[0] >> 29)); 557 558 /* Process last bytes. */ 559 md5_process_block(ctx->buffer, bytes + pad + 8, ctx); 560 561 return md5_read_ctx(ctx, resbuf); 562 } 563 564 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The 565 result is always in little endian byte order, so that a byte-wise 566 output yields to the wanted ASCII representation of the message 567 digest. */ 568 void *md5_buffer(const char *buffer, size_t len, void *resblock) 569 { 570 struct md5_ctx ctx; 571 572 /* Initialize the computation context. */ 573 md5_init_ctx(&ctx); 574 575 /* Process whole buffer but last len % 64 bytes. */ 576 md5_process_bytes(buffer, len, &ctx); 577 578 /* Put result in desired memory area. */ 579 return md5_finish_ctx(&ctx, resblock); 580 } 581 582 static void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx) 583 { 584 /* When we already have some bits in our internal buffer concatenate 585 both inputs first. */ 586 if (ctx->buflen != 0) { 587 size_t left_over = ctx->buflen; 588 size_t add = 128 - left_over > len ? len : 128 - left_over; 589 590 memcpy(&ctx->buffer[left_over], buffer, add); 591 ctx->buflen += add; 592 593 if (left_over + add > 64) { 594 md5_process_block(ctx->buffer, (left_over + add) & ~63, ctx); 595 /* The regions in the following copy operation cannot overlap. */ 596 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63], 597 (left_over + add) & 63); 598 ctx->buflen = (left_over + add) & 63; 599 } 600 601 buffer = (const char *) buffer + add; 602 len -= add; 603 } 604 605 /* Process available complete blocks. */ 606 if (len > 64) { 607 md5_process_block(buffer, len & ~63, ctx); 608 buffer = (const char *) buffer + (len & ~63); 609 len &= 63; 610 } 611 612 /* Move remaining bytes in internal buffer. */ 613 if (len > 0) { 614 memcpy(ctx->buffer, buffer, len); 615 ctx->buflen = len; 616 } 617 } 618 619 /* These are the four functions used in the four steps of the MD5 algorithm 620 and defined in the RFC 1321. The first function is a little bit optimized 621 (as found in Colin Plumbs public domain implementation). */ 622 /* #define FF(b, c, d) ((b & c) | (~b & d)) */ 623 #define FF(b, c, d) (d ^ (b & (c ^ d))) 624 #define FG(b, c, d) FF (d, b, c) 625 #define FH(b, c, d) (b ^ c ^ d) 626 #define FI(b, c, d) (c ^ (b | ~d)) 627 628 /* Process LEN bytes of BUFFER, accumulating context into CTX. 629 It is assumed that LEN % 64 == 0. */ 630 static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx) 631 { 632 md5_uint32 correct_words[16]; 633 const md5_uint32 *words = buffer; 634 size_t nwords = len / sizeof(md5_uint32); 635 const md5_uint32 *endp = words + nwords; 636 md5_uint32 A = ctx->A; 637 md5_uint32 B = ctx->B; 638 md5_uint32 C = ctx->C; 639 md5_uint32 D = ctx->D; 640 641 /* First increment the byte count. RFC 1321 specifies the possible 642 length of the file up to 2^64 bits. Here we only compute the 643 number of bytes. Do a double word increment. */ 644 ctx->total[0] += len; 645 if (ctx->total[0] < len) 646 ++ctx->total[1]; 647 648 /* Process all bytes in the buffer with 64 bytes in each round of 649 the loop. */ 650 while (words < endp) { 651 md5_uint32 *cwp = correct_words; 652 md5_uint32 A_save = A; 653 md5_uint32 B_save = B; 654 md5_uint32 C_save = C; 655 md5_uint32 D_save = D; 656 657 /* First round: using the given function, the context and a constant 658 the next context is computed. Because the algorithms processing 659 unit is a 32-bit word and it is determined to work on words in 660 little endian byte order we perhaps have to change the byte order 661 before the computation. To reduce the work for the next steps 662 we store the swapped words in the array CORRECT_WORDS. */ 663 664 #define OP(a, b, c, d, s, T) \ 665 do \ 666 { \ 667 a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ 668 ++words; \ 669 CYCLIC (a, s); \ 670 a += b; \ 671 } \ 672 while (0) 673 674 /* It is unfortunate that C does not provide an operator for 675 cyclic rotation. Hope the C compiler is smart enough. */ 676 #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) 677 678 /* Before we start, one word to the strange constants. 679 They are defined in RFC 1321 as 680 681 T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 682 */ 683 684 /* Round 1. */ 685 OP(A, B, C, D, 7, 0xd76aa478); 686 OP(D, A, B, C, 12, 0xe8c7b756); 687 OP(C, D, A, B, 17, 0x242070db); 688 OP(B, C, D, A, 22, 0xc1bdceee); 689 OP(A, B, C, D, 7, 0xf57c0faf); 690 OP(D, A, B, C, 12, 0x4787c62a); 691 OP(C, D, A, B, 17, 0xa8304613); 692 OP(B, C, D, A, 22, 0xfd469501); 693 OP(A, B, C, D, 7, 0x698098d8); 694 OP(D, A, B, C, 12, 0x8b44f7af); 695 OP(C, D, A, B, 17, 0xffff5bb1); 696 OP(B, C, D, A, 22, 0x895cd7be); 697 OP(A, B, C, D, 7, 0x6b901122); 698 OP(D, A, B, C, 12, 0xfd987193); 699 OP(C, D, A, B, 17, 0xa679438e); 700 OP(B, C, D, A, 22, 0x49b40821); 701 /* For the second to fourth round we have the possibly swapped words 702 in CORRECT_WORDS. Redefine the macro to take an additional first 703 argument specifying the function to use. */ 704 #undef OP 705 #define OP(f, a, b, c, d, k, s, T) \ 706 do \ 707 { \ 708 a += f (b, c, d) + correct_words[k] + T; \ 709 CYCLIC (a, s); \ 710 a += b; \ 711 } \ 712 while (0) 713 714 /* Round 2. */ 715 OP(FG, A, B, C, D, 1, 5, 0xf61e2562); 716 OP(FG, D, A, B, C, 6, 9, 0xc040b340); 717 OP(FG, C, D, A, B, 11, 14, 0x265e5a51); 718 OP(FG, B, C, D, A, 0, 20, 0xe9b6c7aa); 719 OP(FG, A, B, C, D, 5, 5, 0xd62f105d); 720 OP(FG, D, A, B, C, 10, 9, 0x02441453); 721 OP(FG, C, D, A, B, 15, 14, 0xd8a1e681); 722 OP(FG, B, C, D, A, 4, 20, 0xe7d3fbc8); 723 OP(FG, A, B, C, D, 9, 5, 0x21e1cde6); 724 OP(FG, D, A, B, C, 14, 9, 0xc33707d6); 725 OP(FG, C, D, A, B, 3, 14, 0xf4d50d87); 726 OP(FG, B, C, D, A, 8, 20, 0x455a14ed); 727 OP(FG, A, B, C, D, 13, 5, 0xa9e3e905); 728 OP(FG, D, A, B, C, 2, 9, 0xfcefa3f8); 729 OP(FG, C, D, A, B, 7, 14, 0x676f02d9); 730 OP(FG, B, C, D, A, 12, 20, 0x8d2a4c8a); 731 732 /* Round 3. */ 733 OP(FH, A, B, C, D, 5, 4, 0xfffa3942); 734 OP(FH, D, A, B, C, 8, 11, 0x8771f681); 735 OP(FH, C, D, A, B, 11, 16, 0x6d9d6122); 736 OP(FH, B, C, D, A, 14, 23, 0xfde5380c); 737 OP(FH, A, B, C, D, 1, 4, 0xa4beea44); 738 OP(FH, D, A, B, C, 4, 11, 0x4bdecfa9); 739 OP(FH, C, D, A, B, 7, 16, 0xf6bb4b60); 740 OP(FH, B, C, D, A, 10, 23, 0xbebfbc70); 741 OP(FH, A, B, C, D, 13, 4, 0x289b7ec6); 742 OP(FH, D, A, B, C, 0, 11, 0xeaa127fa); 743 OP(FH, C, D, A, B, 3, 16, 0xd4ef3085); 744 OP(FH, B, C, D, A, 6, 23, 0x04881d05); 745 OP(FH, A, B, C, D, 9, 4, 0xd9d4d039); 746 OP(FH, D, A, B, C, 12, 11, 0xe6db99e5); 747 OP(FH, C, D, A, B, 15, 16, 0x1fa27cf8); 748 OP(FH, B, C, D, A, 2, 23, 0xc4ac5665); 749 750 /* Round 4. */ 751 OP(FI, A, B, C, D, 0, 6, 0xf4292244); 752 OP(FI, D, A, B, C, 7, 10, 0x432aff97); 753 OP(FI, C, D, A, B, 14, 15, 0xab9423a7); 754 OP(FI, B, C, D, A, 5, 21, 0xfc93a039); 755 OP(FI, A, B, C, D, 12, 6, 0x655b59c3); 756 OP(FI, D, A, B, C, 3, 10, 0x8f0ccc92); 757 OP(FI, C, D, A, B, 10, 15, 0xffeff47d); 758 OP(FI, B, C, D, A, 1, 21, 0x85845dd1); 759 OP(FI, A, B, C, D, 8, 6, 0x6fa87e4f); 760 OP(FI, D, A, B, C, 15, 10, 0xfe2ce6e0); 761 OP(FI, C, D, A, B, 6, 15, 0xa3014314); 762 OP(FI, B, C, D, A, 13, 21, 0x4e0811a1); 763 OP(FI, A, B, C, D, 4, 6, 0xf7537e82); 764 OP(FI, D, A, B, C, 11, 10, 0xbd3af235); 765 OP(FI, C, D, A, B, 2, 15, 0x2ad7d2bb); 766 OP(FI, B, C, D, A, 9, 21, 0xeb86d391); 767 768 /* Add the starting values of the context. */ 769 A += A_save; 770 B += B_save; 771 C += C_save; 772 D += D_save; 773 } 774 775 /* Put checksum in context given as argument. */ 776 ctx->A = A; 777 ctx->B = B; 778 ctx->C = C; 779 ctx->D = D; 780 } 781 782 783 /*---------------------------------------------------------------------------- 784 *--------end of md5.c 785 *----------------------------------------------------------------------------*/ 435 786 436 787 … … 438 789 { 439 790 unsigned int i; 440 memcpy(p->h, md5hinit, 16); 791 792 md5_init_ctx(p); 441 793 442 794 for (i = 0; i < 16; i += 8) 443 795 { 444 p-> data[i] = 0x00;445 p-> data[i+1] = 0x00;446 p-> data[i+2] = 0x00;447 p-> data[i+3] = 0x00;448 p-> data[i+4] = 0x00;449 p-> data[i+5] = 0x00;450 p-> data[i+6] = 0x00;451 p-> data[i+7] = 0x00;796 p->buffer[i] = 0x00; 797 p->buffer[i+1] = 0x00; 798 p->buffer[i+2] = 0x00; 799 p->buffer[i+3] = 0x00; 800 p->buffer[i+4] = 0x00; 801 p->buffer[i+5] = 0x00; 802 p->buffer[i+6] = 0x00; 803 p->buffer[i+7] = 0x00; 452 804 } 453 805 454 /* memset(p->data, 0x00, 64); */455 p->offset = (uint8) 0;456 p->nblocks = 0;457 806 return 0; 458 807 } 459 808 460 #if defined(__GNUC__) && defined(__i386__)461 static inline UINT32462 ROTL32( UINT32 x, int s)463 {464 __asm__("roll %%cl,%0"465 :"=r" (x)466 :"0" (x),"c" (s));467 return x;468 }469 #else470 #define ROTL32(x, s) (((x) << (s)) | ((x) >> (32 - (s))))471 #endif472 473 474 #define FF(a, b, c, d, w, s, t) \475 a += ((b&(c^d))^d) + w + t; \476 a = ROTL32(a, s); \477 a += b;478 479 #define GG(a, b, c, d, w, s, t) \480 a += ((d&(b^c))^c) + w + t; \481 a = ROTL32(a, s); \482 a += b;483 484 #define HH(a, b, c, d, w, s, t) \485 a += (b^c^d) + w + t; \486 a = ROTL32(a, s); \487 a += b;488 489 #define II(a, b, c, d, w, s, t) \490 a += (c^(b|~d)) + w + t; \491 a = ROTL32(a, s); \492 a += b;493 494 #if WORDS_BIGENDIAN495 uint32 swapu32(uint32 n)496 {497 return ( ((n & 0xffU) << 24) |498 ((n & 0xff00U) << 8) |499 ((n & 0xff0000U) >> 8) |500 ((n & 0xff000000U) >> 24) );501 }502 #endif503 504 static505 void md5Process(md5Param* p)506 {507 register uint32 a,b,c,d;508 register uint32* w;509 #if WORDS_BIGENDIAN510 register sh_byte t;511 #endif512 513 w = p->data;514 #if WORDS_BIGENDIAN515 t = 16;516 while (t--)517 {518 register uint32 temp = swapu32(*w);519 *(w++) = temp;520 }521 w = p->data;522 #endif523 524 a = p->h[0]; b = p->h[1]; c = p->h[2]; d = p->h[3];525 526 FF(a, b, c, d, (*w++), 7, 0xd76aa478);527 FF(d, a, b, c, (*w++), 12, 0xe8c7b756);528 FF(c, d, a, b, (*w++), 17, 0x242070db);529 FF(b, c, d, a, (*w++), 22, 0xc1bdceee);530 FF(a, b, c, d, (*w++), 7, 0xf57c0faf);531 FF(d, a, b, c, (*w++), 12, 0x4787c62a);532 FF(c, d, a, b, (*w++), 17, 0xa8304613);533 FF(b, c, d, a, (*w++), 22, 0xfd469501);534 FF(a, b, c, d, (*w++), 7, 0x698098d8);535 FF(d, a, b, c, (*w++), 12, 0x8b44f7af);536 FF(c, d, a, b, (*w++), 17, 0xffff5bb1);537 FF(b, c, d, a, (*w++), 22, 0x895cd7be);538 FF(a, b, c, d, (*w++), 7, 0x6b901122);539 FF(d, a, b, c, (*w++), 12, 0xfd987193);540 FF(c, d, a, b, (*w++), 17, 0xa679438e);541 FF(b, c, d, a, (*w++), 22, 0x49b40821);542 543 w = p->data;544 545 GG(a, b, c, d, w[ 1], 5, 0xf61e2562);546 GG(d, a, b, c, w[ 6], 9, 0xc040b340);547 GG(c, d, a, b, w[11], 14, 0x265e5a51);548 GG(b, c, d, a, w[ 0], 20, 0xe9b6c7aa);549 GG(a, b, c, d, w[ 5], 5, 0xd62f105d);550 GG(d, a, b, c, w[10], 9, 0x02441453);551 GG(c, d, a, b, w[15], 14, 0xd8a1e681);552 GG(b, c, d, a, w[ 4], 20, 0xe7d3fbc8);553 GG(a, b, c, d, w[ 9], 5, 0x21e1cde6);554 GG(d, a, b, c, w[14], 9, 0xc33707d6);555 GG(c, d, a, b, w[ 3], 14, 0xf4d50d87);556 GG(b, c, d, a, w[ 8], 20, 0x455a14ed);557 GG(a, b, c, d, w[13], 5, 0xa9e3e905);558 GG(d, a, b, c, w[ 2], 9, 0xfcefa3f8);559 GG(c, d, a, b, w[ 7], 14, 0x676f02d9);560 GG(b, c, d, a, w[12], 20, 0x8d2a4c8a);561 562 HH(a, b, c, d, w[ 5], 4, 0xfffa3942);563 HH(d, a, b, c, w[ 8], 11, 0x8771f681);564 HH(c, d, a, b, w[11], 16, 0x6d9d6122);565 HH(b, c, d, a, w[14], 23, 0xfde5380c);566 HH(a, b, c, d, w[ 1], 4, 0xa4beea44);567 HH(d, a, b, c, w[ 4], 11, 0x4bdecfa9);568 HH(c, d, a, b, w[ 7], 16, 0xf6bb4b60);569 HH(b, c, d, a, w[10], 23, 0xbebfbc70);570 HH(a, b, c, d, w[13], 4, 0x289b7ec6);571 HH(d, a, b, c, w[ 0], 11, 0xeaa127fa);572 HH(c, d, a, b, w[ 3], 16, 0xd4ef3085);573 HH(b, c, d, a, w[ 6], 23, 0x04881d05);574 HH(a, b, c, d, w[ 9], 4, 0xd9d4d039);575 HH(d, a, b, c, w[12], 11, 0xe6db99e5);576 HH(c, d, a, b, w[15], 16, 0x1fa27cf8);577 HH(b, c, d, a, w[ 2], 23, 0xc4ac5665);578 579 II(a, b, c, d, w[ 0], 6, 0xf4292244);580 II(d, a, b, c, w[ 7], 10, 0x432aff97);581 II(c, d, a, b, w[14], 15, 0xab9423a7);582 II(b, c, d, a, w[ 5], 21, 0xfc93a039);583 II(a, b, c, d, w[12], 6, 0x655b59c3);584 II(d, a, b, c, w[ 3], 10, 0x8f0ccc92);585 II(c, d, a, b, w[10], 15, 0xffeff47d);586 II(b, c, d, a, w[ 1], 21, 0x85845dd1);587 II(a, b, c, d, w[ 8], 6, 0x6fa87e4f);588 II(d, a, b, c, w[15], 10, 0xfe2ce6e0);589 II(c, d, a, b, w[ 6], 15, 0xa3014314);590 II(b, c, d, a, w[13], 21, 0x4e0811a1);591 II(a, b, c, d, w[ 4], 6, 0xf7537e82);592 II(d, a, b, c, w[11], 10, 0xbd3af235);593 II(c, d, a, b, w[ 2], 15, 0x2ad7d2bb);594 II(b, c, d, a, w[ 9], 21, 0xeb86d391);595 596 p->h[0] += a;597 p->h[1] += b;598 p->h[2] += c;599 p->h[3] += d;600 }601 602 809 int md5Update(md5Param* p, const sh_byte* data, int size) 603 810 { 604 register int proclength; 605 606 while (size > 0) 607 { 608 proclength = (((int)p->offset + size) > 64) ? 609 (64 - (int)p->offset) : size; 610 memcpy(((sh_byte *) p->data) + p->offset, data, (size_t) proclength); 611 size -= proclength; 612 data += proclength; 613 p->offset += proclength; 614 615 if (p->offset == (uint8) 64) 616 { 617 md5Process(p); 618 p->offset = (uint8) 0; 619 p->nblocks++; 620 } 621 } 622 return 0; 623 } 624 625 static void md5Finish(md5Param* p) 626 { 627 uint32 t, msb, lsb; 628 uint8 * pp; 629 register uint8 *ptr; 630 631 msb = 0; 632 t = p->nblocks; 633 if( (lsb = t << 6) < t ) /* multiply by 64 to make a byte count */ 634 msb++; 635 msb += t >> 26; 636 t = lsb; 637 if( (lsb = t + (uint32)p->offset) < t ) /* add the count */ 638 msb++; 639 t = lsb; 640 if( (lsb = t << 3) < t ) /* multiply by 8 to make a bit count */ 641 msb++; 642 msb += t >> 29; 643 644 ptr = ((uint8 *) p->data) + p->offset++; 645 646 647 *(ptr++) = (uint8) 0x80; 648 649 if (p->offset > (uint8)56) 650 { 651 while (p->offset++ < 64) 652 *(ptr++) = 0; 653 654 md5Process(p); 655 p->offset = 0; 656 } 657 658 ptr = ((uint8 *) p->data) + p->offset; 659 while (p->offset++ < 56) 660 *(ptr++) = 0; 661 662 /* append the 64 bit count */ 663 *(ptr++) = lsb ; 664 *(ptr++) = lsb >> 8; 665 *(ptr++) = lsb >> 16; 666 *(ptr++) = lsb >> 24; 667 *(ptr++) = msb ; 668 *(ptr++) = msb >> 8; 669 *(ptr++) = msb >> 16; 670 *(ptr++) = msb >> 24; 671 672 md5Process(p); 673 674 pp = (uint8 *) p->data; 675 #ifdef WORDS_BIGENDIAN 676 #define X(a) do { *pp++ = (*p).a; *pp++ = (*p).a >> 8; \ 677 *pp++ = (*p).a >> 16; *pp++ = (*p).a >> 24; } while(0) 678 #else /* little endian */ 679 /*#define X(a) do { *(uint32*)p = p->##a ; p += 4; } while(0)*/ 680 /* Unixware's cpp doesn't like the above construct so we do it his way: 681 * (reported by Allan Clark) */ 682 #define X(a) do { *(uint32*)pp = (*p).a ; pp += 4; } while(0) 683 #endif 684 X(h[0]); 685 X(h[1]); 686 X(h[2]); 687 X(h[3]); 688 #undef X 689 690 p->offset = 0; 691 } 692 693 int md5Digest(md5Param* p, uint32* data) 694 { 695 md5Finish(p); 696 memcpy(data, p->h, 16); 811 md5_process_bytes(data, size, p); 812 return 0; 813 } 814 815 static void md5Finish(md5Param* p, void *resblock) 816 { 817 (void) md5_finish_ctx(p, resblock); 818 } 819 820 int md5Digest(md5Param* p, md5_uint32* data) 821 { 822 md5Finish(p, data); 697 823 (void) md5Reset(p); 698 824 return 0; 699 825 } 700 826 /*@+type@*/ 827 701 828 702 829 /* Compute MD5 message digest for bytes read from STREAM. The … … 708 835 /* Important: BLOCKSIZE must be a multiple of 64. */ 709 836 static const int BLOCKSIZE = 8192; 710 md5Paramctx;837 struct md5_ctx ctx; 711 838 char buffer[8264]; /* BLOCKSIZE + 72 AIX compiler chokes */ 712 off_t sum = 0; 839 size_t sum; 840 713 841 SL_TICKET fd; 714 842 char * tmp; … … 797 925 BLOCKSIZE % 64 == 0 798 926 */ 799 (void) md5Update(&ctx, (sh_byte*) buffer, BLOCKSIZE);927 md5_process_block(buffer, BLOCKSIZE, &ctx); 800 928 sh.statistics.bytes_hashed += BLOCKSIZE; 801 929 … … 816 944 if (sum > 0) 817 945 { 818 (void) md5Update(&ctx, (sh_byte*) buffer, (int) sum);946 md5_process_bytes(buffer, sum, &ctx); 819 947 sh.statistics.bytes_hashed += BLOCKSIZE; 820 948 } -
trunk/src/sh_tools.c
r27 r30 127 127 unsigned char c, d; 128 128 const char * p; 129 char *q;130 129 char tmp[4]; 131 130 char * outstr; … … 147 146 148 147 p = instr; 149 q = outstr;150 148 151 149 #if !defined(SH_USE_XML) -
trunk/src/sh_unix.c
r29 r30 429 429 } 430 430 431 intsafe_fatal (int signal, int method, char * details,431 void safe_fatal (int signal, int method, char * details, 432 432 char * file, int line) 433 433 { -
trunk/src/sh_utmp.c
r1 r30 331 331 { 332 332 SL_ENTER(_("sh_utmp_endutent")); 333 (void) fclose(sh_utmpfile); 333 if (NULL != sh_utmpfile) 334 (void) fclose(sh_utmpfile); 334 335 sh_utmpfile = NULL; 335 336 SL_RET0(_("sh_utmp_endutent"));
Note:
See TracChangeset
for help on using the changeset viewer.