Changeset 9131 in project
 Timestamp:
 02/29/08 17:47:11 (12 years ago)
 Location:
 release/3/tigerhash
 Files:

 2 edited
 1 copied
Legend:
 Unmodified
 Added
 Removed

release/3/tigerhash/tags/1.2/tigerhash.scm
r8961 r9131 19 19 #include <stdlib.h> 20 20 21 /* Chicken.h includes one of these but be specific */22 #ifdef HAVE_STDINT_H23 # include <stdint.h>24 #else25 # include <sys/types.h>26 typedef u_int8_t uint8_t;27 typedef u_int16_t uint16_t;28 typedef u_int32_t uint32_t;29 typedef u_int64_t uint64_t;30 #endif31 32 #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN33 # define HASHES_BIG_ENDIAN34 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN35 # define HASHES_BIG_ENDIAN36 #elif defined(sparc)  defined(POWERPC)  defined(mc68000)  defined(sel)37 # define HASHES_BIG_ENDIAN38 #endif39 40 21 /* Tiger  A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996. */ 41 22 42 23 /* sboxes.c: Tiger S boxes */ 43 static 44 uint64_ttable[4*256] = {24 static uint64_t 25 table[4*256] = { 45 26 0x02AAB17CF7E90C5ELL /* 0 */, 0xAC424B03E243A8ECLL /* 1 */, 46 27 0x72CD5BE30DD5FCD3LL /* 2 */, 0x6D019B93F6F97F3ALL /* 3 */, … … 692 673 693 674 /* The compress function is a function. Requires smaller cache? */ 694 static 695 void tiger_compress(uint64_t *str, uint64_t state[3])675 static void 676 tiger_compress( uint64_t *str, uint64_t state[3] ) 696 677 { 697 tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state));678 tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state) ); 698 679 } 699 680 … … 703 684 /* module calls it directly. */ 704 685 #define tiger_compress(str, state) \ 705 tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state))686 tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state) ) 706 687 #endif 707 688 … … 713 694 } tigerctx; 714 695 715 static 716 void tiger_init (tigerctx *ctx)696 static void 697 tiger_init( tigerctx *ctx ) 717 698 { 718 699 ctx>state[0] = 0x0123456789ABCDEFLL; … … 723 704 } 724 705 725 static 726 void tiger_update (tigerctx *ctx, uint8_t *str, uint32_t length)706 static void 707 tiger_update( tigerctx *ctx, uint8_t *str, uint32_t length ) 727 708 { 728 709 register uint32_t i, j; … … 734 715 for (i = length; i >= 64; i=64) 735 716 { 736 #ifdef HASHES_BIG_ENDIAN717 #ifdef C_BIG_ENDIAN 737 718 for (j = 0; j < 64; j++) 738 719 temp[j^7] = str[j]; … … 742 723 #endif 743 724 tiger_compress (dat, ctx>state); 744 str += 8 * sizeof( uint64_t);725 str += 8 * sizeof( uint64_t ); 745 726 } 746 727 747 728 if (i) { 748 memcpy (ctx>rembuf, str, i);729 memcpy( ctx>rembuf, str, i ); 749 730 ctx>remlen = i; 750 731 ctx>len = i; … … 752 733 } 753 734 754 static 755 void tiger_final (tigerctx *ctx, uint8_t *result)735 static void 736 tiger_final( tigerctx *ctx, uint8_t *result ) 756 737 { 757 738 register uint32_t i, j; … … 759 740 uint64_t *dat; 760 741 761 #ifdef HASHES_BIG_ENDIAN742 #ifdef C_BIG_ENDIAN 762 743 for (j = 0; j < ctx>remlen; j++) 763 744 temp[j^7] = ctx>rembuf[j]; … … 779 760 for (; j < 64; j++) 780 761 temp[j] = 0; 781 tiger_compress (((uint64_t*)temp), ctx>state);762 tiger_compress( ((uint64_t*)temp), ctx>state ); 782 763 j=0; 783 764 } … … 788 769 temp[j] = 0; 789 770 ((uint64_t*)(&(temp[56])))[0] = ((uint64_t)ctx>len) << 3; 790 tiger_compress (((uint64_t*)temp), ctx>state);771 tiger_compress( ((uint64_t*)temp), ctx>state ); 791 772 792 773 #if 1 793 # ifdef HASHES_BIG_ENDIAN774 # ifdef C_BIG_ENDIAN 794 775 # define U32_COPY(str, wrd)\ 795 776 do {\ … … 801 782 } while (0) 802 783 for (i = 0; i < 3; ++i) { 803 U32_COPY (result, ctx>state[i] >> 32);804 U32_COPY (result, ctx>state[i]);784 U32_COPY( result, ctx>state[i] >> 32 ); 785 U32_COPY( result, ctx>state[i] ); 805 786 } 806 787 # else … … 814 795 } while (0) 815 796 for (i = 0; i < 3; ++i) { 816 U32_COPY (result, ctx>state[i]);817 U32_COPY (result, ctx>state[i] >> 32);797 U32_COPY( result, ctx>state[i] ); 798 U32_COPY( result, ctx>state[i] >> 32 ); 818 799 } 819 800 # endif 820 801 # undef U32_COPY 821 802 #else 822 memcpy (result, ctx>state, sizeof (ctx>state));803 memcpy( result, ctx>state, sizeof (ctx>state )); 823 804 #endif 824 805 } … … 826 807 #define TGRctxsiz sizeof(tigerctx) 827 808 #define TGRhshlen 3*sizeof(uint64_t) 828 829 #ifdef HASHES_BIG_ENDIAN830 # undef HASHES_BIG_ENDIAN831 #endif832 809 <# 833 810 
release/3/tigerhash/trunk/tigerhash.scm
r8961 r9131 19 19 #include <stdlib.h> 20 20 21 /* Chicken.h includes one of these but be specific */22 #ifdef HAVE_STDINT_H23 # include <stdint.h>24 #else25 # include <sys/types.h>26 typedef u_int8_t uint8_t;27 typedef u_int16_t uint16_t;28 typedef u_int32_t uint32_t;29 typedef u_int64_t uint64_t;30 #endif31 32 #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN33 # define HASHES_BIG_ENDIAN34 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN35 # define HASHES_BIG_ENDIAN36 #elif defined(sparc)  defined(POWERPC)  defined(mc68000)  defined(sel)37 # define HASHES_BIG_ENDIAN38 #endif39 40 21 /* Tiger  A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996. */ 41 22 42 23 /* sboxes.c: Tiger S boxes */ 43 static 44 uint64_ttable[4*256] = {24 static uint64_t 25 table[4*256] = { 45 26 0x02AAB17CF7E90C5ELL /* 0 */, 0xAC424B03E243A8ECLL /* 1 */, 46 27 0x72CD5BE30DD5FCD3LL /* 2 */, 0x6D019B93F6F97F3ALL /* 3 */, … … 692 673 693 674 /* The compress function is a function. Requires smaller cache? */ 694 static 695 void tiger_compress(uint64_t *str, uint64_t state[3])675 static void 676 tiger_compress( uint64_t *str, uint64_t state[3] ) 696 677 { 697 tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state));678 tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state) ); 698 679 } 699 680 … … 703 684 /* module calls it directly. */ 704 685 #define tiger_compress(str, state) \ 705 tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state))686 tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state) ) 706 687 #endif 707 688 … … 713 694 } tigerctx; 714 695 715 static 716 void tiger_init (tigerctx *ctx)696 static void 697 tiger_init( tigerctx *ctx ) 717 698 { 718 699 ctx>state[0] = 0x0123456789ABCDEFLL; … … 723 704 } 724 705 725 static 726 void tiger_update (tigerctx *ctx, uint8_t *str, uint32_t length)706 static void 707 tiger_update( tigerctx *ctx, uint8_t *str, uint32_t length ) 727 708 { 728 709 register uint32_t i, j; … … 734 715 for (i = length; i >= 64; i=64) 735 716 { 736 #ifdef HASHES_BIG_ENDIAN717 #ifdef C_BIG_ENDIAN 737 718 for (j = 0; j < 64; j++) 738 719 temp[j^7] = str[j]; … … 742 723 #endif 743 724 tiger_compress (dat, ctx>state); 744 str += 8 * sizeof( uint64_t);725 str += 8 * sizeof( uint64_t ); 745 726 } 746 727 747 728 if (i) { 748 memcpy (ctx>rembuf, str, i);729 memcpy( ctx>rembuf, str, i ); 749 730 ctx>remlen = i; 750 731 ctx>len = i; … … 752 733 } 753 734 754 static 755 void tiger_final (tigerctx *ctx, uint8_t *result)735 static void 736 tiger_final( tigerctx *ctx, uint8_t *result ) 756 737 { 757 738 register uint32_t i, j; … … 759 740 uint64_t *dat; 760 741 761 #ifdef HASHES_BIG_ENDIAN742 #ifdef C_BIG_ENDIAN 762 743 for (j = 0; j < ctx>remlen; j++) 763 744 temp[j^7] = ctx>rembuf[j]; … … 779 760 for (; j < 64; j++) 780 761 temp[j] = 0; 781 tiger_compress (((uint64_t*)temp), ctx>state);762 tiger_compress( ((uint64_t*)temp), ctx>state ); 782 763 j=0; 783 764 } … … 788 769 temp[j] = 0; 789 770 ((uint64_t*)(&(temp[56])))[0] = ((uint64_t)ctx>len) << 3; 790 tiger_compress (((uint64_t*)temp), ctx>state);771 tiger_compress( ((uint64_t*)temp), ctx>state ); 791 772 792 773 #if 1 793 # ifdef HASHES_BIG_ENDIAN774 # ifdef C_BIG_ENDIAN 794 775 # define U32_COPY(str, wrd)\ 795 776 do {\ … … 801 782 } while (0) 802 783 for (i = 0; i < 3; ++i) { 803 U32_COPY (result, ctx>state[i] >> 32);804 U32_COPY (result, ctx>state[i]);784 U32_COPY( result, ctx>state[i] >> 32 ); 785 U32_COPY( result, ctx>state[i] ); 805 786 } 806 787 # else … … 814 795 } while (0) 815 796 for (i = 0; i < 3; ++i) { 816 U32_COPY (result, ctx>state[i]);817 U32_COPY (result, ctx>state[i] >> 32);797 U32_COPY( result, ctx>state[i] ); 798 U32_COPY( result, ctx>state[i] >> 32 ); 818 799 } 819 800 # endif 820 801 # undef U32_COPY 821 802 #else 822 memcpy (result, ctx>state, sizeof (ctx>state));803 memcpy( result, ctx>state, sizeof (ctx>state )); 823 804 #endif 824 805 } … … 826 807 #define TGRctxsiz sizeof(tigerctx) 827 808 #define TGRhshlen 3*sizeof(uint64_t) 828 829 #ifdef HASHES_BIG_ENDIAN830 # undef HASHES_BIG_ENDIAN831 #endif832 809 <# 833 810
Note: See TracChangeset
for help on using the changeset viewer.