aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/gost_28147
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-04-07 18:40:33 +0000
committerlloyd <[email protected]>2009-04-07 18:40:33 +0000
commit3a847f4e5ce8ce9d88e14c1d00b25961ec3bef01 (patch)
treeda352ea682b1268fd13f7f80bd68df3777368b1a /src/block/gost_28147
parent62a03ddcb34797e02205457354e25211251b9c67 (diff)
Clean up the GOST_2ROUND macro a bit. Put in do/while block so it is a
statement (at least as far as the calling code is concerned)
Diffstat (limited to 'src/block/gost_28147')
-rw-r--r--src/block/gost_28147/gost_28147.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/block/gost_28147/gost_28147.cpp b/src/block/gost_28147/gost_28147.cpp
index 18fd38d30..bfd092c56 100644
--- a/src/block/gost_28147/gost_28147.cpp
+++ b/src/block/gost_28147/gost_28147.cpp
@@ -53,6 +53,7 @@ GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : name(n)
GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) :
BlockCipher(8, 32)
{
+ // Convert the parallel 4x4 sboxes into larger word-based sboxes
for(size_t i = 0; i != 4; ++i)
for(size_t j = 0; j != 256; ++j)
{
@@ -66,19 +67,19 @@ GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) :
* Two rounds of GOST
*/
#define GOST_2ROUND(N1, N2, R1, R2) \
- { \
+ do { \
u32bit T0 = N1 + EK[R1]; \
N2 ^= SBOX[get_byte(3, T0)] | \
SBOX[get_byte(2, T0)+256] | \
SBOX[get_byte(1, T0)+512] | \
SBOX[get_byte(0, T0)+768]; \
\
- T0 = N2 + EK[R2]; \
- N1 ^= SBOX[get_byte(3, T0)] | \
- SBOX[get_byte(2, T0)+256] | \
- SBOX[get_byte(1, T0)+512] | \
- SBOX[get_byte(0, T0)+768]; \
- }
+ u32bit T1 = N2 + EK[R2]; \
+ N1 ^= SBOX[get_byte(3, T1)] | \
+ SBOX[get_byte(2, T1)+256] | \
+ SBOX[get_byte(1, T1)+512] | \
+ SBOX[get_byte(0, T1)+768]; \
+ } while(0)
/*
* GOST Encryption