Changeset 18 for trunk/src/sh_tiger0.c


Ignore:
Timestamp:
Jan 28, 2006, 9:07:52 PM (19 years ago)
Author:
rainer
Message:

Optimized version of tiger algorithm, and basic ingredients for unit testing (part 2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_tiger0.c

    r11 r18  
    2525#include "sh_utils.h"
    2626
    27 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
     27#define PRIV_MAX  32768
     28
     29#if defined(TIGER_64_BIT)
    2830#if defined(HAVE_LONG_64)
    2931typedef unsigned long int word64;
     32#elif defined(HAVE_LONG_LONG_64)
     33typedef unsigned long long int word64;
    3034#else
    31 typedef unsigned long long int word64;
     35#error No 64 bit type found !
    3236#endif
    3337#endif
     
    4650#define GPGFORMAT (_("%08X %08X %08X  %08X %08X %08X"))
    4751#else
    48 #error No 32 byte type found !
     52#error No 32 bit type found !
    4953#endif
    5054
     
    5458#define FIL__  _("sh_tiger0.c")
    5559
    56 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    57 /* #ifdef HAVE_LONG_64 */
     60#if defined(TIGER_64_BIT)
     61
    5862void tiger_t(word64 *str, word64 length, word64 * res);
    5963void tiger(word64 *str, word64 length, word64 * res);
     
    97101static sh_byte buffer[PRIV_MAX + 72];
    98102
    99 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    100 /* #ifdef HAVE_LONG_64 */
     103#if defined(TIGER_64_BIT)
    101104static
    102105word64 * sh_tiger_hash_val (char * filename, TigerType what,
     
    114117  char    * tmp;
    115118  sh_byte * bptr;
    116   /* sh_byte buffer[PRIV_MAX + 72]; */
    117119  sh_byte bbuf[64];
    118120
     
    131133#endif
    132134
    133 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    134   /* #ifdef HAVE_LONG_64 */
     135#if defined(TIGER_64_BIT)
    135136#define TIGER_CAST (word64*)
    136137  static word64 res[3];
     
    254255          }
    255256       
    256         if (blk < 64) /* this must be (PRIV_MAX / 64) */
     257        if (blk < (PRIV_MAX / 64)) /* this must be (PRIV_MAX / 64) */
    257258          break;
    258259
     
    359360    bptr = buffer;
    360361
    361     memcpy(bptr, bbuf,    64); bptr +=   64;
    362     memcpy(bptr, bbuf,    64); bptr +=   64;
    363     memcpy(bptr, buffer, 128); bptr +=  128;
    364     memcpy(bptr, buffer, 256); bptr +=  256;
    365     memcpy(bptr, buffer, 512); bptr +=  512;
    366     memcpy(bptr, buffer,1024); bptr += 1024;
    367     memcpy(bptr, buffer,2048);
     362    memcpy(bptr, bbuf,     64); bptr +=    64;
     363    memcpy(bptr, bbuf,     64); bptr +=    64;
     364    memcpy(bptr, buffer,  128); bptr +=   128;
     365    memcpy(bptr, buffer,  256); bptr +=   256;
     366    memcpy(bptr, buffer,  512); bptr +=   512;
     367    memcpy(bptr, buffer, 1024); bptr +=  1024;
     368    memcpy(bptr, buffer, 2048); bptr +=  2048;
     369    memcpy(bptr, buffer, 4096); bptr +=  4096;
     370    memcpy(bptr, buffer, 8192); bptr +=  8192;
     371    memcpy(bptr, buffer,16384);
    368372
    369373    if (what == TIGER_FILE)
     
    814818                       MSG_E_SUBGEN, _("Not TIGER_FD"),
    815819                       _("sh_tiger_md5_hash"));
     820      out[0] = '\0';
    816821      return out;
    817822    }
     
    13281333                       MSG_E_SUBGEN, _("Not TIGER_FD"),
    13291334                       _("sh_tiger_sha1_hash"));
     1335      out[0] = '\0';
    13301336      return out;
    13311337    }
     
    14101416                                      unsigned long Length, int timeout)
    14111417{
    1412 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1413   /* #ifdef HAVE_LONG_64 */
     1418#if defined(TIGER_64_BIT)
    14141419  word64 * res;
    14151420#else
     
    14251430    {
    14261431      /*@-bufferoverflowhigh -formatconst@*/
    1427 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1428       /* #ifdef HAVE_LONG_64 */
     1432#if defined(TIGER_64_BIT)
    14291433      sprintf(out,                                   /* known to fit  */
    14301434              MYFORMAT,
     
    14611465  char * out;
    14621466  char   outhash[48+6+1];
    1463 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1464   /* #ifdef HAVE_LONG_64 */
     1467#if defined(TIGER_64_BIT)
    14651468  word64 * res;
    14661469#else
     
    14741477    {
    14751478      /*@-bufferoverflowhigh -formatconst@*/
    1476 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1477       /* #ifdef HAVE_LONG_64 */
     1479#if defined(TIGER_64_BIT)
    14781480      sprintf(outhash,                               /* known to fit  */
    14791481              GPGFORMAT,
     
    15301532                               unsigned long Length)
    15311533{
    1532 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1533   /* #ifdef HAVE_LONG_64 */
     1534#if defined(TIGER_64_BIT)
    15341535  word64 * res;
    15351536#else
     
    15481549  if (res != NULL)
    15491550    {
    1550 #if defined(HAVE_LONG_64) || defined(HAVE_LONG_LONG_64)
    1551       /* #ifdef HAVE_LONG_64 */
     1551#if defined(TIGER_64_BIT)
    15521552        out[0] =  (UINT32)(res[0]>>32);
    15531553        out[1] =  (UINT32)(res[0]);
Note: See TracChangeset for help on using the changeset viewer.