diff options
-rw-r--r-- | pypride.py | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -140,8 +140,10 @@ def ror(byte): def M_L0(state): """Apply matrix L0 using the method described in appendix H of the paper""" - temp = swap((state & 0x00ff) ^ (state >> 8)) - return (((state & 0x00ff) ^ temp) << 8) | ((state >> 8) ^ temp) + s0 = state >> 8 + s1 = state & 0x00ff + temp = swap(s1 ^ s0) + return ((s1 ^ temp) << 8) | (s0 ^ temp) def M_L1(state): """Apply matrix L1 using the method described in appendix H of the paper""" @@ -152,10 +154,10 @@ def M_L1(state): def M_L1_inv(state): """Apply matrix L1^-1 using the method described in appendix H of the paper""" - s2 = state >> 8 + s2 = ror(state >> 8) s3 = state & 0x00ff - temp = ror(s2) ^ ror(s3) - return ((ror(temp) ^ ror(s2)) << 8) | swap(temp ^ s3) + temp = s2 ^ ror(s3) + return ((ror(temp) ^ s2) << 8) | swap(temp ^ s3) def M_L2(state): """Apply matrix L2 using the method described in appendix H of the paper""" @@ -166,10 +168,10 @@ def M_L2(state): def M_L2_inv(state): """Apply matrix L2^-1 using the method described in appendix H of the paper""" - s4 = state >> 8 + s4 = ror(state >> 8) s5 = state & 0x00ff - temp = ror(s4) ^ ror(s5) - return (swap(ror(s4) ^ ror(temp)) << 8) | (s5 ^ temp) + temp = s4 ^ ror(s5) + return (swap(s4 ^ ror(temp)) << 8) | (s5 ^ temp) def M_L3(state): """Apply matrix L3 using the method described in appendix H of the paper""" |