diff options
Diffstat (limited to 'src/lib/block')
48 files changed, 666 insertions, 666 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp index 0da4ff0a0..6cca701af 100644 --- a/src/lib/block/aes/aes.cpp +++ b/src/lib/block/aes/aes.cpp @@ -414,71 +414,71 @@ void aes_key_schedule(const byte key[], size_t length, void AES_128::encrypt_n(const byte in[], byte out[], size_t blocks) const { - aes_encrypt_n(in, out, blocks, EK, ME); + aes_encrypt_n(in, out, blocks, m_EK, m_ME); } void AES_128::decrypt_n(const byte in[], byte out[], size_t blocks) const { - aes_decrypt_n(in, out, blocks, DK, MD); + aes_decrypt_n(in, out, blocks, m_DK, m_MD); } void AES_128::key_schedule(const byte key[], size_t length) { - aes_key_schedule(key, length, EK, DK, ME, MD); + aes_key_schedule(key, length, m_EK, m_DK, m_ME, m_MD); } void AES_128::clear() { - zap(EK); - zap(DK); - zap(ME); - zap(MD); + zap(m_EK); + zap(m_DK); + zap(m_ME); + zap(m_MD); } void AES_192::encrypt_n(const byte in[], byte out[], size_t blocks) const { - aes_encrypt_n(in, out, blocks, EK, ME); + aes_encrypt_n(in, out, blocks, m_EK, m_ME); } void AES_192::decrypt_n(const byte in[], byte out[], size_t blocks) const { - aes_decrypt_n(in, out, blocks, DK, MD); + aes_decrypt_n(in, out, blocks, m_DK, m_MD); } void AES_192::key_schedule(const byte key[], size_t length) { - aes_key_schedule(key, length, EK, DK, ME, MD); + aes_key_schedule(key, length, m_EK, m_DK, m_ME, m_MD); } void AES_192::clear() { - zap(EK); - zap(DK); - zap(ME); - zap(MD); + zap(m_EK); + zap(m_DK); + zap(m_ME); + zap(m_MD); } void AES_256::encrypt_n(const byte in[], byte out[], size_t blocks) const { - aes_encrypt_n(in, out, blocks, EK, ME); + aes_encrypt_n(in, out, blocks, m_EK, m_ME); } void AES_256::decrypt_n(const byte in[], byte out[], size_t blocks) const { - aes_decrypt_n(in, out, blocks, DK, MD); + aes_decrypt_n(in, out, blocks, m_DK, m_MD); } void AES_256::key_schedule(const byte key[], size_t length) { - aes_key_schedule(key, length, EK, DK, ME, MD); + aes_key_schedule(key, length, m_EK, m_DK, m_ME, m_MD); } void AES_256::clear() { - zap(EK); - zap(DK); - zap(ME); - zap(MD); + zap(m_EK); + zap(m_DK); + zap(m_ME); + zap(m_MD); } } diff --git a/src/lib/block/aes/aes.h b/src/lib/block/aes/aes.h index f8b8d2938..82de4e63f 100644 --- a/src/lib/block/aes/aes.h +++ b/src/lib/block/aes/aes.h @@ -28,8 +28,8 @@ class BOTAN_DLL AES_128 : public Block_Cipher_Fixed_Params<16, 16> private: void key_schedule(const byte key[], size_t length) override; - secure_vector<u32bit> EK, DK; - secure_vector<byte> ME, MD; + secure_vector<u32bit> m_EK, m_DK; + secure_vector<byte> m_ME, m_MD; }; /** @@ -48,8 +48,8 @@ class BOTAN_DLL AES_192 : public Block_Cipher_Fixed_Params<16, 24> private: void key_schedule(const byte key[], size_t length) override; - secure_vector<u32bit> EK, DK; - secure_vector<byte> ME, MD; + secure_vector<u32bit> m_EK, m_DK; + secure_vector<byte> m_ME, m_MD; }; /** @@ -68,8 +68,8 @@ class BOTAN_DLL AES_256 : public Block_Cipher_Fixed_Params<16, 32> private: void key_schedule(const byte key[], size_t length) override; - secure_vector<u32bit> EK, DK; - secure_vector<byte> ME, MD; + secure_vector<u32bit> m_EK, m_DK; + secure_vector<byte> m_ME, m_MD; }; } diff --git a/src/lib/block/aes_ni/aes_ni.cpp b/src/lib/block/aes_ni/aes_ni.cpp index d359ec772..51b30881f 100644 --- a/src/lib/block/aes_ni/aes_ni.cpp +++ b/src/lib/block/aes_ni/aes_ni.cpp @@ -109,7 +109,7 @@ void AES_128_NI::encrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* key_mm = reinterpret_cast<const __m128i*>(EK.data()); + const __m128i* key_mm = reinterpret_cast<const __m128i*>(m_EK.data()); __m128i K0 = _mm_loadu_si128(key_mm); __m128i K1 = _mm_loadu_si128(key_mm + 1); @@ -185,7 +185,7 @@ void AES_128_NI::decrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* key_mm = reinterpret_cast<const __m128i*>(DK.data()); + const __m128i* key_mm = reinterpret_cast<const __m128i*>(m_DK.data()); __m128i K0 = _mm_loadu_si128(key_mm); __m128i K1 = _mm_loadu_si128(key_mm + 1); @@ -258,8 +258,8 @@ void AES_128_NI::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void AES_128_NI::key_schedule(const byte key[], size_t) { - EK.resize(44); - DK.resize(44); + m_EK.resize(44); + m_DK.resize(44); #define AES_128_key_exp(K, RCON) \ aes_128_key_expansion(K, _mm_aeskeygenassist_si128(K, RCON)) @@ -276,7 +276,7 @@ void AES_128_NI::key_schedule(const byte key[], size_t) __m128i K9 = AES_128_key_exp(K8, 0x1B); __m128i K10 = AES_128_key_exp(K9, 0x36); - __m128i* EK_mm = reinterpret_cast<__m128i*>(EK.data()); + __m128i* EK_mm = reinterpret_cast<__m128i*>(m_EK.data()); _mm_storeu_si128(EK_mm , K0); _mm_storeu_si128(EK_mm + 1, K1); _mm_storeu_si128(EK_mm + 2, K2); @@ -291,7 +291,7 @@ void AES_128_NI::key_schedule(const byte key[], size_t) // Now generate decryption keys - __m128i* DK_mm = reinterpret_cast<__m128i*>(DK.data()); + __m128i* DK_mm = reinterpret_cast<__m128i*>(m_DK.data()); _mm_storeu_si128(DK_mm , K10); _mm_storeu_si128(DK_mm + 1, _mm_aesimc_si128(K9)); _mm_storeu_si128(DK_mm + 2, _mm_aesimc_si128(K8)); @@ -310,8 +310,8 @@ void AES_128_NI::key_schedule(const byte key[], size_t) */ void AES_128_NI::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } /* @@ -322,7 +322,7 @@ void AES_192_NI::encrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* key_mm = reinterpret_cast<const __m128i*>(EK.data()); + const __m128i* key_mm = reinterpret_cast<const __m128i*>(m_EK.data()); __m128i K0 = _mm_loadu_si128(key_mm); __m128i K1 = _mm_loadu_si128(key_mm + 1); @@ -404,7 +404,7 @@ void AES_192_NI::decrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* key_mm = reinterpret_cast<const __m128i*>(DK.data()); + const __m128i* key_mm = reinterpret_cast<const __m128i*>(m_DK.data()); __m128i K0 = _mm_loadu_si128(key_mm); __m128i K1 = _mm_loadu_si128(key_mm + 1); @@ -483,19 +483,19 @@ void AES_192_NI::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void AES_192_NI::key_schedule(const byte key[], size_t) { - EK.resize(52); - DK.resize(52); + m_EK.resize(52); + m_DK.resize(52); __m128i K0 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(key)); __m128i K1 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(key + 8)); K1 = _mm_srli_si128(K1, 8); - load_le(EK.data(), key, 6); + load_le(m_EK.data(), key, 6); #define AES_192_key_exp(RCON, EK_OFF) \ aes_192_key_expansion(&K0, &K1, \ _mm_aeskeygenassist_si128(K1, RCON), \ - &EK[EK_OFF], EK_OFF == 48) + &m_EK[EK_OFF], EK_OFF == 48) AES_192_key_exp(0x01, 6); AES_192_key_exp(0x02, 12); @@ -509,9 +509,9 @@ void AES_192_NI::key_schedule(const byte key[], size_t) #undef AES_192_key_exp // Now generate decryption keys - const __m128i* EK_mm = reinterpret_cast<const __m128i*>(EK.data()); + const __m128i* EK_mm = reinterpret_cast<const __m128i*>(m_EK.data()); - __m128i* DK_mm = reinterpret_cast<__m128i*>(DK.data()); + __m128i* DK_mm = reinterpret_cast<__m128i*>(m_DK.data()); _mm_storeu_si128(DK_mm , _mm_loadu_si128(EK_mm + 12)); _mm_storeu_si128(DK_mm + 1, _mm_aesimc_si128(_mm_loadu_si128(EK_mm + 11))); _mm_storeu_si128(DK_mm + 2, _mm_aesimc_si128(_mm_loadu_si128(EK_mm + 10))); @@ -532,8 +532,8 @@ void AES_192_NI::key_schedule(const byte key[], size_t) */ void AES_192_NI::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } /* @@ -544,7 +544,7 @@ void AES_256_NI::encrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* key_mm = reinterpret_cast<const __m128i*>(EK.data()); + const __m128i* key_mm = reinterpret_cast<const __m128i*>(m_EK.data()); __m128i K0 = _mm_loadu_si128(key_mm); __m128i K1 = _mm_loadu_si128(key_mm + 1); @@ -632,7 +632,7 @@ void AES_256_NI::decrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* key_mm = reinterpret_cast<const __m128i*>(DK.data()); + const __m128i* key_mm = reinterpret_cast<const __m128i*>(m_DK.data()); __m128i K0 = _mm_loadu_si128(key_mm); __m128i K1 = _mm_loadu_si128(key_mm + 1); @@ -717,8 +717,8 @@ void AES_256_NI::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void AES_256_NI::key_schedule(const byte key[], size_t) { - EK.resize(60); - DK.resize(60); + m_EK.resize(60); + m_DK.resize(60); __m128i K0 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(key)); __m128i K1 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(key + 16)); @@ -743,7 +743,7 @@ void AES_256_NI::key_schedule(const byte key[], size_t) __m128i K14 = aes_128_key_expansion(K12, _mm_aeskeygenassist_si128(K13, 0x40)); - __m128i* EK_mm = reinterpret_cast<__m128i*>(EK.data()); + __m128i* EK_mm = reinterpret_cast<__m128i*>(m_EK.data()); _mm_storeu_si128(EK_mm , K0); _mm_storeu_si128(EK_mm + 1, K1); _mm_storeu_si128(EK_mm + 2, K2); @@ -761,7 +761,7 @@ void AES_256_NI::key_schedule(const byte key[], size_t) _mm_storeu_si128(EK_mm + 14, K14); // Now generate decryption keys - __m128i* DK_mm = reinterpret_cast<__m128i*>(DK.data()); + __m128i* DK_mm = reinterpret_cast<__m128i*>(m_DK.data()); _mm_storeu_si128(DK_mm , K14); _mm_storeu_si128(DK_mm + 1, _mm_aesimc_si128(K13)); _mm_storeu_si128(DK_mm + 2, _mm_aesimc_si128(K12)); @@ -784,8 +784,8 @@ void AES_256_NI::key_schedule(const byte key[], size_t) */ void AES_256_NI::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } #undef AES_ENC_4_ROUNDS diff --git a/src/lib/block/aes_ni/aes_ni.h b/src/lib/block/aes_ni/aes_ni.h index 0f85c3482..6f995490a 100644 --- a/src/lib/block/aes_ni/aes_ni.h +++ b/src/lib/block/aes_ni/aes_ni.h @@ -29,7 +29,7 @@ class BOTAN_DLL AES_128_NI : public Block_Cipher_Fixed_Params<16, 16> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK, DK; + secure_vector<u32bit> m_EK, m_DK; }; /** @@ -49,7 +49,7 @@ class BOTAN_DLL AES_192_NI : public Block_Cipher_Fixed_Params<16, 24> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK, DK; + secure_vector<u32bit> m_EK, m_DK; }; /** @@ -69,7 +69,7 @@ class BOTAN_DLL AES_256_NI : public Block_Cipher_Fixed_Params<16, 32> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK, DK; + secure_vector<u32bit> m_EK, m_DK; }; } diff --git a/src/lib/block/aes_ssse3/aes_ssse3.cpp b/src/lib/block/aes_ssse3/aes_ssse3.cpp index 373a5265a..fa0cb787c 100644 --- a/src/lib/block/aes_ssse3/aes_ssse3.cpp +++ b/src/lib/block/aes_ssse3/aes_ssse3.cpp @@ -344,7 +344,7 @@ void AES_128_SSSE3::encrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* keys = reinterpret_cast<const __m128i*>(EK.data()); + const __m128i* keys = reinterpret_cast<const __m128i*>(m_EK.data()); CT::poison(in, blocks * block_size()); @@ -366,7 +366,7 @@ void AES_128_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* keys = reinterpret_cast<const __m128i*>(DK.data()); + const __m128i* keys = reinterpret_cast<const __m128i*>(m_DK.data()); CT::poison(in, blocks * block_size()); @@ -390,11 +390,11 @@ void AES_128_SSSE3::key_schedule(const byte keyb[], size_t) __m128i key = _mm_loadu_si128(reinterpret_cast<const __m128i*>(keyb)); - EK.resize(11*4); - DK.resize(11*4); + m_EK.resize(11*4); + m_DK.resize(11*4); - __m128i* EK_mm = reinterpret_cast<__m128i*>(EK.data()); - __m128i* DK_mm = reinterpret_cast<__m128i*>(DK.data()); + __m128i* EK_mm = reinterpret_cast<__m128i*>(m_EK.data()); + __m128i* DK_mm = reinterpret_cast<__m128i*>(m_DK.data()); _mm_storeu_si128(DK_mm + 10, _mm_shuffle_epi8(key, sr[2])); @@ -420,8 +420,8 @@ void AES_128_SSSE3::key_schedule(const byte keyb[], size_t) void AES_128_SSSE3::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } /* @@ -432,7 +432,7 @@ void AES_192_SSSE3::encrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* keys = reinterpret_cast<const __m128i*>(EK.data()); + const __m128i* keys = reinterpret_cast<const __m128i*>(m_EK.data()); CT::poison(in, blocks * block_size()); @@ -454,7 +454,7 @@ void AES_192_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* keys = reinterpret_cast<const __m128i*>(DK.data()); + const __m128i* keys = reinterpret_cast<const __m128i*>(m_DK.data()); CT::poison(in, blocks * block_size()); @@ -476,11 +476,11 @@ void AES_192_SSSE3::key_schedule(const byte keyb[], size_t) __m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81, 0x1F8391B9, 0xAF9DEEB6); - EK.resize(13*4); - DK.resize(13*4); + m_EK.resize(13*4); + m_DK.resize(13*4); - __m128i* EK_mm = reinterpret_cast<__m128i*>(EK.data()); - __m128i* DK_mm = reinterpret_cast<__m128i*>(DK.data()); + __m128i* EK_mm = reinterpret_cast<__m128i*>(m_EK.data()); + __m128i* DK_mm = reinterpret_cast<__m128i*>(m_DK.data()); __m128i key1 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(keyb)); __m128i key2 = _mm_loadu_si128(reinterpret_cast<const __m128i*>((keyb + 8))); @@ -537,8 +537,8 @@ void AES_192_SSSE3::key_schedule(const byte keyb[], size_t) void AES_192_SSSE3::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } /* @@ -549,7 +549,7 @@ void AES_256_SSSE3::encrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* keys = reinterpret_cast<const __m128i*>(EK.data()); + const __m128i* keys = reinterpret_cast<const __m128i*>(m_EK.data()); CT::poison(in, blocks * block_size()); @@ -571,7 +571,7 @@ void AES_256_SSSE3::decrypt_n(const byte in[], byte out[], size_t blocks) const const __m128i* in_mm = reinterpret_cast<const __m128i*>(in); __m128i* out_mm = reinterpret_cast<__m128i*>(out); - const __m128i* keys = reinterpret_cast<const __m128i*>(DK.data()); + const __m128i* keys = reinterpret_cast<const __m128i*>(m_DK.data()); CT::poison(in, blocks * block_size()); @@ -593,11 +593,11 @@ void AES_256_SSSE3::key_schedule(const byte keyb[], size_t) __m128i rcon = _mm_set_epi32(0x702A9808, 0x4D7C7D81, 0x1F8391B9, 0xAF9DEEB6); - EK.resize(15*4); - DK.resize(15*4); + m_EK.resize(15*4); + m_DK.resize(15*4); - __m128i* EK_mm = reinterpret_cast<__m128i*>(EK.data()); - __m128i* DK_mm = reinterpret_cast<__m128i*>(DK.data()); + __m128i* EK_mm = reinterpret_cast<__m128i*>(m_EK.data()); + __m128i* DK_mm = reinterpret_cast<__m128i*>(m_DK.data()); __m128i key1 = _mm_loadu_si128(reinterpret_cast<const __m128i*>(keyb)); __m128i key2 = _mm_loadu_si128(reinterpret_cast<const __m128i*>((keyb + 16))); @@ -633,8 +633,8 @@ void AES_256_SSSE3::key_schedule(const byte keyb[], size_t) void AES_256_SSSE3::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } } diff --git a/src/lib/block/aes_ssse3/aes_ssse3.h b/src/lib/block/aes_ssse3/aes_ssse3.h index 49e0346e4..1d09b5f61 100644 --- a/src/lib/block/aes_ssse3/aes_ssse3.h +++ b/src/lib/block/aes_ssse3/aes_ssse3.h @@ -27,7 +27,7 @@ class BOTAN_DLL AES_128_SSSE3 : public Block_Cipher_Fixed_Params<16, 16> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK, DK; + secure_vector<u32bit> m_EK, m_DK; }; /** @@ -45,7 +45,7 @@ class BOTAN_DLL AES_192_SSSE3 : public Block_Cipher_Fixed_Params<16, 24> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK, DK; + secure_vector<u32bit> m_EK, m_DK; }; /** @@ -63,7 +63,7 @@ class BOTAN_DLL AES_256_SSSE3 : public Block_Cipher_Fixed_Params<16, 32> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK, DK; + secure_vector<u32bit> m_EK, m_DK; }; } diff --git a/src/lib/block/blowfish/blowfish.cpp b/src/lib/block/blowfish/blowfish.cpp index 0b0e685a8..e38668934 100644 --- a/src/lib/block/blowfish/blowfish.cpp +++ b/src/lib/block/blowfish/blowfish.cpp @@ -15,10 +15,10 @@ namespace Botan { */ void Blowfish::encrypt_n(const byte in[], byte out[], size_t blocks) const { - const u32bit* S1 = &S[0]; - const u32bit* S2 = &S[256]; - const u32bit* S3 = &S[512]; - const u32bit* S4 = &S[768]; + const u32bit* S1 = &m_S[0]; + const u32bit* S2 = &m_S[256]; + const u32bit* S3 = &m_S[512]; + const u32bit* S4 = &m_S[768]; for(size_t i = 0; i != blocks; ++i) { @@ -27,16 +27,16 @@ void Blowfish::encrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 16; j += 2) { - L ^= P[j]; + L ^= m_P[j]; R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^ S3[get_byte(2, L)]) + S4[get_byte(3, L)]; - R ^= P[j+1]; + R ^= m_P[j+1]; L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^ S3[get_byte(2, R)]) + S4[get_byte(3, R)]; } - L ^= P[16]; R ^= P[17]; + L ^= m_P[16]; R ^= m_P[17]; store_be(out, R, L); @@ -50,10 +50,10 @@ void Blowfish::encrypt_n(const byte in[], byte out[], size_t blocks) const */ void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const { - const u32bit* S1 = &S[0]; - const u32bit* S2 = &S[256]; - const u32bit* S3 = &S[512]; - const u32bit* S4 = &S[768]; + const u32bit* S1 = &m_S[0]; + const u32bit* S2 = &m_S[256]; + const u32bit* S3 = &m_S[512]; + const u32bit* S4 = &m_S[768]; for(size_t i = 0; i != blocks; ++i) { @@ -62,16 +62,16 @@ void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 17; j != 1; j -= 2) { - L ^= P[j]; + L ^= m_P[j]; R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^ S3[get_byte(2, L)]) + S4[get_byte(3, L)]; - R ^= P[j-1]; + R ^= m_P[j-1]; L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^ S3[get_byte(2, R)]) + S4[get_byte(3, R)]; } - L ^= P[1]; R ^= P[0]; + L ^= m_P[1]; R ^= m_P[0]; store_be(out, R, L); @@ -85,11 +85,11 @@ void Blowfish::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void Blowfish::key_schedule(const byte key[], size_t length) { - P.resize(18); - copy_mem(P.data(), P_INIT, 18); + m_P.resize(18); + copy_mem(m_P.data(), P_INIT, 18); - S.resize(1024); - copy_mem(S.data(), S_INIT, 1024); + m_S.resize(1024); + copy_mem(m_S.data(), S_INIT, 1024); const byte null_salt[16] = { 0 }; @@ -101,12 +101,12 @@ void Blowfish::key_expansion(const byte key[], const byte salt[16]) { for(size_t i = 0, j = 0; i != 18; ++i, j += 4) - P[i] ^= make_u32bit(key[(j ) % length], key[(j+1) % length], + m_P[i] ^= make_u32bit(key[(j ) % length], key[(j+1) % length], key[(j+2) % length], key[(j+3) % length]); u32bit L = 0, R = 0; - generate_sbox(P, L, R, salt, 0); - generate_sbox(S, L, R, salt, 2); + generate_sbox(m_P, L, R, salt, 0); + generate_sbox(m_S, L, R, salt, 2); } /* @@ -130,11 +130,11 @@ void Blowfish::eks_key_schedule(const byte key[], size_t length, throw Invalid_Argument("Requested Bcrypt work factor " + std::to_string(workfactor) + " too large"); - P.resize(18); - copy_mem(P.data(), P_INIT, 18); + m_P.resize(18); + copy_mem(m_P.data(), P_INIT, 18); - S.resize(1024); - copy_mem(S.data(), S_INIT, 1024); + m_S.resize(1024); + copy_mem(m_S.data(), S_INIT, 1024); key_expansion(key, length, salt); @@ -156,10 +156,10 @@ void Blowfish::generate_sbox(secure_vector<u32bit>& box, const byte salt[16], size_t salt_off) const { - const u32bit* S1 = &S[0]; - const u32bit* S2 = &S[256]; - const u32bit* S3 = &S[512]; - const u32bit* S4 = &S[768]; + const u32bit* S1 = &m_S[0]; + const u32bit* S2 = &m_S[256]; + const u32bit* S3 = &m_S[512]; + const u32bit* S4 = &m_S[768]; for(size_t i = 0; i != box.size(); i += 2) { @@ -168,16 +168,16 @@ void Blowfish::generate_sbox(secure_vector<u32bit>& box, for(size_t j = 0; j != 16; j += 2) { - L ^= P[j]; + L ^= m_P[j]; R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^ S3[get_byte(2, L)]) + S4[get_byte(3, L)]; - R ^= P[j+1]; + R ^= m_P[j+1]; L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^ S3[get_byte(2, R)]) + S4[get_byte(3, R)]; } - u32bit T = R; R = L ^ P[16]; L = T ^ P[17]; + u32bit T = R; R = L ^ m_P[16]; L = T ^ m_P[17]; box[i] = L; box[i+1] = R; } @@ -188,8 +188,8 @@ void Blowfish::generate_sbox(secure_vector<u32bit>& box, */ void Blowfish::clear() { - zap(P); - zap(S); + zap(m_P); + zap(m_S); } } diff --git a/src/lib/block/blowfish/blowfish.h b/src/lib/block/blowfish/blowfish.h index e1042465f..ef2ecc3c4 100644 --- a/src/lib/block/blowfish/blowfish.h +++ b/src/lib/block/blowfish/blowfish.h @@ -45,7 +45,7 @@ class BOTAN_DLL Blowfish : public Block_Cipher_Fixed_Params<8, 1, 56> static const u32bit P_INIT[18]; static const u32bit S_INIT[1024]; - secure_vector<u32bit> S, P; + secure_vector<u32bit> m_S, m_P; }; } diff --git a/src/lib/block/camellia/camellia.cpp b/src/lib/block/camellia/camellia.cpp index e9b10c528..ac5d57d4e 100644 --- a/src/lib/block/camellia/camellia.cpp +++ b/src/lib/block/camellia/camellia.cpp @@ -860,62 +860,62 @@ 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 { - Camellia_F::encrypt(in, out, blocks, SK, 9); + Camellia_F::encrypt(in, out, blocks, m_SK, 9); } void Camellia_192::encrypt_n(const byte in[], byte out[], size_t blocks) const { - Camellia_F::encrypt(in, out, blocks, SK, 12); + Camellia_F::encrypt(in, out, blocks, m_SK, 12); } void Camellia_256::encrypt_n(const byte in[], byte out[], size_t blocks) const { - Camellia_F::encrypt(in, out, blocks, SK, 12); + Camellia_F::encrypt(in, out, blocks, m_SK, 12); } void Camellia_128::decrypt_n(const byte in[], byte out[], size_t blocks) const { - Camellia_F::decrypt(in, out, blocks, SK, 9); + Camellia_F::decrypt(in, out, blocks, m_SK, 9); } void Camellia_192::decrypt_n(const byte in[], byte out[], size_t blocks) const { - Camellia_F::decrypt(in, out, blocks, SK, 12); + Camellia_F::decrypt(in, out, blocks, m_SK, 12); } void Camellia_256::decrypt_n(const byte in[], byte out[], size_t blocks) const { - Camellia_F::decrypt(in, out, blocks, SK, 12); + Camellia_F::decrypt(in, out, blocks, m_SK, 12); } void Camellia_128::key_schedule(const byte key[], size_t length) { - Camellia_F::key_schedule(SK, key, length); + Camellia_F::key_schedule(m_SK, key, length); } void Camellia_192::key_schedule(const byte key[], size_t length) { - Camellia_F::key_schedule(SK, key, length); + Camellia_F::key_schedule(m_SK, key, length); } void Camellia_256::key_schedule(const byte key[], size_t length) { - Camellia_F::key_schedule(SK, key, length); + Camellia_F::key_schedule(m_SK, key, length); } void Camellia_128::clear() { - zap(SK); + zap(m_SK); } void Camellia_192::clear() { - zap(SK); + zap(m_SK); } void Camellia_256::clear() { - zap(SK); + zap(m_SK); } } diff --git a/src/lib/block/camellia/camellia.h b/src/lib/block/camellia/camellia.h index 884cb2bd7..c83741d3c 100644 --- a/src/lib/block/camellia/camellia.h +++ b/src/lib/block/camellia/camellia.h @@ -27,7 +27,7 @@ class BOTAN_DLL Camellia_128 : public Block_Cipher_Fixed_Params<16, 16> private: void key_schedule(const byte key[], size_t length) override; - secure_vector<u64bit> SK; + secure_vector<u64bit> m_SK; }; /** @@ -45,7 +45,7 @@ class BOTAN_DLL Camellia_192 : public Block_Cipher_Fixed_Params<16, 24> private: void key_schedule(const byte key[], size_t length) override; - secure_vector<u64bit> SK; + secure_vector<u64bit> m_SK; }; /** @@ -63,7 +63,7 @@ class BOTAN_DLL Camellia_256 : public Block_Cipher_Fixed_Params<16, 32> private: void key_schedule(const byte key[], size_t length) override; - secure_vector<u64bit> SK; + secure_vector<u64bit> m_SK; }; } diff --git a/src/lib/block/cast/cast128.cpp b/src/lib/block/cast/cast128.cpp index 3973418a3..ce9e86794 100644 --- a/src/lib/block/cast/cast128.cpp +++ b/src/lib/block/cast/cast128.cpp @@ -55,22 +55,22 @@ void CAST_128::encrypt_n(const byte in[], byte out[], size_t blocks) const u32bit L = load_be<u32bit>(in, 0); u32bit R = load_be<u32bit>(in, 1); - R1(L, R, MK[ 0], RK[ 0]); - R2(R, L, MK[ 1], RK[ 1]); - R3(L, R, MK[ 2], RK[ 2]); - R1(R, L, MK[ 3], RK[ 3]); - R2(L, R, MK[ 4], RK[ 4]); - R3(R, L, MK[ 5], RK[ 5]); - R1(L, R, MK[ 6], RK[ 6]); - R2(R, L, MK[ 7], RK[ 7]); - R3(L, R, MK[ 8], RK[ 8]); - R1(R, L, MK[ 9], RK[ 9]); - R2(L, R, MK[10], RK[10]); - R3(R, L, MK[11], RK[11]); - R1(L, R, MK[12], RK[12]); - R2(R, L, MK[13], RK[13]); - R3(L, R, MK[14], RK[14]); - R1(R, L, MK[15], RK[15]); + R1(L, R, m_MK[ 0], m_RK[ 0]); + R2(R, L, m_MK[ 1], m_RK[ 1]); + R3(L, R, m_MK[ 2], m_RK[ 2]); + R1(R, L, m_MK[ 3], m_RK[ 3]); + R2(L, R, m_MK[ 4], m_RK[ 4]); + R3(R, L, m_MK[ 5], m_RK[ 5]); + R1(L, R, m_MK[ 6], m_RK[ 6]); + R2(R, L, m_MK[ 7], m_RK[ 7]); + R3(L, R, m_MK[ 8], m_RK[ 8]); + R1(R, L, m_MK[ 9], m_RK[ 9]); + R2(L, R, m_MK[10], m_RK[10]); + R3(R, L, m_MK[11], m_RK[11]); + R1(L, R, m_MK[12], m_RK[12]); + R2(R, L, m_MK[13], m_RK[13]); + R3(L, R, m_MK[14], m_RK[14]); + R1(R, L, m_MK[15], m_RK[15]); store_be(out, R, L); @@ -89,22 +89,22 @@ void CAST_128::decrypt_n(const byte in[], byte out[], size_t blocks) const u32bit L = load_be<u32bit>(in, 0); u32bit R = load_be<u32bit>(in, 1); - R1(L, R, MK[15], RK[15]); - R3(R, L, MK[14], RK[14]); - R2(L, R, MK[13], RK[13]); - R1(R, L, MK[12], RK[12]); - R3(L, R, MK[11], RK[11]); - R2(R, L, MK[10], RK[10]); - R1(L, R, MK[ 9], RK[ 9]); - R3(R, L, MK[ 8], RK[ 8]); - R2(L, R, MK[ 7], RK[ 7]); - R1(R, L, MK[ 6], RK[ 6]); - R3(L, R, MK[ 5], RK[ 5]); - R2(R, L, MK[ 4], RK[ 4]); - R1(L, R, MK[ 3], RK[ 3]); - R3(R, L, MK[ 2], RK[ 2]); - R2(L, R, MK[ 1], RK[ 1]); - R1(R, L, MK[ 0], RK[ 0]); + R1(L, R, m_MK[15], m_RK[15]); + R3(R, L, m_MK[14], m_RK[14]); + R2(L, R, m_MK[13], m_RK[13]); + R1(R, L, m_MK[12], m_RK[12]); + R3(L, R, m_MK[11], m_RK[11]); + R2(R, L, m_MK[10], m_RK[10]); + R1(L, R, m_MK[ 9], m_RK[ 9]); + R3(R, L, m_MK[ 8], m_RK[ 8]); + R2(L, R, m_MK[ 7], m_RK[ 7]); + R1(R, L, m_MK[ 6], m_RK[ 6]); + R3(L, R, m_MK[ 5], m_RK[ 5]); + R2(R, L, m_MK[ 4], m_RK[ 4]); + R1(L, R, m_MK[ 3], m_RK[ 3]); + R3(R, L, m_MK[ 2], m_RK[ 2]); + R2(L, R, m_MK[ 1], m_RK[ 1]); + R1(R, L, m_MK[ 0], m_RK[ 0]); store_be(out, R, L); @@ -118,26 +118,26 @@ void CAST_128::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void CAST_128::key_schedule(const byte key[], size_t length) { - MK.resize(48); - RK.resize(48); + m_MK.resize(48); + m_RK.resize(48); secure_vector<u32bit> X(4); for(size_t i = 0; i != length; ++i) X[i/4] = (X[i/4] << 8) + key[i]; - cast_ks(MK, X); + cast_ks(m_MK, X); secure_vector<u32bit> RK32(48); cast_ks(RK32, X); for(size_t i = 0; i != 16; ++i) - RK[i] = RK32[i] % 32; + m_RK[i] = RK32[i] % 32; } void CAST_128::clear() { - zap(MK); - zap(RK); + zap(m_MK); + zap(m_RK); } /* @@ -329,10 +329,10 @@ void CAST_128::cast_ks(secure_vector<u32bit>& K, class ByteReader { public: - byte operator()(size_t i) { return (X[i/4] >> (8*(3 - (i%4)))); } - ByteReader(const u32bit* x) : X(x) {} + byte operator()(size_t i) { return (m_X[i/4] >> (8*(3 - (i%4)))); } + ByteReader(const u32bit* x) : m_X(x) {} private: - const u32bit* X; + const u32bit* m_X; }; secure_vector<u32bit> Z(4); diff --git a/src/lib/block/cast/cast128.h b/src/lib/block/cast/cast128.h index 2a0f4462a..491dd56f2 100644 --- a/src/lib/block/cast/cast128.h +++ b/src/lib/block/cast/cast128.h @@ -31,8 +31,8 @@ class BOTAN_DLL CAST_128 : public Block_Cipher_Fixed_Params<8, 11, 16> static void cast_ks(secure_vector<u32bit>& ks, secure_vector<u32bit>& user_key); - secure_vector<u32bit> MK; - secure_vector<byte> RK; + secure_vector<u32bit> m_MK; + secure_vector<byte> m_RK; }; } diff --git a/src/lib/block/cast/cast256.cpp b/src/lib/block/cast/cast256.cpp index 7178dc5c1..637fdfee2 100644 --- a/src/lib/block/cast/cast256.cpp +++ b/src/lib/block/cast/cast256.cpp @@ -57,30 +57,30 @@ void CAST_256::encrypt_n(const byte in[], byte out[], size_t blocks) const u32bit C = load_be<u32bit>(in, 2); u32bit D = load_be<u32bit>(in, 3); - round1(C, D, MK[ 0], RK[ 0]); round2(B, C, MK[ 1], RK[ 1]); - round3(A, B, MK[ 2], RK[ 2]); round1(D, A, MK[ 3], RK[ 3]); - round1(C, D, MK[ 4], RK[ 4]); round2(B, C, MK[ 5], RK[ 5]); - round3(A, B, MK[ 6], RK[ 6]); round1(D, A, MK[ 7], RK[ 7]); - round1(C, D, MK[ 8], RK[ 8]); round2(B, C, MK[ 9], RK[ 9]); - round3(A, B, MK[10], RK[10]); round1(D, A, MK[11], RK[11]); - round1(C, D, MK[12], RK[12]); round2(B, C, MK[13], RK[13]); - round3(A, B, MK[14], RK[14]); round1(D, A, MK[15], RK[15]); - round1(C, D, MK[16], RK[16]); round2(B, C, MK[17], RK[17]); - round3(A, B, MK[18], RK[18]); round1(D, A, MK[19], RK[19]); - round1(C, D, MK[20], RK[20]); round2(B, C, MK[21], RK[21]); - round3(A, B, MK[22], RK[22]); round1(D, A, MK[23], RK[23]); - round1(D, A, MK[27], RK[27]); round3(A, B, MK[26], RK[26]); - round2(B, C, MK[25], RK[25]); round1(C, D, MK[24], RK[24]); - round1(D, A, MK[31], RK[31]); round3(A, B, MK[30], RK[30]); - round2(B, C, MK[29], RK[29]); round1(C, D, MK[28], RK[28]); - round1(D, A, MK[35], RK[35]); round3(A, B, MK[34], RK[34]); - round2(B, C, MK[33], RK[33]); round1(C, D, MK[32], RK[32]); - round1(D, A, MK[39], RK[39]); round3(A, B, MK[38], RK[38]); - round2(B, C, MK[37], RK[37]); round1(C, D, MK[36], RK[36]); - round1(D, A, MK[43], RK[43]); round3(A, B, MK[42], RK[42]); - round2(B, C, MK[41], RK[41]); round1(C, D, MK[40], RK[40]); - round1(D, A, MK[47], RK[47]); round3(A, B, MK[46], RK[46]); - round2(B, C, MK[45], RK[45]); round1(C, D, MK[44], RK[44]); + 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]); + round1(C, D, m_MK[ 4], m_RK[ 4]); round2(B, C, m_MK[ 5], m_RK[ 5]); + round3(A, B, m_MK[ 6], m_RK[ 6]); round1(D, A, m_MK[ 7], m_RK[ 7]); + round1(C, D, m_MK[ 8], m_RK[ 8]); round2(B, C, m_MK[ 9], m_RK[ 9]); + round3(A, B, m_MK[10], m_RK[10]); round1(D, A, m_MK[11], m_RK[11]); + round1(C, D, m_MK[12], m_RK[12]); round2(B, C, m_MK[13], m_RK[13]); + round3(A, B, m_MK[14], m_RK[14]); round1(D, A, m_MK[15], m_RK[15]); + round1(C, D, m_MK[16], m_RK[16]); round2(B, C, m_MK[17], m_RK[17]); + round3(A, B, m_MK[18], m_RK[18]); round1(D, A, m_MK[19], m_RK[19]); + round1(C, D, m_MK[20], m_RK[20]); round2(B, C, m_MK[21], m_RK[21]); + round3(A, B, m_MK[22], m_RK[22]); round1(D, A, m_MK[23], m_RK[23]); + round1(D, A, m_MK[27], m_RK[27]); round3(A, B, m_MK[26], m_RK[26]); + round2(B, C, m_MK[25], m_RK[25]); round1(C, D, m_MK[24], m_RK[24]); + round1(D, A, m_MK[31], m_RK[31]); round3(A, B, m_MK[30], m_RK[30]); + round2(B, C, m_MK[29], m_RK[29]); round1(C, D, m_MK[28], m_RK[28]); + round1(D, A, m_MK[35], m_RK[35]); round3(A, B, m_MK[34], m_RK[34]); + round2(B, C, m_MK[33], m_RK[33]); round1(C, D, m_MK[32], m_RK[32]); + round1(D, A, m_MK[39], m_RK[39]); round3(A, B, m_MK[38], m_RK[38]); + round2(B, C, m_MK[37], m_RK[37]); round1(C, D, m_MK[36], m_RK[36]); + round1(D, A, m_MK[43], m_RK[43]); round3(A, B, m_MK[42], m_RK[42]); + round2(B, C, m_MK[41], m_RK[41]); round1(C, D, m_MK[40], m_RK[40]); + round1(D, A, m_MK[47], m_RK[47]); round3(A, B, m_MK[46], m_RK[46]); + round2(B, C, m_MK[45], m_RK[45]); round1(C, D, m_MK[44], m_RK[44]); store_be(out, A, B, C, D); @@ -101,30 +101,30 @@ void CAST_256::decrypt_n(const byte in[], byte out[], size_t blocks) const u32bit C = load_be<u32bit>(in, 2); u32bit D = load_be<u32bit>(in, 3); - round1(C, D, MK[44], RK[44]); round2(B, C, MK[45], RK[45]); - round3(A, B, MK[46], RK[46]); round1(D, A, MK[47], RK[47]); - round1(C, D, MK[40], RK[40]); round2(B, C, MK[41], RK[41]); - round3(A, B, MK[42], RK[42]); round1(D, A, MK[43], RK[43]); - round1(C, D, MK[36], RK[36]); round2(B, C, MK[37], RK[37]); - round3(A, B, MK[38], RK[38]); round1(D, A, MK[39], RK[39]); - round1(C, D, MK[32], RK[32]); round2(B, C, MK[33], RK[33]); - round3(A, B, MK[34], RK[34]); round1(D, A, MK[35], RK[35]); - round1(C, D, MK[28], RK[28]); round2(B, C, MK[29], RK[29]); - round3(A, B, MK[30], RK[30]); round1(D, A, MK[31], RK[31]); - round1(C, D, MK[24], RK[24]); round2(B, C, MK[25], RK[25]); - round3(A, B, MK[26], RK[26]); round1(D, A, MK[27], RK[27]); - round1(D, A, MK[23], RK[23]); round3(A, B, MK[22], RK[22]); - round2(B, C, MK[21], RK[21]); round1(C, D, MK[20], RK[20]); - round1(D, A, MK[19], RK[19]); round3(A, B, MK[18], RK[18]); - round2(B, C, MK[17], RK[17]); round1(C, D, MK[16], RK[16]); - round1(D, A, MK[15], RK[15]); round3(A, B, MK[14], RK[14]); - round2(B, C, MK[13], RK[13]); round1(C, D, MK[12], RK[12]); - round1(D, A, MK[11], RK[11]); round3(A, B, MK[10], RK[10]); - round2(B, C, MK[ 9], RK[ 9]); round1(C, D, MK[ 8], RK[ 8]); - round1(D, A, MK[ 7], RK[ 7]); round3(A, B, MK[ 6], RK[ 6]); - round2(B, C, MK[ 5], RK[ 5]); round1(C, D, MK[ 4], RK[ 4]); - round1(D, A, MK[ 3], RK[ 3]); round3(A, B, MK[ 2], RK[ 2]); - round2(B, C, MK[ 1], RK[ 1]); round1(C, D, MK[ 0], RK[ 0]); + 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]); + round1(C, D, m_MK[40], m_RK[40]); round2(B, C, m_MK[41], m_RK[41]); + round3(A, B, m_MK[42], m_RK[42]); round1(D, A, m_MK[43], m_RK[43]); + round1(C, D, m_MK[36], m_RK[36]); round2(B, C, m_MK[37], m_RK[37]); + round3(A, B, m_MK[38], m_RK[38]); round1(D, A, m_MK[39], m_RK[39]); + round1(C, D, m_MK[32], m_RK[32]); round2(B, C, m_MK[33], m_RK[33]); + round3(A, B, m_MK[34], m_RK[34]); round1(D, A, m_MK[35], m_RK[35]); + round1(C, D, m_MK[28], m_RK[28]); round2(B, C, m_MK[29], m_RK[29]); + round3(A, B, m_MK[30], m_RK[30]); round1(D, A, m_MK[31], m_RK[31]); + round1(C, D, m_MK[24], m_RK[24]); round2(B, C, m_MK[25], m_RK[25]); + round3(A, B, m_MK[26], m_RK[26]); round1(D, A, m_MK[27], m_RK[27]); + round1(D, A, m_MK[23], m_RK[23]); round3(A, B, m_MK[22], m_RK[22]); + round2(B, C, m_MK[21], m_RK[21]); round1(C, D, m_MK[20], m_RK[20]); + round1(D, A, m_MK[19], m_RK[19]); round3(A, B, m_MK[18], m_RK[18]); + round2(B, C, m_MK[17], m_RK[17]); round1(C, D, m_MK[16], m_RK[16]); + round1(D, A, m_MK[15], m_RK[15]); round3(A, B, m_MK[14], m_RK[14]); + round2(B, C, m_MK[13], m_RK[13]); round1(C, D, m_MK[12], m_RK[12]); + round1(D, A, m_MK[11], m_RK[11]); round3(A, B, m_MK[10], m_RK[10]); + round2(B, C, m_MK[ 9], m_RK[ 9]); round1(C, D, m_MK[ 8], m_RK[ 8]); + round1(D, A, m_MK[ 7], m_RK[ 7]); round3(A, B, m_MK[ 6], m_RK[ 6]); + round2(B, C, m_MK[ 5], m_RK[ 5]); round1(C, D, m_MK[ 4], m_RK[ 4]); + round1(D, A, m_MK[ 3], m_RK[ 3]); round3(A, B, m_MK[ 2], m_RK[ 2]); + round2(B, C, m_MK[ 1], m_RK[ 1]); round1(C, D, m_MK[ 0], m_RK[ 0]); store_be(out, A, B, C, D); @@ -178,8 +178,8 @@ void CAST_256::key_schedule(const byte key[], size_t length) 0x07, 0x18, 0x09, 0x1A, 0x0B, 0x1C, 0x0D, 0x1E, 0x0F, 0x00, 0x11, 0x02 }; - MK.resize(48); - RK.resize(48); + m_MK.resize(48); + m_RK.resize(48); secure_vector<u32bit> K(8); for(size_t i = 0; i != length; ++i) @@ -207,21 +207,21 @@ void CAST_256::key_schedule(const byte key[], size_t length) round1(A, B, KEY_MASK[4*i+14], KEY_ROT[(4*i+14) % 32]); round2(H, A, KEY_MASK[4*i+15], KEY_ROT[(4*i+15) % 32]); - RK[i ] = (A % 32); - RK[i+1] = (C % 32); - RK[i+2] = (E % 32); - RK[i+3] = (G % 32); - MK[i ] = H; - MK[i+1] = F; - MK[i+2] = D; - MK[i+3] = B; + m_RK[i ] = (A % 32); + m_RK[i+1] = (C % 32); + m_RK[i+2] = (E % 32); + m_RK[i+3] = (G % 32); + m_MK[i ] = H; + m_MK[i+1] = F; + m_MK[i+2] = D; + m_MK[i+3] = B; } } void CAST_256::clear() { - zap(MK); - zap(RK); + zap(m_MK); + zap(m_RK); } } diff --git a/src/lib/block/cast/cast256.h b/src/lib/block/cast/cast256.h index 9f7546711..2e7d5cddd 100644 --- a/src/lib/block/cast/cast256.h +++ b/src/lib/block/cast/cast256.h @@ -27,8 +27,8 @@ class BOTAN_DLL CAST_256 : public Block_Cipher_Fixed_Params<16, 4, 32, 4> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> MK; - secure_vector<byte> RK; + secure_vector<u32bit> m_MK; + secure_vector<byte> m_RK; }; } diff --git a/src/lib/block/des/des.cpp b/src/lib/block/des/des.cpp index 6d2bcfe1e..88671df8d 100644 --- a/src/lib/block/des/des.cpp +++ b/src/lib/block/des/des.cpp @@ -154,7 +154,7 @@ void DES::encrypt_n(const byte in[], byte out[], size_t blocks) const u32bit L = static_cast<u32bit>(T >> 32); u32bit R = static_cast<u32bit>(T); - des_encrypt(L, R, round_key.data()); + des_encrypt(L, R, m_round_key.data()); T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | @@ -184,7 +184,7 @@ void DES::decrypt_n(const byte in[], byte out[], size_t blocks) const u32bit L = static_cast<u32bit>(T >> 32); u32bit R = static_cast<u32bit>(T); - des_decrypt(L, R, round_key.data()); + des_decrypt(L, R, m_round_key.data()); T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | @@ -205,13 +205,13 @@ void DES::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void DES::key_schedule(const byte key[], size_t) { - round_key.resize(32); - des_key_schedule(round_key.data(), key); + m_round_key.resize(32); + des_key_schedule(m_round_key.data(), key); } void DES::clear() { - zap(round_key); + zap(m_round_key); } /* @@ -229,9 +229,9 @@ void TripleDES::encrypt_n(const byte in[], byte out[], size_t blocks) const u32bit L = static_cast<u32bit>(T >> 32); u32bit R = static_cast<u32bit>(T); - des_encrypt(L, R, &round_key[0]); - des_decrypt(R, L, &round_key[32]); - des_encrypt(L, R, &round_key[64]); + des_encrypt(L, R, &m_round_key[0]); + des_decrypt(R, L, &m_round_key[32]); + des_encrypt(L, R, &m_round_key[64]); T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | @@ -262,9 +262,9 @@ void TripleDES::decrypt_n(const byte in[], byte out[], size_t blocks) const u32bit L = static_cast<u32bit>(T >> 32); u32bit R = static_cast<u32bit>(T); - des_decrypt(L, R, &round_key[64]); - des_encrypt(R, L, &round_key[32]); - des_decrypt(L, R, &round_key[0]); + des_decrypt(L, R, &m_round_key[64]); + des_encrypt(R, L, &m_round_key[32]); + des_decrypt(L, R, &m_round_key[0]); T = (DES_FPTAB1[get_byte(0, L)] << 5) | (DES_FPTAB1[get_byte(1, L)] << 3) | (DES_FPTAB1[get_byte(2, L)] << 1) | (DES_FPTAB2[get_byte(3, L)] << 1) | @@ -285,19 +285,19 @@ void TripleDES::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void TripleDES::key_schedule(const byte key[], size_t length) { - round_key.resize(3*32); - des_key_schedule(&round_key[0], key); - des_key_schedule(&round_key[32], key + 8); + m_round_key.resize(3*32); + des_key_schedule(&m_round_key[0], key); + des_key_schedule(&m_round_key[32], key + 8); if(length == 24) - des_key_schedule(&round_key[64], key + 16); + des_key_schedule(&m_round_key[64], key + 16); else - copy_mem(&round_key[64], &round_key[0], 32); + copy_mem(&m_round_key[64], &m_round_key[0], 32); } void TripleDES::clear() { - zap(round_key); + zap(m_round_key); } } diff --git a/src/lib/block/des/des.h b/src/lib/block/des/des.h index 1a2fdc5c9..8ea132ac1 100644 --- a/src/lib/block/des/des.h +++ b/src/lib/block/des/des.h @@ -27,7 +27,7 @@ class BOTAN_DLL DES : public Block_Cipher_Fixed_Params<8, 8> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> round_key; + secure_vector<u32bit> m_round_key; }; /** @@ -45,7 +45,7 @@ class BOTAN_DLL TripleDES : public Block_Cipher_Fixed_Params<8, 16, 24, 8> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> round_key; + secure_vector<u32bit> m_round_key; }; /* diff --git a/src/lib/block/des/desx.cpp b/src/lib/block/des/desx.cpp index f6538748c..76a50f9a2 100644 --- a/src/lib/block/des/desx.cpp +++ b/src/lib/block/des/desx.cpp @@ -16,9 +16,9 @@ void DESX::encrypt_n(const byte in[], byte out[], size_t blocks) const { for(size_t i = 0; i != blocks; ++i) { - xor_buf(out, in, K1.data(), BLOCK_SIZE); - des.encrypt(out); - xor_buf(out, K2.data(), BLOCK_SIZE); + xor_buf(out, in, m_K1.data(), BLOCK_SIZE); + m_des.encrypt(out); + xor_buf(out, m_K2.data(), BLOCK_SIZE); in += BLOCK_SIZE; out += BLOCK_SIZE; @@ -32,9 +32,9 @@ void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const { for(size_t i = 0; i != blocks; ++i) { - xor_buf(out, in, K2.data(), BLOCK_SIZE); - des.decrypt(out); - xor_buf(out, K1.data(), BLOCK_SIZE); + xor_buf(out, in, m_K2.data(), BLOCK_SIZE); + m_des.decrypt(out); + xor_buf(out, m_K1.data(), BLOCK_SIZE); in += BLOCK_SIZE; out += BLOCK_SIZE; @@ -46,16 +46,16 @@ void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void DESX::key_schedule(const byte key[], size_t) { - K1.assign(key, key + 8); - des.set_key(key + 8, 8); - K2.assign(key + 16, key + 24); + m_K1.assign(key, key + 8); + m_des.set_key(key + 8, 8); + m_K2.assign(key + 16, key + 24); } void DESX::clear() { - des.clear(); - zap(K1); - zap(K2); + m_des.clear(); + zap(m_K1); + zap(m_K2); } } diff --git a/src/lib/block/des/desx.h b/src/lib/block/des/desx.h index 0f155b241..06ca91c9f 100644 --- a/src/lib/block/des/desx.h +++ b/src/lib/block/des/desx.h @@ -26,8 +26,8 @@ class BOTAN_DLL DESX : public Block_Cipher_Fixed_Params<8, 24> BlockCipher* clone() const override { return new DESX; } private: void key_schedule(const byte[], size_t) override; - secure_vector<byte> K1, K2; - DES des; + secure_vector<byte> 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 b8c3b7280..5fa232478 100644 --- a/src/lib/block/gost_28147/gost_28147.cpp +++ b/src/lib/block/gost_28147/gost_28147.cpp @@ -12,12 +12,12 @@ namespace Botan { byte GOST_28147_89_Params::sbox_entry(size_t row, size_t col) const { - byte x = sboxes[4 * col + (row / 2)]; + byte x = m_sboxes[4 * col + (row / 2)]; return (row % 2 == 0) ? (x >> 4) : (x & 0x0F); } -GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : name(n) +GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : m_name(n) { // Encoded in the packed fromat from RFC 4357 @@ -39,18 +39,18 @@ GOST_28147_89_Params::GOST_28147_89_Params(const std::string& n) : name(n) 0x03, 0x25, 0xEB, 0xFE, 0x9C, 0x6D, 0xF8, 0x6D, 0x2E, 0xAB, 0xDE, 0x20, 0xBA, 0x89, 0x3C, 0x92, 0xF8, 0xD3, 0x53, 0xBC }; - if(name == "R3411_94_TestParam") - sboxes = GOST_R_3411_TEST_PARAMS; - else if(name == "R3411_CryptoPro") - sboxes = GOST_R_3411_CRYPTOPRO_PARAMS; + if(m_name == "R3411_94_TestParam") + m_sboxes = GOST_R_3411_TEST_PARAMS; + else if(m_name == "R3411_CryptoPro") + m_sboxes = GOST_R_3411_CRYPTOPRO_PARAMS; else - throw Invalid_Argument("GOST_28147_89_Params: Unknown " + name); + throw Invalid_Argument("GOST_28147_89_Params: Unknown " + m_name); } /* * GOST Constructor */ -GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : SBOX(1024) +GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : m_SBOX(1024) { // Convert the parallel 4x4 sboxes into larger word-based sboxes for(size_t i = 0; i != 4; ++i) @@ -58,7 +58,7 @@ GOST_28147_89::GOST_28147_89(const GOST_28147_89_Params& param) : SBOX(1024) { const u32bit T = (param.sbox_entry(2*i , j % 16)) | (param.sbox_entry(2*i+1, j / 16) << 4); - SBOX[256*i+j] = rotate_left(T, (11+8*i) % 32); + m_SBOX[256*i+j] = rotate_left(T, (11+8*i) % 32); } } @@ -71,9 +71,9 @@ std::string GOST_28147_89::name() const constructor, but can't break binary compat. */ std::string sbox_name = ""; - if(SBOX[0] == 0x00072000) + if(m_SBOX[0] == 0x00072000) sbox_name = "R3411_94_TestParam"; - else if(SBOX[0] == 0x0002D000) + else if(m_SBOX[0] == 0x0002D000) sbox_name = "R3411_CryptoPro"; else throw Internal_Error("GOST-28147 unrecognized sbox value"); @@ -86,17 +86,17 @@ std::string GOST_28147_89::name() const */ #define GOST_2ROUND(N1, N2, R1, R2) \ do { \ - u32bit T0 = N1 + EK[R1]; \ - N2 ^= SBOX[get_byte(3, T0)] | \ - SBOX[get_byte(2, T0)+256] | \ - SBOX[get_byte(1, T0)+512] | \ - SBOX[get_byte(0, T0)+768]; \ + u32bit T0 = N1 + m_EK[R1]; \ + N2 ^= m_SBOX[get_byte(3, T0)] | \ + m_SBOX[get_byte(2, T0)+256] | \ + m_SBOX[get_byte(1, T0)+512] | \ + m_SBOX[get_byte(0, T0)+768]; \ \ - u32bit T1 = N2 + EK[R2]; \ - N1 ^= SBOX[get_byte(3, T1)] | \ - SBOX[get_byte(2, T1)+256] | \ - SBOX[get_byte(1, T1)+512] | \ - SBOX[get_byte(0, T1)+768]; \ + u32bit T1 = N2 + m_EK[R2]; \ + N1 ^= m_SBOX[get_byte(3, T1)] | \ + m_SBOX[get_byte(2, T1)+256] | \ + m_SBOX[get_byte(1, T1)+512] | \ + m_SBOX[get_byte(0, T1)+768]; \ } while(0) /* @@ -163,14 +163,14 @@ void GOST_28147_89::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void GOST_28147_89::key_schedule(const byte key[], size_t) { - EK.resize(8); + m_EK.resize(8); for(size_t i = 0; i != 8; ++i) - EK[i] = load_le<u32bit>(key, i); + m_EK[i] = load_le<u32bit>(key, i); } void GOST_28147_89::clear() { - zap(EK); + zap(m_EK); } } diff --git a/src/lib/block/gost_28147/gost_28147.h b/src/lib/block/gost_28147/gost_28147.h index 3cf1c4578..d87559b57 100644 --- a/src/lib/block/gost_28147/gost_28147.h +++ b/src/lib/block/gost_28147/gost_28147.h @@ -31,7 +31,7 @@ class BOTAN_DLL GOST_28147_89_Params /** * @return name of this parameter set */ - std::string param_name() const { return name; } + std::string param_name() const { return m_name; } /** * Default GOST parameters are the ones given in GOST R 34.11 for @@ -42,8 +42,8 @@ class BOTAN_DLL GOST_28147_89_Params */ GOST_28147_89_Params(const std::string& name = "R3411_94_TestParam"); private: - const byte* sboxes; - std::string name; + const byte* m_sboxes; + std::string m_name; }; /** @@ -58,7 +58,7 @@ class BOTAN_DLL GOST_28147_89 : public Block_Cipher_Fixed_Params<8, 32> void clear() override; std::string name() const override; - BlockCipher* clone() const override { return new GOST_28147_89(SBOX); } + BlockCipher* clone() const override { return new GOST_28147_89(m_SBOX); } /** * @param params the sbox parameters to use @@ -66,7 +66,7 @@ class BOTAN_DLL GOST_28147_89 : public Block_Cipher_Fixed_Params<8, 32> GOST_28147_89(const GOST_28147_89_Params& params); private: GOST_28147_89(const std::vector<u32bit>& other_SBOX) : - SBOX(other_SBOX), EK(8) {} + m_SBOX(other_SBOX), m_EK(8) {} void key_schedule(const byte[], size_t) override; @@ -74,9 +74,9 @@ class BOTAN_DLL GOST_28147_89 : public Block_Cipher_Fixed_Params<8, 32> * The sbox is not secret, this is just a larger expansion of it * which we generate at runtime for faster execution */ - std::vector<u32bit> SBOX; + std::vector<u32bit> m_SBOX; - secure_vector<u32bit> EK; + secure_vector<u32bit> m_EK; }; } diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp index 8069e16f7..4182c59a7 100644 --- a/src/lib/block/idea/idea.cpp +++ b/src/lib/block/idea/idea.cpp @@ -113,7 +113,7 @@ void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52]) */ void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const { - idea_op(in, out, blocks, EK.data()); + idea_op(in, out, blocks, m_EK.data()); } /* @@ -121,7 +121,7 @@ void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const */ void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const { - idea_op(in, out, blocks, DK.data()); + idea_op(in, out, blocks, m_DK.data()); } /* @@ -129,54 +129,54 @@ void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void IDEA::key_schedule(const byte key[], size_t) { - EK.resize(52); - DK.resize(52); + m_EK.resize(52); + m_DK.resize(52); CT::poison(key, 16); - CT::poison(EK.data(), 52); - CT::poison(DK.data(), 52); + CT::poison(m_EK.data(), 52); + CT::poison(m_DK.data(), 52); for(size_t i = 0; i != 8; ++i) - EK[i] = load_be<u16bit>(key, i); + m_EK[i] = load_be<u16bit>(key, i); for(size_t i = 1, j = 8, offset = 0; j != 52; i %= 8, ++i, ++j) { - EK[i+7+offset] = static_cast<u16bit>((EK[(i % 8) + offset] << 9) | - (EK[((i+1) % 8) + offset] >> 7)); + m_EK[i+7+offset] = static_cast<u16bit>((m_EK[(i % 8) + offset] << 9) | + (m_EK[((i+1) % 8) + offset] >> 7)); offset += (i == 8) ? 8 : 0; } - DK[51] = mul_inv(EK[3]); - DK[50] = -EK[2]; - DK[49] = -EK[1]; - DK[48] = mul_inv(EK[0]); + m_DK[51] = mul_inv(m_EK[3]); + m_DK[50] = -m_EK[2]; + m_DK[49] = -m_EK[1]; + m_DK[48] = mul_inv(m_EK[0]); for(size_t i = 1, j = 4, counter = 47; i != 8; ++i, j += 6) { - DK[counter--] = EK[j+1]; - DK[counter--] = EK[j]; - DK[counter--] = mul_inv(EK[j+5]); - DK[counter--] = -EK[j+3]; - DK[counter--] = -EK[j+4]; - DK[counter--] = mul_inv(EK[j+2]); + m_DK[counter--] = m_EK[j+1]; + m_DK[counter--] = m_EK[j]; + m_DK[counter--] = mul_inv(m_EK[j+5]); + m_DK[counter--] = -m_EK[j+3]; + m_DK[counter--] = -m_EK[j+4]; + m_DK[counter--] = mul_inv(m_EK[j+2]); } - DK[5] = EK[47]; - DK[4] = EK[46]; - DK[3] = mul_inv(EK[51]); - DK[2] = -EK[50]; - DK[1] = -EK[49]; - DK[0] = mul_inv(EK[48]); + m_DK[5] = m_EK[47]; + m_DK[4] = m_EK[46]; + m_DK[3] = mul_inv(m_EK[51]); + m_DK[2] = -m_EK[50]; + m_DK[1] = -m_EK[49]; + m_DK[0] = mul_inv(m_EK[48]); CT::unpoison(key, 16); - CT::unpoison(EK.data(), 52); - CT::unpoison(DK.data(), 52); + CT::unpoison(m_EK.data(), 52); + CT::unpoison(m_DK.data(), 52); } void IDEA::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } } diff --git a/src/lib/block/idea/idea.h b/src/lib/block/idea/idea.h index 68d4d61b0..59f98da9e 100644 --- a/src/lib/block/idea/idea.h +++ b/src/lib/block/idea/idea.h @@ -28,17 +28,17 @@ class BOTAN_DLL IDEA : public Block_Cipher_Fixed_Params<8, 16> /** * @return const reference to encryption subkeys */ - const secure_vector<u16bit>& get_EK() const { return EK; } + const secure_vector<u16bit>& get_EK() const { return m_EK; } /** * @return const reference to decryption subkeys */ - const secure_vector<u16bit>& get_DK() const { return DK; } + const secure_vector<u16bit>& get_DK() const { return m_DK; } private: void key_schedule(const byte[], size_t) override; - secure_vector<u16bit> EK, DK; + secure_vector<u16bit> m_EK, m_DK; }; } diff --git a/src/lib/block/kasumi/kasumi.cpp b/src/lib/block/kasumi/kasumi.cpp index 604d2d21a..014987bc6 100644 --- a/src/lib/block/kasumi/kasumi.cpp +++ b/src/lib/block/kasumi/kasumi.cpp @@ -119,7 +119,7 @@ void KASUMI::encrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 8; j += 2) { - const u16bit* K = &EK[8*j]; + const u16bit* K = &m_EK[8*j]; u16bit R = B1 ^ (rotate_left(B0, 1) & K[0]); u16bit L = B0 ^ (rotate_left(R, 1) | K[1]); @@ -163,7 +163,7 @@ void KASUMI::decrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 8; j += 2) { - const u16bit* K = &EK[8*(6-j)]; + const u16bit* K = &m_EK[8*(6-j)]; u16bit L = B2, R = B3; @@ -210,24 +210,24 @@ void KASUMI::key_schedule(const byte key[], size_t) K[i+8] = K[i] ^ RC[i]; } - EK.resize(64); + m_EK.resize(64); for(size_t i = 0; i != 8; ++i) { - EK[8*i ] = rotate_left(K[(i+0) % 8 ], 2); - EK[8*i+1] = rotate_left(K[(i+2) % 8 + 8], 1); - EK[8*i+2] = rotate_left(K[(i+1) % 8 ], 5); - EK[8*i+3] = K[(i+4) % 8 + 8]; - EK[8*i+4] = rotate_left(K[(i+5) % 8 ], 8); - EK[8*i+5] = K[(i+3) % 8 + 8]; - EK[8*i+6] = rotate_left(K[(i+6) % 8 ], 13); - EK[8*i+7] = K[(i+7) % 8 + 8]; + m_EK[8*i ] = rotate_left(K[(i+0) % 8 ], 2); + m_EK[8*i+1] = rotate_left(K[(i+2) % 8 + 8], 1); + m_EK[8*i+2] = rotate_left(K[(i+1) % 8 ], 5); + m_EK[8*i+3] = K[(i+4) % 8 + 8]; + m_EK[8*i+4] = rotate_left(K[(i+5) % 8 ], 8); + m_EK[8*i+5] = K[(i+3) % 8 + 8]; + m_EK[8*i+6] = rotate_left(K[(i+6) % 8 ], 13); + m_EK[8*i+7] = K[(i+7) % 8 + 8]; } } void KASUMI::clear() { - zap(EK); + zap(m_EK); } } diff --git a/src/lib/block/kasumi/kasumi.h b/src/lib/block/kasumi/kasumi.h index 9f86279af..83b936766 100644 --- a/src/lib/block/kasumi/kasumi.h +++ b/src/lib/block/kasumi/kasumi.h @@ -27,7 +27,7 @@ class BOTAN_DLL KASUMI : public Block_Cipher_Fixed_Params<8, 16> private: void key_schedule(const byte[], size_t) override; - secure_vector<u16bit> EK; + secure_vector<u16bit> m_EK; }; } diff --git a/src/lib/block/mars/mars.cpp b/src/lib/block/mars/mars.cpp index 1c41134d3..4605be415 100644 --- a/src/lib/block/mars/mars.cpp +++ b/src/lib/block/mars/mars.cpp @@ -235,34 +235,34 @@ void MARS::encrypt_n(const byte in[], byte out[], size_t blocks) const { for(size_t i = 0; i != blocks; ++i) { - u32bit A = load_le<u32bit>(in, 0) + EK[0]; - u32bit B = load_le<u32bit>(in, 1) + EK[1]; - u32bit C = load_le<u32bit>(in, 2) + EK[2]; - u32bit D = load_le<u32bit>(in, 3) + EK[3]; + u32bit A = load_le<u32bit>(in, 0) + m_EK[0]; + u32bit B = load_le<u32bit>(in, 1) + m_EK[1]; + u32bit C = load_le<u32bit>(in, 2) + m_EK[2]; + u32bit D = load_le<u32bit>(in, 3) + m_EK[3]; forward_mix(A, B, C, D); - encrypt_round(A, B, C, D, EK[ 4], EK[ 5]); - encrypt_round(B, C, D, A, EK[ 6], EK[ 7]); - encrypt_round(C, D, A, B, EK[ 8], EK[ 9]); - encrypt_round(D, A, B, C, EK[10], EK[11]); - encrypt_round(A, B, C, D, EK[12], EK[13]); - encrypt_round(B, C, D, A, EK[14], EK[15]); - encrypt_round(C, D, A, B, EK[16], EK[17]); - encrypt_round(D, A, B, C, EK[18], EK[19]); - - encrypt_round(A, D, C, B, EK[20], EK[21]); - encrypt_round(B, A, D, C, EK[22], EK[23]); - encrypt_round(C, B, A, D, EK[24], EK[25]); - encrypt_round(D, C, B, A, EK[26], EK[27]); - encrypt_round(A, D, C, B, EK[28], EK[29]); - encrypt_round(B, A, D, C, EK[30], EK[31]); - encrypt_round(C, B, A, D, EK[32], EK[33]); - encrypt_round(D, C, B, A, EK[34], EK[35]); + encrypt_round(A, B, C, D, m_EK[ 4], m_EK[ 5]); + encrypt_round(B, C, D, A, m_EK[ 6], m_EK[ 7]); + encrypt_round(C, D, A, B, m_EK[ 8], m_EK[ 9]); + encrypt_round(D, A, B, C, m_EK[10], m_EK[11]); + encrypt_round(A, B, C, D, m_EK[12], m_EK[13]); + encrypt_round(B, C, D, A, m_EK[14], m_EK[15]); + encrypt_round(C, D, A, B, m_EK[16], m_EK[17]); + encrypt_round(D, A, B, C, m_EK[18], m_EK[19]); + + encrypt_round(A, D, C, B, m_EK[20], m_EK[21]); + encrypt_round(B, A, D, C, m_EK[22], m_EK[23]); + encrypt_round(C, B, A, D, m_EK[24], m_EK[25]); + encrypt_round(D, C, B, A, m_EK[26], m_EK[27]); + encrypt_round(A, D, C, B, m_EK[28], m_EK[29]); + encrypt_round(B, A, D, C, m_EK[30], m_EK[31]); + encrypt_round(C, B, A, D, m_EK[32], m_EK[33]); + encrypt_round(D, C, B, A, m_EK[34], m_EK[35]); reverse_mix(A, B, C, D); - A -= EK[36]; B -= EK[37]; C -= EK[38]; D -= EK[39]; + A -= m_EK[36]; B -= m_EK[37]; C -= m_EK[38]; D -= m_EK[39]; store_le(out, A, B, C, D); @@ -278,34 +278,34 @@ void MARS::decrypt_n(const byte in[], byte out[], size_t blocks) const { for(size_t i = 0; i != blocks; ++i) { - u32bit A = load_le<u32bit>(in, 3) + EK[39]; - u32bit B = load_le<u32bit>(in, 2) + EK[38]; - u32bit C = load_le<u32bit>(in, 1) + EK[37]; - u32bit D = load_le<u32bit>(in, 0) + EK[36]; + u32bit A = load_le<u32bit>(in, 3) + m_EK[39]; + u32bit B = load_le<u32bit>(in, 2) + m_EK[38]; + u32bit C = load_le<u32bit>(in, 1) + m_EK[37]; + u32bit D = load_le<u32bit>(in, 0) + m_EK[36]; forward_mix(A, B, C, D); - decrypt_round(A, B, C, D, EK[35], EK[34]); - decrypt_round(B, C, D, A, EK[33], EK[32]); - decrypt_round(C, D, A, B, EK[31], EK[30]); - decrypt_round(D, A, B, C, EK[29], EK[28]); - decrypt_round(A, B, C, D, EK[27], EK[26]); - decrypt_round(B, C, D, A, EK[25], EK[24]); - decrypt_round(C, D, A, B, EK[23], EK[22]); - decrypt_round(D, A, B, C, EK[21], EK[20]); - - decrypt_round(A, D, C, B, EK[19], EK[18]); - decrypt_round(B, A, D, C, EK[17], EK[16]); - decrypt_round(C, B, A, D, EK[15], EK[14]); - decrypt_round(D, C, B, A, EK[13], EK[12]); - decrypt_round(A, D, C, B, EK[11], EK[10]); - decrypt_round(B, A, D, C, EK[ 9], EK[ 8]); - decrypt_round(C, B, A, D, EK[ 7], EK[ 6]); - decrypt_round(D, C, B, A, EK[ 5], EK[ 4]); + decrypt_round(A, B, C, D, m_EK[35], m_EK[34]); + decrypt_round(B, C, D, A, m_EK[33], m_EK[32]); + decrypt_round(C, D, A, B, m_EK[31], m_EK[30]); + decrypt_round(D, A, B, C, m_EK[29], m_EK[28]); + decrypt_round(A, B, C, D, m_EK[27], m_EK[26]); + decrypt_round(B, C, D, A, m_EK[25], m_EK[24]); + decrypt_round(C, D, A, B, m_EK[23], m_EK[22]); + decrypt_round(D, A, B, C, m_EK[21], m_EK[20]); + + decrypt_round(A, D, C, B, m_EK[19], m_EK[18]); + decrypt_round(B, A, D, C, m_EK[17], m_EK[16]); + decrypt_round(C, B, A, D, m_EK[15], m_EK[14]); + decrypt_round(D, C, B, A, m_EK[13], m_EK[12]); + decrypt_round(A, D, C, B, m_EK[11], m_EK[10]); + decrypt_round(B, A, D, C, m_EK[ 9], m_EK[ 8]); + decrypt_round(C, B, A, D, m_EK[ 7], m_EK[ 6]); + decrypt_round(D, C, B, A, m_EK[ 5], m_EK[ 4]); reverse_mix(A, B, C, D); - A -= EK[3]; B -= EK[2]; C -= EK[1]; D -= EK[0]; + A -= m_EK[3]; B -= m_EK[2]; C -= m_EK[1]; D -= m_EK[0]; store_le(out, D, C, B, A); @@ -325,7 +325,7 @@ void MARS::key_schedule(const byte key[], size_t length) T[length / 4] = static_cast<u32bit>(length) / 4; - EK.resize(40); + m_EK.resize(40); for(u32bit i = 0; i != 4; ++i) { @@ -364,29 +364,29 @@ void MARS::key_schedule(const byte key[], size_t length) T[14] = rotate_left(T[14] + SBOX[T[13] % 512], 9); } - EK[10*i + 0] = T[ 0]; - EK[10*i + 1] = T[ 4]; - EK[10*i + 2] = T[ 8]; - EK[10*i + 3] = T[12]; - EK[10*i + 4] = T[ 1]; - EK[10*i + 5] = T[ 5]; - EK[10*i + 6] = T[ 9]; - EK[10*i + 7] = T[13]; - EK[10*i + 8] = T[ 2]; - EK[10*i + 9] = T[ 6]; + m_EK[10*i + 0] = T[ 0]; + m_EK[10*i + 1] = T[ 4]; + m_EK[10*i + 2] = T[ 8]; + m_EK[10*i + 3] = T[12]; + m_EK[10*i + 4] = T[ 1]; + m_EK[10*i + 5] = T[ 5]; + m_EK[10*i + 6] = T[ 9]; + m_EK[10*i + 7] = T[13]; + m_EK[10*i + 8] = T[ 2]; + m_EK[10*i + 9] = T[ 6]; } for(size_t i = 5; i != 37; i += 2) { - const u32bit key3 = EK[i] & 3; - EK[i] |= 3; - EK[i] ^= rotate_left(SBOX[265 + key3], EK[i-1] % 32) & gen_mask(EK[i]); + const u32bit key3 = m_EK[i] & 3; + m_EK[i] |= 3; + m_EK[i] ^= rotate_left(SBOX[265 + key3], m_EK[i-1] % 32) & gen_mask(m_EK[i]); } } void MARS::clear() { - zap(EK); + zap(m_EK); } } diff --git a/src/lib/block/mars/mars.h b/src/lib/block/mars/mars.h index 250fd2731..5d53f6e26 100644 --- a/src/lib/block/mars/mars.h +++ b/src/lib/block/mars/mars.h @@ -27,7 +27,7 @@ class BOTAN_DLL MARS : public Block_Cipher_Fixed_Params<16, 16, 32, 4> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK; + secure_vector<u32bit> m_EK; }; } diff --git a/src/lib/block/misty1/misty1.cpp b/src/lib/block/misty1/misty1.cpp index 490eec826..7f8ac7c76 100644 --- a/src/lib/block/misty1/misty1.cpp +++ b/src/lib/block/misty1/misty1.cpp @@ -113,7 +113,7 @@ void MISTY1::encrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 12; j += 3) { - const u16bit* RK = &EK[8 * j]; + const u16bit* RK = &m_EK[8 * j]; B1 ^= B0 & RK[0]; B0 ^= B1 | RK[1]; @@ -137,10 +137,10 @@ void MISTY1::encrypt_n(const byte in[], byte out[], size_t blocks) const B1 ^= T0; } - B1 ^= B0 & EK[96]; - B0 ^= B1 | EK[97]; - B3 ^= B2 & EK[98]; - B2 ^= B3 | EK[99]; + B1 ^= B0 & m_EK[96]; + B0 ^= B1 | m_EK[97]; + B3 ^= B2 & m_EK[98]; + B2 ^= B3 | m_EK[99]; store_be(out, B2, B3, B0, B1); @@ -163,7 +163,7 @@ void MISTY1::decrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 12; j += 3) { - const u16bit* RK = &DK[8 * j]; + const u16bit* RK = &m_DK[8 * j]; B2 ^= B3 | RK[0]; B3 ^= B2 & RK[1]; @@ -187,10 +187,10 @@ void MISTY1::decrypt_n(const byte in[], byte out[], size_t blocks) const B3 ^= T0; } - B2 ^= B3 | DK[96]; - B3 ^= B2 & DK[97]; - B0 ^= B1 | DK[98]; - B1 ^= B0 & DK[99]; + B2 ^= B3 | m_DK[96]; + B3 ^= B2 & m_DK[97]; + B0 ^= B1 | m_DK[98]; + B1 ^= B0 & m_DK[99]; store_be(out, B0, B1, B2, B3); @@ -241,20 +241,20 @@ void MISTY1::key_schedule(const byte key[], size_t length) 0x1C, 0x05, 0x00, 0x15, 0x1D, 0x02, 0x11, 0x19, 0x07, 0x13, 0x1B, 0x04, 0x04, 0x0A, 0x0E, 0x00 }; - EK.resize(100); - DK.resize(100); + m_EK.resize(100); + m_DK.resize(100); for(size_t i = 0; i != 100; ++i) { - EK[i] = KS[EK_ORDER[i]]; - DK[i] = KS[DK_ORDER[i]]; + m_EK[i] = KS[EK_ORDER[i]]; + m_DK[i] = KS[DK_ORDER[i]]; } } void MISTY1::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } } diff --git a/src/lib/block/misty1/misty1.h b/src/lib/block/misty1/misty1.h index 56153f929..5c7754086 100644 --- a/src/lib/block/misty1/misty1.h +++ b/src/lib/block/misty1/misty1.h @@ -27,7 +27,7 @@ class BOTAN_DLL MISTY1 : public Block_Cipher_Fixed_Params<8, 16> private: void key_schedule(const byte[], size_t) override; - secure_vector<u16bit> EK, DK; + secure_vector<u16bit> m_EK, m_DK; }; } diff --git a/src/lib/block/noekeon/noekeon.cpp b/src/lib/block/noekeon/noekeon.cpp index d63ec3129..01f7491f3 100644 --- a/src/lib/block/noekeon/noekeon.cpp +++ b/src/lib/block/noekeon/noekeon.cpp @@ -95,7 +95,7 @@ void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 16; ++j) { A0 ^= RC[j]; - theta(A0, A1, A2, A3, EK.data()); + theta(A0, A1, A2, A3, m_EK.data()); A1 = rotate_left(A1, 1); A2 = rotate_left(A2, 5); @@ -109,7 +109,7 @@ void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const } A0 ^= RC[16]; - theta(A0, A1, A2, A3, EK.data()); + theta(A0, A1, A2, A3, m_EK.data()); store_be(out, A0, A1, A2, A3); @@ -132,7 +132,7 @@ void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 16; j != 0; --j) { - theta(A0, A1, A2, A3, DK.data()); + theta(A0, A1, A2, A3, m_DK.data()); A0 ^= RC[j]; A1 = rotate_left(A1, 1); @@ -146,7 +146,7 @@ void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const A3 = rotate_right(A3, 2); } - theta(A0, A1, A2, A3, DK.data()); + theta(A0, A1, A2, A3, m_DK.data()); A0 ^= RC[0]; store_be(out, A0, A1, A2, A3); @@ -184,19 +184,19 @@ void Noekeon::key_schedule(const byte key[], size_t) A0 ^= RC[16]; - DK.resize(4); - DK[0] = A0; - DK[1] = A1; - DK[2] = A2; - DK[3] = A3; + m_DK.resize(4); + m_DK[0] = A0; + m_DK[1] = A1; + m_DK[2] = A2; + m_DK[3] = A3; theta(A0, A1, A2, A3); - EK.resize(4); - EK[0] = A0; - EK[1] = A1; - EK[2] = A2; - EK[3] = A3; + m_EK.resize(4); + m_EK[0] = A0; + m_EK[1] = A1; + m_EK[2] = A2; + m_EK[3] = A3; } /* @@ -204,8 +204,8 @@ void Noekeon::key_schedule(const byte key[], size_t) */ void Noekeon::clear() { - zap(EK); - zap(DK); + zap(m_EK); + zap(m_DK); } } diff --git a/src/lib/block/noekeon/noekeon.h b/src/lib/block/noekeon/noekeon.h index 7b5b6d11b..4a3b9de0c 100644 --- a/src/lib/block/noekeon/noekeon.h +++ b/src/lib/block/noekeon/noekeon.h @@ -33,16 +33,16 @@ class BOTAN_DLL Noekeon : public Block_Cipher_Fixed_Params<16, 16> /** * @return const reference to encryption subkeys */ - const secure_vector<u32bit>& get_EK() const { return EK; } + const secure_vector<u32bit>& get_EK() const { return m_EK; } /** * @return const reference to decryption subkeys */ - const secure_vector<u32bit>& get_DK() const { return DK; } + const secure_vector<u32bit>& get_DK() const { return m_DK; } private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK, DK; + secure_vector<u32bit> m_EK, m_DK; }; } diff --git a/src/lib/block/rc2/rc2.cpp b/src/lib/block/rc2/rc2.cpp index bcd8475e3..112c6561d 100644 --- a/src/lib/block/rc2/rc2.cpp +++ b/src/lib/block/rc2/rc2.cpp @@ -24,24 +24,24 @@ void RC2::encrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 16; ++j) { - R0 += (R1 & ~R3) + (R2 & R3) + K[4*j]; + R0 += (R1 & ~R3) + (R2 & R3) + m_K[4*j]; R0 = rotate_left(R0, 1); - R1 += (R2 & ~R0) + (R3 & R0) + K[4*j + 1]; + R1 += (R2 & ~R0) + (R3 & R0) + m_K[4*j + 1]; R1 = rotate_left(R1, 2); - R2 += (R3 & ~R1) + (R0 & R1) + K[4*j + 2]; + R2 += (R3 & ~R1) + (R0 & R1) + m_K[4*j + 2]; R2 = rotate_left(R2, 3); - R3 += (R0 & ~R2) + (R1 & R2) + K[4*j + 3]; + R3 += (R0 & ~R2) + (R1 & R2) + m_K[4*j + 3]; R3 = rotate_left(R3, 5); if(j == 4 || j == 10) { - R0 += K[R3 % 64]; - R1 += K[R0 % 64]; - R2 += K[R1 % 64]; - R3 += K[R2 % 64]; + R0 += m_K[R3 % 64]; + R1 += m_K[R0 % 64]; + R2 += m_K[R1 % 64]; + R3 += m_K[R2 % 64]; } } @@ -67,23 +67,23 @@ void RC2::decrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 16; ++j) { R3 = rotate_right(R3, 5); - R3 -= (R0 & ~R2) + (R1 & R2) + K[63 - (4*j + 0)]; + R3 -= (R0 & ~R2) + (R1 & R2) + m_K[63 - (4*j + 0)]; R2 = rotate_right(R2, 3); - R2 -= (R3 & ~R1) + (R0 & R1) + K[63 - (4*j + 1)]; + R2 -= (R3 & ~R1) + (R0 & R1) + m_K[63 - (4*j + 1)]; R1 = rotate_right(R1, 2); - R1 -= (R2 & ~R0) + (R3 & R0) + K[63 - (4*j + 2)]; + R1 -= (R2 & ~R0) + (R3 & R0) + m_K[63 - (4*j + 2)]; R0 = rotate_right(R0, 1); - R0 -= (R1 & ~R3) + (R2 & R3) + K[63 - (4*j + 3)]; + R0 -= (R1 & ~R3) + (R2 & R3) + m_K[63 - (4*j + 3)]; if(j == 4 || j == 10) { - R3 -= K[R2 % 64]; - R2 -= K[R1 % 64]; - R1 -= K[R0 % 64]; - R0 -= K[R3 % 64]; + R3 -= m_K[R2 % 64]; + R2 -= m_K[R1 % 64]; + R1 -= m_K[R0 % 64]; + R0 -= m_K[R3 % 64]; } } @@ -134,13 +134,13 @@ void RC2::key_schedule(const byte key[], size_t length) for(s32bit i = 127-length; i >= 0; --i) L[i] = TABLE[L[i+1] ^ L[i+length]]; - K.resize(64); - load_le<u16bit>(K.data(), L.data(), 64); + m_K.resize(64); + load_le<u16bit>(m_K.data(), L.data(), 64); } void RC2::clear() { - zap(K); + zap(m_K); } /* diff --git a/src/lib/block/rc2/rc2.h b/src/lib/block/rc2/rc2.h index 11956f408..76391791a 100644 --- a/src/lib/block/rc2/rc2.h +++ b/src/lib/block/rc2/rc2.h @@ -34,7 +34,7 @@ class BOTAN_DLL RC2 : public Block_Cipher_Fixed_Params<8, 1, 32> private: void key_schedule(const byte[], size_t) override; - secure_vector<u16bit> K; + secure_vector<u16bit> m_K; }; } diff --git a/src/lib/block/rc5/rc5.cpp b/src/lib/block/rc5/rc5.cpp index a32efd775..a02a45e9f 100644 --- a/src/lib/block/rc5/rc5.cpp +++ b/src/lib/block/rc5/rc5.cpp @@ -21,20 +21,20 @@ void RC5::encrypt_n(const byte in[], byte out[], size_t blocks) const u32bit A = load_le<u32bit>(in, 0); u32bit B = load_le<u32bit>(in, 1); - A += S[0]; B += S[1]; - for(size_t j = 0; j != rounds; j += 4) + A += m_S[0]; B += m_S[1]; + for(size_t j = 0; j != m_rounds; j += 4) { - A = rotate_left(A ^ B, B % 32) + S[2*j+2]; - B = rotate_left(B ^ A, A % 32) + S[2*j+3]; + A = rotate_left(A ^ B, B % 32) + m_S[2*j+2]; + B = rotate_left(B ^ A, A % 32) + m_S[2*j+3]; - A = rotate_left(A ^ B, B % 32) + S[2*j+4]; - B = rotate_left(B ^ A, A % 32) + S[2*j+5]; + A = rotate_left(A ^ B, B % 32) + m_S[2*j+4]; + B = rotate_left(B ^ A, A % 32) + m_S[2*j+5]; - A = rotate_left(A ^ B, B % 32) + S[2*j+6]; - B = rotate_left(B ^ A, A % 32) + S[2*j+7]; + A = rotate_left(A ^ B, B % 32) + m_S[2*j+6]; + B = rotate_left(B ^ A, A % 32) + m_S[2*j+7]; - A = rotate_left(A ^ B, B % 32) + S[2*j+8]; - B = rotate_left(B ^ A, A % 32) + S[2*j+9]; + A = rotate_left(A ^ B, B % 32) + m_S[2*j+8]; + B = rotate_left(B ^ A, A % 32) + m_S[2*j+9]; } store_le(out, A, B); @@ -54,21 +54,21 @@ void RC5::decrypt_n(const byte in[], byte out[], size_t blocks) const u32bit A = load_le<u32bit>(in, 0); u32bit B = load_le<u32bit>(in, 1); - for(size_t j = rounds; j != 0; j -= 4) + for(size_t j = m_rounds; j != 0; j -= 4) { - B = rotate_right(B - S[2*j+1], A % 32) ^ A; - A = rotate_right(A - S[2*j ], B % 32) ^ B; + B = rotate_right(B - m_S[2*j+1], A % 32) ^ A; + A = rotate_right(A - m_S[2*j ], B % 32) ^ B; - B = rotate_right(B - S[2*j-1], A % 32) ^ A; - A = rotate_right(A - S[2*j-2], B % 32) ^ B; + B = rotate_right(B - m_S[2*j-1], A % 32) ^ A; + A = rotate_right(A - m_S[2*j-2], B % 32) ^ B; - B = rotate_right(B - S[2*j-3], A % 32) ^ A; - A = rotate_right(A - S[2*j-4], B % 32) ^ B; + B = rotate_right(B - m_S[2*j-3], A % 32) ^ A; + A = rotate_right(A - m_S[2*j-4], B % 32) ^ B; - B = rotate_right(B - S[2*j-5], A % 32) ^ A; - A = rotate_right(A - S[2*j-6], B % 32) ^ B; + B = rotate_right(B - m_S[2*j-5], A % 32) ^ A; + A = rotate_right(A - m_S[2*j-6], B % 32) ^ B; } - B -= S[1]; A -= S[0]; + B -= m_S[1]; A -= m_S[0]; store_le(out, A, B); @@ -82,14 +82,14 @@ void RC5::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void RC5::key_schedule(const byte key[], size_t length) { - S.resize(2*rounds + 2); + m_S.resize(2*m_rounds + 2); const size_t WORD_KEYLENGTH = (((length - 1) / 4) + 1); - const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, S.size()); + const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, m_S.size()); - S[0] = 0xB7E15163; - for(size_t i = 1; i != S.size(); ++i) - S[i] = S[i-1] + 0x9E3779B9; + m_S[0] = 0xB7E15163; + for(size_t i = 1; i != m_S.size(); ++i) + m_S[i] = m_S[i-1] + 0x9E3779B9; secure_vector<u32bit> K(8); @@ -100,16 +100,16 @@ void RC5::key_schedule(const byte key[], size_t length) for(size_t i = 0; i != MIX_ROUNDS; ++i) { - A = rotate_left(S[i % S.size()] + A + B, 3); + A = rotate_left(m_S[i % m_S.size()] + A + B, 3); B = rotate_left(K[i % WORD_KEYLENGTH] + A + B, (A + B) % 32); - S[i % S.size()] = A; + m_S[i % m_S.size()] = A; K[i % WORD_KEYLENGTH] = B; } } void RC5::clear() { - zap(S); + zap(m_S); } /* @@ -117,17 +117,17 @@ void RC5::clear() */ std::string RC5::name() const { - return "RC5(" + std::to_string(rounds) + ")"; + return "RC5(" + std::to_string(m_rounds) + ")"; } /* * RC5 Constructor */ -RC5::RC5(size_t r) : rounds(r) +RC5::RC5(size_t r) : m_rounds(r) { - if(rounds < 8 || rounds > 32 || (rounds % 4 != 0)) + if(m_rounds < 8 || m_rounds > 32 || (m_rounds % 4 != 0)) throw Invalid_Argument("RC5: Invalid number of rounds " + - std::to_string(rounds)); + std::to_string(m_rounds)); } } diff --git a/src/lib/block/rc5/rc5.h b/src/lib/block/rc5/rc5.h index b8ff1c3f7..cb76d51f1 100644 --- a/src/lib/block/rc5/rc5.h +++ b/src/lib/block/rc5/rc5.h @@ -23,7 +23,7 @@ class BOTAN_DLL RC5 : public Block_Cipher_Fixed_Params<8, 1, 32> void clear() override; std::string name() const override; - BlockCipher* clone() const override { return new RC5(rounds); } + BlockCipher* clone() const override { return new RC5(m_rounds); } /** * @param rounds the number of RC5 rounds to run. Must be between @@ -33,8 +33,8 @@ class BOTAN_DLL RC5 : public Block_Cipher_Fixed_Params<8, 1, 32> private: void key_schedule(const byte[], size_t) override; - size_t rounds; - secure_vector<u32bit> S; + size_t m_rounds; + secure_vector<u32bit> m_S; }; } diff --git a/src/lib/block/rc6/rc6.cpp b/src/lib/block/rc6/rc6.cpp index 48fb1c32e..426b86ebd 100644 --- a/src/lib/block/rc6/rc6.cpp +++ b/src/lib/block/rc6/rc6.cpp @@ -22,7 +22,7 @@ void RC6::encrypt_n(const byte in[], byte out[], size_t blocks) const u32bit C = load_le<u32bit>(in, 2); u32bit D = load_le<u32bit>(in, 3); - B += S[0]; D += S[1]; + B += m_S[0]; D += m_S[1]; for(size_t j = 0; j != 20; j += 4) { @@ -30,26 +30,26 @@ void RC6::encrypt_n(const byte in[], byte out[], size_t blocks) const T1 = rotate_left(B*(2*B+1), 5); T2 = rotate_left(D*(2*D+1), 5); - A = rotate_left(A ^ T1, T2 % 32) + S[2*j+2]; - C = rotate_left(C ^ T2, T1 % 32) + S[2*j+3]; + A = rotate_left(A ^ T1, T2 % 32) + m_S[2*j+2]; + C = rotate_left(C ^ T2, T1 % 32) + m_S[2*j+3]; T1 = rotate_left(C*(2*C+1), 5); T2 = rotate_left(A*(2*A+1), 5); - B = rotate_left(B ^ T1, T2 % 32) + S[2*j+4]; - D = rotate_left(D ^ T2, T1 % 32) + S[2*j+5]; + B = rotate_left(B ^ T1, T2 % 32) + m_S[2*j+4]; + D = rotate_left(D ^ T2, T1 % 32) + m_S[2*j+5]; T1 = rotate_left(D*(2*D+1), 5); T2 = rotate_left(B*(2*B+1), 5); - C = rotate_left(C ^ T1, T2 % 32) + S[2*j+6]; - A = rotate_left(A ^ T2, T1 % 32) + S[2*j+7]; + C = rotate_left(C ^ T1, T2 % 32) + m_S[2*j+6]; + A = rotate_left(A ^ T2, T1 % 32) + m_S[2*j+7]; T1 = rotate_left(A*(2*A+1), 5); T2 = rotate_left(C*(2*C+1), 5); - D = rotate_left(D ^ T1, T2 % 32) + S[2*j+8]; - B = rotate_left(B ^ T2, T1 % 32) + S[2*j+9]; + D = rotate_left(D ^ T1, T2 % 32) + m_S[2*j+8]; + B = rotate_left(B ^ T2, T1 % 32) + m_S[2*j+9]; } - A += S[42]; C += S[43]; + A += m_S[42]; C += m_S[43]; store_le(out, A, B, C, D); @@ -70,7 +70,7 @@ void RC6::decrypt_n(const byte in[], byte out[], size_t blocks) const u32bit C = load_le<u32bit>(in, 2); u32bit D = load_le<u32bit>(in, 3); - C -= S[43]; A -= S[42]; + C -= m_S[43]; A -= m_S[42]; for(size_t j = 0; j != 20; j += 4) { @@ -78,26 +78,26 @@ void RC6::decrypt_n(const byte in[], byte out[], size_t blocks) const T1 = rotate_left(A*(2*A+1), 5); T2 = rotate_left(C*(2*C+1), 5); - B = rotate_right(B - S[41 - 2*j], T1 % 32) ^ T2; - D = rotate_right(D - S[40 - 2*j], T2 % 32) ^ T1; + B = rotate_right(B - m_S[41 - 2*j], T1 % 32) ^ T2; + D = rotate_right(D - m_S[40 - 2*j], T2 % 32) ^ T1; T1 = rotate_left(D*(2*D+1), 5); T2 = rotate_left(B*(2*B+1), 5); - A = rotate_right(A - S[39 - 2*j], T1 % 32) ^ T2; - C = rotate_right(C - S[38 - 2*j], T2 % 32) ^ T1; + A = rotate_right(A - m_S[39 - 2*j], T1 % 32) ^ T2; + C = rotate_right(C - m_S[38 - 2*j], T2 % 32) ^ T1; T1 = rotate_left(C*(2*C+1), 5); T2 = rotate_left(A*(2*A+1), 5); - D = rotate_right(D - S[37 - 2*j], T1 % 32) ^ T2; - B = rotate_right(B - S[36 - 2*j], T2 % 32) ^ T1; + D = rotate_right(D - m_S[37 - 2*j], T1 % 32) ^ T2; + B = rotate_right(B - m_S[36 - 2*j], T2 % 32) ^ T1; T1 = rotate_left(B*(2*B+1), 5); T2 = rotate_left(D*(2*D+1), 5); - C = rotate_right(C - S[35 - 2*j], T1 % 32) ^ T2; - A = rotate_right(A - S[34 - 2*j], T2 % 32) ^ T1; + C = rotate_right(C - m_S[35 - 2*j], T1 % 32) ^ T2; + A = rotate_right(A - m_S[34 - 2*j], T2 % 32) ^ T1; } - D -= S[1]; B -= S[0]; + D -= m_S[1]; B -= m_S[0]; store_le(out, A, B, C, D); @@ -111,14 +111,14 @@ void RC6::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void RC6::key_schedule(const byte key[], size_t length) { - S.resize(44); + m_S.resize(44); const size_t WORD_KEYLENGTH = (((length - 1) / 4) + 1); - const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, S.size()); + const size_t MIX_ROUNDS = 3 * std::max(WORD_KEYLENGTH, m_S.size()); - S[0] = 0xB7E15163; - for(size_t i = 1; i != S.size(); ++i) - S[i] = S[i-1] + 0x9E3779B9; + m_S[0] = 0xB7E15163; + for(size_t i = 1; i != m_S.size(); ++i) + m_S[i] = m_S[i-1] + 0x9E3779B9; secure_vector<u32bit> K(8); @@ -128,16 +128,16 @@ void RC6::key_schedule(const byte key[], size_t length) u32bit A = 0, B = 0; for(size_t i = 0; i != MIX_ROUNDS; ++i) { - A = rotate_left(S[i % S.size()] + A + B, 3); + A = rotate_left(m_S[i % m_S.size()] + A + B, 3); B = rotate_left(K[i % WORD_KEYLENGTH] + A + B, (A + B) % 32); - S[i % S.size()] = A; + m_S[i % m_S.size()] = A; K[i % WORD_KEYLENGTH] = B; } } void RC6::clear() { - zap(S); + zap(m_S); } } diff --git a/src/lib/block/rc6/rc6.h b/src/lib/block/rc6/rc6.h index 1ff7304ed..a84d06a9b 100644 --- a/src/lib/block/rc6/rc6.h +++ b/src/lib/block/rc6/rc6.h @@ -27,7 +27,7 @@ class BOTAN_DLL RC6 : public Block_Cipher_Fixed_Params<16, 1, 32> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> S; + secure_vector<u32bit> m_S; }; } diff --git a/src/lib/block/safer/safer_sk.cpp b/src/lib/block/safer/safer_sk.cpp index a8781697d..8dec0b897 100644 --- a/src/lib/block/safer/safer_sk.cpp +++ b/src/lib/block/safer/safer_sk.cpp @@ -94,15 +94,15 @@ void SAFER_SK::encrypt_n(const byte in[], byte out[], size_t blocks) const byte A = in[0], B = in[1], C = in[2], D = in[3], E = in[4], F = in[5], G = in[6], H = in[7], X, Y; - for(size_t j = 0; j != 16*rounds; j += 16) + for(size_t j = 0; j != 16*m_rounds; j += 16) { - A = EXP[A ^ EK[j ]]; B = LOG[B + EK[j+1]]; - C = LOG[C + EK[j+2]]; D = EXP[D ^ EK[j+3]]; - E = EXP[E ^ EK[j+4]]; F = LOG[F + EK[j+5]]; - G = LOG[G + EK[j+6]]; H = EXP[H ^ EK[j+7]]; + A = EXP[A ^ m_EK[j ]]; B = LOG[B + m_EK[j+1]]; + C = LOG[C + m_EK[j+2]]; D = EXP[D ^ m_EK[j+3]]; + E = EXP[E ^ m_EK[j+4]]; F = LOG[F + m_EK[j+5]]; + G = LOG[G + m_EK[j+6]]; H = EXP[H ^ m_EK[j+7]]; - A += EK[j+ 8]; B ^= EK[j+ 9]; C ^= EK[j+10]; D += EK[j+11]; - E += EK[j+12]; F ^= EK[j+13]; G ^= EK[j+14]; H += EK[j+15]; + A += m_EK[j+ 8]; B ^= m_EK[j+ 9]; C ^= m_EK[j+10]; D += m_EK[j+11]; + E += m_EK[j+12]; F ^= m_EK[j+13]; G ^= m_EK[j+14]; H += m_EK[j+15]; B += A; D += C; F += E; H += G; A += B; C += D; E += F; G += H; C += A; G += E; D += B; H += F; A += C; E += G; B += D; F += H; @@ -110,10 +110,10 @@ void SAFER_SK::encrypt_n(const byte in[], byte out[], size_t blocks) const A += B; F = C + G; E = C + F; C = X; G = Y; } - out[0] = A ^ EK[16*rounds+0]; out[1] = B + EK[16*rounds+1]; - out[2] = C + EK[16*rounds+2]; out[3] = D ^ EK[16*rounds+3]; - out[4] = E ^ EK[16*rounds+4]; out[5] = F + EK[16*rounds+5]; - out[6] = G + EK[16*rounds+6]; out[7] = H ^ EK[16*rounds+7]; + out[0] = A ^ m_EK[16*m_rounds+0]; out[1] = B + m_EK[16*m_rounds+1]; + out[2] = C + m_EK[16*m_rounds+2]; out[3] = D ^ m_EK[16*m_rounds+3]; + out[4] = E ^ m_EK[16*m_rounds+4]; out[5] = F + m_EK[16*m_rounds+5]; + out[6] = G + m_EK[16*m_rounds+6]; out[7] = H ^ m_EK[16*m_rounds+7]; in += BLOCK_SIZE; out += BLOCK_SIZE; @@ -130,24 +130,24 @@ void SAFER_SK::decrypt_n(const byte in[], byte out[], size_t blocks) const byte A = in[0], B = in[1], C = in[2], D = in[3], E = in[4], F = in[5], G = in[6], H = in[7]; - A ^= EK[16*rounds+0]; B -= EK[16*rounds+1]; C -= EK[16*rounds+2]; - D ^= EK[16*rounds+3]; E ^= EK[16*rounds+4]; F -= EK[16*rounds+5]; - G -= EK[16*rounds+6]; H ^= EK[16*rounds+7]; + A ^= m_EK[16*m_rounds+0]; B -= m_EK[16*m_rounds+1]; C -= m_EK[16*m_rounds+2]; + D ^= m_EK[16*m_rounds+3]; E ^= m_EK[16*m_rounds+4]; F -= m_EK[16*m_rounds+5]; + G -= m_EK[16*m_rounds+6]; H ^= m_EK[16*m_rounds+7]; - for(s32bit j = 16*(rounds-1); j >= 0; j -= 16) + for(s32bit j = 16*(m_rounds-1); j >= 0; j -= 16) { byte T = E; E = B; B = C; C = T; T = F; F = D; D = G; G = T; A -= E; B -= F; C -= G; D -= H; E -= A; F -= B; G -= C; H -= D; A -= C; E -= G; B -= D; F -= H; C -= A; G -= E; D -= B; H -= F; A -= B; C -= D; E -= F; G -= H; B -= A; D -= C; F -= E; H -= G; - A = LOG[A - EK[j+8 ] + 256]; B = EXP[B ^ EK[j+9 ]]; - C = EXP[C ^ EK[j+10]]; D = LOG[D - EK[j+11] + 256]; - E = LOG[E - EK[j+12] + 256]; F = EXP[F ^ EK[j+13]]; - G = EXP[G ^ EK[j+14]]; H = LOG[H - EK[j+15] + 256]; + A = LOG[A - m_EK[j+8 ] + 256]; B = EXP[B ^ m_EK[j+9 ]]; + C = EXP[C ^ m_EK[j+10]]; D = LOG[D - m_EK[j+11] + 256]; + E = LOG[E - m_EK[j+12] + 256]; F = EXP[F ^ m_EK[j+13]]; + G = EXP[G ^ m_EK[j+14]]; H = LOG[H - m_EK[j+15] + 256]; - A ^= EK[j+0]; B -= EK[j+1]; C -= EK[j+2]; D ^= EK[j+3]; - E ^= EK[j+4]; F -= EK[j+5]; G -= EK[j+6]; H ^= EK[j+7]; + A ^= m_EK[j+0]; B -= m_EK[j+1]; C -= m_EK[j+2]; D ^= m_EK[j+3]; + E ^= m_EK[j+4]; F -= m_EK[j+5]; G -= m_EK[j+6]; H ^= m_EK[j+7]; } out[0] = A; out[1] = B; out[2] = C; out[3] = D; @@ -203,28 +203,28 @@ void SAFER_SK::key_schedule(const byte key[], size_t) 0x07, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - EK.resize(16 * rounds + 8); + m_EK.resize(16 * m_rounds + 8); secure_vector<byte> KB(18); for(size_t i = 0; i != 8; ++i) { KB[ 8] ^= KB[i] = rotate_left(key[i], 5); - KB[17] ^= KB[i+9] = EK[i] = key[i+8]; + KB[17] ^= KB[i+9] = m_EK[i] = key[i+8]; } - for(size_t i = 0; i != rounds; ++i) + for(size_t i = 0; i != m_rounds; ++i) { for(size_t j = 0; j != 18; ++j) KB[j] = rotate_left(KB[j], 6); for(size_t j = 0; j != 16; ++j) - EK[16*i+j+8] = KB[KEY_INDEX[16*i+j]] + BIAS[16*i+j]; + m_EK[16*i+j+8] = KB[KEY_INDEX[16*i+j]] + BIAS[16*i+j]; } } void SAFER_SK::clear() { - zap(EK); + zap(m_EK); } /* @@ -232,7 +232,7 @@ void SAFER_SK::clear() */ std::string SAFER_SK::name() const { - return "SAFER-SK(" + std::to_string(rounds) + ")"; + return "SAFER-SK(" + std::to_string(m_rounds) + ")"; } /* @@ -240,15 +240,15 @@ std::string SAFER_SK::name() const */ BlockCipher* SAFER_SK::clone() const { - return new SAFER_SK(rounds); + return new SAFER_SK(m_rounds); } /* * SAFER-SK Constructor */ -SAFER_SK::SAFER_SK(size_t r) : rounds(r) +SAFER_SK::SAFER_SK(size_t r) : m_rounds(r) { - if(rounds > 13 || rounds == 0) + if(m_rounds > 13 || m_rounds == 0) throw Invalid_Argument(name() + ": Invalid number of rounds"); } diff --git a/src/lib/block/safer/safer_sk.h b/src/lib/block/safer/safer_sk.h index 74241d4e6..2746963c4 100644 --- a/src/lib/block/safer/safer_sk.h +++ b/src/lib/block/safer/safer_sk.h @@ -33,8 +33,8 @@ class BOTAN_DLL SAFER_SK : public Block_Cipher_Fixed_Params<8, 16> private: void key_schedule(const byte[], size_t) override; - size_t rounds; - secure_vector<byte> EK; + size_t m_rounds; + secure_vector<byte> m_EK; }; } diff --git a/src/lib/block/seed/seed.cpp b/src/lib/block/seed/seed.cpp index 23e2a18c0..6e0aaa41f 100644 --- a/src/lib/block/seed/seed.cpp +++ b/src/lib/block/seed/seed.cpp @@ -219,15 +219,15 @@ void SEED::encrypt_n(const byte in[], byte out[], size_t blocks) const { u32bit T0, T1; - T0 = B2 ^ K[2*j]; - T1 = SEED_G(B2 ^ B3 ^ K[2*j+1]); + T0 = B2 ^ m_K[2*j]; + T1 = SEED_G(B2 ^ B3 ^ m_K[2*j+1]); T0 = SEED_G(T1 + T0); T1 = SEED_G(T1 + T0); B1 ^= T1; B0 ^= T0 + T1; - T0 = B0 ^ K[2*j+2]; - T1 = SEED_G(B0 ^ B1 ^ K[2*j+3]); + T0 = B0 ^ m_K[2*j+2]; + T1 = SEED_G(B0 ^ B1 ^ m_K[2*j+3]); T0 = SEED_G(T1 + T0); T1 = SEED_G(T1 + T0); B3 ^= T1; @@ -257,15 +257,15 @@ void SEED::decrypt_n(const byte in[], byte out[], size_t blocks) const { u32bit T0, T1; - T0 = B2 ^ K[30-2*j]; - T1 = SEED_G(B2 ^ B3 ^ K[31-2*j]); + T0 = B2 ^ m_K[30-2*j]; + T1 = SEED_G(B2 ^ B3 ^ m_K[31-2*j]); T0 = SEED_G(T1 + T0); T1 = SEED_G(T1 + T0); B1 ^= T1; B0 ^= T0 + T1; - T0 = B0 ^ K[28-2*j]; - T1 = SEED_G(B0 ^ B1 ^ K[29-2*j]); + T0 = B0 ^ m_K[28-2*j]; + T1 = SEED_G(B0 ^ B1 ^ m_K[29-2*j]); T0 = SEED_G(T1 + T0); T1 = SEED_G(T1 + T0); B3 ^= T1; @@ -296,19 +296,19 @@ void SEED::key_schedule(const byte key[], size_t) for(size_t i = 0; i != 4; ++i) WK[i] = load_be<u32bit>(key, i); - K.resize(32); + m_K.resize(32); for(size_t i = 0; i != 16; i += 2) { - K[2*i ] = SEED_G(WK[0] + WK[2] - RC[i]); - K[2*i+1] = SEED_G(WK[1] - WK[3] + RC[i]) ^ K[2*i]; + 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]); WK[0] = (WK[0] >> 8) | (get_byte(3, WK[1]) << 24); WK[1] = (WK[1] >> 8) | (T << 24); - K[2*i+2] = SEED_G(WK[0] + WK[2] - RC[i+1]); - K[2*i+3] = SEED_G(WK[1] - WK[3] + RC[i+1]) ^ K[2*i+2]; + m_K[2*i+2] = SEED_G(WK[0] + WK[2] - RC[i+1]); + m_K[2*i+3] = SEED_G(WK[1] - WK[3] + RC[i+1]) ^ m_K[2*i+2]; T = get_byte(0, WK[3]); WK[3] = (WK[3] << 8) | get_byte(0, WK[2]); @@ -318,7 +318,7 @@ void SEED::key_schedule(const byte key[], size_t) void SEED::clear() { - zap(K); + zap(m_K); } } diff --git a/src/lib/block/seed/seed.h b/src/lib/block/seed/seed.h index 299b0c398..66462e7d7 100644 --- a/src/lib/block/seed/seed.h +++ b/src/lib/block/seed/seed.h @@ -27,7 +27,7 @@ class BOTAN_DLL SEED : public Block_Cipher_Fixed_Params<16, 16> private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> K; + secure_vector<u32bit> m_K; }; } diff --git a/src/lib/block/serpent/serpent.cpp b/src/lib/block/serpent/serpent.cpp index c0a65ed33..c35e3e338 100644 --- a/src/lib/block/serpent/serpent.cpp +++ b/src/lib/block/serpent/serpent.cpp @@ -43,10 +43,10 @@ inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3) * XOR a key block with a data block */ #define key_xor(round, B0, B1, B2, B3) \ - B0 ^= round_key[4*round ]; \ - B1 ^= round_key[4*round+1]; \ - B2 ^= round_key[4*round+2]; \ - B3 ^= round_key[4*round+3]; + B0 ^= m_round_key[4*round ]; \ + B1 ^= m_round_key[4*round+1]; \ + B2 ^= m_round_key[4*round+2]; \ + B3 ^= m_round_key[4*round+3]; /* * Serpent Encryption @@ -193,12 +193,12 @@ void Serpent::key_schedule(const byte key[], size_t length) SBoxE6(W[128],W[129],W[130],W[131]); SBoxE5(W[132],W[133],W[134],W[135]); SBoxE4(W[136],W[137],W[138],W[139]); - round_key.assign(W.begin() + 8, W.end()); + m_round_key.assign(W.begin() + 8, W.end()); } void Serpent::clear() { - zap(round_key); + zap(m_round_key); } } diff --git a/src/lib/block/serpent/serpent.h b/src/lib/block/serpent/serpent.h index 7fdf4600d..b9864cf89 100644 --- a/src/lib/block/serpent/serpent.h +++ b/src/lib/block/serpent/serpent.h @@ -30,7 +30,7 @@ class BOTAN_DLL Serpent : public Block_Cipher_Fixed_Params<16, 16, 32, 8> * @return const reference to the key schedule */ const secure_vector<u32bit>& get_round_keys() const - { return round_key; } + { return m_round_key; } /** * For use by subclasses that implement the key schedule @@ -38,12 +38,12 @@ class BOTAN_DLL Serpent : public Block_Cipher_Fixed_Params<16, 16, 32, 8> */ void set_round_keys(const u32bit ks[132]) { - round_key.assign(&ks[0], &ks[132]); + m_round_key.assign(&ks[0], &ks[132]); } private: void key_schedule(const byte key[], size_t length) override; - secure_vector<u32bit> round_key; + secure_vector<u32bit> m_round_key; }; } diff --git a/src/lib/block/tea/tea.cpp b/src/lib/block/tea/tea.cpp index 01f342607..457171e1d 100644 --- a/src/lib/block/tea/tea.cpp +++ b/src/lib/block/tea/tea.cpp @@ -24,8 +24,8 @@ void TEA::encrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 32; ++j) { S += 0x9E3779B9; - L += ((R << 4) + K[0]) ^ (R + S) ^ ((R >> 5) + K[1]); - R += ((L << 4) + K[2]) ^ (L + S) ^ ((L >> 5) + K[3]); + L += ((R << 4) + m_K[0]) ^ (R + S) ^ ((R >> 5) + m_K[1]); + R += ((L << 4) + m_K[2]) ^ (L + S) ^ ((L >> 5) + m_K[3]); } store_be(out, L, R); @@ -48,8 +48,8 @@ void TEA::decrypt_n(const byte in[], byte out[], size_t blocks) const u32bit S = 0xC6EF3720; for(size_t j = 0; j != 32; ++j) { - R -= ((L << 4) + K[2]) ^ (L + S) ^ ((L >> 5) + K[3]); - L -= ((R << 4) + K[0]) ^ (R + S) ^ ((R >> 5) + K[1]); + R -= ((L << 4) + m_K[2]) ^ (L + S) ^ ((L >> 5) + m_K[3]); + L -= ((R << 4) + m_K[0]) ^ (R + S) ^ ((R >> 5) + m_K[1]); S -= 0x9E3779B9; } @@ -65,14 +65,14 @@ void TEA::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void TEA::key_schedule(const byte key[], size_t) { - K.resize(4); + m_K.resize(4); for(size_t i = 0; i != 4; ++i) - K[i] = load_be<u32bit>(key, i); + m_K[i] = load_be<u32bit>(key, i); } void TEA::clear() { - zap(K); + zap(m_K); } } diff --git a/src/lib/block/tea/tea.h b/src/lib/block/tea/tea.h index 3c5b4773e..fd2b5fe36 100644 --- a/src/lib/block/tea/tea.h +++ b/src/lib/block/tea/tea.h @@ -26,7 +26,7 @@ class BOTAN_DLL TEA : public Block_Cipher_Fixed_Params<8, 16> BlockCipher* clone() const override { return new TEA; } private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> K; + secure_vector<u32bit> m_K; }; } diff --git a/src/lib/block/twofish/twofish.cpp b/src/lib/block/twofish/twofish.cpp index ffdf4b198..336d73a03 100644 --- a/src/lib/block/twofish/twofish.cpp +++ b/src/lib/block/twofish/twofish.cpp @@ -21,42 +21,42 @@ void Twofish::encrypt_n(const byte in[], byte out[], size_t blocks) const { for(size_t i = 0; i != blocks; ++i) { - u32bit A = load_le<u32bit>(in, 0) ^ RK[0]; - u32bit B = load_le<u32bit>(in, 1) ^ RK[1]; - u32bit C = load_le<u32bit>(in, 2) ^ RK[2]; - u32bit D = load_le<u32bit>(in, 3) ^ RK[3]; + u32bit A = load_le<u32bit>(in, 0) ^ m_RK[0]; + u32bit B = load_le<u32bit>(in, 1) ^ m_RK[1]; + u32bit C = load_le<u32bit>(in, 2) ^ m_RK[2]; + u32bit D = load_le<u32bit>(in, 3) ^ m_RK[3]; for(size_t j = 0; j != 16; j += 2) { u32bit X, Y; - X = SB[ get_byte(3, A)] ^ SB[256+get_byte(2, A)] ^ - SB[512+get_byte(1, A)] ^ SB[768+get_byte(0, A)]; - Y = SB[ get_byte(0, B)] ^ SB[256+get_byte(3, B)] ^ - SB[512+get_byte(2, B)] ^ SB[768+get_byte(1, B)]; + 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)]; + Y = m_SB[ get_byte(0, B)] ^ m_SB[256+get_byte(3, B)] ^ + m_SB[512+get_byte(2, B)] ^ m_SB[768+get_byte(1, B)]; X += Y; - Y += X + RK[2*j + 9]; - X += RK[2*j + 8]; + Y += X + m_RK[2*j + 9]; + X += m_RK[2*j + 8]; C = rotate_right(C ^ X, 1); D = rotate_left(D, 1) ^ Y; - X = SB[ get_byte(3, C)] ^ SB[256+get_byte(2, C)] ^ - SB[512+get_byte(1, C)] ^ SB[768+get_byte(0, C)]; - Y = SB[ get_byte(0, D)] ^ SB[256+get_byte(3, D)] ^ - SB[512+get_byte(2, D)] ^ SB[768+get_byte(1, D)]; + X = m_SB[ get_byte(3, C)] ^ m_SB[256+get_byte(2, C)] ^ + m_SB[512+get_byte(1, C)] ^ m_SB[768+get_byte(0, C)]; + Y = m_SB[ get_byte(0, D)] ^ m_SB[256+get_byte(3, D)] ^ + m_SB[512+get_byte(2, D)] ^ m_SB[768+get_byte(1, D)]; X += Y; - Y += X + RK[2*j + 11]; - X += RK[2*j + 10]; + Y += X + m_RK[2*j + 11]; + X += m_RK[2*j + 10]; A = rotate_right(A ^ X, 1); B = rotate_left(B, 1) ^ Y; } - C ^= RK[4]; - D ^= RK[5]; - A ^= RK[6]; - B ^= RK[7]; + C ^= m_RK[4]; + D ^= m_RK[5]; + A ^= m_RK[6]; + B ^= m_RK[7]; store_le(out, C, D, A, B); @@ -72,42 +72,42 @@ void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const { for(size_t i = 0; i != blocks; ++i) { - u32bit A = load_le<u32bit>(in, 0) ^ RK[4]; - u32bit B = load_le<u32bit>(in, 1) ^ RK[5]; - u32bit C = load_le<u32bit>(in, 2) ^ RK[6]; - u32bit D = load_le<u32bit>(in, 3) ^ RK[7]; + u32bit A = load_le<u32bit>(in, 0) ^ m_RK[4]; + u32bit B = load_le<u32bit>(in, 1) ^ m_RK[5]; + u32bit C = load_le<u32bit>(in, 2) ^ m_RK[6]; + u32bit D = load_le<u32bit>(in, 3) ^ m_RK[7]; for(size_t j = 0; j != 16; j += 2) { u32bit X, Y; - X = SB[ get_byte(3, A)] ^ SB[256+get_byte(2, A)] ^ - SB[512+get_byte(1, A)] ^ SB[768+get_byte(0, A)]; - Y = SB[ get_byte(0, B)] ^ SB[256+get_byte(3, B)] ^ - SB[512+get_byte(2, B)] ^ SB[768+get_byte(1, B)]; + 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)]; + Y = m_SB[ get_byte(0, B)] ^ m_SB[256+get_byte(3, B)] ^ + m_SB[512+get_byte(2, B)] ^ m_SB[768+get_byte(1, B)]; X += Y; - Y += X + RK[39 - 2*j]; - X += RK[38 - 2*j]; + Y += X + m_RK[39 - 2*j]; + X += m_RK[38 - 2*j]; C = rotate_left(C, 1) ^ X; D = rotate_right(D ^ Y, 1); - X = SB[ get_byte(3, C)] ^ SB[256+get_byte(2, C)] ^ - SB[512+get_byte(1, C)] ^ SB[768+get_byte(0, C)]; - Y = SB[ get_byte(0, D)] ^ SB[256+get_byte(3, D)] ^ - SB[512+get_byte(2, D)] ^ SB[768+get_byte(1, D)]; + X = m_SB[ get_byte(3, C)] ^ m_SB[256+get_byte(2, C)] ^ + m_SB[512+get_byte(1, C)] ^ m_SB[768+get_byte(0, C)]; + Y = m_SB[ get_byte(0, D)] ^ m_SB[256+get_byte(3, D)] ^ + m_SB[512+get_byte(2, D)] ^ m_SB[768+get_byte(1, D)]; X += Y; - Y += X + RK[37 - 2*j]; - X += RK[36 - 2*j]; + Y += X + m_RK[37 - 2*j]; + X += m_RK[36 - 2*j]; A = rotate_left(A, 1) ^ X; B = rotate_right(B ^ Y, 1); } - C ^= RK[0]; - D ^= RK[1]; - A ^= RK[2]; - B ^= RK[3]; + C ^= m_RK[0]; + D ^= m_RK[1]; + A ^= m_RK[2]; + B ^= m_RK[3]; store_le(out, C, D, A, B); @@ -121,8 +121,8 @@ void Twofish::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void Twofish::key_schedule(const byte key[], size_t length) { - SB.resize(1024); - RK.resize(40); + m_SB.resize(1024); + m_RK.resize(40); secure_vector<byte> S(16); @@ -133,10 +133,10 @@ void Twofish::key_schedule(const byte key[], size_t length) { for(size_t i = 0; i != 256; ++i) { - SB[ i] = MDS0[Q0[Q0[i]^S[ 0]]^S[ 4]]; - SB[256+i] = MDS1[Q0[Q1[i]^S[ 1]]^S[ 5]]; - SB[512+i] = MDS2[Q1[Q0[i]^S[ 2]]^S[ 6]]; - SB[768+i] = MDS3[Q1[Q1[i]^S[ 3]]^S[ 7]]; + m_SB[ i] = MDS0[Q0[Q0[i]^S[ 0]]^S[ 4]]; + m_SB[256+i] = MDS1[Q0[Q1[i]^S[ 1]]^S[ 5]]; + m_SB[512+i] = MDS2[Q1[Q0[i]^S[ 2]]^S[ 6]]; + m_SB[768+i] = MDS3[Q1[Q1[i]^S[ 3]]^S[ 7]]; } for(size_t i = 0; i != 40; i += 2) @@ -152,18 +152,18 @@ void Twofish::key_schedule(const byte key[], size_t length) Y = rotate_left(Y, 8); X += Y; Y += X; - RK[i] = X; - RK[i+1] = rotate_left(Y, 9); + m_RK[i] = X; + m_RK[i+1] = rotate_left(Y, 9); } } else if(length == 24) { for(size_t i = 0; i != 256; ++i) { - SB[ i] = MDS0[Q0[Q0[Q1[i]^S[ 0]]^S[ 4]]^S[ 8]]; - SB[256+i] = MDS1[Q0[Q1[Q1[i]^S[ 1]]^S[ 5]]^S[ 9]]; - SB[512+i] = MDS2[Q1[Q0[Q0[i]^S[ 2]]^S[ 6]]^S[10]]; - SB[768+i] = MDS3[Q1[Q1[Q0[i]^S[ 3]]^S[ 7]]^S[11]]; + m_SB[ i] = MDS0[Q0[Q0[Q1[i]^S[ 0]]^S[ 4]]^S[ 8]]; + m_SB[256+i] = MDS1[Q0[Q1[Q1[i]^S[ 1]]^S[ 5]]^S[ 9]]; + m_SB[512+i] = MDS2[Q1[Q0[Q0[i]^S[ 2]]^S[ 6]]^S[10]]; + m_SB[768+i] = MDS3[Q1[Q1[Q0[i]^S[ 3]]^S[ 7]]^S[11]]; } for(size_t i = 0; i != 40; i += 2) @@ -179,18 +179,18 @@ void Twofish::key_schedule(const byte key[], size_t length) Y = rotate_left(Y, 8); X += Y; Y += X; - RK[i] = X; - RK[i+1] = rotate_left(Y, 9); + m_RK[i] = X; + m_RK[i+1] = rotate_left(Y, 9); } } else if(length == 32) { for(size_t i = 0; i != 256; ++i) { - SB[ i] = MDS0[Q0[Q0[Q1[Q1[i]^S[ 0]]^S[ 4]]^S[ 8]]^S[12]]; - SB[256+i] = MDS1[Q0[Q1[Q1[Q0[i]^S[ 1]]^S[ 5]]^S[ 9]]^S[13]]; - SB[512+i] = MDS2[Q1[Q0[Q0[Q0[i]^S[ 2]]^S[ 6]]^S[10]]^S[14]]; - SB[768+i] = MDS3[Q1[Q1[Q0[Q1[i]^S[ 3]]^S[ 7]]^S[11]]^S[15]]; + m_SB[ i] = MDS0[Q0[Q0[Q1[Q1[i]^S[ 0]]^S[ 4]]^S[ 8]]^S[12]]; + m_SB[256+i] = MDS1[Q0[Q1[Q1[Q0[i]^S[ 1]]^S[ 5]]^S[ 9]]^S[13]]; + m_SB[512+i] = MDS2[Q1[Q0[Q0[Q0[i]^S[ 2]]^S[ 6]]^S[10]]^S[14]]; + m_SB[768+i] = MDS3[Q1[Q1[Q0[Q1[i]^S[ 3]]^S[ 7]]^S[11]]^S[15]]; } for(size_t i = 0; i != 40; i += 2) @@ -206,8 +206,8 @@ void Twofish::key_schedule(const byte key[], size_t length) Y = rotate_left(Y, 8); X += Y; Y += X; - RK[i] = X; - RK[i+1] = rotate_left(Y, 9); + m_RK[i] = X; + m_RK[i+1] = rotate_left(Y, 9); } } } @@ -238,8 +238,8 @@ void Twofish::rs_mul(byte S[4], byte key, size_t offset) */ void Twofish::clear() { - zap(SB); - zap(RK); + zap(m_SB); + zap(m_RK); } } diff --git a/src/lib/block/twofish/twofish.h b/src/lib/block/twofish/twofish.h index c6af1a030..c3dd7fec0 100644 --- a/src/lib/block/twofish/twofish.h +++ b/src/lib/block/twofish/twofish.h @@ -39,7 +39,7 @@ class BOTAN_DLL Twofish : public Block_Cipher_Fixed_Params<16, 16, 32, 8> static const byte EXP_TO_POLY[255]; static const byte POLY_TO_EXP[255]; - secure_vector<u32bit> SB, RK; + secure_vector<u32bit> m_SB, m_RK; }; } diff --git a/src/lib/block/xtea/xtea.cpp b/src/lib/block/xtea/xtea.cpp index 59060dff7..333406d9b 100644 --- a/src/lib/block/xtea/xtea.cpp +++ b/src/lib/block/xtea/xtea.cpp @@ -63,7 +63,7 @@ void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const { while(blocks >= 4) { - xtea_encrypt_4(in, out, &(this->EK[0])); + xtea_encrypt_4(in, out, &(this->m_EK[0])); in += 4 * BLOCK_SIZE; out += 4 * BLOCK_SIZE; blocks -= 4; @@ -76,8 +76,8 @@ void XTEA::encrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 32; ++j) { - L += (((R << 4) ^ (R >> 5)) + R) ^ EK[2*j]; - R += (((L << 4) ^ (L >> 5)) + L) ^ EK[2*j+1]; + L += (((R << 4) ^ (R >> 5)) + R) ^ m_EK[2*j]; + R += (((L << 4) ^ (L >> 5)) + L) ^ m_EK[2*j+1]; } store_be(out, L, R); @@ -94,7 +94,7 @@ void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const { while(blocks >= 4) { - xtea_decrypt_4(in, out, &(this->EK[0])); + xtea_decrypt_4(in, out, &(this->m_EK[0])); in += 4 * BLOCK_SIZE; out += 4 * BLOCK_SIZE; blocks -= 4; @@ -107,8 +107,8 @@ void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const for(size_t j = 0; j != 32; ++j) { - R -= (((L << 4) ^ (L >> 5)) + L) ^ EK[63 - 2*j]; - L -= (((R << 4) ^ (R >> 5)) + R) ^ EK[62 - 2*j]; + R -= (((L << 4) ^ (L >> 5)) + L) ^ m_EK[63 - 2*j]; + L -= (((R << 4) ^ (R >> 5)) + R) ^ m_EK[62 - 2*j]; } store_be(out, L, R); @@ -123,7 +123,7 @@ void XTEA::decrypt_n(const byte in[], byte out[], size_t blocks) const */ void XTEA::key_schedule(const byte key[], size_t) { - EK.resize(64); + m_EK.resize(64); secure_vector<u32bit> UK(4); for(size_t i = 0; i != 4; ++i) @@ -132,15 +132,15 @@ void XTEA::key_schedule(const byte key[], size_t) u32bit D = 0; for(size_t i = 0; i != 64; i += 2) { - EK[i ] = D + UK[D % 4]; + m_EK[i ] = D + UK[D % 4]; D += 0x9E3779B9; - EK[i+1] = D + UK[(D >> 11) % 4]; + m_EK[i+1] = D + UK[(D >> 11) % 4]; } } void XTEA::clear() { - zap(EK); + zap(m_EK); } } diff --git a/src/lib/block/xtea/xtea.h b/src/lib/block/xtea/xtea.h index ea5c39418..3baccc866 100644 --- a/src/lib/block/xtea/xtea.h +++ b/src/lib/block/xtea/xtea.h @@ -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 EK; } + const secure_vector<u32bit>& get_EK() const { return m_EK; } private: void key_schedule(const byte[], size_t) override; - secure_vector<u32bit> EK; + secure_vector<u32bit> m_EK; }; } |