Changeset 9131 in project


Ignore:
Timestamp:
02/29/08 17:47:11 (11 years ago)
Author:
kon
Message:

Cosmetic chg for the sake of chg.

Location:
release/3/tiger-hash
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/3/tiger-hash/tags/1.2/tiger-hash.scm

    r8961 r9131  
    1919#include <stdlib.h>
    2020
    21 /* Chicken.h includes one of these but be specific */
    22 #ifdef HAVE_STDINT_H
    23 # include <stdint.h>
    24 #else
    25 # 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 #endif
    31 
    32 #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN
    33 # define HASHES_BIG_ENDIAN
    34 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
    35 # define HASHES_BIG_ENDIAN
    36 #elif defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel)
    37 # define HASHES_BIG_ENDIAN
    38 #endif
    39 
    4021/* Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996. */
    4122
    4223/* sboxes.c: Tiger S boxes */
    43 static
    44 uint64_t table[4*256] = {
     24static uint64_t
     25table[4*256] = {
    4526    0x02AAB17CF7E90C5ELL   /*    0 */,    0xAC424B03E243A8ECLL   /*    1 */,
    4627    0x72CD5BE30DD5FCD3LL   /*    2 */,    0x6D019B93F6F97F3ALL   /*    3 */,
     
    692673
    693674/* The compress function is a function. Requires smaller cache?    */
    694 static
    695 void tiger_compress(uint64_t *str, uint64_t state[3])
     675static void
     676tiger_compress( uint64_t *str, uint64_t state[3] )
    696677{
    697   tiger_compress_macro(((uint64_t*)str), ((uint64_t*)state));
     678  tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state) );
    698679}
    699680
     
    703684/* module calls it directly.                                       */
    704685#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) )
    706687#endif
    707688
     
    713694} tigerctx;
    714695
    715 static
    716 void tiger_init (tigerctx *ctx)
     696static void
     697tiger_init( tigerctx *ctx )
    717698{
    718699  ctx->state[0] = 0x0123456789ABCDEFLL;
     
    723704}
    724705
    725 static
    726 void tiger_update (tigerctx *ctx, uint8_t *str, uint32_t length)
     706static void
     707tiger_update( tigerctx *ctx, uint8_t *str, uint32_t length )
    727708{
    728709  register uint32_t i, j;
     
    734715  for (i = length; i >= 64; i-=64)
    735716    {
    736 #ifdef HASHES_BIG_ENDIAN
     717#ifdef C_BIG_ENDIAN
    737718      for (j = 0; j < 64; j++)
    738719        temp[j^7] = str[j];
     
    742723#endif
    743724      tiger_compress (dat, ctx->state);
    744       str += 8 * sizeof(uint64_t);
     725      str += 8 * sizeof( uint64_t );
    745726    }
    746727
    747728  if (i) {
    748     memcpy (ctx->rembuf, str, i);
     729    memcpy( ctx->rembuf, str, i );
    749730    ctx->remlen = i;
    750731    ctx->len -= i;
     
    752733}
    753734
    754 static
    755 void tiger_final (tigerctx *ctx, uint8_t *result)
     735static void
     736tiger_final( tigerctx *ctx, uint8_t *result )
    756737{
    757738  register uint32_t i, j;
     
    759740  uint64_t *dat;
    760741
    761 #ifdef HASHES_BIG_ENDIAN
     742#ifdef C_BIG_ENDIAN
    762743  for (j = 0; j < ctx->remlen; j++)
    763744    temp[j^7] = ctx->rembuf[j];
     
    779760      for (; j < 64; j++)
    780761        temp[j] = 0;
    781       tiger_compress (((uint64_t*)temp), ctx->state);
     762      tiger_compress( ((uint64_t*)temp), ctx->state );
    782763      j=0;
    783764    }
     
    788769    temp[j] = 0;
    789770  ((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 );
    791772
    792773#if 1
    793 # ifdef HASHES_BIG_ENDIAN
     774# ifdef C_BIG_ENDIAN
    794775# define U32_COPY(str, wrd)\
    795776    do {\
     
    801782    } while (0)
    802783  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] );
    805786  }
    806787# else
     
    814795    } while (0)
    815796  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 );
    818799  }
    819800# endif
    820801# undef U32_COPY
    821802#else
    822   memcpy (result, ctx->state, sizeof (ctx->state));
     803  memcpy( result, ctx->state, sizeof (ctx->state ));
    823804#endif
    824805}
     
    826807#define TGRctxsiz sizeof(tigerctx)
    827808#define TGRhshlen 3*sizeof(uint64_t)
    828 
    829 #ifdef HASHES_BIG_ENDIAN
    830 # undef HASHES_BIG_ENDIAN
    831 #endif
    832809<#
    833810
  • release/3/tiger-hash/trunk/tiger-hash.scm

    r8961 r9131  
    1919#include <stdlib.h>
    2020
    21 /* Chicken.h includes one of these but be specific */
    22 #ifdef HAVE_STDINT_H
    23 # include <stdint.h>
    24 #else
    25 # 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 #endif
    31 
    32 #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN
    33 # define HASHES_BIG_ENDIAN
    34 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
    35 # define HASHES_BIG_ENDIAN
    36 #elif defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel)
    37 # define HASHES_BIG_ENDIAN
    38 #endif
    39 
    4021/* Tiger - A Fast New Hash Function, by Ross Anderson and Eli Biham, proceedings of Fast Software Encryption 3, Cambridge, 1996. */
    4122
    4223/* sboxes.c: Tiger S boxes */
    43 static
    44 uint64_t table[4*256] = {
     24static uint64_t
     25table[4*256] = {
    4526    0x02AAB17CF7E90C5ELL   /*    0 */,    0xAC424B03E243A8ECLL   /*    1 */,
    4627    0x72CD5BE30DD5FCD3LL   /*    2 */,    0x6D019B93F6F97F3ALL   /*    3 */,
     
    692673
    693674/* The compress function is a function. Requires smaller cache?    */
    694 static
    695 void tiger_compress(uint64_t *str, uint64_t state[3])
     675static void
     676tiger_compress( uint64_t *str, uint64_t state[3] )
    696677{
    697   tiger_compress_macro(((uint64_t*)str), ((uint64_t*)state));
     678  tiger_compress_macro( ((uint64_t*)str), ((uint64_t*)state) );
    698679}
    699680
     
    703684/* module calls it directly.                                       */
    704685#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) )
    706687#endif
    707688
     
    713694} tigerctx;
    714695
    715 static
    716 void tiger_init (tigerctx *ctx)
     696static void
     697tiger_init( tigerctx *ctx )
    717698{
    718699  ctx->state[0] = 0x0123456789ABCDEFLL;
     
    723704}
    724705
    725 static
    726 void tiger_update (tigerctx *ctx, uint8_t *str, uint32_t length)
     706static void
     707tiger_update( tigerctx *ctx, uint8_t *str, uint32_t length )
    727708{
    728709  register uint32_t i, j;
     
    734715  for (i = length; i >= 64; i-=64)
    735716    {
    736 #ifdef HASHES_BIG_ENDIAN
     717#ifdef C_BIG_ENDIAN
    737718      for (j = 0; j < 64; j++)
    738719        temp[j^7] = str[j];
     
    742723#endif
    743724      tiger_compress (dat, ctx->state);
    744       str += 8 * sizeof(uint64_t);
     725      str += 8 * sizeof( uint64_t );
    745726    }
    746727
    747728  if (i) {
    748     memcpy (ctx->rembuf, str, i);
     729    memcpy( ctx->rembuf, str, i );
    749730    ctx->remlen = i;
    750731    ctx->len -= i;
     
    752733}
    753734
    754 static
    755 void tiger_final (tigerctx *ctx, uint8_t *result)
     735static void
     736tiger_final( tigerctx *ctx, uint8_t *result )
    756737{
    757738  register uint32_t i, j;
     
    759740  uint64_t *dat;
    760741
    761 #ifdef HASHES_BIG_ENDIAN
     742#ifdef C_BIG_ENDIAN
    762743  for (j = 0; j < ctx->remlen; j++)
    763744    temp[j^7] = ctx->rembuf[j];
     
    779760      for (; j < 64; j++)
    780761        temp[j] = 0;
    781       tiger_compress (((uint64_t*)temp), ctx->state);
     762      tiger_compress( ((uint64_t*)temp), ctx->state );
    782763      j=0;
    783764    }
     
    788769    temp[j] = 0;
    789770  ((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 );
    791772
    792773#if 1
    793 # ifdef HASHES_BIG_ENDIAN
     774# ifdef C_BIG_ENDIAN
    794775# define U32_COPY(str, wrd)\
    795776    do {\
     
    801782    } while (0)
    802783  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] );
    805786  }
    806787# else
     
    814795    } while (0)
    815796  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 );
    818799  }
    819800# endif
    820801# undef U32_COPY
    821802#else
    822   memcpy (result, ctx->state, sizeof (ctx->state));
     803  memcpy( result, ctx->state, sizeof (ctx->state ));
    823804#endif
    824805}
     
    826807#define TGRctxsiz sizeof(tigerctx)
    827808#define TGRhshlen 3*sizeof(uint64_t)
    828 
    829 #ifdef HASHES_BIG_ENDIAN
    830 # undef HASHES_BIG_ENDIAN
    831 #endif
    832809<#
    833810
Note: See TracChangeset for help on using the changeset viewer.