X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/d03ab969116fe715d569304c1c474749b2f64529..59919ae4b1721ca271c3d3e5955c09d322573821:/sha.h diff --git a/sha.h b/sha.h index 8f72def..97003ef 100644 --- a/sha.h +++ b/sha.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: sha.h,v 1.1 1999/09/03 08:41:12 mdw Exp $ + * $Id: sha.h,v 1.5 2000/10/15 19:09:20 mdw Exp $ * * Implementation of the SHA-1 hash function * @@ -30,6 +30,19 @@ /*----- Revision history --------------------------------------------------* * * $Log: sha.h,v $ + * Revision 1.5 2000/10/15 19:09:20 mdw + * Support HMAC mode for hash functions which need to store more state than + * the hash output size. + * + * Revision 1.4 2000/06/17 11:32:52 mdw + * Change buffer offset to be unsigned. + * + * Revision 1.3 1999/12/10 23:20:03 mdw + * New hash interface requirements. + * + * Revision 1.2 1999/11/19 13:20:08 mdw + * Modify notes section slightly. + * * Revision 1.1 1999/09/03 08:41:12 mdw * Initial import. * @@ -38,13 +51,14 @@ /*----- Notes on the SHA-1 hash function ----------------------------------* * * SHA (Secure Hash Algorithm) was designed by the NSA, for use with the - * Digital Signature Algorithm. It has gained wide acceptance since then, - * and is probably now most people's collision-resistant function of choice. - * The author prefers RIPEMD-160, for no particularly good reasons. + * Digital Signature Algorithm. It is defined by FIPS 180-1. It has gained + * wide acceptance since its initial publication, and is probably now most + * people's collision-resistant function of choice. The author prefers + * RIPEMD-160, for no particularly good reasons. */ -#ifndef SHA_H -#define SHA_H +#ifndef CATACOMB_SHA_H +#define CATACOMB_SHA_H #ifdef __cplusplus extern "C" { @@ -54,17 +68,22 @@ #include +#ifndef CATACOMB_GHASH_H +# include "ghash.h" +#endif + /*----- Magic numbers -----------------------------------------------------*/ #define SHA_BUFSZ 64 #define SHA_HASHSZ 20 +#define SHA_STATESZ 20 /*----- Data structures ---------------------------------------------------*/ typedef struct sha_ctx { uint32 a, b, c, d, e; /* Chaining variables */ - unsigned long count; /* Byte count so far */ - int off; /* Offset into buffer */ + uint32 nl, nh; /* Byte count so far */ + unsigned off; /* Offset into buffer */ octet buf[SHA_BUFSZ]; /* Accumulation buffer */ } sha_ctx; @@ -148,6 +167,10 @@ extern void sha_done(sha_ctx */*ctx*/, void */*hash*/); extern unsigned long sha_state(sha_ctx */*ctx*/, void */*state*/); +/*----- Generic hash interface --------------------------------------------*/ + +extern const gchash sha; + /*----- That's all, folks -------------------------------------------------*/ #ifdef __cplusplus