chiark / gitweb /
crypto debugging, and several bugfixes
[userv-utils.git] / ipif / mech-blowfish.c
index 07ec8c13cd89f463ede1271c0b7258aa80d4ffed..7447cadb1d888a3ccd729f897c720ba9e5ca0018 100644 (file)
@@ -22,7 +22,7 @@ static void mds_blowfish(struct mechdata **md_r) {
   unsigned char iv[BLOWFISH_BLOCKBYTES];
   unsigned char key[BLOWFISH_MAXKEYBYTES];
 
-  md= xmalloc(sizeof(md));
+  XMALLOC(md);
 
   keysize= getarg_ulong();
   arg_assert(!(keysize & 7));
@@ -53,18 +53,20 @@ static void mes_bfmac(struct mechdata **md_r, int *maxprefix_io, int *maxsuffix_
 
 #define MSGSIZE_OUT                                                  \
   msgsize= buf->size;                                                \
-  arg_assert(!(msgsize & ~BLOWFISH_BLOCKBYTES));
+  arg_assert(!(msgsize & (BLOWFISH_BLOCKBYTES-1)));
 
 #define MSGSIZE_IN                                                   \
   msgsize= buf->size;                                                \
-  if (msgsize & ~BLOWFISH_BLOCKBYTES) return "not multiple of block size"
+  if (msgsize & (BLOWFISH_BLOCKBYTES-1)) return "not multiple of block size"
 
 #define FOREACH_BLOCK(func,inptr,outptr)                             \
  {                                                                    \
    unsigned char *ptr;                                               \
-   ptr= buf->start;                                                  \
-   while (ptr < buf->start + msgsize)                                \
+   for (ptr= buf->start;                                             \
+        ptr < buf->start + msgsize;                                  \
+       ptr += BLOWFISH_BLOCKBYTES) {                                 \
      func(&md->cbc,inptr,outptr);                                    \
+   }                                                                  \
  }
 
 static void menc_blowfish(struct mechdata *md, struct buffer *buf) {