Changeset 5284:3fcf039ca02c in roaraudio
- Timestamp:
- 11/22/11 12:53:18 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/hash.h
r4878 r5284 39 39 #include "libroar.h" 40 40 41 typedef uint_least32_t roar_hash_t; 42 41 43 // the hashtypes: 42 #define ROAR_HT_NONE 043 #define ROAR_HT_MD5 144 #define ROAR_HT_SHA1 245 #define ROAR_HT_RIPEMD160 346 #define ROAR_HT_MD2 547 #define ROAR_HT_TIGER 648 #define ROAR_HT_HAVAL 749 #define ROAR_HT_SHA256 850 #define ROAR_HT_SHA384 951 #define ROAR_HT_SHA512 1052 #define ROAR_HT_SHA224 1153 #define ROAR_HT_MD4 30154 #define ROAR_HT_CRC32 30255 #define ROAR_HT_RFC1510 30356 #define ROAR_HT_RFC2440 30457 #define ROAR_HT_WHIRLPOOL 30558 #define ROAR_HT_UUID 7000059 #define ROAR_HT_GTN8 7000160 #define ROAR_HT_GTN16 7000261 #define ROAR_HT_GTN32 7000462 #define ROAR_HT_GTN64 7000863 #define ROAR_HT_CLIENTID 7100164 #define ROAR_HT_STREAMID 7100265 #define ROAR_HT_SOURCEID 7100366 #define ROAR_HT_SAMPLEID 7100467 #define ROAR_HT_MIXERID 7100568 #define ROAR_HT_BRIDGEID 7100669 #define ROAR_HT_LISTENID 7100770 #define ROAR_HT_ACTIONID 7100871 #define ROAR_HT_MSGQUEUEID 7100972 #define ROAR_HT_MSGBUSID 7101073 #define ROAR_HT_GTIN8 7200174 #define ROAR_HT_GTIN13 7200275 #define ROAR_HT_ISBN10 7200344 #define ROAR_HT_NONE ((roar_hash_t)0UL) 45 #define ROAR_HT_MD5 ((roar_hash_t)1UL) 46 #define ROAR_HT_SHA1 ((roar_hash_t)2UL) 47 #define ROAR_HT_RIPEMD160 ((roar_hash_t)3UL) 48 #define ROAR_HT_MD2 ((roar_hash_t)5UL) 49 #define ROAR_HT_TIGER ((roar_hash_t)6UL) 50 #define ROAR_HT_HAVAL ((roar_hash_t)7UL) 51 #define ROAR_HT_SHA256 ((roar_hash_t)8UL) 52 #define ROAR_HT_SHA384 ((roar_hash_t)9UL) 53 #define ROAR_HT_SHA512 ((roar_hash_t)10UL) 54 #define ROAR_HT_SHA224 ((roar_hash_t)11UL) 55 #define ROAR_HT_MD4 ((roar_hash_t)301UL) 56 #define ROAR_HT_CRC32 ((roar_hash_t)302UL) 57 #define ROAR_HT_RFC1510 ((roar_hash_t)303UL) 58 #define ROAR_HT_RFC2440 ((roar_hash_t)304UL) 59 #define ROAR_HT_WHIRLPOOL ((roar_hash_t)305UL) 60 #define ROAR_HT_UUID ((roar_hash_t)70000UL) 61 #define ROAR_HT_GTN8 ((roar_hash_t)70001UL) 62 #define ROAR_HT_GTN16 ((roar_hash_t)70002UL) 63 #define ROAR_HT_GTN32 ((roar_hash_t)70004UL) 64 #define ROAR_HT_GTN64 ((roar_hash_t)70008UL) 65 #define ROAR_HT_CLIENTID ((roar_hash_t)71001UL) 66 #define ROAR_HT_STREAMID ((roar_hash_t)71002UL) 67 #define ROAR_HT_SOURCEID ((roar_hash_t)71003UL) 68 #define ROAR_HT_SAMPLEID ((roar_hash_t)71004UL) 69 #define ROAR_HT_MIXERID ((roar_hash_t)71005UL) 70 #define ROAR_HT_BRIDGEID ((roar_hash_t)71006UL) 71 #define ROAR_HT_LISTENID ((roar_hash_t)71007UL) 72 #define ROAR_HT_ACTIONID ((roar_hash_t)71008UL) 73 #define ROAR_HT_MSGQUEUEID ((roar_hash_t)71009UL) 74 #define ROAR_HT_MSGBUSID ((roar_hash_t)71010UL) 75 #define ROAR_HT_GTIN8 ((roar_hash_t)72001UL) 76 #define ROAR_HT_GTIN13 ((roar_hash_t)72002UL) 77 #define ROAR_HT_ISBN10 ((roar_hash_t)72003UL) 76 78 #define ROAR_HT_ISBN13 ROAR_HT_GTIN13 77 #define ROAR_HT_ADLER32 7300179 #define ROAR_HT_ADLER32 ((roar_hash_t)73001UL) 78 80 79 81 struct roar_hash_cmds { 80 int algo;82 roar_hash_t algo; 81 83 ssize_t statelen; 82 84 ssize_t blocksize; … … 88 90 }; 89 91 90 const char * roar_ht2str (const intht);91 int roar_str2ht (const char* ht);92 const char * roar_ht2str (const roar_hash_t ht); 93 roar_hash_t roar_str2ht (const char * ht); 92 94 93 ssize_t roar_ht_digestlen (const intht);95 ssize_t roar_ht_digestlen (const roar_hash_t ht); 94 96 95 ssize_t roar_hash_digest2str(char * out, size_t outlen, void * digest, size_t digestlen, int ht);97 ssize_t roar_hash_digest2str(char * out, size_t outlen, void * digest, size_t digestlen, roar_hash_t ht); 96 98 97 int roar_ht_is_supported(const intht);99 int roar_ht_is_supported(const roar_hash_t ht); 98 100 99 101 struct roar_hash_state; 100 102 101 struct roar_hash_state * roar_hash_new( int algo);103 struct roar_hash_state * roar_hash_new(roar_hash_t algo); 102 104 int roar_hash_free(struct roar_hash_state * state); 103 105 int roar_hash_digest(struct roar_hash_state * state, void * digest, size_t * len); 104 106 int roar_hash_proc(struct roar_hash_state * state, const void * data, size_t len); 105 107 106 int roar_hash_buffer(void * digest, const void * data, size_t datalen, int algo);107 int roar_hash_salted_buffer(void * digest, const void * data, size_t datalen, int algo, const void * salt, size_t saltlen);108 int roar_hash_buffer(void * digest, const void * data, size_t datalen, roar_hash_t algo); 109 int roar_hash_salted_buffer(void * digest, const void * data, size_t datalen, roar_hash_t algo, const void * salt, size_t saltlen); 108 110 109 111 #endif -
libroar/hash.c
r5270 r5284 46 46 47 47 static const struct hashes { 48 const uint_least32_tid;48 const roar_hash_t id; 49 49 const char * name; 50 50 const ssize_t dlen; … … 110 110 }; 111 111 112 static struct roar_hash_cmds * roar_ht2cmds(const int ht) {112 static struct roar_hash_cmds * roar_ht2cmds(const roar_hash_t ht) { 113 113 size_t i; 114 114 115 for(i = 0; _libroar_hash_cmds[i].algo != -1; i++)115 for(i = 0; _libroar_hash_cmds[i].algo != (roar_hash_t)-1; i++) 116 116 if ( _libroar_hash_cmds[i].algo == ht ) 117 117 return &(_libroar_hash_cmds[i]); … … 121 121 } 122 122 123 static inline int roar_ht2gcrypt_tested (const int ht) {123 static inline int roar_ht2gcrypt_tested (const roar_hash_t ht) { 124 124 #ifdef ROAR_HAVE_LIBGCRYPT 125 125 const char * name; … … 143 143 } 144 144 145 const char * roar_ht2str (const intht) {145 const char * roar_ht2str (const roar_hash_t ht) { 146 146 int i; 147 147 148 for (i = 0; _libroar_hashes[i].id != ( uint_least32_t)-1; i++)148 for (i = 0; _libroar_hashes[i].id != (roar_hash_t)-1; i++) 149 149 if ( _libroar_hashes[i].id == ht ) 150 150 return _libroar_hashes[i].name; … … 154 154 } 155 155 156 introar_str2ht (const char * ht) {156 roar_hash_t roar_str2ht (const char * ht) { 157 157 int i; 158 158 159 for (i = 0; _libroar_hashes[i].id != ( uint_least32_t)-1; i++)159 for (i = 0; _libroar_hashes[i].id != (roar_hash_t)-1; i++) 160 160 if ( !strcasecmp(_libroar_hashes[i].name, ht) ) 161 161 return _libroar_hashes[i].id; … … 165 165 } 166 166 167 ssize_t roar_ht_digestlen (const intht) {167 ssize_t roar_ht_digestlen (const roar_hash_t ht) { 168 168 int i; 169 169 … … 192 192 } 193 193 194 ssize_t roar_hash_digest2str(char * out, size_t outlen, void * digest, size_t digestlen, int ht) {194 ssize_t roar_hash_digest2str(char * out, size_t outlen, void * digest, size_t digestlen, roar_hash_t ht) { 195 195 ssize_t slen = roar_ht_digestlen(ht); 196 196 union { … … 300 300 } 301 301 302 int roar_ht_is_supported(const intht) {302 int roar_ht_is_supported(const roar_hash_t ht) { 303 303 roar_crypto_init(); 304 304 … … 316 316 } 317 317 318 struct roar_hash_state * roar_hash_new( int algo) {318 struct roar_hash_state * roar_hash_new(roar_hash_t algo) { 319 319 struct roar_hash_cmds * cmds = roar_ht2cmds(algo); 320 320 struct roar_hash_state * self; … … 397 397 } 398 398 399 int roar_hash_buffer(void * digest, const void * data, size_t datalen, int algo) {399 int roar_hash_buffer(void * digest, const void * data, size_t datalen, roar_hash_t algo) { 400 400 roar_crypto_init(); 401 401 … … 404 404 405 405 #ifdef ROAR_HAVE_LIBGCRYPT 406 static inline int roar_hash_salted_buffer_gcrypt(void * digest, const void * data, size_t datalen, int algo, const void * salt, size_t saltlen) {406 static inline int roar_hash_salted_buffer_gcrypt(void * digest, const void * data, size_t datalen, roar_hash_t algo, const void * salt, size_t saltlen) { 407 407 gcry_md_hd_t hdl; 408 408 … … 434 434 #endif 435 435 436 int roar_hash_salted_buffer(void * digest, const void * data, size_t datalen, int algo, const void * salt, size_t saltlen) {436 int roar_hash_salted_buffer(void * digest, const void * data, size_t datalen, roar_hash_t algo, const void * salt, size_t saltlen) { 437 437 struct roar_hash_state * state; 438 438 size_t len;
Note: See TracChangeset
for help on using the changeset viewer.