aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block
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
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')
-rw-r--r--src/lib/block/aes/aes.cpp130
-rw-r--r--src/lib/block/aes/aes.h66
-rw-r--r--src/lib/block/aes/aes_ni/aes_ni.cpp20
-rw-r--r--src/lib/block/aes/aes_ssse3/aes_ssse3.cpp26
-rw-r--r--src/lib/block/block_cipher.h24
-rw-r--r--src/lib/block/blowfish/blowfish.cpp66
-rw-r--r--src/lib/block/blowfish/blowfish.h22
-rw-r--r--src/lib/block/camellia/camellia.cpp170
-rw-r--r--src/lib/block/camellia/camellia.h24
-rw-r--r--src/lib/block/cascade/cascade.cpp8
-rw-r--r--src/lib/block/cascade/cascade.h6
-rw-r--r--src/lib/block/cast/cast128.cpp46
-rw-r--r--src/lib/block/cast/cast128.h14
-rw-r--r--src/lib/block/cast/cast256.cpp42
-rw-r--r--src/lib/block/cast/cast256.h10
-rw-r--r--src/lib/block/cast/cast_sboxes.h8
-rw-r--r--src/lib/block/des/des.cpp56
-rw-r--r--src/lib/block/des/des.h40
-rw-r--r--src/lib/block/des/des_tab.cpp24
-rw-r--r--src/lib/block/des/desx.cpp6
-rw-r--r--src/lib/block/des/desx.h8
-rw-r--r--src/lib/block/gost_28147/gost_28147.cpp30
-rw-r--r--src/lib/block/gost_28147/gost_28147.h16
-rw-r--r--src/lib/block/idea/idea.cpp36
-rw-r--r--src/lib/block/idea/idea.h10
-rw-r--r--src/lib/block/idea/idea_sse2/idea_sse2.cpp4
-rw-r--r--src/lib/block/kasumi/kasumi.cpp48
-rw-r--r--src/lib/block/kasumi/kasumi.h8
-rw-r--r--src/lib/block/lion/lion.cpp14
-rw-r--r--src/lib/block/lion/lion.h8
-rw-r--r--src/lib/block/misty1/misty1.cpp48
-rw-r--r--src/lib/block/misty1/misty1.h8
-rw-r--r--src/lib/block/noekeon/noekeon.cpp50
-rw-r--r--src/lib/block/noekeon/noekeon.h14
-rw-r--r--src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp4
-rw-r--r--src/lib/block/seed/seed.cpp44
-rw-r--r--src/lib/block/seed/seed.h8
-rw-r--r--src/lib/block/serpent/serpent.cpp24
-rw-r--r--src/lib/block/serpent/serpent.h16
-rw-r--r--src/lib/block/serpent/serpent_simd/serpent_simd.cpp4
-rw-r--r--src/lib/block/threefish/threefish.cpp38
-rw-r--r--src/lib/block/threefish/threefish.h24
-rw-r--r--src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp12
-rw-r--r--src/lib/block/twofish/twofish.cpp38
-rw-r--r--src/lib/block/twofish/twofish.h30
-rw-r--r--src/lib/block/twofish/twofish_tab.cpp18
-rw-r--r--src/lib/block/xtea/xtea.cpp24
-rw-r--r--src/lib/block/xtea/xtea.h10
48 files changed, 702 insertions, 702 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp
index f0e66bc1b..6b9d56665 100644
--- a/src/lib/block/aes/aes.cpp
+++ b/src/lib/block/aes/aes.cpp
@@ -47,7 +47,7 @@ namespace Botan {
namespace {
-const byte SE[256] = {
+const uint8_t SE[256] = {
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B,
0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0,
0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26,
@@ -71,7 +71,7 @@ const byte SE[256] = {
0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F,
0xB0, 0x54, 0xBB, 0x16 };
-const byte SD[256] = {
+const uint8_t SD[256] = {
0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E,
0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87,
0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32,
@@ -95,24 +95,24 @@ const byte SD[256] = {
0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63,
0x55, 0x21, 0x0C, 0x7D };
-inline byte xtime(byte s) { return (s << 1) ^ ((s >> 7) * 0x1B); }
-inline byte xtime4(byte s) { return xtime(xtime(s)); }
-inline byte xtime8(byte s) { return xtime(xtime(xtime(s))); }
+inline uint8_t xtime(uint8_t s) { return (s << 1) ^ ((s >> 7) * 0x1B); }
+inline uint8_t xtime4(uint8_t s) { return xtime(xtime(s)); }
+inline uint8_t xtime8(uint8_t s) { return xtime(xtime(xtime(s))); }
-inline byte xtime3(byte s) { return xtime(s) ^ s; }
-inline byte xtime9(byte s) { return xtime8(s) ^ s; }
-inline byte xtime11(byte s) { return xtime8(s) ^ xtime(s) ^ s; }
-inline byte xtime13(byte s) { return xtime8(s) ^ xtime4(s) ^ s; }
-inline byte xtime14(byte s) { return xtime8(s) ^ xtime4(s) ^ xtime(s); }
+inline uint8_t xtime3(uint8_t s) { return xtime(s) ^ s; }
+inline uint8_t xtime9(uint8_t s) { return xtime8(s) ^ s; }
+inline uint8_t xtime11(uint8_t s) { return xtime8(s) ^ xtime(s) ^ s; }
+inline uint8_t xtime13(uint8_t s) { return xtime8(s) ^ xtime4(s) ^ s; }
+inline uint8_t xtime14(uint8_t s) { return xtime8(s) ^ xtime4(s) ^ xtime(s); }
-const std::vector<u32bit>& AES_TE()
+const std::vector<uint32_t>& AES_TE()
{
auto compute_TE = []() {
- std::vector<u32bit> TE(1024);
+ std::vector<uint32_t> TE(1024);
for(size_t i = 0; i != 256; ++i)
{
- const byte s = SE[i];
- const u32bit x = make_u32bit(xtime(s), s, s, xtime3(s));
+ const uint8_t s = SE[i];
+ const uint32_t x = make_uint32(xtime(s), s, s, xtime3(s));
TE[i] = x;
TE[i+256] = rotate_right(x, 8);
@@ -122,18 +122,18 @@ const std::vector<u32bit>& AES_TE()
return TE;
};
- static const std::vector<u32bit> TE = compute_TE();
+ static const std::vector<uint32_t> TE = compute_TE();
return TE;
}
-const std::vector<u32bit>& AES_TD()
+const std::vector<uint32_t>& AES_TD()
{
auto compute_TD = []() {
- std::vector<u32bit> TD(1024);
+ std::vector<uint32_t> TD(1024);
for(size_t i = 0; i != 256; ++i)
{
- const byte s = SD[i];
- const u32bit x = make_u32bit(xtime14(s), xtime9(s), xtime13(s), xtime11(s));
+ const uint8_t s = SD[i];
+ const uint32_t x = make_uint32(xtime14(s), xtime9(s), xtime13(s), xtime11(s));
TD[i] = x;
TD[i+256] = rotate_right(x, 8);
@@ -142,27 +142,27 @@ const std::vector<u32bit>& AES_TD()
}
return TD;
};
- static const std::vector<u32bit> TD = compute_TD();
+ static const std::vector<uint32_t> TD = compute_TD();
return TD;
}
/*
* AES Encryption
*/
-void aes_encrypt_n(const byte in[], byte out[],
+void aes_encrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks,
- const secure_vector<u32bit>& EK,
- const secure_vector<byte>& ME)
+ const secure_vector<uint32_t>& EK,
+ const secure_vector<uint8_t>& ME)
{
BOTAN_ASSERT(EK.size() && ME.size() == 16, "Key was set");
const size_t cache_line_size = CPUID::cache_line_size();
- const std::vector<u32bit>& TE = AES_TE();
+ const std::vector<uint32_t>& TE = AES_TE();
// Hit every cache line of TE
- u32bit Z = 0;
- for(size_t i = 0; i < TE.size(); i += cache_line_size / sizeof(u32bit))
+ uint32_t Z = 0;
+ for(size_t i = 0; i < TE.size(); i += cache_line_size / sizeof(uint32_t))
{
Z |= TE[i];
}
@@ -170,7 +170,7 @@ void aes_encrypt_n(const byte in[], byte out[],
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit T0, T1, T2, T3;
+ uint32_t T0, T1, T2, T3;
load_be(in + 16*i, T0, T1, T2, T3);
T0 ^= EK[0];
@@ -188,22 +188,22 @@ void aes_encrypt_n(const byte in[], byte out[],
* vulnerable.
*/
- u32bit B0 = TE[get_byte(0, T0)] ^
+ uint32_t B0 = TE[get_byte(0, T0)] ^
rotate_right(TE[get_byte(1, T1)], 8) ^
rotate_right(TE[get_byte(2, T2)], 16) ^
rotate_right(TE[get_byte(3, T3)], 24) ^ EK[4];
- u32bit B1 = TE[get_byte(0, T1)] ^
+ uint32_t B1 = TE[get_byte(0, T1)] ^
rotate_right(TE[get_byte(1, T2)], 8) ^
rotate_right(TE[get_byte(2, T3)], 16) ^
rotate_right(TE[get_byte(3, T0)], 24) ^ EK[5];
- u32bit B2 = TE[get_byte(0, T2)] ^
+ uint32_t B2 = TE[get_byte(0, T2)] ^
rotate_right(TE[get_byte(1, T3)], 8) ^
rotate_right(TE[get_byte(2, T0)], 16) ^
rotate_right(TE[get_byte(3, T1)], 24) ^ EK[6];
- u32bit B3 = TE[get_byte(0, T3)] ^
+ uint32_t B3 = TE[get_byte(0, T3)] ^
rotate_right(TE[get_byte(1, T0)], 8) ^
rotate_right(TE[get_byte(2, T1)], 16) ^
rotate_right(TE[get_byte(3, T2)], 24) ^ EK[7];
@@ -251,17 +251,17 @@ void aes_encrypt_n(const byte in[], byte out[],
/*
* AES Decryption
*/
-void aes_decrypt_n(const byte in[], byte out[], size_t blocks,
- const secure_vector<u32bit>& DK,
- const secure_vector<byte>& MD)
+void aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks,
+ const secure_vector<uint32_t>& DK,
+ const secure_vector<uint8_t>& MD)
{
BOTAN_ASSERT(DK.size() && MD.size() == 16, "Key was set");
const size_t cache_line_size = CPUID::cache_line_size();
- const std::vector<u32bit>& TD = AES_TD();
+ const std::vector<uint32_t>& TD = AES_TD();
- u32bit Z = 0;
- for(size_t i = 0; i < TD.size(); i += cache_line_size / sizeof(u32bit))
+ uint32_t Z = 0;
+ for(size_t i = 0; i < TD.size(); i += cache_line_size / sizeof(uint32_t))
{
Z |= TD[i];
}
@@ -269,29 +269,29 @@ void aes_decrypt_n(const byte in[], byte out[], size_t blocks,
for(size_t i = 0; i != blocks; ++i)
{
- u32bit T0 = load_be<u32bit>(in, 0) ^ DK[0];
- u32bit T1 = load_be<u32bit>(in, 1) ^ DK[1];
- u32bit T2 = load_be<u32bit>(in, 2) ^ DK[2];
- u32bit T3 = load_be<u32bit>(in, 3) ^ DK[3];
+ uint32_t T0 = load_be<uint32_t>(in, 0) ^ DK[0];
+ uint32_t T1 = load_be<uint32_t>(in, 1) ^ DK[1];
+ uint32_t T2 = load_be<uint32_t>(in, 2) ^ DK[2];
+ uint32_t T3 = load_be<uint32_t>(in, 3) ^ DK[3];
T0 ^= Z;
- u32bit B0 = TD[get_byte(0, T0)] ^
+ uint32_t B0 = TD[get_byte(0, T0)] ^
rotate_right(TD[get_byte(1, T3)], 8) ^
rotate_right(TD[get_byte(2, T2)], 16) ^
rotate_right(TD[get_byte(3, T1)], 24) ^ DK[4];
- u32bit B1 = TD[get_byte(0, T1)] ^
+ uint32_t B1 = TD[get_byte(0, T1)] ^
rotate_right(TD[get_byte(1, T0)], 8) ^
rotate_right(TD[get_byte(2, T3)], 16) ^
rotate_right(TD[get_byte(3, T2)], 24) ^ DK[5];
- u32bit B2 = TD[get_byte(0, T2)] ^
+ uint32_t B2 = TD[get_byte(0, T2)] ^
rotate_right(TD[get_byte(1, T1)], 8) ^
rotate_right(TD[get_byte(2, T0)], 16) ^
rotate_right(TD[get_byte(3, T3)], 24) ^ DK[6];
- u32bit B3 = TD[get_byte(0, T3)] ^
+ uint32_t B3 = TD[get_byte(0, T3)] ^
rotate_right(TD[get_byte(1, T2)], 8) ^
rotate_right(TD[get_byte(2, T1)], 16) ^
rotate_right(TD[get_byte(3, T0)], 24) ^ DK[7];
@@ -339,19 +339,19 @@ void aes_decrypt_n(const byte in[], byte out[], size_t blocks,
}
}
-void aes_key_schedule(const byte key[], size_t length,
- secure_vector<u32bit>& EK,
- secure_vector<u32bit>& DK,
- secure_vector<byte>& ME,
- secure_vector<byte>& MD)
+void aes_key_schedule(const uint8_t key[], size_t length,
+ secure_vector<uint32_t>& EK,
+ secure_vector<uint32_t>& DK,
+ secure_vector<uint8_t>& ME,
+ secure_vector<uint8_t>& MD)
{
- static const u32bit RC[10] = {
+ static const uint32_t RC[10] = {
0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000,
0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000 };
const size_t rounds = (length / 4) + 6;
- secure_vector<u32bit> XEK(length + 32), XDK(length + 32);
+ secure_vector<uint32_t> XEK(length + 32), XDK(length + 32);
const size_t X = length / 4;
@@ -359,12 +359,12 @@ void aes_key_schedule(const byte key[], size_t length,
BOTAN_ASSERT(X == 4 || X == 6 || X == 8, "Valid AES key size");
for(size_t i = 0; i != X; ++i)
- XEK[i] = load_be<u32bit>(key, i);
+ XEK[i] = load_be<uint32_t>(key, i);
for(size_t i = X; i < 4*(rounds+1); i += X)
{
XEK[i] = XEK[i-X] ^ RC[(i-X)/X] ^
- make_u32bit(SE[get_byte(1, XEK[i-1])],
+ make_uint32(SE[get_byte(1, XEK[i-1])],
SE[get_byte(2, XEK[i-1])],
SE[get_byte(3, XEK[i-1])],
SE[get_byte(0, XEK[i-1])]);
@@ -374,7 +374,7 @@ void aes_key_schedule(const byte key[], size_t length,
XEK[i+j] = XEK[i+j-X];
if(X == 8 && j == 4)
- XEK[i+j] ^= make_u32bit(SE[get_byte(0, XEK[i+j-1])],
+ XEK[i+j] ^= make_uint32(SE[get_byte(0, XEK[i+j-1])],
SE[get_byte(1, XEK[i+j-1])],
SE[get_byte(2, XEK[i+j-1])],
SE[get_byte(3, XEK[i+j-1])]);
@@ -383,7 +383,7 @@ void aes_key_schedule(const byte key[], size_t length,
}
}
- const std::vector<u32bit>& TD = AES_TD();
+ const std::vector<uint32_t>& TD = AES_TD();
for(size_t i = 0; i != 4*(rounds+1); i += 4)
{
@@ -439,7 +439,7 @@ std::string AES_128::provider() const { return aes_provider(); }
std::string AES_192::provider() const { return aes_provider(); }
std::string AES_256::provider() const { return aes_provider(); }
-void AES_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -458,7 +458,7 @@ void AES_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
aes_encrypt_n(in, out, blocks, m_EK, m_ME);
}
-void AES_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -477,7 +477,7 @@ void AES_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
aes_decrypt_n(in, out, blocks, m_DK, m_MD);
}
-void AES_128::key_schedule(const byte key[], size_t length)
+void AES_128::key_schedule(const uint8_t key[], size_t length)
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -504,7 +504,7 @@ void AES_128::clear()
zap(m_MD);
}
-void AES_192::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -523,7 +523,7 @@ void AES_192::encrypt_n(const byte in[], byte out[], size_t blocks) const
aes_encrypt_n(in, out, blocks, m_EK, m_ME);
}
-void AES_192::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -542,7 +542,7 @@ void AES_192::decrypt_n(const byte in[], byte out[], size_t blocks) const
aes_decrypt_n(in, out, blocks, m_DK, m_MD);
}
-void AES_192::key_schedule(const byte key[], size_t length)
+void AES_192::key_schedule(const uint8_t key[], size_t length)
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -569,7 +569,7 @@ void AES_192::clear()
zap(m_MD);
}
-void AES_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -588,7 +588,7 @@ void AES_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
aes_encrypt_n(in, out, blocks, m_EK, m_ME);
}
-void AES_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
@@ -607,7 +607,7 @@ void AES_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
aes_decrypt_n(in, out, blocks, m_DK, m_MD);
}
-void AES_256::key_schedule(const byte key[], size_t length)
+void AES_256::key_schedule(const uint8_t key[], size_t length)
{
#if defined(BOTAN_HAS_AES_NI)
if(CPUID::has_aes_ni())
diff --git a/src/lib/block/aes/aes.h b/src/lib/block/aes/aes.h
index 6bd38cada..52f877e36 100644
--- a/src/lib/block/aes/aes.h
+++ b/src/lib/block/aes/aes.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -27,22 +27,22 @@ class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
std::string name() const override { return "AES-128"; }
BlockCipher* clone() const override { return new AES_128; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
#if defined(BOTAN_HAS_AES_SSSE3)
- void ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_key_schedule(const byte key[], size_t length);
+ void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_key_schedule(const uint8_t key[], size_t length);
#endif
#if defined(BOTAN_HAS_AES_NI)
- void aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_key_schedule(const byte key[], size_t length);
+ void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_key_schedule(const uint8_t key[], size_t length);
#endif
- secure_vector<u32bit> m_EK, m_DK;
- secure_vector<byte> m_ME, m_MD;
+ secure_vector<uint32_t> m_EK, m_DK;
+ secure_vector<uint8_t> m_ME, m_MD;
};
/**
@@ -51,8 +51,8 @@ class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -61,21 +61,21 @@ class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
BlockCipher* clone() const override { return new AES_192; }
private:
#if defined(BOTAN_HAS_AES_SSSE3)
- void ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_key_schedule(const byte key[], size_t length);
+ void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_key_schedule(const uint8_t key[], size_t length);
#endif
#if defined(BOTAN_HAS_AES_NI)
- void aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_key_schedule(const byte key[], size_t length);
+ void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_key_schedule(const uint8_t key[], size_t length);
#endif
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u32bit> m_EK, m_DK;
- secure_vector<byte> m_ME, m_MD;
+ secure_vector<uint32_t> m_EK, m_DK;
+ secure_vector<uint8_t> m_ME, m_MD;
};
/**
@@ -84,8 +84,8 @@ class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
class BOTAN_DLL AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -95,21 +95,21 @@ class BOTAN_DLL AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
BlockCipher* clone() const override { return new AES_256; }
private:
#if defined(BOTAN_HAS_AES_SSSE3)
- void ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void ssse3_key_schedule(const byte key[], size_t length);
+ void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void ssse3_key_schedule(const uint8_t key[], size_t length);
#endif
#if defined(BOTAN_HAS_AES_NI)
- void aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const;
- void aesni_key_schedule(const byte key[], size_t length);
+ void aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void aesni_key_schedule(const uint8_t key[], size_t length);
#endif
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u32bit> m_EK, m_DK;
- secure_vector<byte> m_ME, m_MD;
+ secure_vector<uint32_t> m_EK, m_DK;
+ secure_vector<uint8_t> m_ME, m_MD;
};
}
diff --git a/src/lib/block/aes/aes_ni/aes_ni.cpp b/src/lib/block/aes/aes_ni/aes_ni.cpp
index 7518a6cf2..52f4e44a2 100644
--- a/src/lib/block/aes/aes_ni/aes_ni.cpp
+++ b/src/lib/block/aes/aes_ni/aes_ni.cpp
@@ -25,7 +25,7 @@ __m128i aes_128_key_expansion(__m128i key, __m128i key_with_rcon)
BOTAN_FUNC_ISA("ssse3")
void aes_192_key_expansion(__m128i* K1, __m128i* K2, __m128i key2_with_rcon,
- u32bit out[], bool last)
+ uint32_t out[], bool last)
{
__m128i key1 = *K1;
__m128i key2 = *K2;
@@ -107,7 +107,7 @@ __m128i aes_256_key_expansion(__m128i key, __m128i key2)
* AES-128 Encryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_128::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -184,7 +184,7 @@ void AES_128::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-128 Decryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_128::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -261,7 +261,7 @@ void AES_128::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-128 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_128::aesni_key_schedule(const byte key[], size_t)
+void AES_128::aesni_key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(44);
m_DK.resize(44);
@@ -314,7 +314,7 @@ void AES_128::aesni_key_schedule(const byte key[], size_t)
* AES-192 Encryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_192::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -397,7 +397,7 @@ void AES_192::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-192 Decryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_192::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -480,7 +480,7 @@ void AES_192::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-192 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_192::aesni_key_schedule(const byte key[], size_t)
+void AES_192::aesni_key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(52);
m_DK.resize(52);
@@ -530,7 +530,7 @@ void AES_192::aesni_key_schedule(const byte key[], size_t)
* AES-256 Encryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_256::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::aesni_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -619,7 +619,7 @@ void AES_256::aesni_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-256 Decryption
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_256::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::aesni_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -708,7 +708,7 @@ void AES_256::aesni_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-256 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3,aes")
-void AES_256::aesni_key_schedule(const byte key[], size_t)
+void AES_256::aesni_key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(60);
m_DK.resize(60);
diff --git a/src/lib/block/aes/aes_ssse3/aes_ssse3.cpp b/src/lib/block/aes/aes_ssse3/aes_ssse3.cpp
index d8c7e7314..6dcf1e794 100644
--- a/src/lib/block/aes/aes_ssse3/aes_ssse3.cpp
+++ b/src/lib/block/aes/aes_ssse3/aes_ssse3.cpp
@@ -65,7 +65,7 @@ __m128i aes_schedule_transform(__m128i input,
}
BOTAN_FUNC_ISA("ssse3")
-__m128i aes_schedule_mangle(__m128i k, byte round_no)
+__m128i aes_schedule_mangle(__m128i k, uint8_t round_no)
{
__m128i t = _mm_shuffle_epi8(_mm_xor_si128(k, _mm_set1_epi8(0x5B)),
mc_forward[0]);
@@ -88,7 +88,7 @@ __m128i aes_schedule_192_smear(__m128i x, __m128i y)
}
BOTAN_FUNC_ISA("ssse3")
-__m128i aes_schedule_mangle_dec(__m128i k, byte round_no)
+__m128i aes_schedule_mangle_dec(__m128i k, uint8_t round_no)
{
const __m128i dsk[8] = {
_mm_set_epi32(0x4AED9334, 0x82255BFC, 0xB6116FC8, 0x7ED9A700),
@@ -117,7 +117,7 @@ __m128i aes_schedule_mangle_dec(__m128i k, byte round_no)
}
BOTAN_FUNC_ISA("ssse3")
-__m128i aes_schedule_mangle_last(__m128i k, byte round_no)
+__m128i aes_schedule_mangle_last(__m128i k, uint8_t round_no)
{
const __m128i out_tr1 = _mm_set_epi32(
0xF7974121, 0xDEBE6808, 0xFF9F4929, 0xD6B66000);
@@ -315,7 +315,7 @@ __m128i aes_ssse3_decrypt(__m128i B, const __m128i* keys, size_t rounds)
x = _mm_xor_si128(x, K);
x = _mm_xor_si128(x, y);
- const u32bit which_sr = ((((rounds - 1) << 4) ^ 48) & 48) / 16;
+ const uint32_t which_sr = ((((rounds - 1) << 4) ^ 48) & 48) / 16;
return _mm_shuffle_epi8(x, sr[which_sr]);
}
@@ -346,7 +346,7 @@ __m128i aes_ssse3_decrypt(__m128i B, const __m128i* keys, size_t rounds)
* AES-128 Encryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_128::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -369,7 +369,7 @@ void AES_128::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-128 Decryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_128::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_128::ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -392,7 +392,7 @@ void AES_128::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-128 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_128::ssse3_key_schedule(const byte keyb[], size_t)
+void AES_128::ssse3_key_schedule(const uint8_t keyb[], size_t)
{
__m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81,
0x1F8391B9, 0xAF9DEEB6);
@@ -431,7 +431,7 @@ void AES_128::ssse3_key_schedule(const byte keyb[], size_t)
* AES-192 Encryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_192::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -454,7 +454,7 @@ void AES_192::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-192 Decryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_192::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_192::ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -477,7 +477,7 @@ void AES_192::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-192 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_192::ssse3_key_schedule(const byte keyb[], size_t)
+void AES_192::ssse3_key_schedule(const uint8_t keyb[], size_t)
{
__m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81,
0x1F8391B9, 0xAF9DEEB6);
@@ -545,7 +545,7 @@ void AES_192::ssse3_key_schedule(const byte keyb[], size_t)
* AES-256 Encryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_256::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -568,7 +568,7 @@ void AES_256::ssse3_encrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-256 Decryption
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_256::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void AES_256::ssse3_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const __m128i* in_mm = reinterpret_cast<const __m128i*>(in);
__m128i* out_mm = reinterpret_cast<__m128i*>(out);
@@ -591,7 +591,7 @@ void AES_256::ssse3_decrypt_n(const byte in[], byte out[], size_t blocks) const
* AES-256 Key Schedule
*/
BOTAN_FUNC_ISA("ssse3")
-void AES_256::ssse3_key_schedule(const byte keyb[], size_t)
+void AES_256::ssse3_key_schedule(const uint8_t keyb[], size_t)
{
__m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81,
0x1F8391B9, 0xAF9DEEB6);
diff --git a/src/lib/block/block_cipher.h b/src/lib/block/block_cipher.h
index 2062160bc..ec080dbf0 100644
--- a/src/lib/block/block_cipher.h
+++ b/src/lib/block/block_cipher.h
@@ -77,7 +77,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out The byte array designated to hold the encrypted block.
* Must be of length block_size().
*/
- void encrypt(const byte in[], byte out[]) const
+ void encrypt(const uint8_t in[], uint8_t out[]) const
{ encrypt_n(in, out, 1); }
/**
@@ -87,7 +87,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out The byte array designated to hold the decrypted block.
* Must be of length block_size().
*/
- void decrypt(const byte in[], byte out[]) const
+ void decrypt(const uint8_t in[], uint8_t out[]) const
{ decrypt_n(in, out, 1); }
/**
@@ -96,7 +96,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* Must be of length block_size(). Will hold the result when the function
* has finished.
*/
- void encrypt(byte block[]) const { encrypt_n(block, block, 1); }
+ void encrypt(uint8_t block[]) const { encrypt_n(block, block, 1); }
/**
* Decrypt a block.
@@ -104,14 +104,14 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* Must be of length block_size(). Will hold the result when the function
* has finished.
*/
- void decrypt(byte block[]) const { decrypt_n(block, block, 1); }
+ void decrypt(uint8_t block[]) const { decrypt_n(block, block, 1); }
/**
* Encrypt one or more blocks
* @param block the input/output buffer (multiple of block_size())
*/
template<typename Alloc>
- void encrypt(std::vector<byte, Alloc>& block) const
+ void encrypt(std::vector<uint8_t, Alloc>& block) const
{
return encrypt_n(block.data(), block.data(), block.size() / block_size());
}
@@ -121,7 +121,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param block the input/output buffer (multiple of block_size())
*/
template<typename Alloc>
- void decrypt(std::vector<byte, Alloc>& block) const
+ void decrypt(std::vector<uint8_t, Alloc>& block) const
{
return decrypt_n(block.data(), block.data(), block.size() / block_size());
}
@@ -132,8 +132,8 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out the output buffer (same size as in)
*/
template<typename Alloc, typename Alloc2>
- void encrypt(const std::vector<byte, Alloc>& in,
- std::vector<byte, Alloc2>& out) const
+ void encrypt(const std::vector<uint8_t, Alloc>& in,
+ std::vector<uint8_t, Alloc2>& out) const
{
return encrypt_n(in.data(), out.data(), in.size() / block_size());
}
@@ -144,8 +144,8 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out the output buffer (same size as in)
*/
template<typename Alloc, typename Alloc2>
- void decrypt(const std::vector<byte, Alloc>& in,
- std::vector<byte, Alloc2>& out) const
+ void decrypt(const std::vector<uint8_t, Alloc>& in,
+ std::vector<uint8_t, Alloc2>& out) const
{
return decrypt_n(in.data(), out.data(), in.size() / block_size());
}
@@ -156,7 +156,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out the output buffer (same size as in)
* @param blocks the number of blocks to process
*/
- virtual void encrypt_n(const byte in[], byte out[],
+ virtual void encrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks) const = 0;
/**
@@ -165,7 +165,7 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
* @param out the output buffer (same size as in)
* @param blocks the number of blocks to process
*/
- virtual void decrypt_n(const byte in[], byte out[],
+ virtual void decrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks) const = 0;
/**
diff --git a/src/lib/block/blowfish/blowfish.cpp b/src/lib/block/blowfish/blowfish.cpp
index 69d345baa..17ac00a1f 100644
--- a/src/lib/block/blowfish/blowfish.cpp
+++ b/src/lib/block/blowfish/blowfish.cpp
@@ -12,12 +12,12 @@ namespace Botan {
namespace {
-const u32bit P_INIT[18] = {
+const uint32_t P_INIT[18] = {
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0,
0x082EFA98, 0xEC4E6C89, 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917, 0x9216D5D9, 0x8979FB1B };
-const u32bit S_INIT[1024] = {
+const uint32_t S_INIT[1024] = {
0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, 0xB8E1AFED, 0x6A267E96,
0xBA7C9045, 0xF12C7F99, 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E, 0x0D95748F, 0x728EB658,
@@ -195,16 +195,16 @@ const u32bit S_INIT[1024] = {
/*
* Blowfish Encryption
*/
-void Blowfish::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Blowfish::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u32bit* S1 = &m_S[0];
- const u32bit* S2 = &m_S[256];
- const u32bit* S3 = &m_S[512];
- const u32bit* S4 = &m_S[768];
+ const uint32_t* S1 = &m_S[0];
+ const uint32_t* S2 = &m_S[256];
+ const uint32_t* S3 = &m_S[512];
+ const uint32_t* S4 = &m_S[768];
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*i, L, R);
for(size_t j = 0; j != 16; j += 2)
@@ -227,16 +227,16 @@ void Blowfish::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Blowfish Decryption
*/
-void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Blowfish::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u32bit* S1 = &m_S[0];
- const u32bit* S2 = &m_S[256];
- const u32bit* S3 = &m_S[512];
- const u32bit* S4 = &m_S[768];
+ const uint32_t* S1 = &m_S[0];
+ const uint32_t* S2 = &m_S[256];
+ const uint32_t* S3 = &m_S[512];
+ const uint32_t* S4 = &m_S[768];
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*i, L, R);
for(size_t j = 17; j != 1; j -= 2)
@@ -259,7 +259,7 @@ void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Blowfish Key Schedule
*/
-void Blowfish::key_schedule(const byte key[], size_t length)
+void Blowfish::key_schedule(const uint8_t key[], size_t length)
{
m_P.resize(18);
copy_mem(m_P.data(), P_INIT, 18);
@@ -267,20 +267,20 @@ void Blowfish::key_schedule(const byte key[], size_t length)
m_S.resize(1024);
copy_mem(m_S.data(), S_INIT, 1024);
- const byte null_salt[16] = { 0 };
+ const uint8_t null_salt[16] = { 0 };
key_expansion(key, length, null_salt);
}
-void Blowfish::key_expansion(const byte key[],
+void Blowfish::key_expansion(const uint8_t key[],
size_t length,
- const byte salt[16])
+ const uint8_t salt[16])
{
for(size_t i = 0, j = 0; i != 18; ++i, j += 4)
- m_P[i] ^= make_u32bit(key[(j ) % length], key[(j+1) % length],
+ m_P[i] ^= make_uint32(key[(j ) % length], key[(j+1) % length],
key[(j+2) % length], key[(j+3) % length]);
- u32bit L = 0, R = 0;
+ uint32_t L = 0, R = 0;
generate_sbox(m_P, L, R, salt, 0);
generate_sbox(m_S, L, R, salt, 2);
}
@@ -288,8 +288,8 @@ void Blowfish::key_expansion(const byte key[],
/*
* Modified key schedule used for bcrypt password hashing
*/
-void Blowfish::eks_key_schedule(const byte key[], size_t length,
- const byte salt[16], size_t workfactor)
+void Blowfish::eks_key_schedule(const uint8_t key[], size_t length,
+ const uint8_t salt[16], size_t workfactor)
{
// Truncate longer passwords to the 56 byte limit Blowfish enforces
length = std::min<size_t>(length, 55);
@@ -314,7 +314,7 @@ void Blowfish::eks_key_schedule(const byte key[], size_t length,
key_expansion(key, length, salt);
- const byte null_salt[16] = { 0 };
+ const uint8_t null_salt[16] = { 0 };
const size_t rounds = static_cast<size_t>(1) << workfactor;
for(size_t r = 0; r != rounds; ++r)
@@ -327,20 +327,20 @@ void Blowfish::eks_key_schedule(const byte key[], size_t length,
/*
* Generate one of the Sboxes
*/
-void Blowfish::generate_sbox(secure_vector<u32bit>& box,
- u32bit& L, u32bit& R,
- const byte salt[16],
+void Blowfish::generate_sbox(secure_vector<uint32_t>& box,
+ uint32_t& L, uint32_t& R,
+ const uint8_t salt[16],
size_t salt_off) const
{
- const u32bit* S1 = &m_S[0];
- const u32bit* S2 = &m_S[256];
- const u32bit* S3 = &m_S[512];
- const u32bit* S4 = &m_S[768];
+ const uint32_t* S1 = &m_S[0];
+ const uint32_t* S2 = &m_S[256];
+ const uint32_t* S3 = &m_S[512];
+ const uint32_t* S4 = &m_S[768];
for(size_t i = 0; i != box.size(); i += 2)
{
- L ^= load_be<u32bit>(salt, (i + salt_off) % 4);
- R ^= load_be<u32bit>(salt, (i + salt_off + 1) % 4);
+ L ^= load_be<uint32_t>(salt, (i + salt_off) % 4);
+ R ^= load_be<uint32_t>(salt, (i + salt_off + 1) % 4);
for(size_t j = 0; j != 16; j += 2)
{
@@ -353,7 +353,7 @@ void Blowfish::generate_sbox(secure_vector<u32bit>& box,
S3[get_byte(2, R)]) + S4[get_byte(3, R)];
}
- u32bit T = R; R = L ^ m_P[16]; L = T ^ m_P[17];
+ uint32_t T = R; R = L ^ m_P[16]; L = T ^ m_P[17];
box[i] = L;
box[i+1] = R;
}
diff --git a/src/lib/block/blowfish/blowfish.h b/src/lib/block/blowfish/blowfish.h
index 5aa35f337..690b9c400 100644
--- a/src/lib/block/blowfish/blowfish.h
+++ b/src/lib/block/blowfish/blowfish.h
@@ -18,31 +18,31 @@ namespace Botan {
class BOTAN_DLL Blowfish final : public Block_Cipher_Fixed_Params<8, 1, 56>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
/**
* Modified EKSBlowfish key schedule, used for bcrypt password hashing
*/
- void eks_key_schedule(const byte key[], size_t key_length,
- const byte salt[16], size_t workfactor);
+ void eks_key_schedule(const uint8_t key[], size_t key_length,
+ const uint8_t salt[16], size_t workfactor);
void clear() override;
std::string name() const override { return "Blowfish"; }
BlockCipher* clone() const override { return new Blowfish; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- void key_expansion(const byte key[],
+ void key_expansion(const uint8_t key[],
size_t key_length,
- const byte salt[16]);
+ const uint8_t salt[16]);
- void generate_sbox(secure_vector<u32bit>& box,
- u32bit& L, u32bit& R,
- const byte salt[16],
+ void generate_sbox(secure_vector<uint32_t>& box,
+ uint32_t& L, uint32_t& R,
+ const uint8_t salt[16],
size_t salt_off) const;
- secure_vector<u32bit> m_S, m_P;
+ secure_vector<uint32_t> m_S, m_P;
};
}
diff --git a/src/lib/block/camellia/camellia.cpp b/src/lib/block/camellia/camellia.cpp
index 5ac13b9ab..c4a186738 100644
--- a/src/lib/block/camellia/camellia.cpp
+++ b/src/lib/block/camellia/camellia.cpp
@@ -12,7 +12,7 @@ namespace Botan {
namespace {
-const u64bit Camellia_SBOX1[256] = {
+const uint64_t Camellia_SBOX1[256] = {
0x7070700070000070, 0x8282820082000082, 0x2C2C2C002C00002C, 0xECECEC00EC0000EC,
0xB3B3B300B30000B3, 0x2727270027000027, 0xC0C0C000C00000C0, 0xE5E5E500E50000E5,
0xE4E4E400E40000E4, 0x8585850085000085, 0x5757570057000057, 0x3535350035000035,
@@ -78,7 +78,7 @@ const u64bit Camellia_SBOX1[256] = {
0x1515150015000015, 0xE3E3E300E30000E3, 0xADADAD00AD0000AD, 0xF4F4F400F40000F4,
0x7777770077000077, 0xC7C7C700C70000C7, 0x8080800080000080, 0x9E9E9E009E00009E };
-const u64bit Camellia_SBOX2[256] = {
+const uint64_t Camellia_SBOX2[256] = {
0x00E0E0E0E0E00000, 0x0005050505050000, 0x0058585858580000, 0x00D9D9D9D9D90000,
0x0067676767670000, 0x004E4E4E4E4E0000, 0x0081818181810000, 0x00CBCBCBCBCB0000,
0x00C9C9C9C9C90000, 0x000B0B0B0B0B0000, 0x00AEAEAEAEAE0000, 0x006A6A6A6A6A0000,
@@ -144,7 +144,7 @@ const u64bit Camellia_SBOX2[256] = {
0x002A2A2A2A2A0000, 0x00C7C7C7C7C70000, 0x005B5B5B5B5B0000, 0x00E9E9E9E9E90000,
0x00EEEEEEEEEE0000, 0x008F8F8F8F8F0000, 0x0001010101010000, 0x003D3D3D3D3D0000 };
-const u64bit Camellia_SBOX3[256] = {
+const uint64_t Camellia_SBOX3[256] = {
0x3800383800383800, 0x4100414100414100, 0x1600161600161600, 0x7600767600767600,
0xD900D9D900D9D900, 0x9300939300939300, 0x6000606000606000, 0xF200F2F200F2F200,
0x7200727200727200, 0xC200C2C200C2C200, 0xAB00ABAB00ABAB00, 0x9A009A9A009A9A00,
@@ -210,7 +210,7 @@ const u64bit Camellia_SBOX3[256] = {
0x8A008A8A008A8A00, 0xF100F1F100F1F100, 0xD600D6D600D6D600, 0x7A007A7A007A7A00,
0xBB00BBBB00BBBB00, 0xE300E3E300E3E300, 0x4000404000404000, 0x4F004F4F004F4F00 };
-const u64bit Camellia_SBOX4[256] = {
+const uint64_t Camellia_SBOX4[256] = {
0x7070007000007070, 0x2C2C002C00002C2C, 0xB3B300B30000B3B3, 0xC0C000C00000C0C0,
0xE4E400E40000E4E4, 0x5757005700005757, 0xEAEA00EA0000EAEA, 0xAEAE00AE0000AEAE,
0x2323002300002323, 0x6B6B006B00006B6B, 0x4545004500004545, 0xA5A500A50000A5A5,
@@ -276,7 +276,7 @@ const u64bit Camellia_SBOX4[256] = {
0x2828002800002828, 0x7B7B007B00007B7B, 0xC9C900C90000C9C9, 0xC1C100C10000C1C1,
0xE3E300E30000E3E3, 0xF4F400F40000F4F4, 0xC7C700C70000C7C7, 0x9E9E009E00009E9E };
-const u64bit Camellia_SBOX5[256] = {
+const uint64_t Camellia_SBOX5[256] = {
0x00E0E0E000E0E0E0, 0x0005050500050505, 0x0058585800585858, 0x00D9D9D900D9D9D9,
0x0067676700676767, 0x004E4E4E004E4E4E, 0x0081818100818181, 0x00CBCBCB00CBCBCB,
0x00C9C9C900C9C9C9, 0x000B0B0B000B0B0B, 0x00AEAEAE00AEAEAE, 0x006A6A6A006A6A6A,
@@ -342,7 +342,7 @@ const u64bit Camellia_SBOX5[256] = {
0x002A2A2A002A2A2A, 0x00C7C7C700C7C7C7, 0x005B5B5B005B5B5B, 0x00E9E9E900E9E9E9,
0x00EEEEEE00EEEEEE, 0x008F8F8F008F8F8F, 0x0001010100010101, 0x003D3D3D003D3D3D };
-const u64bit Camellia_SBOX6[256] = {
+const uint64_t Camellia_SBOX6[256] = {
0x3800383838003838, 0x4100414141004141, 0x1600161616001616, 0x7600767676007676,
0xD900D9D9D900D9D9, 0x9300939393009393, 0x6000606060006060, 0xF200F2F2F200F2F2,
0x7200727272007272, 0xC200C2C2C200C2C2, 0xAB00ABABAB00ABAB, 0x9A009A9A9A009A9A,
@@ -408,7 +408,7 @@ const u64bit Camellia_SBOX6[256] = {
0x8A008A8A8A008A8A, 0xF100F1F1F100F1F1, 0xD600D6D6D600D6D6, 0x7A007A7A7A007A7A,
0xBB00BBBBBB00BBBB, 0xE300E3E3E300E3E3, 0x4000404040004040, 0x4F004F4F4F004F4F };
-const u64bit Camellia_SBOX7[256] = {
+const uint64_t Camellia_SBOX7[256] = {
0x7070007070700070, 0x2C2C002C2C2C002C, 0xB3B300B3B3B300B3, 0xC0C000C0C0C000C0,
0xE4E400E4E4E400E4, 0x5757005757570057, 0xEAEA00EAEAEA00EA, 0xAEAE00AEAEAE00AE,
0x2323002323230023, 0x6B6B006B6B6B006B, 0x4545004545450045, 0xA5A500A5A5A500A5,
@@ -474,7 +474,7 @@ const u64bit Camellia_SBOX7[256] = {
0x2828002828280028, 0x7B7B007B7B7B007B, 0xC9C900C9C9C900C9, 0xC1C100C1C1C100C1,
0xE3E300E3E3E300E3, 0xF4F400F4F4F400F4, 0xC7C700C7C7C700C7, 0x9E9E009E9E9E009E };
-const u64bit Camellia_SBOX8[256] = {
+const uint64_t Camellia_SBOX8[256] = {
0x7070700070707000, 0x8282820082828200, 0x2C2C2C002C2C2C00, 0xECECEC00ECECEC00,
0xB3B3B300B3B3B300, 0x2727270027272700, 0xC0C0C000C0C0C000, 0xE5E5E500E5E5E500,
0xE4E4E400E4E4E400, 0x8585850085858500, 0x5757570057575700, 0x3535350035353500,
@@ -546,9 +546,9 @@ namespace Camellia_F {
* We use the slow byte-wise version of F in the first and last rounds
* to help protect against timing attacks
*/
-u64bit F_SLOW(u64bit v, u64bit K)
+uint64_t F_SLOW(uint64_t v, uint64_t K)
{
- static const byte SBOX[256] = {
+ static const uint8_t SBOX[256] = {
0x70, 0x82, 0x2C, 0xEC, 0xB3, 0x27, 0xC0, 0xE5, 0xE4, 0x85, 0x57,
0x35, 0xEA, 0x0C, 0xAE, 0x41, 0x23, 0xEF, 0x6B, 0x93, 0x45, 0x19,
0xA5, 0x21, 0xED, 0x0E, 0x4F, 0x4E, 0x1D, 0x65, 0x92, 0xBD, 0x86,
@@ -574,32 +574,32 @@ u64bit F_SLOW(u64bit v, u64bit K)
0xD3, 0x7B, 0xBB, 0xC9, 0x43, 0xC1, 0x15, 0xE3, 0xAD, 0xF4, 0x77,
0xC7, 0x80, 0x9E };
- const u64bit x = v ^ K;
-
- const byte t1 = SBOX[get_byte(0, x)];
- const byte t2 = rotate_left(SBOX[get_byte(1, x)], 1);
- const byte t3 = rotate_left(SBOX[get_byte(2, x)], 7);
- const byte t4 = SBOX[rotate_left(get_byte(3, x), 1)];
- const byte t5 = rotate_left(SBOX[get_byte(4, x)], 1);
- const byte t6 = rotate_left(SBOX[get_byte(5, x)], 7);
- const byte t7 = SBOX[rotate_left(get_byte(6, x), 1)];
- const byte t8 = SBOX[get_byte(7, x)];
-
- const byte y1 = t1 ^ t3 ^ t4 ^ t6 ^ t7 ^ t8;
- const byte y2 = t1 ^ t2 ^ t4 ^ t5 ^ t7 ^ t8;
- const byte y3 = t1 ^ t2 ^ t3 ^ t5 ^ t6 ^ t8;
- const byte y4 = t2 ^ t3 ^ t4 ^ t5 ^ t6 ^ t7;
- const byte y5 = t1 ^ t2 ^ t6 ^ t7 ^ t8;
- const byte y6 = t2 ^ t3 ^ t5 ^ t7 ^ t8;
- const byte y7 = t3 ^ t4 ^ t5 ^ t6 ^ t8;
- const byte y8 = t1 ^ t4 ^ t5 ^ t6 ^ t7;
-
- return make_u64bit(y1, y2, y3, y4, y5, y6, y7, y8);
+ const uint64_t x = v ^ K;
+
+ const uint8_t t1 = SBOX[get_byte(0, x)];
+ const uint8_t t2 = rotate_left(SBOX[get_byte(1, x)], 1);
+ const uint8_t t3 = rotate_left(SBOX[get_byte(2, x)], 7);
+ const uint8_t t4 = SBOX[rotate_left(get_byte(3, x), 1)];
+ const uint8_t t5 = rotate_left(SBOX[get_byte(4, x)], 1);
+ const uint8_t t6 = rotate_left(SBOX[get_byte(5, x)], 7);
+ const uint8_t t7 = SBOX[rotate_left(get_byte(6, x), 1)];
+ const uint8_t t8 = SBOX[get_byte(7, x)];
+
+ const uint8_t y1 = t1 ^ t3 ^ t4 ^ t6 ^ t7 ^ t8;
+ const uint8_t y2 = t1 ^ t2 ^ t4 ^ t5 ^ t7 ^ t8;
+ const uint8_t y3 = t1 ^ t2 ^ t3 ^ t5 ^ t6 ^ t8;
+ const uint8_t y4 = t2 ^ t3 ^ t4 ^ t5 ^ t6 ^ t7;
+ const uint8_t y5 = t1 ^ t2 ^ t6 ^ t7 ^ t8;
+ const uint8_t y6 = t2 ^ t3 ^ t5 ^ t7 ^ t8;
+ const uint8_t y7 = t3 ^ t4 ^ t5 ^ t6 ^ t8;
+ const uint8_t y8 = t1 ^ t4 ^ t5 ^ t6 ^ t7;
+
+ return make_uint64(y1, y2, y3, y4, y5, y6, y7, y8);
}
-inline u64bit F(u64bit v, u64bit K)
+inline uint64_t F(uint64_t v, uint64_t K)
{
- const u64bit x = v ^ K;
+ const uint64_t x = v ^ K;
return Camellia_SBOX1[get_byte(0, x)] ^
Camellia_SBOX2[get_byte(1, x)] ^
@@ -611,46 +611,46 @@ inline u64bit F(u64bit v, u64bit K)
Camellia_SBOX8[get_byte(7, x)];
}
-inline u64bit FL(u64bit v, u64bit K)
+inline uint64_t FL(uint64_t v, uint64_t K)
{
- u32bit x1 = (v >> 32);
- u32bit x2 = (v & 0xFFFFFFFF);
+ uint32_t x1 = (v >> 32);
+ uint32_t x2 = (v & 0xFFFFFFFF);
- const u32bit k1 = (K >> 32);
- const u32bit k2 = (K & 0xFFFFFFFF);
+ const uint32_t k1 = (K >> 32);
+ const uint32_t k2 = (K & 0xFFFFFFFF);
x2 ^= rotate_left(x1 & k1, 1);
x1 ^= (x2 | k2);
- return ((static_cast<u64bit>(x1) << 32) | x2);
+ return ((static_cast<uint64_t>(x1) << 32) | x2);
}
-inline u64bit FLINV(u64bit v, u64bit K)
+inline uint64_t FLINV(uint64_t v, uint64_t K)
{
- u32bit x1 = (v >> 32);
- u32bit x2 = (v & 0xFFFFFFFF);
+ uint32_t x1 = (v >> 32);
+ uint32_t x2 = (v & 0xFFFFFFFF);
- const u32bit k1 = (K >> 32);
- const u32bit k2 = (K & 0xFFFFFFFF);
+ const uint32_t k1 = (K >> 32);
+ const uint32_t k2 = (K & 0xFFFFFFFF);
x1 ^= (x2 | k2);
x2 ^= rotate_left(x1 & k1, 1);
- return ((static_cast<u64bit>(x1) << 32) | x2);
+ return ((static_cast<uint64_t>(x1) << 32) | x2);
}
/*
* Camellia Encryption
*/
-void encrypt(const byte in[], byte out[], size_t blocks,
- const secure_vector<u64bit>& SK, const size_t rounds)
+void encrypt(const uint8_t in[], uint8_t out[], size_t blocks,
+ const secure_vector<uint64_t>& SK, const size_t rounds)
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit D1, D2;
+ uint64_t D1, D2;
load_be(in + 16*i, D1, D2);
- const u64bit* K = SK.data();
+ const uint64_t* K = SK.data();
D1 ^= *K++;
D2 ^= *K++;
@@ -683,15 +683,15 @@ void encrypt(const byte in[], byte out[], size_t blocks,
/*
* Camellia Decryption
*/
-void decrypt(const byte in[], byte out[], size_t blocks,
- const secure_vector<u64bit>& SK, const size_t rounds)
+void decrypt(const uint8_t in[], uint8_t out[], size_t blocks,
+ const secure_vector<uint64_t>& SK, const size_t rounds)
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit D1, D2;
+ uint64_t D1, D2;
load_be(in + 16*i, D1, D2);
- const u64bit* K = &SK[SK.size()-1];
+ const uint64_t* K = &SK[SK.size()-1];
D2 ^= *K--;
D1 ^= *K--;
@@ -721,12 +721,12 @@ void decrypt(const byte in[], byte out[], size_t blocks,
}
}
-u64bit left_rot_hi(u64bit h, u64bit l, size_t shift)
+uint64_t left_rot_hi(uint64_t h, uint64_t l, size_t shift)
{
return (h << shift) | ((l >> (64-shift)));
}
-u64bit left_rot_lo(u64bit h, u64bit l, size_t shift)
+uint64_t left_rot_lo(uint64_t h, uint64_t l, size_t shift)
{
return (h >> (64-shift)) | (l << shift);
}
@@ -734,24 +734,24 @@ u64bit left_rot_lo(u64bit h, u64bit l, size_t shift)
/*
* Camellia Key Schedule
*/
-void key_schedule(secure_vector<u64bit>& SK, const byte key[], size_t length)
+void key_schedule(secure_vector<uint64_t>& SK, const uint8_t key[], size_t length)
{
- const u64bit Sigma1 = 0xA09E667F3BCC908B;
- const u64bit Sigma2 = 0xB67AE8584CAA73B2;
- const u64bit Sigma3 = 0xC6EF372FE94F82BE;
- const u64bit Sigma4 = 0x54FF53A5F1D36F1C;
- const u64bit Sigma5 = 0x10E527FADE682D1D;
- const u64bit Sigma6 = 0xB05688C2B3E6C1FD;
-
- const u64bit KL_H = load_be<u64bit>(key, 0);
- const u64bit KL_L = load_be<u64bit>(key, 1);
-
- const u64bit KR_H = (length >= 24) ? load_be<u64bit>(key, 2) : 0;
- const u64bit KR_L =
- (length == 32) ? load_be<u64bit>(key, 3) : ((length == 24) ? ~KR_H : 0);
-
- u64bit D1 = KL_H ^ KR_H;
- u64bit D2 = KL_L ^ KR_L;
+ const uint64_t Sigma1 = 0xA09E667F3BCC908B;
+ const uint64_t Sigma2 = 0xB67AE8584CAA73B2;
+ const uint64_t Sigma3 = 0xC6EF372FE94F82BE;
+ const uint64_t Sigma4 = 0x54FF53A5F1D36F1C;
+ const uint64_t Sigma5 = 0x10E527FADE682D1D;
+ const uint64_t Sigma6 = 0xB05688C2B3E6C1FD;
+
+ const uint64_t KL_H = load_be<uint64_t>(key, 0);
+ const uint64_t KL_L = load_be<uint64_t>(key, 1);
+
+ const uint64_t KR_H = (length >= 24) ? load_be<uint64_t>(key, 2) : 0;
+ const uint64_t KR_L =
+ (length == 32) ? load_be<uint64_t>(key, 3) : ((length == 24) ? ~KR_H : 0);
+
+ uint64_t D1 = KL_H ^ KR_H;
+ uint64_t D2 = KL_L ^ KR_L;
D2 ^= F(D1, Sigma1);
D1 ^= F(D2, Sigma2);
D1 ^= KL_H;
@@ -759,16 +759,16 @@ void key_schedule(secure_vector<u64bit>& SK, const byte key[], size_t length)
D2 ^= F(D1, Sigma3);
D1 ^= F(D2, Sigma4);
- const u64bit KA_H = D1;
- const u64bit KA_L = D2;
+ const uint64_t KA_H = D1;
+ const uint64_t KA_L = D2;
D1 = KA_H ^ KR_H;
D2 = KA_L ^ KR_L;
D2 ^= F(D1, Sigma5);
D1 ^= F(D2, Sigma6);
- const u64bit KB_H = D1;
- const u64bit KB_L = D2;
+ const uint64_t KB_H = D1;
+ const uint64_t KB_L = D2;
if(length == 16)
{
@@ -852,47 +852,47 @@ void key_schedule(secure_vector<u64bit>& SK, const byte key[], size_t length)
}
-void Camellia_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_128::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::encrypt(in, out, blocks, m_SK, 9);
}
-void Camellia_192::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_192::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::encrypt(in, out, blocks, m_SK, 12);
}
-void Camellia_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_256::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::encrypt(in, out, blocks, m_SK, 12);
}
-void Camellia_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_128::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::decrypt(in, out, blocks, m_SK, 9);
}
-void Camellia_192::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_192::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::decrypt(in, out, blocks, m_SK, 12);
}
-void Camellia_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Camellia_256::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
Camellia_F::decrypt(in, out, blocks, m_SK, 12);
}
-void Camellia_128::key_schedule(const byte key[], size_t length)
+void Camellia_128::key_schedule(const uint8_t key[], size_t length)
{
Camellia_F::key_schedule(m_SK, key, length);
}
-void Camellia_192::key_schedule(const byte key[], size_t length)
+void Camellia_192::key_schedule(const uint8_t key[], size_t length)
{
Camellia_F::key_schedule(m_SK, key, length);
}
-void Camellia_256::key_schedule(const byte key[], size_t length)
+void Camellia_256::key_schedule(const uint8_t key[], size_t length)
{
Camellia_F::key_schedule(m_SK, key, length);
}
diff --git a/src/lib/block/camellia/camellia.h b/src/lib/block/camellia/camellia.h
index 71aa95ac6..736315f3a 100644
--- a/src/lib/block/camellia/camellia.h
+++ b/src/lib/block/camellia/camellia.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL Camellia_128 final : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "Camellia-128"; }
BlockCipher* clone() const override { return new Camellia_128; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u64bit> m_SK;
+ secure_vector<uint64_t> m_SK;
};
/**
@@ -36,16 +36,16 @@ class BOTAN_DLL Camellia_128 final : public Block_Cipher_Fixed_Params<16, 16>
class BOTAN_DLL Camellia_192 final : public Block_Cipher_Fixed_Params<16, 24>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "Camellia-192"; }
BlockCipher* clone() const override { return new Camellia_192; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u64bit> m_SK;
+ secure_vector<uint64_t> m_SK;
};
/**
@@ -54,16 +54,16 @@ class BOTAN_DLL Camellia_192 final : public Block_Cipher_Fixed_Params<16, 24>
class BOTAN_DLL Camellia_256 final : public Block_Cipher_Fixed_Params<16, 32>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "Camellia-256"; }
BlockCipher* clone() const override { return new Camellia_256; }
private:
- void key_schedule(const byte key[], size_t length) override;
+ void key_schedule(const uint8_t key[], size_t length) override;
- secure_vector<u64bit> m_SK;
+ secure_vector<uint64_t> m_SK;
};
}
diff --git a/src/lib/block/cascade/cascade.cpp b/src/lib/block/cascade/cascade.cpp
index 98e862de9..e54d3e5b5 100644
--- a/src/lib/block/cascade/cascade.cpp
+++ b/src/lib/block/cascade/cascade.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-void Cascade_Cipher::encrypt_n(const byte in[], byte out[],
+void Cascade_Cipher::encrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks) const
{
size_t c1_blocks = blocks * (block_size() / m_cipher1->block_size());
@@ -19,7 +19,7 @@ void Cascade_Cipher::encrypt_n(const byte in[], byte out[],
m_cipher2->encrypt_n(out, out, c2_blocks);
}
-void Cascade_Cipher::decrypt_n(const byte in[], byte out[],
+void Cascade_Cipher::decrypt_n(const uint8_t in[], uint8_t out[],
size_t blocks) const
{
size_t c1_blocks = blocks * (block_size() / m_cipher1->block_size());
@@ -29,9 +29,9 @@ void Cascade_Cipher::decrypt_n(const byte in[], byte out[],
m_cipher1->decrypt_n(out, out, c1_blocks);
}
-void Cascade_Cipher::key_schedule(const byte key[], size_t)
+void Cascade_Cipher::key_schedule(const uint8_t key[], size_t)
{
- const byte* key2 = key + m_cipher1->maximum_keylength();
+ const uint8_t* key2 = key + m_cipher1->maximum_keylength();
m_cipher1->set_key(key , m_cipher1->maximum_keylength());
m_cipher2->set_key(key2, m_cipher2->maximum_keylength());
diff --git a/src/lib/block/cascade/cascade.h b/src/lib/block/cascade/cascade.h
index aa7bd0421..1ab81b9b5 100644
--- a/src/lib/block/cascade/cascade.h
+++ b/src/lib/block/cascade/cascade.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Cascade_Cipher final : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
size_t block_size() const override { return m_block; }
@@ -43,7 +43,7 @@ class BOTAN_DLL Cascade_Cipher final : public BlockCipher
Cascade_Cipher(const Cascade_Cipher&) = delete;
Cascade_Cipher& operator=(const Cascade_Cipher&) = delete;
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
size_t m_block;
std::unique_ptr<BlockCipher> m_cipher1, m_cipher2;
diff --git a/src/lib/block/cast/cast128.cpp b/src/lib/block/cast/cast128.cpp
index 96c4f45a7..d955dfeef 100644
--- a/src/lib/block/cast/cast128.cpp
+++ b/src/lib/block/cast/cast128.cpp
@@ -16,9 +16,9 @@ namespace {
/*
* CAST-128 Round Type 1
*/
-inline void R1(u32bit& L, u32bit R, u32bit MK, byte RK)
+inline void R1(uint32_t& L, uint32_t R, uint32_t MK, uint8_t RK)
{
- u32bit T = rotate_left(MK + R, RK);
+ uint32_t T = rotate_left(MK + R, RK);
L ^= (CAST_SBOX1[get_byte(0, T)] ^ CAST_SBOX2[get_byte(1, T)]) -
CAST_SBOX3[get_byte(2, T)] + CAST_SBOX4[get_byte(3, T)];
}
@@ -26,9 +26,9 @@ inline void R1(u32bit& L, u32bit R, u32bit MK, byte RK)
/*
* CAST-128 Round Type 2
*/
-inline void R2(u32bit& L, u32bit R, u32bit MK, byte RK)
+inline void R2(uint32_t& L, uint32_t R, uint32_t MK, uint8_t RK)
{
- u32bit T = rotate_left(MK ^ R, RK);
+ uint32_t T = rotate_left(MK ^ R, RK);
L ^= (CAST_SBOX1[get_byte(0, T)] - CAST_SBOX2[get_byte(1, T)] +
CAST_SBOX3[get_byte(2, T)]) ^ CAST_SBOX4[get_byte(3, T)];
}
@@ -36,9 +36,9 @@ inline void R2(u32bit& L, u32bit R, u32bit MK, byte RK)
/*
* CAST-128 Round Type 3
*/
-inline void R3(u32bit& L, u32bit R, u32bit MK, byte RK)
+inline void R3(uint32_t& L, uint32_t R, uint32_t MK, uint8_t RK)
{
- u32bit T = rotate_left(MK - R, RK);
+ uint32_t T = rotate_left(MK - R, RK);
L ^= ((CAST_SBOX1[get_byte(0, T)] + CAST_SBOX2[get_byte(1, T)]) ^
CAST_SBOX3[get_byte(2, T)]) - CAST_SBOX4[get_byte(3, T)];
}
@@ -48,11 +48,11 @@ inline void R3(u32bit& L, u32bit R, u32bit MK, byte RK)
/*
* CAST-128 Encryption
*/
-void CAST_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void CAST_128::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*i, L, R);
R1(L, R, m_MK[ 0], m_RK[ 0]);
@@ -79,11 +79,11 @@ void CAST_128::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* CAST-128 Decryption
*/
-void CAST_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void CAST_128::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*i, L, R);
R1(L, R, m_MK[15], m_RK[15]);
@@ -110,18 +110,18 @@ void CAST_128::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* CAST-128 Key Schedule
*/
-void CAST_128::key_schedule(const byte key[], size_t length)
+void CAST_128::key_schedule(const uint8_t key[], size_t length)
{
m_MK.resize(48);
m_RK.resize(48);
- secure_vector<u32bit> X(4);
+ secure_vector<uint32_t> X(4);
for(size_t i = 0; i != length; ++i)
X[i/4] = (X[i/4] << 8) + key[i];
cast_ks(m_MK, X);
- secure_vector<u32bit> RK32(48);
+ secure_vector<uint32_t> RK32(48);
cast_ks(RK32, X);
for(size_t i = 0; i != 16; ++i)
@@ -137,10 +137,10 @@ void CAST_128::clear()
/*
* S-Box Based Key Expansion
*/
-void CAST_128::cast_ks(secure_vector<u32bit>& K,
- secure_vector<u32bit>& X)
+void CAST_128::cast_ks(secure_vector<uint32_t>& K,
+ secure_vector<uint32_t>& X)
{
- static const u32bit S5[256] = {
+ static const uint32_t S5[256] = {
0x7EC90C04, 0x2C6E74B9, 0x9B0E66DF, 0xA6337911, 0xB86A7FFF, 0x1DD358F5,
0x44DD9D44, 0x1731167F, 0x08FBF1FA, 0xE7F511CC, 0xD2051B00, 0x735ABA00,
0x2AB722D8, 0x386381CB, 0xACF6243A, 0x69BEFD7A, 0xE6A2E77F, 0xF0C720CD,
@@ -185,7 +185,7 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K,
0x34010718, 0xBB30CAB8, 0xE822FE15, 0x88570983, 0x750E6249, 0xDA627E55,
0x5E76FFA8, 0xB1534546, 0x6D47DE08, 0xEFE9E7D4 };
- static const u32bit S6[256] = {
+ static const uint32_t S6[256] = {
0xF6FA8F9D, 0x2CAC6CE1, 0x4CA34867, 0xE2337F7C, 0x95DB08E7, 0x016843B4,
0xECED5CBC, 0x325553AC, 0xBF9F0960, 0xDFA1E2ED, 0x83F0579D, 0x63ED86B9,
0x1AB6A6B8, 0xDE5EBE39, 0xF38FF732, 0x8989B138, 0x33F14961, 0xC01937BD,
@@ -230,7 +230,7 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K,
0xB0E93524, 0xBEBB8FBD, 0xA2D762CF, 0x49C92F54, 0x38B5F331, 0x7128A454,
0x48392905, 0xA65B1DB8, 0x851C97BD, 0xD675CF2F };
- static const u32bit S7[256] = {
+ static const uint32_t S7[256] = {
0x85E04019, 0x332BF567, 0x662DBFFF, 0xCFC65693, 0x2A8D7F6F, 0xAB9BC912,
0xDE6008A1, 0x2028DA1F, 0x0227BCE7, 0x4D642916, 0x18FAC300, 0x50F18B82,
0x2CB2CB11, 0xB232E75C, 0x4B3695F2, 0xB28707DE, 0xA05FBCF6, 0xCD4181E9,
@@ -275,7 +275,7 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K,
0xC3C0BDAE, 0x4958C24C, 0x518F36B2, 0x84B1D370, 0x0FEDCE83, 0x878DDADA,
0xF2A279C7, 0x94E01BE8, 0x90716F4B, 0x954B8AA3 };
- static const u32bit S8[256] = {
+ static const uint32_t S8[256] = {
0xE216300D, 0xBBDDFFFC, 0xA7EBDABD, 0x35648095, 0x7789F8B7, 0xE6C1121B,
0x0E241600, 0x052CE8B5, 0x11A9CFB0, 0xE5952F11, 0xECE7990A, 0x9386D174,
0x2A42931C, 0x76E38111, 0xB12DEF3A, 0x37DDDDFC, 0xDE9ADEB1, 0x0A0CC32C,
@@ -323,13 +323,13 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K,
class ByteReader
{
public:
- byte operator()(size_t i) { return (m_X[i/4] >> (8*(3 - (i%4)))); }
- explicit ByteReader(const u32bit* x) : m_X(x) {}
+ uint8_t operator()(size_t i) { return (m_X[i/4] >> (8*(3 - (i%4)))); }
+ explicit ByteReader(const uint32_t* x) : m_X(x) {}
private:
- const u32bit* m_X;
+ const uint32_t* m_X;
};
- secure_vector<u32bit> Z(4);
+ secure_vector<uint32_t> Z(4);
ByteReader x(X.data()), z(Z.data());
Z[0] = X[0] ^ S5[x(13)] ^ S6[x(15)] ^ S7[x(12)] ^ S8[x(14)] ^ S7[x( 8)];
diff --git a/src/lib/block/cast/cast128.h b/src/lib/block/cast/cast128.h
index 2782e96b9..96e543aed 100644
--- a/src/lib/block/cast/cast128.h
+++ b/src/lib/block/cast/cast128.h
@@ -18,21 +18,21 @@ namespace Botan {
class BOTAN_DLL CAST_128 final : public Block_Cipher_Fixed_Params<8, 11, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "CAST-128"; }
BlockCipher* clone() const override { return new CAST_128; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- static void cast_ks(secure_vector<u32bit>& ks,
- secure_vector<u32bit>& user_key);
+ static void cast_ks(secure_vector<uint32_t>& ks,
+ secure_vector<uint32_t>& user_key);
- secure_vector<u32bit> m_MK;
- secure_vector<byte> m_RK;
+ secure_vector<uint32_t> m_MK;
+ secure_vector<uint8_t> m_RK;
};
}
diff --git a/src/lib/block/cast/cast256.cpp b/src/lib/block/cast/cast256.cpp
index 637fdfee2..a4a7dbd36 100644
--- a/src/lib/block/cast/cast256.cpp
+++ b/src/lib/block/cast/cast256.cpp
@@ -16,9 +16,9 @@ namespace {
/*
* CAST-256 Round Type 1
*/
-void round1(u32bit& out, u32bit in, u32bit mask, u32bit rot)
+void round1(uint32_t& out, uint32_t in, uint32_t mask, uint32_t rot)
{
- u32bit temp = rotate_left(mask + in, rot);
+ uint32_t temp = rotate_left(mask + in, rot);
out ^= (CAST_SBOX1[get_byte(0, temp)] ^ CAST_SBOX2[get_byte(1, temp)]) -
CAST_SBOX3[get_byte(2, temp)] + CAST_SBOX4[get_byte(3, temp)];
}
@@ -26,9 +26,9 @@ void round1(u32bit& out, u32bit in, u32bit mask, u32bit rot)
/*
* CAST-256 Round Type 2
*/
-void round2(u32bit& out, u32bit in, u32bit mask, u32bit rot)
+void round2(uint32_t& out, uint32_t in, uint32_t mask, uint32_t rot)
{
- u32bit temp = rotate_left(mask ^ in, rot);
+ uint32_t temp = rotate_left(mask ^ in, rot);
out ^= (CAST_SBOX1[get_byte(0, temp)] - CAST_SBOX2[get_byte(1, temp)] +
CAST_SBOX3[get_byte(2, temp)]) ^ CAST_SBOX4[get_byte(3, temp)];
}
@@ -36,9 +36,9 @@ void round2(u32bit& out, u32bit in, u32bit mask, u32bit rot)
/*
* CAST-256 Round Type 3
*/
-void round3(u32bit& out, u32bit in, u32bit mask, u32bit rot)
+void round3(uint32_t& out, uint32_t in, uint32_t mask, uint32_t rot)
{
- u32bit temp = rotate_left(mask - in, rot);
+ uint32_t temp = rotate_left(mask - in, rot);
out ^= ((CAST_SBOX1[get_byte(0, temp)] + CAST_SBOX2[get_byte(1, temp)]) ^
CAST_SBOX3[get_byte(2, temp)]) - CAST_SBOX4[get_byte(3, temp)];
}
@@ -48,14 +48,14 @@ void round3(u32bit& out, u32bit in, u32bit mask, u32bit rot)
/*
* CAST-256 Encryption
*/
-void CAST_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void CAST_256::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit A = load_be<u32bit>(in, 0);
- u32bit B = load_be<u32bit>(in, 1);
- u32bit C = load_be<u32bit>(in, 2);
- u32bit D = load_be<u32bit>(in, 3);
+ uint32_t A = load_be<uint32_t>(in, 0);
+ uint32_t B = load_be<uint32_t>(in, 1);
+ uint32_t C = load_be<uint32_t>(in, 2);
+ uint32_t D = load_be<uint32_t>(in, 3);
round1(C, D, m_MK[ 0], m_RK[ 0]); round2(B, C, m_MK[ 1], m_RK[ 1]);
round3(A, B, m_MK[ 2], m_RK[ 2]); round1(D, A, m_MK[ 3], m_RK[ 3]);
@@ -92,14 +92,14 @@ void CAST_256::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* CAST-256 Decryption
*/
-void CAST_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void CAST_256::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit A = load_be<u32bit>(in, 0);
- u32bit B = load_be<u32bit>(in, 1);
- u32bit C = load_be<u32bit>(in, 2);
- u32bit D = load_be<u32bit>(in, 3);
+ uint32_t A = load_be<uint32_t>(in, 0);
+ uint32_t B = load_be<uint32_t>(in, 1);
+ uint32_t C = load_be<uint32_t>(in, 2);
+ uint32_t D = load_be<uint32_t>(in, 3);
round1(C, D, m_MK[44], m_RK[44]); round2(B, C, m_MK[45], m_RK[45]);
round3(A, B, m_MK[46], m_RK[46]); round1(D, A, m_MK[47], m_RK[47]);
@@ -136,9 +136,9 @@ void CAST_256::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* CAST-256 Key Schedule
*/
-void CAST_256::key_schedule(const byte key[], size_t length)
+void CAST_256::key_schedule(const uint8_t key[], size_t length)
{
- static const u32bit KEY_MASK[192] = {
+ static const uint32_t KEY_MASK[192] = {
0x5A827999, 0xC95C653A, 0x383650DB, 0xA7103C7C, 0x15EA281D, 0x84C413BE,
0xF39DFF5F, 0x6277EB00, 0xD151D6A1, 0x402BC242, 0xAF05ADE3, 0x1DDF9984,
0x8CB98525, 0xFB9370C6, 0x6A6D5C67, 0xD9474808, 0x482133A9, 0xB6FB1F4A,
@@ -172,7 +172,7 @@ void CAST_256::key_schedule(const byte key[], size_t length)
0x4BBC26CD, 0xBA96126E, 0x296FFE0F, 0x9849E9B0, 0x0723D551, 0x75FDC0F2,
0xE4D7AC93, 0x53B19834, 0xC28B83D5, 0x31656F76, 0xA03F5B17, 0x0F1946B8 };
- static const byte KEY_ROT[32] = {
+ static const uint8_t KEY_ROT[32] = {
0x13, 0x04, 0x15, 0x06, 0x17, 0x08, 0x19, 0x0A, 0x1B, 0x0C,
0x1D, 0x0E, 0x1F, 0x10, 0x01, 0x12, 0x03, 0x14, 0x05, 0x16,
0x07, 0x18, 0x09, 0x1A, 0x0B, 0x1C, 0x0D, 0x1E, 0x0F, 0x00,
@@ -181,11 +181,11 @@ void CAST_256::key_schedule(const byte key[], size_t length)
m_MK.resize(48);
m_RK.resize(48);
- secure_vector<u32bit> K(8);
+ secure_vector<uint32_t> K(8);
for(size_t i = 0; i != length; ++i)
K[i/4] = (K[i/4] << 8) + key[i];
- u32bit A = K[0], B = K[1], C = K[2], D = K[3],
+ uint32_t A = K[0], B = K[1], C = K[2], D = K[3],
E = K[4], F = K[5], G = K[6], H = K[7];
for(size_t i = 0; i != 48; i += 4)
diff --git a/src/lib/block/cast/cast256.h b/src/lib/block/cast/cast256.h
index 086c94331..fe35abfba 100644
--- a/src/lib/block/cast/cast256.h
+++ b/src/lib/block/cast/cast256.h
@@ -18,17 +18,17 @@ namespace Botan {
class BOTAN_DLL CAST_256 final : public Block_Cipher_Fixed_Params<16, 4, 32, 4>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "CAST-256"; }
BlockCipher* clone() const override { return new CAST_256; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u32bit> m_MK;
- secure_vector<byte> m_RK;
+ secure_vector<uint32_t> m_MK;
+ secure_vector<uint8_t> m_RK;
};
}
diff --git a/src/lib/block/cast/cast_sboxes.h b/src/lib/block/cast/cast_sboxes.h
index f73ce8142..c8d6a3a90 100644
--- a/src/lib/block/cast/cast_sboxes.h
+++ b/src/lib/block/cast/cast_sboxes.h
@@ -12,7 +12,7 @@
namespace Botan {
-const u32bit CAST_SBOX1[256] = {
+const uint32_t CAST_SBOX1[256] = {
0x30FB40D4, 0x9FA0FF0B, 0x6BECCD2F, 0x3F258C7A, 0x1E213F2F, 0x9C004DD3,
0x6003E540, 0xCF9FC949, 0xBFD4AF27, 0x88BBBDB5, 0xE2034090, 0x98D09675,
0x6E63A0E0, 0x15C361D2, 0xC2E7661D, 0x22D4FF8E, 0x28683B6F, 0xC07FD059,
@@ -57,7 +57,7 @@ const u32bit CAST_SBOX1[256] = {
0xB141AB08, 0x7CCA89B9, 0x1A69E783, 0x02CC4843, 0xA2F7C579, 0x429EF47D,
0x427B169C, 0x5AC9F049, 0xDD8F0F00, 0x5C8165BF };
-const u32bit CAST_SBOX2[256] = {
+const uint32_t CAST_SBOX2[256] = {
0x1F201094, 0xEF0BA75B, 0x69E3CF7E, 0x393F4380, 0xFE61CF7A, 0xEEC5207A,
0x55889C94, 0x72FC0651, 0xADA7EF79, 0x4E1D7235, 0xD55A63CE, 0xDE0436BA,
0x99C430EF, 0x5F0C0794, 0x18DCDB7D, 0xA1D6EFF3, 0xA0B52F7B, 0x59E83605,
@@ -102,7 +102,7 @@ const u32bit CAST_SBOX2[256] = {
0x5C038323, 0x3E5D3BB9, 0x43D79572, 0x7E6DD07C, 0x06DFDF1E, 0x6C6CC4EF,
0x7160A539, 0x73BFBE70, 0x83877605, 0x4523ECF1 };
-const u32bit CAST_SBOX3[256] = {
+const uint32_t CAST_SBOX3[256] = {
0x8DEFC240, 0x25FA5D9F, 0xEB903DBF, 0xE810C907, 0x47607FFF, 0x369FE44B,
0x8C1FC644, 0xAECECA90, 0xBEB1F9BF, 0xEEFBCAEA, 0xE8CF1950, 0x51DF07AE,
0x920E8806, 0xF0AD0548, 0xE13C8D83, 0x927010D5, 0x11107D9F, 0x07647DB9,
@@ -147,7 +147,7 @@ const u32bit CAST_SBOX3[256] = {
0x52BCE688, 0x1B03588A, 0xF7BAEFD5, 0x4142ED9C, 0xA4315C11, 0x83323EC5,
0xDFEF4636, 0xA133C501, 0xE9D3531C, 0xEE353783 };
-const u32bit CAST_SBOX4[256] = {
+const uint32_t CAST_SBOX4[256] = {
0x9DB30420, 0x1FB6E9DE, 0xA7BE7BEF, 0xD273A298, 0x4A4F7BDB, 0x64AD8C57,
0x85510443, 0xFA020ED1, 0x7E287AFF, 0xE60FB663, 0x095F35A1, 0x79EBF120,
0xFD059D43, 0x6497B7B1, 0xF3641F63, 0x241E4ADF, 0x28147F5F, 0x4FA2B8CD,
diff --git a/src/lib/block/des/des.cpp b/src/lib/block/des/des.cpp
index a55c43ec7..44f315047 100644
--- a/src/lib/block/des/des.cpp
+++ b/src/lib/block/des/des.cpp
@@ -18,12 +18,12 @@ namespace {
/*
* DES Key Schedule
*/
-void des_key_schedule(u32bit round_key[32], const byte key[8])
+void des_key_schedule(uint32_t round_key[32], const uint8_t key[8])
{
- static const byte ROT[16] = { 1, 1, 2, 2, 2, 2, 2, 2,
+ static const uint8_t ROT[16] = { 1, 1, 2, 2, 2, 2, 2, 2,
1, 2, 2, 2, 2, 2, 2, 1 };
- u32bit C = ((key[7] & 0x80) << 20) | ((key[6] & 0x80) << 19) |
+ uint32_t C = ((key[7] & 0x80) << 20) | ((key[6] & 0x80) << 19) |
((key[5] & 0x80) << 18) | ((key[4] & 0x80) << 17) |
((key[3] & 0x80) << 16) | ((key[2] & 0x80) << 15) |
((key[1] & 0x80) << 14) | ((key[0] & 0x80) << 13) |
@@ -37,7 +37,7 @@ void des_key_schedule(u32bit round_key[32], const byte key[8])
((key[1] & 0x20) ) | ((key[0] & 0x20) >> 1) |
((key[7] & 0x10) >> 1) | ((key[6] & 0x10) >> 2) |
((key[5] & 0x10) >> 3) | ((key[4] & 0x10) >> 4);
- u32bit D = ((key[7] & 0x02) << 26) | ((key[6] & 0x02) << 25) |
+ uint32_t D = ((key[7] & 0x02) << 26) | ((key[6] & 0x02) << 25) |
((key[5] & 0x02) << 24) | ((key[4] & 0x02) << 23) |
((key[3] & 0x02) << 22) | ((key[2] & 0x02) << 21) |
((key[1] & 0x02) << 20) | ((key[0] & 0x02) << 19) |
@@ -84,12 +84,12 @@ void des_key_schedule(u32bit round_key[32], const byte key[8])
/*
* DES Encryption
*/
-void des_encrypt(u32bit& L, u32bit& R,
- const u32bit round_key[32])
+void des_encrypt(uint32_t& L, uint32_t& R,
+ const uint32_t round_key[32])
{
for(size_t i = 0; i != 16; i += 2)
{
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = rotate_right(R, 4) ^ round_key[2*i];
T1 = R ^ round_key[2*i + 1];
@@ -112,12 +112,12 @@ void des_encrypt(u32bit& L, u32bit& R,
/*
* DES Decryption
*/
-void des_decrypt(u32bit& L, u32bit& R,
- const u32bit round_key[32])
+void des_decrypt(uint32_t& L, uint32_t& R,
+ const uint32_t round_key[32])
{
for(size_t i = 16; i != 0; i -= 2)
{
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = rotate_right(R, 4) ^ round_key[2*i - 2];
T1 = R ^ round_key[2*i - 1];
@@ -142,17 +142,17 @@ void des_decrypt(u32bit& L, u32bit& R,
/*
* DES Encryption
*/
-void DES::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void DES::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i < blocks; ++i)
{
- u64bit T = (DES_IPTAB1[in[8*i+0]] ) | (DES_IPTAB1[in[8*i+1]] << 1) |
+ uint64_t T = (DES_IPTAB1[in[8*i+0]] ) | (DES_IPTAB1[in[8*i+1]] << 1) |
(DES_IPTAB1[in[8*i+2]] << 2) | (DES_IPTAB1[in[8*i+3]] << 3) |
(DES_IPTAB1[in[8*i+4]] << 4) | (DES_IPTAB1[in[8*i+5]] << 5) |
(DES_IPTAB1[in[8*i+6]] << 6) | (DES_IPTAB2[in[8*i+7]] );
- u32bit L = static_cast<u32bit>(T >> 32);
- u32bit R = static_cast<u32bit>(T);
+ uint32_t L = static_cast<uint32_t>(T >> 32);
+ uint32_t R = static_cast<uint32_t>(T);
des_encrypt(L, R, m_round_key.data());
@@ -169,17 +169,17 @@ void DES::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* DES Decryption
*/
-void DES::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void DES::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i < blocks; ++i)
{
- u64bit T = (DES_IPTAB1[in[BLOCK_SIZE*i+0]] ) | (DES_IPTAB1[in[BLOCK_SIZE*i+1]] << 1) |
+ uint64_t T = (DES_IPTAB1[in[BLOCK_SIZE*i+0]] ) | (DES_IPTAB1[in[BLOCK_SIZE*i+1]] << 1) |
(DES_IPTAB1[in[BLOCK_SIZE*i+2]] << 2) | (DES_IPTAB1[in[BLOCK_SIZE*i+3]] << 3) |
(DES_IPTAB1[in[BLOCK_SIZE*i+4]] << 4) | (DES_IPTAB1[in[BLOCK_SIZE*i+5]] << 5) |
(DES_IPTAB1[in[BLOCK_SIZE*i+6]] << 6) | (DES_IPTAB2[in[BLOCK_SIZE*i+7]] );
- u32bit L = static_cast<u32bit>(T >> 32);
- u32bit R = static_cast<u32bit>(T);
+ uint32_t L = static_cast<uint32_t>(T >> 32);
+ uint32_t R = static_cast<uint32_t>(T);
des_decrypt(L, R, m_round_key.data());
@@ -197,7 +197,7 @@ void DES::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* DES Key Schedule
*/
-void DES::key_schedule(const byte key[], size_t)
+void DES::key_schedule(const uint8_t key[], size_t)
{
m_round_key.resize(32);
des_key_schedule(m_round_key.data(), key);
@@ -211,17 +211,17 @@ void DES::clear()
/*
* TripleDES Encryption
*/
-void TripleDES::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void TripleDES::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
+ uint64_t T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
(DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) |
(DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) |
(DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] );
- u32bit L = static_cast<u32bit>(T >> 32);
- u32bit R = static_cast<u32bit>(T);
+ uint32_t L = static_cast<uint32_t>(T >> 32);
+ uint32_t R = static_cast<uint32_t>(T);
des_encrypt(L, R, &m_round_key[0]);
des_decrypt(R, L, &m_round_key[32]);
@@ -244,17 +244,17 @@ void TripleDES::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* TripleDES Decryption
*/
-void TripleDES::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void TripleDES::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u64bit T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
+ uint64_t T = (DES_IPTAB1[in[0]] ) | (DES_IPTAB1[in[1]] << 1) |
(DES_IPTAB1[in[2]] << 2) | (DES_IPTAB1[in[3]] << 3) |
(DES_IPTAB1[in[4]] << 4) | (DES_IPTAB1[in[5]] << 5) |
(DES_IPTAB1[in[6]] << 6) | (DES_IPTAB2[in[7]] );
- u32bit L = static_cast<u32bit>(T >> 32);
- u32bit R = static_cast<u32bit>(T);
+ uint32_t L = static_cast<uint32_t>(T >> 32);
+ uint32_t R = static_cast<uint32_t>(T);
des_decrypt(L, R, &m_round_key[64]);
des_encrypt(R, L, &m_round_key[32]);
@@ -277,7 +277,7 @@ void TripleDES::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* TripleDES Key Schedule
*/
-void TripleDES::key_schedule(const byte key[], size_t length)
+void TripleDES::key_schedule(const uint8_t key[], size_t length)
{
m_round_key.resize(3*32);
des_key_schedule(&m_round_key[0], key);
diff --git a/src/lib/block/des/des.h b/src/lib/block/des/des.h
index ff31421d2..f0c32be29 100644
--- a/src/lib/block/des/des.h
+++ b/src/lib/block/des/des.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL DES final : public Block_Cipher_Fixed_Params<8, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "DES"; }
BlockCipher* clone() const override { return new DES; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u32bit> m_round_key;
+ secure_vector<uint32_t> m_round_key;
};
/**
@@ -36,34 +36,34 @@ class BOTAN_DLL DES final : public Block_Cipher_Fixed_Params<8, 8>
class BOTAN_DLL TripleDES final : public Block_Cipher_Fixed_Params<8, 16, 24, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "TripleDES"; }
BlockCipher* clone() const override { return new TripleDES; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u32bit> m_round_key;
+ secure_vector<uint32_t> m_round_key;
};
/*
* DES Tables
*/
-extern const u32bit DES_SPBOX1[256];
-extern const u32bit DES_SPBOX2[256];
-extern const u32bit DES_SPBOX3[256];
-extern const u32bit DES_SPBOX4[256];
-extern const u32bit DES_SPBOX5[256];
-extern const u32bit DES_SPBOX6[256];
-extern const u32bit DES_SPBOX7[256];
-extern const u32bit DES_SPBOX8[256];
+extern const uint32_t DES_SPBOX1[256];
+extern const uint32_t DES_SPBOX2[256];
+extern const uint32_t DES_SPBOX3[256];
+extern const uint32_t DES_SPBOX4[256];
+extern const uint32_t DES_SPBOX5[256];
+extern const uint32_t DES_SPBOX6[256];
+extern const uint32_t DES_SPBOX7[256];
+extern const uint32_t DES_SPBOX8[256];
-extern const u64bit DES_IPTAB1[256];
-extern const u64bit DES_IPTAB2[256];
-extern const u64bit DES_FPTAB1[256];
-extern const u64bit DES_FPTAB2[256];
+extern const uint64_t DES_IPTAB1[256];
+extern const uint64_t DES_IPTAB2[256];
+extern const uint64_t DES_FPTAB1[256];
+extern const uint64_t DES_FPTAB2[256];
}
diff --git a/src/lib/block/des/des_tab.cpp b/src/lib/block/des/des_tab.cpp
index 0f8179995..c64b6baf6 100644
--- a/src/lib/block/des/des_tab.cpp
+++ b/src/lib/block/des/des_tab.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-const u32bit DES_SPBOX1[256] = {
+const uint32_t DES_SPBOX1[256] = {
0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404,
0x00000004, 0x00010000, 0x00000400, 0x01010400, 0x01010404, 0x00000400,
0x01000404, 0x01010004, 0x01000000, 0x00000004, 0x00000404, 0x01000400,
@@ -54,7 +54,7 @@ const u32bit DES_SPBOX1[256] = {
0x00010404, 0x01010400, 0x00000404, 0x01000400, 0x01000400, 0x00000000,
0x00010004, 0x00010400, 0x00000000, 0x01010004 };
-const u32bit DES_SPBOX2[256] = {
+const uint32_t DES_SPBOX2[256] = {
0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020,
0x80100020, 0x80008020, 0x80000020, 0x80108020, 0x80108000, 0x80000000,
0x80008000, 0x00100000, 0x00000020, 0x80100020, 0x00108000, 0x00100020,
@@ -99,7 +99,7 @@ const u32bit DES_SPBOX2[256] = {
0x80000020, 0x00100020, 0x00108000, 0x00000000, 0x80008000, 0x00008020,
0x80000000, 0x80100020, 0x80108020, 0x00108000 };
-const u32bit DES_SPBOX3[256] = {
+const uint32_t DES_SPBOX3[256] = {
0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000,
0x00020208, 0x08000200, 0x00020008, 0x08000008, 0x08000008, 0x00020000,
0x08020208, 0x00020008, 0x08020000, 0x00000208, 0x08000000, 0x00000008,
@@ -144,7 +144,7 @@ const u32bit DES_SPBOX3[256] = {
0x00020200, 0x08000008, 0x08020000, 0x08000208, 0x00000208, 0x08020000,
0x00020208, 0x00000008, 0x08020008, 0x00020200 };
-const u32bit DES_SPBOX4[256] = {
+const uint32_t DES_SPBOX4[256] = {
0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081,
0x00800001, 0x00002001, 0x00000000, 0x00802000, 0x00802000, 0x00802081,
0x00000081, 0x00000000, 0x00800080, 0x00800001, 0x00000001, 0x00002000,
@@ -189,7 +189,7 @@ const u32bit DES_SPBOX4[256] = {
0x00802080, 0x00800081, 0x00002001, 0x00002080, 0x00800000, 0x00802001,
0x00000080, 0x00800000, 0x00002000, 0x00802080 };
-const u32bit DES_SPBOX5[256] = {
+const uint32_t DES_SPBOX5[256] = {
0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100,
0x40000000, 0x02080000, 0x40080100, 0x00080000, 0x02000100, 0x40080100,
0x42000100, 0x42080000, 0x00080100, 0x40000000, 0x02000000, 0x40080000,
@@ -234,7 +234,7 @@ const u32bit DES_SPBOX5[256] = {
0x40080000, 0x42000000, 0x00080100, 0x02000100, 0x40000100, 0x00080000,
0x00000000, 0x40080000, 0x02080100, 0x40000100 };
-const u32bit DES_SPBOX6[256] = {
+const uint32_t DES_SPBOX6[256] = {
0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010,
0x20404010, 0x00400000, 0x20004000, 0x00404010, 0x00400000, 0x20000010,
0x00400010, 0x20004000, 0x20000000, 0x00004010, 0x00000000, 0x00400010,
@@ -279,7 +279,7 @@ const u32bit DES_SPBOX6[256] = {
0x20400000, 0x00404010, 0x00004000, 0x00400010, 0x20004010, 0x00000000,
0x20404000, 0x20000000, 0x00400010, 0x20004010 };
-const u32bit DES_SPBOX7[256] = {
+const uint32_t DES_SPBOX7[256] = {
0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802,
0x00200802, 0x04200800, 0x04200802, 0x00200000, 0x00000000, 0x04000002,
0x00000002, 0x04000000, 0x04200002, 0x00000802, 0x04000800, 0x00200802,
@@ -324,7 +324,7 @@ const u32bit DES_SPBOX7[256] = {
0x00000002, 0x04200802, 0x00000000, 0x00200802, 0x04200000, 0x00000800,
0x04000002, 0x04000800, 0x00000800, 0x00200002 };
-const u32bit DES_SPBOX8[256] = {
+const uint32_t DES_SPBOX8[256] = {
0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040,
0x00000040, 0x10000000, 0x00040040, 0x10040000, 0x10041040, 0x00041000,
0x10041000, 0x00041040, 0x00001000, 0x00000040, 0x10040000, 0x10000040,
@@ -369,7 +369,7 @@ const u32bit DES_SPBOX8[256] = {
0x10001040, 0x00000000, 0x10041040, 0x00041000, 0x00041000, 0x00001040,
0x00001040, 0x00040040, 0x10000000, 0x10041000 };
-const u64bit DES_IPTAB1[256] = {
+const uint64_t DES_IPTAB1[256] = {
0x0000000000000000, 0x0000000200000000, 0x0000000000000002, 0x0000000200000002,
0x0000020000000000, 0x0000020200000000, 0x0000020000000002, 0x0000020200000002,
0x0000000000000200, 0x0000000200000200, 0x0000000000000202, 0x0000000200000202,
@@ -435,7 +435,7 @@ const u64bit DES_IPTAB1[256] = {
0x0202000002020200, 0x0202000202020200, 0x0202000002020202, 0x0202000202020202,
0x0202020002020200, 0x0202020202020200, 0x0202020002020202, 0x0202020202020202 };
-const u64bit DES_IPTAB2[256] = {
+const uint64_t DES_IPTAB2[256] = {
0x0000000000000000, 0x0000010000000000, 0x0000000000000100, 0x0000010000000100,
0x0001000000000000, 0x0001010000000000, 0x0001000000000100, 0x0001010000000100,
0x0000000000010000, 0x0000010000010000, 0x0000000000010100, 0x0000010000010100,
@@ -501,7 +501,7 @@ const u64bit DES_IPTAB2[256] = {
0x0100000101010001, 0x0100010101010001, 0x0100000101010101, 0x0100010101010101,
0x0101000101010001, 0x0101010101010001, 0x0101000101010101, 0x0101010101010101 };
-const u64bit DES_FPTAB1[256] = {
+const uint64_t DES_FPTAB1[256] = {
0x0000000000000000, 0x0000000100000000, 0x0000000004000000, 0x0000000104000000,
0x0000000000040000, 0x0000000100040000, 0x0000000004040000, 0x0000000104040000,
0x0000000000000400, 0x0000000100000400, 0x0000000004000400, 0x0000000104000400,
@@ -567,7 +567,7 @@ const u64bit DES_FPTAB1[256] = {
0x0404040000000404, 0x0404040100000404, 0x0404040004000404, 0x0404040104000404,
0x0404040000040404, 0x0404040100040404, 0x0404040004040404, 0x0404040104040404 };
-const u64bit DES_FPTAB2[256] = {
+const uint64_t DES_FPTAB2[256] = {
0x0000000000000000, 0x0000004000000000, 0x0000000001000000, 0x0000004001000000,
0x0000000000010000, 0x0000004000010000, 0x0000000001010000, 0x0000004001010000,
0x0000000000000100, 0x0000004000000100, 0x0000000001000100, 0x0000004001000100,
diff --git a/src/lib/block/des/desx.cpp b/src/lib/block/des/desx.cpp
index 76a50f9a2..7c9995523 100644
--- a/src/lib/block/des/desx.cpp
+++ b/src/lib/block/des/desx.cpp
@@ -12,7 +12,7 @@ namespace Botan {
/*
* DESX Encryption
*/
-void DESX::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void DESX::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
@@ -28,7 +28,7 @@ void DESX::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* DESX Decryption
*/
-void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void DESX::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
@@ -44,7 +44,7 @@ void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* DESX Key Schedule
*/
-void DESX::key_schedule(const byte key[], size_t)
+void DESX::key_schedule(const uint8_t key[], size_t)
{
m_K1.assign(key, key + 8);
m_des.set_key(key + 8, 8);
diff --git a/src/lib/block/des/desx.h b/src/lib/block/des/desx.h
index f3c9ac99a..7bc7d047f 100644
--- a/src/lib/block/des/desx.h
+++ b/src/lib/block/des/desx.h
@@ -18,15 +18,15 @@ namespace Botan {
class BOTAN_DLL DESX final : public Block_Cipher_Fixed_Params<8, 24>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "DESX"; }
BlockCipher* clone() const override { return new DESX; }
private:
- void key_schedule(const byte[], size_t) override;
- secure_vector<byte> m_K1, m_K2;
+ void key_schedule(const uint8_t[], size_t) override;
+ secure_vector<uint8_t> m_K1, m_K2;
DES m_des;
};
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()
diff --git a/src/lib/block/gost_28147/gost_28147.h b/src/lib/block/gost_28147/gost_28147.h
index 4105154e3..6ee1ec60e 100644
--- a/src/lib/block/gost_28147/gost_28147.h
+++ b/src/lib/block/gost_28147/gost_28147.h
@@ -26,7 +26,7 @@ class BOTAN_DLL GOST_28147_89_Params
* @param col the column
* @return sbox entry at this row/column
*/
- byte sbox_entry(size_t row, size_t col) const;
+ uint8_t sbox_entry(size_t row, size_t col) const;
/**
* @return name of this parameter set
@@ -42,7 +42,7 @@ class BOTAN_DLL GOST_28147_89_Params
*/
GOST_28147_89_Params(const std::string& name = "R3411_94_TestParam");
private:
- const byte* m_sboxes;
+ const uint8_t* m_sboxes;
std::string m_name;
};
@@ -52,8 +52,8 @@ class BOTAN_DLL GOST_28147_89_Params
class BOTAN_DLL GOST_28147_89 final : public Block_Cipher_Fixed_Params<8, 32>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -65,18 +65,18 @@ class BOTAN_DLL GOST_28147_89 final : public Block_Cipher_Fixed_Params<8, 32>
*/
explicit GOST_28147_89(const GOST_28147_89_Params& params);
private:
- explicit GOST_28147_89(const std::vector<u32bit>& other_SBOX) :
+ explicit GOST_28147_89(const std::vector<uint32_t>& other_SBOX) :
m_SBOX(other_SBOX), m_EK(8) {}
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
/*
* The sbox is not secret, this is just a larger expansion of it
* which we generate at runtime for faster execution
*/
- std::vector<u32bit> m_SBOX;
+ std::vector<uint32_t> m_SBOX;
- secure_vector<u32bit> m_EK;
+ secure_vector<uint32_t> m_EK;
};
}
diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp
index 1fe25d599..4eab6a4f3 100644
--- a/src/lib/block/idea/idea.cpp
+++ b/src/lib/block/idea/idea.cpp
@@ -17,17 +17,17 @@ namespace {
/*
* Multiplication modulo 65537
*/
-inline u16bit mul(u16bit x, u16bit y)
+inline uint16_t mul(uint16_t x, uint16_t y)
{
- const u32bit P = static_cast<u32bit>(x) * y;
+ const uint32_t P = static_cast<uint32_t>(x) * y;
- const u16bit Z_mask = static_cast<u16bit>(CT::expand_mask(P) & 0xFFFF);
+ const uint16_t Z_mask = static_cast<uint16_t>(CT::expand_mask(P) & 0xFFFF);
- const u32bit P_hi = P >> 16;
- const u32bit P_lo = P & 0xFFFF;
+ const uint32_t P_hi = P >> 16;
+ const uint32_t P_lo = P & 0xFFFF;
- const u16bit r_1 = (P_lo - P_hi) + (P_lo < P_hi);
- const u16bit r_2 = 1 - x - y;
+ const uint16_t r_1 = (P_lo - P_hi) + (P_lo < P_hi);
+ const uint16_t r_2 = 1 - x - y;
return CT::select(Z_mask, r_1, r_2);
}
@@ -43,9 +43,9 @@ inline u16bit mul(u16bit x, u16bit y)
* Do the exponentiation with a basic square and multiply: all bits are
* of exponent are 1 so we always multiply
*/
-u16bit mul_inv(u16bit x)
+uint16_t mul_inv(uint16_t x)
{
- u16bit y = x;
+ uint16_t y = x;
for(size_t i = 0; i != 15; ++i)
{
@@ -59,7 +59,7 @@ u16bit mul_inv(u16bit x)
/**
* IDEA is involutional, depending only on the key schedule
*/
-void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52])
+void idea_op(const uint8_t in[], uint8_t out[], size_t blocks, const uint16_t K[52])
{
const size_t BLOCK_SIZE = 8;
@@ -69,7 +69,7 @@ void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52])
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u16bit X1, X2, X3, X4;
+ uint16_t X1, X2, X3, X4;
load_be(in + BLOCK_SIZE*i, X1, X2, X3, X4);
for(size_t j = 0; j != 8; ++j)
@@ -79,10 +79,10 @@ void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52])
X3 += K[6*j+2];
X4 = mul(X4, K[6*j+3]);
- u16bit T0 = X3;
+ uint16_t T0 = X3;
X3 = mul(X3 ^ X1, K[6*j+4]);
- u16bit T1 = X2;
+ uint16_t T1 = X2;
X2 = mul((X2 ^ X4) + X3, K[6*j+5]);
X3 += X2;
@@ -122,7 +122,7 @@ std::string IDEA::provider() const
/*
* IDEA Encryption
*/
-void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void IDEA::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_IDEA_SSE2)
if(CPUID::has_sse2())
@@ -143,7 +143,7 @@ void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* IDEA Decryption
*/
-void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void IDEA::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_IDEA_SSE2)
if(CPUID::has_sse2())
@@ -164,7 +164,7 @@ void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* IDEA Key Schedule
*/
-void IDEA::key_schedule(const byte key[], size_t)
+void IDEA::key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(52);
m_DK.resize(52);
@@ -174,11 +174,11 @@ void IDEA::key_schedule(const byte key[], size_t)
CT::poison(m_DK.data(), 52);
for(size_t i = 0; i != 8; ++i)
- m_EK[i] = load_be<u16bit>(key, i);
+ m_EK[i] = load_be<uint16_t>(key, i);
for(size_t i = 1, j = 8, offset = 0; j != 52; i %= 8, ++i, ++j)
{
- m_EK[i+7+offset] = static_cast<u16bit>((m_EK[(i % 8) + offset] << 9) |
+ m_EK[i+7+offset] = static_cast<uint16_t>((m_EK[(i % 8) + offset] << 9) |
(m_EK[((i+1) % 8) + offset] >> 7));
offset += (i == 8) ? 8 : 0;
}
diff --git a/src/lib/block/idea/idea.h b/src/lib/block/idea/idea.h
index eb391a0c8..5a718867b 100644
--- a/src/lib/block/idea/idea.h
+++ b/src/lib/block/idea/idea.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL IDEA final : public Block_Cipher_Fixed_Params<8, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
@@ -28,12 +28,12 @@ class BOTAN_DLL IDEA final : public Block_Cipher_Fixed_Params<8, 16>
BlockCipher* clone() const override { return new IDEA; }
private:
#if defined(BOTAN_HAS_IDEA_SSE2)
- void sse2_idea_op_8(const byte in[64], byte out[64], const u16bit EK[52]) const;
+ void sse2_idea_op_8(const uint8_t in[64], uint8_t out[64], const uint16_t EK[52]) const;
#endif
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u16bit> m_EK, m_DK;
+ secure_vector<uint16_t> m_EK, m_DK;
};
}
diff --git a/src/lib/block/idea/idea_sse2/idea_sse2.cpp b/src/lib/block/idea/idea_sse2/idea_sse2.cpp
index 1e63a8332..93648cfc7 100644
--- a/src/lib/block/idea/idea_sse2/idea_sse2.cpp
+++ b/src/lib/block/idea/idea_sse2/idea_sse2.cpp
@@ -14,7 +14,7 @@ namespace Botan {
namespace {
BOTAN_FUNC_ISA("sse2")
-inline __m128i mul(__m128i X, u16bit K_16)
+inline __m128i mul(__m128i X, uint16_t K_16)
{
const __m128i zeros = _mm_set1_epi16(0);
const __m128i ones = _mm_set1_epi16(1);
@@ -134,7 +134,7 @@ void transpose_out(__m128i& B0, __m128i& B1, __m128i& B2, __m128i& B3)
* 8 wide IDEA encryption/decryption in SSE2
*/
BOTAN_FUNC_ISA("sse2")
-void IDEA::sse2_idea_op_8(const byte in[64], byte out[64], const u16bit EK[52]) const
+void IDEA::sse2_idea_op_8(const uint8_t in[64], uint8_t out[64], const uint16_t EK[52]) const
{
CT::poison(in, 64);
CT::poison(out, 64);
diff --git a/src/lib/block/kasumi/kasumi.cpp b/src/lib/block/kasumi/kasumi.cpp
index 014987bc6..92ad5dd14 100644
--- a/src/lib/block/kasumi/kasumi.cpp
+++ b/src/lib/block/kasumi/kasumi.cpp
@@ -15,7 +15,7 @@ namespace {
/*
* KASUMI S-Boxes
*/
-const byte KASUMI_SBOX_S7[128] = {
+const uint8_t KASUMI_SBOX_S7[128] = {
0x36, 0x32, 0x3E, 0x38, 0x16, 0x22, 0x5E, 0x60, 0x26, 0x06, 0x3F, 0x5D,
0x02, 0x12, 0x7B, 0x21, 0x37, 0x71, 0x27, 0x72, 0x15, 0x43, 0x41, 0x0C,
0x2F, 0x49, 0x2E, 0x1B, 0x19, 0x6F, 0x7C, 0x51, 0x35, 0x09, 0x79, 0x4F,
@@ -28,7 +28,7 @@ const byte KASUMI_SBOX_S7[128] = {
0x44, 0x1D, 0x73, 0x2C, 0x40, 0x6B, 0x6C, 0x18, 0x6E, 0x53, 0x24, 0x4E,
0x2A, 0x13, 0x0F, 0x29, 0x58, 0x77, 0x3B, 0x03 };
-const u16bit KASUMI_SBOX_S9[512] = {
+const uint16_t KASUMI_SBOX_S9[512] = {
0x00A7, 0x00EF, 0x00A1, 0x017B, 0x0187, 0x014E, 0x0009, 0x0152, 0x0026,
0x00E2, 0x0030, 0x0166, 0x01C4, 0x0181, 0x005A, 0x018D, 0x00B7, 0x00FD,
0x0093, 0x014B, 0x019F, 0x0154, 0x0033, 0x016A, 0x0132, 0x01F4, 0x0106,
@@ -90,10 +90,10 @@ const u16bit KASUMI_SBOX_S9[512] = {
/*
* KASUMI FI Function
*/
-u16bit FI(u16bit I, u16bit K)
+uint16_t FI(uint16_t I, uint16_t K)
{
- u16bit D9 = (I >> 7);
- byte D7 = (I & 0x7F);
+ uint16_t D9 = (I >> 7);
+ uint8_t D7 = (I & 0x7F);
D9 = KASUMI_SBOX_S9[D9] ^ D7;
D7 = KASUMI_SBOX_S7[D7] ^ (D9 & 0x7F);
@@ -108,21 +108,21 @@ u16bit FI(u16bit I, u16bit K)
/*
* KASUMI Encryption
*/
-void KASUMI::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void KASUMI::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u16bit B0 = load_be<u16bit>(in, 0);
- u16bit B1 = load_be<u16bit>(in, 1);
- u16bit B2 = load_be<u16bit>(in, 2);
- u16bit B3 = load_be<u16bit>(in, 3);
+ uint16_t B0 = load_be<uint16_t>(in, 0);
+ uint16_t B1 = load_be<uint16_t>(in, 1);
+ uint16_t B2 = load_be<uint16_t>(in, 2);
+ uint16_t B3 = load_be<uint16_t>(in, 3);
for(size_t j = 0; j != 8; j += 2)
{
- const u16bit* K = &m_EK[8*j];
+ const uint16_t* K = &m_EK[8*j];
- u16bit R = B1 ^ (rotate_left(B0, 1) & K[0]);
- u16bit L = B0 ^ (rotate_left(R, 1) | K[1]);
+ uint16_t R = B1 ^ (rotate_left(B0, 1) & K[0]);
+ uint16_t L = B0 ^ (rotate_left(R, 1) | K[1]);
L = FI(L ^ K[ 2], K[ 3]) ^ R;
R = FI(R ^ K[ 4], K[ 5]) ^ L;
@@ -152,20 +152,20 @@ void KASUMI::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* KASUMI Decryption
*/
-void KASUMI::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void KASUMI::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u16bit B0 = load_be<u16bit>(in, 0);
- u16bit B1 = load_be<u16bit>(in, 1);
- u16bit B2 = load_be<u16bit>(in, 2);
- u16bit B3 = load_be<u16bit>(in, 3);
+ uint16_t B0 = load_be<uint16_t>(in, 0);
+ uint16_t B1 = load_be<uint16_t>(in, 1);
+ uint16_t B2 = load_be<uint16_t>(in, 2);
+ uint16_t B3 = load_be<uint16_t>(in, 3);
for(size_t j = 0; j != 8; j += 2)
{
- const u16bit* K = &m_EK[8*(6-j)];
+ const uint16_t* K = &m_EK[8*(6-j)];
- u16bit L = B2, R = B3;
+ uint16_t L = B2, R = B3;
L = FI(L ^ K[10], K[11]) ^ R;
R = FI(R ^ K[12], K[13]) ^ L;
@@ -198,15 +198,15 @@ void KASUMI::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* KASUMI Key Schedule
*/
-void KASUMI::key_schedule(const byte key[], size_t)
+void KASUMI::key_schedule(const uint8_t key[], size_t)
{
- static const u16bit RC[] = { 0x0123, 0x4567, 0x89AB, 0xCDEF,
+ static const uint16_t RC[] = { 0x0123, 0x4567, 0x89AB, 0xCDEF,
0xFEDC, 0xBA98, 0x7654, 0x3210 };
- secure_vector<u16bit> K(16);
+ secure_vector<uint16_t> K(16);
for(size_t i = 0; i != 8; ++i)
{
- K[i] = load_be<u16bit>(key, i);
+ K[i] = load_be<uint16_t>(key, i);
K[i+8] = K[i] ^ RC[i];
}
diff --git a/src/lib/block/kasumi/kasumi.h b/src/lib/block/kasumi/kasumi.h
index 24fd83050..4c6acdadd 100644
--- a/src/lib/block/kasumi/kasumi.h
+++ b/src/lib/block/kasumi/kasumi.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL KASUMI final : public Block_Cipher_Fixed_Params<8, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "KASUMI"; }
BlockCipher* clone() const override { return new KASUMI; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u16bit> m_EK;
+ secure_vector<uint16_t> m_EK;
};
}
diff --git a/src/lib/block/lion/lion.cpp b/src/lib/block/lion/lion.cpp
index 56aa55c2f..4df22dd0b 100644
--- a/src/lib/block/lion/lion.cpp
+++ b/src/lib/block/lion/lion.cpp
@@ -13,13 +13,13 @@ namespace Botan {
/*
* Lion Encryption
*/
-void Lion::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Lion::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const size_t LEFT_SIZE = left_size();
const size_t RIGHT_SIZE = right_size();
- secure_vector<byte> buffer_vec(LEFT_SIZE);
- byte* buffer = buffer_vec.data();
+ secure_vector<uint8_t> buffer_vec(LEFT_SIZE);
+ uint8_t* buffer = buffer_vec.data();
for(size_t i = 0; i != blocks; ++i)
{
@@ -43,13 +43,13 @@ void Lion::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Lion Decryption
*/
-void Lion::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Lion::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
const size_t LEFT_SIZE = left_size();
const size_t RIGHT_SIZE = right_size();
- secure_vector<byte> buffer_vec(LEFT_SIZE);
- byte* buffer = buffer_vec.data();
+ secure_vector<uint8_t> buffer_vec(LEFT_SIZE);
+ uint8_t* buffer = buffer_vec.data();
for(size_t i = 0; i != blocks; ++i)
{
@@ -73,7 +73,7 @@ void Lion::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Lion Key Schedule
*/
-void Lion::key_schedule(const byte key[], size_t length)
+void Lion::key_schedule(const uint8_t key[], size_t length)
{
clear();
diff --git a/src/lib/block/lion/lion.h b/src/lib/block/lion/lion.h
index e6ecca64f..5d82370ae 100644
--- a/src/lib/block/lion/lion.h
+++ b/src/lib/block/lion/lion.h
@@ -25,8 +25,8 @@ namespace Botan {
class BOTAN_DLL Lion final : public BlockCipher
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
size_t block_size() const override { return m_block_size; }
@@ -48,7 +48,7 @@ class BOTAN_DLL Lion final : public BlockCipher
StreamCipher* cipher,
size_t block_size);
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
size_t left_size() const { return m_hash->output_length(); }
size_t right_size() const { return m_block_size - left_size(); }
@@ -56,7 +56,7 @@ class BOTAN_DLL Lion final : public BlockCipher
const size_t m_block_size;
std::unique_ptr<HashFunction> m_hash;
std::unique_ptr<StreamCipher> m_cipher;
- secure_vector<byte> m_key1, m_key2;
+ secure_vector<uint8_t> m_key1, m_key2;
};
}
diff --git a/src/lib/block/misty1/misty1.cpp b/src/lib/block/misty1/misty1.cpp
index 7f8ac7c76..9afed9168 100644
--- a/src/lib/block/misty1/misty1.cpp
+++ b/src/lib/block/misty1/misty1.cpp
@@ -13,7 +13,7 @@ namespace Botan {
namespace {
-static const byte MISTY1_SBOX_S7[128] = {
+static const uint8_t MISTY1_SBOX_S7[128] = {
0x1B, 0x32, 0x33, 0x5A, 0x3B, 0x10, 0x17, 0x54, 0x5B, 0x1A, 0x72, 0x73,
0x6B, 0x2C, 0x66, 0x49, 0x1F, 0x24, 0x13, 0x6C, 0x37, 0x2E, 0x3F, 0x4A,
0x5D, 0x0F, 0x40, 0x56, 0x25, 0x51, 0x1C, 0x04, 0x0B, 0x46, 0x20, 0x0D,
@@ -26,7 +26,7 @@ static const byte MISTY1_SBOX_S7[128] = {
0x2D, 0x7A, 0x7F, 0x61, 0x50, 0x22, 0x11, 0x06, 0x47, 0x16, 0x52, 0x4E,
0x71, 0x3E, 0x69, 0x43, 0x34, 0x5C, 0x58, 0x7D };
-static const u16bit MISTY1_SBOX_S9[512] = {
+static const uint16_t MISTY1_SBOX_S9[512] = {
0x01C3, 0x00CB, 0x0153, 0x019F, 0x01E3, 0x00E9, 0x00FB, 0x0035, 0x0181,
0x00B9, 0x0117, 0x01EB, 0x0133, 0x0009, 0x002D, 0x00D3, 0x00C7, 0x014A,
0x0037, 0x007E, 0x00EB, 0x0164, 0x0193, 0x01D8, 0x00A3, 0x011E, 0x0055,
@@ -88,13 +88,13 @@ static const u16bit MISTY1_SBOX_S9[512] = {
/*
* MISTY1 FI Function
*/
-u16bit FI(u16bit input, u16bit key7, u16bit key9)
+uint16_t FI(uint16_t input, uint16_t key7, uint16_t key9)
{
- u16bit D9 = input >> 7, D7 = input & 0x7F;
+ uint16_t D9 = input >> 7, D7 = input & 0x7F;
D9 = MISTY1_SBOX_S9[D9] ^ D7;
D7 = (MISTY1_SBOX_S7[D7] ^ key7 ^ D9) & 0x7F;
D9 = MISTY1_SBOX_S9[D9 ^ key9] ^ D7;
- return static_cast<u16bit>((D7 << 9) | D9);
+ return static_cast<uint16_t>((D7 << 9) | D9);
}
}
@@ -102,25 +102,25 @@ u16bit FI(u16bit input, u16bit key7, u16bit key9)
/*
* MISTY1 Encryption
*/
-void MISTY1::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void MISTY1::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u16bit B0 = load_be<u16bit>(in, 0);
- u16bit B1 = load_be<u16bit>(in, 1);
- u16bit B2 = load_be<u16bit>(in, 2);
- u16bit B3 = load_be<u16bit>(in, 3);
+ uint16_t B0 = load_be<uint16_t>(in, 0);
+ uint16_t B1 = load_be<uint16_t>(in, 1);
+ uint16_t B2 = load_be<uint16_t>(in, 2);
+ uint16_t B3 = load_be<uint16_t>(in, 3);
for(size_t j = 0; j != 12; j += 3)
{
- const u16bit* RK = &m_EK[8 * j];
+ const uint16_t* RK = &m_EK[8 * j];
B1 ^= B0 & RK[0];
B0 ^= B1 | RK[1];
B3 ^= B2 & RK[2];
B2 ^= B3 | RK[3];
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = FI(B0 ^ RK[ 4], RK[ 5], RK[ 6]) ^ B1;
T1 = FI(B1 ^ RK[ 7], RK[ 8], RK[ 9]) ^ T0;
@@ -152,25 +152,25 @@ void MISTY1::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* MISTY1 Decryption
*/
-void MISTY1::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void MISTY1::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u16bit B0 = load_be<u16bit>(in, 2);
- u16bit B1 = load_be<u16bit>(in, 3);
- u16bit B2 = load_be<u16bit>(in, 0);
- u16bit B3 = load_be<u16bit>(in, 1);
+ uint16_t B0 = load_be<uint16_t>(in, 2);
+ uint16_t B1 = load_be<uint16_t>(in, 3);
+ uint16_t B2 = load_be<uint16_t>(in, 0);
+ uint16_t B3 = load_be<uint16_t>(in, 1);
for(size_t j = 0; j != 12; j += 3)
{
- const u16bit* RK = &m_DK[8 * j];
+ const uint16_t* RK = &m_DK[8 * j];
B2 ^= B3 | RK[0];
B3 ^= B2 & RK[1];
B0 ^= B1 | RK[2];
B1 ^= B0 & RK[3];
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = FI(B2 ^ RK[ 4], RK[ 5], RK[ 6]) ^ B3;
T1 = FI(B3 ^ RK[ 7], RK[ 8], RK[ 9]) ^ T0;
@@ -202,11 +202,11 @@ void MISTY1::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* MISTY1 Key Schedule
*/
-void MISTY1::key_schedule(const byte key[], size_t length)
+void MISTY1::key_schedule(const uint8_t key[], size_t length)
{
- secure_vector<u16bit> KS(32);
+ secure_vector<uint16_t> KS(32);
for(size_t i = 0; i != length / 2; ++i)
- KS[i] = load_be<u16bit>(key, i);
+ KS[i] = load_be<uint16_t>(key, i);
for(size_t i = 0; i != 8; ++i)
{
@@ -219,7 +219,7 @@ void MISTY1::key_schedule(const byte key[], size_t length)
* Precomputed indexes for the orderings of the subkeys (MISTY1 reuses
* values)
*/
- static const byte EK_ORDER[100] = {
+ static const uint8_t EK_ORDER[100] = {
0x00, 0x0E, 0x0A, 0x04, 0x00, 0x15, 0x1D, 0x02, 0x11, 0x19, 0x07, 0x13,
0x1B, 0x04, 0x01, 0x16, 0x1E, 0x03, 0x12, 0x1A, 0x00, 0x14, 0x1C, 0x05,
0x01, 0x0F, 0x0B, 0x05, 0x02, 0x17, 0x1F, 0x04, 0x13, 0x1B, 0x01, 0x15,
@@ -230,7 +230,7 @@ void MISTY1::key_schedule(const byte key[], size_t length)
0x19, 0x02, 0x07, 0x14, 0x1C, 0x01, 0x10, 0x18, 0x06, 0x12, 0x1A, 0x03,
0x04, 0x0A, 0x0E, 0x00 };
- static const byte DK_ORDER[100] = {
+ static const uint8_t DK_ORDER[100] = {
0x00, 0x0E, 0x0A, 0x04, 0x07, 0x14, 0x1C, 0x01, 0x10, 0x18, 0x06, 0x12,
0x1A, 0x03, 0x06, 0x13, 0x1B, 0x00, 0x17, 0x1F, 0x05, 0x11, 0x19, 0x02,
0x07, 0x0D, 0x09, 0x03, 0x05, 0x12, 0x1A, 0x07, 0x16, 0x1E, 0x04, 0x10,
diff --git a/src/lib/block/misty1/misty1.h b/src/lib/block/misty1/misty1.h
index 791ace6aa..865e6c935 100644
--- a/src/lib/block/misty1/misty1.h
+++ b/src/lib/block/misty1/misty1.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL MISTY1 final : public Block_Cipher_Fixed_Params<8, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "MISTY1"; }
BlockCipher* clone() const override { return new MISTY1; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u16bit> m_EK, m_DK;
+ secure_vector<uint16_t> m_EK, m_DK;
};
}
diff --git a/src/lib/block/noekeon/noekeon.cpp b/src/lib/block/noekeon/noekeon.cpp
index eac0979a4..419f5d01a 100644
--- a/src/lib/block/noekeon/noekeon.cpp
+++ b/src/lib/block/noekeon/noekeon.cpp
@@ -16,11 +16,11 @@ namespace {
/*
* Noekeon's Theta Operation
*/
-inline void theta(u32bit& A0, u32bit& A1,
- u32bit& A2, u32bit& A3,
- const u32bit EK[4])
+inline void theta(uint32_t& A0, uint32_t& A1,
+ uint32_t& A2, uint32_t& A3,
+ const uint32_t EK[4])
{
- u32bit T = A0 ^ A2;
+ uint32_t T = A0 ^ A2;
T ^= rotate_left(T, 8) ^ rotate_right(T, 8);
A1 ^= T;
A3 ^= T;
@@ -39,10 +39,10 @@ inline void theta(u32bit& A0, u32bit& A1,
/*
* Theta With Null Key
*/
-inline void theta(u32bit& A0, u32bit& A1,
- u32bit& A2, u32bit& A3)
+inline void theta(uint32_t& A0, uint32_t& A1,
+ uint32_t& A2, uint32_t& A3)
{
- u32bit T = A0 ^ A2;
+ uint32_t T = A0 ^ A2;
T ^= rotate_left(T, 8) ^ rotate_right(T, 8);
A1 ^= T;
A3 ^= T;
@@ -56,12 +56,12 @@ inline void theta(u32bit& A0, u32bit& A1,
/*
* Noekeon's Gamma S-Box Layer
*/
-inline void gamma(u32bit& A0, u32bit& A1, u32bit& A2, u32bit& A3)
+inline void gamma(uint32_t& A0, uint32_t& A1, uint32_t& A2, uint32_t& A3)
{
A1 ^= ~A3 & ~A2;
A0 ^= A2 & A1;
- u32bit T = A3;
+ uint32_t T = A3;
A3 = A0;
A0 = T;
@@ -88,7 +88,7 @@ std::string Noekeon::provider() const
/*
* Noekeon Round Constants
*/
-const byte Noekeon::RC[] = {
+const uint8_t Noekeon::RC[] = {
0x80, 0x1B, 0x36, 0x6C, 0xD8, 0xAB, 0x4D, 0x9A,
0x2F, 0x5E, 0xBC, 0x63, 0xC6, 0x97, 0x35, 0x6A,
0xD4 };
@@ -96,7 +96,7 @@ const byte Noekeon::RC[] = {
/*
* Noekeon Encryption
*/
-void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Noekeon::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_NOEKEON_SIMD)
if(CPUID::has_simd_32())
@@ -113,10 +113,10 @@ void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
for(size_t i = 0; i != blocks; ++i)
{
- u32bit A0 = load_be<u32bit>(in, 0);
- u32bit A1 = load_be<u32bit>(in, 1);
- u32bit A2 = load_be<u32bit>(in, 2);
- u32bit A3 = load_be<u32bit>(in, 3);
+ uint32_t A0 = load_be<uint32_t>(in, 0);
+ uint32_t A1 = load_be<uint32_t>(in, 1);
+ uint32_t A2 = load_be<uint32_t>(in, 2);
+ uint32_t A3 = load_be<uint32_t>(in, 3);
for(size_t j = 0; j != 16; ++j)
{
@@ -147,7 +147,7 @@ void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Noekeon Encryption
*/
-void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Noekeon::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_NOEKEON_SIMD)
if(CPUID::has_simd_32())
@@ -177,10 +177,10 @@ void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const
for(size_t i = 0; i != blocks; ++i)
{
- u32bit A0 = load_be<u32bit>(in, 0);
- u32bit A1 = load_be<u32bit>(in, 1);
- u32bit A2 = load_be<u32bit>(in, 2);
- u32bit A3 = load_be<u32bit>(in, 3);
+ uint32_t A0 = load_be<uint32_t>(in, 0);
+ uint32_t A1 = load_be<uint32_t>(in, 1);
+ uint32_t A2 = load_be<uint32_t>(in, 2);
+ uint32_t A3 = load_be<uint32_t>(in, 3);
for(size_t j = 16; j != 0; --j)
{
@@ -211,12 +211,12 @@ void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Noekeon Key Schedule
*/
-void Noekeon::key_schedule(const byte key[], size_t)
+void Noekeon::key_schedule(const uint8_t key[], size_t)
{
- u32bit A0 = load_be<u32bit>(key, 0);
- u32bit A1 = load_be<u32bit>(key, 1);
- u32bit A2 = load_be<u32bit>(key, 2);
- u32bit A3 = load_be<u32bit>(key, 3);
+ uint32_t A0 = load_be<uint32_t>(key, 0);
+ uint32_t A1 = load_be<uint32_t>(key, 1);
+ uint32_t A2 = load_be<uint32_t>(key, 2);
+ uint32_t A3 = load_be<uint32_t>(key, 3);
for(size_t i = 0; i != 16; ++i)
{
diff --git a/src/lib/block/noekeon/noekeon.h b/src/lib/block/noekeon/noekeon.h
index b0aa4218c..83af6d8d7 100644
--- a/src/lib/block/noekeon/noekeon.h
+++ b/src/lib/block/noekeon/noekeon.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL Noekeon final : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
std::string provider() const override;
void clear() override;
@@ -27,17 +27,17 @@ class BOTAN_DLL Noekeon final : public Block_Cipher_Fixed_Params<16, 16>
BlockCipher* clone() const override { return new Noekeon; }
private:
#if defined(BOTAN_HAS_NOEKEON_SIMD)
- void simd_encrypt_4(const byte in[], byte out[]) const;
- void simd_decrypt_4(const byte in[], byte out[]) const;
+ void simd_encrypt_4(const uint8_t in[], uint8_t out[]) const;
+ void simd_decrypt_4(const uint8_t in[], uint8_t out[]) const;
#endif
/**
* The Noekeon round constants
*/
- static const byte RC[17];
+ static const uint8_t RC[17];
- void key_schedule(const byte[], size_t) override;
- secure_vector<u32bit> m_EK, m_DK;
+ void key_schedule(const uint8_t[], size_t) override;
+ secure_vector<uint32_t> m_EK, m_DK;
};
}
diff --git a/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp b/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp
index e37412b5f..03048ec9c 100644
--- a/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp
+++ b/src/lib/block/noekeon/noekeon_simd/noekeon_simd.cpp
@@ -63,7 +63,7 @@ namespace Botan {
/*
* Noekeon Encryption
*/
-void Noekeon::simd_encrypt_4(const byte in[], byte out[]) const
+void Noekeon::simd_encrypt_4(const uint8_t in[], uint8_t out[]) const
{
const SIMD_32 K0 = SIMD_32(m_EK[0]);
const SIMD_32 K1 = SIMD_32(m_EK[1]);
@@ -108,7 +108,7 @@ void Noekeon::simd_encrypt_4(const byte in[], byte out[]) const
/*
* Noekeon Encryption
*/
-void Noekeon::simd_decrypt_4(const byte in[], byte out[]) const
+void Noekeon::simd_decrypt_4(const uint8_t in[], uint8_t out[]) const
{
const SIMD_32 K0 = SIMD_32(m_DK[0]);
const SIMD_32 K1 = SIMD_32(m_DK[1]);
diff --git a/src/lib/block/seed/seed.cpp b/src/lib/block/seed/seed.cpp
index 24afed67d..0df35383f 100644
--- a/src/lib/block/seed/seed.cpp
+++ b/src/lib/block/seed/seed.cpp
@@ -12,7 +12,7 @@ namespace Botan {
namespace {
-const u32bit SEED_S0[256] = {
+const uint32_t SEED_S0[256] = {
0x2989A1A8, 0x05858184, 0x16C6D2D4, 0x13C3D3D0, 0x14445054, 0x1D0D111C,
0x2C8CA0AC, 0x25052124, 0x1D4D515C, 0x03434340, 0x18081018, 0x1E0E121C,
0x11415150, 0x3CCCF0FC, 0x0ACAC2C8, 0x23436360, 0x28082028, 0x04444044,
@@ -57,7 +57,7 @@ const u32bit SEED_S0[256] = {
0x07070304, 0x33033330, 0x28C8E0E8, 0x1B0B1318, 0x05050104, 0x39497178,
0x10809090, 0x2A4A6268, 0x2A0A2228, 0x1A8A9298 };
-const u32bit SEED_S1[256] = {
+const uint32_t SEED_S1[256] = {
0x38380830, 0xE828C8E0, 0x2C2D0D21, 0xA42686A2, 0xCC0FCFC3, 0xDC1ECED2,
0xB03383B3, 0xB83888B0, 0xAC2F8FA3, 0x60204060, 0x54154551, 0xC407C7C3,
0x44044440, 0x6C2F4F63, 0x682B4B63, 0x581B4B53, 0xC003C3C3, 0x60224262,
@@ -102,7 +102,7 @@ const u32bit SEED_S1[256] = {
0x080A0A02, 0x84078783, 0xD819C9D1, 0x4C0C4C40, 0x80038383, 0x8C0F8F83,
0xCC0ECEC2, 0x383B0B33, 0x480A4A42, 0xB43787B3 };
-const u32bit SEED_S2[256] = {
+const uint32_t SEED_S2[256] = {
0xA1A82989, 0x81840585, 0xD2D416C6, 0xD3D013C3, 0x50541444, 0x111C1D0D,
0xA0AC2C8C, 0x21242505, 0x515C1D4D, 0x43400343, 0x10181808, 0x121C1E0E,
0x51501141, 0xF0FC3CCC, 0xC2C80ACA, 0x63602343, 0x20282808, 0x40440444,
@@ -147,7 +147,7 @@ const u32bit SEED_S2[256] = {
0x03040707, 0x33303303, 0xE0E828C8, 0x13181B0B, 0x01040505, 0x71783949,
0x90901080, 0x62682A4A, 0x22282A0A, 0x92981A8A };
-const u32bit SEED_S3[256] = {
+const uint32_t SEED_S3[256] = {
0x08303838, 0xC8E0E828, 0x0D212C2D, 0x86A2A426, 0xCFC3CC0F, 0xCED2DC1E,
0x83B3B033, 0x88B0B838, 0x8FA3AC2F, 0x40606020, 0x45515415, 0xC7C3C407,
0x44404404, 0x4F636C2F, 0x4B63682B, 0x4B53581B, 0xC3C3C003, 0x42626022,
@@ -195,7 +195,7 @@ const u32bit SEED_S3[256] = {
/*
* SEED G Function
*/
-inline u32bit SEED_G(u32bit X)
+inline uint32_t SEED_G(uint32_t X)
{
return (SEED_S0[get_byte(3, X)] ^ SEED_S1[get_byte(2, X)] ^
SEED_S2[get_byte(1, X)] ^ SEED_S3[get_byte(0, X)]);
@@ -206,18 +206,18 @@ inline u32bit SEED_G(u32bit X)
/*
* SEED Encryption
*/
-void SEED::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void SEED::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit B0 = load_be<u32bit>(in, 0);
- u32bit B1 = load_be<u32bit>(in, 1);
- u32bit B2 = load_be<u32bit>(in, 2);
- u32bit B3 = load_be<u32bit>(in, 3);
+ uint32_t B0 = load_be<uint32_t>(in, 0);
+ uint32_t B1 = load_be<uint32_t>(in, 1);
+ uint32_t B2 = load_be<uint32_t>(in, 2);
+ uint32_t B3 = load_be<uint32_t>(in, 3);
for(size_t j = 0; j != 16; j += 2)
{
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = B2 ^ m_K[2*j];
T1 = SEED_G(B2 ^ B3 ^ m_K[2*j+1]);
@@ -244,18 +244,18 @@ void SEED::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* SEED Decryption
*/
-void SEED::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void SEED::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
for(size_t i = 0; i != blocks; ++i)
{
- u32bit B0 = load_be<u32bit>(in, 0);
- u32bit B1 = load_be<u32bit>(in, 1);
- u32bit B2 = load_be<u32bit>(in, 2);
- u32bit B3 = load_be<u32bit>(in, 3);
+ uint32_t B0 = load_be<uint32_t>(in, 0);
+ uint32_t B1 = load_be<uint32_t>(in, 1);
+ uint32_t B2 = load_be<uint32_t>(in, 2);
+ uint32_t B3 = load_be<uint32_t>(in, 3);
for(size_t j = 0; j != 16; j += 2)
{
- u32bit T0, T1;
+ uint32_t T0, T1;
T0 = B2 ^ m_K[30-2*j];
T1 = SEED_G(B2 ^ B3 ^ m_K[31-2*j]);
@@ -282,19 +282,19 @@ void SEED::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* SEED Key Schedule
*/
-void SEED::key_schedule(const byte key[], size_t)
+void SEED::key_schedule(const uint8_t key[], size_t)
{
- const u32bit RC[16] = {
+ const uint32_t RC[16] = {
0x9E3779B9, 0x3C6EF373, 0x78DDE6E6, 0xF1BBCDCC,
0xE3779B99, 0xC6EF3733, 0x8DDE6E67, 0x1BBCDCCF,
0x3779B99E, 0x6EF3733C, 0xDDE6E678, 0xBBCDCCF1,
0x779B99E3, 0xEF3733C6, 0xDE6E678D, 0xBCDCCF1B
};
- secure_vector<u32bit> WK(4);
+ secure_vector<uint32_t> WK(4);
for(size_t i = 0; i != 4; ++i)
- WK[i] = load_be<u32bit>(key, i);
+ WK[i] = load_be<uint32_t>(key, i);
m_K.resize(32);
@@ -303,7 +303,7 @@ void SEED::key_schedule(const byte key[], size_t)
m_K[2*i ] = SEED_G(WK[0] + WK[2] - RC[i]);
m_K[2*i+1] = SEED_G(WK[1] - WK[3] + RC[i]) ^ m_K[2*i];
- byte T = get_byte(3, WK[0]);
+ uint8_t T = get_byte(3, WK[0]);
WK[0] = (WK[0] >> 8) | (get_byte(3, WK[1]) << 24);
WK[1] = (WK[1] >> 8) | (T << 24);
diff --git a/src/lib/block/seed/seed.h b/src/lib/block/seed/seed.h
index 45e691913..99a510e70 100644
--- a/src/lib/block/seed/seed.h
+++ b/src/lib/block/seed/seed.h
@@ -18,16 +18,16 @@ namespace Botan {
class BOTAN_DLL SEED final : public Block_Cipher_Fixed_Params<16, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "SEED"; }
BlockCipher* clone() const override { return new SEED; }
private:
- void key_schedule(const byte[], size_t) override;
+ void key_schedule(const uint8_t[], size_t) override;
- secure_vector<u32bit> m_K;
+ secure_vector<uint32_t> m_K;
};
}
diff --git a/src/lib/block/serpent/serpent.cpp b/src/lib/block/serpent/serpent.cpp
index a1326b888..93af81231 100644
--- a/src/lib/block/serpent/serpent.cpp
+++ b/src/lib/block/serpent/serpent.cpp
@@ -20,7 +20,7 @@ namespace {
/*
* Serpent's Linear Transform
*/
-inline void transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
+inline void transform(uint32_t& B0, uint32_t& B1, uint32_t& B2, uint32_t& B3)
{
B0 = rotate_left(B0, 13); B2 = rotate_left(B2, 3);
B1 ^= B0 ^ B2; B3 ^= B2 ^ (B0 << 3);
@@ -32,7 +32,7 @@ inline void transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
/*
* Serpent's Inverse Linear Transform
*/
-inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
+inline void i_transform(uint32_t& B0, uint32_t& B1, uint32_t& B2, uint32_t& B3)
{
B2 = rotate_right(B2, 22); B0 = rotate_right(B0, 5);
B2 ^= B3 ^ (B1 << 7); B0 ^= B1 ^ B3;
@@ -55,7 +55,7 @@ inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
/*
* Serpent Encryption
*/
-void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Serpent::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_SERPENT_SIMD)
if(CPUID::has_simd_32())
@@ -72,7 +72,7 @@ void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_SIMD_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit B0, B1, B2, B3;
+ uint32_t B0, B1, B2, B3;
load_le(in + 16*i, B0, B1, B2, B3);
key_xor( 0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3);
@@ -115,7 +115,7 @@ void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Serpent Decryption
*/
-void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Serpent::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_SERPENT_SIMD)
if(CPUID::has_simd_32())
@@ -132,7 +132,7 @@ void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_SIMD_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit B0, B1, B2, B3;
+ uint32_t B0, B1, B2, B3;
load_le(in + 16*i, B0, B1, B2, B3);
key_xor(32,B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3);
@@ -179,19 +179,19 @@ void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Serpent Key Schedule
*/
-void Serpent::key_schedule(const byte key[], size_t length)
+void Serpent::key_schedule(const uint8_t key[], size_t length)
{
- const u32bit PHI = 0x9E3779B9;
+ const uint32_t PHI = 0x9E3779B9;
- secure_vector<u32bit> W(140);
+ secure_vector<uint32_t> W(140);
for(size_t i = 0; i != length / 4; ++i)
- W[i] = load_le<u32bit>(key, i);
+ W[i] = load_le<uint32_t>(key, i);
- W[length / 4] |= u32bit(1) << ((length%4)*8);
+ W[length / 4] |= uint32_t(1) << ((length%4)*8);
for(size_t i = 8; i != 140; ++i)
{
- u32bit wi = W[i-8] ^ W[i-5] ^ W[i-3] ^ W[i-1] ^ PHI ^ u32bit(i-8);
+ uint32_t wi = W[i-8] ^ W[i-5] ^ W[i-3] ^ W[i-1] ^ PHI ^ uint32_t(i-8);
W[i] = rotate_left(wi, 11);
}
diff --git a/src/lib/block/serpent/serpent.h b/src/lib/block/serpent/serpent.h
index 218772e0c..4ba385fde 100644
--- a/src/lib/block/serpent/serpent.h
+++ b/src/lib/block/serpent/serpent.h
@@ -19,8 +19,8 @@ namespace Botan {
class BOTAN_DLL Serpent final : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string provider() const override;
@@ -34,33 +34,33 @@ class BOTAN_DLL Serpent final : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
/**
* Encrypt 4 blocks in parallel using SSE2 or AltiVec
*/
- void simd_encrypt_4(const byte in[64], byte out[64]) const;
+ void simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const;
/**
* Decrypt 4 blocks in parallel using SSE2 or AltiVec
*/
- void simd_decrypt_4(const byte in[64], byte out[64]) const;
+ void simd_decrypt_4(const uint8_t in[64], uint8_t out[64]) const;
#endif
/**
* For use by subclasses using SIMD, asm, etc
* @return const reference to the key schedule
*/
- const secure_vector<u32bit>& get_round_keys() const
+ const secure_vector<uint32_t>& get_round_keys() const
{ return m_round_key; }
/**
* For use by subclasses that implement the key schedule
* @param ks is the new key schedule value to set
*/
- void set_round_keys(const u32bit ks[132])
+ void set_round_keys(const uint32_t ks[132])
{
m_round_key.assign(&ks[0], &ks[132]);
}
private:
- void key_schedule(const byte key[], size_t length) override;
- secure_vector<u32bit> m_round_key;
+ void key_schedule(const uint8_t key[], size_t length) override;
+ secure_vector<uint32_t> m_round_key;
};
}
diff --git a/src/lib/block/serpent/serpent_simd/serpent_simd.cpp b/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
index 7571e5511..f69d1f6f5 100644
--- a/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
+++ b/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
@@ -57,7 +57,7 @@ namespace {
/*
* SIMD Serpent Encryption of 4 blocks in parallel
*/
-void Serpent::simd_encrypt_4(const byte in[64], byte out[64]) const
+void Serpent::simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const
{
SIMD_32 B0 = SIMD_32::load_le(in);
SIMD_32 B1 = SIMD_32::load_le(in + 16);
@@ -113,7 +113,7 @@ void Serpent::simd_encrypt_4(const byte in[64], byte out[64]) const
/*
* SIMD Serpent Decryption of 4 blocks in parallel
*/
-void Serpent::simd_decrypt_4(const byte in[64], byte out[64]) const
+void Serpent::simd_decrypt_4(const uint8_t in[64], uint8_t out[64]) const
{
SIMD_32 B0 = SIMD_32::load_le(in);
SIMD_32 B1 = SIMD_32::load_le(in + 16);
diff --git a/src/lib/block/threefish/threefish.cpp b/src/lib/block/threefish/threefish.cpp
index 2acdef020..28a144fb6 100644
--- a/src/lib/block/threefish/threefish.cpp
+++ b/src/lib/block/threefish/threefish.cpp
@@ -54,8 +54,8 @@ namespace Botan {
THREEFISH_INJECT_KEY(R2); \
} while(0)
-void Threefish_512::skein_feedfwd(const secure_vector<u64bit>& M,
- const secure_vector<u64bit>& T)
+void Threefish_512::skein_feedfwd(const secure_vector<uint64_t>& M,
+ const secure_vector<uint64_t>& T)
{
BOTAN_ASSERT(m_K.size() == 9, "Key was set");
BOTAN_ASSERT(M.size() == 8, "Single block");
@@ -64,14 +64,14 @@ void Threefish_512::skein_feedfwd(const secure_vector<u64bit>& M,
m_T[1] = T[1];
m_T[2] = T[0] ^ T[1];
- u64bit X0 = M[0];
- u64bit X1 = M[1];
- u64bit X2 = M[2];
- u64bit X3 = M[3];
- u64bit X4 = M[4];
- u64bit X5 = M[5];
- u64bit X6 = M[6];
- u64bit X7 = M[7];
+ uint64_t X0 = M[0];
+ uint64_t X1 = M[1];
+ uint64_t X2 = M[2];
+ uint64_t X3 = M[3];
+ uint64_t X4 = M[4];
+ uint64_t X5 = M[5];
+ uint64_t X6 = M[6];
+ uint64_t X7 = M[7];
THREEFISH_INJECT_KEY(0);
@@ -110,7 +110,7 @@ std::string Threefish_512::provider() const
return "base";
}
-void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Threefish_512::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_ASSERT(m_K.size() == 9, "Key was set");
BOTAN_ASSERT(m_T.size() == 3, "Tweak was set");
@@ -124,7 +124,7 @@ void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit X0, X1, X2, X3, X4, X5, X6, X7;
+ uint64_t X0, X1, X2, X3, X4, X5, X6, X7;
load_le(in + BLOCK_SIZE*i, X0, X1, X2, X3, X4, X5, X6, X7);
THREEFISH_INJECT_KEY(0);
@@ -147,7 +147,7 @@ void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const
#undef THREEFISH_INJECT_KEY
#undef THREEFISH_ROUND
-void Threefish_512::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Threefish_512::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_ASSERT(m_K.size() == 9, "Key was set");
BOTAN_ASSERT(m_T.size() == 3, "Tweak was set");
@@ -204,7 +204,7 @@ void Threefish_512::decrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit X0, X1, X2, X3, X4, X5, X6, X7;
+ uint64_t X0, X1, X2, X3, X4, X5, X6, X7;
load_le(in + BLOCK_SIZE*i, X0, X1, X2, X3, X4, X5, X6, X7);
THREEFISH_INJECT_KEY(18);
@@ -227,23 +227,23 @@ void Threefish_512::decrypt_n(const byte in[], byte out[], size_t blocks) const
#undef THREEFISH_ROUND
}
-void Threefish_512::set_tweak(const byte tweak[], size_t len)
+void Threefish_512::set_tweak(const uint8_t tweak[], size_t len)
{
if(len != 16)
throw Exception("Threefish-512 requires 128 bit tweak");
m_T.resize(3);
- m_T[0] = load_le<u64bit>(tweak, 0);
- m_T[1] = load_le<u64bit>(tweak, 1);
+ m_T[0] = load_le<uint64_t>(tweak, 0);
+ m_T[1] = load_le<uint64_t>(tweak, 1);
m_T[2] = m_T[0] ^ m_T[1];
}
-void Threefish_512::key_schedule(const byte key[], size_t)
+void Threefish_512::key_schedule(const uint8_t key[], size_t)
{
// todo: define key schedule for smaller keys
m_K.resize(9);
for(size_t i = 0; i != 8; ++i)
- m_K[i] = load_le<u64bit>(key, i);
+ m_K[i] = load_le<uint64_t>(key, i);
m_K[8] = m_K[0] ^ m_K[1] ^ m_K[2] ^ m_K[3] ^
m_K[4] ^ m_K[5] ^ m_K[6] ^ m_K[7] ^ 0x1BD11BDAA9FC1A22;
diff --git a/src/lib/block/threefish/threefish.h b/src/lib/block/threefish/threefish.h
index b02239c93..8fe690f52 100644
--- a/src/lib/block/threefish/threefish.h
+++ b/src/lib/block/threefish/threefish.h
@@ -18,36 +18,36 @@ namespace Botan {
class BOTAN_DLL Threefish_512 final : public Block_Cipher_Fixed_Params<64, 64>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
- void set_tweak(const byte tweak[], size_t len);
+ void set_tweak(const uint8_t tweak[], size_t len);
void clear() override;
std::string provider() const override;
std::string name() const override { return "Threefish-512"; }
BlockCipher* clone() const override { return new Threefish_512; }
protected:
- const secure_vector<u64bit>& get_T() const { return m_T; }
- const secure_vector<u64bit>& get_K() const { return m_K; }
+ const secure_vector<uint64_t>& get_T() const { return m_T; }
+ const secure_vector<uint64_t>& get_K() const { return m_K; }
private:
#if defined(BOTAN_HAS_THREEFISH_512_AVX2)
- void avx2_encrypt_n(const byte in[], byte out[], size_t blocks) const;
- void avx2_decrypt_n(const byte in[], byte out[], size_t blocks) const;
+ void avx2_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
+ void avx2_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
#endif
- void key_schedule(const byte key[], size_t key_len) override;
+ void key_schedule(const uint8_t key[], size_t key_len) override;
// Interface for Skein
friend class Skein_512;
- virtual void skein_feedfwd(const secure_vector<u64bit>& M,
- const secure_vector<u64bit>& T);
+ virtual void skein_feedfwd(const secure_vector<uint64_t>& M,
+ const secure_vector<uint64_t>& T);
// Private data
- secure_vector<u64bit> m_T;
- secure_vector<u64bit> m_K;
+ secure_vector<uint64_t> m_T;
+ secure_vector<uint64_t> m_K;
};
}
diff --git a/src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp b/src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp
index e4a46e3de..b8e2320ae 100644
--- a/src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp
+++ b/src/lib/block/threefish/threefish_avx2/threefish_avx2.cpp
@@ -75,10 +75,10 @@ inline void rotate_keys(__m256i& R0, __m256i& R1, __m256i R2)
}
BOTAN_FUNC_ISA("avx2")
-void Threefish_512::avx2_encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Threefish_512::avx2_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u64bit* K = &get_K()[0];
- const u64bit* T_64 = &get_T()[0];
+ const uint64_t* K = &get_K()[0];
+ const uint64_t* T_64 = &get_T()[0];
const __m256i ROTATE_1 = _mm256_set_epi64x(37,19,36,46);
const __m256i ROTATE_2 = _mm256_set_epi64x(42,14,27,33);
@@ -250,10 +250,10 @@ void Threefish_512::avx2_encrypt_n(const byte in[], byte out[], size_t blocks) c
}
BOTAN_FUNC_ISA("avx2")
-void Threefish_512::avx2_decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Threefish_512::avx2_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u64bit* K = &get_K()[0];
- const u64bit* T_64 = &get_T()[0];
+ const uint64_t* K = &get_K()[0];
+ const uint64_t* T_64 = &get_T()[0];
const __m256i ROTATE_1 = _mm256_set_epi64x(37,19,36,46);
const __m256i ROTATE_2 = _mm256_set_epi64x(42,14,27,33);
diff --git a/src/lib/block/twofish/twofish.cpp b/src/lib/block/twofish/twofish.cpp
index 0b30d4080..51ef01ea9 100644
--- a/src/lib/block/twofish/twofish.cpp
+++ b/src/lib/block/twofish/twofish.cpp
@@ -17,11 +17,11 @@ namespace Botan {
/*
* Twofish Encryption
*/
-void Twofish::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Twofish::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit A, B, C, D;
+ uint32_t A, B, C, D;
load_le(in + BLOCK_SIZE*i, A, B, C, D);
A ^= m_RK[0];
@@ -31,7 +31,7 @@ void Twofish::encrypt_n(const byte in[], byte out[], size_t blocks) const
for(size_t j = 0; j != 16; j += 2)
{
- u32bit X, Y;
+ uint32_t X, Y;
X = m_SB[ get_byte(3, A)] ^ m_SB[256+get_byte(2, A)] ^
m_SB[512+get_byte(1, A)] ^ m_SB[768+get_byte(0, A)];
@@ -68,11 +68,11 @@ void Twofish::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Twofish Decryption
*/
-void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Twofish::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit A, B, C, D;
+ uint32_t A, B, C, D;
load_le(in + BLOCK_SIZE*i, A, B, C, D);
A ^= m_RK[4];
@@ -82,7 +82,7 @@ void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const
for(size_t j = 0; j != 16; j += 2)
{
- u32bit X, Y;
+ uint32_t X, Y;
X = m_SB[ get_byte(3, A)] ^ m_SB[256+get_byte(2, A)] ^
m_SB[512+get_byte(1, A)] ^ m_SB[768+get_byte(0, A)];
@@ -119,12 +119,12 @@ void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Twofish Key Schedule
*/
-void Twofish::key_schedule(const byte key[], size_t length)
+void Twofish::key_schedule(const uint8_t key[], size_t length)
{
m_SB.resize(1024);
m_RK.resize(40);
- secure_vector<byte> S(16);
+ secure_vector<uint8_t> S(16);
for(size_t i = 0; i != length; ++i)
{
@@ -133,12 +133,12 @@ void Twofish::key_schedule(const byte key[], size_t length)
*/
if(key[i])
{
- byte X = POLY_TO_EXP[key[i] - 1];
+ uint8_t X = POLY_TO_EXP[key[i] - 1];
- byte RS1 = RS[(4*i ) % 32];
- byte RS2 = RS[(4*i+1) % 32];
- byte RS3 = RS[(4*i+2) % 32];
- byte RS4 = RS[(4*i+3) % 32];
+ uint8_t RS1 = RS[(4*i ) % 32];
+ uint8_t RS2 = RS[(4*i+1) % 32];
+ uint8_t RS3 = RS[(4*i+2) % 32];
+ uint8_t RS4 = RS[(4*i+3) % 32];
S[4*(i/8) ] ^= EXP_TO_POLY[(X + POLY_TO_EXP[RS1 - 1]) % 255];
S[4*(i/8)+1] ^= EXP_TO_POLY[(X + POLY_TO_EXP[RS2 - 1]) % 255];
@@ -159,11 +159,11 @@ void Twofish::key_schedule(const byte key[], size_t length)
BOTAN_PARALLEL_FOR(size_t i = 0; i < 40; i += 2)
{
- u32bit X = MDS0[Q0[Q0[i ]^key[ 8]]^key[ 0]] ^
+ uint32_t X = MDS0[Q0[Q0[i ]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[i ]^key[ 9]]^key[ 1]] ^
MDS2[Q1[Q0[i ]^key[10]]^key[ 2]] ^
MDS3[Q1[Q1[i ]^key[11]]^key[ 3]];
- u32bit Y = MDS0[Q0[Q0[i+1]^key[12]]^key[ 4]] ^
+ uint32_t Y = MDS0[Q0[Q0[i+1]^key[12]]^key[ 4]] ^
MDS1[Q0[Q1[i+1]^key[13]]^key[ 5]] ^
MDS2[Q1[Q0[i+1]^key[14]]^key[ 6]] ^
MDS3[Q1[Q1[i+1]^key[15]]^key[ 7]];
@@ -186,11 +186,11 @@ void Twofish::key_schedule(const byte key[], size_t length)
BOTAN_PARALLEL_FOR(size_t i = 0; i < 40; i += 2)
{
- u32bit X = MDS0[Q0[Q0[Q1[i ]^key[16]]^key[ 8]]^key[ 0]] ^
+ uint32_t X = MDS0[Q0[Q0[Q1[i ]^key[16]]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[Q1[i ]^key[17]]^key[ 9]]^key[ 1]] ^
MDS2[Q1[Q0[Q0[i ]^key[18]]^key[10]]^key[ 2]] ^
MDS3[Q1[Q1[Q0[i ]^key[19]]^key[11]]^key[ 3]];
- u32bit Y = MDS0[Q0[Q0[Q1[i+1]^key[20]]^key[12]]^key[ 4]] ^
+ uint32_t Y = MDS0[Q0[Q0[Q1[i+1]^key[20]]^key[12]]^key[ 4]] ^
MDS1[Q0[Q1[Q1[i+1]^key[21]]^key[13]]^key[ 5]] ^
MDS2[Q1[Q0[Q0[i+1]^key[22]]^key[14]]^key[ 6]] ^
MDS3[Q1[Q1[Q0[i+1]^key[23]]^key[15]]^key[ 7]];
@@ -213,11 +213,11 @@ void Twofish::key_schedule(const byte key[], size_t length)
BOTAN_PARALLEL_FOR(size_t i = 0; i < 40; i += 2)
{
- u32bit X = MDS0[Q0[Q0[Q1[Q1[i ]^key[24]]^key[16]]^key[ 8]]^key[ 0]] ^
+ uint32_t X = MDS0[Q0[Q0[Q1[Q1[i ]^key[24]]^key[16]]^key[ 8]]^key[ 0]] ^
MDS1[Q0[Q1[Q1[Q0[i ]^key[25]]^key[17]]^key[ 9]]^key[ 1]] ^
MDS2[Q1[Q0[Q0[Q0[i ]^key[26]]^key[18]]^key[10]]^key[ 2]] ^
MDS3[Q1[Q1[Q0[Q1[i ]^key[27]]^key[19]]^key[11]]^key[ 3]];
- u32bit Y = MDS0[Q0[Q0[Q1[Q1[i+1]^key[28]]^key[20]]^key[12]]^key[ 4]] ^
+ uint32_t Y = MDS0[Q0[Q0[Q1[Q1[i+1]^key[28]]^key[20]]^key[12]]^key[ 4]] ^
MDS1[Q0[Q1[Q1[Q0[i+1]^key[29]]^key[21]]^key[13]]^key[ 5]] ^
MDS2[Q1[Q0[Q0[Q0[i+1]^key[30]]^key[22]]^key[14]]^key[ 6]] ^
MDS3[Q1[Q1[Q0[Q1[i+1]^key[31]]^key[23]]^key[15]]^key[ 7]];
diff --git a/src/lib/block/twofish/twofish.h b/src/lib/block/twofish/twofish.h
index b8021263e..50168ffdf 100644
--- a/src/lib/block/twofish/twofish.h
+++ b/src/lib/block/twofish/twofish.h
@@ -18,26 +18,26 @@ namespace Botan {
class BOTAN_DLL Twofish final : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "Twofish"; }
BlockCipher* clone() const override { return new Twofish; }
private:
- void key_schedule(const byte[], size_t) override;
-
- static const u32bit MDS0[256];
- static const u32bit MDS1[256];
- static const u32bit MDS2[256];
- static const u32bit MDS3[256];
- static const byte Q0[256];
- static const byte Q1[256];
- static const byte RS[32];
- static const byte EXP_TO_POLY[255];
- static const byte POLY_TO_EXP[255];
-
- secure_vector<u32bit> m_SB, m_RK;
+ void key_schedule(const uint8_t[], size_t) override;
+
+ static const uint32_t MDS0[256];
+ static const uint32_t MDS1[256];
+ static const uint32_t MDS2[256];
+ static const uint32_t MDS3[256];
+ static const uint8_t Q0[256];
+ static const uint8_t Q1[256];
+ static const uint8_t RS[32];
+ static const uint8_t EXP_TO_POLY[255];
+ static const uint8_t POLY_TO_EXP[255];
+
+ secure_vector<uint32_t> m_SB, m_RK;
};
}
diff --git a/src/lib/block/twofish/twofish_tab.cpp b/src/lib/block/twofish/twofish_tab.cpp
index 6eb6b62f0..d6ac8f41b 100644
--- a/src/lib/block/twofish/twofish_tab.cpp
+++ b/src/lib/block/twofish/twofish_tab.cpp
@@ -9,7 +9,7 @@
namespace Botan {
-const byte Twofish::Q0[256] = {
+const uint8_t Twofish::Q0[256] = {
0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78,
0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C,
0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30,
@@ -33,7 +33,7 @@ const byte Twofish::Q0[256] = {
0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42,
0x4A, 0x5E, 0xC1, 0xE0 };
-const byte Twofish::Q1[256] = {
+const uint8_t Twofish::Q1[256] = {
0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B,
0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1,
0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B,
@@ -57,12 +57,12 @@ const byte Twofish::Q1[256] = {
0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56,
0x55, 0x09, 0xBE, 0x91 };
-const byte Twofish::RS[32] = {
+const uint8_t Twofish::RS[32] = {
0x01, 0xA4, 0x02, 0xA4, 0xA4, 0x56, 0xA1, 0x55, 0x55, 0x82, 0xFC, 0x87,
0x87, 0xF3, 0xC1, 0x5A, 0x5A, 0x1E, 0x47, 0x58, 0x58, 0xC6, 0xAE, 0xDB,
0xDB, 0x68, 0x3D, 0x9E, 0x9E, 0xE5, 0x19, 0x03 };
-const byte Twofish::EXP_TO_POLY[255] = {
+const uint8_t Twofish::EXP_TO_POLY[255] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x4D, 0x9A, 0x79, 0xF2,
0xA9, 0x1F, 0x3E, 0x7C, 0xF8, 0xBD, 0x37, 0x6E, 0xDC, 0xF5, 0xA7, 0x03,
0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xCD, 0xD7, 0xE3, 0x8B, 0x5B, 0xB6,
@@ -86,7 +86,7 @@ const byte Twofish::EXP_TO_POLY[255] = {
0x3B, 0x76, 0xEC, 0x95, 0x67, 0xCE, 0xD1, 0xEF, 0x93, 0x6B, 0xD6, 0xE1,
0x8F, 0x53, 0xA6 };
-const byte Twofish::POLY_TO_EXP[255] = {
+const uint8_t Twofish::POLY_TO_EXP[255] = {
0x00, 0x01, 0x17, 0x02, 0x2E, 0x18, 0x53, 0x03, 0x6A, 0x2F, 0x93, 0x19,
0x34, 0x54, 0x45, 0x04, 0x5C, 0x6B, 0xB6, 0x30, 0xA6, 0x94, 0x4B, 0x1A,
0x8C, 0x35, 0x81, 0x55, 0xAA, 0x46, 0x0D, 0x05, 0x24, 0x5D, 0x87, 0x6C,
@@ -110,7 +110,7 @@ const byte Twofish::POLY_TO_EXP[255] = {
0xB4, 0x0B, 0x7F, 0x51, 0x15, 0x43, 0x91, 0x10, 0x71, 0xBB, 0xEE, 0xBF,
0x85, 0xC8, 0xA1 };
-const u32bit Twofish::MDS0[256] = {
+const uint32_t Twofish::MDS0[256] = {
0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B,
0xE2E22BFB, 0x9E9EFAC8, 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B,
0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, 0x3C3C57D6, 0x93938A32,
@@ -155,7 +155,7 @@ const u32bit Twofish::MDS0[256] = {
0x04047FF6, 0x272746C2, 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756,
0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91 };
-const u32bit Twofish::MDS1[256] = {
+const uint32_t Twofish::MDS1[256] = {
0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252,
0xA3658080, 0x76DFE4E4, 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A,
0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, 0x0D54E6E6, 0xC6432020,
@@ -200,7 +200,7 @@ const u32bit Twofish::MDS1[256] = {
0x0FE25151, 0x00000000, 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7,
0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8 };
-const u32bit Twofish::MDS2[256] = {
+const uint32_t Twofish::MDS2[256] = {
0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B,
0xE2FBE22B, 0x9EC89EFA, 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F,
0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, 0x3CD63C57, 0x9332938A,
@@ -245,7 +245,7 @@ const u32bit Twofish::MDS2[256] = {
0x04F6047F, 0x27C22746, 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7,
0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF };
-const u32bit Twofish::MDS3[256] = {
+const uint32_t Twofish::MDS3[256] = {
0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98,
0x6580A365, 0xDFE476DF, 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866,
0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, 0x54E60D54, 0x4320C643,
diff --git a/src/lib/block/xtea/xtea.cpp b/src/lib/block/xtea/xtea.cpp
index 4e5ca7e7c..b53de448b 100644
--- a/src/lib/block/xtea/xtea.cpp
+++ b/src/lib/block/xtea/xtea.cpp
@@ -13,16 +13,16 @@ namespace Botan {
/*
* XTEA Encryption
*/
-void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void XTEA::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u32bit* EK = &m_EK[0];
+ const uint32_t* EK = &m_EK[0];
const size_t blocks4 = blocks / 4;
const size_t blocks_left = blocks % 4;
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks4; i++)
{
- u32bit L0, R0, L1, R1, L2, R2, L3, R3;
+ uint32_t L0, R0, L1, R1, L2, R2, L3, R3;
load_be(in + 4*BLOCK_SIZE*i, L0, R0, L1, R1, L2, R2, L3, R3);
for(size_t r = 0; r != 32; ++r)
@@ -43,7 +43,7 @@ void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks_left; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*(4*blocks4+i), L, R);
for(size_t r = 0; r != 32; ++r)
@@ -59,16 +59,16 @@ void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* XTEA Decryption
*/
-void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void XTEA::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
- const u32bit* EK = &m_EK[0];
+ const uint32_t* EK = &m_EK[0];
const size_t blocks4 = blocks / 4;
const size_t blocks_left = blocks % 4;
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks4; i++)
{
- u32bit L0, R0, L1, R1, L2, R2, L3, R3;
+ uint32_t L0, R0, L1, R1, L2, R2, L3, R3;
load_be(in + 4*BLOCK_SIZE*i, L0, R0, L1, R1, L2, R2, L3, R3);
for(size_t r = 0; r != 32; ++r)
@@ -89,7 +89,7 @@ void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks_left; ++i)
{
- u32bit L, R;
+ uint32_t L, R;
load_be(in + BLOCK_SIZE*(4*blocks4+i), L, R);
for(size_t r = 0; r != 32; ++r)
@@ -105,15 +105,15 @@ void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* XTEA Key Schedule
*/
-void XTEA::key_schedule(const byte key[], size_t)
+void XTEA::key_schedule(const uint8_t key[], size_t)
{
m_EK.resize(64);
- secure_vector<u32bit> UK(4);
+ secure_vector<uint32_t> UK(4);
for(size_t i = 0; i != 4; ++i)
- UK[i] = load_be<u32bit>(key, i);
+ UK[i] = load_be<uint32_t>(key, i);
- u32bit D = 0;
+ uint32_t D = 0;
for(size_t i = 0; i != 64; i += 2)
{
m_EK[i ] = D + UK[D % 4];
diff --git a/src/lib/block/xtea/xtea.h b/src/lib/block/xtea/xtea.h
index 3baccc866..cf9bedc4a 100644
--- a/src/lib/block/xtea/xtea.h
+++ b/src/lib/block/xtea/xtea.h
@@ -18,8 +18,8 @@ namespace Botan {
class BOTAN_DLL XTEA : public Block_Cipher_Fixed_Params<8, 16>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string name() const override { return "XTEA"; }
@@ -28,11 +28,11 @@ class BOTAN_DLL XTEA : public Block_Cipher_Fixed_Params<8, 16>
/**
* @return const reference to the key schedule
*/
- const secure_vector<u32bit>& get_EK() const { return m_EK; }
+ const secure_vector<uint32_t>& get_EK() const { return m_EK; }
private:
- void key_schedule(const byte[], size_t) override;
- secure_vector<u32bit> m_EK;
+ void key_schedule(const uint8_t[], size_t) override;
+ secure_vector<uint32_t> m_EK;
};
}