From 6ced98bd0eb9435f22e745b723e6ebb96e543032 Mon Sep 17 00:00:00 2001 From: mdw Date: Sat, 17 Jun 2000 11:24:08 +0000 Subject: [PATCH] New key size interface. --- hmac.h | 9 ++++++++- idea.c | 12 ++++++++++-- idea.h | 7 ++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/hmac.h b/hmac.h index d64003f..7ad01f7 100644 --- a/hmac.h +++ b/hmac.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: hmac.h,v 1.2 1999/12/10 23:17:39 mdw Exp $ + * $Id: hmac.h,v 1.3 2000/06/17 11:23:57 mdw Exp $ * * Generic code for HMAC and NMAC * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: hmac.h,v $ + * Revision 1.3 2000/06/17 11:23:57 mdw + * New key size interface. + * * Revision 1.2 1999/12/10 23:17:39 mdw * Split mode macros into interface and implementation. * @@ -95,6 +98,10 @@ typedef struct pre##_macctx { \ unsigned count; /* Byte count for outer hash */ \ } pre##_macctx; \ \ +/* --- Other useful constants --- */ \ + \ +extern const octet pre##_mackeysz[]; \ + \ /* --- @pre_nmacinit@ --- * \ * \ * Arguments: @pre_macctx *key@ = pointer to a MAC key object \ diff --git a/idea.c b/idea.c index f554bf4..5f88948 100644 --- a/idea.c +++ b/idea.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: idea.c,v 1.1 1999/09/03 08:41:12 mdw Exp $ + * $Id: idea.c,v 1.2 2000/06/17 11:24:08 mdw Exp $ * * Implementation of the IDEA cipher * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: idea.c,v $ + * Revision 1.2 2000/06/17 11:24:08 mdw + * New key size interface. + * * Revision 1.1 1999/09/03 08:41:12 mdw * Initial import. * @@ -45,8 +48,13 @@ #include #include "blkc.h" +#include "gcipher.h" #include "idea.h" +/*----- Global variables --------------------------------------------------*/ + +const octet idea_keysz[] = { KSZ_SET, IDEA_KEYSZ }; + /*----- Main code ---------------------------------------------------------*/ /* --- @inv@ --- * @@ -115,7 +123,7 @@ static uint16 inv(uint16 n) void idea_init(idea_ctx *k, const void *buf, size_t sz) { - assert(((void)"IDEA key must be 128 bits", sz == IDEA_KEYSZ)); + KSZ_ASSERT(idea, sz); /* --- Unpack the encryption key --- */ diff --git a/idea.h b/idea.h index 84b7e51..326925f 100644 --- a/idea.h +++ b/idea.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: idea.h,v 1.2 1999/12/10 23:29:48 mdw Exp $ + * $Id: idea.h,v 1.3 2000/06/17 11:24:08 mdw Exp $ * * Implementation of the IDEA cipher * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: idea.h,v $ + * Revision 1.3 2000/06/17 11:24:08 mdw + * New key size interface. + * * Revision 1.2 1999/12/10 23:29:48 mdw * Change header file guard names. * @@ -73,6 +76,8 @@ #define IDEA_KEYSZ 16 #define IDEA_CLASS (N, B, 64) +extern const octet idea_keysz[]; + /*----- Data structures ---------------------------------------------------*/ typedef struct idea_ctx { -- 2.11.0