e1011a007dbe36d6949d7592e4c386978faa59b7
3 * $Id: tiger.h,v 1.1 2000/07/15 10:02:43 mdw Exp $
5 * The Tiger hash function
7 * (c) 2000 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.1 2000/07/15 10:02:43 mdw
34 * Anderson and Biham's Tiger hash function added.
38 /*----- Notes on the Tiger hash function ----------------------------------*
40 * Tiger was designed by Eli Biham and Ross Anderson to be an efficient and
41 * secure hash function which worked well on 64-bit processors. This
42 * implementation should work everywhere, but it'll be faster if real 64-bit
43 * arithmetic is available.
45 * I don't know of any really good analysis of Tiger.
48 #ifndef CATACOMB_TIGER_H
49 #define CATACOMB_TIGER_H
55 /*----- Header files ------------------------------------------------------*/
57 #include <mLib/bits.h>
59 #ifndef CATACOMB_GHASH_H
63 /*----- Magic numbers -----------------------------------------------------*/
65 #define TIGER_BUFSZ 64
66 #define TIGER_HASHSZ 24
68 /*----- Data structures ---------------------------------------------------*/
70 typedef struct tiger_ctx
{
71 kludge64 a
, b
, c
; /* Chaining variables */
72 uint32 nl
, nh
; /* Byte count so far */
73 unsigned off
; /* Offset into buffer */
74 octet buf
[TIGER_BUFSZ
]; /* Accumulation buffer */
77 /*----- Functions provided ------------------------------------------------*/
79 /* --- @tiger_compress@ --- *
81 * Arguments: @tiger_ctx *ctx@ = pointer to context block
82 * @const void *sbuf@ = pointer to buffer of appropriate size
86 * Use: Tiger compression function.
89 extern void tiger_compress(tiger_ctx */
*ctx*/
, const void */
*sbuf*/
);
91 /* --- @tiger_init@ --- *
93 * Arguments: @tiger_ctx *ctx@ = pointer to context block to initialize
97 * Use: Initializes a context block ready for hashing.
100 extern void tiger_init(tiger_ctx */
*ctx*/
);
102 /* --- @tiger_set@ --- *
104 * Arguments: @tiger_ctx *ctx@ = pointer to context block
105 * @const void *buf@ = pointer to state buffer
106 * @unsigned long count@ = current count of bytes processed
110 * Use: Initializes a context block from a given state. This is
111 * useful in cases where the initial hash state is meant to be
112 * secret, e.g., for NMAC and HMAC support.
115 extern void tiger_set(tiger_ctx */
*ctx*/
, const void */
*buf*/
,
116 unsigned long /*count*/);
118 /* --- @tiger_hash@ --- *
120 * Arguments: @tiger_ctx *ctx@ = pointer to context block
121 * @const void *buf@ = buffer of data to hash
122 * @size_t sz@ = size of buffer to hash
126 * Use: Hashes a buffer of data. The buffer may be of any size and
130 extern void tiger_hash(tiger_ctx */
*ctx*/
, const void */
*buf*/
, size_t /*sz*/);
132 /* --- @tiger_done@ --- *
134 * Arguments: @tiger_ctx *ctx@ = pointer to context block
135 * @void *hash@ = pointer to output buffer
139 * Use: Returns the hash of the data read so far.
142 extern void tiger_done(tiger_ctx */
*ctx*/
, void */
*hash*/
);
144 /* --- @tiger_state@ --- *
146 * Arguments: @tiger_ctx *ctx@ = pointer to context
147 * @void *state@ = pointer to buffer for current state
149 * Returns: Number of bytes written to the hash function so far.
151 * Use: Returns the current state of the hash function such that
152 * it can be passed to @tiger_set@.
155 extern unsigned long tiger_state(tiger_ctx */
*ctx*/
, void */
*state*/
);
157 /*----- Generic hash interface --------------------------------------------*/
159 extern const gchash tiger
;
161 /*----- That's all, folks -------------------------------------------------*/