aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/gost_28147
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/block/gost_28147')
-rw-r--r--src/lib/block/gost_28147/gost_28147.cpp48
-rw-r--r--src/lib/block/gost_28147/gost_28147.h14
2 files changed, 31 insertions, 31 deletions
diff --git a/src/lib/block/gost_28147/gost_28147.cpp b/src/lib/block/gost_28147/gost_28147.cpp
index b8c3b7280..5fa232478 100644
--- a/src/lib/block/gost_28147/gost_28147.cpp
+++ b/src/lib/block/gost_28147/gost_28147.cpp
@@ -12,12 +12,12 @@ namespace Botan {
byte GOST_28147_89_Params::sbox_entry(size_t row, size_t col) const
{
- byte x = sboxes[4 * col + (row / 2)];
+ byte x = m_sboxes[4 * col + (row / 2)];
return (row % 2 == 0) ? (x >> 4) : (x & 0x0F);
}
-GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : name(n)
+GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : m_name(n)
{
// Encoded in the packed fromat from RFC 4357
@@ -39,18 +39,18 @@ GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : name(n)
0x03, 0x25, 0xEB, 0xFE, 0x9C, 0x6D, 0xF8, 0x6D, 0x2E, 0xAB, 0xDE,
0x20, 0xBA, 0x89, 0x3C, 0x92, 0xF8, 0xD3, 0x53, 0xBC };
- if(name == "R3411_94_TestParam")
- sboxes = GOST_R_3411_TEST_PARAMS;
- else if(name == "R3411_CryptoPro")
- sboxes = GOST_R_3411_CRYPTOPRO_PARAMS;
+ if(m_name == "R3411_94_TestParam")
+ m_sboxes = GOST_R_3411_TEST_PARAMS;
+ else if(m_name == "R3411_CryptoPro")
+ m_sboxes = GOST_R_3411_CRYPTOPRO_PARAMS;
else
- throw Invalid_Argument("GOST_28147_89_Params: Unknown " + name);
+ throw Invalid_Argument("GOST_28147_89_Params: Unknown " + m_name);
}
/*
* GOST Constructor
*/
-GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : SBOX(1024)
+GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : m_SBOX(1024)
{
// Convert the parallel 4x4 sboxes into larger word-based sboxes
for(size_t i = 0; i != 4; ++i)
@@ -58,7 +58,7 @@ GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : SBOX(1024)
{
const u32bit T = (param.sbox_entry(2*i , j % 16)) |
(param.sbox_entry(2*i+1, j / 16) << 4);
- SBOX[256*i+j] = rotate_left(T, (11+8*i) % 32);
+ m_SBOX[256*i+j] = rotate_left(T, (11+8*i) % 32);
}
}
@@ -71,9 +71,9 @@ std::string GOST_28147_89::name() const
constructor, but can't break binary compat.
*/
std::string sbox_name = "";
- if(SBOX[0] == 0x00072000)
+ if(m_SBOX[0] == 0x00072000)
sbox_name = "R3411_94_TestParam";
- else if(SBOX[0] == 0x0002D000)
+ else if(m_SBOX[0] == 0x0002D000)
sbox_name = "R3411_CryptoPro";
else
throw Internal_Error("GOST-28147 unrecognized sbox value");
@@ -86,17 +86,17 @@ std::string GOST_28147_89::name() const
*/
#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]; \
+ u32bit T0 = N1 + m_EK[R1]; \
+ N2 ^= m_SBOX[get_byte(3, T0)] | \
+ m_SBOX[get_byte(2, T0)+256] | \
+ m_SBOX[get_byte(1, T0)+512] | \
+ m_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]; \
+ u32bit T1 = N2 + m_EK[R2]; \
+ N1 ^= m_SBOX[get_byte(3, T1)] | \
+ m_SBOX[get_byte(2, T1)+256] | \
+ m_SBOX[get_byte(1, T1)+512] | \
+ m_SBOX[get_byte(0, T1)+768]; \
} while(0)
/*
@@ -163,14 +163,14 @@ void GOST_28147_89::decrypt_n(const byte in[], byte out[], size_t blocks) const
*/
void GOST_28147_89::key_schedule(const byte key[], size_t)
{
- EK.resize(8);
+ m_EK.resize(8);
for(size_t i = 0; i != 8; ++i)
- EK[i] = load_le<u32bit>(key, i);
+ m_EK[i] = load_le<u32bit>(key, i);
}
void GOST_28147_89::clear()
{
- zap(EK);
+ zap(m_EK);
}
}
diff --git a/src/lib/block/gost_28147/gost_28147.h b/src/lib/block/gost_28147/gost_28147.h
index 3cf1c4578..d87559b57 100644
--- a/src/lib/block/gost_28147/gost_28147.h
+++ b/src/lib/block/gost_28147/gost_28147.h
@@ -31,7 +31,7 @@ class BOTAN_DLL GOST_28147_89_Params
/**
* @return name of this parameter set
*/
- std::string param_name() const { return name; }
+ std::string param_name() const { return m_name; }
/**
* Default GOST parameters are the ones given in GOST R 34.11 for
@@ -42,8 +42,8 @@ class BOTAN_DLL GOST_28147_89_Params
*/
GOST_28147_89_Params(const std::string& name = "R3411_94_TestParam");
private:
- const byte* sboxes;
- std::string name;
+ const byte* m_sboxes;
+ std::string m_name;
};
/**
@@ -58,7 +58,7 @@ class BOTAN_DLL GOST_28147_89 : public Block_Cipher_Fixed_Params<8, 32>
void clear() override;
std::string name() const override;
- BlockCipher* clone() const override { return new GOST_28147_89(SBOX); }
+ BlockCipher* clone() const override { return new GOST_28147_89(m_SBOX); }
/**
* @param params the sbox parameters to use
@@ -66,7 +66,7 @@ class BOTAN_DLL GOST_28147_89 : public Block_Cipher_Fixed_Params<8, 32>
GOST_28147_89(const GOST_28147_89_Params& params);
private:
GOST_28147_89(const std::vector<u32bit>& other_SBOX) :
- SBOX(other_SBOX), EK(8) {}
+ m_SBOX(other_SBOX), m_EK(8) {}
void key_schedule(const byte[], size_t) override;
@@ -74,9 +74,9 @@ class BOTAN_DLL GOST_28147_89 : public Block_Cipher_Fixed_Params<8, 32>
* The sbox is not secret, this is just a larger expansion of it
* which we generate at runtime for faster execution
*/
- std::vector<u32bit> SBOX;
+ std::vector<u32bit> m_SBOX;
- secure_vector<u32bit> EK;
+ secure_vector<u32bit> m_EK;
};
}