~mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
76ba9c8
)
Provide correct key sizes for NMAC, HMAC and SSLMAC.
author
mdw
<mdw>
Thu, 19 Apr 2001 18:24:45 +0000
(18:24 +0000)
committer
mdw
<mdw>
Thu, 19 Apr 2001 18:24:45 +0000
(18:24 +0000)
hmac-def.h
patch
|
blob
|
blame
|
history
hmac.h
patch
|
blob
|
blame
|
history
diff --git
a/hmac-def.h
b/hmac-def.h
index
95d7562
..
ffd796c
100644
(file)
--- a/
hmac-def.h
+++ b/
hmac-def.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: hmac-def.h,v 1.
6 2001/04/03 19:35
:45 mdw Exp $
+ * $Id: hmac-def.h,v 1.
7 2001/04/19 18:24
:45 mdw Exp $
*
* Definitions for HMAC and NMAC
*
*
* Definitions for HMAC and NMAC
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: hmac-def.h,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: hmac-def.h,v $
+ * Revision 1.7 2001/04/19 18:24:45 mdw
+ * Provide correct key sizes for NMAC, HMAC and SSLMAC.
+ *
* Revision 1.6 2001/04/03 19:35:45 mdw
* Support the SSL HMAC variant (untested).
*
* Revision 1.6 2001/04/03 19:35:45 mdw
* Support the SSL HMAC variant (untested).
*
@@
-96,7
+99,9
@@
\
/* --- Useful constants --- */ \
\
\
/* --- Useful constants --- */ \
\
-const octet pre##_mackeysz[] = { KSZ_ANY, PRE##_STATESZ }; \
+const octet pre##_hmackeysz[] = { KSZ_ANY, PRE##_STATESZ }; \
+const octet pre##_sslmackeysz[] = { KSZ_ANY, PRE##_STATESZ }; \
+const octet pre##_nmackeysz[] = { KSZ_SET, 2 * PRE##_STATESZ, 0 }; \
\
/* --- @pre_nmacinit@ --- * \
* \
\
/* --- @pre_nmacinit@ --- * \
* \
@@
-178,7
+183,6
@@
void pre##_hmacinit(pre##_mackey *key, const void *k, size_t sz) \
\
void pre##_sslmacinit(pre##_mackey *key, const void *k, size_t sz) \
{ \
\
void pre##_sslmacinit(pre##_mackey *key, const void *k, size_t sz) \
{ \
- int i; \
const octet *kbuf = k; \
pre##_ctx ctx; \
octet buf[PRE##_HASHSZ]; \
const octet *kbuf = k; \
pre##_ctx ctx; \
octet buf[PRE##_HASHSZ]; \
@@
-261,10
+265,11
@@
void pre##_macdone(pre##_macctx *ctx, void *mac) \
/* --- Generic MAC interface --- */ \
\
static const gmac_ops gkops; \
/* --- Generic MAC interface --- */ \
\
static const gmac_ops gkops; \
-static const ghash_ops gops
;
\
+static const ghash_ops gops
, gnops, gsslops;
\
\
typedef struct gkctx { \
gmac m; \
\
typedef struct gkctx { \
gmac m; \
+ const ghash_ops *gops; \
pre##_mackey k; \
} gkctx; \
\
pre##_mackey k; \
} gkctx; \
\
@@
-278,7
+283,7
@@
static ghash *gkinit(gmac *m) \
{ \
gkctx *gk = (gkctx *)m; \
gctx *g = S_CREATE(gctx); \
{ \
gkctx *gk = (gkctx *)m; \
gctx *g = S_CREATE(gctx); \
- g->h.ops =
&gops;
\
+ g->h.ops =
gk->gops;
\
pre##_macinit(&g->c, &gk->k); \
return (&g->h); \
} \
pre##_macinit(&g->c, &gk->k); \
return (&g->h); \
} \
@@
-287,14
+292,27
@@
static gmac *gkey(const void *k, size_t sz) \
{ \
gkctx *gk = S_CREATE(gkctx); \
gk->m.ops = &gkops; \
{ \
gkctx *gk = S_CREATE(gkctx); \
gk->m.ops = &gkops; \
+ gk->gops = &gops; \
pre##_hmacinit(&gk->k, k, sz); \
return (&gk->m); \
} \
\
pre##_hmacinit(&gk->k, k, sz); \
return (&gk->m); \
} \
\
+static gmac *gnkey(const void *k, size_t sz) \
+{ \
+ gkctx *gk = S_CREATE(gkctx); \
+ const octet *kk = k; \
+ assert(keysz(sz, pre##_nmackeysz) == sz); \
+ gk->m.ops = &gkops; \
+ gk->gops = &gnops; \
+ pre##_nmacinit(&gk->k, kk, kk + PRE##_STATESZ); \
+ return (&gk->m); \
+} \
+ \
static gmac *gsslkey(const void *k, size_t sz) \
{ \
gkctx *gk = S_CREATE(gkctx); \
gk->m.ops = &gkops; \
static gmac *gsslkey(const void *k, size_t sz) \
{ \
gkctx *gk = S_CREATE(gkctx); \
gk->m.ops = &gkops; \
+ gk->gops = &gsslops; \
pre##_sslmacinit(&gk->k, k, sz); \
return (&gk->m); \
} \
pre##_sslmacinit(&gk->k, k, sz); \
return (&gk->m); \
} \
@@
-342,14
+360,24
@@
static ghash *ghinit(void) \
return (0); \
} \
\
return (0); \
} \
\
+const gcmac pre##_nmac = \
+ { #pre "-nmac", PRE##_HASHSZ, pre##_nmackeysz, gnkey }; \
const gcmac pre##_hmac = \
const gcmac pre##_hmac = \
- { #pre "-hmac", PRE##_HASHSZ, pre##_
mackeysz, gkey };
\
+ { #pre "-hmac", PRE##_HASHSZ, pre##_
hmackeysz, gkey };
\
const gcmac pre##_sslmac = \
const gcmac pre##_sslmac = \
- { #pre "-sslmac", PRE##_HASHSZ, pre##_
mackeysz, gsslkey };
\
+ { #pre "-sslmac", PRE##_HASHSZ, pre##_
sslmackeysz, gsslkey };
\
static const gmac_ops gkops = { &pre##_hmac, gkinit, gkdestroy }; \
static const gmac_ops gkops = { &pre##_hmac, gkinit, gkdestroy }; \
+static const gmac_ops gnkops = { &pre##_nmac, gkinit, gkdestroy }; \
+static const gmac_ops gsslkops = { &pre##_sslmac, gkinit, gkdestroy }; \
static const gchash gch = { #pre "-hmac", PRE##_HASHSZ, ghinit }; \
static const ghash_ops gops = \
{ &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
static const gchash gch = { #pre "-hmac", PRE##_HASHSZ, ghinit }; \
static const ghash_ops gops = \
{ &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
+static const gchash gnch = { #pre "-nmac", PRE##_HASHSZ, ghinit }; \
+static const ghash_ops gnops = \
+ { &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
+static const gchash gsslch = { #pre "-sslmac", PRE##_HASHSZ, ghinit }; \
+static const ghash_ops gsslops = \
+ { &gch, ghhash, ghdone, ghdestroy, ghcopy }; \
\
HMAC_TEST(PRE, pre)
\
HMAC_TEST(PRE, pre)
diff --git
a/hmac.h
b/hmac.h
index
097371a
..
e9c8d78
100644
(file)
--- a/
hmac.h
+++ b/
hmac.h
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: hmac.h,v 1.
5 2001/04/03 19:35
:45 mdw Exp $
+ * $Id: hmac.h,v 1.
6 2001/04/19 18:24
:45 mdw Exp $
*
* Generic code for HMAC and NMAC
*
*
* Generic code for HMAC and NMAC
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: hmac.h,v $
/*----- 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.5 2001/04/03 19:35:45 mdw
* Support the SSL HMAC variant (untested).
*
@@
-107,7
+110,9
@@
typedef struct pre##_macctx { \
\
/* --- Other useful constants --- */ \
\
\
/* --- 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@ --- * \
* \
\
/* --- @pre_nmacinit@ --- * \
* \
@@
-197,7
+202,9
@@
extern void pre##_macdone(pre##_macctx */*ctx*/, void */*mac*/); \
\
/* --- Generic MAC interface --- */ \
\
\
/* --- 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 -------------------------------------------------*/
/*----- That's all, folks -------------------------------------------------*/