X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=hash.h;fp=hash.h;h=585ef4e318c6963c2d071602636c272bad9e02d7;hb=758c28419b5b0876bee510f1fb4e01b75b2918f5;hp=0feee8430addb7d73635ed28767788c9c36c2446;hpb=c2e27a85d7a7b8d4ce734c88f9ff1493b87a5789;p=osl.git diff --git a/hash.h b/hash.h index 0feee84..585ef4e 100644 --- a/hash.h +++ b/hash.h @@ -11,9 +11,23 @@ /** hash arrays are always unsigned char. */ #define HASH_TYPE unsigned char -#include "sha1.h" -/** Our own sha1 implementation, see sha1.c. */ -#define hash_function sha1_hash +/** Size of the hash value in bytes. */ +#define HASH_SIZE 20 + +void sha1_hash(const char *data, unsigned long len, unsigned char *result); +void sha3_hash(const char *data, unsigned long len, unsigned char *result); +void sha256_hash(const char *data, unsigned long len, unsigned char *result); + +static inline void hash_function(uint8_t table_version, const char *data, + unsigned long len, unsigned char *result) +{ + switch (table_version) { + case 1: return sha1_hash(data, len, result); + case 2: return sha3_hash(data, len, result); + case 3: return sha256_hash(data, len, result); + } + assert(0); +} /** * Compare two hashes.