[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sha1 alignment bug



On Thu, 26 Apr 2001, Randolph Chung wrote:

> > > unsigned char Buffer[64];
> > > unsigned char State[5*4];
> > > unsigned char Count[2*4];
> > > 
> > > the code goes on to address these as uint32_t * 's... on 64-bit
> > > architectures this causes very bad unaligned accesses.
> 
> that should have said "on 64-bit PARISC architectures"
> 
> this can be fixed in the kernel with a alignment handler, which we don't
> have in the palinux kernel yet.

But that alignment handler is not invoked on alpha, arm, or sparc. I
suspect this has to do with gcc3 being weird. I bet if you drop a unsigned
long as the first element in the structure your problem will go away.

This may be due to the new hashes class, which would permit Gcc to pack
the structures.. Hmm. Yes..

> > If this is infact a problem (I assume you are getting traps) then making
> > a union with each and unsigned long will correct it in a portable way.
> 
> that sounds reasonable. i'll investigate.

Please try that, thats the solution I've had waiting in case this ever
stopped working :>

Jason



Reply to: