Changeset 11 for trunk/src/sh_utils.c


Ignore:
Timestamp:
Jan 2, 2006, 12:03:25 AM (14 years ago)
Author:
rainer
Message:

Minor optimisations for server

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_utils.c

    r1 r11  
    527527    (char)0x36, (char)0x36, (char)0x36, (char)0x36, (char)0x36, (char)0x36
    528528  };
     529  static char  zap[KEY_BLOCK] = {
     530    (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 
     531    (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 
     532    (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, 
     533    (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00, (char)0x00
     534  };
    529535  char        K[KEY_BLOCK];
    530536  char        outer[KEY_BLOCK];
     
    546552    }
    547553
    548   memset (K, 0x00, KEY_BLOCK);
     554  memcpy (K, zap, KEY_BLOCK);
    549555
    550556  if (sh_util_hextobinary (K, hexkey, KEY_LEN) < 0)
     
    773779 * input for a one-way hash function.
    774780 */
     781UINT32   taus_svec[6];
     782
    775783UINT32 taus_get (void *state1, void *state2, void *state3)
    776784{
    777   UINT32   svec[6];
    778785  UINT32   retval;
    779786  UINT32 * res;
    780787  register int i;
    781788
    782   svec[0] = taus_get_long (state1);
    783   svec[1] = taus_get_long (state2);
    784   svec[2] = taus_get_long (state3);
    785   svec[3] = taus_get_long (state1);
    786   svec[4] = taus_get_long (state2);
    787   svec[5] = taus_get_long (state3);
    788 
    789   res     = sh_tiger_hash_uint32 ( (char *) &svec[0],
     789  taus_svec[0] = taus_get_long (state1);
     790  taus_svec[1] = taus_get_long (state2);
     791  taus_svec[2] = taus_get_long (state3);
     792  taus_svec[3] = taus_get_long (state1);
     793  taus_svec[4] = taus_get_long (state2);
     794  taus_svec[5] = taus_get_long (state3);
     795
     796  res     = sh_tiger_hash_uint32 ( (char *) &taus_svec[0],
    790797                                   TIGER_DATA,
    791798                                   (unsigned long)(6 * sizeof(UINT32)));
    792799
    793800  for (i = 1; i < KEY_BYT/4; ++i)
    794     res[0] ^= res[i];
     801    {
     802      res[0] ^= res[i];
     803      res[i]  = 0;
     804    }
    795805  retval = res[0];
    796806
    797   memset (res,  0,            KEY_BYT);
    798   memset (svec, 0, 6 * sizeof(UINT32));
     807  taus_svec[0] = 0; taus_svec[1] = 0; taus_svec[2] = 0;
     808  taus_svec[3] = 0; taus_svec[4] = 0; taus_svec[5] = 0;
    799809
    800810  return retval;
Note: See TracChangeset for help on using the changeset viewer.