/* -*-c-*-
*
- * $Id: blkc.h,v 1.7 2004/04/08 01:36:15 mdw Exp $
+ * $Id$
*
* Common definitions for block ciphers
*
* (c) 1999 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of Catacomb.
*
* 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,
BLKC_GLUE(BLKC_STEP_X_, BLKC_ENDIAN(PRE)) \
(PRE, w)
+#define BLKC_ZERO(PRE, w) \
+ BLKC_GLUE(BLKC_ZERO_, BLKC_TYPE(PRE)) \
+ (PRE, w, BLKC_BITS(PRE))
+
#define BLKC_SET(PRE, w, x) \
BLKC_GLUE(BLKC_SET_X_, BLKC_ENDIAN(PRE)) \
(PRE, w, x)
BLKC_SKEL_X(PRE, BLKC_W(w); const BLKC_WX(wx);, \
*_w ^= *_wx; _w++; _wx++; ) \
+#define BLKC_ZERO_X(PRE, w, n) \
+ BLKC_SKEL_X(PRE, BLKC_W(w);, *_w++ = 0;)
+
#define BLKC_STEP_X_B(PRE, w) do { \
unsigned _i = PRE##_BLKSZ / 4; BLKC_W(w); uint32 _x = 0; \
while (_i && !_x) { _i--; _w[_i] = _x = U32(_w[_i] + 1); } \
#define BLKC_XLOAD_GUTS(op, i) _w[i] ^= op(_p + 4 * i)
#define BLKC_MOVE_GUTS(op, i) _w[i] = _wx[i]
#define BLKC_XMOVE_GUTS(op, i) _w[i] ^= _wx[i]
+#define BLKC_ZERO_GUTS(op, i) _w[i] = 0
#define BLKC_STORE_N(PRE, b, w, op, n) \
BLKC_GLUE(BLKC_SKEL_, n) \
BLKC_GLUE(BLKC_SKEL_, n) \
(PRE, BLKC_W(w); const BLKC_WX(wx);, op, BLKC_MOVE_GUTS)
+#define BLKC_ZERO_N(PRE, w, n) \
+ BLKC_GLUE(BLKC_SKEL_, n) \
+ (PRE, BLKC_W(w); , op, BLKC_ZERO_GUTS)
+
#define BLKC_XMOVE_N(PRE, w, wx, n) \
BLKC_GLUE(BLKC_SKEL_, n) \
(PRE, BLKC_W(w); const BLKC_WX(wx);, op, BLKC_XMOVE_GUTS)
#ifdef TEST_RIG
+#include <string.h>
+
#include <mLib/quis.h>
#include <mLib/testrig.h>
if (memcmp(b.buf, v[2].buf, PRE##_BLKSZ)) { \
ok = 0; \
printf("\nfail encryption:" \
- "\n\tkey = "); \
+ "\n\tkey = "); \
type_hex.dump(&v[0], stdout); \
printf("\n\tplaintext = "); type_hex.dump(&v[1], stdout); \
printf("\n\texpected = "); type_hex.dump(&v[2], stdout); \
if (memcmp(b.buf, v[1].buf, PRE##_BLKSZ)) { \
ok = 0; \
printf("\nfail decryption:" \
- "\n\tkey = "); \
+ "\n\tkey = "); \
type_hex.dump(&v[0], stdout); \
printf("\n\tciphertext = "); type_hex.dump(&v[2], stdout); \
printf("\n\texpected = "); type_hex.dump(&v[1], stdout); \