Changeset 5530:9aa578adc5bd in roaraudio


Ignore:
Timestamp:
06/12/12 09:26:41 (7 years ago)
Author:
phi
Branch:
default
Message:

strengthened hash support against memory analyzing attacks

Location:
libroar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libroar/hash.c

    r5529 r5530  
    372372  ret = state->cmds->uninit(state->state); 
    373373 
     374 // clear crypto data. 
     375 memset(state->state, 0, state->cmds->statelen); 
     376 memset(state, 0, sizeof(struct roar_hash_state)); 
     377 
    374378 roar_mm_free(state->state); 
    375379 roar_mm_free(state); 
  • libroar/hash_sha1.c

    r5529 r5530  
    133133 roar_hash_sha1_proc(state, &count, 8); 
    134134 
    135  context->is_final = 1; 
    136135 
    137136 for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { 
     
    140139 
    141140 memset(context, 0, sizeof(struct roar_hash_sha1)); 
     141 context->is_final = 1; 
    142142 
    143143 return 0; 
  • libroar/hash_tiger.c

    r5381 r5530  
    725725 
    726726static void tiger_round( uint64_t * ra, uint64_t * rb, uint64_t * rc, uint64_t x, uint64_t mul) { 
    727   uint64_t a = *ra; 
    728   uint64_t b = *rb; 
    729   uint64_t c = *rc; 
    730  
    731   c ^= x; 
    732   a -= (  sbox1[  c        & 0xff ] ^ sbox2[ (c >> 16) & 0xff ] 
    733         ^ sbox3[ (c >> 32) & 0xff ] ^ sbox4[ (c >> 48) & 0xff ]); 
    734   b += (  sbox4[ (c >>  8) & 0xff ] ^ sbox3[ (c >> 24) & 0xff ] 
    735         ^ sbox2[ (c >> 40) & 0xff ] ^ sbox1[ (c >> 56) & 0xff ]); 
    736   b *= mul; 
    737  
    738   *ra = a; 
    739   *rb = b; 
    740   *rc = c; 
     727 uint64_t a = *ra; 
     728 uint64_t b = *rb; 
     729 uint64_t c = *rc; 
     730 
     731 c ^= x; 
     732 a -= (  sbox1[  c        & 0xff ] ^ sbox2[ (c >> 16) & 0xff ] 
     733       ^ sbox3[ (c >> 32) & 0xff ] ^ sbox4[ (c >> 48) & 0xff ]); 
     734 b += (  sbox4[ (c >>  8) & 0xff ] ^ sbox3[ (c >> 24) & 0xff ] 
     735       ^ sbox2[ (c >> 40) & 0xff ] ^ sbox1[ (c >> 56) & 0xff ]); 
     736 b *= mul; 
     737 
     738 *ra = a; 
     739 *rb = b; 
     740 *rc = c; 
     741 
     742 a = b = c = 0; 
    741743} 
    742744 
     
    824826 state->blocks++; 
    825827 
     828 a = b = c = aa = bb = cc = 0; 
     829 
    826830 ROAR_DBG("roar_hash_tiger_proc_block(state=%p, block=%p) = 0", state, block); 
    827831 return 0; 
Note: See TracChangeset for help on using the changeset viewer.