Skip to content

Commit

Permalink
[C++17] Use ::byte instead of byte.
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain-Geissler-1A committed Jun 18, 2017
1 parent 80c4033 commit 6b60c46
Show file tree
Hide file tree
Showing 218 changed files with 2,301 additions and 2,301 deletions.
6 changes: 3 additions & 3 deletions 3way.cpp
Expand Up @@ -65,7 +65,7 @@ static inline word32 reverseBits(word32 a)
pi_gamma_pi(a0, a1, a2); \
}

void ThreeWay::Base::UncheckedSetKey(const byte *uk, unsigned int length, const NameValuePairs &params)
void ThreeWay::Base::UncheckedSetKey(const ::byte *uk, unsigned int length, const NameValuePairs &params)
{
AssertValidKeyLength(length);

Expand All @@ -84,7 +84,7 @@ void ThreeWay::Base::UncheckedSetKey(const byte *uk, unsigned int length, const
}
}

void ThreeWay::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
void ThreeWay::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const
{
typedef BlockGetAndPut<word32, BigEndian> Block;

Expand All @@ -111,7 +111,7 @@ void ThreeWay::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock
Block::Put(xorBlock, outBlock)(a0)(a1)(a2);
}

void ThreeWay::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
void ThreeWay::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const
{
typedef BlockGetAndPut<word32, LittleEndian> Block;

Expand Down
6 changes: 3 additions & 3 deletions 3way.h
Expand Up @@ -30,7 +30,7 @@ class ThreeWay : public ThreeWay_Info, public BlockCipherDocumentation
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<ThreeWay_Info>
{
public:
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs &params);

protected:
unsigned int m_rounds;
Expand All @@ -43,7 +43,7 @@ class ThreeWay : public ThreeWay_Info, public BlockCipherDocumentation
class CRYPTOPP_NO_VTABLE Enc : public Base
{
public:
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const;
};

//! \class Dec
Expand All @@ -52,7 +52,7 @@ class ThreeWay : public ThreeWay_Info, public BlockCipherDocumentation
class CRYPTOPP_NO_VTABLE Dec : public Base
{
public:
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const;
};

public:
Expand Down
12 changes: 6 additions & 6 deletions adler32.cpp
Expand Up @@ -5,7 +5,7 @@

NAMESPACE_BEGIN(CryptoPP)

void Adler32::Update(const byte *input, size_t length)
void Adler32::Update(const ::byte *input, size_t length)
{
const unsigned long BASE = 65521;

Expand Down Expand Up @@ -53,23 +53,23 @@ void Adler32::Update(const byte *input, size_t length)
m_s2 = (word16)s2;
}

void Adler32::TruncatedFinal(byte *hash, size_t size)
void Adler32::TruncatedFinal(::byte *hash, size_t size)
{
ThrowIfInvalidTruncatedSize(size);

switch (size)
{
default:
hash[3] = byte(m_s1);
hash[3] = ::byte(m_s1);
// fall through
case 3:
hash[2] = byte(m_s1 >> 8);
hash[2] = ::byte(m_s1 >> 8);
// fall through
case 2:
hash[1] = byte(m_s2);
hash[1] = ::byte(m_s2);
// fall through
case 1:
hash[0] = byte(m_s2 >> 8);
hash[0] = ::byte(m_s2 >> 8);
// fall through
case 0:
;;
Expand Down
4 changes: 2 additions & 2 deletions adler32.h
Expand Up @@ -17,8 +17,8 @@ class Adler32 : public HashTransformation
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = 4)
Adler32() {Reset();}
void Update(const byte *input, size_t length);
void TruncatedFinal(byte *hash, size_t size);
void Update(const ::byte *input, size_t length);
void TruncatedFinal(::byte *hash, size_t size);
unsigned int DigestSize() const {return DIGESTSIZE;}
CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Adler32";}
std::string AlgorithmName() const {return StaticAlgorithmName();}
Expand Down
22 changes: 11 additions & 11 deletions algparam.h
Expand Up @@ -39,7 +39,7 @@ class ConstByteArrayParameter
ConstByteArrayParameter(const char *data = NULLPTR, bool deepCopy = false)
: m_deepCopy(false), m_data(NULLPTR), m_size(0)
{
Assign((const byte *)data, data ? strlen(data) : 0, deepCopy);
Assign((const ::byte *)data, data ? strlen(data) : 0, deepCopy);
}

//! \brief Construct a ConstByteArrayParameter
Expand All @@ -48,7 +48,7 @@ class ConstByteArrayParameter
//! \param deepCopy flag indicating whether the data should be copied
//! \details The deepCopy option is used when the NameValuePairs object can't
//! keep a copy of the data available
ConstByteArrayParameter(const byte *data, size_t size, bool deepCopy = false)
ConstByteArrayParameter(const ::byte *data, size_t size, bool deepCopy = false)
: m_deepCopy(false), m_data(NULLPTR), m_size(0)
{
Assign(data, size, deepCopy);
Expand All @@ -64,7 +64,7 @@ class ConstByteArrayParameter
: m_deepCopy(false), m_data(NULLPTR), m_size(0)
{
CRYPTOPP_COMPILE_ASSERT(sizeof(typename T::value_type) == 1);
Assign((const byte *)string.data(), string.size(), deepCopy);
Assign((const ::byte *)string.data(), string.size(), deepCopy);
}

//! \brief Assign contents from a memory buffer
Expand All @@ -73,7 +73,7 @@ class ConstByteArrayParameter
//! \param deepCopy flag indicating whether the data should be copied
//! \details The deepCopy option is used when the NameValuePairs object can't
//! keep a copy of the data available
void Assign(const byte *data, size_t size, bool deepCopy)
void Assign(const ::byte *data, size_t size, bool deepCopy)
{
// This fires, which means: no data with a size, or data with no size.
// CRYPTOPP_ASSERT((data && size) || !(data || size));
Expand All @@ -88,15 +88,15 @@ class ConstByteArrayParameter
}

//! \brief Pointer to the first byte in the memory block
const byte *begin() const {return m_deepCopy ? m_block.begin() : m_data;}
const ::byte *begin() const {return m_deepCopy ? m_block.begin() : m_data;}
//! \brief Pointer beyond the last byte in the memory block
const byte *end() const {return m_deepCopy ? m_block.end() : m_data + m_size;}
const ::byte *end() const {return m_deepCopy ? m_block.end() : m_data + m_size;}
//! \brief Length of the memory block
size_t size() const {return m_deepCopy ? m_block.size() : m_size;}

private:
bool m_deepCopy;
const byte *m_data;
const ::byte *m_data;
size_t m_size;
SecByteBlock m_block;
};
Expand All @@ -109,7 +109,7 @@ class ByteArrayParameter
//! \brief Construct a ByteArrayParameter
//! \param data a memory buffer
//! \param size the length of the memory buffer
ByteArrayParameter(byte *data = NULLPTR, unsigned int size = 0)
ByteArrayParameter(::byte *data = NULLPTR, unsigned int size = 0)
: m_data(data), m_size(size) {}

//! \brief Construct a ByteArrayParameter
Expand All @@ -118,14 +118,14 @@ class ByteArrayParameter
: m_data(block.begin()), m_size(block.size()) {}

//! \brief Pointer to the first byte in the memory block
byte *begin() const {return m_data;}
::byte *begin() const {return m_data;}
//! \brief Pointer beyond the last byte in the memory block
byte *end() const {return m_data + m_size;}
::byte *end() const {return m_data + m_size;}
//! \brief Length of the memory block
size_t size() const {return m_size;}

private:
byte *m_data;
::byte *m_data;
size_t m_size;
};

Expand Down
36 changes: 18 additions & 18 deletions arc4.cpp
Expand Up @@ -25,7 +25,7 @@ ARC4_Base::~ARC4_Base()
m_x = m_y = 0;
}

void ARC4_Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const NameValuePairs &params)
void ARC4_Base::UncheckedSetKey(const ::byte *key, unsigned int keyLen, const NameValuePairs &params)
{
AssertValidKeyLength(keyLen);

Expand All @@ -34,7 +34,7 @@ void ARC4_Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Name

unsigned int i;
for (i=0; i<256; i++)
m_state[i] = byte(i);
m_state[i] = ::byte(i);

unsigned int keyIndex = 0, stateIndex = 0;
for (i=0; i<256; i++)
Expand All @@ -43,7 +43,7 @@ void ARC4_Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Name
stateIndex += key[keyIndex] + a;
stateIndex &= 0xff;
m_state[i] = m_state[stateIndex];
m_state[stateIndex] = byte(a);
m_state[stateIndex] = ::byte(a);
if (++keyIndex >= keyLen)
keyIndex = 0;
}
Expand All @@ -53,29 +53,29 @@ void ARC4_Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Name
}

template <class T>
static inline unsigned int MakeByte(T &x, T &y, byte *s)
static inline unsigned int MakeByte(T &x, T &y, ::byte *s)
{
unsigned int a = s[x];
y = byte((y+a) & 0xff);
y = ::byte((y+a) & 0xff);
unsigned int b = s[y];
s[x] = byte(b);
s[y] = byte(a);
x = byte((x+1) & 0xff);
s[x] = ::byte(b);
s[y] = ::byte(a);
x = ::byte((x+1) & 0xff);
return s[(a+b) & 0xff];
}

void ARC4_Base::GenerateBlock(byte *output, size_t size)
void ARC4_Base::GenerateBlock(::byte *output, size_t size)
{
while (size--)
*output++ = static_cast<byte>(MakeByte(m_x, m_y, m_state));
*output++ = static_cast<::byte>(MakeByte(m_x, m_y, m_state));
}

void ARC4_Base::ProcessData(byte *outString, const byte *inString, size_t length)
void ARC4_Base::ProcessData(::byte *outString, const ::byte *inString, size_t length)
{
if (length == 0)
return;

byte *const s = m_state;
::byte *const s = m_state;
unsigned int x = m_x;
unsigned int y = m_y;

Expand All @@ -90,21 +90,21 @@ void ARC4_Base::ProcessData(byte *outString, const byte *inString, size_t length
{
do
{
*outString++ = *inString++ ^ byte(MakeByte(x, y, s));
*outString++ = *inString++ ^ ::byte(MakeByte(x, y, s));
}
while(--length);
}

m_x = byte(x);
m_y = byte(y);
m_x = ::byte(x);
m_y = ::byte(y);
}

void ARC4_Base::DiscardBytes(size_t length)
{
if (length == 0)
return;

byte *const s = m_state;
::byte *const s = m_state;
unsigned int x = m_x;
unsigned int y = m_y;

Expand All @@ -114,8 +114,8 @@ void ARC4_Base::DiscardBytes(size_t length)
}
while(--length);

m_x = byte(x);
m_y = byte(y);
m_x = ::byte(x);
m_y = ::byte(y);
}

}
Expand Down
10 changes: 5 additions & 5 deletions arc4.h
Expand Up @@ -26,10 +26,10 @@ class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, publi

CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "ARC4";}

void GenerateBlock(byte *output, size_t size);
void GenerateBlock(::byte *output, size_t size);
void DiscardBytes(size_t n);

void ProcessData(byte *outString, const byte *inString, size_t length);
void ProcessData(::byte *outString, const ::byte *inString, size_t length);

bool IsRandomAccess() const {return false;}
bool IsSelfInverting() const {return true;}
Expand All @@ -39,11 +39,11 @@ class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, publi
typedef SymmetricCipherFinal<ARC4_Base> Decryption;

protected:
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs &params);
virtual unsigned int GetDefaultDiscardBytes() const {return 0;}

FixedSizeSecBlock<byte, 256> m_state;
byte m_x, m_y;
FixedSizeSecBlock<::byte, 256> m_state;
::byte m_x, m_y;
};

//! \class ARC4
Expand Down

0 comments on commit 6b60c46

Please sign in to comment.