/* -*-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
* $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
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@ --- *
* @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.
*/