3 * $Id: ghash.h,v 1.5 2000/07/15 10:00:58 mdw Exp $
5 * Generic hash function interface
7 * (c) 1999 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.5 2000/07/15 10:00:58 mdw
34 * New generic hash operation for copying hash contexts.
36 * Revision 1.4 2000/07/03 18:08:24 mdw
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.
45 * Revision 1.2 2000/06/17 11:22:17 mdw
46 * Minor changes in the generic hash interface.
48 * Revision 1.1 1999/12/10 23:16:01 mdw
53 #ifndef CATACOMB_GHASH_H
54 #define CATACOMB_GHASH_H
60 /*----- Header files ------------------------------------------------------*/
64 #include <mLib/bits.h>
66 /*----- Generic hash function interface -----------------------------------*/
68 typedef struct ghash
{
69 const struct ghash_ops
*ops
; /* Pointer to hash operations */
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 */
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 */
86 /*----- That's all, folks -------------------------------------------------*/