Changeset 4674:360407693181 in roaraudio


Ignore:
Timestamp:
12/20/10 19:51:22 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

support to salt nonce

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/random.h

    r4672 r4674  
    4848int roar_random_gen_nonce(void * buffer, size_t len); 
    4949 
     50int roar_random_salt_nonce (void * salt, size_t len); 
     51 
    5052int roar_random_gen(void * buffer, size_t len, int quality); 
    5153 
  • libroar/random.c

    r4673 r4674  
    5555#define TIGER_DIGESTLEN (3*8) 
    5656 
     57static size_t roar_nonce_salt_len = 0; 
     58static void * roar_nonce_salt     = NULL; 
     59 
    5760int roar_random_gen_nonce(void * buffer, size_t len) { 
    5861 static uint32_t buf[14]; 
     
    101104  } 
    102105 
    103   roar_hash_buffer(off, buf, TIGER_BLOCKLEN, ROAR_HT_TIGER); 
     106  roar_hash_salted_buffer(off, buf, TIGER_BLOCKLEN, ROAR_HT_TIGER, roar_nonce_salt, roar_nonce_salt_len); 
    104107 
    105108  writelen = len >= TIGER_DIGESTLEN ? TIGER_DIGESTLEN : len; 
     
    111114 
    112115 return 0; 
     116} 
     117 
     118int roar_random_salt_nonce (void * salt, size_t len) { 
     119 char buf[1]; 
     120 int ret; 
     121 
     122 roar_nonce_salt     = salt; 
     123 roar_nonce_salt_len = len; 
     124 
     125 ret = roar_random_gen_nonce(buf, sizeof(buf)); 
     126 
     127 roar_nonce_salt     = NULL; 
     128 roar_nonce_salt_len = 0; 
     129 
     130 return ret; 
    113131} 
    114132 
Note: See TracChangeset for help on using the changeset viewer.