X-Git-Url: https://git.distorted.org.uk/~mdw/userv-utils/blobdiff_plain/d31674ca96a34a90de366fe7fdbb826617219e19..244a0e991c9286152f4e8c2252249088c5461c67:/ipif/mech-blowfish.c 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) {