X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/d03ab969116fe715d569304c1c474749b2f64529..5d01b1b9514a258c5a3c201e944f676cb2c467f0:/des3.c diff --git a/des3.c b/des3.c index 281d8ea..66f8243 100644 --- a/des3.c +++ b/des3.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: des3.c,v 1.1 1999/09/03 08:41:11 mdw Exp $ + * $Id: des3.c,v 1.3 2004/04/08 01:36:15 mdw Exp $ * * Implementation of double- and triple-DES * * (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: des3.c,v $ - * Revision 1.1 1999/09/03 08:41:11 mdw - * Initial import. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -48,6 +40,11 @@ #include "des-base.h" #include "des.h" #include "des3.h" +#include "gcipher.h" + +/*----- Global variables --------------------------------------------------*/ + +const octet des3_keysz[] = { KSZ_SET, 21, 7, 8, 14, 16, 24, 0 }; /*----- Main code ---------------------------------------------------------*/ @@ -60,9 +57,9 @@ * Returns: --- * * Use: Initializes a DES key buffer. The key buffer may have length - * 7, 8, 14, 16, 21, or 24. These correspond to one, two or - * three DES keys, either packed or unpacked (i.e., still - * containing parity bits). + * 7, 8, 14, 16, 21, or 24. These correspond to one, two or + * three DES keys, either packed or unpacked (i.e., still + * containing parity bits). */ void des3_init(des3_ctx *k, const void *buf, size_t sz) @@ -70,8 +67,7 @@ void des3_init(des3_ctx *k, const void *buf, size_t sz) size_t step; const octet *p = buf; - assert(((void)("des3 key length must be one of 7, 8, 14, 16, 21 or 24"), - (sz % 7 == 0 || sz % 8 == 0) && sz < 25)); + KSZ_ASSERT(des3, sz); if (sz % 7 == 0) step = 7;