#include "blowfish.h"
struct mechdata {
+ unsigned char iv[BLOWFISH_BLOCKBYTES];
struct blowfish_cbc_state cbc;
};
static void mds_blowfish(struct mechdata **md_r) {
struct mechdata *md;
unsigned long keysize;
- unsigned char iv[BLOWFISH_BLOCKBYTES];
unsigned char key[BLOWFISH_MAXKEYBYTES];
XMALLOC(md);
keysize >>= 3;
arg_assert(keysize > 0 && keysize <= BLOWFISH_MAXKEYBYTES);
- random_key(iv,sizeof(iv));
+ random_key(md->iv,sizeof(md->iv));
random_key(key,keysize);
blowfish_loadkey(&md->cbc.ek, key,keysize);
- blowfish_cbc_setiv(&md->cbc, iv);
-
*md_r= md;
}
#define FOREACH_BLOCK(func,inptr,outptr) \
{ \
unsigned char *ptr; \
+ blowfish_cbc_setiv(&md->cbc, md->iv); \
for (ptr= buf->start; \
ptr < buf->start + msgsize; \
ptr += BLOWFISH_BLOCKBYTES) { \