On Wed, Oct 03, 2007 at 06:21:49PM +0800, Herbert Xu wrote:

> static void __ctr_inc_byte(u8 *a, int size)
> {
>       __be8 *b = (__be8 *)(a + size);
>       u8 c;
> 
>       do {
>               c = be8_to_cpu(*--b) + 1;
>               *b = cpu_to_be8(c);
>               if (c)
>                       break;
>       } while (--size);

This should be a for loop and we can make it inline too.

static inline void __ctr_inc_byte(u8 *a, int size)
{
        __be8 *b = (__be8 *)(a + size);
        u8 c;

        for (; size; size--) {
                c = b8_to_cpu(*--b) + 1;
                *b = cpu_to_be8(c);
                if (c)
                        break;
        }
}
 
> Let's also get rid of the xor selection and just use this xor
> function:
> 
> static void xor_quad(u8 *dst, const u8 *src, unsigned int bs)
> {
>       u32 *a = (u32 *)dst;
>       u32 *b = (u32 *)src;
> 
>       for (; bs >= 4; bs -= 4)
>               *a++ ^= *b++;
> 
>       xor_byte((u8 *)a, (u8 *)b, bs);
> }

xor_byte should be constructed in a similar fashion.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to