Mercurial > hg > index.fcgi > gift-gnutella > gift-gnutella-0.0.11-1pba
view src/sha1.h @ 0:d39e1d0d75b6
initial add
author | paulo@hit-nxdomain.opendns.com |
---|---|
date | Sat, 20 Feb 2010 21:18:28 -0800 |
parents | |
children |
line source
1 /*
2 * $Id: sha1.h,v 1.10 2004/03/05 17:47:29 hipnod Exp $
3 *
4 * Copyright (C) 2001-2004 giFT project (gift.sourceforge.net)
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 */
17 #ifndef GIFT_GT_SHA1_H_
18 #define GIFT_GT_SHA1_H_
20 /*****************************************************************************/
22 #define SHA_BLOCKSIZE 64
23 #define SHA_DIGESTSIZE 20
25 #define SHA1_BINSIZE 20
26 #define SHA1_STRLEN 32
28 /*****************************************************************************/
30 struct sha1_state
31 {
32 unsigned long digest[5]; /* message digest */
33 unsigned long count_lo, count_hi; /* 64-bit bit count */
34 uint8_t data[SHA_BLOCKSIZE]; /* SHA data buffer */
35 int local; /* unprocessed amount in data */
36 };
38 typedef struct sha1_state sha1_state_t;
40 /*****************************************************************************/
42 /* TODO: prefix these suckers */
43 char *sha1_string (const unsigned char *sha1);
44 unsigned char *sha1_digest (const char *file, off_t size);
45 unsigned char *sha1_bin (const char *ascii);
46 unsigned char *sha1_dup (const unsigned char *sha1);
48 /*****************************************************************************/
50 void gt_sha1_init (sha1_state_t *state);
51 void gt_sha1_append (sha1_state_t *state, const void *data,
52 size_t len);
53 void gt_sha1_finish (sha1_state_t *state, unsigned char *hash);
55 /*****************************************************************************/
57 #endif /* GIFT_GT_SHA1_H_ */