X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fsha1.h;h=4b17da548c97c6eaf98b158dddd2a28f7e6a43b4;hb=3bf739559578b42ef385479feb602b2dfe1f41b5;hp=2527e09a72f5e5204bef389aca83d1dda956428f;hpb=a4fe009d3366b0a3e119713b0ecc7fc0070efdfa;p=libucw.git diff --git a/ucw/sha1.h b/ucw/sha1.h index 2527e09a..4b17da54 100644 --- a/ucw/sha1.h +++ b/ucw/sha1.h @@ -1,7 +1,7 @@ /* * SHA-1 Hash Function (FIPS 180-1, RFC 3174) * - * (c) 2008 Martin Mares + * (c) 2008--2009 Martin Mares * * Based on the code from libgcrypt-1.2.3, which was: * @@ -63,6 +63,19 @@ void sha1_hash_buffer(byte *outbuf, const byte *buffer, uns length); */ void sha1_hmac(byte *outbuf, const byte *key, uns keylen, const byte *data, uns datalen); +/** + * The HMAC also exists in a stream version in a way analogous to the + * plain SHA1. Pass this as a context. + */ +typedef struct { + sha1_context ictx; + sha1_context octx; +} sha1_hmac_context; + +void sha1_hmac_init(sha1_hmac_context *hd, const byte *key, uns keylen); /** Initialize HMAC with context @hd and the given key. See sha1_init(). */ +void sha1_hmac_update(sha1_hmac_context *hd, const byte *data, uns datalen); /** Hash another @datalen bytes of data. See sha1_update(). */ +byte *sha1_hmac_final(sha1_hmac_context *hd); /** Terminate the HMAC and return a pointer to the allocated hash. See sha1_final(). */ + #define SHA1_SIZE 20 /** Size of the SHA1 hash in its binary representation **/ #define SHA1_HEX_SIZE 41 /** Buffer length for a string containing SHA1 in hexadecimal format. **/ #define SHA1_BLOCK_SIZE 64 /** SHA1 splits input to blocks of this size. **/