Skip to content

Commit 57bcec3

Browse files
author
gefeili
committed
Refactor in permutation
1 parent 6e67c1a commit 57bcec3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

core/src/main/java/org/bouncycastle/crypto/engines/AsconPermutationFriend.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@ public static class AsconPermutation
2828

2929
public void round(long C)
3030
{
31-
long t0 = x0 ^ x1 ^ x2 ^ x3 ^ C ^ (x1 & (x0 ^ x2 ^ x4 ^ C));
32-
long t1 = x0 ^ x2 ^ x3 ^ x4 ^ C ^ ((x1 ^ x2 ^ C) & (x1 ^ x3));
33-
long t2 = x1 ^ x2 ^ x4 ^ C ^ (x3 & x4);
34-
long t3 = x0 ^ x1 ^ x2 ^ C ^ ((~x0) & (x3 ^ x4));
35-
long t4 = x1 ^ x3 ^ x4 ^ ((x0 ^ x4) & x1);
31+
x2 ^= C;
32+
long x0x4 = x0 ^ x4;
33+
//long x0x2c = x0 ^ x2;
34+
long x1x2c = x1 ^ x2;
35+
36+
//long t0 = x0 ^ x1x2c ^ x3 ^ (x1 & (x0x4 ^ x2));
37+
long t0 = x0 ^ x2 ^ x3 ^ (x1 & ~(x0x4 ^ x2));
38+
long t1 = x0x4 ^ x2 ^ x3 ^ (x1x2c & (x1 ^ x3));
39+
//long t1 = x0x4 ^ x2 ^ x3 ^ (x1 & ~(x2 | x3));
40+
long t2 = x1x2c ^ (x4 & (~x3));//x4 ^ (x3 & x4);
41+
//long t3 = x0 ^ x1x2c ^ ((~x0) & (x3 ^ x4));
42+
long t3 = (x0 | (x3 ^ x4)) ^ x1x2c;
43+
long t4 = x1 ^ x3 ^ x4 ^ (x0x4 & x1);
3644
x0 = t0 ^ Longs.rotateRight(t0, 19) ^ Longs.rotateRight(t0, 28);
3745
x1 = t1 ^ Longs.rotateRight(t1, 39) ^ Longs.rotateRight(t1, 61);
3846
x2 = ~(t2 ^ Longs.rotateRight(t2, 1) ^ Longs.rotateRight(t2, 6));

0 commit comments

Comments
 (0)