[Mono-dev] Correction to System.Security.Cryptography.Rfc2898DeriveBytes.cs

Sebastien Pouliot sebastien.pouliot at gmail.com
Thu Mar 22 17:05:39 EDT 2007

On Thu, 2007-03-15 at 13:09 -0400, Sebastien Pouliot wrote:
> On Thu, 2007-03-15 at 09:18 -0700, Roei Erez wrote:
> > Hello,
> > The method 'private byte[] F (byte[] s, int c, int i)'  uses
> > BitConverter.GetBytes(int num).
> > This usage is machine dependant, which depends on if the machine works
> > as big endian or little endian..
> > I think, althogh not sure, that the better way is to use
> > BitConverterLE.GetBytes(int num) or calculate the bytes manually using
> > bitwise operations.
> > Attached is a patch for this.
> > Do you agree?
> Make sense, but please wait before committing the fix (unless you have
> unit tests that trigger this condition). I'll look at the source ASAP.

I made a unit test and little endian + reverse was correct (if complex).
I committed (SVN r74843) a different fix, without BitConverter[LE] +
Reverse and, more importantly, without F allocating over and over the
same memory block.

Thanks for spotting this!

p.s. oops, I also added the tests to our build :|
Sebastien Pouliot  <sebastien at ximian.com>
Blog: http://pages.infinit.net/ctech/

More information about the Mono-devel-list mailing list