Changeset 4671:21813f03d0cc in roaraudio


Ignore:
Timestamp:
12/20/10 00:23:21 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added RFC 2440/4880 CRC24 binding for hashing functions

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/crc.h

    r4585 r4671  
    4242#define roar_crc24_init() roar_crc24_add(0, NULL, 0) 
    4343 
     44int roar_hash_crc24_init(void * state); 
     45int roar_hash_crc24_digest(void * state, void * digest, size_t * len); 
     46int roar_hash_crc24_proc(void * state, const void * data, size_t len); 
     47 
    4448#endif 
    4549 
  • libroar/crc.c

    r4645 r4671  
    5858} 
    5959 
     60int roar_hash_crc24_init(void * state) { 
     61 uint32_t * self = state; 
     62 
     63 *self = roar_crc24_init(); 
     64 
     65 return 0; 
     66} 
     67 
     68int roar_hash_crc24_digest(void * state, void * digest, size_t * len) { 
     69 uint32_t * self = state; 
     70 unsigned char * out  = digest; 
     71 register uint32_t crc; 
     72 
     73 if ( *len < 3 ) 
     74  return -1; 
     75 
     76 *len = 3; 
     77 
     78 crc = *self; 
     79 
     80 out[0] = ((crc & 0x00FF0000) >> 16) & 0xFF; 
     81 out[1] = ((crc & 0x0000FF00) >>  8) & 0xFF; 
     82 out[2] = ((crc & 0x000000FF) >>  0) & 0xFF; 
     83 
     84 return 0; 
     85} 
     86 
     87int roar_hash_crc24_proc(void * state, const void * data, size_t len) { 
     88 uint32_t * self = state; 
     89 
     90 *self = roar_crc24_add(*self, data, len); 
     91 
     92 return 0; 
     93} 
     94 
    6095//ll 
  • libroar/hash.c

    r4670 r4671  
    9898  (int (*)(void *, const void *, size_t))roar_hash_tiger_proc 
    9999 }, 
     100 {ROAR_HT_RFC2440, sizeof(uint32_t), -1, 
     101  roar_hash_crc24_init, NULL, 
     102  roar_hash_crc24_digest, NULL, roar_hash_crc24_proc 
     103 }, 
    100104 {-1, -1, -1, NULL, NULL, NULL, NULL, NULL} 
    101105}; 
     
    290294 struct roar_hash_state * state; 
    291295 size_t len; 
    292  int ret; 
     296 int ret = 0; 
     297 
     298 ROAR_DBG("roar_hash_salted_buffer(digest=%p, data=%p, datalen=%llu, algo=%i, salt=%p, saltlen=%llu) = ?", digest, data, (unsigned long long int)datalen, algo, salt, (unsigned long long int)saltlen); 
    293299 
    294300 if ( digest == NULL || data == NULL ) 
     
    300306 
    301307 if ( (state = roar_hash_new(algo)) != NULL ) { 
     308  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret); 
     309 
    302310  if ( roar_hash_proc(state, data, datalen) == -1 ) 
    303311   ret = -1; 
     312 
     313  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret); 
    304314 
    305315  if ( saltlen != 0 ) 
     
    307317    ret = -1; 
    308318 
     319  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret); 
     320 
    309321  if ( roar_hash_digest(state, digest, &len) == -1 ) 
    310322   ret = -1; 
    311323 
     324  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret); 
     325 
    312326  if ( roar_hash_free(state) == -1 ) 
    313327   ret = -1; 
    314328 
     329  ROAR_DBG("roar_hash_salted_buffer(*): ret=%i", ret); 
     330 
    315331  return ret; 
    316332 } 
     333 
     334 ROAR_DBG("roar_hash_salted_buffer(*): state=%p", state); 
    317335 
    318336#ifdef ROAR_HAVE_LIBGCRYPT 
Note: See TracChangeset for help on using the changeset viewer.