aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/serpent
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/block/serpent')
-rw-r--r--src/lib/block/serpent/serpent.cpp24
-rw-r--r--src/lib/block/serpent/serpent.h16
-rw-r--r--src/lib/block/serpent/serpent_simd/serpent_simd.cpp4
3 files changed, 22 insertions, 22 deletions
diff --git a/src/lib/block/serpent/serpent.cpp b/src/lib/block/serpent/serpent.cpp
index a1326b888..93af81231 100644
--- a/src/lib/block/serpent/serpent.cpp
+++ b/src/lib/block/serpent/serpent.cpp
@@ -20,7 +20,7 @@ namespace {
/*
* Serpent's Linear Transform
*/
-inline void transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
+inline void transform(uint32_t& B0, uint32_t& B1, uint32_t& B2, uint32_t& B3)
{
B0 = rotate_left(B0, 13); B2 = rotate_left(B2, 3);
B1 ^= B0 ^ B2; B3 ^= B2 ^ (B0 << 3);
@@ -32,7 +32,7 @@ inline void transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
/*
* Serpent's Inverse Linear Transform
*/
-inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
+inline void i_transform(uint32_t& B0, uint32_t& B1, uint32_t& B2, uint32_t& B3)
{
B2 = rotate_right(B2, 22); B0 = rotate_right(B0, 5);
B2 ^= B3 ^ (B1 << 7); B0 ^= B1 ^ B3;
@@ -55,7 +55,7 @@ inline void i_transform(u32bit& B0, u32bit& B1, u32bit& B2, u32bit& B3)
/*
* Serpent Encryption
*/
-void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
+void Serpent::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_SERPENT_SIMD)
if(CPUID::has_simd_32())
@@ -72,7 +72,7 @@ void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_SIMD_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit B0, B1, B2, B3;
+ uint32_t B0, B1, B2, B3;
load_le(in + 16*i, B0, B1, B2, B3);
key_xor( 0,B0,B1,B2,B3); SBoxE1(B0,B1,B2,B3); transform(B0,B1,B2,B3);
@@ -115,7 +115,7 @@ void Serpent::encrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Serpent Decryption
*/
-void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
+void Serpent::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const
{
#if defined(BOTAN_HAS_SERPENT_SIMD)
if(CPUID::has_simd_32())
@@ -132,7 +132,7 @@ void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
BOTAN_PARALLEL_SIMD_FOR(size_t i = 0; i < blocks; ++i)
{
- u32bit B0, B1, B2, B3;
+ uint32_t B0, B1, B2, B3;
load_le(in + 16*i, B0, B1, B2, B3);
key_xor(32,B0,B1,B2,B3); SBoxD8(B0,B1,B2,B3); key_xor(31,B0,B1,B2,B3);
@@ -179,19 +179,19 @@ void Serpent::decrypt_n(const byte in[], byte out[], size_t blocks) const
/*
* Serpent Key Schedule
*/
-void Serpent::key_schedule(const byte key[], size_t length)
+void Serpent::key_schedule(const uint8_t key[], size_t length)
{
- const u32bit PHI = 0x9E3779B9;
+ const uint32_t PHI = 0x9E3779B9;
- secure_vector<u32bit> W(140);
+ secure_vector<uint32_t> W(140);
for(size_t i = 0; i != length / 4; ++i)
- W[i] = load_le<u32bit>(key, i);
+ W[i] = load_le<uint32_t>(key, i);
- W[length / 4] |= u32bit(1) << ((length%4)*8);
+ W[length / 4] |= uint32_t(1) << ((length%4)*8);
for(size_t i = 8; i != 140; ++i)
{
- u32bit wi = W[i-8] ^ W[i-5] ^ W[i-3] ^ W[i-1] ^ PHI ^ u32bit(i-8);
+ uint32_t wi = W[i-8] ^ W[i-5] ^ W[i-3] ^ W[i-1] ^ PHI ^ uint32_t(i-8);
W[i] = rotate_left(wi, 11);
}
diff --git a/src/lib/block/serpent/serpent.h b/src/lib/block/serpent/serpent.h
index 218772e0c..4ba385fde 100644
--- a/src/lib/block/serpent/serpent.h
+++ b/src/lib/block/serpent/serpent.h
@@ -19,8 +19,8 @@ namespace Botan {
class BOTAN_DLL Serpent final : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
{
public:
- void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
- void decrypt_n(const byte in[], byte out[], size_t blocks) const override;
+ void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
+ void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
void clear() override;
std::string provider() const override;
@@ -34,33 +34,33 @@ class BOTAN_DLL Serpent final : public Block_Cipher_Fixed_Params<16, 16, 32, 8>
/**
* Encrypt 4 blocks in parallel using SSE2 or AltiVec
*/
- void simd_encrypt_4(const byte in[64], byte out[64]) const;
+ void simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const;
/**
* Decrypt 4 blocks in parallel using SSE2 or AltiVec
*/
- void simd_decrypt_4(const byte in[64], byte out[64]) const;
+ void simd_decrypt_4(const uint8_t in[64], uint8_t out[64]) const;
#endif
/**
* For use by subclasses using SIMD, asm, etc
* @return const reference to the key schedule
*/
- const secure_vector<u32bit>& get_round_keys() const
+ const secure_vector<uint32_t>& get_round_keys() const
{ return m_round_key; }
/**
* For use by subclasses that implement the key schedule
* @param ks is the new key schedule value to set
*/
- void set_round_keys(const u32bit ks[132])
+ void set_round_keys(const uint32_t ks[132])
{
m_round_key.assign(&ks[0], &ks[132]);
}
private:
- void key_schedule(const byte key[], size_t length) override;
- secure_vector<u32bit> m_round_key;
+ void key_schedule(const uint8_t key[], size_t length) override;
+ secure_vector<uint32_t> m_round_key;
};
}
diff --git a/src/lib/block/serpent/serpent_simd/serpent_simd.cpp b/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
index 7571e5511..f69d1f6f5 100644
--- a/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
+++ b/src/lib/block/serpent/serpent_simd/serpent_simd.cpp
@@ -57,7 +57,7 @@ namespace {
/*
* SIMD Serpent Encryption of 4 blocks in parallel
*/
-void Serpent::simd_encrypt_4(const byte in[64], byte out[64]) const
+void Serpent::simd_encrypt_4(const uint8_t in[64], uint8_t out[64]) const
{
SIMD_32 B0 = SIMD_32::load_le(in);
SIMD_32 B1 = SIMD_32::load_le(in + 16);
@@ -113,7 +113,7 @@ void Serpent::simd_encrypt_4(const byte in[64], byte out[64]) const
/*
* SIMD Serpent Decryption of 4 blocks in parallel
*/
-void Serpent::simd_decrypt_4(const byte in[64], byte out[64]) const
+void Serpent::simd_decrypt_4(const uint8_t in[64], uint8_t out[64]) const
{
SIMD_32 B0 = SIMD_32::load_le(in);
SIMD_32 B1 = SIMD_32::load_le(in + 16);