src/inc/haval.h 1.1

1.1 2009/07/27 17:55:17 kent
Adding haval, an md5 alternative.
Index: src/inc/haval.h
===================================================================
RCS file: src/inc/haval.h
diff -N src/inc/haval.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/inc/haval.h	27 Jul 2009 17:55:17 -0000	1.1
@@ -0,0 +1,89 @@
+
+/*  $Id$ */
+
+/*
+ *  haval.h:  specifies the interface to the HAVAL (V.1) hashing library.
+ *
+ *  Copyright (c) 2003 Calyptix Security Corporation
+ *  All rights reserved.
+ *
+ *  This code is derived from software contributed to Calyptix Security
+ *  Corporation by Yuliang Zheng.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above
+ *     copyright notice, this list of conditions and the following
+ *     disclaimer in the documentation and/or other materials provided
+ *     with the distribution.
+ *  3. Neither the name of Calyptix Security Corporation nor the
+ *     names of its contributors may be used to endorse or promote
+ *     products derived from this software without specific prior
+ *     written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * -------------------------------------------------------------------
+ *
+ *      HAVAL is a one-way hashing algorithm with the following
+ *      collision-resistant property:
+ *             It is computationally infeasible to find two or more
+ *             messages that are hashed into the same fingerprint.
+ *
+ *  Reference:
+ *       Y. Zheng, J. Pieprzyk and J. Seberry:
+ *       ``HAVAL --- a one-way hashing algorithm with variable
+ *       length of output'', Advances in Cryptology --- AUSCRYPT'92,
+ *       Lecture Notes in Computer Science,  Vol.718, pp.83-104, 
+ *       Springer-Verlag, 1993.
+ *
+ *      This library provides routines to hash
+ *        -  a string,
+ *        -  a file,
+ *        -  input from the standard input device,
+ *        -  a 32-word block, and
+ *        -  a string of specified length.
+ *
+ *  Authors:    Yuliang Zheng and Lawrence Teo
+ *              Calyptix Security Corporation
+ *              P.O. Box 561508, Charlotte, NC 28213, USA
+ *              Email: info@calyptix.com
+ *              URL:   http://www.calyptix.com/
+ *              Voice: +1 704 806 8635
+ *
+ *  For a list of changes, see the ChangeLog file.
+ */
+
+typedef unsigned long int haval_word; /* a HAVAL word = 32 bits */
+
+typedef struct {
+  haval_word    count[2];                /* number of bits in a message */
+  haval_word    fingerprint[8];          /* current state of fingerprint */    
+  haval_word    block[32];               /* buffer for a 32-word block */ 
+  unsigned char remainder[32*4];         /* unhashed chars (No.<128) */   
+} haval_state;
+
+void haval_string (char *, unsigned char *); /* hash a string */
+int  haval_file (char *, unsigned char *);   /* hash a file */
+void haval_stdin (void);                     /* filter -- hash input from stdin */
+void haval_start (haval_state *);            /* initialization */
+void haval_hash (haval_state *, unsigned char *,
+                 unsigned int);              /* updating routine */
+void haval_end (haval_state *, unsigned char *); /* finalization */
+void haval_hash_block (haval_state *);       /* hash a 32-word block */
+
+