memxor() tweaks, as it is heavily used in xcbc
authorMartin Willi <martin@strongswan.org>
Wed, 26 Nov 2008 10:06:59 +0000 (10:06 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 26 Nov 2008 10:06:59 +0000 (10:06 -0000)
src/libstrongswan/utils.c

index 88aa1bf..3a6a478 100644 (file)
@@ -61,10 +61,18 @@ void *clalloc(void * pointer, size_t size)
  */
 void memxor(u_int8_t dest[], u_int8_t src[], size_t n)
 {
-       size_t i;
-       for (i = 0; i < n; i++)
+       int i = 0, m;
+       
+       m = n - sizeof(long);
+       while (i < m)
+       {
+               *(long*)(dest + i) ^= *(long*)(src + i);
+               i += sizeof(long);
+       }
+       while (i < n)
        {
                dest[i] ^= src[i];
+               i++;
        }
 }