Skip to contentSkip to conversation

crypto_xor

DISCUSSION Nikos Mavrogiannopoulos 2 participants 2 messages Sep 1, 2010 – Sep 7, 2010 Crypto API

lore
Share & tools
lore
#0 lore raw

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

maintainer
#1 lore raw
Quoted 5 lines · Nikos Mavrogiannopoulos

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,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt