X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=ipif%2Fmech-blowfish.c;fp=ipif%2Fmech-blowfish.c;h=7447cadb1d888a3ccd729f897c720ba9e5ca0018;hb=0f4b558c78aae6fda9f52287e1b53483e9435903;hp=07ec8c13cd89f463ede1271c0b7258aa80d4ffed;hpb=09966b4959fa31ea3f6746b6b6583907744484e1;p=userv-utils.git diff --git a/ipif/mech-blowfish.c b/ipif/mech-blowfish.c index 07ec8c1..7447cad 100644 --- a/ipif/mech-blowfish.c +++ b/ipif/mech-blowfish.c @@ -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) {