New SHA variants with longer outputs.
[u/mdw/catacomb] / tiger.h
CommitLineData
eeccf7a8 1/* -*-c-*-
2 *
3 * $Id: tiger.h,v 1.1 2000/07/15 10:02:43 mdw Exp $
4 *
5 * The Tiger hash function
6 *
7 * (c) 2000 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Catacomb.
13 *
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.
18 *
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.
23 *
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,
27 * MA 02111-1307, USA.
28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: tiger.h,v $
33 * Revision 1.1 2000/07/15 10:02:43 mdw
34 * Anderson and Biham's Tiger hash function added.
35 *
36 */
37
38/*----- Notes on the Tiger hash function ----------------------------------*
39 *
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.
44 *
45 * I don't know of any really good analysis of Tiger.
46 */
47
48#ifndef CATACOMB_TIGER_H
49#define CATACOMB_TIGER_H
50
51#ifdef __cplusplus
52 extern "C" {
53#endif
54
55/*----- Header files ------------------------------------------------------*/
56
57#include <mLib/bits.h>
58
59#ifndef CATACOMB_GHASH_H
60# include "ghash.h"
61#endif
62
63/*----- Magic numbers -----------------------------------------------------*/
64
65#define TIGER_BUFSZ 64
66#define TIGER_HASHSZ 24
67
68/*----- Data structures ---------------------------------------------------*/
69
70typedef 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 */
75} tiger_ctx;
76
77/*----- Functions provided ------------------------------------------------*/
78
79/* --- @tiger_compress@ --- *
80 *
81 * Arguments: @tiger_ctx *ctx@ = pointer to context block
82 * @const void *sbuf@ = pointer to buffer of appropriate size
83 *
84 * Returns: ---
85 *
86 * Use: Tiger compression function.
87 */
88
89extern void tiger_compress(tiger_ctx */*ctx*/, const void */*sbuf*/);
90
91/* --- @tiger_init@ --- *
92 *
93 * Arguments: @tiger_ctx *ctx@ = pointer to context block to initialize
94 *
95 * Returns: ---
96 *
97 * Use: Initializes a context block ready for hashing.
98 */
99
100extern void tiger_init(tiger_ctx */*ctx*/);
101
102/* --- @tiger_set@ --- *
103 *
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
107 *
108 * Returns: ---
109 *
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.
113 */
114
115extern void tiger_set(tiger_ctx */*ctx*/, const void */*buf*/,
116 unsigned long /*count*/);
117
118/* --- @tiger_hash@ --- *
119 *
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
123 *
124 * Returns: ---
125 *
126 * Use: Hashes a buffer of data. The buffer may be of any size and
127 * alignment.
128 */
129
130extern void tiger_hash(tiger_ctx */*ctx*/, const void */*buf*/, size_t /*sz*/);
131
132/* --- @tiger_done@ --- *
133 *
134 * Arguments: @tiger_ctx *ctx@ = pointer to context block
135 * @void *hash@ = pointer to output buffer
136 *
137 * Returns: ---
138 *
139 * Use: Returns the hash of the data read so far.
140 */
141
142extern void tiger_done(tiger_ctx */*ctx*/, void */*hash*/);
143
144/* --- @tiger_state@ --- *
145 *
146 * Arguments: @tiger_ctx *ctx@ = pointer to context
147 * @void *state@ = pointer to buffer for current state
148 *
149 * Returns: Number of bytes written to the hash function so far.
150 *
151 * Use: Returns the current state of the hash function such that
152 * it can be passed to @tiger_set@.
153 */
154
155extern unsigned long tiger_state(tiger_ctx */*ctx*/, void */*state*/);
156
157/*----- Generic hash interface --------------------------------------------*/
158
159extern const gchash tiger;
160
161/*----- That's all, folks -------------------------------------------------*/
162
163#ifdef __cplusplus
164 }
165#endif
166
167#endif