2010-09-01 15:02:29

by Nikos Mavrogiannopoulos

[permalink] [raw]
Subject: crypto_xor

Hello,
I was checking the crypto_xor() function and it is for some reason
limited to 32 bit integers. Why not make it depend on the architecture
by replacing the u32 with unsigned long? That way 64bit machines should
perform xor with less instructions...

Something like:

void crypto_xor(u8 *dst, const u8 *src, unsigned int size)
{
unsigned long *a = (unsigned long *)dst;
unsigned long *b = (unsigned long *)src;

for (; size >= sizeof(unsigned long); size -= sizeof(unsigned long))
*a++ ^= *b++;

crypto_xor_byte((u8 *)a, (u8 *)b, size);
}


regards,
Nikos


2010-09-07 02:12:11

by Herbert Xu

[permalink] [raw]
Subject: Re: crypto_xor

Nikos Mavrogiannopoulos <[email protected]> wrote:
> Hello,
> I was checking the crypto_xor() function and it is for some reason
> limited to 32 bit integers. Why not make it depend on the architecture
> by replacing the u32 with unsigned long? That way 64bit machines should
> perform xor with less instructions...

We could do that, but you'd also need to go through every user
to make sure that their alignment requirement is upgraded from
4 to sizeof(unsigned long).

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt