summaryrefslogtreecommitdiff
path: root/serpent-encrypt.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2011-06-07 21:39:40 +0200
committerNiels Möller <nisse@lysator.liu.se>2011-06-07 21:39:40 +0200
commit2c32cfc7b71e859f6f64fd2eaf936fb2d92522d7 (patch)
tree6bf8ca904439126fc5ce6be0596a93915b82329a /serpent-encrypt.c
parentdae705f56224540b60f902d6644032654d3c0440 (diff)
downloadnettle-2c32cfc7b71e859f6f64fd2eaf936fb2d92522d7.tar.gz
(SBOX2): Renamed arguments. Eliminated temporaries.
Rev: nettle/ChangeLog:1.179 Rev: nettle/serpent-encrypt.c:1.4
Diffstat (limited to 'serpent-encrypt.c')
-rw-r--r--serpent-encrypt.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/serpent-encrypt.c b/serpent-encrypt.c
index 30923a7d..634b883d 100644
--- a/serpent-encrypt.c
+++ b/serpent-encrypt.c
@@ -94,6 +94,7 @@
y1 ^= x3; \
} 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 */
#define SBOX1(type, x0, x1, x2, x3, y0, y1, y2, y3) \
do { \
@@ -117,27 +118,26 @@
y0 ^= x2; \
} 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 */
-#define SBOX2(type, a, b, c, d, w, x, y, z) \
- do { \
- type t02, t03, t05, t06, t07, t08; \
- type t09, t10, t12, t13, t14, t01; \
- t01 = a | c ; \
- t02 = a ^ b ; \
- t03 = d ^ t01; \
- w = t02 ^ t03; \
- t05 = c ^ w ; \
- t06 = b ^ t05; \
- t07 = b | t05; \
- t08 = t01 & t06; \
- t09 = t03 ^ t07; \
- t10 = t02 | t09; \
- x = t10 ^ t08; \
- t12 = a | d ; \
- t13 = t09 ^ x ; \
- t14 = b ^ t13; \
- z = ~ t09; \
- y = t12 ^ t14; \
+#define SBOX2(type, x0, x1, x2, x3, y0, y1, y2, y3) \
+ do { \
+ y2 = x0 | x2; \
+ y1 = x0 ^ x1; \
+ y3 = x3 ^ y2; \
+ y0 = y1 ^ y3; \
+ x3 |= x0; \
+ x2 ^= y0; \
+ x0 = x1 ^ x2; \
+ x2 |= x1; \
+ x0 &= y2; \
+ y3 ^= x2; \
+ y1 |= y3; \
+ y1 ^= x0; \
+ y2 = y3 ^ y1; \
+ y2 ^= x1; \
+ y3 = ~ y3; \
+ y2 ^= x3; \
} while (0)
/* S3: 0 15 11 8 12 9 6 3 13 1 2 4 10 7 5 14 */