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

Re: sha1 alignment bug



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

> Someone is doing screwy alignment, you can see that all the starts of all
> those buffers are aligned by 4 and they are at the start of the structure,
> and structures are 'aligned by size'. Thus any casting is assured to be
> aligned by size. 

i think you explained the reasoning yourself in your message, in that
the problem is that your buffers are only byte-aligned, but you are
accessing them in a 32-bit aligned manner. 

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

randolph
-- 
Debian Developer <tausq@debian.org>
http://www.TauSq.org/



Reply to: