]> git.tuebingen.mpg.de Git - osl.git/blobdiff - hash.h
Add sha3 implementation, introduce version-2 tables.
[osl.git] / hash.h
diff --git a/hash.h b/hash.h
index 27b060139ed05966a6fa13abad32f3947725d973..6d6cb8f3911f40e65f2037f57fd90420c69d8120 100644 (file)
--- a/hash.h
+++ b/hash.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2007-2009 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 /** hash arrays are always unsigned char. */
 #define HASH_TYPE unsigned char
 
-#include "sha1.h"
-/** We use openssl's sha1 implementation. */
-#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);
+
+static inline void hash_function(uint8_t table_version, const char *data,
+               unsigned long len, unsigned char *result)
+{
+       if (table_version == 1)
+               return sha1_hash(data, len, result);
+       if (table_version == 2)
+               return sha3_hash(data, len, result);
+       assert(0);
+}
 
 /**
  * Compare two hashes.