Changeset 4671:21813f03d0cc in roaraudio for libroar/crc.c


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.