X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/d03ab969116fe715d569304c1c474749b2f64529..20fa0f6976d598481208c0583d72b2ccef637be9:/rc5.c diff --git a/rc5.c b/rc5.c index 5d03be7..306b5ec 100644 --- a/rc5.c +++ b/rc5.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: rc5.c,v 1.1 1999/09/03 08:41:12 mdw Exp $ + * $Id: rc5.c,v 1.3 2004/04/08 01:36:15 mdw Exp $ * * The RC5-32/12 block cipher * * (c) 1999 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,26 +15,18 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: rc5.c,v $ - * Revision 1.1 1999/09/03 08:41:12 mdw - * Initial import. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -44,12 +36,16 @@ #include #include +#include "arena.h" #include "blkc.h" +#include "gcipher.h" #include "rc5.h" -/*----- Internal magical constants ----------------------------------------*/ +/*----- Global variables --------------------------------------------------*/ -#define RC5_ROUNDS 12 +const octet rc5_keysz[] = { KSZ_RANGE, RC5_KEYSZ, 1, 255, 1 }; + +/*----- Internal magical constants ----------------------------------------*/ #define T ((RC5_ROUNDS + 1) * 2) #define P 0xb7e15163 @@ -78,7 +74,7 @@ void rc5_init(rc5_ctx *k, const void *sbuf, size_t sz) * This is slightly unfortunately defined. */ - assert(((void)"RC5 does not support zero-length keys", sz != 0)); + KSZ_ASSERT(rc5, sz); { int i; @@ -87,7 +83,7 @@ void rc5_init(rc5_ctx *k, const void *sbuf, size_t sz) /* --- Create the buffer --- */ w = (sz + 3) / 4; - l = xmalloc(w * sizeof(uint32)); + l = XS_ALLOC(w * sizeof(uint32)); /* --- Extract the key material --- */ @@ -137,7 +133,8 @@ void rc5_init(rc5_ctx *k, const void *sbuf, size_t sz) } } - free(l); + memset(l, 0, w * sizeof(uint32)); + XS_FREE(l); } /* --- @EROUND@, @DROUND@ --- */