]> git.tuebingen.mpg.de Git - osl.git/blobdiff - hash.h
Version 3 tables.
[osl.git] / hash.h
diff --git a/hash.h b/hash.h
index 6244d081e178c69281eb6c3b2dfbcd0e38cfbeaa..585ef4e318c6963c2d071602636c272bad9e02d7 100644 (file)
--- a/hash.h
+++ b/hash.h
 /** Size of the hash value in bytes. */
 #define HASH_SIZE 20
 
-void sha1_hash(const char *data, unsigned long len, unsigned char *sha1);
+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);
 
-/** Our own sha1 implementation, see sha1.c. */
-#define hash_function sha1_hash
+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.