fixing segv
[oweals/gnunet.git] / src / block / block.c
index 8d8018b50276fb085feb1226a5500eed7b42bf6f..29382dad193d74665f61aac25c4d41f94a7f5e14 100644 (file)
@@ -46,6 +46,7 @@ struct Plugin
   struct GNUNET_BLOCK_PluginFunctions *api;
 };
 
+
 /**
  * Handle to an initialized block library.
  */
@@ -63,6 +64,27 @@ struct GNUNET_BLOCK_Context
 };
 
 
+/**
+ * Mingle hash with the mingle_number to produce different bits.
+ * 
+ * @param in original hash code
+ * @param mingle_number number for hash permutation
+ * @param hc where to store the result.
+ */
+void
+GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in,
+                         int32_t mingle_number, 
+                         GNUNET_HashCode * hc)
+{
+  GNUNET_HashCode m;
+
+  GNUNET_CRYPTO_hash (&mingle_number, 
+                     sizeof (int32_t), 
+                     &m);
+  GNUNET_CRYPTO_hash_xor (&m, in, hc);
+}
+
+
 /**
  * Create a block context.  Loads the block plugins.
  *