3 * $Id: ghash-def.h,v 1.2 2000/06/17 11:22:03 mdw Exp $
5 * Definitions for generic hash 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 --------------------------------------------------*
32 * $Log: ghash-def.h,v $
33 * Revision 1.2 2000/06/17 11:22:03 mdw
34 * Use secure arena for memory allocation. Minor changes in the generic
37 * Revision 1.1 1999/12/10 23:21:37 mdw
42 #ifndef CATACOMB_GHASH_DEF_H
43 #define CATACOMB_GHASH_DEF_H
49 /*----- Header files ------------------------------------------------------*/
51 #include <mLib/bits.h>
54 #ifndef CATACOMB_ARENA_H
58 #ifndef CATACOMB_GHASH_H
62 /*----- Generic hash function interface -----------------------------------*/
64 /* --- @GHASH_DEF@ --- *
66 * Arguments: @PRE, pre@ = prefixes for hash function
68 * Use: Defines the generic hash instance.
71 #define GHASH_DEF(PRE, pre) \
73 static const ghash_ops gops; \
75 typedef struct gctx { \
80 static ghash *ghinit(void) \
82 gctx *g = S_CREATE(gctx); \
88 static void ghhash(ghash *h, const void *p, size_t sz) \
90 gctx *g = (gctx *)h; \
91 pre##_hash(&g->c, p, sz); \
94 static void ghdone(ghash *h, void *buf) \
96 gctx *g = (gctx *)h; \
97 pre##_done(&g->c, buf); \
100 static void ghdestroy(ghash *h) \
102 gctx *g = (gctx *)h; \
106 static const ghash_ops gops = { &pre, ghhash, ghdone, ghdestroy }; \
107 const gchash pre = { #pre, PRE##_HASHSZ, ghinit };
109 /*----- That's all, folks -------------------------------------------------*/