aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/serpent
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-05-15 09:34:37 -0400
committerJack Lloyd <[email protected]>2020-06-06 09:39:10 -0400
commit6f2cbeb12df7cc264a24a399074470b572a7a11b (patch)
tree9b92053782d7b7929c6e36818e146c54f5149a7e /src/lib/block/serpent
parent406432d07575cb35ec0e62a47840f38f49fedcc0 (diff)
Rename vars in the Sbox expressions
Diffstat (limited to 'src/lib/block/serpent')
-rw-r--r--src/lib/block/serpent/serpent_sbox.h732
1 files changed, 366 insertions, 366 deletions
diff --git a/src/lib/block/serpent/serpent_sbox.h b/src/lib/block/serpent/serpent_sbox.h
index a8bc61ef9..31471e724 100644
--- a/src/lib/block/serpent/serpent_sbox.h
+++ b/src/lib/block/serpent/serpent_sbox.h
@@ -14,433 +14,433 @@
#include <botan/build.h>
template<typename T>
-BOTAN_FORCE_INLINE void SBoxE0(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxE0(T& a, T& b, T& c, T& d)
{
- B3 ^= B0;
- T B4 = B1;
- B1 &= B3;
- B4 ^= B2;
- B1 ^= B0;
- B0 |= B3;
- B0 ^= B4;
- B4 ^= B3;
- B3 ^= B2;
- B2 |= B1;
- B2 ^= B4;
- B4 = ~B4;
- B4 |= B1;
- B1 ^= B3;
- B1 ^= B4;
- B3 |= B0;
- B1 ^= B3;
- B4 ^= B3;
- B3 = B0;
- B0 = B1;
- B1 = B4;
+ d ^= a;
+ T t0 = b;
+ b &= d;
+ t0 ^= c;
+ b ^= a;
+ a |= d;
+ a ^= t0;
+ t0 ^= d;
+ d ^= c;
+ c |= b;
+ c ^= t0;
+ t0 = ~t0;
+ t0 |= b;
+ b ^= d;
+ b ^= t0;
+ d |= a;
+ b ^= d;
+ t0 ^= d;
+ d = a;
+ a = b;
+ b = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxE1(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxE1(T& a, T& b, T& c, T& d)
{
- B0 = ~B0;
- B2 = ~B2;
- T B4 = B0;
- B0 &= B1;
- B2 ^= B0;
- B0 |= B3;
- B3 ^= B2;
- B1 ^= B0;
- B0 ^= B4;
- B4 |= B1;
- B1 ^= B3;
- B2 |= B0;
- B2 &= B4;
- B0 ^= B1;
- B1 &= B2;
- B1 ^= B0;
- B0 &= B2;
- B4 ^= B0;
- B0 = B2;
- B2 = B3;
- B3 = B1;
- B1 = B4;
+ a = ~a;
+ c = ~c;
+ T t0 = a;
+ a &= b;
+ c ^= a;
+ a |= d;
+ d ^= c;
+ b ^= a;
+ a ^= t0;
+ t0 |= b;
+ b ^= d;
+ c |= a;
+ c &= t0;
+ a ^= b;
+ b &= c;
+ b ^= a;
+ a &= c;
+ t0 ^= a;
+ a = c;
+ c = d;
+ d = b;
+ b = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxE2(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxE2(T& a, T& b, T& c, T& d)
{
- T B4 = B0;
- B0 &= B2;
- B0 ^= B3;
- B2 ^= B1;
- B2 ^= B0;
- B3 |= B4;
- B3 ^= B1;
- B4 ^= B2;
- B1 = B3;
- B3 |= B4;
- B3 ^= B0;
- B0 &= B1;
- B4 ^= B0;
- B1 ^= B3;
- B1 ^= B4;
- B0 = B2;
- B2 = B1;
- B1 = B3;
- B3 = ~B4;
+ T t0 = a;
+ a &= c;
+ a ^= d;
+ c ^= b;
+ c ^= a;
+ d |= t0;
+ d ^= b;
+ t0 ^= c;
+ b = d;
+ d |= t0;
+ d ^= a;
+ a &= b;
+ t0 ^= a;
+ b ^= d;
+ b ^= t0;
+ a = c;
+ c = b;
+ b = d;
+ d = ~t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxE3(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxE3(T& a, T& b, T& c, T& d)
{
- T B4 = B0;
- B0 |= B3;
- B3 ^= B1;
- B1 &= B4;
- B4 ^= B2;
- B2 ^= B3;
- B3 &= B0;
- B4 |= B1;
- B3 ^= B4;
- B0 ^= B1;
- B4 &= B0;
- B1 ^= B3;
- B4 ^= B2;
- B1 |= B0;
- B1 ^= B2;
- B0 ^= B3;
- B2 = B1;
- B1 |= B3;
- B0 ^= B1;
- B1 = B2;
- B2 = B3;
- B3 = B4;
+ T t0 = a;
+ a |= d;
+ d ^= b;
+ b &= t0;
+ t0 ^= c;
+ c ^= d;
+ d &= a;
+ t0 |= b;
+ d ^= t0;
+ a ^= b;
+ t0 &= a;
+ b ^= d;
+ t0 ^= c;
+ b |= a;
+ b ^= c;
+ a ^= d;
+ c = b;
+ b |= d;
+ a ^= b;
+ b = c;
+ c = d;
+ d = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxE4(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxE4(T& a, T& b, T& c, T& d)
{
- B1 ^= B3;
- B3 = ~B3;
- B2 ^= B3;
- B3 ^= B0;
- T B4 = B1;
- B1 &= B3;
- B1 ^= B2;
- B4 ^= B3;
- B0 ^= B4;
- B2 &= B4;
- B2 ^= B0;
- B0 &= B1;
- B3 ^= B0;
- B4 |= B1;
- B4 ^= B0;
- B0 |= B3;
- B0 ^= B2;
- B2 &= B3;
- B0 = ~B0;
- B4 ^= B2;
- B2 = B0;
- B0 = B1;
- B1 = B4;
+ b ^= d;
+ d = ~d;
+ c ^= d;
+ d ^= a;
+ T t0 = b;
+ b &= d;
+ b ^= c;
+ t0 ^= d;
+ a ^= t0;
+ c &= t0;
+ c ^= a;
+ a &= b;
+ d ^= a;
+ t0 |= b;
+ t0 ^= a;
+ a |= d;
+ a ^= c;
+ c &= d;
+ a = ~a;
+ t0 ^= c;
+ c = a;
+ a = b;
+ b = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxE5(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxE5(T& a, T& b, T& c, T& d)
{
- B0 ^= B1;
- B1 ^= B3;
- B3 = ~B3;
- T B4 = B1;
- B1 &= B0;
- B2 ^= B3;
- B1 ^= B2;
- B2 |= B4;
- B4 ^= B3;
- B3 &= B1;
- B3 ^= B0;
- B4 ^= B1;
- B4 ^= B2;
- B2 ^= B0;
- B0 &= B3;
- B2 = ~B2;
- B0 ^= B4;
- B4 |= B3;
- B4 ^= B2;
- B2 = B0;
- B0 = B1;
- B1 = B3;
- B3 = B4;
+ a ^= b;
+ b ^= d;
+ d = ~d;
+ T t0 = b;
+ b &= a;
+ c ^= d;
+ b ^= c;
+ c |= t0;
+ t0 ^= d;
+ d &= b;
+ d ^= a;
+ t0 ^= b;
+ t0 ^= c;
+ c ^= a;
+ a &= d;
+ c = ~c;
+ a ^= t0;
+ t0 |= d;
+ t0 ^= c;
+ c = a;
+ a = b;
+ b = d;
+ d = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxE6(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxE6(T& a, T& b, T& c, T& d)
{
- B2 = ~B2;
- T B4 = B3;
- B3 &= B0;
- B0 ^= B4;
- B3 ^= B2;
- B2 |= B4;
- B1 ^= B3;
- B2 ^= B0;
- B0 |= B1;
- B2 ^= B1;
- B4 ^= B0;
- B0 |= B3;
- B0 ^= B2;
- B4 ^= B3;
- B4 ^= B0;
- B3 = ~B3;
- B2 &= B4;
- B3 ^= B2;
- B2 = B4;
+ c = ~c;
+ T t0 = d;
+ d &= a;
+ a ^= t0;
+ d ^= c;
+ c |= t0;
+ b ^= d;
+ c ^= a;
+ a |= b;
+ c ^= b;
+ t0 ^= a;
+ a |= d;
+ a ^= c;
+ t0 ^= d;
+ t0 ^= a;
+ d = ~d;
+ c &= t0;
+ d ^= c;
+ c = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxE7(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxE7(T& a, T& b, T& c, T& d)
{
- T B4 = B1;
- B1 |= B2;
- B1 ^= B3;
- B4 ^= B2;
- B2 ^= B1;
- B3 |= B4;
- B3 &= B0;
- B4 ^= B2;
- B3 ^= B1;
- B1 |= B4;
- B1 ^= B0;
- B0 |= B4;
- B0 ^= B2;
- B1 ^= B4;
- B2 ^= B1;
- B1 &= B0;
- B1 ^= B4;
- B2 = ~B2;
- B2 |= B0;
- B4 ^= B2;
- B2 = B1;
- B1 = B3;
- B3 = B0;
- B0 = B4;
+ T t0 = b;
+ b |= c;
+ b ^= d;
+ t0 ^= c;
+ c ^= b;
+ d |= t0;
+ d &= a;
+ t0 ^= c;
+ d ^= b;
+ b |= t0;
+ b ^= a;
+ a |= t0;
+ a ^= c;
+ b ^= t0;
+ c ^= b;
+ b &= a;
+ b ^= t0;
+ c = ~c;
+ c |= a;
+ t0 ^= c;
+ c = b;
+ b = d;
+ d = a;
+ a = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxD0(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxD0(T& a, T& b, T& c, T& d)
{
- B2 = ~B2;
- T B4 = B1;
- B1 |= B0;
- B4 = ~B4;
- B1 ^= B2;
- B2 |= B4;
- B1 ^= B3;
- B0 ^= B4;
- B2 ^= B0;
- B0 &= B3;
- B4 ^= B0;
- B0 |= B1;
- B0 ^= B2;
- B3 ^= B4;
- B2 ^= B1;
- B3 ^= B0;
- B3 ^= B1;
- B2 &= B3;
- B4 ^= B2;
- B2 = B1;
- B1 = B4;
+ c = ~c;
+ T t0 = b;
+ b |= a;
+ t0 = ~t0;
+ b ^= c;
+ c |= t0;
+ b ^= d;
+ a ^= t0;
+ c ^= a;
+ a &= d;
+ t0 ^= a;
+ a |= b;
+ a ^= c;
+ d ^= t0;
+ c ^= b;
+ d ^= a;
+ d ^= b;
+ c &= d;
+ t0 ^= c;
+ c = b;
+ b = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxD1(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxD1(T& a, T& b, T& c, T& d)
{
- T B4 = B1;
- B1 ^= B3;
- B3 &= B1;
- B4 ^= B2;
- B3 ^= B0;
- B0 |= B1;
- B2 ^= B3;
- B0 ^= B4;
- B0 |= B2;
- B1 ^= B3;
- B0 ^= B1;
- B1 |= B3;
- B1 ^= B0;
- B4 = ~B4;
- B4 ^= B1;
- B1 |= B0;
- B1 ^= B0;
- B1 |= B4;
- B3 ^= B1;
- B1 = B0;
- B0 = B4;
- B4 = B2;
- B2 = B3;
- B3 = B4;
+ T t0 = b;
+ b ^= d;
+ d &= b;
+ t0 ^= c;
+ d ^= a;
+ a |= b;
+ c ^= d;
+ a ^= t0;
+ a |= c;
+ b ^= d;
+ a ^= b;
+ b |= d;
+ b ^= a;
+ t0 = ~t0;
+ t0 ^= b;
+ b |= a;
+ b ^= a;
+ b |= t0;
+ d ^= b;
+ b = a;
+ a = t0;
+ t0 = c;
+ c = d;
+ d = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxD2(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxD2(T& a, T& b, T& c, T& d)
{
- B2 ^= B3;
- B3 ^= B0;
- T B4 = B3;
- B3 &= B2;
- B3 ^= B1;
- B1 |= B2;
- B1 ^= B4;
- B4 &= B3;
- B2 ^= B3;
- B4 &= B0;
- B4 ^= B2;
- B2 &= B1;
- B2 |= B0;
- B3 = ~B3;
- B2 ^= B3;
- B0 ^= B3;
- B0 &= B1;
- B3 ^= B4;
- B3 ^= B0;
- B0 = B1;
- B1 = B4;
+ c ^= d;
+ d ^= a;
+ T t0 = d;
+ d &= c;
+ d ^= b;
+ b |= c;
+ b ^= t0;
+ t0 &= d;
+ c ^= d;
+ t0 &= a;
+ t0 ^= c;
+ c &= b;
+ c |= a;
+ d = ~d;
+ c ^= d;
+ a ^= d;
+ a &= b;
+ d ^= t0;
+ d ^= a;
+ a = b;
+ b = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxD3(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxD3(T& a, T& b, T& c, T& d)
{
- T B4 = B2;
- B2 ^= B1;
- B0 ^= B2;
- B4 &= B2;
- B4 ^= B0;
- B0 &= B1;
- B1 ^= B3;
- B3 |= B4;
- B2 ^= B3;
- B0 ^= B3;
- B1 ^= B4;
- B3 &= B2;
- B3 ^= B1;
- B1 ^= B0;
- B1 |= B2;
- B0 ^= B3;
- B1 ^= B4;
- B0 ^= B1;
- B4 = B0;
- B0 = B2;
- B2 = B3;
- B3 = B4;
+ T t0 = c;
+ c ^= b;
+ a ^= c;
+ t0 &= c;
+ t0 ^= a;
+ a &= b;
+ b ^= d;
+ d |= t0;
+ c ^= d;
+ a ^= d;
+ b ^= t0;
+ d &= c;
+ d ^= b;
+ b ^= a;
+ b |= c;
+ a ^= d;
+ b ^= t0;
+ a ^= b;
+ t0 = a;
+ a = c;
+ c = d;
+ d = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxD4(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxD4(T& a, T& b, T& c, T& d)
{
- T B4 = B2;
- B2 &= B3;
- B2 ^= B1;
- B1 |= B3;
- B1 &= B0;
- B4 ^= B2;
- B4 ^= B1;
- B1 &= B2;
- B0 = ~B0;
- B3 ^= B4;
- B1 ^= B3;
- B3 &= B0;
- B3 ^= B2;
- B0 ^= B1;
- B2 &= B0;
- B3 ^= B0;
- B2 ^= B4;
- B2 |= B3;
- B3 ^= B0;
- B2 ^= B1;
- B1 = B3;
- B3 = B4;
+ T t0 = c;
+ c &= d;
+ c ^= b;
+ b |= d;
+ b &= a;
+ t0 ^= c;
+ t0 ^= b;
+ b &= c;
+ a = ~a;
+ d ^= t0;
+ b ^= d;
+ d &= a;
+ d ^= c;
+ a ^= b;
+ c &= a;
+ d ^= a;
+ c ^= t0;
+ c |= d;
+ d ^= a;
+ c ^= b;
+ b = d;
+ d = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxD5(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxD5(T& a, T& b, T& c, T& d)
{
- B1 = ~B1;
- T B4 = B3;
- B2 ^= B1;
- B3 |= B0;
- B3 ^= B2;
- B2 |= B1;
- B2 &= B0;
- B4 ^= B3;
- B2 ^= B4;
- B4 |= B0;
- B4 ^= B1;
- B1 &= B2;
- B1 ^= B3;
- B4 ^= B2;
- B3 &= B4;
- B4 ^= B1;
- B3 ^= B4;
- B4 = ~B4;
- B3 ^= B0;
- B0 = B1;
- B1 = B4;
- B4 = B3;
- B3 = B2;
- B2 = B4;
+ b = ~b;
+ T t0 = d;
+ c ^= b;
+ d |= a;
+ d ^= c;
+ c |= b;
+ c &= a;
+ t0 ^= d;
+ c ^= t0;
+ t0 |= a;
+ t0 ^= b;
+ b &= c;
+ b ^= d;
+ t0 ^= c;
+ d &= t0;
+ t0 ^= b;
+ d ^= t0;
+ t0 = ~t0;
+ d ^= a;
+ a = b;
+ b = t0;
+ t0 = d;
+ d = c;
+ c = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxD6(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxD6(T& a, T& b, T& c, T& d)
{
- B0 ^= B2;
- T B4 = B2;
- B2 &= B0;
- B4 ^= B3;
- B2 = ~B2;
- B3 ^= B1;
- B2 ^= B3;
- B4 |= B0;
- B0 ^= B2;
- B3 ^= B4;
- B4 ^= B1;
- B1 &= B3;
- B1 ^= B0;
- B0 ^= B3;
- B0 |= B2;
- B3 ^= B1;
- B4 ^= B0;
- B0 = B1;
- B1 = B2;
- B2 = B4;
+ a ^= c;
+ T t0 = c;
+ c &= a;
+ t0 ^= d;
+ c = ~c;
+ d ^= b;
+ c ^= d;
+ t0 |= a;
+ a ^= c;
+ d ^= t0;
+ t0 ^= b;
+ b &= d;
+ b ^= a;
+ a ^= d;
+ a |= c;
+ d ^= b;
+ t0 ^= a;
+ a = b;
+ b = c;
+ c = t0;
}
template<typename T>
-BOTAN_FORCE_INLINE void SBoxD7(T& B0, T& B1, T& B2, T& B3)
+BOTAN_FORCE_INLINE void SBoxD7(T& a, T& b, T& c, T& d)
{
- T B4 = B2;
- B2 ^= B0;
- B0 &= B3;
- B4 |= B3;
- B2 = ~B2;
- B3 ^= B1;
- B1 |= B0;
- B0 ^= B2;
- B2 &= B4;
- B3 &= B4;
- B1 ^= B2;
- B2 ^= B0;
- B0 |= B2;
- B4 ^= B1;
- B0 ^= B3;
- B3 ^= B4;
- B4 |= B0;
- B3 ^= B2;
- B4 ^= B2;
- B2 = B1;
- B1 = B0;
- B0 = B3;
- B3 = B4;
+ T t0 = c;
+ c ^= a;
+ a &= d;
+ t0 |= d;
+ c = ~c;
+ d ^= b;
+ b |= a;
+ a ^= c;
+ c &= t0;
+ d &= t0;
+ b ^= c;
+ c ^= a;
+ a |= c;
+ t0 ^= b;
+ a ^= d;
+ d ^= t0;
+ t0 |= a;
+ d ^= c;
+ t0 ^= c;
+ c = b;
+ b = a;
+ a = d;
+ d = t0;
}
#endif