I've applied the patch and it seems to work well - thanks Wei. -- gl ----- Original Message ----- From: "Wei Dai" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, February 04, 2003 12:38 AM Subject: Re: Streamcipher Seek() bugged?
> Thanks for the bug report. Apparently I forgot to test doing Seek() after > already encrypting something. As a workaround you can do a Resynchronize() > with the original IV before doing Seek(), or apply the attached patch. > > On Sun, Feb 02, 2003 at 06:36:54AM -0000, gl wrote: > > > > Forgot my IV_SIZE const: > > > > const IV_SIZE = Blowfish::BLOCKSIZE; > > -- > > gl > > > > ----- Original Message ----- > > From: "gl" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Sunday, February 02, 2003 6:32 AM > > Subject: Streamcipher Seek() bugged? > > > > > > > > > > I've just updated my working 4.2 code to use 5.0 (downloaded from the > > > website, not from CVS). Under 4.2, Seek()'ing worked correctly for me, > > but > > > it no longer seems to work under 5. > > > > > > Here's some test code that demonstrates the failure: > > > > > > AutoSeededRandomPool rnd; > > > > > > SecByteBlock pass; > > > const char* passphrase = "test passphrase-"; > > > pass.Assign((unsigned char*)passphrase, strlen(passphrase)); > > > > > > unsigned char plain[100], buffer[100]; > > > rnd.GenerateBlock(plain, 100); > > > memcpy(buffer, plain, 100); > > > > > > SecByteBlock IV; > > > IV .New(IV_SIZE); > > > rnd.GenerateBlock(IV, IV_SIZE); > > > > > > CTR_Mode<Blowfish>::Encryption Enc(pass, pass.size(), IV); > > > CTR_Mode<Blowfish>::Decryption Dec(pass, pass.size(), IV); > > > > > > // encode, then decode the buffer > > > Enc.ProcessString(buffer, 100); > > > _ASSERT(memcmp(plain, buffer, 100) != 0); // passes > > > Dec.ProcessString(buffer, 100); > > > // does it match the plaintext? > > > _ASSERT(memcmp(plain, buffer, 100) == 0); // passes > > > > > > // encrypt the buffer again > > > Enc.Seek(0); > > > Enc.ProcessString(buffer, 100); > > > // copy the first plain byte into the first encrypted byte, > > > // seek the streamcipher and process it. > > > buffer[0] = plain[0]; > > > Enc.Seek(0); > > > Enc.ProcessString(buffer, 1); > > > // now try to decode the buffer again > > > Dec.Seek(0); > > > Dec.ProcessString(buffer, 100); > > > // do they still match? > > > _ASSERTE(memcmp(plain, buffer, 100) == 0); // FAILS! > > > > > > Does anyone see anything wrong with this? If no, Wei, any idea what's > > > happening here? > > > -- > > > gl > > > >
