]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
(SBOX0): Renamed arguments. Eliminated temporaries.
authorNiels Möller <nisse@lysator.liu.se>
Tue, 7 Jun 2011 11:57:43 +0000 (13:57 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 7 Jun 2011 11:57:43 +0000 (13:57 +0200)
Rev: nettle/ChangeLog:1.177
Rev: nettle/serpent-encrypt.c:1.2

ChangeLog
serpent-encrypt.c

index 6360e693330f69d02097d36f4b6962a15142f5cc..ab97fb63ece3c77fe57d66b58604f75d087e06c7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-07  Niels Möller  <nisse@lysator.liu.se>
+
+       * serpent-encrypt.c (SBOX0): Renamed arguments. Eliminated
+       temporaries.
+
 2011-06-06  Niels Möller  <nisse@lysator.liu.se>
 
        * Makefile.in (DISTFILES): Added serpent-internal.h.
index 91ba13f5369d31ae09b3d865f2aeef90a9a8abdb..dda821d8a7ee6209d11f40f68ec10dc907ee1f06 100644 (file)
    destroyed. Can this freedom be used to optimize the sboxes? */
 
 /* S0:  3  8 15  1 10  6  5 11 14 13  4  2  7  0  9 12 */
-#define SBOX0(type, a, b, c, d, w, x, y, z)    \
-  do { \
-    type t02, t03, t05, t06, t07, t08, t09; \
-    type t11, t12, t13, t14, t15, t17, t01; \
-    t01 = b   ^ c  ; \
-    t02 = a   | d  ; \
-    t03 = a   ^ b  ; \
-    z   = t02 ^ t01; \
-    t05 = c   | z  ; \
-    t06 = a   ^ d  ; \
-    t07 = b   | c  ; \
-    t08 = d   & t05; \
-    t09 = t03 & t07; \
-    y   = t09 ^ t08; \
-    t11 = t09 & y  ; \
-    t12 = c   ^ d  ; \
-    t13 = t07 ^ t11; \
-    t14 = b   & t06; \
-    t15 = t06 ^ t13; \
-    w   =     ~ t15; \
-    t17 = w   ^ t14; \
-    x   = t12 ^ t17; \
+/* Could easily let y0, y1 overlap with x0, x1, and possibly also x2 and y2 */
+#define SBOX0(type, x0, x1, x2, x3, y0, y1, y2, y3)    \
+  do {                                                 \
+    y3  = x1 ^ x2;                                     \
+    y0  = x0 | x3;                                     \
+    y1  = x0 ^ x1;                                     \
+    y3 ^= y0;                                          \
+    y2  = x2 | y3;                                     \
+    x0 ^= x3;                                          \
+    y2 &= x3;                                          \
+    x3 ^= x2;                                          \
+    x2 |= x1;                                          \
+    y0  = y1 & x2;                                     \
+    y2 ^= y0;                                          \
+    y0 &= y2;                                          \
+    y0 ^= x2;                                          \
+    x1 &= x0;                                          \
+    y0 ^= x0;                                          \
+    y0  = ~ y0;                                                \
+    y1  = y0 ^ x1;                                     \
+    y1 ^= x3;                                          \
   } while (0)
 
 /* S1: 15 12  2  7  9  0  5 10  1 11 14  8  6 13  3  4 */