Another question - it seems that I can _de_crypt with
CTR_MODE<>::_En_cryption objects, just as you could (well, needed to) in
4.2.  Is this algorithm dependent or mode dependent?  I'm trying to reduce
code size for a self-extractor, so sharing my encryption class code is
desirable.
--
gl

----- Original Message -----
From: "gl" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 02, 2003 6:36 AM
Subject: Re: Streamcipher Seek() bugged?


>
> 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
> >
>
>

Reply via email to