chiark / gitweb /
Add some more vectors, and a whinge about how Skipjack test vectors are.
[catacomb] / ghash.h
1 /* -*-c-*-
2  *
3  * $Id: ghash.h,v 1.5 2000/07/15 10:00:58 mdw Exp $
4  *
5  * Generic hash function interface
6  *
7  * (c) 1999 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: ghash.h,v $
33  * Revision 1.5  2000/07/15 10:00:58  mdw
34  * New generic hash operation for copying hash contexts.
35  *
36  * Revision 1.4  2000/07/03 18:08:24  mdw
37  * Include `bits.h'.
38  *
39  * Revision 1.3  2000/07/02 18:27:42  mdw
40  * (ghash->ops->done): Interface change.  Passing in a null buffer pointer
41  * uses a buffer internal to the ghash object.  The operation returns the
42  * address of the buffer it used.  Clients of generic hashes no longer need
43  * to use dynamically allocated memory for hash results.
44  *
45  * Revision 1.2  2000/06/17 11:22:17  mdw
46  * Minor changes in the generic hash interface.
47  *
48  * Revision 1.1  1999/12/10 23:16:01  mdw
49  * Generic interface.
50  *
51  */
52
53 #ifndef CATACOMB_GHASH_H
54 #define CATACOMB_GHASH_H
55
56 #ifdef __cplusplus
57   extern "C" {
58 #endif
59
60 /*----- Header files ------------------------------------------------------*/
61
62 #include <stddef.h>
63
64 #include <mLib/bits.h>
65
66 /*----- Generic hash function interface -----------------------------------*/
67
68 typedef struct ghash {
69   const struct ghash_ops *ops;          /* Pointer to hash operations */
70 } ghash;
71
72 typedef struct ghash_ops {
73   const struct gchash *c;               /* Pointer to hash class */
74   void (*hash)(ghash */*h*/, const void */*p*/, size_t /*sz*/); /* Hash */
75   octet *(*done)(ghash */*h*/, void */*buf*/); /* Write result */
76   void (*destroy)(ghash */*h*/);        /* Destroy hash block */
77   ghash *(*copy)(ghash */*h*/);         /* Make a copy of the hash context */
78 } ghash_ops;
79
80 typedef struct gchash {
81   const char *name;                     /* Name of the hash function */
82   size_t hashsz;                        /* Size of output hash */
83   ghash *(*init)(void);                 /* Create a new hash instance */
84 } gchash;
85
86 /*----- That's all, folks -------------------------------------------------*/
87
88 #ifdef __cplusplus
89   }
90 #endif
91
92 #endif