diff options
author | Niels Möller <nisse@lysator.liu.se> | 2011-06-07 13:57:43 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2011-06-07 13:57:43 +0200 |
commit | 66b7bda5759fbf2b8597f746f6081ccbcd6adbac (patch) | |
tree | c43f66e9a71fdf65d2e0d5d7a96c2e1414219b4e /serpent-encrypt.c | |
parent | 00a6c2d167bf929cc0d9e13f9093d2ef205d7f33 (diff) | |
download | nettle-66b7bda5759fbf2b8597f746f6081ccbcd6adbac.tar.gz |
(SBOX0): Renamed arguments. Eliminated temporaries.
Rev: nettle/ChangeLog:1.177
Rev: nettle/serpent-encrypt.c:1.2
Diffstat (limited to 'serpent-encrypt.c')
-rw-r--r-- | serpent-encrypt.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/serpent-encrypt.c b/serpent-encrypt.c index 91ba13f5..dda821d8 100644 --- a/serpent-encrypt.c +++ b/serpent-encrypt.c @@ -71,28 +71,27 @@ 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 */ |