X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/6ced98bd0eb9435f22e745b723e6ebb96e543032..2685767a6125c1620719c7de6234aedf41857b7e:/hmac.h diff --git a/hmac.h b/hmac.h index 7ad01f7..e9c8d78 100644 --- a/hmac.h +++ b/hmac.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: hmac.h,v 1.3 2000/06/17 11:23:57 mdw Exp $ + * $Id: hmac.h,v 1.6 2001/04/19 18:24:45 mdw Exp $ * * Generic code for HMAC and NMAC * @@ -30,6 +30,16 @@ /*----- Revision history --------------------------------------------------* * * $Log: hmac.h,v $ + * Revision 1.6 2001/04/19 18:24:45 mdw + * Provide correct key sizes for NMAC, HMAC and SSLMAC. + * + * Revision 1.5 2001/04/03 19:35:45 mdw + * Support the SSL HMAC variant (untested). + * + * Revision 1.4 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.3 2000/06/17 11:23:57 mdw * New key size interface. * @@ -84,9 +94,9 @@ /* --- An HMAC or NMAC key --- */ \ \ typedef struct pre##_mackey { \ - octet ochain[PRE##_HASHSZ]; /* Chaining for outer hash */ \ + octet ochain[PRE##_STATESZ]; /* Chaining for outer hash */ \ unsigned ocount; /* Byte count for outer hash */ \ - octet ichain[PRE##_HASHSZ]; /* Chaining for inner hash */ \ + octet ichain[PRE##_STATESZ]; /* Chaining for inner hash */ \ unsigned icount; /* Byte count for inner hash */ \ } pre##_mackey; \ \ @@ -94,13 +104,15 @@ typedef struct pre##_mackey { \ \ typedef struct pre##_macctx { \ pre##_ctx ctx; /* Context for main hashing */ \ - octet chain[PRE##_HASHSZ]; /* Chaining for outer hash */ \ + octet chain[PRE##_STATESZ]; /* Chaining for outer hash */ \ unsigned count; /* Byte count for outer hash */ \ } pre##_macctx; \ \ /* --- Other useful constants --- */ \ \ -extern const octet pre##_mackeysz[]; \ +extern const octet pre##_hmackeysz[]; \ +extern const octet pre##_nmackeysz[]; \ +extern const octet pre##_sslmackeysz[]; \ \ /* --- @pre_nmacinit@ --- * \ * \ @@ -134,6 +146,21 @@ extern void pre##_nmacinit(pre##_mackey */*key*/, \ extern void pre##_hmacinit(pre##_mackey */*key*/, \ const void */*k*/, size_t /*sz*/); \ \ +/* --- @pre_sslmacinit@ --- * \ + * \ + * Arguments: @pre_mackey *key@ = pointer to MAC key object \ + * @const void *k@ = pointer to key to use \ + * @size_t sz@ = size of key data \ + * \ + * Returns: --- \ + * \ + * Use: Initializes a MAC key for doing hasing using the SSL3 \ + * variant of HMAC. \ + */ \ + \ +extern void pre##_sslmacinit(pre##_mackey */*key*/, \ + const void */*k*/, size_t /*sz*/); \ + \ /* --- @pre_macinit@ --- * \ * \ * Arguments: @pre_macctx *ctx@ = pointer to MAC context block \ @@ -175,7 +202,9 @@ extern void pre##_macdone(pre##_macctx */*ctx*/, void */*mac*/); \ \ /* --- Generic MAC interface --- */ \ \ -extern const gcmac pre##_hmac; +extern const gcmac pre##_hmac; \ +extern const gcmac pre##_nmac; \ +extern const gcmac pre##_sslmac; /*----- That's all, folks -------------------------------------------------*/