chiark / gitweb /
Various manual fixes.
[mLib] / unihash.h
index 5fb57416946c8b8c84051a2301475bbe16dab3b8..f6c19b1991ac0fe5492dac81de89e44d55c1c349 100644 (file)
--- a/unihash.h
+++ b/unihash.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: unihash.h,v 1.1 2003/10/12 14:43:24 mdw Exp $
+ * $Id: unihash.h,v 1.4 2004/04/08 01:36:13 mdw Exp $
  *
  * Simple and efficient universal hashing for hashtables
  *
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: unihash.h,v $
- * Revision 1.1  2003/10/12 14:43:24  mdw
- * Universal hashing.
- *
- */
-
 #ifndef MLIB_UNIHASH_H
 #define MLIB_UNIHASH_H
 
@@ -50,7 +42,7 @@
  * $m_{n-1}, m_{n-2}, \ldots, m_2, m_1, m_0$% in %$\gf{q}%.
  * Then we compute
  *
- *   %$H_k(M) = k^{n+1} \sum_{0\le i<n} m_i k^{i+1}.$%
+ *   %$H_k(M) = k^{n+1} \sum_{0\le i<n} m_i k^{i+1}.$%
  *
  * Note that %$H_0(M) = 0$% for all messages %$M$%.
  *
  * computationally unbounded adversaries.  Simply XOR the hash with a random
  * string indexed from a large random pad by some nonce sent with the
  * message.  The probability of a forgery attempt being successful is then
- * %$(\ell + 1)/2^t$%, where %$t$% is the tag length and %$n$% is the longest
- * message permitted.
+ * %$(\ell + 1)/2^t$%, where %$t$% is the tag length and %$\ell$% is the
+ * longest message permitted.
  */
 
 /*----- Practicalities ----------------------------------------------------*
  *
  * We work in %$\gf{2^32}$%, represented as a field of polynomials modulo
- * %$\{104c11db7}_x$% (this is the standard CRC-32 polynomial).  Our blocks
- * are bytes.  We append a big-endian byte length.
+ * %$\texttt{104c11db7}_x$% (this is the standard CRC-32 polynomial).  Our
+ * blocks are bytes.
  *
  * The choice of a 32-bit hash is made for pragmatic reasons: we're never
  * likely to actually want all 32 bits for a real hashtable anyway.  The
@@ -135,6 +127,10 @@ typedef struct unihash_info {
   uint32 s[UNIHASH_NBATCH][4][256];    /* S-tables as described */
 } unihash_info;
 
+/*----- A global hash-info table ------------------------------------------*/
+
+extern unihash_info unihash_global;    /* Key this if you like */
+
 /*----- Functions provided ------------------------------------------------*/
 
 /* --- @unihash_setkey@ --- *
@@ -156,7 +152,7 @@ extern void unihash_setkey(unihash_info */*i*/, uint32 /*k*/);
  *             @const void *p@ = pointer to data to hash
  *             @size_t sz@ = size of the data
  *
- * Returns:    ---
+ * Returns:    Hash of data so far.
  *
  * Use:                Hashes data.  Call this as many times as needed.  
  */