Commit 2c32cfc7 authored by Niels Möller's avatar Niels Möller
Browse files

(SBOX2): Renamed arguments. Eliminated temporaries.

Rev: nettle/ChangeLog:1.179
Rev: nettle/serpent-encrypt.c:1.4
parent dae705f5
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* serpent-encrypt.c (SBOX0): Renamed arguments. Eliminated * serpent-encrypt.c (SBOX0): Renamed arguments. Eliminated
temporaries. temporaries.
(SBOX1): Likewise. (SBOX1): Likewise.
(SBOX2): Likewise.
2011-06-06 Niels Mller <nisse@lysator.liu.se> 2011-06-06 Niels Mller <nisse@lysator.liu.se>
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
y1 ^= x3; \ y1 ^= x3; \
} while (0) } while (0)
/* FIXME: Arrange for some overlap between inputs and outputs? */
/* S1: 15 12 2 7 9 0 5 10 1 11 14 8 6 13 3 4 */ /* S1: 15 12 2 7 9 0 5 10 1 11 14 8 6 13 3 4 */
#define SBOX1(type, x0, x1, x2, x3, y0, y1, y2, y3) \ #define SBOX1(type, x0, x1, x2, x3, y0, y1, y2, y3) \
do { \ do { \
...@@ -117,27 +118,26 @@ ...@@ -117,27 +118,26 @@
y0 ^= x2; \ y0 ^= x2; \
} while (0) } while (0)
/* FIXME: Arrange for some overlap between inputs and outputs? */
/* S2: 8 6 7 9 3 12 10 15 13 1 14 4 0 11 5 2 */ /* S2: 8 6 7 9 3 12 10 15 13 1 14 4 0 11 5 2 */
#define SBOX2(type, a, b, c, d, w, x, y, z) \ #define SBOX2(type, x0, x1, x2, x3, y0, y1, y2, y3) \
do { \ do { \
type t02, t03, t05, t06, t07, t08; \ y2 = x0 | x2; \
type t09, t10, t12, t13, t14, t01; \ y1 = x0 ^ x1; \
t01 = a | c ; \ y3 = x3 ^ y2; \
t02 = a ^ b ; \ y0 = y1 ^ y3; \
t03 = d ^ t01; \ x3 |= x0; \
w = t02 ^ t03; \ x2 ^= y0; \
t05 = c ^ w ; \ x0 = x1 ^ x2; \
t06 = b ^ t05; \ x2 |= x1; \
t07 = b | t05; \ x0 &= y2; \
t08 = t01 & t06; \ y3 ^= x2; \
t09 = t03 ^ t07; \ y1 |= y3; \
t10 = t02 | t09; \ y1 ^= x0; \
x = t10 ^ t08; \ y2 = y3 ^ y1; \
t12 = a | d ; \ y2 ^= x1; \
t13 = t09 ^ x ; \ y3 = ~ y3; \
t14 = b ^ t13; \ y2 ^= x3; \
z = ~ t09; \
y = t12 ^ t14; \
} while (0) } while (0)
/* S3: 0 15 11 8 12 9 6 3 13 1 2 4 10 7 5 14 */ /* S3: 0 15 11 8 12 9 6 3 13 1 2 4 10 7 5 14 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment