Debian Codegraph @

cipher/hash-common.h

raw
1 /* hash-common.h - Declarations of common code for hash algorithms.
2 * Copyright (C) 2008 Free Software Foundation, Inc.
3 *
4 * This file is part of Libgcrypt.
5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
10 *
11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef GCRY_HASH_COMMON_H
21 #define GCRY_HASH_COMMON_H
22
23 #include "types.h"
24
25
26 const char * _gcry_hash_selftest_check_one
27 /**/ (int algo,
28 int datamode, const void *data, size_t datalen,
29 const void *expect, size_t expectlen);
30
31 /* Type for the md_write helper function. */
32 typedef unsigned int (*_gcry_md_block_write_t) (void *c,
33 const unsigned char *blks,
34 size_t nblks);
35
36 #if (defined(USE_SHA512) || defined(USE_WHIRLPOOL))
37 /* SHA-512 and Whirlpool needs u64. SHA-512 needs larger buffer. */
38 # define MD_BLOCK_MAX_BLOCKSIZE 128
39 # define MD_NBLOCKS_TYPE u64
40 #else
41 # define MD_BLOCK_MAX_BLOCKSIZE 64
42 # define MD_NBLOCKS_TYPE u32
43 #endif
44
45 /* SHA1 needs 2x64 bytes and SHA-512 needs 128 bytes. */
46 #define MD_BLOCK_CTX_BUFFER_SIZE 128
47
48 typedef struct gcry_md_block_ctx
49 {
50 byte buf[MD_BLOCK_CTX_BUFFER_SIZE];
51 MD_NBLOCKS_TYPE nblocks;
52 MD_NBLOCKS_TYPE nblocks_high;
53 int count;
54 unsigned int blocksize_shift;
55 _gcry_md_block_write_t bwrite;
56 } gcry_md_block_ctx_t;
57
58
59 void
60 _gcry_md_block_write( void *context, const void *inbuf_arg, size_t inlen);
61
62 #endif /*GCRY_HASH_COMMON_H*/