aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/gost_28147/gost_28147.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-11 15:28:38 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:48:24 -0500
commitf3cb3edb512bdcab498d825886c3366c341b3f78 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/block/gost_28147/gost_28147.cpp
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
Diffstat (limited to 'src/lib/block/gost_28147/gost_28147.cpp')
-rw-r--r--src/lib/block/gost_28147/gost_28147.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/lib/block/gost_28147/gost_28147.cpp b/src/lib/block/gost_28147/gost_28147.cpp
index 5fa232478..f73ac5910 100644
--- a/src/lib/block/gost_28147/gost_28147.cpp
+++ b/src/lib/block/gost_28147/gost_28147.cpp
@@ -10,9 +10,9 @@
namespace Botan {
-byte GOST_28147_89_Params::sbox_entry(size_t row, size_t col) const
+uint8_t GOST_28147_89_Params::sbox_entry(size_t row, size_t col) const
{
- byte x = m_sboxes[4 * col + (row / 2)];
+ uint8_t x = m_sboxes[4 * col + (row / 2)];
return (row % 2 == 0) ? (x >> 4) : (x & 0x0F);
}
@@ -22,7 +22,7 @@ GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : m_name(n)
// Encoded in the packed fromat from RFC 4357
// GostR3411_94_TestParamSet (OID 1.2.643.2.2.31.0)
- static const byte GOST_R_3411_TEST_PARAMS[64] = {
+ static const uint8_t GOST_R_3411_TEST_PARAMS[64] = {
0x4E, 0x57, 0x64, 0xD1, 0xAB, 0x8D, 0xCB, 0xBF, 0x94, 0x1A, 0x7A,
0x4D, 0x2C, 0xD1, 0x10, 0x10, 0xD6, 0xA0, 0x57, 0x35, 0x8D, 0x38,
0xF2, 0xF7, 0x0F, 0x49, 0xD1, 0x5A, 0xEA, 0x2F, 0x8D, 0x94, 0x62,
@@ -31,7 +31,7 @@ GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : m_name(n)
0x8B, 0x55, 0x95, 0xBF, 0x28, 0x39, 0xB3, 0x2E, 0xCC };
// GostR3411-94-CryptoProParamSet (OID 1.2.643.2.2.31.1)
- static const byte GOST_R_3411_CRYPTOPRO_PARAMS[64] = {
+ static const uint8_t GOST_R_3411_CRYPTOPRO_PARAMS[64] = {
0xA5, 0x74, 0x77, 0xD1, 0x4F, 0xFA, 0x66, 0xE3, 0x54, 0xC7, 0x42,
0x4A, 0x60, 0xEC, 0xB4, 0x19, 0x82, 0x90, 0x9D, 0x75, 0x1D, 0x4F,
0xC9, 0x0B, 0x3B, 0x12, 0x2F, 0x54, 0x79, 0x08, 0xA0, 0xAF, 0xD1,
@@ -56,7 +56,7 @@ GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : m_SBOX(1024)
for(size_t i = 0; i != 4; ++i)
for(size_t j = 0; j != 256; ++j)
{
- const u32bit T = (param.sbox_entry(2*i , j % 16)) |
+ const uint32_t T = (param.sbox_entry(2*i , j % 16)) |
(param.sbox_entry(2*i+1, j / 16) << 4);
m_SBOX[256*i+j] = rotate_left(T, (11+8*i) % 32);
}
@@ -86,13 +86,13 @@ std::string GOST_28147_89::name() const
*/
#define GOST_2ROUND(N1, N2, R1, R2) \
do { \
- u32bit T0 = N1 + m_EK[R1]; \
+ uint32_t 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 + m_EK[R2]; \
+ uint32_t 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] | \
@@ -102,12 +102,12 @@ std::string GOST_28147_89::name() const
/*
* GOST Encryption
*/
-void GOST_28147_89::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void GOST_28147_89::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit N1 = load_le<u32bit>(in, 0);
- u32bit N2 = load_le<u32bit>(in, 1);
+ uint32_t N1 = load_le<uint32_t>(in, 0);
+ uint32_t N2 = load_le<uint32_t>(in, 1);
for(size_t j = 0; j != 3; ++j)
{
@@ -132,12 +132,12 @@ void GOST_28147_89::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* GOST Decryption
*/
-void GOST_28147_89::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void GOST_28147_89::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit N1 = load_le<u32bit>(in, 0);
- u32bit N2 = load_le<u32bit>(in, 1);
+ uint32_t N1 = load_le<uint32_t>(in, 0);
+ uint32_t N2 = load_le<uint32_t>(in, 1);
GOST_2ROUND(N1, N2, 0, 1);
GOST_2ROUND(N1, N2, 2, 3);
@@ -161,11 +161,11 @@ void GOST_28147_89::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* GOST Key Schedule
*/
-void GOST_28147_89::key_schedule(const byte key[], size_t)
+void GOST_28147_89::key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(8);
for(size_t i = 0; i != 8; ++i)
- m_EK[i] = load_le<u32bit>(key, i);
+ m_EK[i] = load_le<uint32_t>(key, i);
}
void GOST_28147_89::clear()