]> mj.ucw.cz Git - libucw.git/blob - lib/sha1.h
Libucw: Added an implementation of HMAC-SHA1.
[libucw.git] / lib / sha1.h
1 /*
2  *      SHA-1 Hash Function (FIPS 180-1, RFC 3174)
3  *
4  *      (c) 2008 Martin Mares <mj@ucw.cz>
5  *
6  *      Based on the code from libgcrypt-1.2.3, which was:
7  *
8  *      Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc.
9  *
10  *      This software may be freely distributed and used according to the terms
11  *      of the GNU Lesser General Public License.
12  */
13
14 #ifndef _UCW_SHA1_H
15 #define _UCW_SHA1_H
16
17 typedef struct {
18   u32 h0,h1,h2,h3,h4;
19   u32 nblocks;
20   byte buf[64];
21   int count;
22 } sha1_context;
23
24 void sha1_init(sha1_context *hd);
25 void sha1_update(sha1_context *hd, const byte *inbuf, uns inlen);
26 byte *sha1_final(sha1_context *hd);
27
28 /* One-shot interface */
29 void sha1_hash_buffer(byte *outbuf, const byte *buffer, uns length);
30
31 /* HMAC */
32 void sha1_hmac(byte *outbuf, const byte *key, uns keylen, const byte *data, uns datalen);
33
34 #define SHA1_SIZE 20
35 #define SHA1_HEX_SIZE 41
36 #define SHA1_BLOCK_SIZE 64
37
38 #endif