diff --git a/3way.cpp b/3way.cpp index 60bd0e13..5ea95ef2 100644 --- a/3way.cpp +++ b/3way.cpp @@ -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 ¶ms) +void ThreeWay::Base::UncheckedSetKey(const ::byte *uk, unsigned int length, const NameValuePairs ¶ms) { AssertValidKeyLength(length); @@ -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 Block; @@ -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 Block; diff --git a/3way.h b/3way.h index bafc02f9..a8d03a08 100644 --- a/3way.h +++ b/3way.h @@ -30,7 +30,7 @@ class ThreeWay : public ThreeWay_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); protected: unsigned int m_rounds; @@ -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 @@ -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: diff --git a/adler32.cpp b/adler32.cpp index 75c2e659..d80fdc3d 100644 --- a/adler32.cpp +++ b/adler32.cpp @@ -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; @@ -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: ;; diff --git a/adler32.h b/adler32.h index 3c62748b..31e23711 100644 --- a/adler32.h +++ b/adler32.h @@ -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();} diff --git a/algparam.h b/algparam.h index 95399615..a1157044 100644 --- a/algparam.h +++ b/algparam.h @@ -39,7 +39,7 @@ public: 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 @@ -48,7 +48,7 @@ public: //! \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); @@ -64,7 +64,7 @@ public: : 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 @@ -73,7 +73,7 @@ public: //! \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)); @@ -88,15 +88,15 @@ public: } //! \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; }; @@ -109,7 +109,7 @@ public: //! \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 @@ -118,14 +118,14 @@ public: : 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; }; diff --git a/arc4.cpp b/arc4.cpp index 7046b727..cb0d1477 100644 --- a/arc4.cpp +++ b/arc4.cpp @@ -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 ¶ms) +void ARC4_Base::UncheckedSetKey(const ::byte *key, unsigned int keyLen, const NameValuePairs ¶ms) { AssertValidKeyLength(keyLen); @@ -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++) @@ -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; } @@ -53,29 +53,29 @@ void ARC4_Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Name } template -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(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; @@ -90,13 +90,13 @@ 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) @@ -104,7 +104,7 @@ 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; @@ -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); } } diff --git a/arc4.h b/arc4.h index e7fdfc2e..7a382098 100644 --- a/arc4.h +++ b/arc4.h @@ -26,10 +26,10 @@ public: 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;} @@ -39,11 +39,11 @@ public: typedef SymmetricCipherFinal Decryption; protected: - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); virtual unsigned int GetDefaultDiscardBytes() const {return 0;} - FixedSizeSecBlock m_state; - byte m_x, m_y; + FixedSizeSecBlock< ::byte, 256> m_state; + ::byte m_x, m_y; }; //! \class ARC4 diff --git a/aria.cpp b/aria.cpp index bfa9ab07..e0029eaf 100644 --- a/aria.cpp +++ b/aria.cpp @@ -179,7 +179,7 @@ NAMESPACE_BEGIN(CryptoPP) typedef BlockGetAndPut BigEndianBlock; typedef BlockGetAndPut NativeEndianBlock; -inline byte ARIA_BRF(const word32 x, const int y) { +inline ::byte ARIA_BRF(const word32 x, const int y) { return GETBYTE(x, y); } @@ -224,7 +224,7 @@ inline byte ARIA_BRF(const word32 x, const int y) { // n-bit right shift of Y XORed to X template -inline void ARIA_GSRK(const word32 X[4], const word32 Y[4], byte RK[16]) +inline void ARIA_GSRK(const word32 X[4], const word32 Y[4], ::byte RK[16]) { // MSVC is not generating a "rotate immediate". Constify to help it along. static const unsigned int Q = 4-(N/32); @@ -250,12 +250,12 @@ inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16]) } #endif -void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs ¶ms) +void ARIA::Base::UncheckedSetKey(const ::byte *key, unsigned int keylen, const NameValuePairs ¶ms) { CRYPTOPP_UNUSED(params); - const byte *mk = key; - byte *rk = m_rk.data(); + const ::byte *mk = key; + ::byte *rk = m_rk.data(); int Q, q, R, r; switch (keylen) @@ -503,9 +503,9 @@ void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const Nam } } -void ARIA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void ARIA::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { - const byte *rk = reinterpret_cast(m_rk.data()); + const ::byte *rk = reinterpret_cast(m_rk.data()); word32 *t = const_cast(m_w.data()+20); // Timing attack countermeasure. See comments in Rijndael for more details. @@ -543,22 +543,22 @@ void ARIA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, b const __m128i MASK = _mm_set_epi8(12,13,14,15, 8,9,10,11, 4,5,6,7, 0,1,2,3); if (HasSSSE3()) { - outBlock[ 0] = (byte)(X1[ARIA_BRF(t[0],3)] ); - outBlock[ 1] = (byte)(X2[ARIA_BRF(t[0],2)]>>8); - outBlock[ 2] = (byte)(S1[ARIA_BRF(t[0],1)] ); - outBlock[ 3] = (byte)(S2[ARIA_BRF(t[0],0)] ); - outBlock[ 4] = (byte)(X1[ARIA_BRF(t[1],3)] ); - outBlock[ 5] = (byte)(X2[ARIA_BRF(t[1],2)]>>8); - outBlock[ 6] = (byte)(S1[ARIA_BRF(t[1],1)] ); - outBlock[ 7] = (byte)(S2[ARIA_BRF(t[1],0)] ); - outBlock[ 8] = (byte)(X1[ARIA_BRF(t[2],3)] ); - outBlock[ 9] = (byte)(X2[ARIA_BRF(t[2],2)]>>8); - outBlock[10] = (byte)(S1[ARIA_BRF(t[2],1)] ); - outBlock[11] = (byte)(S2[ARIA_BRF(t[2],0)] ); - outBlock[12] = (byte)(X1[ARIA_BRF(t[3],3)] ); - outBlock[13] = (byte)(X2[ARIA_BRF(t[3],2)]>>8); - outBlock[14] = (byte)(S1[ARIA_BRF(t[3],1)] ); - outBlock[15] = (byte)(S2[ARIA_BRF(t[3],0)] ); + outBlock[ 0] = (::byte)(X1[ARIA_BRF(t[0],3)] ); + outBlock[ 1] = (::byte)(X2[ARIA_BRF(t[0],2)]>>8); + outBlock[ 2] = (::byte)(S1[ARIA_BRF(t[0],1)] ); + outBlock[ 3] = (::byte)(S2[ARIA_BRF(t[0],0)] ); + outBlock[ 4] = (::byte)(X1[ARIA_BRF(t[1],3)] ); + outBlock[ 5] = (::byte)(X2[ARIA_BRF(t[1],2)]>>8); + outBlock[ 6] = (::byte)(S1[ARIA_BRF(t[1],1)] ); + outBlock[ 7] = (::byte)(S2[ARIA_BRF(t[1],0)] ); + outBlock[ 8] = (::byte)(X1[ARIA_BRF(t[2],3)] ); + outBlock[ 9] = (::byte)(X2[ARIA_BRF(t[2],2)]>>8); + outBlock[10] = (::byte)(S1[ARIA_BRF(t[2],1)] ); + outBlock[11] = (::byte)(S2[ARIA_BRF(t[2],0)] ); + outBlock[12] = (::byte)(X1[ARIA_BRF(t[3],3)] ); + outBlock[13] = (::byte)(X2[ARIA_BRF(t[3],2)]>>8); + outBlock[14] = (::byte)(S1[ARIA_BRF(t[3],1)] ); + outBlock[15] = (::byte)(S2[ARIA_BRF(t[3],0)] ); // 'outBlock' may be unaligned. _mm_storeu_si128(reinterpret_cast<__m128i*>(outBlock), @@ -578,22 +578,22 @@ void ARIA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, b else # endif // CRYPTOPP_ENABLE_ARIA_SSSE3_INTRINSICS { - outBlock[ 0] = (byte)(X1[ARIA_BRF(t[0],3)] ) ^ rk[ 3]; - outBlock[ 1] = (byte)(X2[ARIA_BRF(t[0],2)]>>8) ^ rk[ 2]; - outBlock[ 2] = (byte)(S1[ARIA_BRF(t[0],1)] ) ^ rk[ 1]; - outBlock[ 3] = (byte)(S2[ARIA_BRF(t[0],0)] ) ^ rk[ 0]; - outBlock[ 4] = (byte)(X1[ARIA_BRF(t[1],3)] ) ^ rk[ 7]; - outBlock[ 5] = (byte)(X2[ARIA_BRF(t[1],2)]>>8) ^ rk[ 6]; - outBlock[ 6] = (byte)(S1[ARIA_BRF(t[1],1)] ) ^ rk[ 5]; - outBlock[ 7] = (byte)(S2[ARIA_BRF(t[1],0)] ) ^ rk[ 4]; - outBlock[ 8] = (byte)(X1[ARIA_BRF(t[2],3)] ) ^ rk[11]; - outBlock[ 9] = (byte)(X2[ARIA_BRF(t[2],2)]>>8) ^ rk[10]; - outBlock[10] = (byte)(S1[ARIA_BRF(t[2],1)] ) ^ rk[ 9]; - outBlock[11] = (byte)(S2[ARIA_BRF(t[2],0)] ) ^ rk[ 8]; - outBlock[12] = (byte)(X1[ARIA_BRF(t[3],3)] ) ^ rk[15]; - outBlock[13] = (byte)(X2[ARIA_BRF(t[3],2)]>>8) ^ rk[14]; - outBlock[14] = (byte)(S1[ARIA_BRF(t[3],1)] ) ^ rk[13]; - outBlock[15] = (byte)(S2[ARIA_BRF(t[3],0)] ) ^ rk[12]; + outBlock[ 0] = (::byte)(X1[ARIA_BRF(t[0],3)] ) ^ rk[ 3]; + outBlock[ 1] = (::byte)(X2[ARIA_BRF(t[0],2)]>>8) ^ rk[ 2]; + outBlock[ 2] = (::byte)(S1[ARIA_BRF(t[0],1)] ) ^ rk[ 1]; + outBlock[ 3] = (::byte)(S2[ARIA_BRF(t[0],0)] ) ^ rk[ 0]; + outBlock[ 4] = (::byte)(X1[ARIA_BRF(t[1],3)] ) ^ rk[ 7]; + outBlock[ 5] = (::byte)(X2[ARIA_BRF(t[1],2)]>>8) ^ rk[ 6]; + outBlock[ 6] = (::byte)(S1[ARIA_BRF(t[1],1)] ) ^ rk[ 5]; + outBlock[ 7] = (::byte)(S2[ARIA_BRF(t[1],0)] ) ^ rk[ 4]; + outBlock[ 8] = (::byte)(X1[ARIA_BRF(t[2],3)] ) ^ rk[11]; + outBlock[ 9] = (::byte)(X2[ARIA_BRF(t[2],2)]>>8) ^ rk[10]; + outBlock[10] = (::byte)(S1[ARIA_BRF(t[2],1)] ) ^ rk[ 9]; + outBlock[11] = (::byte)(S2[ARIA_BRF(t[2],0)] ) ^ rk[ 8]; + outBlock[12] = (::byte)(X1[ARIA_BRF(t[3],3)] ) ^ rk[15]; + outBlock[13] = (::byte)(X2[ARIA_BRF(t[3],2)]>>8) ^ rk[14]; + outBlock[14] = (::byte)(S1[ARIA_BRF(t[3],1)] ) ^ rk[13]; + outBlock[15] = (::byte)(S2[ARIA_BRF(t[3],0)] ) ^ rk[12]; } #else outBlock[ 0] = (byte)(X1[ARIA_BRF(t[0],3)] ); diff --git a/aria.h b/aria.h index 88811b49..ab563441 100644 --- a/aria.h +++ b/aria.h @@ -44,12 +44,12 @@ public: class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { protected: - void UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *key, unsigned int keylen, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; private: // Reference implementation allocates a table of 17 round keys. - FixedSizeAlignedSecBlock m_rk; // round keys + FixedSizeAlignedSecBlock< ::byte, 16*17> m_rk; // round keys FixedSizeAlignedSecBlock m_w; // w0, w1, w2, w3, t and u unsigned int m_rounds; }; diff --git a/asn.cpp b/asn.cpp index fb1bff0d..e38bded9 100644 --- a/asn.cpp +++ b/asn.cpp @@ -19,16 +19,16 @@ size_t DERLengthEncode(BufferedTransformation &bt, lword length) size_t i=0; if (length <= 0x7f) { - bt.Put(byte(length)); + bt.Put(::byte(length)); i++; } else { - bt.Put(byte(BytePrecision(length) | 0x80)); + bt.Put(::byte(BytePrecision(length) | 0x80)); i++; for (int j=BytePrecision(length); j; --j) { - bt.Put(byte(length >> (j-1)*8)); + bt.Put(::byte(length >> (j-1)*8)); i++; } } @@ -37,7 +37,7 @@ size_t DERLengthEncode(BufferedTransformation &bt, lword length) bool BERLengthDecode(BufferedTransformation &bt, lword &length, bool &definiteLength) { - byte b; + ::byte b; if (!bt.Get(b)) return false; @@ -92,7 +92,7 @@ void DEREncodeNull(BufferedTransformation &out) void BERDecodeNull(BufferedTransformation &in) { - byte b; + ::byte b; if (!in.Get(b) || b != TAG_NULL) BERDecodeError(); size_t length; @@ -101,7 +101,7 @@ void BERDecodeNull(BufferedTransformation &in) } /// ASN Strings -size_t DEREncodeOctetString(BufferedTransformation &bt, const byte *str, size_t strLen) +size_t DEREncodeOctetString(BufferedTransformation &bt, const ::byte *str, size_t strLen) { bt.Put(OCTET_STRING); size_t lengthBytes = DERLengthEncode(bt, strLen); @@ -116,7 +116,7 @@ size_t DEREncodeOctetString(BufferedTransformation &bt, const SecByteBlock &str) size_t BERDecodeOctetString(BufferedTransformation &bt, SecByteBlock &str) { - byte b; + ::byte b; if (!bt.Get(b) || b != OCTET_STRING) BERDecodeError(); @@ -134,7 +134,7 @@ size_t BERDecodeOctetString(BufferedTransformation &bt, SecByteBlock &str) size_t BERDecodeOctetString(BufferedTransformation &bt, BufferedTransformation &str) { - byte b; + ::byte b; if (!bt.Get(b) || b != OCTET_STRING) BERDecodeError(); @@ -148,17 +148,17 @@ size_t BERDecodeOctetString(BufferedTransformation &bt, BufferedTransformation & return bc; } -size_t DEREncodeTextString(BufferedTransformation &bt, const std::string &str, byte asnTag) +size_t DEREncodeTextString(BufferedTransformation &bt, const std::string &str, ::byte asnTag) { bt.Put(asnTag); size_t lengthBytes = DERLengthEncode(bt, str.size()); - bt.Put((const byte *)str.data(), str.size()); + bt.Put((const ::byte *)str.data(), str.size()); return 1+lengthBytes+str.size(); } -size_t BERDecodeTextString(BufferedTransformation &bt, std::string &str, byte asnTag) +size_t BERDecodeTextString(BufferedTransformation &bt, std::string &str, ::byte asnTag) { - byte b; + ::byte b; if (!bt.Get(b) || b != asnTag) BERDecodeError(); @@ -179,18 +179,18 @@ size_t BERDecodeTextString(BufferedTransformation &bt, std::string &str, byte as } /// ASN BitString -size_t DEREncodeBitString(BufferedTransformation &bt, const byte *str, size_t strLen, unsigned int unusedBits) +size_t DEREncodeBitString(BufferedTransformation &bt, const ::byte *str, size_t strLen, unsigned int unusedBits) { bt.Put(BIT_STRING); size_t lengthBytes = DERLengthEncode(bt, strLen+1); - bt.Put((byte)unusedBits); + bt.Put((::byte)unusedBits); bt.Put(str, strLen); return 2+lengthBytes+strLen; } size_t BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigned int &unusedBits) { - byte b; + ::byte b; if (!bt.Get(b) || b != BIT_STRING) BERDecodeError(); @@ -203,7 +203,7 @@ size_t BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigne BERDecodeError(); // X.690, 8.6.2.2: "The number [of unused bits] shall be in the range zero to seven" - byte unused; + ::byte unused; if (!bt.Get(unused) || unused > 7) BERDecodeError(); unusedBits = unused; @@ -215,7 +215,7 @@ size_t BERDecodeBitString(BufferedTransformation &bt, SecByteBlock &str, unsigne void DERReencode(BufferedTransformation &source, BufferedTransformation &dest) { - byte tag; + ::byte tag; source.Peek(tag); BERGeneralDecoder decoder(source, tag); DERGeneralEncoder encoder(dest, tag); @@ -233,13 +233,13 @@ void DERReencode(BufferedTransformation &source, BufferedTransformation &dest) void OID::EncodeValue(BufferedTransformation &bt, word32 v) { for (unsigned int i=RoundUpToMultipleOf(STDMAX(7U,BitPrecision(v)), 7U)-7; i != 0; i-=7) - bt.Put((byte)(0x80 | ((v >> i) & 0x7f))); - bt.Put((byte)(v & 0x7f)); + bt.Put((::byte)(0x80 | ((v >> i) & 0x7f))); + bt.Put((::byte)(v & 0x7f)); } size_t OID::DecodeValue(BufferedTransformation &bt, word32 &v) { - byte b; + ::byte b; size_t i=0; v = 0; while (true) @@ -260,7 +260,7 @@ void OID::DEREncode(BufferedTransformation &bt) const { CRYPTOPP_ASSERT(m_values.size() >= 2); ByteQueue temp; - temp.Put(byte(m_values[0] * 40 + m_values[1])); + temp.Put(::byte(m_values[0] * 40 + m_values[1])); for (size_t i=2; i 0 && m_id == 0 && m_queue.Peek(b) && b == 0) { m_queue.TransferTo(CurrentTarget(), 1); @@ -392,21 +392,21 @@ void EncodedObjectFilter::Put(const byte *inString, size_t length) } } -BERGeneralDecoder::BERGeneralDecoder(BufferedTransformation &inQueue, byte asnTag) +BERGeneralDecoder::BERGeneralDecoder(BufferedTransformation &inQueue, ::byte asnTag) : m_inQueue(inQueue), m_finished(false) { Init(asnTag); } -BERGeneralDecoder::BERGeneralDecoder(BERGeneralDecoder &inQueue, byte asnTag) +BERGeneralDecoder::BERGeneralDecoder(BERGeneralDecoder &inQueue, ::byte asnTag) : m_inQueue(inQueue), m_finished(false) { Init(asnTag); } -void BERGeneralDecoder::Init(byte asnTag) +void BERGeneralDecoder::Init(::byte asnTag) { - byte b; + ::byte b; if (!m_inQueue.Get(b) || b != asnTag) BERDecodeError(); @@ -441,17 +441,17 @@ bool BERGeneralDecoder::EndReached() const } } -byte BERGeneralDecoder::PeekByte() const +::byte BERGeneralDecoder::PeekByte() const { - byte b; + ::byte b; if (!Peek(b)) BERDecodeError(); return b; } -void BERGeneralDecoder::CheckByte(byte check) +void BERGeneralDecoder::CheckByte(::byte check) { - byte b; + ::byte b; if (!Get(b) || b != check) BERDecodeError(); } @@ -499,14 +499,14 @@ lword BERGeneralDecoder::ReduceLength(lword delta) return delta; } -DERGeneralEncoder::DERGeneralEncoder(BufferedTransformation &outQueue, byte asnTag) +DERGeneralEncoder::DERGeneralEncoder(BufferedTransformation &outQueue, ::byte asnTag) : ByteQueue(), m_outQueue(outQueue), m_finished(false), m_asnTag(asnTag) { } // TODO: GCC (and likely other compilers) identify this as a copy constructor; and not a constructor. // We have to wait until Crypto++ 6.0 to fix it because the signature change breaks versioning. -DERGeneralEncoder::DERGeneralEncoder(DERGeneralEncoder &outQueue, byte asnTag) +DERGeneralEncoder::DERGeneralEncoder(DERGeneralEncoder &outQueue, ::byte asnTag) : ByteQueue(), m_outQueue(outQueue), m_finished(false), m_asnTag(asnTag) { } diff --git a/asn.h b/asn.h index c3d852ed..8abbe308 100644 --- a/asn.h +++ b/asn.h @@ -79,7 +79,7 @@ public: UnknownOID(const char *err) : BERDecodeErr(err) {} }; -// unsigned int DERLengthEncode(unsigned int length, byte *output=0); +// unsigned int DERLengthEncode(unsigned int length, ::byte *output=0); //! \brief DER encode a length //! \param bt BufferedTransformation object for writing @@ -108,7 +108,7 @@ CRYPTOPP_DLL void CRYPTOPP_API BERDecodeNull(BufferedTransformation &bt); //! \param str the string to encode //! \param strLen the length of the string //! \returns the number of octets used for the encoding -CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeOctetString(BufferedTransformation &bt, const byte *str, size_t strLen); +CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeOctetString(BufferedTransformation &bt, const ::byte *str, size_t strLen); //! \brief DER encode octet string //! \param bt BufferedTransformation object for reading @@ -134,14 +134,14 @@ CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeOctetString(BufferedTransformation &bt //! \param asnTag the ASN.1 type //! \returns the number of octets used for the encoding //! \details DEREncodeTextString() can be used for UTF8_STRING, PRINTABLE_STRING, and IA5_STRING -CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeTextString(BufferedTransformation &bt, const std::string &str, byte asnTag); +CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeTextString(BufferedTransformation &bt, const std::string &str, ::byte asnTag); //! \brief BER decode text string //! \param bt BufferedTransformation object for reading //! \param str the string to encode //! \param asnTag the ASN.1 type //! \details DEREncodeTextString() can be used for UTF8_STRING, PRINTABLE_STRING, and IA5_STRING -CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeTextString(BufferedTransformation &bt, std::string &str, byte asnTag); +CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeTextString(BufferedTransformation &bt, std::string &str, ::byte asnTag); //! \brief DER encode bit string //! \param bt BufferedTransformation object for writing @@ -149,7 +149,7 @@ CRYPTOPP_DLL size_t CRYPTOPP_API BERDecodeTextString(BufferedTransformation &bt, //! \param strLen the length of the string //! \param unusedBits the number of unused bits //! \returns the number of octets used for the encoding -CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeBitString(BufferedTransformation &bt, const byte *str, size_t strLen, unsigned int unusedBits=0); +CRYPTOPP_DLL size_t CRYPTOPP_API DEREncodeBitString(BufferedTransformation &bt, const ::byte *str, size_t strLen, unsigned int unusedBits=0); //! \brief DER decode bit string //! \param bt BufferedTransformation object for reading @@ -225,7 +225,7 @@ public: //! \brief Input a byte buffer for processing //! \param inString the byte buffer to process //! \param length the size of the string, in bytes - void Put(const byte *inString, size_t length); + void Put(const ::byte *inString, size_t length); unsigned int GetNumberOfCompletedObjects() const {return m_nCurrentObject;} unsigned long GetPositionOfObject(unsigned int i) const {return m_positions[i];} @@ -238,7 +238,7 @@ private: std::vector m_positions; ByteQueue m_queue; enum State {IDENTIFIER, LENGTH, BODY, TAIL, ALL_DONE} m_state; - byte m_id; + ::byte m_id; lword m_lengthRemaining; }; @@ -248,14 +248,14 @@ class CRYPTOPP_DLL BERGeneralDecoder : public Store public: virtual ~BERGeneralDecoder(); - explicit BERGeneralDecoder(BufferedTransformation &inQueue, byte asnTag); - explicit BERGeneralDecoder(BERGeneralDecoder &inQueue, byte asnTag); + explicit BERGeneralDecoder(BufferedTransformation &inQueue, ::byte asnTag); + explicit BERGeneralDecoder(BERGeneralDecoder &inQueue, ::byte asnTag); bool IsDefiniteLength() const {return m_definiteLength;} lword RemainingLength() const {CRYPTOPP_ASSERT(m_definiteLength); return m_length;} bool EndReached() const; - byte PeekByte() const; - void CheckByte(byte b); + ::byte PeekByte() const; + void CheckByte(::byte b); size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true); size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const; @@ -269,7 +269,7 @@ protected: lword m_length; private: - void Init(byte asnTag); + void Init(::byte asnTag); void StoreInitialize(const NameValuePairs ¶meters) {CRYPTOPP_UNUSED(parameters); CRYPTOPP_ASSERT(false);} lword ReduceLength(lword delta); @@ -286,8 +286,8 @@ class CRYPTOPP_DLL DERGeneralEncoder : public ByteQueue public: virtual ~DERGeneralEncoder(); - explicit DERGeneralEncoder(BufferedTransformation &outQueue, byte asnTag = SEQUENCE | CONSTRUCTED); - explicit DERGeneralEncoder(DERGeneralEncoder &outQueue, byte asnTag = SEQUENCE | CONSTRUCTED); + explicit DERGeneralEncoder(BufferedTransformation &outQueue, ::byte asnTag = SEQUENCE | CONSTRUCTED); + explicit DERGeneralEncoder(DERGeneralEncoder &outQueue, ::byte asnTag = SEQUENCE | CONSTRUCTED); // call this to denote end of sequence void MessageEnd(); @@ -296,16 +296,16 @@ private: BufferedTransformation &m_outQueue; bool m_finished; - byte m_asnTag; + ::byte m_asnTag; }; //! \brief BER Sequence Decoder class CRYPTOPP_DLL BERSequenceDecoder : public BERGeneralDecoder { public: - explicit BERSequenceDecoder(BufferedTransformation &inQueue, byte asnTag = SEQUENCE | CONSTRUCTED) + explicit BERSequenceDecoder(BufferedTransformation &inQueue, ::byte asnTag = SEQUENCE | CONSTRUCTED) : BERGeneralDecoder(inQueue, asnTag) {} - explicit BERSequenceDecoder(BERSequenceDecoder &inQueue, byte asnTag = SEQUENCE | CONSTRUCTED) + explicit BERSequenceDecoder(BERSequenceDecoder &inQueue, ::byte asnTag = SEQUENCE | CONSTRUCTED) : BERGeneralDecoder(inQueue, asnTag) {} }; @@ -313,9 +313,9 @@ public: class CRYPTOPP_DLL DERSequenceEncoder : public DERGeneralEncoder { public: - explicit DERSequenceEncoder(BufferedTransformation &outQueue, byte asnTag = SEQUENCE | CONSTRUCTED) + explicit DERSequenceEncoder(BufferedTransformation &outQueue, ::byte asnTag = SEQUENCE | CONSTRUCTED) : DERGeneralEncoder(outQueue, asnTag) {} - explicit DERSequenceEncoder(DERSequenceEncoder &outQueue, byte asnTag = SEQUENCE | CONSTRUCTED) + explicit DERSequenceEncoder(DERSequenceEncoder &outQueue, ::byte asnTag = SEQUENCE | CONSTRUCTED) : DERGeneralEncoder(outQueue, asnTag) {} }; @@ -323,9 +323,9 @@ public: class CRYPTOPP_DLL BERSetDecoder : public BERGeneralDecoder { public: - explicit BERSetDecoder(BufferedTransformation &inQueue, byte asnTag = SET | CONSTRUCTED) + explicit BERSetDecoder(BufferedTransformation &inQueue, ::byte asnTag = SET | CONSTRUCTED) : BERGeneralDecoder(inQueue, asnTag) {} - explicit BERSetDecoder(BERSetDecoder &inQueue, byte asnTag = SET | CONSTRUCTED) + explicit BERSetDecoder(BERSetDecoder &inQueue, ::byte asnTag = SET | CONSTRUCTED) : BERGeneralDecoder(inQueue, asnTag) {} }; @@ -333,9 +333,9 @@ public: class CRYPTOPP_DLL DERSetEncoder : public DERGeneralEncoder { public: - explicit DERSetEncoder(BufferedTransformation &outQueue, byte asnTag = SET | CONSTRUCTED) + explicit DERSetEncoder(BufferedTransformation &outQueue, ::byte asnTag = SET | CONSTRUCTED) : DERGeneralEncoder(outQueue, asnTag) {} - explicit DERSetEncoder(DERSetEncoder &outQueue, byte asnTag = SET | CONSTRUCTED) + explicit DERSetEncoder(DERSetEncoder &outQueue, ::byte asnTag = SET | CONSTRUCTED) : DERGeneralEncoder(outQueue, asnTag) {} }; @@ -350,9 +350,9 @@ public: //! \param tag ASN.1 tag to match as optional data //! \param mask the mask to apply when matching the tag //! \sa ASNTag and ASNIdFlag - void BERDecode(BERSequenceDecoder &seqDecoder, byte tag, byte mask = ~CONSTRUCTED) + void BERDecode(BERSequenceDecoder &seqDecoder, ::byte tag, ::byte mask = ~CONSTRUCTED) { - byte b; + ::byte b; if (seqDecoder.Peek(b) && (b & mask) == tag) reset(new T(seqDecoder)); } @@ -452,9 +452,9 @@ protected: //! \param asnTag the ASN.1 type //! \details DEREncodeUnsigned() can be used with INTEGER, BOOLEAN, and ENUM template -size_t DEREncodeUnsigned(BufferedTransformation &out, T w, byte asnTag = INTEGER) +size_t DEREncodeUnsigned(BufferedTransformation &out, T w, ::byte asnTag = INTEGER) { - byte buf[sizeof(w)+1]; + ::byte buf[sizeof(w)+1]; unsigned int bc; if (asnTag == BOOLEAN) { @@ -465,7 +465,7 @@ size_t DEREncodeUnsigned(BufferedTransformation &out, T w, byte asnTag = INTEGER { buf[0] = 0; for (unsigned int i=0; i> (sizeof(w)-1-i)*8); + buf[i+1] = ::byte(w >> (sizeof(w)-1-i)*8); bc = sizeof(w); while (bc > 1 && buf[sizeof(w)+1-bc] == 0) --bc; @@ -488,10 +488,10 @@ size_t DEREncodeUnsigned(BufferedTransformation &out, T w, byte asnTag = INTEGER //! \throws BERDecodeErr() if the value cannot be parsed or the decoded value is not within range. //! \details DEREncodeUnsigned() can be used with INTEGER, BOOLEAN, and ENUM template -void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag = INTEGER, +void BERDecodeUnsigned(BufferedTransformation &in, T &w, ::byte asnTag = INTEGER, T minValue = 0, T maxValue = T(0xffffffff)) { - byte b; + ::byte b; if (!in.Get(b) || b != asnTag) BERDecodeError(); @@ -516,7 +516,7 @@ void BERDecodeUnsigned(BufferedTransformation &in, T &w, byte asnTag = INTEGER, // not all be ones and (b) shall not all be zeros ... These rules ensure that an integer value // is always encoded in the smallest possible number of octet". // We invented AER (Alternate Encoding Rules), which is more relaxed than BER, CER, and DER. - const byte *ptr = buf; + const ::byte *ptr = buf; while (bc > sizeof(w) && *ptr == 0) { bc--; diff --git a/authenc.cpp b/authenc.cpp index fd446b73..4dc9cf67 100644 --- a/authenc.cpp +++ b/authenc.cpp @@ -8,11 +8,11 @@ NAMESPACE_BEGIN(CryptoPP) -void AuthenticatedSymmetricCipherBase::AuthenticateData(const byte *input, size_t len) +void AuthenticatedSymmetricCipherBase::AuthenticateData(const ::byte *input, size_t len) { unsigned int blockSize = AuthenticationBlockSize(); unsigned int &num = m_bufferedDataLength; - byte* data = m_buffer.begin(); + ::byte* data = m_buffer.begin(); if (num != 0) // process left over data { @@ -45,7 +45,7 @@ void AuthenticatedSymmetricCipherBase::AuthenticateData(const byte *input, size_ num = (unsigned int)len; } -void AuthenticatedSymmetricCipherBase::SetKey(const byte *userKey, size_t keylength, const NameValuePairs ¶ms) +void AuthenticatedSymmetricCipherBase::SetKey(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms) { m_bufferedDataLength = 0; m_state = State_Start; @@ -54,12 +54,12 @@ void AuthenticatedSymmetricCipherBase::SetKey(const byte *userKey, size_t keylen m_state = State_KeySet; size_t length; - const byte *iv = GetIVAndThrowIfInvalid(params, length); + const ::byte *iv = GetIVAndThrowIfInvalid(params, length); if (iv) Resynchronize(iv, (int)length); } -void AuthenticatedSymmetricCipherBase::Resynchronize(const byte *iv, int length) +void AuthenticatedSymmetricCipherBase::Resynchronize(const ::byte *iv, int length) { if (m_state < State_KeySet) throw BadState(AlgorithmName(), "Resynchronize", "key is set"); @@ -72,7 +72,7 @@ void AuthenticatedSymmetricCipherBase::Resynchronize(const byte *iv, int length) m_state = State_IVSet; } -void AuthenticatedSymmetricCipherBase::Update(const byte *input, size_t length) +void AuthenticatedSymmetricCipherBase::Update(const ::byte *input, size_t length) { if (length == 0) return; @@ -101,7 +101,7 @@ void AuthenticatedSymmetricCipherBase::Update(const byte *input, size_t length) } } -void AuthenticatedSymmetricCipherBase::ProcessData(byte *outString, const byte *inString, size_t length) +void AuthenticatedSymmetricCipherBase::ProcessData(::byte *outString, const ::byte *inString, size_t length) { m_totalMessageLength += length; if (m_state >= State_IVSet && m_totalMessageLength > MaxMessageLength()) @@ -133,7 +133,7 @@ reswitch: } } -void AuthenticatedSymmetricCipherBase::TruncatedFinal(byte *mac, size_t macSize) +void AuthenticatedSymmetricCipherBase::TruncatedFinal(::byte *mac, size_t macSize) { if (m_totalHeaderLength > MaxHeaderLength()) throw InvalidArgument(AlgorithmName() + ": header length of " + IntToString(m_totalHeaderLength) + " exceeds the maximum of " + IntToString(MaxHeaderLength())); diff --git a/authenc.h b/authenc.h index 5f9f2b1a..02bd1b12 100644 --- a/authenc.h +++ b/authenc.h @@ -30,29 +30,29 @@ public: //! \param length the length of the byte buffer //! \param params additional parameters passed as NameValuePairs //! \details key must be at least DEFAULT_KEYLENGTH in length. - void UncheckedSetKey(const byte * key, unsigned int length,const CryptoPP::NameValuePairs ¶ms) + void UncheckedSetKey(const ::byte * key, unsigned int length,const CryptoPP::NameValuePairs ¶ms) {CRYPTOPP_UNUSED(key), CRYPTOPP_UNUSED(length), CRYPTOPP_UNUSED(params); CRYPTOPP_ASSERT(false);} - void SetKey(const byte *userKey, size_t keylength, const NameValuePairs ¶ms); + void SetKey(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms); void Restart() {if (m_state > State_KeySet) m_state = State_KeySet;} - void Resynchronize(const byte *iv, int length=-1); - void Update(const byte *input, size_t length); - void ProcessData(byte *outString, const byte *inString, size_t length); - void TruncatedFinal(byte *mac, size_t macSize); + void Resynchronize(const ::byte *iv, int length=-1); + void Update(const ::byte *input, size_t length); + void ProcessData(::byte *outString, const ::byte *inString, size_t length); + void TruncatedFinal(::byte *mac, size_t macSize); protected: - void AuthenticateData(const byte *data, size_t len); + void AuthenticateData(const ::byte *data, size_t len); const SymmetricCipher & GetSymmetricCipher() const {return const_cast(this)->AccessSymmetricCipher();}; virtual SymmetricCipher & AccessSymmetricCipher() =0; virtual bool AuthenticationIsOnPlaintext() const =0; virtual unsigned int AuthenticationBlockSize() const =0; - virtual void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms) =0; - virtual void Resync(const byte *iv, size_t len) =0; - virtual size_t AuthenticateBlocks(const byte *data, size_t len) =0; + virtual void SetKeyWithoutResync(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms) =0; + virtual void Resync(const ::byte *iv, size_t len) =0; + virtual size_t AuthenticateBlocks(const ::byte *data, size_t len) =0; virtual void AuthenticateLastHeaderBlock() =0; virtual void AuthenticateLastConfidentialBlock() {} - virtual void AuthenticateLastFooterBlock(byte *mac, size_t macSize) =0; + virtual void AuthenticateLastFooterBlock(::byte *mac, size_t macSize) =0; enum State {State_Start, State_KeySet, State_IVSet, State_AuthUntransformed, State_AuthTransformed, State_AuthFooter}; State m_state; diff --git a/base32.cpp b/base32.cpp index f474de07..c7e583e0 100644 --- a/base32.cpp +++ b/base32.cpp @@ -7,8 +7,8 @@ NAMESPACE_BEGIN(CryptoPP) namespace { - const byte s_vecUpper[] = "ABCDEFGHIJKMNPQRSTUVWXYZ23456789"; - const byte s_vecLower[] = "abcdefghijkmnpqrstuvwxyz23456789"; + const ::byte s_vecUpper[] = "ABCDEFGHIJKMNPQRSTUVWXYZ23456789"; + const ::byte s_vecLower[] = "abcdefghijkmnpqrstuvwxyz23456789"; } void Base32Encoder::IsolatedInitialize(const NameValuePairs ¶meters) diff --git a/base64.cpp b/base64.cpp index 63f7b12b..1fdb8e2f 100644 --- a/base64.cpp +++ b/base64.cpp @@ -7,9 +7,9 @@ NAMESPACE_BEGIN(CryptoPP) namespace { - const byte s_stdVec[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - const byte s_urlVec[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; - const byte s_padding = '='; + const ::byte s_stdVec[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + const ::byte s_urlVec[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; + const ::byte s_padding = '='; } void Base64Encoder::IsolatedInitialize(const NameValuePairs ¶meters) diff --git a/basecode.cpp b/basecode.cpp index c96087ec..bfd66444 100644 --- a/basecode.cpp +++ b/basecode.cpp @@ -27,7 +27,7 @@ void BaseN_Encoder::IsolatedInitialize(const NameValuePairs ¶meters) if (m_bitsPerChar <= 0 || m_bitsPerChar >= 8) throw InvalidArgument("BaseN_Encoder: Log2Base must be between 1 and 7 inclusive"); - byte padding; + ::byte padding; bool pad; if (parameters.GetValue(Name::PaddingByte(), padding)) pad = parameters.GetValueWithDefault(Name::Pad(), true); @@ -45,7 +45,7 @@ void BaseN_Encoder::IsolatedInitialize(const NameValuePairs ¶meters) m_outBuf.New(m_outputBlockSize); } -size_t BaseN_Encoder::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t BaseN_Encoder::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { FILTER_BEGIN; while (m_inputPosition < length) @@ -130,7 +130,7 @@ void BaseN_Decoder::IsolatedInitialize(const NameValuePairs ¶meters) m_outBuf.New(m_outputBlockSize); } -size_t BaseN_Decoder::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t BaseN_Decoder::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { FILTER_BEGIN; while (m_inputPosition < length) @@ -175,7 +175,7 @@ size_t BaseN_Decoder::Put2(const byte *begin, size_t length, int messageEnd, boo FILTER_END_NO_MESSAGE_END; } -void BaseN_Decoder::InitializeDecodingLookupArray(int *lookup, const byte *alphabet, unsigned int base, bool caseInsensitive) +void BaseN_Decoder::InitializeDecodingLookupArray(int *lookup, const ::byte *alphabet, unsigned int base, bool caseInsensitive) { std::fill(lookup, lookup+256, -1); @@ -211,7 +211,7 @@ void Grouper::IsolatedInitialize(const NameValuePairs ¶meters) m_counter = 0; } -size_t Grouper::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t Grouper::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { FILTER_BEGIN; if (m_groupSize) diff --git a/basecode.h b/basecode.h index a522d6db..11eb8fd3 100644 --- a/basecode.h +++ b/basecode.h @@ -32,7 +32,7 @@ public: //! \param padding the character to use as padding //! \pre log2base must be between 1 and 7 inclusive //! \throws InvalidArgument if log2base is not between 1 and 7 - BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULLPTR, int padding=-1) + BaseN_Encoder(const ::byte *alphabet, int log2base, BufferedTransformation *attachment=NULLPTR, int padding=-1) : m_alphabet(NULLPTR), m_padding(0), m_bitsPerChar(0) , m_outputBlockSize(0), m_bytePos(0), m_bitPos(0) { @@ -40,14 +40,14 @@ public: IsolatedInitialize(MakeParameters(Name::EncodingLookupArray(), alphabet) (Name::Log2Base(), log2base) (Name::Pad(), padding != -1) - (Name::PaddingByte(), byte(padding))); + (Name::PaddingByte(), ::byte(padding))); } void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking); private: - const byte *m_alphabet; + const ::byte *m_alphabet; int m_padding, m_bitsPerChar, m_outputBlockSize; int m_bytePos, m_bitPos; SecByteBlock m_outBuf; @@ -84,7 +84,7 @@ public: } void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking); //! \brief Initializes BaseN lookup array //! \param lookup table of values @@ -96,7 +96,7 @@ public: //! \details Internally, the function sets the first 256 elements in the lookup table to //! their value from the alphabet array or -1. base is the number of element (like 32), //! and not an exponent (like 5 in 25) - static void CRYPTOPP_API InitializeDecodingLookupArray(int *lookup, const byte *alphabet, unsigned int base, bool caseInsensitive); + static void CRYPTOPP_API InitializeDecodingLookupArray(int *lookup, const ::byte *alphabet, unsigned int base, bool caseInsensitive); private: const int *m_lookup; @@ -130,7 +130,7 @@ public: } void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking); private: SecByteBlock m_separator, m_terminator; diff --git a/bench.h b/bench.h index d16f7462..90931688 100644 --- a/bench.h +++ b/bench.h @@ -28,7 +28,7 @@ extern double g_allocatedTime; extern double g_hertz; extern double g_logTotal; extern unsigned int g_logCount; -extern const byte defaultKey[]; +extern const ::byte defaultKey[]; // Test book keeping extern time_t g_testBegin; diff --git a/bench1.cpp b/bench1.cpp index 2d128648..2c5fa5eb 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -35,7 +35,7 @@ const double CLOCK_TICKS_PER_SECOND = (double)CLK_TCK; const double CLOCK_TICKS_PER_SECOND = 1000000.0; #endif -const byte defaultKey[] = "0123456789" // 168 + NULL +const ::byte defaultKey[] = "0123456789" // 168 + NULL "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" "00000000000000000000000000000000000000000000000000000" "00000000000000000000000000000000000000000000000000000"; diff --git a/blake2.cpp b/blake2.cpp index 09a3794d..8150f665 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -36,20 +36,20 @@ inline __m128i MM_SET_EPI64X(const word64 a, const word64 b) #endif // C/C++ implementation -static void BLAKE2_CXX_Compress32(const byte* input, BLAKE2_State& state); -static void BLAKE2_CXX_Compress64(const byte* input, BLAKE2_State& state); +static void BLAKE2_CXX_Compress32(const ::byte* input, BLAKE2_State& state); +static void BLAKE2_CXX_Compress64(const ::byte* input, BLAKE2_State& state); // Also see http://github.com/weidai11/cryptopp/issues/247 for SunCC 5.12 #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE -static void BLAKE2_SSE2_Compress32(const byte* input, BLAKE2_State& state); +static void BLAKE2_SSE2_Compress32(const ::byte* input, BLAKE2_State& state); # if (__SUNPRO_CC != 0x5120) -static void BLAKE2_SSE2_Compress64(const byte* input, BLAKE2_State& state); +static void BLAKE2_SSE2_Compress64(const ::byte* input, BLAKE2_State& state); # endif #endif #if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE -static void BLAKE2_SSE4_Compress32(const byte* input, BLAKE2_State& state); -static void BLAKE2_SSE4_Compress64(const byte* input, BLAKE2_State& state); +static void BLAKE2_SSE4_Compress32(const ::byte* input, BLAKE2_State& state); +static void BLAKE2_SSE4_Compress64(const ::byte* input, BLAKE2_State& state); #endif // Disable NEON for Cortex-A53 and A57. Also see http://github.com/weidai11/cryptopp/issues/367 @@ -109,11 +109,11 @@ template<> struct CRYPTOPP_NO_VTABLE BLAKE2_Sigma { // Always align for NEON and SSE - CRYPTOPP_ALIGN_DATA(16) static const byte sigma[10][16]; + CRYPTOPP_ALIGN_DATA(16) static const ::byte sigma[10][16]; }; CRYPTOPP_ALIGN_DATA(16) -const byte BLAKE2_Sigma::sigma[10][16] = { +const ::byte BLAKE2_Sigma::sigma[10][16] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, @@ -131,11 +131,11 @@ template<> struct CRYPTOPP_NO_VTABLE BLAKE2_Sigma { // Always align for NEON and SSE - CRYPTOPP_ALIGN_DATA(16) static const byte sigma[12][16]; + CRYPTOPP_ALIGN_DATA(16) static const ::byte sigma[12][16]; }; CRYPTOPP_ALIGN_DATA(16) -const byte BLAKE2_Sigma::sigma[12][16] = { +const ::byte BLAKE2_Sigma::sigma[12][16] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, @@ -150,8 +150,8 @@ const byte BLAKE2_Sigma::sigma[12][16] = { { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } }; -typedef void (*pfnCompress32)(const byte*, BLAKE2_State&); -typedef void (*pfnCompress64)(const byte*, BLAKE2_State&); +typedef void (*pfnCompress32)(const ::byte*, BLAKE2_State&); +typedef void (*pfnCompress64)(const ::byte*, BLAKE2_State&); pfnCompress64 InitializeCompress64Fn() { @@ -198,12 +198,12 @@ pfnCompress32 InitializeCompress32Fn() #endif // CRYPTOPP_DOXYGEN_PROCESSING BLAKE2_ParameterBlock::BLAKE2_ParameterBlock(size_t digestLen, size_t keyLen, - const byte* saltStr, size_t saltLen, - const byte* personalizationStr, size_t personalizationLen) + const ::byte* saltStr, size_t saltLen, + const ::byte* personalizationStr, size_t personalizationLen) { // Avoid Coverity finding SIZEOF_MISMATCH/suspicious_sizeof - digestLength = (byte)digestLen; - keyLength = (byte)keyLen; + digestLength = (::byte)digestLen; + keyLength = (::byte)keyLen; fanout = depth = 1; nodeDepth = innerLength = 0; @@ -238,12 +238,12 @@ BLAKE2_ParameterBlock::BLAKE2_ParameterBlock(size_t digestLen, size_t key } BLAKE2_ParameterBlock::BLAKE2_ParameterBlock(size_t digestLen, size_t keyLen, - const byte* saltStr, size_t saltLen, - const byte* personalizationStr, size_t personalizationLen) + const ::byte* saltStr, size_t saltLen, + const ::byte* personalizationStr, size_t personalizationLen) { // Avoid Coverity finding SIZEOF_MISMATCH/suspicious_sizeof - digestLength = (byte)digestLen; - keyLength = (byte)keyLen; + digestLength = (::byte)digestLen; + keyLength = (::byte)keyLen; fanout = depth = 1; nodeDepth = innerLength = 0; @@ -279,7 +279,7 @@ BLAKE2_ParameterBlock::BLAKE2_ParameterBlock(size_t digestLen, size_t keyL } template -void BLAKE2_Base::UncheckedSetKey(const byte *key, unsigned int length, const CryptoPP::NameValuePairs& params) +void BLAKE2_Base::UncheckedSetKey(const ::byte *key, unsigned int length, const CryptoPP::NameValuePairs& params) { if (key && length) { @@ -307,8 +307,8 @@ void BLAKE2_Base::UncheckedSetKey(const byte *key, unsigned int leng memset(m_block.data(), 0x00, T_64bit ? 32 : 16); #endif - block.keyLength = (byte)length; - block.digestLength = (byte)params.GetIntValueWithDefault(Name::DigestSize(), DIGESTSIZE); + block.keyLength = (::byte)length; + block.digestLength = (::byte)params.GetIntValueWithDefault(Name::DigestSize(), DIGESTSIZE); block.fanout = block.depth = 1; ConstByteArrayParameter t; @@ -356,8 +356,8 @@ BLAKE2_Base::BLAKE2_Base(bool treeMode, unsigned int digestSize) : m } template -BLAKE2_Base::BLAKE2_Base(const byte *key, size_t keyLength, const byte* salt, size_t saltLength, - const byte* personalization, size_t personalizationLength, bool treeMode, unsigned int digestSize) +BLAKE2_Base::BLAKE2_Base(const ::byte *key, size_t keyLength, const ::byte* salt, size_t saltLength, + const ::byte* personalization, size_t personalizationLength, bool treeMode, unsigned int digestSize) : m_state(1), m_block(1), m_digestSize(digestSize), m_treeMode(treeMode) { CRYPTOPP_ASSERT(keyLength <= MAX_KEYLENGTH); @@ -385,8 +385,8 @@ void BLAKE2_Base::Restart(const BLAKE2_ParameterBlock& bloc if (&block != m_block.data()) { memcpy_s(m_block.data(), sizeof(ParameterBlock), &block, sizeof(ParameterBlock)); - m_block.data()->digestLength = (byte)m_digestSize; - m_block.data()->keyLength = (byte)m_key.size(); + m_block.data()->digestLength = (::byte)m_digestSize; + m_block.data()->keyLength = (::byte)m_key.size(); } State& state = *m_state.data(); @@ -409,7 +409,7 @@ void BLAKE2_Base::Restart(const BLAKE2_ParameterBlock& bloc } template -void BLAKE2_Base::Update(const byte *input, size_t length) +void BLAKE2_Base::Update(const ::byte *input, size_t length) { State& state = *m_state.data(); if (state.length + length > BLOCKSIZE) @@ -443,7 +443,7 @@ void BLAKE2_Base::Update(const byte *input, size_t length) } template -void BLAKE2_Base::TruncatedFinal(byte *hash, size_t size) +void BLAKE2_Base::TruncatedFinal(::byte *hash, size_t size) { this->ThrowIfInvalidTruncatedSize(size); @@ -476,7 +476,7 @@ void BLAKE2_Base::IncrementCounter(size_t count) } template <> -void BLAKE2_Base::Compress(const byte *input) +void BLAKE2_Base::Compress(const ::byte *input) { // Selects the most advanced implementation at runtime static const pfnCompress64 s_pfn = InitializeCompress64Fn(); @@ -484,14 +484,14 @@ void BLAKE2_Base::Compress(const byte *input) } template <> -void BLAKE2_Base::Compress(const byte *input) +void BLAKE2_Base::Compress(const ::byte *input) { // Selects the most advanced implementation at runtime static const pfnCompress32 s_pfn = InitializeCompress32Fn(); s_pfn(input, *m_state.data()); } -void BLAKE2_CXX_Compress64(const byte* input, BLAKE2_State& state) +void BLAKE2_CXX_Compress64(const ::byte* input, BLAKE2_State& state) { #undef BLAKE2_G #undef BLAKE2_ROUND @@ -554,7 +554,7 @@ void BLAKE2_CXX_Compress64(const byte* input, BLAKE2_State& state) state.h[i] = state.h[i] ^ ConditionalByteReverse(LittleEndian::ToEnum(), v[i] ^ v[i + 8]); } -void BLAKE2_CXX_Compress32(const byte* input, BLAKE2_State& state) +void BLAKE2_CXX_Compress32(const ::byte* input, BLAKE2_State& state) { #undef BLAKE2_G #undef BLAKE2_ROUND @@ -616,7 +616,7 @@ void BLAKE2_CXX_Compress32(const byte* input, BLAKE2_State& state } #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE -static void BLAKE2_SSE2_Compress32(const byte* input, BLAKE2_State& state) +static void BLAKE2_SSE2_Compress32(const ::byte* input, BLAKE2_State& state) { word32 m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15; GetBlock get(input); @@ -1035,7 +1035,7 @@ static void BLAKE2_SSE2_Compress32(const byte* input, BLAKE2_State& state) +static void BLAKE2_SSE2_Compress64(const ::byte* input, BLAKE2_State& state) { word64 m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15; GetBlock get(input); @@ -1930,7 +1930,7 @@ static void BLAKE2_SSE2_Compress64(const byte* input, BLAKE2_State #endif // CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE -static void BLAKE2_SSE4_Compress32(const byte* input, BLAKE2_State& state) +static void BLAKE2_SSE4_Compress32(const ::byte* input, BLAKE2_State& state) { __m128i row1, row2, row3, row4; __m128i buf1, buf2, buf3, buf4; @@ -2485,7 +2485,7 @@ static void BLAKE2_SSE4_Compress32(const byte* input, BLAKE2_State& state) +static void BLAKE2_SSE4_Compress64(const ::byte* input, BLAKE2_State& state) { __m128i row1l, row1h; __m128i row2l, row2h; diff --git a/blake2.h b/blake2.h index b3402001..bb0c3bf1 100644 --- a/blake2.h +++ b/blake2.h @@ -73,20 +73,20 @@ struct CRYPTOPP_NO_VTABLE BLAKE2_ParameterBlock { CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); memset(this, 0x00, sizeof(*this)); - digestLength = (byte)digestSize; + digestLength = (::byte)digestSize; fanout = depth = 1; } - BLAKE2_ParameterBlock(size_t digestSize, size_t keyLength, const byte* salt, size_t saltLength, - const byte* personalization, size_t personalizationLength); + BLAKE2_ParameterBlock(size_t digestSize, size_t keyLength, const ::byte* salt, size_t saltLength, + const ::byte* personalization, size_t personalizationLength); - byte digestLength; - byte keyLength, fanout, depth; - byte leafLength[4]; - byte nodeOffset[8]; - byte nodeDepth, innerLength, rfu[14]; - byte salt[SALTSIZE]; - byte personalization[PERSONALIZATIONSIZE]; + ::byte digestLength; + ::byte keyLength, fanout, depth; + ::byte leafLength[4]; + ::byte nodeOffset[8]; + ::byte nodeDepth, innerLength, rfu[14]; + ::byte salt[SALTSIZE]; + ::byte personalization[PERSONALIZATIONSIZE]; }; //! \brief BLAKE2s parameter block specialization @@ -108,20 +108,20 @@ struct CRYPTOPP_NO_VTABLE BLAKE2_ParameterBlock { CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); memset(this, 0x00, sizeof(*this)); - digestLength = (byte)digestSize; + digestLength = (::byte)digestSize; fanout = depth = 1; } - BLAKE2_ParameterBlock(size_t digestSize, size_t keyLength, const byte* salt, size_t saltLength, - const byte* personalization, size_t personalizationLength); + BLAKE2_ParameterBlock(size_t digestSize, size_t keyLength, const ::byte* salt, size_t saltLength, + const ::byte* personalization, size_t personalizationLength); - byte digestLength; - byte keyLength, fanout, depth; - byte leafLength[4]; - byte nodeOffset[6]; - byte nodeDepth, innerLength; - byte salt[SALTSIZE]; - byte personalization[PERSONALIZATIONSIZE]; + ::byte digestLength; + ::byte keyLength, fanout, depth; + ::byte leafLength[4]; + ::byte nodeOffset[6]; + ::byte nodeDepth, innerLength; + ::byte salt[SALTSIZE]; + ::byte personalization[PERSONALIZATIONSIZE]; }; //! \class BLAKE2_State @@ -146,7 +146,7 @@ struct CRYPTOPP_NO_VTABLE BLAKE2_State // SSE2, SSE4 and NEON depend upon t[] and f[] being side-by-side W h[8], t[2], f[2]; - byte buffer[BLOCKSIZE]; + ::byte buffer[BLOCKSIZE]; size_t length; }; @@ -191,7 +191,7 @@ public: unsigned int DigestSize() const {return m_digestSize;} unsigned int OptimalDataAlignment() const {return (CRYPTOPP_BOOL_ALIGN16 ? 16 : GetAlignmentOf());} - void Update(const byte *input, size_t length); + void Update(const ::byte *input, size_t length); void Restart(); //! \brief Restart a hash with parameter block and counter @@ -213,20 +213,20 @@ public: //! \details Tree mode is persisted across calls to Restart(). bool GetTreeMode() const {return m_treeMode;} - void TruncatedFinal(byte *hash, size_t size); + void TruncatedFinal(::byte *hash, size_t size); protected: BLAKE2_Base(); BLAKE2_Base(bool treeMode, unsigned int digestSize); - BLAKE2_Base(const byte *key, size_t keyLength, const byte* salt, size_t saltLength, - const byte* personalization, size_t personalizationLength, + BLAKE2_Base(const ::byte *key, size_t keyLength, const ::byte* salt, size_t saltLength, + const ::byte* personalization, size_t personalizationLength, bool treeMode, unsigned int digestSize); // Operates on state buffer and/or input. Must be BLOCKSIZE, final block will pad with 0's. - void Compress(const byte *input); + void Compress(const ::byte *input); inline void IncrementCounter(size_t count=BLOCKSIZE); - void UncheckedSetKey(const byte* key, unsigned int length, const CryptoPP::NameValuePairs& params); + void UncheckedSetKey(const ::byte* key, unsigned int length, const CryptoPP::NameValuePairs& params); private: AlignedState m_state; @@ -266,8 +266,8 @@ public: //! \param personalizationLength the size of the byte array //! \param treeMode flag indicating tree mode //! \param digestSize the digest size, in bytes - BLAKE2b(const byte *key, size_t keyLength, const byte* salt = NULLPTR, size_t saltLength = 0, - const byte* personalization = NULLPTR, size_t personalizationLength = 0, + BLAKE2b(const ::byte *key, size_t keyLength, const ::byte* salt = NULLPTR, size_t saltLength = 0, + const ::byte* personalization = NULLPTR, size_t personalizationLength = 0, bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {} }; @@ -302,8 +302,8 @@ public: //! \param personalizationLength the size of the byte array //! \param treeMode flag indicating tree mode //! \param digestSize the digest size, in bytes - BLAKE2s(const byte *key, size_t keyLength, const byte* salt = NULLPTR, size_t saltLength = 0, - const byte* personalization = NULLPTR, size_t personalizationLength = 0, + BLAKE2s(const ::byte *key, size_t keyLength, const ::byte* salt = NULLPTR, size_t saltLength = 0, + const ::byte* personalization = NULLPTR, size_t personalizationLength = 0, bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {} }; diff --git a/blowfish.cpp b/blowfish.cpp index e615da3b..31ad7245 100644 --- a/blowfish.cpp +++ b/blowfish.cpp @@ -6,7 +6,7 @@ NAMESPACE_BEGIN(CryptoPP) -void Blowfish::Base::UncheckedSetKey(const byte *key_string, unsigned int keylength, const NameValuePairs &) +void Blowfish::Base::UncheckedSetKey(const ::byte *key_string, unsigned int keylength, const NameValuePairs &) { AssertValidKeyLength(keylength); @@ -68,7 +68,7 @@ void Blowfish::Base::crypt_block(const word32 in[2], word32 out[2]) const out[1] = left; } -void Blowfish::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Blowfish::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { typedef BlockGetAndPut Block; diff --git a/blowfish.h b/blowfish.h index bc37ca0d..33797dbd 100644 --- a/blowfish.h +++ b/blowfish.h @@ -31,8 +31,8 @@ class Blowfish : public Blowfish_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; - void UncheckedSetKey(const byte *key_string, unsigned int keylength, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; + void UncheckedSetKey(const ::byte *key_string, unsigned int keylength, const NameValuePairs ¶ms); private: void crypt_block(const word32 in[2], word32 out[2]) const; diff --git a/blumshub.cpp b/blumshub.cpp index 353f6ecc..0c3ac0e7 100644 --- a/blumshub.cpp +++ b/blumshub.cpp @@ -25,21 +25,21 @@ unsigned int PublicBlumBlumShub::GenerateBit() return current.GetBit(--bitsLeft); } -byte PublicBlumBlumShub::GenerateByte() +::byte PublicBlumBlumShub::GenerateByte() { - byte b=0; + ::byte b=0; for (int i=0; i<8; i++) - b = byte((b << 1) | PublicBlumBlumShub::GenerateBit()); + b = ::byte((b << 1) | PublicBlumBlumShub::GenerateBit()); return b; } -void PublicBlumBlumShub::GenerateBlock(byte *output, size_t size) +void PublicBlumBlumShub::GenerateBlock(::byte *output, size_t size) { while (size--) *output++ = PublicBlumBlumShub::GenerateByte(); } -void PublicBlumBlumShub::ProcessData(byte *outString, const byte *inString, size_t length) +void PublicBlumBlumShub::ProcessData(::byte *outString, const ::byte *inString, size_t length) { while (length--) *outString++ = *inString++ ^ PublicBlumBlumShub::GenerateByte(); diff --git a/blumshub.h b/blumshub.h index 54fbc0f0..f99658c7 100644 --- a/blumshub.h +++ b/blumshub.h @@ -23,9 +23,9 @@ public: PublicBlumBlumShub(const Integer &n, const Integer &seed); unsigned int GenerateBit(); - byte GenerateByte(); - void GenerateBlock(byte *output, size_t size); - void ProcessData(byte *outString, const byte *inString, size_t length); + ::byte GenerateByte(); + void GenerateBlock(::byte *output, size_t size); + void ProcessData(::byte *outString, const ::byte *inString, size_t length); bool IsSelfInverting() const {return true;} bool IsForwardTransformation() const {return true;} diff --git a/camellia.cpp b/camellia.cpp index da48caa6..8a6c57f1 100644 --- a/camellia.cpp +++ b/camellia.cpp @@ -66,7 +66,7 @@ NAMESPACE_BEGIN(CryptoPP) #define EFI(i) (i) #endif -void Camellia::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs &) +void Camellia::Base::UncheckedSetKey(const ::byte *key, unsigned int keylen, const NameValuePairs &) { m_rounds = (keylen >= 24) ? 4 : 3; unsigned int kslen = (8 * m_rounds + 2); @@ -81,7 +81,7 @@ void Camellia::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const getBlock(kl0)(kl1)(kl2)(kl3); word32 k0=kl0, k1=kl1, k2=kl2, k3=kl3; -#define CALC_ADDR2(base, i, j) ((byte *)(base)+8*(i)+4*(j)+((-16*(i))&m)) +#define CALC_ADDR2(base, i, j) ((::byte *)(base)+8*(i)+4*(j)+((-16*(i))&m)) #define CALC_ADDR(base, i) CALC_ADDR2(base, i, 0) #if 1 @@ -197,7 +197,7 @@ void Camellia::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const } } -void Camellia::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Camellia::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { #define KS(i, j) ks[i*4 + EFI(j/2)*2 + EFI(j%2)] @@ -250,7 +250,7 @@ void Camellia::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBloc // The Camellia s-boxes CRYPTOPP_ALIGN_DATA(4) -const byte Camellia::Base::s1[256] = +const ::byte Camellia::Base::s1[256] = { 112,130,44,236,179,39,192,229,228,133,87,53,234,12,174,65, 35,239,107,147,69,25,165,33,237,14,79,78,29,101,146,189, diff --git a/camellia.h b/camellia.h index 88d6b659..3f7be1d4 100644 --- a/camellia.h +++ b/camellia.h @@ -27,11 +27,11 @@ class Camellia : public Camellia_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *key, unsigned int keylen, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; protected: - CRYPTOPP_ALIGN_DATA(4) static const byte s1[256]; + CRYPTOPP_ALIGN_DATA(4) static const ::byte s1[256]; static const word32 SP[4][256]; unsigned int m_rounds; diff --git a/cast.cpp b/cast.cpp index 010fef04..55b358b4 100644 --- a/cast.cpp +++ b/cast.cpp @@ -33,7 +33,7 @@ NAMESPACE_BEGIN(CryptoPP) typedef BlockGetAndPut Block; -void CAST128::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void CAST128::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 t, l, r; @@ -63,7 +63,7 @@ void CAST128::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, Block::Put(xorBlock, outBlock)(r)(l); } -void CAST128::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void CAST128::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 t, l, r; @@ -94,7 +94,7 @@ void CAST128::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, t = l = r = 0; } -void CAST128::Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &) +void CAST128::Base::UncheckedSetKey(const ::byte *userKey, unsigned int keylength, const NameValuePairs &) { AssertValidKeyLength(keylength); @@ -211,7 +211,7 @@ const unsigned int CAST256::Base::t_r[8][24]={ /* CAST256's encrypt/decrypt functions are identical except for the order that the keys are used */ -void CAST256::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void CAST256::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 t, block[4]; Block::Get(inBlock)(block[0])(block[1])(block[2])(block[3]); @@ -251,7 +251,7 @@ void CAST256::Base::Omega(int i, word32 kappa[8]) f2(kappa[7],kappa[0],t_m[7][i],t_r[7][i]); } -void CAST256::Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &) +void CAST256::Base::UncheckedSetKey(const ::byte *userKey, unsigned int keylength, const NameValuePairs &) { AssertValidKeyLength(keylength); diff --git a/cast.h b/cast.h index 32561c85..1b1d3777 100644 --- a/cast.h +++ b/cast.h @@ -36,7 +36,7 @@ class CAST128 : public CAST128_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: bool reduced; @@ -48,7 +48,7 @@ class CAST128 : public CAST128_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 @@ -56,7 +56,7 @@ class CAST128 : public CAST128_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: @@ -81,8 +81,8 @@ class CAST256 : public CAST256_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; protected: static const word32 t_m[8][24]; diff --git a/cbcmac.cpp b/cbcmac.cpp index b0c46de2..c2fa1aae 100644 --- a/cbcmac.cpp +++ b/cbcmac.cpp @@ -6,14 +6,14 @@ NAMESPACE_BEGIN(CryptoPP) -void CBC_MAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) +void CBC_MAC_Base::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { AccessCipher().SetKey(key, length, params); m_reg.CleanNew(AccessCipher().BlockSize()); m_counter = 0; } -void CBC_MAC_Base::Update(const byte *input, size_t length) +void CBC_MAC_Base::Update(const ::byte *input, size_t length) { unsigned int blockSize = AccessCipher().BlockSize(); @@ -40,7 +40,7 @@ void CBC_MAC_Base::Update(const byte *input, size_t length) } } -void CBC_MAC_Base::TruncatedFinal(byte *mac, size_t size) +void CBC_MAC_Base::TruncatedFinal(::byte *mac, size_t size) { ThrowIfInvalidTruncatedSize(size); diff --git a/cbcmac.h b/cbcmac.h index 985a34d1..53505b8d 100644 --- a/cbcmac.h +++ b/cbcmac.h @@ -18,9 +18,9 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_MAC_Base : public MessageAuthenticatio public: CBC_MAC_Base() : m_counter(0) {} - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); - void Update(const byte *input, size_t length); - void TruncatedFinal(byte *mac, size_t size); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); + void Update(const ::byte *input, size_t length); + void TruncatedFinal(::byte *mac, size_t size); unsigned int DigestSize() const {return const_cast(this)->AccessCipher().BlockSize();} protected: @@ -41,7 +41,7 @@ class CBC_MAC : public MessageAuthenticationCodeImpl >, { public: CBC_MAC() {} - CBC_MAC(const byte *key, size_t length=SameKeyLengthAs::DEFAULT_KEYLENGTH) + CBC_MAC(const ::byte *key, size_t length=SameKeyLengthAs::DEFAULT_KEYLENGTH) {this->SetKey(key, length);} static std::string StaticAlgorithmName() {return std::string("CBC-MAC(") + T::StaticAlgorithmName() + ")";} diff --git a/ccm.cpp b/ccm.cpp index 0d40397e..1490136e 100644 --- a/ccm.cpp +++ b/ccm.cpp @@ -8,7 +8,7 @@ NAMESPACE_BEGIN(CryptoPP) -void CCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms) +void CCM_Base::SetKeyWithoutResync(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms) { BlockCipher &blockCipher = AccessBlockCipher(); @@ -25,7 +25,7 @@ void CCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const m_L = 8; } -void CCM_Base::Resync(const byte *iv, size_t len) +void CCM_Base::Resync(const ::byte *iv, size_t len) { BlockCipher &cipher = AccessBlockCipher(); @@ -34,7 +34,7 @@ void CCM_Base::Resync(const byte *iv, size_t len) if (m_L > 8) m_L = 8; - m_buffer[0] = byte(m_L-1); // flag + m_buffer[0] = ::byte(m_L-1); // flag memcpy(m_buffer+1, iv, len); memset(m_buffer+1+len, 0, REQUIRED_BLOCKSIZE-1-len); @@ -56,10 +56,10 @@ void CCM_Base::UncheckedSpecifyDataLengths(lword headerLength, lword messageLeng m_aadLength = headerLength; m_messageLength = messageLength; - byte *cbcBuffer = CBC_Buffer(); + ::byte *cbcBuffer = CBC_Buffer(); const BlockCipher &cipher = GetBlockCipher(); - cbcBuffer[0] = byte(64*(headerLength>0) + 8*((m_digestSize-2)/2) + (m_L-1)); // flag + cbcBuffer[0] = ::byte(64*(headerLength>0) + 8*((m_digestSize-2)/2) + (m_L-1)); // flag PutWord(true, BIG_ENDIAN_ORDER, cbcBuffer+REQUIRED_BLOCKSIZE-8, m_messageLength); memcpy(cbcBuffer+1, m_buffer+1, REQUIRED_BLOCKSIZE-1-m_L); cipher.ProcessBlock(cbcBuffer); @@ -90,16 +90,16 @@ void CCM_Base::UncheckedSpecifyDataLengths(lword headerLength, lword messageLeng } } -size_t CCM_Base::AuthenticateBlocks(const byte *data, size_t len) +size_t CCM_Base::AuthenticateBlocks(const ::byte *data, size_t len) { - byte *cbcBuffer = CBC_Buffer(); + ::byte *cbcBuffer = CBC_Buffer(); const BlockCipher &cipher = GetBlockCipher(); return cipher.AdvancedProcessBlocks(cbcBuffer, data, cbcBuffer, len, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput); } void CCM_Base::AuthenticateLastHeaderBlock() { - byte *cbcBuffer = CBC_Buffer(); + ::byte *cbcBuffer = CBC_Buffer(); const BlockCipher &cipher = GetBlockCipher(); if (m_aadLength != m_totalHeaderLength) @@ -115,7 +115,7 @@ void CCM_Base::AuthenticateLastHeaderBlock() void CCM_Base::AuthenticateLastConfidentialBlock() { - byte *cbcBuffer = CBC_Buffer(); + ::byte *cbcBuffer = CBC_Buffer(); const BlockCipher &cipher = GetBlockCipher(); if (m_messageLength != m_totalMessageLength) @@ -129,7 +129,7 @@ void CCM_Base::AuthenticateLastConfidentialBlock() } } -void CCM_Base::AuthenticateLastFooterBlock(byte *mac, size_t macSize) +void CCM_Base::AuthenticateLastFooterBlock(::byte *mac, size_t macSize) { m_ctr.Seek(0); m_ctr.ProcessData(mac, CBC_Buffer(), macSize); diff --git a/ccm.h b/ccm.h index 1b94c064..37f5a64f 100644 --- a/ccm.h +++ b/ccm.h @@ -61,19 +61,19 @@ protected: {return true;} unsigned int AuthenticationBlockSize() const {return GetBlockCipher().BlockSize();} - void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms); - void Resync(const byte *iv, size_t len); - size_t AuthenticateBlocks(const byte *data, size_t len); + void SetKeyWithoutResync(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms); + void Resync(const ::byte *iv, size_t len); + size_t AuthenticateBlocks(const ::byte *data, size_t len); void AuthenticateLastHeaderBlock(); void AuthenticateLastConfidentialBlock(); - void AuthenticateLastFooterBlock(byte *mac, size_t macSize); + void AuthenticateLastFooterBlock(::byte *mac, size_t macSize); SymmetricCipher & AccessSymmetricCipher() {return m_ctr;} virtual BlockCipher & AccessBlockCipher() =0; virtual int DefaultDigestSize() const =0; const BlockCipher & GetBlockCipher() const {return const_cast(this)->AccessBlockCipher();}; - byte *CBC_Buffer() {return m_buffer+REQUIRED_BLOCKSIZE;} + ::byte *CBC_Buffer() {return m_buffer+REQUIRED_BLOCKSIZE;} enum {REQUIRED_BLOCKSIZE = 16}; int m_digestSize, m_L; diff --git a/chacha.cpp b/chacha.cpp index 28e3d4c6..c8b7cb67 100644 --- a/chacha.cpp +++ b/chacha.cpp @@ -27,7 +27,7 @@ void ChaCha_TestInstantiations() #endif template -void ChaCha_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) +void ChaCha_Policy::CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length) { CRYPTOPP_UNUSED(params); CRYPTOPP_ASSERT(length == 16 || length == 32); @@ -46,7 +46,7 @@ void ChaCha_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *ke } template -void ChaCha_Policy::CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length) +void ChaCha_Policy::CipherResynchronize(::byte *keystreamBuffer, const ::byte *IV, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(length==8); @@ -92,7 +92,7 @@ unsigned int ChaCha_Policy::GetOptimalBlockSize() const } template -void ChaCha_Policy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) +void ChaCha_Policy::OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount) { word32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; diff --git a/chacha.h b/chacha.h index b07031b7..da739ce7 100644 --- a/chacha.h +++ b/chacha.h @@ -38,9 +38,9 @@ class CRYPTOPP_NO_VTABLE ChaCha_Policy : public AdditiveCipherConcretePolicy::ROUNDS) - void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); - void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); - void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length); + void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length); + void OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount); + void CipherResynchronize(::byte *keystreamBuffer, const ::byte *IV, size_t length); bool CipherIsRandomAccess() const {return false;} // TODO void SeekToIteration(lword iterationCount); unsigned int GetAlignment() const; diff --git a/channels.cpp b/channels.cpp index ec7a98a0..da26eb8f 100644 --- a/channels.cpp +++ b/channels.cpp @@ -147,7 +147,7 @@ const std::string & ChannelRouteIterator::Channel() // ChannelSwitch /////////////////// -size_t ChannelSwitch::ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) +size_t ChannelSwitch::ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking) { if (m_blocked) { @@ -231,7 +231,7 @@ bool ChannelSwitch::ChannelMessageSeriesEnd(const std::string &channel, int prop return false; } -byte * ChannelSwitch::ChannelCreatePutSpace(const std::string &channel, size_t &size) +::byte * ChannelSwitch::ChannelCreatePutSpace(const std::string &channel, size_t &size) { m_it.Reset(channel); if (!m_it.End()) @@ -246,7 +246,7 @@ byte * ChannelSwitch::ChannelCreatePutSpace(const std::string &channel, size_t & return NULLPTR; } -size_t ChannelSwitch::ChannelPutModifiable2(const std::string &channel, byte *inString, size_t length, int messageEnd, bool blocking) +size_t ChannelSwitch::ChannelPutModifiable2(const std::string &channel, ::byte *inString, size_t length, int messageEnd, bool blocking) { ChannelRouteIterator it(*this); it.Reset(channel); diff --git a/channels.h b/channels.h index 9af4b461..daaa489b 100644 --- a/channels.h +++ b/channels.h @@ -109,13 +109,13 @@ public: void IsolatedInitialize(const NameValuePairs ¶meters=g_nullNameValuePairs); - size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking); - size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking); + size_t ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking); + size_t ChannelPutModifiable2(const std::string &channel, ::byte *begin, size_t length, int messageEnd, bool blocking); bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true); bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true); - byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); + ::byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); void AddDefaultRoute(BufferedTransformation &destination); void RemoveDefaultRoute(BufferedTransformation &destination); diff --git a/cmac.cpp b/cmac.cpp index 1b56662d..2b2d4a2f 100644 --- a/cmac.cpp +++ b/cmac.cpp @@ -8,13 +8,13 @@ NAMESPACE_BEGIN(CryptoPP) -static void MulU(byte *k, unsigned int length) +static void MulU(::byte *k, unsigned int length) { - byte carry = 0; + ::byte carry = 0; for (int i=length-1; i>=1; i-=2) { - byte carry2 = k[i] >> 7; + ::byte carry2 = k[i] >> 7; k[i] += k[i] + carry; carry = k[i-1] >> 7; k[i-1] += k[i-1] + carry2; @@ -55,7 +55,7 @@ static void MulU(byte *k, unsigned int length) } } -void CMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) +void CMAC_Base::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { BlockCipher &cipher = AccessCipher(); cipher.SetKey(key, length, params); @@ -70,7 +70,7 @@ void CMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const Name MulU(m_reg+2*blockSize, blockSize); } -void CMAC_Base::Update(const byte *input, size_t length) +void CMAC_Base::Update(const ::byte *input, size_t length) { CRYPTOPP_ASSERT((input && length) || !(input || length)); if (!length) @@ -115,7 +115,7 @@ void CMAC_Base::Update(const byte *input, size_t length) CRYPTOPP_ASSERT(m_counter > 0); } -void CMAC_Base::TruncatedFinal(byte *mac, size_t size) +void CMAC_Base::TruncatedFinal(::byte *mac, size_t size) { ThrowIfInvalidTruncatedSize(size); diff --git a/cmac.h b/cmac.h index 60482277..70dd42fb 100644 --- a/cmac.h +++ b/cmac.h @@ -20,9 +20,9 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CMAC_Base : public MessageAuthenticationCo public: CMAC_Base() : m_counter(0) {} - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); - void Update(const byte *input, size_t length); - void TruncatedFinal(byte *mac, size_t size); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); + void Update(const ::byte *input, size_t length); + void TruncatedFinal(::byte *mac, size_t size); unsigned int DigestSize() const {return GetCipher().BlockSize();} unsigned int OptimalBlockSize() const {return GetCipher().BlockSize();} unsigned int OptimalDataAlignment() const {return GetCipher().OptimalDataAlignment();} @@ -52,7 +52,7 @@ public: //! \brief Construct a CMAC //! \param key the MAC key //! \param length the key size, in bytes - CMAC(const byte *key, size_t length=SameKeyLengthAs::DEFAULT_KEYLENGTH) + CMAC(const ::byte *key, size_t length=SameKeyLengthAs::DEFAULT_KEYLENGTH) {this->SetKey(key, length);} static std::string StaticAlgorithmName() {return std::string("CMAC(") + T::StaticAlgorithmName() + ")";} diff --git a/crc.cpp b/crc.cpp index e1b51bb9..9571b950 100644 --- a/crc.cpp +++ b/crc.cpp @@ -156,7 +156,7 @@ CRC32::CRC32() Reset(); } -void CRC32::Update(const byte *s, size_t n) +void CRC32::Update(const ::byte *s, size_t n) { #if (CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE) if (HasCRC32()) @@ -196,7 +196,7 @@ void CRC32::Update(const byte *s, size_t n) m_crc = crc; } -void CRC32::TruncatedFinal(byte *hash, size_t size) +void CRC32::TruncatedFinal(::byte *hash, size_t size) { ThrowIfInvalidTruncatedSize(size); @@ -324,7 +324,7 @@ CRC32C::CRC32C() Reset(); } -void CRC32C::Update(const byte *s, size_t n) +void CRC32C::Update(const ::byte *s, size_t n) { #if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE if (HasSSE4()) @@ -378,7 +378,7 @@ void CRC32C::Update(const byte *s, size_t n) m_crc = crc; } -void CRC32C::TruncatedFinal(byte *hash, size_t size) +void CRC32C::TruncatedFinal(::byte *hash, size_t size) { ThrowIfInvalidTruncatedSize(size); diff --git a/crc.h b/crc.h index 61923d58..d81a8fdd 100644 --- a/crc.h +++ b/crc.h @@ -28,14 +28,14 @@ class CRC32 : public HashTransformation public: CRYPTOPP_CONSTANT(DIGESTSIZE = 4) CRC32(); - 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 "CRC32";} std::string AlgorithmName() const {return StaticAlgorithmName();} - void UpdateByte(byte b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);} - byte GetCrcByte(size_t i) const {return ((byte *)&(m_crc))[i];} + void UpdateByte(::byte b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);} + ::byte GetCrcByte(size_t i) const {return ((::byte *)&(m_crc))[i];} protected: void Reset() {m_crc = CRC32_NEGL;} @@ -53,14 +53,14 @@ class CRC32C : public HashTransformation public: CRYPTOPP_CONSTANT(DIGESTSIZE = 4) CRC32C(); - 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 "CRC32C";} std::string AlgorithmName() const {return StaticAlgorithmName();} - void UpdateByte(byte b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);} - byte GetCrcByte(size_t i) const {return ((byte *)&(m_crc))[i];} + void UpdateByte(::byte b) {m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc);} + ::byte GetCrcByte(size_t i) const {return ((::byte *)&(m_crc))[i];} protected: void Reset() {m_crc = CRC32_NEGL;} diff --git a/cryptlib.cpp b/cryptlib.cpp index 3cac112f..23cf61d9 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -34,7 +34,7 @@ NAMESPACE_BEGIN(CryptoPP) -CRYPTOPP_COMPILE_ASSERT(sizeof(byte) == 1); +CRYPTOPP_COMPILE_ASSERT(sizeof(::byte) == 1); CRYPTOPP_COMPILE_ASSERT(sizeof(word16) == 2); CRYPTOPP_COMPILE_ASSERT(sizeof(word32) == 4); CRYPTOPP_COMPILE_ASSERT(sizeof(word64) == 8); @@ -68,18 +68,18 @@ Algorithm::Algorithm(bool checkSelfTestStatus) } } -void SimpleKeyingInterface::SetKey(const byte *key, size_t length, const NameValuePairs ¶ms) +void SimpleKeyingInterface::SetKey(const ::byte *key, size_t length, const NameValuePairs ¶ms) { this->ThrowIfInvalidKeyLength(length); this->UncheckedSetKey(key, static_cast(length), params); } -void SimpleKeyingInterface::SetKeyWithRounds(const byte *key, size_t length, int rounds) +void SimpleKeyingInterface::SetKeyWithRounds(const ::byte *key, size_t length, int rounds) { SetKey(key, length, MakeParameters(Name::Rounds(), rounds)); } -void SimpleKeyingInterface::SetKeyWithIV(const byte *key, size_t length, const byte *iv, size_t ivLength) +void SimpleKeyingInterface::SetKeyWithIV(const ::byte *key, size_t length, const ::byte *iv, size_t ivLength) { SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, ivLength))); } @@ -96,7 +96,7 @@ void SimpleKeyingInterface::ThrowIfResynchronizable() throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": this object requires an IV"); } -void SimpleKeyingInterface::ThrowIfInvalidIV(const byte *iv) +void SimpleKeyingInterface::ThrowIfInvalidIV(const ::byte *iv) { if (!iv && IVRequirement() == UNPREDICTABLE_RANDOM_IV) throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": this object cannot use a null IV"); @@ -114,10 +114,10 @@ size_t SimpleKeyingInterface::ThrowIfInvalidIVLength(int size) return (size_t)size; } -const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs ¶ms, size_t &size) +const ::byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs ¶ms, size_t &size) { ConstByteArrayParameter ivWithLength; - const byte *iv; + const ::byte *iv; bool found = false; try {found = params.GetValue(Name::IV(), ivWithLength);} @@ -144,12 +144,12 @@ const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs } } -void SimpleKeyingInterface::GetNextIV(RandomNumberGenerator &rng, byte *IV) +void SimpleKeyingInterface::GetNextIV(RandomNumberGenerator &rng, ::byte *IV) { rng.GenerateBlock(IV, IVSize()); } -size_t BlockTransformation::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const +size_t BlockTransformation::AdvancedProcessBlocks(const ::byte *inBlocks, const ::byte *xorBlocks, ::byte *outBlocks, size_t length, word32 flags) const { CRYPTOPP_ASSERT(inBlocks); CRYPTOPP_ASSERT(outBlocks); @@ -188,7 +188,7 @@ size_t BlockTransformation::AdvancedProcessBlocks(const byte *inBlocks, const by } if (flags & BT_InBlockIsCounter) - const_cast(inBlocks)[blockSize-1]++; + const_cast< ::byte *>(inBlocks)[blockSize-1]++; inBlocks += inIncrement; outBlocks += outIncrement; xorBlocks += xorIncrement; @@ -213,7 +213,7 @@ unsigned int HashTransformation::OptimalDataAlignment() const return GetAlignmentOf(); } -void StreamTransformation::ProcessLastBlock(byte *outString, const byte *inString, size_t length) +void StreamTransformation::ProcessLastBlock(::byte *outString, const ::byte *inString, size_t length) { CRYPTOPP_ASSERT(MinLastBlockSize() == 0); // this function should be overridden otherwise @@ -237,7 +237,7 @@ void AuthenticatedSymmetricCipher::SpecifyDataLengths(lword headerLength, lword UncheckedSpecifyDataLengths(headerLength, messageLength, footerLength); } -void AuthenticatedSymmetricCipher::EncryptAndAuthenticate(byte *ciphertext, byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *message, size_t messageLength) +void AuthenticatedSymmetricCipher::EncryptAndAuthenticate(::byte *ciphertext, ::byte *mac, size_t macSize, const ::byte *iv, int ivLength, const ::byte *header, size_t headerLength, const ::byte *message, size_t messageLength) { Resynchronize(iv, ivLength); SpecifyDataLengths(headerLength, messageLength); @@ -246,7 +246,7 @@ void AuthenticatedSymmetricCipher::EncryptAndAuthenticate(byte *ciphertext, byte TruncatedFinal(mac, macSize); } -bool AuthenticatedSymmetricCipher::DecryptAndVerify(byte *message, const byte *mac, size_t macLength, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *ciphertext, size_t ciphertextLength) +bool AuthenticatedSymmetricCipher::DecryptAndVerify(::byte *message, const ::byte *mac, size_t macLength, const ::byte *iv, int ivLength, const ::byte *header, size_t headerLength, const ::byte *ciphertext, size_t ciphertextLength) { Resynchronize(iv, ivLength); SpecifyDataLengths(headerLength, ciphertextLength); @@ -260,9 +260,9 @@ unsigned int RandomNumberGenerator::GenerateBit() return GenerateByte() & 1; } -byte RandomNumberGenerator::GenerateByte() +::byte RandomNumberGenerator::GenerateByte() { - byte b; + ::byte b; GenerateBlock(&b, 1); return b; } @@ -276,7 +276,7 @@ word32 RandomNumberGenerator::GenerateWord32(word32 min, word32 max) do { - GenerateBlock((byte *)&value, sizeof(value)); + GenerateBlock((::byte *)&value, sizeof(value)); value = Crop(value, maxBits); } while (value > range); @@ -295,7 +295,7 @@ word32 RandomNumberGenerator::GenerateWord32(word32 min, word32 max) // RandomNumberGenerator pointer or reference so polymorphism can provide the // proper runtime dispatching. -void RandomNumberGenerator::GenerateBlock(byte *output, size_t size) +void RandomNumberGenerator::GenerateBlock(::byte *output, size_t size) { CRYPTOPP_UNUSED(output), CRYPTOPP_UNUSED(size); @@ -315,7 +315,7 @@ void RandomNumberGenerator::DiscardBytes(size_t n) void RandomNumberGenerator::GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword length) { - FixedSizeSecBlock buffer; + FixedSizeSecBlock< ::byte, 256> buffer; while (length) { size_t len = UnsignedMin(buffer.size(), length); @@ -348,7 +348,7 @@ public: #endif //! \brief An implementation that throws NotImplemented - void GenerateBlock(byte *output, size_t size) + void GenerateBlock(::byte *output, size_t size) { CRYPTOPP_UNUSED(output); CRYPTOPP_UNUSED(size); throw NotImplemented("NullRNG: NullRNG should only be passed to functions that don't need to generate random bytes"); @@ -377,7 +377,7 @@ RandomNumberGenerator & NullRNG() return s_nullRNG; } -bool HashTransformation::TruncatedVerify(const byte *digestIn, size_t digestLength) +bool HashTransformation::TruncatedVerify(const ::byte *digestIn, size_t digestLength) { ThrowIfInvalidTruncatedSize(digestLength); SecByteBlock digest(digestLength); @@ -425,7 +425,7 @@ bool BufferedTransformation::MessageSeriesEnd(int propagation, bool blocking) return IsolatedMessageSeriesEnd(blocking); } -byte * BufferedTransformation::ChannelCreatePutSpace(const std::string &channel, size_t &size) +::byte * BufferedTransformation::ChannelCreatePutSpace(const std::string &channel, size_t &size) { if (channel.empty()) return CreatePutSpace(size); @@ -433,7 +433,7 @@ byte * BufferedTransformation::ChannelCreatePutSpace(const std::string &channel, throw NoChannelSupport(AlgorithmName()); } -size_t BufferedTransformation::ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) +size_t BufferedTransformation::ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking) { if (channel.empty()) return Put2(begin, length, messageEnd, blocking); @@ -441,7 +441,7 @@ size_t BufferedTransformation::ChannelPut2(const std::string &channel, const byt throw NoChannelSupport(AlgorithmName()); } -size_t BufferedTransformation::ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking) +size_t BufferedTransformation::ChannelPutModifiable2(const std::string &channel, ::byte *begin, size_t length, int messageEnd, bool blocking) { if (channel.empty()) return PutModifiable2(begin, length, messageEnd, blocking); @@ -479,12 +479,12 @@ bool BufferedTransformation::AnyRetrievable() const return AttachedTransformation()->AnyRetrievable(); else { - byte b; + ::byte b; return Peek(b) != 0; } } -size_t BufferedTransformation::Get(byte &outByte) +size_t BufferedTransformation::Get(::byte &outByte) { if (AttachedTransformation()) return AttachedTransformation()->Get(outByte); @@ -492,7 +492,7 @@ size_t BufferedTransformation::Get(byte &outByte) return Get(&outByte, 1); } -size_t BufferedTransformation::Get(byte *outString, size_t getMax) +size_t BufferedTransformation::Get(::byte *outString, size_t getMax) { if (AttachedTransformation()) return AttachedTransformation()->Get(outString, getMax); @@ -503,7 +503,7 @@ size_t BufferedTransformation::Get(byte *outString, size_t getMax) } } -size_t BufferedTransformation::Peek(byte &outByte) const +size_t BufferedTransformation::Peek(::byte &outByte) const { if (AttachedTransformation()) return AttachedTransformation()->Peek(outByte); @@ -511,7 +511,7 @@ size_t BufferedTransformation::Peek(byte &outByte) const return Peek(&outByte, 1); } -size_t BufferedTransformation::Peek(byte *outString, size_t peekMax) const +size_t BufferedTransformation::Peek(::byte *outString, size_t peekMax) const { if (AttachedTransformation()) return AttachedTransformation()->Peek(outString, peekMax); @@ -702,7 +702,7 @@ size_t BufferedTransformation::PutWord32(word32 value, ByteOrder order, bool blo size_t BufferedTransformation::PeekWord16(word16 &value, ByteOrder order) const { - byte buf[2] = {0, 0}; + ::byte buf[2] = {0, 0}; size_t len = Peek(buf, 2); if (order) @@ -715,7 +715,7 @@ size_t BufferedTransformation::PeekWord16(word16 &value, ByteOrder order) const size_t BufferedTransformation::PeekWord32(word32 &value, ByteOrder order) const { - byte buf[4] = {0, 0, 0, 0}; + ::byte buf[4] = {0, 0, 0, 0}; size_t len = Peek(buf, 4); if (order) @@ -763,7 +763,7 @@ public: Detach(attachment); } - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { FILTER_BEGIN; m_plaintextQueue.Put(inString, length); @@ -808,7 +808,7 @@ public: Detach(attachment); } - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { FILTER_BEGIN; m_ciphertextQueue.Put(inString, length); @@ -847,21 +847,21 @@ BufferedTransformation * PK_Decryptor::CreateDecryptionFilter(RandomNumberGenera return new PK_DefaultDecryptionFilter(rng, *this, attachment, parameters); } -size_t PK_Signer::Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const +size_t PK_Signer::Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, ::byte *signature) const { member_ptr m(messageAccumulator); return SignAndRestart(rng, *m, signature, false); } -size_t PK_Signer::SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const +size_t PK_Signer::SignMessage(RandomNumberGenerator &rng, const ::byte *message, size_t messageLen, ::byte *signature) const { member_ptr m(NewSignatureAccumulator(rng)); m->Update(message, messageLen); return SignAndRestart(rng, *m, signature, false); } -size_t PK_Signer::SignMessageWithRecovery(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, - const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, byte *signature) const +size_t PK_Signer::SignMessageWithRecovery(RandomNumberGenerator &rng, const ::byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, ::byte *signature) const { member_ptr m(NewSignatureAccumulator(rng)); InputRecoverableMessage(*m, recoverableMessage, recoverableMessageLength); @@ -875,7 +875,7 @@ bool PK_Verifier::Verify(PK_MessageAccumulator *messageAccumulator) const return VerifyAndRestart(*m); } -bool PK_Verifier::VerifyMessage(const byte *message, size_t messageLen, const byte *signature, size_t signatureLength) const +bool PK_Verifier::VerifyMessage(const ::byte *message, size_t messageLen, const ::byte *signature, size_t signatureLength) const { member_ptr m(NewVerificationAccumulator()); InputSignature(*m, signature, signatureLength); @@ -883,15 +883,15 @@ bool PK_Verifier::VerifyMessage(const byte *message, size_t messageLen, const by return VerifyAndRestart(*m); } -DecodingResult PK_Verifier::Recover(byte *recoveredMessage, PK_MessageAccumulator *messageAccumulator) const +DecodingResult PK_Verifier::Recover(::byte *recoveredMessage, PK_MessageAccumulator *messageAccumulator) const { member_ptr m(messageAccumulator); return RecoverAndRestart(recoveredMessage, *m); } -DecodingResult PK_Verifier::RecoverMessage(byte *recoveredMessage, - const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, - const byte *signature, size_t signatureLength) const +DecodingResult PK_Verifier::RecoverMessage(::byte *recoveredMessage, + const ::byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, + const ::byte *signature, size_t signatureLength) const { member_ptr m(NewVerificationAccumulator()); InputSignature(*m, signature, signatureLength); @@ -899,19 +899,19 @@ DecodingResult PK_Verifier::RecoverMessage(byte *recoveredMessage, return RecoverAndRestart(recoveredMessage, *m); } -void SimpleKeyAgreementDomain::GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const +void SimpleKeyAgreementDomain::GenerateKeyPair(RandomNumberGenerator &rng, ::byte *privateKey, ::byte *publicKey) const { GeneratePrivateKey(rng, privateKey); GeneratePublicKey(rng, privateKey, publicKey); } -void AuthenticatedKeyAgreementDomain::GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const +void AuthenticatedKeyAgreementDomain::GenerateStaticKeyPair(RandomNumberGenerator &rng, ::byte *privateKey, ::byte *publicKey) const { GenerateStaticPrivateKey(rng, privateKey); GenerateStaticPublicKey(rng, privateKey, publicKey); } -void AuthenticatedKeyAgreementDomain::GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const +void AuthenticatedKeyAgreementDomain::GenerateEphemeralKeyPair(RandomNumberGenerator &rng, ::byte *privateKey, ::byte *publicKey) const { GenerateEphemeralPrivateKey(rng, privateKey); GenerateEphemeralPublicKey(rng, privateKey, publicKey); diff --git a/cryptlib.h b/cryptlib.h index b855784d..fcbba376 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -564,7 +564,7 @@ public: //! \param length the size of the key, in bytes //! \param params additional initialization parameters that cannot be passed //! directly through the constructor - virtual void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms = g_nullNameValuePairs); + virtual void SetKey(const ::byte *key, size_t length, const NameValuePairs ¶ms = g_nullNameValuePairs); //! \brief Sets or reset the key of this object //! \param key the key to use when keying the object @@ -574,7 +574,7 @@ public: //! \details SetKeyWithRounds() calls SetKey() with a NameValuePairs //! object that only specifies rounds. rounds is an integer parameter, //! and -1 means use the default number of rounds. - void SetKeyWithRounds(const byte *key, size_t length, int rounds); + void SetKeyWithRounds(const ::byte *key, size_t length, int rounds); //! \brief Sets or reset the key of this object //! \param key the key to use when keying the object @@ -584,7 +584,7 @@ public: //! \details SetKeyWithIV() calls SetKey() with a NameValuePairs //! that only specifies IV. The IV is a byte buffer with size ivLength. //! ivLength is an integer parameter, and -1 means use IVSize(). - void SetKeyWithIV(const byte *key, size_t length, const byte *iv, size_t ivLength); + void SetKeyWithIV(const ::byte *key, size_t length, const ::byte *iv, size_t ivLength); //! \brief Sets or reset the key of this object //! \param key the key to use when keying the object @@ -593,7 +593,7 @@ public: //! \details SetKeyWithIV() calls SetKey() with a NameValuePairs() object //! that only specifies iv. iv is a byte buffer, and it must have //! a size IVSize(). - void SetKeyWithIV(const byte *key, size_t length, const byte *iv) + void SetKeyWithIV(const ::byte *key, size_t length, const ::byte *iv) {SetKeyWithIV(key, length, iv, IVSize());} //! \brief Secure IVs requirements as enumerated values. @@ -665,7 +665,7 @@ public: //! \param ivLength the size of the initialization vector, in bytes //! \details Resynchronize() resynchronizes with an IV provided by the caller. ivLength=-1 means use IVSize(). //! \throws NotImplemented() if the object does not support resynchronization - virtual void Resynchronize(const byte *iv, int ivLength=-1) { + virtual void Resynchronize(const ::byte *iv, int ivLength=-1) { CRYPTOPP_UNUSED(iv); CRYPTOPP_UNUSED(ivLength); throw NotImplemented(GetAlgorithm().AlgorithmName() + ": this object doesn't support resynchronization"); } @@ -679,7 +679,7 @@ public: //! before using this object again. //! \details Internally, the base class implementation calls RandomNumberGenerator's GenerateBlock() //! \note This method is not implemented on decryption objects. - virtual void GetNextIV(RandomNumberGenerator &rng, byte *iv); + virtual void GetNextIV(RandomNumberGenerator &rng, ::byte *iv); protected: //! \brief Returns the base class Algorithm @@ -691,7 +691,7 @@ protected: //! \param length the length of the byte buffer //! \param params additional parameters passed as NameValuePairs //! \details key must be at least DEFAULT_KEYLENGTH in length. - virtual void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) =0; + virtual void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) =0; //! \brief Validates the key length //! \param length the size of the keying material, in bytes @@ -712,7 +712,7 @@ protected: //! then the function succeeds. If iv is NULL, then IVRequirement is checked against //! UNPREDICTABLE_RANDOM_IV. If IVRequirement is UNPREDICTABLE_RANDOM_IV, then //! then the function succeeds. Otherwise, an exception is thrown. - void ThrowIfInvalidIV(const byte *iv); + void ThrowIfInvalidIV(const ::byte *iv); //! \brief Validates the IV length //! \param length the size of an IV, in bytes @@ -724,7 +724,7 @@ protected: //! \param size the length of the IV, in bytes //! \return a pointer to the first byte of the IV //! \throws InvalidArgument if the number of rounds are invalid - const byte * GetIVAndThrowIfInvalid(const NameValuePairs ¶ms, size_t &size); + const ::byte * GetIVAndThrowIfInvalid(const NameValuePairs ¶ms, size_t &size); //! \brief Validates the key length //! \param length the size of the keying material, in bytes @@ -751,7 +751,7 @@ public: //! BLOCKSIZE at compile time, or BlockSize() at runtime. //! \note The message can be transformed in-place, or the buffers must \a not overlap //! \sa FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize() - virtual void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0; + virtual void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const =0; //! \brief Encrypt or decrypt a block //! \param inBlock the input message before processing @@ -761,7 +761,7 @@ public: //! Use BLOCKSIZE at compile time, or BlockSize() at runtime. //! \sa FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize() //! \note The message can be transformed in-place, or the buffers must \a not overlap - void ProcessBlock(const byte *inBlock, byte *outBlock) const + void ProcessBlock(const ::byte *inBlock, ::byte *outBlock) const {ProcessAndXorBlock(inBlock, NULLPTR, outBlock);} //! \brief Encrypt or decrypt a block in place @@ -770,7 +770,7 @@ public: //! \details The size of the block is determined by the block cipher and its documentation. //! Use BLOCKSIZE at compile time, or BlockSize() at runtime. //! \sa FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize() - void ProcessBlock(byte *inoutBlock) const + void ProcessBlock(::byte *inoutBlock) const {ProcessAndXorBlock(inoutBlock, NULLPTR, inoutBlock);} //! Provides the block size of the cipher @@ -815,7 +815,7 @@ public: //! \param flags additional flags to control processing //! \details Encrypt and xor multiple blocks according to FlagsForAdvancedProcessBlocks flags. //! \note If BT_InBlockIsCounter is set, then the last byte of inBlocks may be modified. - virtual size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const; + virtual size_t AdvancedProcessBlocks(const ::byte *inBlocks, const ::byte *xorBlocks, ::byte *outBlocks, size_t length, word32 flags) const; //! \brief Provides the direction of the cipher //! \return ENCRYPTION if IsForwardTransformation() is true, DECRYPTION otherwise @@ -860,7 +860,7 @@ public: //! \param inString the input byte buffer //! \param length the size of the input and output byte buffers, in bytes //! \details Either inString == outString, or they must not overlap. - virtual void ProcessData(byte *outString, const byte *inString, size_t length) =0; + virtual void ProcessData(::byte *outString, const ::byte *inString, size_t length) =0; //! \brief Encrypt or decrypt the last block of data //! \param outString the output byte buffer @@ -868,7 +868,7 @@ public: //! \param length the size of the input and output byte buffers, in bytes //! ProcessLastBlock is used when the last block of data is special. //! Currently the only use of this function is CBC-CTS mode. - virtual void ProcessLastBlock(byte *outString, const byte *inString, size_t length); + virtual void ProcessLastBlock(::byte *outString, const ::byte *inString, size_t length); //! \brief Provides the size of the last block //! \returns the minimum size of the last block @@ -880,7 +880,7 @@ public: //! \param inoutString the string to process //! \param length the size of the inoutString, in bytes //! \details Internally, the base class implementation calls ProcessData(). - inline void ProcessString(byte *inoutString, size_t length) + inline void ProcessString(::byte *inoutString, size_t length) {ProcessData(inoutString, inoutString, length);} //! \brief Encrypt or decrypt a string of bytes @@ -888,13 +888,13 @@ public: //! \param inString the input string to process //! \param length the size of the input and output strings, in bytes //! \details Internally, the base class implementation calls ProcessData(). - inline void ProcessString(byte *outString, const byte *inString, size_t length) + inline void ProcessString(::byte *outString, const ::byte *inString, size_t length) {ProcessData(outString, inString, length);} //! \brief Encrypt or decrypt a byte //! \param input the input byte to process //! \details Internally, the base class implementation calls ProcessData() with a size of 1. - inline byte ProcessByte(byte input) + inline ::byte ProcessByte(::byte input) {ProcessData(&input, &input, 1); return input;} //! \brief Determines whether the cipher supports random access @@ -946,7 +946,7 @@ public: //! \brief Updates a hash with additional input //! \param input the additional input as a buffer //! \param length the size of the buffer, in bytes - virtual void Update(const byte *input, size_t length) =0; + virtual void Update(const ::byte *input, size_t length) =0; //! \brief Request space which can be written into by the caller //! \param size the requested size of the buffer @@ -956,14 +956,14 @@ public: //! the array returned to the caller. //! \details The base class implementation sets size to 0 and returns NULL or nullptr. //! \note Some objects, like ArraySink, cannot create a space because its fixed. - virtual byte * CreateUpdateSpace(size_t &size) {size=0; return NULLPTR;} + virtual ::byte * CreateUpdateSpace(size_t &size) {size=0; return NULLPTR;} //! \brief Computes the hash of the current message //! \param digest a pointer to the buffer to receive the hash //! \details Final() restarts the hash for a new message. //! \pre COUNTOF(digest) == DigestSize() or COUNTOF(digest) == HASH::DIGESTSIZE ensures //! the output byte buffer is large enough for the digest. - virtual void Final(byte *digest) + virtual void Final(::byte *digest) {TruncatedFinal(digest, DigestSize());} //! \brief Restart the hash @@ -1006,7 +1006,7 @@ public: //! \details CalculateDigest() restarts the hash for the next message. //! \pre COUNTOF(digest) == DigestSize() or COUNTOF(digest) == HASH::DIGESTSIZE ensures //! the output byte buffer is large enough for the digest. - virtual void CalculateDigest(byte *digest, const byte *input, size_t length) + virtual void CalculateDigest(::byte *digest, const ::byte *input, size_t length) {Update(input, length); Final(digest);} //! \brief Verifies the hash of the current message @@ -1018,7 +1018,7 @@ public: //! \details Verify() restarts the hash for the next message. //! \pre COUNTOF(digest) == DigestSize() or COUNTOF(digest) == HASH::DIGESTSIZE ensures //! the output byte buffer is large enough for the digest. - virtual bool Verify(const byte *digest) + virtual bool Verify(const ::byte *digest) {return TruncatedVerify(digest, DigestSize());} //! \brief Updates the hash with additional input and verifies the hash of the current message @@ -1034,7 +1034,7 @@ public: //! \details VerifyDigest() restarts the hash for the next message. //! \pre COUNTOF(digest) == DigestSize() or COUNTOF(digest) == HASH::DIGESTSIZE ensures //! the output byte buffer is large enough for the digest. - virtual bool VerifyDigest(const byte *digest, const byte *input, size_t length) + virtual bool VerifyDigest(const ::byte *digest, const ::byte *input, size_t length) {Update(input, length); return Verify(digest);} //! \brief Computes the hash of the current message @@ -1042,7 +1042,7 @@ public: //! \param digestSize the size of the truncated digest, in bytes //! \details TruncatedFinal() call Final() and then copies digestSize bytes to digest. //! The hash is restarted the hash for the next message. - virtual void TruncatedFinal(byte *digest, size_t digestSize) =0; + virtual void TruncatedFinal(::byte *digest, size_t digestSize) =0; //! \brief Updates the hash with additional input and computes the hash of the current message //! \param digest a pointer to the buffer to receive the hash @@ -1054,7 +1054,7 @@ public: //! \details CalculateTruncatedDigest() restarts the hash for the next message. //! \pre COUNTOF(digest) == DigestSize() or COUNTOF(digest) == HASH::DIGESTSIZE ensures //! the output byte buffer is large enough for the digest. - virtual void CalculateTruncatedDigest(byte *digest, size_t digestSize, const byte *input, size_t length) + virtual void CalculateTruncatedDigest(::byte *digest, size_t digestSize, const ::byte *input, size_t length) {Update(input, length); TruncatedFinal(digest, digestSize);} //! \brief Verifies the hash of the current message @@ -1067,7 +1067,7 @@ public: //! \details Verify() performs a bitwise compare on the buffers using VerifyBufsEqual(), which is //! a constant time comparison function. digestLength cannot exceed DigestSize(). //! \details TruncatedVerify() restarts the hash for the next message. - virtual bool TruncatedVerify(const byte *digest, size_t digestLength); + virtual bool TruncatedVerify(const ::byte *digest, size_t digestLength); //! \brief Updates the hash with additional input and verifies the hash of the current message //! \param digest a pointer to the buffer of an \a existing hash @@ -1083,7 +1083,7 @@ public: //! \details VerifyTruncatedDigest() restarts the hash for the next message. //! \pre COUNTOF(digest) == DigestSize() or COUNTOF(digest) == HASH::DIGESTSIZE ensures //! the output byte buffer is large enough for the digest. - virtual bool VerifyTruncatedDigest(const byte *digest, size_t digestLength, const byte *input, size_t length) + virtual bool VerifyTruncatedDigest(const ::byte *digest, size_t digestLength, const ::byte *input, size_t length) {Update(input, length); return TruncatedVerify(digest, digestLength);} protected: @@ -1160,12 +1160,12 @@ public: //! \return true if the authenticated encryption succeeded, false otherwise //! \details EncryptAndAuthenticate() encrypts and generates the MAC in one call. The function will truncate MAC if //! macSize < TagSize(). - virtual void EncryptAndAuthenticate(byte *ciphertext, byte *mac, size_t macSize, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *message, size_t messageLength); + virtual void EncryptAndAuthenticate(::byte *ciphertext, ::byte *mac, size_t macSize, const ::byte *iv, int ivLength, const ::byte *header, size_t headerLength, const ::byte *message, size_t messageLength); //! \brief Decrypts and verifies a MAC in one call //! \return true if the MAC is valid and the decoding succeeded, false otherwise //! \details DecryptAndVerify() decrypts and verifies the MAC in one call. The function returns true iff MAC is valid. //! DecryptAndVerify() will assume MAC is truncated if macLength < TagSize(). - virtual bool DecryptAndVerify(byte *message, const byte *mac, size_t macLength, const byte *iv, int ivLength, const byte *header, size_t headerLength, const byte *ciphertext, size_t ciphertextLength); + virtual bool DecryptAndVerify(::byte *message, const ::byte *mac, size_t macLength, const ::byte *iv, int ivLength, const ::byte *header, size_t headerLength, const ::byte *ciphertext, size_t ciphertextLength); //! \brief Provides the name of this algorithm //! \return the standard algorithm name @@ -1198,7 +1198,7 @@ public: //! ability to use additional entropy. //! \details If a derived class does not override IncorporateEntropy(), then the base class throws //! NotImplemented. - virtual void IncorporateEntropy(const byte *input, size_t length) + virtual void IncorporateEntropy(const ::byte *input, size_t length) { CRYPTOPP_UNUSED(input); CRYPTOPP_UNUSED(length); throw NotImplemented("RandomNumberGenerator: IncorporateEntropy not implemented"); @@ -1213,7 +1213,7 @@ public: //! \details Default implementation calls GenerateBlock() with one byte. //! \details All generated values are uniformly distributed over the range specified within the //! the constraints of a particular generator. - virtual byte GenerateByte(); + virtual ::byte GenerateByte(); //! \brief Generate new random bit and return it //! \return a random bit @@ -1239,7 +1239,7 @@ public: //! the constraints of a particular generator. //! \note A derived generator \a must override either GenerateBlock() or //! GenerateIntoBufferedTransformation(). They can override both, or have one call the other. - virtual void GenerateBlock(byte *output, size_t size); + virtual void GenerateBlock(::byte *output, size_t size); //! \brief Generate random bytes into a BufferedTransformation //! \param target the BufferedTransformation object which receives the bytes @@ -1361,7 +1361,7 @@ public: //! \param blocking specifies whether the object should block when processing input. //! \return the number of bytes that remain in the block (i.e., bytes not processed) //! \details Put(byte) calls Put(byte*, size_t). - size_t Put(byte inByte, bool blocking=true) + size_t Put(::byte inByte, bool blocking=true) {return Put(&inByte, 1, blocking);} //! \brief Input a byte buffer for processing @@ -1370,7 +1370,7 @@ public: //! \param blocking specifies whether the object should block when processing input //! \return the number of bytes that remain in the block (i.e., bytes not processed) //! \details Internally, Put() calls Put2(). - size_t Put(const byte *inString, size_t length, bool blocking=true) + size_t Put(const ::byte *inString, size_t length, bool blocking=true) {return Put2(inString, length, 0, blocking);} //! Input a 16-bit word for processing. @@ -1396,7 +1396,7 @@ public: //! \details The base class implementation sets size to 0 and returns NULL. //! \note Some objects, like ArraySink, cannot create a space because its fixed. In the case of //! an ArraySink, the pointer to the array is returned and the size is remaining size. - virtual byte * CreatePutSpace(size_t &size) + virtual ::byte * CreatePutSpace(size_t &size) {size=0; return NULLPTR;} //! \brief Determines whether input can be modified by the callee @@ -1411,7 +1411,7 @@ public: //! \param blocking specifies whether the object should block when processing input //! \return 0 indicates all bytes were processed during the call. Non-0 indicates the //! number of bytes that were \a not processed - size_t PutModifiable(byte *inString, size_t length, bool blocking=true) + size_t PutModifiable(::byte *inString, size_t length, bool blocking=true) {return PutModifiable2(inString, length, 0, blocking);} //! \brief Signals the end of messages to the object @@ -1432,7 +1432,7 @@ public: //! ensure all attached transformations finish processing the message. //! \details propagation count includes this object. Setting propagation to 1 means this //! object only. Setting propagation to -1 means unlimited propagation. - size_t PutMessageEnd(const byte *inString, size_t length, int propagation=-1, bool blocking=true) + size_t PutMessageEnd(const ::byte *inString, size_t length, int propagation=-1, bool blocking=true) {return Put2(inString, length, propagation < 0 ? -1 : propagation+1, blocking);} //! \brief Input multiple bytes for processing @@ -1441,7 +1441,7 @@ public: //! \param messageEnd means how many filters to signal MessageEnd() to, including this one //! \param blocking specifies whether the object should block when processing input //! \details Derived classes must implement Put2(). - virtual size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) =0; + virtual size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) =0; //! \brief Input multiple bytes that may be modified by callee. //! \param inString the byte buffer to process. @@ -1449,7 +1449,7 @@ public: //! \param messageEnd means how many filters to signal MessageEnd() to, including this one. //! \param blocking specifies whether the object should block when processing input. //! \details Internally, PutModifiable2() calls Put2(). - virtual size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking) + virtual size_t PutModifiable2(::byte *inString, size_t length, int messageEnd, bool blocking) {return Put2(inString, length, messageEnd, blocking);} //! \class BlockingInputOnly @@ -1571,21 +1571,21 @@ public: //! \param outByte the 8-bit value to be retrieved //! \return the number of bytes consumed during the call. //! \details Use the return value of Get to detect short reads. - virtual size_t Get(byte &outByte); + virtual size_t Get(::byte &outByte); //! \brief Retrieve a block of bytes //! \param outString a block of bytes //! \param getMax the number of bytes to Get //! \return the number of bytes consumed during the call. //! \details Use the return value of Get to detect short reads. - virtual size_t Get(byte *outString, size_t getMax); + virtual size_t Get(::byte *outString, size_t getMax); //! \brief Peek a 8-bit byte //! \param outByte the 8-bit value to be retrieved //! \return the number of bytes read during the call. //! \details Peek does not remove bytes from the object. Use the return value of //! Get() to detect short reads. - virtual size_t Peek(byte &outByte) const; + virtual size_t Peek(::byte &outByte) const; //! \brief Peek a block of bytes //! \param outString a block of bytes @@ -1593,7 +1593,7 @@ public: //! \return the number of bytes read during the call. //! \details Peek does not remove bytes from the object. Use the return value of //! Get() to detect short reads. - virtual size_t Peek(byte *outString, size_t peekMax) const; + virtual size_t Peek(::byte *outString, size_t peekMax) const; //! \brief Retrieve a 16-bit word //! \param value the 16-bit value to be retrieved @@ -1840,7 +1840,7 @@ public: //! \param blocking specifies whether the object should block when processing input. //! \return 0 indicates all bytes were processed during the call. Non-0 indicates the //! number of bytes that were \a not processed. - size_t ChannelPut(const std::string &channel, byte inByte, bool blocking=true) + size_t ChannelPut(const std::string &channel, ::byte inByte, bool blocking=true) {return ChannelPut(channel, &inByte, 1, blocking);} //! \brief Input a byte buffer for processing on a channel @@ -1850,7 +1850,7 @@ public: //! \param blocking specifies whether the object should block when processing input //! \return 0 indicates all bytes were processed during the call. Non-0 indicates the //! number of bytes that were \a not processed. - size_t ChannelPut(const std::string &channel, const byte *inString, size_t length, bool blocking=true) + size_t ChannelPut(const std::string &channel, const ::byte *inString, size_t length, bool blocking=true) {return ChannelPut2(channel, inString, length, 0, blocking);} //! \brief Input multiple bytes that may be modified by callee on a channel @@ -1860,7 +1860,7 @@ public: //! \param blocking specifies whether the object should block when processing input //! \return 0 indicates all bytes were processed during the call. Non-0 indicates the //! number of bytes that were \a not processed. - size_t ChannelPutModifiable(const std::string &channel, byte *inString, size_t length, bool blocking=true) + size_t ChannelPutModifiable(const std::string &channel, ::byte *inString, size_t length, bool blocking=true) {return ChannelPutModifiable2(channel, inString, length, 0, blocking);} //! \brief Input a 16-bit word for processing on a channel. @@ -1901,7 +1901,7 @@ public: //! \return the number of bytes that remain in the block (i.e., bytes not processed) //! \details propagation count includes this object. Setting propagation to 1 means this //! object only. Setting propagation to -1 means unlimited propagation. - size_t ChannelPutMessageEnd(const std::string &channel, const byte *inString, size_t length, int propagation=-1, bool blocking=true) + size_t ChannelPutMessageEnd(const std::string &channel, const ::byte *inString, size_t length, int propagation=-1, bool blocking=true) {return ChannelPut2(channel, inString, length, propagation < 0 ? -1 : propagation+1, blocking);} //! \brief Request space which can be written into by the caller @@ -1915,7 +1915,7 @@ public: //! \details The base class implementation sets size to 0 and returns NULL. //! \note Some objects, like ArraySink(), cannot create a space because its fixed. In the case of //! an ArraySink(), the pointer to the array is returned and the size is remaining size. - virtual byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); + virtual ::byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); //! \brief Input multiple bytes for processing on a channel. //! \param channel the channel to process the data. @@ -1924,7 +1924,7 @@ public: //! \param messageEnd means how many filters to signal MessageEnd() to, including this one. //! \param blocking specifies whether the object should block when processing input. //! \return the number of bytes that remain in the block (i.e., bytes not processed) - virtual size_t ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking); + virtual size_t ChannelPut2(const std::string &channel, const ::byte *inString, size_t length, int messageEnd, bool blocking); //! \brief Input multiple bytes that may be modified by callee on a channel //! \param channel the channel to process the data @@ -1933,7 +1933,7 @@ public: //! \param messageEnd means how many filters to signal MessageEnd() to, including this one //! \param blocking specifies whether the object should block when processing input //! \return the number of bytes that remain in the block (i.e., bytes not processed) - virtual size_t ChannelPutModifiable2(const std::string &channel, byte *inString, size_t length, int messageEnd, bool blocking); + virtual size_t ChannelPutModifiable2(const std::string &channel, ::byte *inString, size_t length, int messageEnd, bool blocking); //! \brief Flush buffered input and/or output on a channel //! \param channel the channel to flush the data @@ -2009,7 +2009,7 @@ protected: {return propagation != 0 ? propagation - 1 : 0;} private: - byte m_buf[4]; // for ChannelPutWord16 and ChannelPutWord32, to ensure buffer isn't deallocated before non-blocking operation completes + ::byte m_buf[4]; // for ChannelPutWord16 and ChannelPutWord32, to ensure buffer isn't deallocated before non-blocking operation completes }; //! \brief An input discarding BufferedTransformation @@ -2328,8 +2328,8 @@ public: //! byte buffer is large enough. //! \sa PK_Decryptor virtual void Encrypt(RandomNumberGenerator &rng, - const byte *plaintext, size_t plaintextLength, - byte *ciphertext, const NameValuePairs ¶meters = g_nullNameValuePairs) const =0; + const ::byte *plaintext, size_t plaintextLength, + ::byte *ciphertext, const NameValuePairs ¶meters = g_nullNameValuePairs) const =0; //! \brief Create a new encryption filter //! \param rng a RandomNumberGenerator derived class @@ -2363,8 +2363,8 @@ public: //! byte buffer is large enough //! \sa PK_Encryptor virtual DecodingResult Decrypt(RandomNumberGenerator &rng, - const byte *ciphertext, size_t ciphertextLength, - byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const =0; + const ::byte *ciphertext, size_t ciphertextLength, + ::byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const =0; //! \brief Create a new decryption filter //! \param rng a RandomNumberGenerator derived class @@ -2388,7 +2388,7 @@ public: //! \pre COUNTOF(plaintext) == MaxPlaintextLength(ciphertextLength) ensures the output //! byte buffer is large enough //! \sa PK_Encryptor - DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const byte *ciphertext, byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const + DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const ::byte *ciphertext, ::byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const {return Decrypt(rng, ciphertext, FixedCiphertextLength(), plaintext, parameters);} }; @@ -2483,7 +2483,7 @@ public: {throw NotImplemented("PK_MessageAccumulator: DigestSize() should not be called");} //! \warning TruncatedFinal() should not be called on PK_MessageAccumulator - void TruncatedFinal(byte *digest, size_t digestSize) + void TruncatedFinal(::byte *digest, size_t digestSize) { CRYPTOPP_UNUSED(digest); CRYPTOPP_UNUSED(digestSize); throw NotImplemented("PK_MessageAccumulator: TruncatedFinal() should not be called"); @@ -2508,7 +2508,7 @@ public: //! \param messageAccumulator a reference to a PK_MessageAccumulator //! \param recoverableMessage a pointer to the recoverable message part to be signed //! \param recoverableMessageLength the size of the recoverable message part - virtual void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const =0; + virtual void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const ::byte *recoverableMessage, size_t recoverableMessageLength) const =0; //! \brief Sign and delete the messageAccumulator //! \param rng a RandomNumberGenerator derived class @@ -2517,7 +2517,7 @@ public: //! \return actual signature length //! \details Sign() deletes the messageAccumulator, even if an exception is thrown. //! \pre COUNTOF(signature) == MaxSignatureLength() - virtual size_t Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const; + virtual size_t Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, ::byte *signature) const; //! \brief Sign and restart messageAccumulator //! \param rng a RandomNumberGenerator derived class @@ -2526,7 +2526,7 @@ public: //! \param restart flag indicating whether the messageAccumulator should be restarted //! \return actual signature length //! \pre COUNTOF(signature) == MaxSignatureLength() - virtual size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart=true) const =0; + virtual size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, ::byte *signature, bool restart=true) const =0; //! \brief Sign a message //! \param rng a RandomNumberGenerator derived class @@ -2535,7 +2535,7 @@ public: //! \param signature a block of bytes for the signature //! \return actual signature length //! \pre COUNTOF(signature) == MaxSignatureLength() - virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const; + virtual size_t SignMessage(RandomNumberGenerator &rng, const ::byte *message, size_t messageLen, ::byte *signature) const; //! \brief Sign a recoverable message //! \param rng a RandomNumberGenerator derived class @@ -2546,8 +2546,8 @@ public: //! \param signature a block of bytes for the signature //! \return actual signature length //! \pre COUNTOF(signature) == MaxSignatureLength(recoverableMessageLength) - virtual size_t SignMessageWithRecovery(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, - const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, byte *signature) const; + virtual size_t SignMessageWithRecovery(RandomNumberGenerator &rng, const ::byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, ::byte *signature) const; }; //! \class PK_Verifier @@ -2572,7 +2572,7 @@ public: //! \param messageAccumulator a pointer to a PK_MessageAccumulator derived class //! \param signature the signature on the message //! \param signatureLength the size of the signature - virtual void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const =0; + virtual void InputSignature(PK_MessageAccumulator &messageAccumulator, const ::byte *signature, size_t signatureLength) const =0; //! \brief Check whether messageAccumulator contains a valid signature and message //! \param messageAccumulator a pointer to a PK_MessageAccumulator derived class @@ -2592,8 +2592,8 @@ public: //! \param signature a pointer to the signature over the message //! \param signatureLen the size of the signature //! \return true if the signature is valid, false otherwise - virtual bool VerifyMessage(const byte *message, size_t messageLen, - const byte *signature, size_t signatureLen) const; + virtual bool VerifyMessage(const ::byte *message, size_t messageLen, + const ::byte *signature, size_t signatureLen) const; //! \brief Recover a message from its signature //! \param recoveredMessage a pointer to the recoverable message part to be verified @@ -2601,7 +2601,7 @@ public: //! \return the result of the verification operation //! \details Recover() deletes the messageAccumulator, even if an exception is thrown. //! \pre COUNTOF(recoveredMessage) == MaxRecoverableLengthFromSignatureLength(signatureLength) - virtual DecodingResult Recover(byte *recoveredMessage, PK_MessageAccumulator *messageAccumulator) const; + virtual DecodingResult Recover(::byte *recoveredMessage, PK_MessageAccumulator *messageAccumulator) const; //! \brief Recover a message from its signature //! \param recoveredMessage a pointer to the recoverable message part to be verified @@ -2609,7 +2609,7 @@ public: //! \return the result of the verification operation //! \details RecoverAndRestart() restarts the messageAccumulator //! \pre COUNTOF(recoveredMessage) == MaxRecoverableLengthFromSignatureLength(signatureLength) - virtual DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const =0; + virtual DecodingResult RecoverAndRestart(::byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const =0; //! \brief Recover a message from its signature //! \param recoveredMessage a pointer for the recovered message @@ -2619,9 +2619,9 @@ public: //! \param signatureLength the size of the signature //! \return the result of the verification operation //! \pre COUNTOF(recoveredMessage) == MaxRecoverableLengthFromSignatureLength(signatureLength) - virtual DecodingResult RecoverMessage(byte *recoveredMessage, - const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, - const byte *signature, size_t signatureLength) const; + virtual DecodingResult RecoverMessage(::byte *recoveredMessage, + const ::byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, + const ::byte *signature, size_t signatureLength) const; }; //! \class SimpleKeyAgreementDomain @@ -2650,14 +2650,14 @@ public: //! \param rng a RandomNumberGenerator derived class //! \param privateKey a byte buffer for the generated private key in this domain //! \pre COUNTOF(privateKey) == PrivateKeyLength() - virtual void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0; + virtual void GeneratePrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const =0; //! \brief Generate a public key from a private key in this domain //! \param rng a RandomNumberGenerator derived class //! \param privateKey a byte buffer with the previously generated private key //! \param publicKey a byte buffer for the generated public key in this domain //! \pre COUNTOF(publicKey) == PublicKeyLength() - virtual void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0; + virtual void GeneratePublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const =0; //! \brief Generate a private/public key pair //! \param rng a RandomNumberGenerator derived class @@ -2666,7 +2666,7 @@ public: //! \details GenerateKeyPair() is equivalent to calling GeneratePrivateKey() and then GeneratePublicKey(). //! \pre COUNTOF(privateKey) == PrivateKeyLength() //! \pre COUNTOF(publicKey) == PublicKeyLength() - virtual void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const; + virtual void GenerateKeyPair(RandomNumberGenerator &rng, ::byte *privateKey, ::byte *publicKey) const; //! \brief Derive agreed value //! \param agreedValue a byte buffer for the shared secret @@ -2680,7 +2680,7 @@ public: //! \pre COUNTOF(agreedValue) == AgreedValueLength() //! \pre COUNTOF(privateKey) == PrivateKeyLength() //! \pre COUNTOF(otherPublicKey) == PublicKeyLength() - virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0; + virtual bool Agree(::byte *agreedValue, const ::byte *privateKey, const ::byte *otherPublicKey, bool validateOtherPublicKey=true) const =0; }; //! \brief Interface for domains of authenticated key agreement protocols @@ -2708,14 +2708,14 @@ public: //! \param rng a RandomNumberGenerator derived class //! \param privateKey a byte buffer for the generated private key in this domain //! \pre COUNTOF(privateKey) == PrivateStaticKeyLength() - virtual void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0; + virtual void GenerateStaticPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const =0; //! \brief Generate a static public key from a private key in this domain //! \param rng a RandomNumberGenerator derived class //! \param privateKey a byte buffer with the previously generated private key //! \param publicKey a byte buffer for the generated public key in this domain //! \pre COUNTOF(publicKey) == PublicStaticKeyLength() - virtual void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0; + virtual void GenerateStaticPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const =0; //! \brief Generate a static private/public key pair //! \param rng a RandomNumberGenerator derived class @@ -2724,7 +2724,7 @@ public: //! \details GenerateStaticKeyPair() is equivalent to calling GenerateStaticPrivateKey() and then GenerateStaticPublicKey(). //! \pre COUNTOF(privateKey) == PrivateStaticKeyLength() //! \pre COUNTOF(publicKey) == PublicStaticKeyLength() - virtual void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const; + virtual void GenerateStaticKeyPair(RandomNumberGenerator &rng, ::byte *privateKey, ::byte *publicKey) const; //! \brief Provides the size of ephemeral private key //! \return the size of ephemeral private key in this domain @@ -2738,21 +2738,21 @@ public: //! \param rng a RandomNumberGenerator derived class //! \param privateKey a byte buffer for the generated private key in this domain //! \pre COUNTOF(privateKey) == PrivateEphemeralKeyLength() - virtual void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const =0; + virtual void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const =0; //! \brief Generate ephemeral public key //! \param rng a RandomNumberGenerator derived class //! \param privateKey a byte buffer for the generated private key in this domain //! \param publicKey a byte buffer for the generated public key in this domain //! \pre COUNTOF(publicKey) == PublicEphemeralKeyLength() - virtual void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const =0; + virtual void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const =0; //! \brief Generate private/public key pair //! \param rng a RandomNumberGenerator derived class //! \param privateKey a byte buffer for the generated private key in this domain //! \param publicKey a byte buffer for the generated public key in this domain //! \details GenerateEphemeralKeyPair() is equivalent to calling GenerateEphemeralPrivateKey() and then GenerateEphemeralPublicKey() - virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const; + virtual void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, ::byte *privateKey, ::byte *publicKey) const; //! \brief Derive agreed value //! \param agreedValue a byte buffer for the shared secret @@ -2770,9 +2770,9 @@ public: //! \pre COUNTOF(ephemeralPrivateKey) == EphemeralPrivateKeyLength() //! \pre COUNTOF(staticOtherPublicKey) == StaticPublicKeyLength() //! \pre COUNTOF(ephemeralOtherPublicKey) == EphemeralPublicKeyLength() - virtual bool Agree(byte *agreedValue, - const byte *staticPrivateKey, const byte *ephemeralPrivateKey, - const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, + virtual bool Agree(::byte *agreedValue, + const ::byte *staticPrivateKey, const ::byte *ephemeralPrivateKey, + const ::byte *staticOtherPublicKey, const ::byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const =0; }; @@ -2830,10 +2830,10 @@ public: virtual bool OutgoingMessageAvailable() const =0; virtual unsigned int GetOutgoingMessageLength() const =0; - virtual void GetOutgoingMessage(byte *message) =0; + virtual void GetOutgoingMessage(::byte *message) =0; virtual bool LastMessageProcessed() const =0; - virtual void ProcessIncomingMessage(const byte *message, unsigned int messageLength) =0; + virtual void ProcessIncomingMessage(const ::byte *message, unsigned int messageLength) =0; protected: void HandleProtocolError(Exception::ErrorType errorType, const std::string &s) const; @@ -2852,7 +2852,7 @@ public: virtual ~KeyAgreementSession() {} virtual unsigned int GetAgreedValueLength() const =0; - virtual void GetAgreedValue(byte *agreedValue) const =0; + virtual void GetAgreedValue(::byte *agreedValue) const =0; }; class PasswordAuthenticatedKeyAgreementSession : public KeyAgreementSession @@ -2861,9 +2861,9 @@ public: virtual ~PasswordAuthenticatedKeyAgreementSession() {} void InitializePasswordAuthenticatedKeyAgreementSession(RandomNumberGenerator &rng, - const byte *myId, unsigned int myIdLength, - const byte *counterPartyId, unsigned int counterPartyIdLength, - const byte *passwordOrVerifier, unsigned int passwordOrVerifierLength); + const ::byte *myId, unsigned int myIdLength, + const ::byte *counterPartyId, unsigned int counterPartyIdLength, + const ::byte *passwordOrVerifier, unsigned int passwordOrVerifierLength); }; class PasswordAuthenticatedKeyAgreementDomain : public KeyAgreementAlgorithm @@ -2875,8 +2875,8 @@ public: virtual bool ValidateDomainParameters(RandomNumberGenerator &rng) const {return GetCryptoParameters().Validate(rng, 2);} - virtual unsigned int GetPasswordVerifierLength(const byte *password, unsigned int passwordLength) const =0; - virtual void GeneratePasswordVerifier(RandomNumberGenerator &rng, const byte *userId, unsigned int userIdLength, const byte *password, unsigned int passwordLength, byte *verifier) const =0; + virtual unsigned int GetPasswordVerifierLength(const ::byte *password, unsigned int passwordLength) const =0; + virtual void GeneratePasswordVerifier(RandomNumberGenerator &rng, const ::byte *userId, unsigned int userIdLength, const ::byte *password, unsigned int passwordLength, ::byte *verifier) const =0; enum RoleFlags {CLIENT=1, SERVER=2, INITIATOR=4, RESPONDER=8}; diff --git a/datatest.cpp b/datatest.cpp index 2f9bcb5f..5ac33dd9 100644 --- a/datatest.cpp +++ b/datatest.cpp @@ -87,7 +87,7 @@ void RandomizedTransfer(BufferedTransformation &source, BufferedTransformation & { while (source.MaxRetrievable() > (finish ? 0 : 4096)) { - byte buf[4096+64]; + ::byte buf[4096+64]; size_t start = Test::GlobalRNG().GenerateWord32(0, 63); size_t len = Test::GlobalRNG().GenerateWord32(1, UnsignedMin(4096U, 3*source.MaxRetrievable()/2)); len = source.Get(buf+start, len); @@ -131,7 +131,7 @@ void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransfo while (iss >> std::skipws >> std::hex >> value) { value = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, value); - q.Put((const byte *)&value, 8); + q.Put((const ::byte *)&value, 8); } } else @@ -140,7 +140,7 @@ void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransfo while (iss >> std::skipws >> std::hex >> value) { value = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, value); - q.Put((const byte *)&value, 4); + q.Put((const ::byte *)&value, 4); } } goto end; @@ -165,7 +165,7 @@ void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransfo while (repeat--) { - q.Put((const byte *)s2.data(), s2.size()); + q.Put((const ::byte *)s2.data(), s2.size()); RandomizedTransfer(q, target, false); } } @@ -226,7 +226,7 @@ public: { m_temp.clear(); PutDecodedDatumInto(m_data, name, StringSink(m_temp).Ref()); - reinterpret_cast(pValue)->Assign((const byte *)m_temp.data(), m_temp.size(), false); + reinterpret_cast(pValue)->Assign((const ::byte *)m_temp.data(), m_temp.size(), false); } else throw ValueTypeMismatch(name, typeid(std::string), valueType); @@ -306,7 +306,7 @@ void TestSignatureScheme(TestData &v) { TestKeyPairValidAndConsistent(verifier->AccessMaterial(), signer->GetMaterial()); SignatureVerificationFilter verifierFilter(*verifier, NULLPTR, SignatureVerificationFilter::THROW_EXCEPTION); - verifierFilter.Put((const byte *)"abc", 3); + verifierFilter.Put((const ::byte *)"abc", 3); StringSource ss("abc", true, new SignerFilter(Test::GlobalRNG(), *signer, new Redirector(verifierFilter))); } else if (test == "Sign") @@ -425,8 +425,8 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) } else { - encryptor->SetKey((const byte *)key.data(), key.size(), pairs); - decryptor->SetKey((const byte *)key.data(), key.size(), pairs); + encryptor->SetKey((const ::byte *)key.data(), key.size(), pairs); + decryptor->SetKey((const ::byte *)key.data(), key.size(), pairs); } int seek = pairs.GetIntValueWithDefault("Seek", 0); @@ -450,13 +450,13 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) if (test == "EncryptionMCT" || test == "DecryptionMCT") { SymmetricCipher *cipher = encryptor.get(); - SecByteBlock buf((byte *)plaintext.data(), plaintext.size()), keybuf((byte *)key.data(), key.size()); + SecByteBlock buf((::byte *)plaintext.data(), plaintext.size()), keybuf((::byte *)key.data(), key.size()); if (test == "DecryptionMCT") { cipher = decryptor.get(); ciphertext = GetDecodedDatum(v, "Ciphertext"); - buf.Assign((byte *)ciphertext.data(), ciphertext.size()); + buf.Assign((::byte *)ciphertext.data(), ciphertext.size()); } for (int i=0; i<400; i++) @@ -469,7 +469,7 @@ void TestSymmetricCipher(TestData &v, const NameValuePairs &overrideParameters) } encrypted.erase(0, encrypted.size() - keybuf.size()); - xorbuf(keybuf.begin(), (const byte *)encrypted.data(), keybuf.size()); + xorbuf(keybuf.begin(), (const ::byte *)encrypted.data(), keybuf.size()); cipher->SetKey(keybuf, keybuf.size()); } encrypted.assign((char *)buf.begin(), buf.size()); @@ -558,8 +558,8 @@ void TestAuthenticatedSymmetricCipher(TestData &v, const NameValuePairs &overrid member_ptr asc1, asc2; asc1.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); asc2.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); - asc1->SetKey((const byte *)key.data(), key.size(), pairs); - asc2->SetKey((const byte *)key.data(), key.size(), pairs); + asc1->SetKey((const ::byte *)key.data(), key.size(), pairs); + asc2->SetKey((const ::byte *)key.data(), key.size(), pairs); std::string encrypted, decrypted; AuthenticatedEncryptionFilter ef(*asc1, new StringSink(encrypted)); @@ -645,7 +645,7 @@ void TestDigestOrMAC(TestData &v, bool testDigest) mac.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); pHash = mac.get(); std::string key = GetDecodedDatum(v, "Key"); - mac->SetKey((const byte *)key.c_str(), key.size(), pairs); + mac->SetKey((const ::byte *)key.c_str(), key.size(), pairs); } if (test == "Verify" || test == "VerifyTruncated" || test == "NotVerify") @@ -688,10 +688,10 @@ void TestKeyDerivationFunction(TestData &v) kdf.reset(ObjectFactoryRegistry::Registry().CreateObject(name.c_str())); std::string calc; calc.resize(length); - unsigned int ret = kdf->DeriveKey(reinterpret_cast(&calc[0]), calc.size(), - reinterpret_cast(key.data()), key.size(), - reinterpret_cast(salt.data()), salt.size(), - reinterpret_cast(info.data()), info.size()); + unsigned int ret = kdf->DeriveKey(reinterpret_cast< ::byte*>(&calc[0]), calc.size(), + reinterpret_cast(key.data()), key.size(), + reinterpret_cast(salt.data()), salt.size(), + reinterpret_cast(info.data()), info.size()); if(calc != derived || ret != length) SignalTestFailure(); diff --git a/default.cpp b/default.cpp index 8383499f..84af3acb 100644 --- a/default.cpp +++ b/default.cpp @@ -25,13 +25,13 @@ NAMESPACE_BEGIN(CryptoPP) // the amount of entropy in the input string, whichever is smaller. template -static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int iterations) +static void Mash(const ::byte *in, size_t inLen, ::byte *out, size_t outLen, int iterations) { if (BytePrecision(outLen) > 2) throw InvalidArgument("Mash: output legnth too large"); size_t bufSize = RoundUpToMultipleOf(outLen, (size_t)H::DIGESTSIZE); - byte b[2]; + ::byte b[2]; SecByteBlock buf(bufSize); SecByteBlock outBuf(bufSize); H hash; @@ -39,8 +39,8 @@ static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int ite unsigned int i; for(i=0; i> 8); - b[1] = (byte) i; + b[0] = (::byte) (i >> 8); + b[1] = (::byte) i; hash.Update(b, 2); hash.Update(in, inLen); hash.Final(outBuf+i); @@ -51,8 +51,8 @@ static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int ite memcpy(buf, outBuf, bufSize); for (i=0; i> 8); - b[1] = (byte) i; + b[0] = (::byte) (i >> 8); + b[1] = (::byte) i; hash.Update(b, 2); hash.Update(buf, bufSize); hash.Final(outBuf+i); @@ -63,7 +63,7 @@ static void Mash(const byte *in, size_t inLen, byte *out, size_t outLen, int ite } template -static void GenerateKeyIV(const byte *passphrase, size_t passphraseLength, const byte *salt, size_t saltLength, unsigned int iterations, byte *key, byte *IV) +static void GenerateKeyIV(const ::byte *passphrase, size_t passphraseLength, const ::byte *salt, size_t saltLength, unsigned int iterations, ::byte *key, ::byte *IV) { SecByteBlock temp(passphraseLength+saltLength); memcpy(temp, passphrase, passphraseLength); @@ -78,14 +78,14 @@ static void GenerateKeyIV(const byte *passphrase, size_t passphraseLength, const template DataEncryptor::DataEncryptor(const char *passphrase, BufferedTransformation *attachment) - : ProxyFilter(NULLPTR, 0, 0, attachment), m_passphrase((const byte *)passphrase, strlen(passphrase)) + : ProxyFilter(NULLPTR, 0, 0, attachment), m_passphrase((const ::byte *)passphrase, strlen(passphrase)) { CRYPTOPP_COMPILE_ASSERT(SALTLENGTH <= DIGESTSIZE); CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE <= DIGESTSIZE); } template -DataEncryptor::DataEncryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment) +DataEncryptor::DataEncryptor(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment) : ProxyFilter(NULLPTR, 0, 0, attachment), m_passphrase(passphrase, passphraseLength) { CRYPTOPP_COMPILE_ASSERT(SALTLENGTH <= DIGESTSIZE); @@ -93,7 +93,7 @@ DataEncryptor::DataEncryptor(const byte *passphrase, size_t passphras } template -void DataEncryptor::FirstPut(const byte *) +void DataEncryptor::FirstPut(const ::byte *) { SecByteBlock salt(DIGESTSIZE), keyCheck(DIGESTSIZE); H hash; @@ -101,9 +101,9 @@ void DataEncryptor::FirstPut(const byte *) // use hash(passphrase | time | clock) as salt hash.Update(m_passphrase, m_passphrase.size()); time_t t=time(NULLPTR); - hash.Update((byte *)&t, sizeof(t)); + hash.Update((::byte *)&t, sizeof(t)); clock_t c=clock(); - hash.Update((byte *)&c, sizeof(c)); + hash.Update((::byte *)&c, sizeof(c)); hash.Final(salt); // use hash(passphrase | salt) as key check @@ -125,7 +125,7 @@ void DataEncryptor::FirstPut(const byte *) } template -void DataEncryptor::LastPut(const byte *inString, size_t length) +void DataEncryptor::LastPut(const ::byte *inString, size_t length) { CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); m_filter->MessageEnd(); @@ -137,7 +137,7 @@ template DataDecryptor::DataDecryptor(const char *p, BufferedTransformation *attachment, bool throwException) : ProxyFilter(NULLPTR, SALTLENGTH+BLOCKSIZE, 0, attachment) , m_state(WAITING_FOR_KEYCHECK) - , m_passphrase((const byte *)p, strlen(p)) + , m_passphrase((const ::byte *)p, strlen(p)) , m_throwException(throwException) { CRYPTOPP_COMPILE_ASSERT(SALTLENGTH <= DIGESTSIZE); @@ -145,7 +145,7 @@ DataDecryptor::DataDecryptor(const char *p, BufferedTransformation *a } template -DataDecryptor::DataDecryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException) +DataDecryptor::DataDecryptor(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException) : ProxyFilter(NULLPTR, SALTLENGTH+BLOCKSIZE, 0, attachment) , m_state(WAITING_FOR_KEYCHECK) , m_passphrase(passphrase, passphraseLength) @@ -156,13 +156,13 @@ DataDecryptor::DataDecryptor(const byte *passphrase, size_t passphras } template -void DataDecryptor::FirstPut(const byte *inString) +void DataDecryptor::FirstPut(const ::byte *inString) { CheckKey(inString, inString+SALTLENGTH); } template -void DataDecryptor::LastPut(const byte *inString, size_t length) +void DataDecryptor::LastPut(const ::byte *inString, size_t length) { CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); if (m_filter.get() == NULLPTR) @@ -179,7 +179,7 @@ void DataDecryptor::LastPut(const byte *inString, size_t length) } template -void DataDecryptor::CheckKey(const byte *salt, const byte *keyCheck) +void DataDecryptor::CheckKey(const ::byte *salt, const ::byte *keyCheck) { SecByteBlock check(STDMAX((unsigned int)2*BLOCKSIZE, (unsigned int)DIGESTSIZE)); @@ -214,7 +214,7 @@ void DataDecryptor::CheckKey(const byte *salt, const byte *keyCheck) // ******************************************************** template -static MAC* NewDataEncryptorMAC(const byte *passphrase, size_t passphraseLength) +static MAC* NewDataEncryptorMAC(const ::byte *passphrase, size_t passphraseLength) { size_t macKeyLength = MAC::StaticGetValidKeyLength(16); SecByteBlock macKey(macKeyLength); @@ -226,13 +226,13 @@ static MAC* NewDataEncryptorMAC(const byte *passphrase, size_t passphraseLength) template DataEncryptorWithMAC::DataEncryptorWithMAC(const char *passphrase, BufferedTransformation *attachment) : ProxyFilter(NULLPTR, 0, 0, attachment) - , m_mac(NewDataEncryptorMAC((const byte *)passphrase, strlen(passphrase))) + , m_mac(NewDataEncryptorMAC((const ::byte *)passphrase, strlen(passphrase))) { SetFilter(new HashFilter(*m_mac, new DataEncryptor(passphrase), true)); } template -DataEncryptorWithMAC::DataEncryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment) +DataEncryptorWithMAC::DataEncryptorWithMAC(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment) : ProxyFilter(NULLPTR, 0, 0, attachment) , m_mac(NewDataEncryptorMAC(passphrase, passphraseLength)) { @@ -240,7 +240,7 @@ DataEncryptorWithMAC::DataEncryptorWithMAC(const byte *passphrase } template -void DataEncryptorWithMAC::LastPut(const byte *inString, size_t length) +void DataEncryptorWithMAC::LastPut(const ::byte *inString, size_t length) { CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); m_filter->MessageEnd(); @@ -251,14 +251,14 @@ void DataEncryptorWithMAC::LastPut(const byte *inString, size_t l template DataDecryptorWithMAC::DataDecryptorWithMAC(const char *passphrase, BufferedTransformation *attachment, bool throwException) : ProxyFilter(NULLPTR, 0, 0, attachment) - , m_mac(NewDataEncryptorMAC((const byte *)passphrase, strlen(passphrase))) + , m_mac(NewDataEncryptorMAC((const ::byte *)passphrase, strlen(passphrase))) , m_throwException(throwException) { SetFilter(new DataDecryptor(passphrase, m_hashVerifier=new HashVerificationFilter(*m_mac, NULLPTR, HashVerificationFilter::PUT_MESSAGE), throwException)); } template -DataDecryptorWithMAC::DataDecryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException) +DataDecryptorWithMAC::DataDecryptorWithMAC(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException) : ProxyFilter(NULLPTR, 0, 0, attachment) , m_mac(NewDataEncryptorMAC(passphrase, passphraseLength)) , m_throwException(throwException) @@ -279,7 +279,7 @@ bool DataDecryptorWithMAC::CheckLastMAC() const } template -void DataDecryptorWithMAC::LastPut(const byte *inString, size_t length) +void DataDecryptorWithMAC::LastPut(const ::byte *inString, size_t length) { CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); m_filter->MessageEnd(); diff --git a/default.h b/default.h index 56f54c98..53566540 100644 --- a/default.h +++ b/default.h @@ -98,11 +98,11 @@ public: //! \param passphrase a byte string password //! \param passphraseLength the length of the byte string password //! \param attachment a BufferedTransformation to attach to this object - DataEncryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR); + DataEncryptor(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR); protected: - void FirstPut(const byte *); - void LastPut(const byte *inString, size_t length); + void FirstPut(const ::byte *); + void LastPut(const ::byte *inString, size_t length); private: SecByteBlock m_passphrase; @@ -139,19 +139,19 @@ public: //! \param passphraseLength the length of the byte string password //! \param attachment a BufferedTransformation to attach to this object //! \param throwException a flag specifiying whether an Exception should be thrown on error - DataDecryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR, bool throwException=true); + DataDecryptor(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR, bool throwException=true); enum State {WAITING_FOR_KEYCHECK, KEY_GOOD, KEY_BAD}; State CurrentState() const {return m_state;} protected: - void FirstPut(const byte *inString); - void LastPut(const byte *inString, size_t length); + void FirstPut(const ::byte *inString); + void LastPut(const ::byte *inString, size_t length); State m_state; private: - void CheckKey(const byte *salt, const byte *keyCheck); + void CheckKey(const ::byte *salt, const ::byte *keyCheck); SecByteBlock m_passphrase; typename CBC_Mode::Decryption m_cipher; @@ -195,11 +195,11 @@ public: //! \param passphrase a byte string password //! \param passphraseLength the length of the byte string password //! \param attachment a BufferedTransformation to attach to this object - DataEncryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR); + DataEncryptorWithMAC(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR); protected: - void FirstPut(const byte *inString) {CRYPTOPP_UNUSED(inString);} - void LastPut(const byte *inString, size_t length); + void FirstPut(const ::byte *inString) {CRYPTOPP_UNUSED(inString);} + void LastPut(const ::byte *inString, size_t length); private: member_ptr m_mac; @@ -243,14 +243,14 @@ public: //! \param passphraseLength the length of the byte string password //! \param attachment a BufferedTransformation to attach to this object //! \param throwException a flag specifiying whether an Exception should be thrown on error - DataDecryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR, bool throwException=true); + DataDecryptorWithMAC(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR, bool throwException=true); typename DataDecryptor::State CurrentState() const; bool CheckLastMAC() const; protected: - void FirstPut(const byte *inString) {CRYPTOPP_UNUSED(inString);} - void LastPut(const byte *inString, size_t length); + void FirstPut(const ::byte *inString) {CRYPTOPP_UNUSED(inString);} + void LastPut(const ::byte *inString, size_t length); private: member_ptr m_mac; diff --git a/des.cpp b/des.cpp index 7807e752..28b2de1c 100644 --- a/des.cpp +++ b/des.cpp @@ -117,7 +117,7 @@ static inline void FPERM(word32 &left, word32 &right) left = rotrFixed(left^work, 4U); } -void DES::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &) +void DES::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); @@ -237,7 +237,7 @@ namespace { /* permuted choice table (key) */ namespace { - const byte pc1[] = { + const ::byte pc1[] = { 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, @@ -252,14 +252,14 @@ namespace { /* number left rotations of pc1 */ namespace { - const byte totrot[] = { + const ::byte totrot[] = { 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 }; } /* permuted choice key (table) */ namespace { - const byte pc2[] = { + const ::byte pc2[] = { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, @@ -281,16 +281,16 @@ namespace { } /* Set key (initialize key schedule array) */ -void RawDES::RawSetKey(CipherDir dir, const byte *key) +void RawDES::RawSetKey(CipherDir dir, const ::byte *key) { #if (_MSC_VER >= 1600) || (__cplusplus >= 201103L) # define register /* Define to nothing for C++11 and above */ #endif SecByteBlock buffer(56+56+8); - byte *const pc1m=buffer; /* place to modify pc1 into */ - byte *const pcr=pc1m+56; /* place to rotate pc1 into */ - byte *const ks=pcr+56; + ::byte *const pc1m=buffer; /* place to modify pc1 into */ + ::byte *const pcr=pc1m+56; /* place to rotate pc1 into */ + ::byte *const ks=pcr+56; register int i,j,l; int m; @@ -366,7 +366,7 @@ void RawDES::RawProcessBlock(word32 &l_, word32 &r_) const l_ = l; r_ = r; } -void DES_EDE2::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &) +void DES_EDE2::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); @@ -374,7 +374,7 @@ void DES_EDE2::Base::UncheckedSetKey(const byte *userKey, unsigned int length, c m_des2.RawSetKey(ReverseCipherDir(GetCipherDirection()), userKey+8); } -void DES_EDE2::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void DES_EDE2::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 l,r; Block::Get(inBlock)(l)(r); @@ -386,7 +386,7 @@ void DES_EDE2::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBloc Block::Put(xorBlock, outBlock)(r)(l); } -void DES_EDE3::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &) +void DES_EDE3::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); @@ -395,7 +395,7 @@ void DES_EDE3::Base::UncheckedSetKey(const byte *userKey, unsigned int length, c m_des3.RawSetKey(GetCipherDirection(), userKey + (IsForwardTransformation() ? 16 : 0)); } -void DES_EDE3::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void DES_EDE3::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 l,r; Block::Get(inBlock)(l)(r); @@ -409,13 +409,13 @@ void DES_EDE3::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBloc #endif // #ifndef CRYPTOPP_IMPORTS -static inline bool CheckParity(byte b) +static inline bool CheckParity(::byte b) { unsigned int a = b ^ (b >> 4); return ((a ^ (a>>1) ^ (a>>2) ^ (a>>3)) & 1) == 1; } -bool DES::CheckKeyParityBits(const byte *key) +bool DES::CheckKeyParityBits(const ::byte *key) { for (unsigned int i=0; i<8; i++) if (!CheckParity(key[i])) @@ -423,7 +423,7 @@ bool DES::CheckKeyParityBits(const byte *key) return true; } -void DES::CorrectKeyParityBits(byte *key) +void DES::CorrectKeyParityBits(::byte *key) { for (unsigned int i=0; i<8; i++) if (!CheckParity(key[i])) @@ -431,7 +431,7 @@ void DES::CorrectKeyParityBits(byte *key) } // Encrypt or decrypt a block of data in ECB mode -void DES::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void DES::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 l,r; Block::Get(inBlock)(l)(r); @@ -441,7 +441,7 @@ void DES::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by Block::Put(xorBlock, outBlock)(r)(l); } -void DES_XEX3::Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &) +void DES_XEX3::Base::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); @@ -453,7 +453,7 @@ void DES_XEX3::Base::UncheckedSetKey(const byte *key, unsigned int length, const memcpy(m_x3, key + (IsForwardTransformation() ? 16 : 0), BLOCKSIZE); } -void DES_XEX3::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void DES_XEX3::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { xorbuf(outBlock, inBlock, m_x1, BLOCKSIZE); m_des->ProcessAndXorBlock(outBlock, xorBlock, outBlock); diff --git a/des.h b/des.h index 3ef8c837..c6a4cc3b 100644 --- a/des.h +++ b/des.h @@ -16,7 +16,7 @@ NAMESPACE_BEGIN(CryptoPP) class CRYPTOPP_DLL RawDES { public: - void RawSetKey(CipherDir direction, const byte *userKey); + void RawSetKey(CipherDir direction, const ::byte *userKey); void RawProcessBlock(word32 &l, word32 &r) const; protected: @@ -47,15 +47,15 @@ class DES : public DES_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl, public RawDES { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; }; public: //! check DES key parity bits - static bool CheckKeyParityBits(const byte *key); + static bool CheckKeyParityBits(const ::byte *key); //! correct DES key parity bits - static void CorrectKeyParityBits(byte *key); + static void CorrectKeyParityBits(::byte *key); typedef BlockCipherFinal Encryption; typedef BlockCipherFinal Decryption; @@ -79,8 +79,8 @@ class DES_EDE2 : public DES_EDE2_Info, public BlockCipherDocumentation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; protected: RawDES m_des1, m_des2; @@ -109,8 +109,8 @@ class DES_EDE3 : public DES_EDE3_Info, public BlockCipherDocumentation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; protected: RawDES m_des1, m_des2, m_des3; @@ -139,11 +139,11 @@ class DES_XEX3 : public DES_XEX3_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; protected: - FixedSizeSecBlock m_x1, m_x3; + FixedSizeSecBlock< ::byte, BLOCKSIZE> m_x1, m_x3; // VS2005 workaround: calling modules compiled with /clr gets unresolved external symbol DES::Base::ProcessAndXorBlock // if we use DES::Encryption here directly without value_ptr. value_ptr m_des; diff --git a/dh.h b/dh.h index a71897a6..cf95861b 100644 --- a/dh.h +++ b/dh.h @@ -132,7 +132,7 @@ public: //! builds of the library do not provide FIPS validated cryptography, so the code should be //! removed by the optimizer. //! \pre COUNTOF(publicKey) == PublicKeyLength() - void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GeneratePublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const { Base::GeneratePublicKey(rng, privateKey, publicKey); diff --git a/dh2.cpp b/dh2.cpp index 40e6dd50..57f29b76 100644 --- a/dh2.cpp +++ b/dh2.cpp @@ -12,9 +12,9 @@ void DH2_TestInstantiations() } #endif -bool DH2::Agree(byte *agreedValue, - const byte *staticSecretKey, const byte *ephemeralSecretKey, - const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, +bool DH2::Agree(::byte *agreedValue, + const ::byte *staticSecretKey, const ::byte *ephemeralSecretKey, + const ::byte *staticOtherPublicKey, const ::byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey) const { return d1.Agree(agreedValue, staticSecretKey, staticOtherPublicKey, validateStaticOtherPublicKey) diff --git a/dh2.h b/dh2.h index 2163de27..fcf9afc3 100644 --- a/dh2.h +++ b/dh2.h @@ -38,27 +38,27 @@ public: {return d1.PrivateKeyLength();} unsigned int StaticPublicKeyLength() const {return d1.PublicKeyLength();} - void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GenerateStaticPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const {d1.GeneratePrivateKey(rng, privateKey);} - void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GenerateStaticPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const {d1.GeneratePublicKey(rng, privateKey, publicKey);} - void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const + void GenerateStaticKeyPair(RandomNumberGenerator &rng, ::byte *privateKey, ::byte *publicKey) const {d1.GenerateKeyPair(rng, privateKey, publicKey);} unsigned int EphemeralPrivateKeyLength() const {return d2.PrivateKeyLength();} unsigned int EphemeralPublicKeyLength() const {return d2.PublicKeyLength();} - void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const {d2.GeneratePrivateKey(rng, privateKey);} - void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const {d2.GeneratePublicKey(rng, privateKey, publicKey);} - void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const + void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, ::byte *privateKey, ::byte *publicKey) const {d2.GenerateKeyPair(rng, privateKey, publicKey);} - bool Agree(byte *agreedValue, - const byte *staticPrivateKey, const byte *ephemeralPrivateKey, - const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, + bool Agree(::byte *agreedValue, + const ::byte *staticPrivateKey, const ::byte *ephemeralPrivateKey, + const ::byte *staticOtherPublicKey, const ::byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const; protected: diff --git a/dlltest.cpp b/dlltest.cpp index e46ccdd5..08bf2ad8 100644 --- a/dlltest.cpp +++ b/dlltest.cpp @@ -55,14 +55,14 @@ void FIPS140_SampleApplication() std::cout << "2. Re-do power-up self test passed.\n"; // encrypt and decrypt - const byte key[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; - const byte iv[] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef}; - const byte plaintext[] = { // "Now is the time for all " without tailing 0 + const ::byte key[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; + const ::byte iv[] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef}; + const ::byte plaintext[] = { // "Now is the time for all " without tailing 0 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74, 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20, 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20}; - byte ciphertext[24]; - byte decrypted[24]; + ::byte ciphertext[24]; + ::byte decrypted[24]; CFB_FIPS_Mode::Encryption encryption_DES_EDE3_CFB; encryption_DES_EDE3_CFB.SetKeyWithIV(key, sizeof(key), iv); @@ -80,9 +80,9 @@ void FIPS140_SampleApplication() std::cout << "3. DES-EDE3-CFB Encryption/decryption succeeded.\n"; // hash - const byte message[] = {'a', 'b', 'c'}; - const byte expectedDigest[] = {0xA9,0x99,0x3E,0x36,0x47,0x06,0x81,0x6A,0xBA,0x3E,0x25,0x71,0x78,0x50,0xC2,0x6C,0x9C,0xD0,0xD8,0x9D}; - byte digest[20]; + const ::byte message[] = {'a', 'b', 'c'}; + const ::byte expectedDigest[] = {0xA9,0x99,0x3E,0x36,0x47,0x06,0x81,0x6A,0xBA,0x3E,0x25,0x71,0x78,0x50,0xC2,0x6C,0x9C,0xD0,0xD8,0x9D}; + ::byte digest[20]; SHA1 sha; sha.Update(message, 3); @@ -134,7 +134,7 @@ void FIPS140_SampleApplication() std::cout << "6. DSA key encode/decode succeeded.\n"; // sign and verify - byte signature[40]; + ::byte signature[40]; DSA::Signer signer(dsaPrivateKey); CRYPTOPP_ASSERT(signer.SignatureLength() == 40); signer.SignMessage(rng, message, 3, signature); diff --git a/dmac.h b/dmac.h index 1af7e04a..946475c2 100644 --- a/dmac.h +++ b/dmac.h @@ -24,13 +24,13 @@ public: DMAC_Base() : m_subkeylength(0), m_counter(0) {} - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); - void Update(const byte *input, size_t length); - void TruncatedFinal(byte *mac, size_t size); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); + void Update(const ::byte *input, size_t length); + void TruncatedFinal(::byte *mac, size_t size); unsigned int DigestSize() const {return DIGESTSIZE;} private: - byte *GenerateSubKeys(const byte *key, size_t keylength); + ::byte *GenerateSubKeys(const ::byte *key, size_t keylength); size_t m_subkeylength; SecByteBlock m_subkeys; @@ -54,12 +54,12 @@ public: //! \brief Construct a DMAC //! \param key a byte array used to key the cipher //! \param length the size of the byte array, in bytes - DMAC(const byte *key, size_t length=DMAC_Base::DEFAULT_KEYLENGTH) + DMAC(const ::byte *key, size_t length=DMAC_Base::DEFAULT_KEYLENGTH) {this->SetKey(key, length);} }; template -void DMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) +void DMAC_Base::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { m_subkeylength = T::StaticGetValidKeyLength(T::BLOCKSIZE); m_subkeys.resize(2*UnsignedMin((unsigned int)T::BLOCKSIZE, m_subkeylength)); @@ -70,19 +70,19 @@ void DMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const N } template -void DMAC_Base::Update(const byte *input, size_t length) +void DMAC_Base::Update(const ::byte *input, size_t length) { m_mac1.Update(input, length); m_counter = (unsigned int)((m_counter + length) % T::BLOCKSIZE); } template -void DMAC_Base::TruncatedFinal(byte *mac, size_t size) +void DMAC_Base::TruncatedFinal(::byte *mac, size_t size) { ThrowIfInvalidTruncatedSize(size); - byte pad[T::BLOCKSIZE]; - byte padByte = byte(T::BLOCKSIZE-m_counter); + ::byte pad[T::BLOCKSIZE]; + ::byte padByte = ::byte(T::BLOCKSIZE-m_counter); memset(pad, padByte, padByte); m_mac1.Update(pad, padByte); m_mac1.TruncatedFinal(mac, size); @@ -92,7 +92,7 @@ void DMAC_Base::TruncatedFinal(byte *mac, size_t size) } template -byte *DMAC_Base::GenerateSubKeys(const byte *key, size_t keylength) +::byte *DMAC_Base::GenerateSubKeys(const ::byte *key, size_t keylength) { typename T::Encryption cipher(key, keylength); memset(m_subkeys, 0, m_subkeys.size()); diff --git a/drbg.h b/drbg.h index 468b8b1c..97493b07 100644 --- a/drbg.h +++ b/drbg.h @@ -49,7 +49,7 @@ public: //! with at least MINIMUM_ENTROPY entropy. The byte array for input must //! meet NIST SP 800-90B or //! SP 800-90C requirements. - virtual void IncorporateEntropy(const byte *input, size_t length)=0; + virtual void IncorporateEntropy(const ::byte *input, size_t length)=0; //! \brief Update RNG state with additional unpredictable values //! \param entropy the entropy to add to the generator @@ -62,14 +62,14 @@ public: //! MINIMUM_ENTROPY entropy. The byte array for entropy must meet //! NIST SP 800-90B or //!! SP 800-90C requirements. - virtual void IncorporateEntropy(const byte *entropy, size_t entropyLength, const byte* additional, size_t additionaLength)=0; + virtual void IncorporateEntropy(const ::byte *entropy, size_t entropyLength, const ::byte* additional, size_t additionaLength)=0; //! \brief Generate random array of bytes //! \param output the byte buffer //! \param size the length of the buffer, in bytes //! \throws NIST_DRBG::Err if a reseed is required //! \throws NIST_DRBG::Err if the size exceeds MAXIMUM_BYTES_PER_REQUEST - virtual void GenerateBlock(byte *output, size_t size)=0; + virtual void GenerateBlock(::byte *output, size_t size)=0; //! \brief Generate random array of bytes //! \param additional additional input to add to the generator @@ -81,7 +81,7 @@ public: //! \details GenerateBlock() is an overload provided to match NIST requirements. The byte //! array for additional input is optional. If present the additional randomness //! is mixed before generating the output bytes. - virtual void GenerateBlock(const byte* additional, size_t additionaLength, byte *output, size_t size)=0; + virtual void GenerateBlock(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size)=0; //! \brief Provides the security strength //! \returns The security strength of the generator, in bytes @@ -138,10 +138,10 @@ public: virtual unsigned int MaxRequestBeforeReseed() const=0; protected: - virtual void DRBG_Instantiate(const byte* entropy, size_t entropyLength, - const byte* nonce, size_t nonceLength, const byte* personalization, size_t personalizationLength)=0; + virtual void DRBG_Instantiate(const ::byte* entropy, size_t entropyLength, + const ::byte* nonce, size_t nonceLength, const ::byte* personalization, size_t personalizationLength)=0; - virtual void DRBG_Reseed(const byte* entropy, size_t entropyLength, const byte* additional, size_t additionaLength)=0; + virtual void DRBG_Reseed(const ::byte* entropy, size_t entropyLength, const ::byte* additional, size_t additionaLength)=0; }; // ************************************************************* @@ -205,8 +205,8 @@ public: //! Hash_DRBG drbg(entropy, 32, entropy+32, 16); //! drbg.GenerateBlock(result, result.size()); //! - Hash_DRBG(const byte* entropy=NULLPTR, size_t entropyLength=STRENGTH, const byte* nonce=NULLPTR, - size_t nonceLength=0, const byte* personalization=NULLPTR, size_t personalizationLength=0) + Hash_DRBG(const ::byte* entropy=NULLPTR, size_t entropyLength=STRENGTH, const ::byte* nonce=NULLPTR, + size_t nonceLength=0, const ::byte* personalization=NULLPTR, size_t personalizationLength=0) : NIST_DRBG(), m_c(SEEDLENGTH), m_v(SEEDLENGTH), m_reseed(0) { if (entropy != NULLPTR && entropyLength != 0) @@ -222,32 +222,32 @@ public: unsigned int MaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} unsigned int MaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} - void IncorporateEntropy(const byte *input, size_t length) + void IncorporateEntropy(const ::byte *input, size_t length) {return DRBG_Reseed(input, length, NULLPTR, 0);} - void IncorporateEntropy(const byte *entropy, size_t entropyLength, const byte* additional, size_t additionaLength) + void IncorporateEntropy(const ::byte *entropy, size_t entropyLength, const ::byte* additional, size_t additionaLength) {return DRBG_Reseed(entropy, entropyLength, additional, additionaLength);} - void GenerateBlock(byte *output, size_t size) + void GenerateBlock(::byte *output, size_t size) {return Hash_Generate(NULLPTR, 0, output, size);} - void GenerateBlock(const byte* additional, size_t additionaLength, byte *output, size_t size) + void GenerateBlock(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size) {return Hash_Generate(additional, additionaLength, output, size);} protected: // 10.1.1.2 Instantiation of Hash_DRBG (p.39) - void DRBG_Instantiate(const byte* entropy, size_t entropyLength, const byte* nonce, size_t nonceLength, - const byte* personalization, size_t personalizationLength); + void DRBG_Instantiate(const ::byte* entropy, size_t entropyLength, const ::byte* nonce, size_t nonceLength, + const ::byte* personalization, size_t personalizationLength); // 10.1.1.3 Reseeding a Hash_DRBG Instantiation (p.40) - void DRBG_Reseed(const byte* entropy, size_t entropyLength, const byte* additional, size_t additionaLength); + void DRBG_Reseed(const ::byte* entropy, size_t entropyLength, const ::byte* additional, size_t additionaLength); // 10.1.1.4 Generating Pseudorandom Bits Using Hash_DRBG (p.41) - void Hash_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size); + void Hash_Generate(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size); // 10.3.1 Derivation Function Using a Hash Function (Hash_df) (p.49) - void Hash_Update(const byte* input1, size_t inlen1, const byte* input2, size_t inlen2, - const byte* input3, size_t inlen3, const byte* input4, size_t inlen4, byte* output, size_t outlen); + void Hash_Update(const ::byte* input1, size_t inlen1, const ::byte* input2, size_t inlen2, + const ::byte* input3, size_t inlen3, const ::byte* input4, size_t inlen4, ::byte* output, size_t outlen); private: SecByteBlock m_c, m_v; @@ -319,8 +319,8 @@ public: //! HMAC_DRBG drbg(entropy, 32, entropy+32, 16); //! drbg.GenerateBlock(result, result.size()); //! - HMAC_DRBG(const byte* entropy=NULLPTR, size_t entropyLength=STRENGTH, const byte* nonce=NULLPTR, - size_t nonceLength=0, const byte* personalization=NULLPTR, size_t personalizationLength=0) + HMAC_DRBG(const ::byte* entropy=NULLPTR, size_t entropyLength=STRENGTH, const ::byte* nonce=NULLPTR, + size_t nonceLength=0, const ::byte* personalization=NULLPTR, size_t personalizationLength=0) : NIST_DRBG(), m_k(HASH::DIGESTSIZE), m_v(HASH::DIGESTSIZE), m_reseed(0) { if (entropy != NULLPTR && entropyLength != 0) @@ -336,31 +336,31 @@ public: unsigned int MaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} unsigned int MaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} - void IncorporateEntropy(const byte *input, size_t length) + void IncorporateEntropy(const ::byte *input, size_t length) {return DRBG_Reseed(input, length, NULLPTR, 0);} - void IncorporateEntropy(const byte *entropy, size_t entropyLength, const byte* additional, size_t additionaLength) + void IncorporateEntropy(const ::byte *entropy, size_t entropyLength, const ::byte* additional, size_t additionaLength) {return DRBG_Reseed(entropy, entropyLength, additional, additionaLength);} - void GenerateBlock(byte *output, size_t size) + void GenerateBlock(::byte *output, size_t size) {return HMAC_Generate(NULLPTR, 0, output, size);} - void GenerateBlock(const byte* additional, size_t additionaLength, byte *output, size_t size) + void GenerateBlock(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size) {return HMAC_Generate(additional, additionaLength, output, size);} protected: // 10.1.2.3 Instantiation of HMAC_DRBG (p.45) - void DRBG_Instantiate(const byte* entropy, size_t entropyLength, const byte* nonce, size_t nonceLength, - const byte* personalization, size_t personalizationLength); + void DRBG_Instantiate(const ::byte* entropy, size_t entropyLength, const ::byte* nonce, size_t nonceLength, + const ::byte* personalization, size_t personalizationLength); // 10.1.2.4 Reseeding a HMAC_DRBG Instantiation (p.46) - void DRBG_Reseed(const byte* entropy, size_t entropyLength, const byte* additional, size_t additionaLength); + void DRBG_Reseed(const ::byte* entropy, size_t entropyLength, const ::byte* additional, size_t additionaLength); // 10.1.2.5 Generating Pseudorandom Bits Using HMAC_DRBG (p.46) - void HMAC_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size); + void HMAC_Generate(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size); // 10.1.2.2 Derivation Function Using a HMAC Function (HMAC_Update) (p.44) - void HMAC_Update(const byte* input1, size_t inlen1, const byte* input2, size_t inlen2, const byte* input3, size_t inlen3); + void HMAC_Update(const ::byte* input1, size_t inlen1, const ::byte* input2, size_t inlen2, const ::byte* input3, size_t inlen3); private: SecByteBlock m_k, m_v; @@ -376,8 +376,8 @@ private: // 10.1.1.2 Instantiation of Hash_DRBG (p.39) template -void Hash_DRBG::DRBG_Instantiate(const byte* entropy, size_t entropyLength, const byte* nonce, size_t nonceLength, - const byte* personalization, size_t personalizationLength) +void Hash_DRBG::DRBG_Instantiate(const ::byte* entropy, size_t entropyLength, const ::byte* nonce, size_t nonceLength, + const ::byte* personalization, size_t personalizationLength) { // SP 800-90A, 8.6.3: The entropy input shall have entropy that is equal to or greater than the security // strength of the instantiation. Additional entropy may be provided in the nonce or the optional @@ -394,7 +394,7 @@ void Hash_DRBG::DRBG_Instantiate(const byte* entropy CRYPTOPP_ASSERT(nonceLength <= MAXIMUM_NONCE); CRYPTOPP_ASSERT(personalizationLength <= MAXIMUM_PERSONALIZATION); - const byte zero = 0; + const ::byte zero = 0; SecByteBlock t1(SEEDLENGTH), t2(SEEDLENGTH); Hash_Update(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength, NULLPTR, 0, t1, t1.size()); Hash_Update(&zero, 1, t1, t1.size(), NULLPTR, 0, NULLPTR, 0, t2, t2.size()); @@ -405,7 +405,7 @@ void Hash_DRBG::DRBG_Instantiate(const byte* entropy // 10.1.1.3 Reseeding a Hash_DRBG Instantiation (p.40) template -void Hash_DRBG::DRBG_Reseed(const byte* entropy, size_t entropyLength, const byte* additional, size_t additionaLength) +void Hash_DRBG::DRBG_Reseed(const ::byte* entropy, size_t entropyLength, const ::byte* additional, size_t additionaLength) { // SP 800-90A, 8.6.3: The entropy input shall have entropy that is equal to or greater than the security // strength of the instantiation. Additional entropy may be provided in the nonce or the optional @@ -421,7 +421,7 @@ void Hash_DRBG::DRBG_Reseed(const byte* entropy, siz CRYPTOPP_ASSERT(entropyLength <= MAXIMUM_ENTROPY); CRYPTOPP_ASSERT(additionaLength <= MAXIMUM_ADDITIONAL); - const byte zero = 0, one = 1; + const ::byte zero = 0, one = 1; SecByteBlock t1(SEEDLENGTH), t2(SEEDLENGTH); Hash_Update(&one, 1, m_v, m_v.size(), entropy, entropyLength, additional, additionaLength, t1, t1.size()); Hash_Update(&zero, 1, t1, t1.size(), NULLPTR, 0, NULLPTR, 0, t2, t2.size()); @@ -432,7 +432,7 @@ void Hash_DRBG::DRBG_Reseed(const byte* entropy, siz // 10.1.1.4 Generating Pseudorandom Bits Using Hash_DRBG (p.41) template -void Hash_DRBG::Hash_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size) +void Hash_DRBG::Hash_Generate(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size) { // Step 1 if (static_cast(m_reseed) >= static_cast(MaxRequestBeforeReseed())) @@ -449,7 +449,7 @@ void Hash_DRBG::Hash_Generate(const byte* additional if (additional && additionaLength) { HASH hash; - const byte two = 2; + const ::byte two = 2; SecByteBlock w(HASH::DIGESTSIZE); hash.Update(&two, 1); @@ -462,13 +462,13 @@ void Hash_DRBG::Hash_Generate(const byte* additional while (j>=0) { carry = m_v[i] + w[j] + carry; - m_v[i] = static_cast(carry); + m_v[i] = static_cast< ::byte>(carry); i--; j--; carry >>= 8; } while (i>=0) { carry = m_v[i] + carry; - m_v[i] = static_cast(carry); + m_v[i] = static_cast< ::byte>(carry); i--; carry >>= 8; } } @@ -492,7 +492,7 @@ void Hash_DRBG::Hash_Generate(const byte* additional // Steps 4-7 { HASH hash; - const byte three = 3; + const ::byte three = 3; SecByteBlock h(HASH::DIGESTSIZE); hash.Update(&three, 1); @@ -506,9 +506,9 @@ void Hash_DRBG::Hash_Generate(const byte* additional // Using Integer class slows things down by about 8 cpb. // Using word128 and word64 benefits the first loop only by about 2 cpb. #if defined(CRYPTOPP_WORD128_AVAILABLE) - byte* p1 = m_v.begin()+SEEDLENGTH-8; - byte* p2 = m_c.begin()+SEEDLENGTH-8; - byte* p3 = h.begin()+HASH::DIGESTSIZE-8; + ::byte* p1 = m_v.begin()+SEEDLENGTH-8; + ::byte* p2 = m_c.begin()+SEEDLENGTH-8; + ::byte* p3 = h.begin()+HASH::DIGESTSIZE-8; const word64 w1 = GetWord(false, BIG_ENDIAN_ORDER, p1); const word64 w2 = GetWord(false, BIG_ENDIAN_ORDER, p2); @@ -553,14 +553,14 @@ void Hash_DRBG::Hash_Generate(const byte* additional while (j>=0) { carry = m_v[i] + m_c[i] + h[j] + carry; - m_v[i] = static_cast(carry); + m_v[i] = static_cast< ::byte>(carry); i--; j--; carry >>= 8; } while (i>=0) { carry = m_v[i] + m_c[i] + carry; - m_v[i] = static_cast(carry); + m_v[i] = static_cast< ::byte>(carry); i--; carry >>= 8; } @@ -573,17 +573,17 @@ void Hash_DRBG::Hash_Generate(const byte* additional // 10.3.1 Derivation Function Using a Hash Function (Hash_df) (p.49) template -void Hash_DRBG::Hash_Update(const byte* input1, size_t inlen1, const byte* input2, size_t inlen2, - const byte* input3, size_t inlen3, const byte* input4, size_t inlen4, byte* output, size_t outlen) +void Hash_DRBG::Hash_Update(const ::byte* input1, size_t inlen1, const ::byte* input2, size_t inlen2, + const ::byte* input3, size_t inlen3, const ::byte* input4, size_t inlen4, ::byte* output, size_t outlen) { HASH hash; - byte counter = 1; + ::byte counter = 1; word32 bits = ConditionalByteReverse(BIG_ENDIAN_ORDER, static_cast(outlen*8)); while (outlen) { hash.Update(&counter, 1); - hash.Update(reinterpret_cast(&bits), 4); + hash.Update(reinterpret_cast(&bits), 4); if (input1 && inlen1) hash.Update(input1, inlen1); @@ -606,8 +606,8 @@ void Hash_DRBG::Hash_Update(const byte* input1, size // 10.1.2.3 Instantiation of HMAC_DRBG (p.45) template -void HMAC_DRBG::DRBG_Instantiate(const byte* entropy, size_t entropyLength, const byte* nonce, size_t nonceLength, - const byte* personalization, size_t personalizationLength) +void HMAC_DRBG::DRBG_Instantiate(const ::byte* entropy, size_t entropyLength, const ::byte* nonce, size_t nonceLength, + const ::byte* personalization, size_t personalizationLength) { // SP 800-90A, 8.6.3: The entropy input shall have entropy that is equal to or greater than the security // strength of the instantiation. Additional entropy may be provided in the nonce or the optional @@ -624,8 +624,8 @@ void HMAC_DRBG::DRBG_Instantiate(const byte* entropy CRYPTOPP_ASSERT(nonceLength <= MAXIMUM_NONCE); CRYPTOPP_ASSERT(personalizationLength <= MAXIMUM_PERSONALIZATION); - std::fill(m_k.begin(), m_k.begin()+m_k.size(), byte(0)); - std::fill(m_v.begin(), m_v.begin()+m_v.size(), byte(1)); + std::fill(m_k.begin(), m_k.begin()+m_k.size(), ::byte(0)); + std::fill(m_v.begin(), m_v.begin()+m_v.size(), ::byte(1)); HMAC_Update(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength); m_reseed = 1; @@ -633,7 +633,7 @@ void HMAC_DRBG::DRBG_Instantiate(const byte* entropy // 10.1.2.4 Reseeding a HMAC_DRBG Instantiation (p.46) template -void HMAC_DRBG::DRBG_Reseed(const byte* entropy, size_t entropyLength, const byte* additional, size_t additionaLength) +void HMAC_DRBG::DRBG_Reseed(const ::byte* entropy, size_t entropyLength, const ::byte* additional, size_t additionaLength) { // SP 800-90A, 8.6.3: The entropy input shall have entropy that is equal to or greater than the security // strength of the instantiation. Additional entropy may be provided in the nonce or the optional @@ -655,7 +655,7 @@ void HMAC_DRBG::DRBG_Reseed(const byte* entropy, siz // 10.1.2.5 Generating Pseudorandom Bits Using HMAC_DRBG (p.46) template -void HMAC_DRBG::HMAC_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size) +void HMAC_DRBG::HMAC_Generate(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size) { // Step 1 if (static_cast(m_reseed) >= static_cast(MaxRequestBeforeReseed())) @@ -693,9 +693,9 @@ void HMAC_DRBG::HMAC_Generate(const byte* additional // 10.1.2.2 Derivation Function Using a HMAC Function (HMAC_Update) (p.44) template -void HMAC_DRBG::HMAC_Update(const byte* input1, size_t inlen1, const byte* input2, size_t inlen2, const byte* input3, size_t inlen3) +void HMAC_DRBG::HMAC_Update(const ::byte* input1, size_t inlen1, const ::byte* input2, size_t inlen2, const ::byte* input3, size_t inlen3) { - const byte zero = 0, one = 1; + const ::byte zero = 0, one = 1; HMAC hmac; // Step 1 diff --git a/dsa.cpp b/dsa.cpp index 6bc187a9..16b72d56 100644 --- a/dsa.cpp +++ b/dsa.cpp @@ -12,7 +12,7 @@ NAMESPACE_BEGIN(CryptoPP) -size_t DSAConvertSignatureFormat(byte *buffer, size_t bufferSize, DSASignatureFormat toFormat, const byte *signature, size_t signatureLen, DSASignatureFormat fromFormat) +size_t DSAConvertSignatureFormat(::byte *buffer, size_t bufferSize, DSASignatureFormat toFormat, const ::byte *signature, size_t signatureLen, DSASignatureFormat fromFormat) { Integer r, s; StringStore store(signature, signatureLen); diff --git a/dsa.h b/dsa.h index 8ea4773f..f652fc14 100644 --- a/dsa.h +++ b/dsa.h @@ -34,8 +34,8 @@ enum DSASignatureFormat { //! of signature in the target format. If toFormat == DSA_P1363, then //! bufferSize must equal publicKey.SignatureLength() //! \since Crypto++ 1.0 -size_t DSAConvertSignatureFormat(byte *buffer, size_t bufferSize, DSASignatureFormat toFormat, - const byte *signature, size_t signatureLen, DSASignatureFormat fromFormat); +size_t DSAConvertSignatureFormat(::byte *buffer, size_t bufferSize, DSASignatureFormat toFormat, + const ::byte *signature, size_t signatureLen, DSASignatureFormat fromFormat); NAMESPACE_END diff --git a/eax.cpp b/eax.cpp index ef4f2a9f..99e09acb 100644 --- a/eax.cpp +++ b/eax.cpp @@ -5,13 +5,13 @@ NAMESPACE_BEGIN(CryptoPP) -void EAX_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms) +void EAX_Base::SetKeyWithoutResync(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms) { AccessMAC().SetKey(userKey, keylength, params); m_buffer.New(2*AccessMAC().TagSize()); } -void EAX_Base::Resync(const byte *iv, size_t len) +void EAX_Base::Resync(const ::byte *iv, size_t len) { MessageAuthenticationCode &mac = AccessMAC(); unsigned int blockSize = mac.TagSize(); @@ -26,7 +26,7 @@ void EAX_Base::Resync(const byte *iv, size_t len) m_ctr.SetCipherWithIV(AccessMAC().AccessCipher(), m_buffer+blockSize, blockSize); } -size_t EAX_Base::AuthenticateBlocks(const byte *data, size_t len) +size_t EAX_Base::AuthenticateBlocks(const ::byte *data, size_t len) { AccessMAC().Update(data, len); return 0; @@ -46,7 +46,7 @@ void EAX_Base::AuthenticateLastHeaderBlock() mac.Update(m_buffer, blockSize); } -void EAX_Base::AuthenticateLastFooterBlock(byte *tag, size_t macSize) +void EAX_Base::AuthenticateLastFooterBlock(::byte *tag, size_t macSize) { CRYPTOPP_ASSERT(m_bufferedDataLength == 0); MessageAuthenticationCode &mac = AccessMAC(); diff --git a/eax.h b/eax.h index fd02c5ca..fa3f8075 100644 --- a/eax.h +++ b/eax.h @@ -55,11 +55,11 @@ protected: {return false;} unsigned int AuthenticationBlockSize() const {return 1;} - void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms); - void Resync(const byte *iv, size_t len); - size_t AuthenticateBlocks(const byte *data, size_t len); + void SetKeyWithoutResync(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms); + void Resync(const ::byte *iv, size_t len); + size_t AuthenticateBlocks(const ::byte *data, size_t len); void AuthenticateLastHeaderBlock(); - void AuthenticateLastFooterBlock(byte *mac, size_t macSize); + void AuthenticateLastFooterBlock(::byte *mac, size_t macSize); SymmetricCipher & AccessSymmetricCipher() {return m_ctr;} const CMAC_Base & GetMAC() const {return const_cast(this)->AccessMAC();} virtual CMAC_Base & AccessMAC() =0; diff --git a/ec2n.cpp b/ec2n.cpp index 3b6cf2a2..97dfc84e 100644 --- a/ec2n.cpp +++ b/ec2n.cpp @@ -38,7 +38,7 @@ void EC2N::DEREncode(BufferedTransformation &bt) const seq.MessageEnd(); } -bool EC2N::DecodePoint(EC2N::Point &P, const byte *encodedPoint, size_t encodedPointLen) const +bool EC2N::DecodePoint(EC2N::Point &P, const ::byte *encodedPoint, size_t encodedPointLen) const { StringStore store(encodedPoint, encodedPointLen); return DecodePoint(P, store, encodedPointLen); @@ -46,7 +46,7 @@ bool EC2N::DecodePoint(EC2N::Point &P, const byte *encodedPoint, size_t encodedP bool EC2N::DecodePoint(EC2N::Point &P, BufferedTransformation &bt, size_t encodedPointLen) const { - byte type; + ::byte type; if (encodedPointLen < 1 || !bt.Get(type)) return false; @@ -115,7 +115,7 @@ void EC2N::EncodePoint(BufferedTransformation &bt, const Point &P, bool compress } } -void EC2N::EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const +void EC2N::EncodePoint(::byte *encodedPoint, const Point &P, bool compressed) const { ArraySink sink(encodedPoint, EncodedPointSize(compressed)); EncodePoint(sink, P, compressed); diff --git a/ec2n.h b/ec2n.h index cc4c0462..636373f4 100644 --- a/ec2n.h +++ b/ec2n.h @@ -73,8 +73,8 @@ public: {return 1 + (compressed?1:2)*m_field->MaxElementByteLength();} // returns false if point is compressed and not valid (doesn't check if uncompressed) bool DecodePoint(Point &P, BufferedTransformation &bt, size_t len) const; - bool DecodePoint(Point &P, const byte *encodedPoint, size_t len) const; - void EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const; + bool DecodePoint(Point &P, const ::byte *encodedPoint, size_t len) const; + void EncodePoint(::byte *encodedPoint, const Point &P, bool compressed) const; void EncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const; Point BERDecodePoint(BufferedTransformation &bt) const; diff --git a/eccrypto.cpp b/eccrypto.cpp index 92106052..96970ae1 100644 --- a/eccrypto.cpp +++ b/eccrypto.cpp @@ -520,7 +520,7 @@ void DL_GroupParameters_EC::GenerateRandom(RandomNumberGenerator &rng, const template void DL_GroupParameters_EC::BERDecode(BufferedTransformation &bt) { - byte b; + ::byte b; if (!bt.Peek(b)) BERDecodeError(); if (b == OBJECT_IDENTIFIER) diff --git a/eccrypto.h b/eccrypto.h index a4bf3e75..26700650 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -103,7 +103,7 @@ public: bool ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const; bool ValidateElement(unsigned int level, const Element &element, const DL_FixedBasePrecomputation *precomp) const; bool FastSubgroupCheckAvailable() const {return false;} - void EncodeElement(bool reversible, const Element &element, byte *encoded) const + void EncodeElement(bool reversible, const Element &element, ::byte *encoded) const { if (reversible) GetCurve().EncodePoint(encoded, element, m_compress); @@ -117,7 +117,7 @@ public: else return GetCurve().GetField().MaxElementByteLength(); } - Element DecodeElement(const byte *encoded, bool checkForGroupMembership) const + Element DecodeElement(const ::byte *encoded, bool checkForGroupMembership) const { Point result; if (!GetCurve().DecodePoint(result, encoded, GetEncodedElementSize(true))) diff --git a/ecp.cpp b/ecp.cpp index 73f66685..94739e28 100644 --- a/ecp.cpp +++ b/ecp.cpp @@ -63,7 +63,7 @@ void ECP::DEREncode(BufferedTransformation &bt) const seq.MessageEnd(); } -bool ECP::DecodePoint(ECP::Point &P, const byte *encodedPoint, size_t encodedPointLen) const +bool ECP::DecodePoint(ECP::Point &P, const ::byte *encodedPoint, size_t encodedPointLen) const { StringStore store(encodedPoint, encodedPointLen); return DecodePoint(P, store, encodedPointLen); @@ -71,7 +71,7 @@ bool ECP::DecodePoint(ECP::Point &P, const byte *encodedPoint, size_t encodedPoi bool ECP::DecodePoint(ECP::Point &P, BufferedTransformation &bt, size_t encodedPointLen) const { - byte type; + ::byte type; if (encodedPointLen < 1 || !bt.Get(type)) return false; @@ -136,7 +136,7 @@ void ECP::EncodePoint(BufferedTransformation &bt, const Point &P, bool compresse } } -void ECP::EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const +void ECP::EncodePoint(::byte *encodedPoint, const Point &P, bool compressed) const { ArraySink sink(encodedPoint, EncodedPointSize(compressed)); EncodePoint(sink, P, compressed); diff --git a/ecp.h b/ecp.h index 082eb636..7510244a 100644 --- a/ecp.h +++ b/ecp.h @@ -80,8 +80,8 @@ public: {return 1 + (compressed?1:2)*GetField().MaxElementByteLength();} // returns false if point is compressed and not valid (doesn't check if uncompressed) bool DecodePoint(Point &P, BufferedTransformation &bt, size_t len) const; - bool DecodePoint(Point &P, const byte *encodedPoint, size_t len) const; - void EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const; + bool DecodePoint(Point &P, const ::byte *encodedPoint, size_t len) const; + void EncodePoint(::byte *encodedPoint, const Point &P, bool compressed) const; void EncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const; Point BERDecodePoint(BufferedTransformation &bt) const; diff --git a/ecpoint.h b/ecpoint.h index 57f9f55a..bb3a82e4 100644 --- a/ecpoint.h +++ b/ecpoint.h @@ -107,7 +107,7 @@ public: //! \param encodedPoint byte array with the encoded point //! \param len the size of the array //! \returns true if a point was decoded, false otherwise - virtual bool DecodePoint(Point &P, const byte *encodedPoint, size_t len) const =0; + virtual bool DecodePoint(Point &P, const ::byte *encodedPoint, size_t len) const =0; //! \brief Verifies points on elliptic curve //! \param P point to verify @@ -124,7 +124,7 @@ public: //! \param encodedPoint byte array for the encoded point //! \param compressed flag indicating if the point is compressed //! \details encodedPoint must be at least EncodedPointSize() in length - virtual void EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const =0; + virtual void EncodePoint(::byte *encodedPoint, const Point &P, bool compressed) const =0; //! \brief Encodes an elliptic curve point //! \param bt target BufferedTransformation diff --git a/elgamal.h b/elgamal.h index 1b7906c8..d4630209 100644 --- a/elgamal.h +++ b/elgamal.h @@ -26,7 +26,7 @@ class CRYPTOPP_NO_VTABLE ElGamalBase : public DL_KeyAgreementAlgorithm_DH &groupParams, byte *derivedKey, size_t derivedLength, const Integer &agreedElement, const Integer &ephemeralPublicKey, const NameValuePairs &derivationParams) const + void Derive(const DL_GroupParameters &groupParams, ::byte *derivedKey, size_t derivedLength, const Integer &agreedElement, const Integer &ephemeralPublicKey, const NameValuePairs &derivationParams) const { CRYPTOPP_UNUSED(groupParams), CRYPTOPP_UNUSED(ephemeralPublicKey), CRYPTOPP_UNUSED(derivationParams); agreedElement.Encode(derivedKey, derivedLength); @@ -56,7 +56,7 @@ public: return 0; } - void SymmetricEncrypt(RandomNumberGenerator &rng, const byte *key, const byte *plainText, size_t plainTextLength, byte *cipherText, const NameValuePairs ¶meters) const + void SymmetricEncrypt(RandomNumberGenerator &rng, const ::byte *key, const ::byte *plainText, size_t plainTextLength, ::byte *cipherText, const NameValuePairs ¶meters) const { CRYPTOPP_UNUSED(parameters); const Integer &p = GetGroupParameters().GetModulus(); @@ -65,12 +65,12 @@ public: SecByteBlock block(modulusLen-1); rng.GenerateBlock(block, modulusLen-2-plainTextLength); memcpy(block+modulusLen-2-plainTextLength, plainText, plainTextLength); - block[modulusLen-2] = (byte)plainTextLength; + block[modulusLen-2] = (::byte)plainTextLength; a_times_b_mod_c(Integer(key, modulusLen), Integer(block, modulusLen-1), p).Encode(cipherText, modulusLen); } - DecodingResult SymmetricDecrypt(const byte *key, const byte *cipherText, size_t cipherTextLength, byte *plainText, const NameValuePairs ¶meters) const + DecodingResult SymmetricDecrypt(const ::byte *key, const ::byte *cipherText, size_t cipherTextLength, ::byte *plainText, const NameValuePairs ¶meters) const { CRYPTOPP_UNUSED(parameters); const Integer &p = GetGroupParameters().GetModulus(); @@ -107,7 +107,7 @@ public: const DL_GroupParameters_GFP & GetGroupParameters() const {return this->GetKey().GetGroupParameters();} - DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const byte *cipherText, byte *plainText) const + DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const ::byte *cipherText, ::byte *plainText) const {return Decrypt(rng, cipherText, FixedCiphertextLength(), plainText);} protected: diff --git a/emsa2.cpp b/emsa2.cpp index 1cde59c5..890b05f4 100644 --- a/emsa2.cpp +++ b/emsa2.cpp @@ -8,9 +8,9 @@ NAMESPACE_BEGIN(CryptoPP) void EMSA2Pad::ComputeMessageRepresentative(RandomNumberGenerator& /*rng*/, - const byte* recoverableMessage, size_t recoverableMessageLength, + const ::byte* recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const + ::byte *representative, size_t representativeBitLength) const { CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(recoverableMessageLength), CRYPTOPP_UNUSED(representativeBitLength); CRYPTOPP_ASSERT(representativeBitLength >= MinRepresentativeBitLength(hashIdentifier.second, hash.DigestSize())); @@ -23,7 +23,7 @@ void EMSA2Pad::ComputeMessageRepresentative(RandomNumberGenerator& /*rng*/, representative[0] = messageEmpty ? 0x4b : 0x6b; memset(representative+1, 0xbb, representativeByteLength-digestSize-4); // pad with 0xbb - byte *afterP2 = representative+representativeByteLength-digestSize-3; + ::byte *afterP2 = representative+representativeByteLength-digestSize-3; afterP2[0] = 0xba; hash.Final(afterP2+1); representative[representativeByteLength-2] = *hashIdentifier.first; diff --git a/emsa2.h b/emsa2.h index 1ee4b76b..f7d01e1d 100644 --- a/emsa2.h +++ b/emsa2.h @@ -19,7 +19,7 @@ NAMESPACE_BEGIN(CryptoPP) template class EMSA2HashId { public: - static const byte id; + static const ::byte id; }; template @@ -67,9 +67,9 @@ public: {CRYPTOPP_UNUSED(hashIdentifierLength); return 8*digestLength + 31;} void ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const; + ::byte *representative, size_t representativeBitLength) const; }; //! EMSA2, for use with RWSS and RSA_ISO diff --git a/esign.h b/esign.h index dcda42c4..6012972b 100644 --- a/esign.h +++ b/esign.h @@ -126,9 +126,9 @@ public: CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "EMSA5";} void ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const + ::byte *representative, size_t representativeBitLength) const { CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(recoverableMessageLength); CRYPTOPP_UNUSED(messageEmpty), CRYPTOPP_UNUSED(hashIdentifier); @@ -138,7 +138,7 @@ public: T mgf; mgf.GenerateAndMask(hash, representative, representativeByteLength, digest, digest.size(), false); if (representativeBitLength % 8 != 0) - representative[0] = (byte)Crop(representative[0], representativeBitLength % 8); + representative[0] = (::byte)Crop(representative[0], representativeBitLength % 8); } }; diff --git a/fhmqv.h b/fhmqv.h index 49120f02..ff9fd2d7 100644 --- a/fhmqv.h +++ b/fhmqv.h @@ -75,7 +75,7 @@ public: //! generate static private key /*! \pre size of privateKey == PrivateStaticKeyLength() */ - void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GenerateStaticPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const { Integer x(rng, Integer::One(), GetAbstractGroupParameters().GetMaxExponent()); x.Encode(privateKey, StaticPrivateKeyLength()); @@ -83,7 +83,7 @@ public: //! generate static public key /*! \pre size of publicKey == PublicStaticKeyLength() */ - void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GenerateStaticPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const { CRYPTOPP_UNUSED(rng); const DL_GroupParameters ¶ms = GetAbstractGroupParameters(); @@ -96,7 +96,7 @@ public: unsigned int EphemeralPublicKeyLength() const{return StaticPublicKeyLength();} //! return length of ephemeral private keys in this domain - void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const { const DL_GroupParameters ¶ms = GetAbstractGroupParameters(); Integer x(rng, Integer::One(), params.GetMaxExponent()); @@ -106,7 +106,7 @@ public: } //! return length of ephemeral public keys in this domain - void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const { CRYPTOPP_UNUSED(rng); memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength()); @@ -121,12 +121,12 @@ public: \pre length of staticOtherPublicKey == StaticPublicKeyLength() \pre length of ephemeralOtherPublicKey == EphemeralPublicKeyLength() */ - bool Agree(byte *agreedValue, - const byte *staticPrivateKey, const byte *ephemeralPrivateKey, - const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, + bool Agree(::byte *agreedValue, + const ::byte *staticPrivateKey, const ::byte *ephemeralPrivateKey, + const ::byte *staticOtherPublicKey, const ::byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const { - byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; + ::byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; size_t xxs = 0, yys = 0, aas = 0, bbs = 0; // Depending on the role, this will hold either A's or B's static @@ -143,11 +143,11 @@ public: Element B = params.ExponentiateBase(b); params.EncodeElement(true, B, tt); - XX = const_cast(ephemeralOtherPublicKey); + XX = const_cast< ::byte*>(ephemeralOtherPublicKey); xxs = EphemeralPublicKeyLength(); - YY = const_cast(ephemeralPrivateKey) + StaticPrivateKeyLength(); + YY = const_cast< ::byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength(); yys = EphemeralPublicKeyLength(); - AA = const_cast(staticOtherPublicKey); + AA = const_cast< ::byte*>(staticOtherPublicKey); aas = StaticPublicKeyLength(); BB = tt.BytePtr(); bbs = tt.SizeInBytes(); @@ -158,13 +158,13 @@ public: Element A = params.ExponentiateBase(a); params.EncodeElement(true, A, tt); - XX = const_cast(ephemeralPrivateKey) + StaticPrivateKeyLength(); + XX = const_cast< ::byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength(); xxs = EphemeralPublicKeyLength(); - YY = const_cast(ephemeralOtherPublicKey); + YY = const_cast< ::byte*>(ephemeralOtherPublicKey); yys = EphemeralPublicKeyLength(); AA = tt.BytePtr(); aas = tt.SizeInBytes(); - BB = const_cast(staticOtherPublicKey); + BB = const_cast< ::byte*>(staticOtherPublicKey); bbs = StaticPublicKeyLength(); } else @@ -240,9 +240,9 @@ public: protected: inline void Hash(const Element* sigma, - const byte* e1, size_t e1len, const byte* e2, size_t e2len, - const byte* s1, size_t s1len, const byte* s2, size_t s2len, - byte* digest, size_t dlen) const + const ::byte* e1, size_t e1len, const ::byte* e2, size_t e2len, + const ::byte* s1, size_t s1len, const ::byte* s2, size_t s2len, + ::byte* digest, size_t dlen) const { HASH hash; size_t idx = 0, req = dlen; diff --git a/files.cpp b/files.cpp index c200e9e7..ad4775ef 100644 --- a/files.cpp +++ b/files.cpp @@ -122,7 +122,7 @@ size_t FileStore::CopyRangeTo2(BufferedTransformation &target, lword &begin, lwo return 0; else { - size_t blockedBytes = target.ChannelPut(channel, byte(result), blocking); + size_t blockedBytes = target.ChannelPut(channel, ::byte(result), blocking); begin += 1-blockedBytes; return blockedBytes; } @@ -228,7 +228,7 @@ bool FileSink::IsolatedFlush(bool hardFlush, bool blocking) return false; } -size_t FileSink::Put2(const byte *inString, size_t length, int messageEnd, bool blocking) +size_t FileSink::Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { CRYPTOPP_UNUSED(blocking); if (!m_stream) diff --git a/files.h b/files.h index a2bf54b9..67f80f3a 100644 --- a/files.h +++ b/files.h @@ -73,7 +73,7 @@ private: member_ptr m_file; std::istream *m_stream; - byte *m_space; + ::byte *m_space; size_t m_len; bool m_waiting; }; @@ -167,7 +167,7 @@ public: std::ostream* GetStream() {return m_stream;} void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); bool IsolatedFlush(bool hardFlush, bool blocking); private: diff --git a/filters.cpp b/filters.cpp index 7b0017a6..3c694c14 100644 --- a/filters.cpp +++ b/filters.cpp @@ -115,7 +115,7 @@ void Filter::PropagateInitialize(const NameValuePairs ¶meters, int propagati AttachedTransformation()->Initialize(parameters, propagation-1); } -size_t Filter::OutputModifiable(int outputSite, byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel) +size_t Filter::OutputModifiable(int outputSite, ::byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel) { if (messageEnd) messageEnd--; @@ -124,7 +124,7 @@ size_t Filter::OutputModifiable(int outputSite, byte *inString, size_t length, i return result; } -size_t Filter::Output(int outputSite, const byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel) +size_t Filter::Output(int outputSite, const ::byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel) { if (messageEnd) messageEnd--; @@ -171,7 +171,7 @@ void MeterFilter::AddRangeToSkip(unsigned int message, lword position, lword siz std::sort(m_rangesToSkip.begin(), m_rangesToSkip.end()); } -size_t MeterFilter::PutMaybeModifiable(byte *begin, size_t length, int messageEnd, bool blocking, bool modifiable) +size_t MeterFilter::PutMaybeModifiable(::byte *begin, size_t length, int messageEnd, bool blocking, bool modifiable) { if (!m_transparent) return 0; @@ -229,12 +229,12 @@ size_t MeterFilter::PutMaybeModifiable(byte *begin, size_t length, int messageEn FILTER_END_NO_MESSAGE_END; } -size_t MeterFilter::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t MeterFilter::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { - return PutMaybeModifiable(const_cast(begin), length, messageEnd, blocking, false); + return PutMaybeModifiable(const_cast< ::byte *>(begin), length, messageEnd, blocking, false); } -size_t MeterFilter::PutModifiable2(byte *begin, size_t length, int messageEnd, bool blocking) +size_t MeterFilter::PutModifiable2(::byte *begin, size_t length, int messageEnd, bool blocking) { return PutMaybeModifiable(begin, length, messageEnd, blocking, true); } @@ -259,11 +259,11 @@ void FilterWithBufferedInput::BlockQueue::ResetQueue(size_t blockSize, size_t ma m_begin = m_buffer; } -byte *FilterWithBufferedInput::BlockQueue::GetBlock() +::byte *FilterWithBufferedInput::BlockQueue::GetBlock() { if (m_size >= m_blockSize) { - byte *ptr = m_begin; + ::byte *ptr = m_begin; if ((m_begin+=m_blockSize) == m_buffer.end()) m_begin = m_buffer; m_size -= m_blockSize; @@ -273,10 +273,10 @@ byte *FilterWithBufferedInput::BlockQueue::GetBlock() return NULLPTR; } -byte *FilterWithBufferedInput::BlockQueue::GetContigousBlocks(size_t &numberOfBytes) +::byte *FilterWithBufferedInput::BlockQueue::GetContigousBlocks(size_t &numberOfBytes) { numberOfBytes = STDMIN(numberOfBytes, STDMIN(size_t(m_buffer.end()-m_begin), m_size)); - byte *ptr = m_begin; + ::byte *ptr = m_begin; m_begin += numberOfBytes; m_size -= numberOfBytes; if (m_size == 0 || m_begin == m_buffer.end()) @@ -284,27 +284,27 @@ byte *FilterWithBufferedInput::BlockQueue::GetContigousBlocks(size_t &numberOfBy return ptr; } -size_t FilterWithBufferedInput::BlockQueue::GetAll(byte *outString) +size_t FilterWithBufferedInput::BlockQueue::GetAll(::byte *outString) { // Avoid passing NULL pointer to memcpy if (!outString) return 0; size_t size = m_size; size_t numberOfBytes = m_maxBlocks*m_blockSize; - const byte *ptr = GetContigousBlocks(numberOfBytes); + const ::byte *ptr = GetContigousBlocks(numberOfBytes); memcpy(outString, ptr, numberOfBytes); memcpy(outString+numberOfBytes, m_begin, m_size); m_size = 0; return size; } -void FilterWithBufferedInput::BlockQueue::Put(const byte *inString, size_t length) +void FilterWithBufferedInput::BlockQueue::Put(const ::byte *inString, size_t length) { // Avoid passing NULL pointer to memcpy if (!inString || !length) return; CRYPTOPP_ASSERT(m_size + length <= m_buffer.size()); - byte *end = (m_size < size_t(m_buffer.end()-m_begin)) ? m_begin + m_size : m_begin + m_size - m_buffer.size(); + ::byte *end = (m_size < size_t(m_buffer.end()-m_begin)) ? m_begin + m_size : m_begin + m_size - m_buffer.size(); size_t len = STDMIN(length, size_t(m_buffer.end()-end)); memcpy(end, inString, len); if (len < length) @@ -347,7 +347,7 @@ bool FilterWithBufferedInput::IsolatedFlush(bool hardFlush, bool blocking) return false; } -size_t FilterWithBufferedInput::PutMaybeModifiable(byte *inString, size_t length, int messageEnd, bool blocking, bool modifiable) +size_t FilterWithBufferedInput::PutMaybeModifiable(::byte *inString, size_t length, int messageEnd, bool blocking, bool modifiable) { if (!blocking) throw BlockingInputOnly("FilterWithBufferedInput"); @@ -376,7 +376,7 @@ size_t FilterWithBufferedInput::PutMaybeModifiable(byte *inString, size_t length while (newLength > m_lastSize && m_queue.CurrentSize() > 0) { size_t len = newLength - m_lastSize; - byte *ptr = m_queue.GetContigousBlocks(len); + ::byte *ptr = m_queue.GetContigousBlocks(len); NextPutModifiable(ptr, len); newLength -= len; } @@ -456,7 +456,7 @@ void FilterWithBufferedInput::ForceNextPut() } } -void FilterWithBufferedInput::NextPutMultiple(const byte *inString, size_t length) +void FilterWithBufferedInput::NextPutMultiple(const ::byte *inString, size_t length) { CRYPTOPP_ASSERT(m_blockSize > 1); // m_blockSize = 1 should always override this function while (length > 0) @@ -505,13 +505,13 @@ void ProxyFilter::SetFilter(Filter *filter) } } -void ProxyFilter::NextPutMultiple(const byte *s, size_t len) +void ProxyFilter::NextPutMultiple(const ::byte *s, size_t len) { if (m_filter.get()) m_filter->Put(s, len); } -void ProxyFilter::NextPutModifiable(byte *s, size_t len) +void ProxyFilter::NextPutModifiable(::byte *s, size_t len) { if (m_filter.get()) m_filter->PutModifiable(s, len); @@ -524,14 +524,14 @@ void RandomNumberSink::IsolatedInitialize(const NameValuePairs ¶meters) parameters.GetRequiredParameter("RandomNumberSink", "RandomNumberGeneratorPointer", m_rng); } -size_t RandomNumberSink::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t RandomNumberSink::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); m_rng->IncorporateEntropy(begin, length); return 0; } -size_t ArraySink::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t ArraySink::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); @@ -547,7 +547,7 @@ size_t ArraySink::Put2(const byte *begin, size_t length, int messageEnd, bool bl return length - copied; } -byte * ArraySink::CreatePutSpace(size_t &size) +::byte * ArraySink::CreatePutSpace(size_t &size) { size = SaturatingSubtract(m_size, m_total); return m_buf + m_total; @@ -562,7 +562,7 @@ void ArraySink::IsolatedInitialize(const NameValuePairs ¶meters) m_size = array.size(); } -size_t ArrayXorSink::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t ArrayXorSink::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); @@ -626,14 +626,14 @@ void StreamTransformationFilter::InitializeDerivedAndReturnNewSizes(const NameVa lastSize = LastBlockSize(m_cipher, m_padding); } -void StreamTransformationFilter::FirstPut(const byte* inString) +void StreamTransformationFilter::FirstPut(const ::byte* inString) { CRYPTOPP_UNUSED(inString); m_optimalBufferSize = m_cipher.OptimalBlockSize(); m_optimalBufferSize = (unsigned int)STDMAX(m_optimalBufferSize, RoundDownToMultipleOf(4096U, m_optimalBufferSize)); } -void StreamTransformationFilter::NextPutMultiple(const byte *inString, size_t length) +void StreamTransformationFilter::NextPutMultiple(const ::byte *inString, size_t length) { if (!length) return; @@ -643,7 +643,7 @@ void StreamTransformationFilter::NextPutMultiple(const byte *inString, size_t le do { size_t len = m_optimalBufferSize; - byte *space = HelpCreatePutSpace(*AttachedTransformation(), DEFAULT_CHANNEL, s, length, len); + ::byte *space = HelpCreatePutSpace(*AttachedTransformation(), DEFAULT_CHANNEL, s, length, len); if (len < length) { if (len == m_optimalBufferSize) @@ -660,15 +660,15 @@ void StreamTransformationFilter::NextPutMultiple(const byte *inString, size_t le while (length > 0); } -void StreamTransformationFilter::NextPutModifiable(byte *inString, size_t length) +void StreamTransformationFilter::NextPutModifiable(::byte *inString, size_t length) { m_cipher.ProcessString(inString, length); AttachedTransformation()->PutModifiable(inString, length); } -void StreamTransformationFilter::LastPut(const byte *inString, size_t length) +void StreamTransformationFilter::LastPut(const ::byte *inString, size_t length) { - byte *space = NULLPTR; + ::byte *space = NULLPTR; switch (m_padding) { @@ -720,14 +720,14 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length) if (m_padding == PKCS_PADDING) { CRYPTOPP_ASSERT(s < 256); - byte pad = static_cast(s-length); + ::byte pad = static_cast< ::byte>(s-length); memset(space+length, pad, s-length); } else if (m_padding == W3C_PADDING) { CRYPTOPP_ASSERT(s < 256); memset(space+length, 0, s-length-1); - space[s-1] = static_cast(s-length); + space[s-1] = static_cast< ::byte>(s-length); } else { @@ -744,14 +744,14 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length) m_cipher.ProcessData(space, inString, s); if (m_padding == PKCS_PADDING) { - byte pad = space[s-1]; - if (pad < 1 || pad > s || std::find_if(space+s-pad, space+s, std::bind2nd(std::not_equal_to(), pad)) != space+s) + ::byte pad = space[s-1]; + if (pad < 1 || pad > s || std::find_if(space+s-pad, space+s, std::bind2nd(std::not_equal_to< ::byte>(), pad)) != space+s) throw InvalidCiphertext("StreamTransformationFilter: invalid PKCS #7 block padding found"); length = s-pad; } else if (m_padding == W3C_PADDING) { - byte pad = space[s - 1]; + ::byte pad = space[s - 1]; if (pad < 1 || pad > s) throw InvalidCiphertext("StreamTransformationFilter: invalid W3C block padding found"); length = s - pad; @@ -789,7 +789,7 @@ void HashFilter::IsolatedInitialize(const NameValuePairs ¶meters) m_digestSize = s < 0 ? m_hashModule.DigestSize() : s; } -size_t HashFilter::Put2(const byte *inString, size_t length, int messageEnd, bool blocking) +size_t HashFilter::Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { FILTER_BEGIN; if (m_putMessage) @@ -828,7 +828,7 @@ void HashVerificationFilter::InitializeDerivedAndReturnNewSizes(const NameValueP lastSize = m_flags & HASH_AT_BEGIN ? 0 : m_digestSize; } -void HashVerificationFilter::FirstPut(const byte *inString) +void HashVerificationFilter::FirstPut(const ::byte *inString) { if (m_flags & HASH_AT_BEGIN) { @@ -839,14 +839,14 @@ void HashVerificationFilter::FirstPut(const byte *inString) } } -void HashVerificationFilter::NextPutMultiple(const byte *inString, size_t length) +void HashVerificationFilter::NextPutMultiple(const ::byte *inString, size_t length) { m_hashModule.Update(inString, length); if (m_flags & PUT_MESSAGE) AttachedTransformation()->Put(inString, length); } -void HashVerificationFilter::LastPut(const byte *inString, size_t length) +void HashVerificationFilter::LastPut(const ::byte *inString, size_t length) { if (m_flags & HASH_AT_BEGIN) { @@ -883,7 +883,7 @@ void AuthenticatedEncryptionFilter::IsolatedInitialize(const NameValuePairs &par StreamTransformationFilter::IsolatedInitialize(parameters); } -byte * AuthenticatedEncryptionFilter::ChannelCreatePutSpace(const std::string &channel, size_t &size) +::byte * AuthenticatedEncryptionFilter::ChannelCreatePutSpace(const std::string &channel, size_t &size) { if (channel.empty()) return StreamTransformationFilter::CreatePutSpace(size); @@ -894,7 +894,7 @@ byte * AuthenticatedEncryptionFilter::ChannelCreatePutSpace(const std::string &c throw InvalidChannelName("AuthenticatedEncryptionFilter", channel); } -size_t AuthenticatedEncryptionFilter::ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) +size_t AuthenticatedEncryptionFilter::ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking) { if (channel.empty()) return StreamTransformationFilter::Put2(begin, length, messageEnd, blocking); @@ -905,7 +905,7 @@ size_t AuthenticatedEncryptionFilter::ChannelPut2(const std::string &channel, co throw InvalidChannelName("AuthenticatedEncryptionFilter", channel); } -void AuthenticatedEncryptionFilter::LastPut(const byte *inString, size_t length) +void AuthenticatedEncryptionFilter::LastPut(const ::byte *inString, size_t length) { StreamTransformationFilter::LastPut(inString, length); m_hf.MessageEnd(); @@ -934,7 +934,7 @@ void AuthenticatedDecryptionFilter::InitializeDerivedAndReturnNewSizes(const Nam lastSize = m_hashVerifier.m_lastSize; } -byte * AuthenticatedDecryptionFilter::ChannelCreatePutSpace(const std::string &channel, size_t &size) +::byte * AuthenticatedDecryptionFilter::ChannelCreatePutSpace(const std::string &channel, size_t &size) { if (channel.empty()) return m_streamFilter.CreatePutSpace(size); @@ -945,7 +945,7 @@ byte * AuthenticatedDecryptionFilter::ChannelCreatePutSpace(const std::string &c throw InvalidChannelName("AuthenticatedDecryptionFilter", channel); } -size_t AuthenticatedDecryptionFilter::ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) +size_t AuthenticatedDecryptionFilter::ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking) { if (channel.empty()) { @@ -960,17 +960,17 @@ size_t AuthenticatedDecryptionFilter::ChannelPut2(const std::string &channel, co throw InvalidChannelName("AuthenticatedDecryptionFilter", channel); } -void AuthenticatedDecryptionFilter::FirstPut(const byte *inString) +void AuthenticatedDecryptionFilter::FirstPut(const ::byte *inString) { m_hashVerifier.Put(inString, m_firstSize); } -void AuthenticatedDecryptionFilter::NextPutMultiple(const byte *inString, size_t length) +void AuthenticatedDecryptionFilter::NextPutMultiple(const ::byte *inString, size_t length) { m_streamFilter.Put(inString, length); } -void AuthenticatedDecryptionFilter::LastPut(const byte *inString, size_t length) +void AuthenticatedDecryptionFilter::LastPut(const ::byte *inString, size_t length) { m_streamFilter.MessageEnd(); m_hashVerifier.PutMessageEnd(inString, length); @@ -984,7 +984,7 @@ void SignerFilter::IsolatedInitialize(const NameValuePairs ¶meters) m_messageAccumulator.reset(m_signer.NewSignatureAccumulator(m_rng)); } -size_t SignerFilter::Put2(const byte *inString, size_t length, int messageEnd, bool blocking) +size_t SignerFilter::Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { FILTER_BEGIN; m_messageAccumulator->Update(inString, length); @@ -1019,7 +1019,7 @@ void SignatureVerificationFilter::InitializeDerivedAndReturnNewSizes(const NameV lastSize = m_flags & SIGNATURE_AT_BEGIN ? 0 : size; } -void SignatureVerificationFilter::FirstPut(const byte *inString) +void SignatureVerificationFilter::FirstPut(const ::byte *inString) { if (m_flags & SIGNATURE_AT_BEGIN) { @@ -1040,14 +1040,14 @@ void SignatureVerificationFilter::FirstPut(const byte *inString) } } -void SignatureVerificationFilter::NextPutMultiple(const byte *inString, size_t length) +void SignatureVerificationFilter::NextPutMultiple(const ::byte *inString, size_t length) { m_messageAccumulator->Update(inString, length); if (m_flags & PUT_MESSAGE) AttachedTransformation()->Put(inString, length); } -void SignatureVerificationFilter::LastPut(const byte *inString, size_t length) +void SignatureVerificationFilter::LastPut(const ::byte *inString, size_t length) { if (m_flags & SIGNATURE_AT_BEGIN) { @@ -1157,7 +1157,7 @@ size_t RandomNumberStore::TransferTo2(BufferedTransformation &target, lword &tra size_t NullStore::CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end, const std::string &channel, bool blocking) const { - static const byte nullBytes[128] = {0}; + static const ::byte nullBytes[128] = {0}; while (begin < end) { size_t len = (size_t)STDMIN(end-begin, lword(128)); diff --git a/filters.h b/filters.h index f12be70d..df22538f 100644 --- a/filters.h +++ b/filters.h @@ -93,7 +93,7 @@ protected: //! \param blocking specifies whether the object should block when processing input //! \param channel the channel to process the data //! \returns the number of bytes that remain in the block (i.e., bytes not processed) - size_t Output(int outputSite, const byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel=DEFAULT_CHANNEL); + size_t Output(int outputSite, const ::byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel=DEFAULT_CHANNEL); //! \brief Output multiple bytes that may be modified by callee. //! \param outputSite unknown, system crash between keyboard and chair... @@ -103,7 +103,7 @@ protected: //! \param blocking specifies whether the object should block when processing input //! \param channel the channel to process the data //! \returns the number of bytes that remain in the block (i.e., bytes not processed) - size_t OutputModifiable(int outputSite, byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel=DEFAULT_CHANNEL); + size_t OutputModifiable(int outputSite, ::byte *inString, size_t length, int messageEnd, bool blocking, const std::string &channel=DEFAULT_CHANNEL); //! \brief Signals the end of messages to the object //! \param outputSite unknown, system crash between keyboard and chair... @@ -174,12 +174,12 @@ struct CRYPTOPP_DLL FilterPutSpaceHelper //! "ChannelCreatePutSpace()" using \p desiredSize. If the target returns \p desiredSize with a size less //! than \p minSize (i.e., the request could not be fulfilled), then an internal SecByteBlock //! called \p m_tempSpace is resized and used for the caller. - byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize) + ::byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize) { CRYPTOPP_ASSERT(desiredSize >= minSize && bufferSize >= minSize); if (m_tempSpace.size() < minSize) { - byte *result = target.ChannelCreatePutSpace(channel, desiredSize); + ::byte *result = target.ChannelCreatePutSpace(channel, desiredSize); if (desiredSize >= minSize) { bufferSize = desiredSize; @@ -197,7 +197,7 @@ struct CRYPTOPP_DLL FilterPutSpaceHelper //! \param channel channel for the working space //! \param minSize minimum size of the allocation, in bytes //! \details Internally, the overload calls HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize) using \p minSize for missing arguments. - byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize) + ::byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize) {return HelpCreatePutSpace(target, channel, minSize, minSize, minSize);} //! \brief Create a working space in a BufferedTransformation @@ -206,7 +206,7 @@ struct CRYPTOPP_DLL FilterPutSpaceHelper //! \param minSize minimum size of the allocation, in bytes //! \param bufferSize the actual size of the allocation, in bytes //! \details Internally, the overload calls HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize) using \p minSize for missing arguments. - byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t bufferSize) + ::byte *HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t bufferSize) {return HelpCreatePutSpace(target, channel, minSize, minSize, bufferSize);} //! \brief Temporay working space @@ -259,14 +259,14 @@ public: unsigned int GetTotalMessages() const {return m_totalMessages;} unsigned int GetTotalMessageSeries() const {return m_totalMessageSeries;} - byte * CreatePutSpace(size_t &size) + ::byte * CreatePutSpace(size_t &size) {return AttachedTransformation()->CreatePutSpace(size);} - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); - size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); + size_t PutModifiable2(::byte *inString, size_t length, int messageEnd, bool blocking); bool IsolatedMessageSeriesEnd(bool blocking); private: - size_t PutMaybeModifiable(byte *inString, size_t length, int messageEnd, bool blocking, bool modifiable); + size_t PutMaybeModifiable(::byte *inString, size_t length, int messageEnd, bool blocking, bool modifiable); bool ShouldPropagateMessageEnd() const {return m_transparent;} bool ShouldPropagateMessageSeriesEnd() const {return m_transparent;} @@ -281,7 +281,7 @@ private: lword m_currentMessageBytes, m_totalBytes; unsigned int m_currentSeriesMessages, m_totalMessages, m_totalMessageSeries; std::deque m_rangesToSkip; - byte *m_begin; + ::byte *m_begin; size_t m_length; }; @@ -332,11 +332,11 @@ public: FilterWithBufferedInput(size_t firstSize, size_t blockSize, size_t lastSize, BufferedTransformation *attachment); void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { - return PutMaybeModifiable(const_cast(inString), length, messageEnd, blocking, false); + return PutMaybeModifiable(const_cast< ::byte *>(inString), length, messageEnd, blocking, false); } - size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking) + size_t PutModifiable2(::byte *inString, size_t length, int messageEnd, bool blocking) { return PutMaybeModifiable(inString, length, messageEnd, blocking, true); } @@ -366,15 +366,15 @@ protected: // FirstPut() is called if (firstSize != 0 and totalLength >= firstSize) // or (firstSize == 0 and (totalLength > 0 or a MessageEnd() is received)). // inString is m_firstSize in length. - virtual void FirstPut(const byte *inString) =0; + virtual void FirstPut(const ::byte *inString) =0; // NextPut() is called if totalLength >= firstSize+blockSize+lastSize - virtual void NextPutSingle(const byte *inString) + virtual void NextPutSingle(const ::byte *inString) {CRYPTOPP_UNUSED(inString); CRYPTOPP_ASSERT(false);} // Same as NextPut() except length can be a multiple of blockSize // Either NextPut() or NextPutMultiple() must be overridden - virtual void NextPutMultiple(const byte *inString, size_t length); + virtual void NextPutMultiple(const ::byte *inString, size_t length); // Same as NextPutMultiple(), but inString can be modified - virtual void NextPutModifiable(byte *inString, size_t length) + virtual void NextPutModifiable(::byte *inString, size_t length) {NextPutMultiple(inString, length);} //! \brief Input the last block of data //! \param inString the input byte buffer @@ -386,12 +386,12 @@ protected: //! else if totalLength <= firstSize+lastSize then length == totalLength-firstSize //! else lastSize <= length < lastSize+blockSize //! - virtual void LastPut(const byte *inString, size_t length) =0; + virtual void LastPut(const ::byte *inString, size_t length) =0; virtual void FlushDerived() {} protected: - size_t PutMaybeModifiable(byte *begin, size_t length, int messageEnd, bool blocking, bool modifiable); - void NextPutMaybeModifiable(byte *inString, size_t length, bool modifiable) + size_t PutMaybeModifiable(::byte *begin, size_t length, int messageEnd, bool blocking, bool modifiable); + void NextPutMaybeModifiable(::byte *inString, size_t length, bool modifiable) { if (modifiable) NextPutModifiable(inString, length); else NextPutMultiple(inString, length); @@ -399,24 +399,24 @@ protected: // This function should no longer be used, put this here to cause a compiler error // if someone tries to override NextPut(). - virtual int NextPut(const byte *inString, size_t length) + virtual int NextPut(const ::byte *inString, size_t length) {CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(false); return 0;} class BlockQueue { public: void ResetQueue(size_t blockSize, size_t maxBlocks); - byte *GetBlock(); - byte *GetContigousBlocks(size_t &numberOfBytes); - size_t GetAll(byte *outString); - void Put(const byte *inString, size_t length); + ::byte *GetBlock(); + ::byte *GetContigousBlocks(size_t &numberOfBytes); + size_t GetAll(::byte *outString); + void Put(const ::byte *inString, size_t length); size_t CurrentSize() const {return m_size;} size_t MaxSize() const {return m_buffer.size();} private: SecByteBlock m_buffer; size_t m_blockSize, m_maxBlocks, m_size; - byte *m_begin; + ::byte *m_begin; }; size_t m_firstSize, m_blockSize, m_lastSize; @@ -438,7 +438,7 @@ public: //! \param attachment an optional attached transformation FilterWithInputQueue(BufferedTransformation *attachment=NULLPTR) : Filter(attachment) {} - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { if (!blocking) throw BlockingInputOnly("FilterWithInputQueue"); @@ -517,10 +517,10 @@ public: protected: void InitializeDerivedAndReturnNewSizes(const NameValuePairs ¶meters, size_t &firstSize, size_t &blockSize, size_t &lastSize); - void FirstPut(const byte *inString); - void NextPutMultiple(const byte *inString, size_t length); - void NextPutModifiable(byte *inString, size_t length); - void LastPut(const byte *inString, size_t length); + void FirstPut(const ::byte *inString); + void NextPutMultiple(const ::byte *inString, size_t length); + void NextPutModifiable(::byte *inString, size_t length); + void LastPut(const ::byte *inString, size_t length); static size_t LastBlockSize(StreamTransformation &c, BlockPaddingScheme padding); @@ -548,14 +548,14 @@ public: std::string AlgorithmName() const {return m_hashModule.AlgorithmName();} void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); - byte * CreatePutSpace(size_t &size) {return m_hashModule.CreateUpdateSpace(size);} + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); + ::byte * CreatePutSpace(size_t &size) {return m_hashModule.CreateUpdateSpace(size);} private: HashTransformation &m_hashModule; bool m_putMessage; unsigned int m_digestSize; - byte *m_space; + ::byte *m_space; std::string m_messagePutChannel, m_hashPutChannel; }; @@ -609,9 +609,9 @@ public: protected: void InitializeDerivedAndReturnNewSizes(const NameValuePairs ¶meters, size_t &firstSize, size_t &blockSize, size_t &lastSize); - void FirstPut(const byte *inString); - void NextPutMultiple(const byte *inString, size_t length); - void LastPut(const byte *inString, size_t length); + void FirstPut(const ::byte *inString); + void NextPutMultiple(const ::byte *inString, size_t length); + void LastPut(const ::byte *inString, size_t length); private: friend class AuthenticatedDecryptionFilter; @@ -646,8 +646,8 @@ public: AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULLPTR, bool putAAD=false, int truncatedDigestSize=-1, const std::string &macChannel=DEFAULT_CHANNEL, BlockPaddingScheme padding = DEFAULT_PADDING); void IsolatedInitialize(const NameValuePairs ¶meters); - byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); - size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking); + ::byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); + size_t ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking); //! \brief Input the last block of data //! \param inString the input byte buffer @@ -659,7 +659,7 @@ public: //! else if totalLength <= firstSize+lastSize then length == totalLength-firstSize //! else lastSize <= length < lastSize+blockSize //! - void LastPut(const byte *inString, size_t length); + void LastPut(const ::byte *inString, size_t length); protected: HashFilter m_hf; @@ -702,14 +702,14 @@ public: AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULLPTR, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1, BlockPaddingScheme padding = DEFAULT_PADDING); std::string AlgorithmName() const {return m_hashVerifier.AlgorithmName();} - byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); - size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking); + ::byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); + size_t ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking); bool GetLastResult() const {return m_hashVerifier.GetLastResult();} protected: void InitializeDerivedAndReturnNewSizes(const NameValuePairs ¶meters, size_t &firstSize, size_t &blockSize, size_t &lastSize); - void FirstPut(const byte *inString); - void NextPutMultiple(const byte *inString, size_t length); + void FirstPut(const ::byte *inString); + void NextPutMultiple(const ::byte *inString, size_t length); //! \brief Input the last block of data //! \param inString the input byte buffer @@ -721,7 +721,7 @@ protected: //! else if totalLength <= firstSize+lastSize then length == totalLength-firstSize //! else lastSize <= length < lastSize+blockSize //! - void LastPut(const byte *inString, size_t length); + void LastPut(const ::byte *inString, size_t length); HashVerificationFilter m_hashVerifier; StreamTransformationFilter m_streamFilter; @@ -746,7 +746,7 @@ public: std::string AlgorithmName() const {return m_signer.AlgorithmName();} void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); private: RandomNumberGenerator &m_rng; @@ -807,9 +807,9 @@ public: protected: void InitializeDerivedAndReturnNewSizes(const NameValuePairs ¶meters, size_t &firstSize, size_t &blockSize, size_t &lastSize); - void FirstPut(const byte *inString); - void NextPutMultiple(const byte *inString, size_t length); - void LastPut(const byte *inString, size_t length); + void FirstPut(const ::byte *inString); + void NextPutMultiple(const ::byte *inString, size_t length); + void LastPut(const ::byte *inString, size_t length); private: const PK_Verifier &m_verifier; @@ -868,7 +868,7 @@ public: {return m_target ? m_target->CanModifyInput() : false;} void Initialize(const NameValuePairs ¶meters, int propagation); - byte * CreatePutSpace(size_t &size) + ::byte * CreatePutSpace(size_t &size) { if (m_target) return m_target->CreatePutSpace(size); @@ -878,14 +878,14 @@ public: return NULLPTR; } } - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) {return m_target ? m_target->Put2(inString, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;} bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) {return m_target && GetPassSignals() ? m_target->Flush(hardFlush, propagation, blocking) : false;} bool MessageSeriesEnd(int propagation=-1, bool blocking=true) {return m_target && GetPassSignals() ? m_target->MessageSeriesEnd(propagation, blocking) : false;} - byte * ChannelCreatePutSpace(const std::string &channel, size_t &size) + ::byte * ChannelCreatePutSpace(const std::string &channel, size_t &size) { if (m_target) return m_target->ChannelCreatePutSpace(channel, size); @@ -895,9 +895,9 @@ public: return NULLPTR; } } - size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) + size_t ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking) {return m_target ? m_target->ChannelPut2(channel, begin, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;} - size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking) + size_t ChannelPutModifiable2(const std::string &channel, ::byte *begin, size_t length, int messageEnd, bool blocking) {return m_target ? m_target->ChannelPutModifiable2(channel, begin, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;} bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true) {return m_target && GetPassSignals() ? m_target->ChannelFlush(channel, completeFlush, propagation, blocking) : false;} @@ -935,11 +935,11 @@ public: //! \param passSignal flag indicating if signals should be passed void SetPassSignal(bool passSignal) {m_passSignal = passSignal;} - byte * CreatePutSpace(size_t &size) + ::byte * CreatePutSpace(size_t &size) {return m_owner.AttachedTransformation()->CreatePutSpace(size);} - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) {return m_owner.AttachedTransformation()->Put2(inString, length, m_passSignal ? messageEnd : 0, blocking);} - size_t PutModifiable2(byte *begin, size_t length, int messageEnd, bool blocking) + size_t PutModifiable2(::byte *begin, size_t length, int messageEnd, bool blocking) {return m_owner.AttachedTransformation()->PutModifiable2(begin, length, m_passSignal ? messageEnd : 0, blocking);} void Initialize(const NameValuePairs ¶meters=g_nullNameValuePairs, int propagation=-1) {if (m_passSignal) m_owner.AttachedTransformation()->Initialize(parameters, propagation);} @@ -948,11 +948,11 @@ public: bool MessageSeriesEnd(int propagation=-1, bool blocking=true) {return m_passSignal ? m_owner.AttachedTransformation()->MessageSeriesEnd(propagation, blocking) : false;} - byte * ChannelCreatePutSpace(const std::string &channel, size_t &size) + ::byte * ChannelCreatePutSpace(const std::string &channel, size_t &size) {return m_owner.AttachedTransformation()->ChannelCreatePutSpace(channel, size);} - size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) + size_t ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking) {return m_owner.AttachedTransformation()->ChannelPut2(channel, begin, length, m_passSignal ? messageEnd : 0, blocking);} - size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking) + size_t ChannelPutModifiable2(const std::string &channel, ::byte *begin, size_t length, int messageEnd, bool blocking) {return m_owner.AttachedTransformation()->ChannelPutModifiable2(channel, begin, length, m_passSignal ? messageEnd : 0, blocking);} bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true) {return m_passSignal ? m_owner.AttachedTransformation()->ChannelFlush(channel, completeFlush, propagation, blocking) : false;} @@ -984,8 +984,8 @@ public: //! \brief Sets the OutputProxy filter //! \param filter an OutputProxy filter void SetFilter(Filter *filter); - void NextPutMultiple(const byte *s, size_t len); - void NextPutModifiable(byte *inString, size_t length); + void NextPutMultiple(const ::byte *s, size_t len); + void NextPutModifiable(::byte *inString, size_t length); protected: member_ptr m_filter; @@ -1003,7 +1003,7 @@ public: SimpleProxyFilter(BufferedTransformation *filter, BufferedTransformation *attachment) : ProxyFilter(filter, 0, 0, attachment) {} - void FirstPut(const byte * inString) + void FirstPut(const ::byte * inString) {CRYPTOPP_UNUSED(inString);} //! \brief Input the last block of data @@ -1016,7 +1016,7 @@ public: //! else if totalLength <= firstSize+lastSize then length == totalLength-firstSize //! else lastSize <= length < lastSize+blockSize //! - void LastPut(const byte *inString, size_t length) + void LastPut(const ::byte *inString, size_t length) {CRYPTOPP_UNUSED(inString), CRYPTOPP_UNUSED(length); m_filter->MessageEnd();} }; @@ -1071,7 +1071,7 @@ public: void IsolatedInitialize(const NameValuePairs ¶meters) {if (!parameters.GetValue("OutputStringPointer", m_output)) throw InvalidArgument("StringSink: OutputStringPointer not specified");} - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); typedef typename T::traits_type::char_type char_type; @@ -1114,7 +1114,7 @@ public: : m_rng(&rng) {} void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); private: RandomNumberGenerator *m_rng; @@ -1137,7 +1137,7 @@ public: //! \brief Construct an ArraySink //! \param buf pointer to a memory buffer //! \param size length of the memory buffer - ArraySink(byte *buf, size_t size) + ArraySink(::byte *buf, size_t size) : m_buf(buf), m_size(size), m_total(0) {} //! \brief Provides the size remaining in the Sink @@ -1149,11 +1149,11 @@ public: lword TotalPutLength() {return m_total;} void IsolatedInitialize(const NameValuePairs ¶meters); - byte * CreatePutSpace(size_t &size); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); + ::byte * CreatePutSpace(size_t &size); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); protected: - byte *m_buf; + ::byte *m_buf; size_t m_size; lword m_total; }; @@ -1169,11 +1169,11 @@ public: //! \brief Construct an ArrayXorSink //! \param buf pointer to a memory buffer //! \param size length of the memory buffer - ArrayXorSink(byte *buf, size_t size) + ArrayXorSink(::byte *buf, size_t size) : ArraySink(buf, size) {} - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); - byte * CreatePutSpace(size_t &size) {return BufferedTransformation::CreatePutSpace(size);} + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); + ::byte * CreatePutSpace(size_t &size) {return BufferedTransformation::CreatePutSpace(size);} }; //! \class StringStore @@ -1190,7 +1190,7 @@ public: //! \brief Construct a StringStore //! \param string pointer to a memory buffer //! \param length size of the memory buffer - StringStore(const byte *string, size_t length) + StringStore(const ::byte *string, size_t length) {StoreInitialize(MakeParameters("InputBuffer", ConstByteArrayParameter(string, length)));} //! \brief Construct a StringStore @@ -1205,7 +1205,7 @@ public: private: CRYPTOPP_DLL void StoreInitialize(const NameValuePairs ¶meters); - const byte *m_store; + const ::byte *m_store; size_t m_length, m_count; }; @@ -1393,7 +1393,7 @@ public: //! \param length size of the byte array //! \param pumpAll flag indicating if source data should be pumped to its attached transformation //! \param attachment an optional attached transformation - StringSource(const byte *string, size_t length, bool pumpAll, BufferedTransformation *attachment = NULLPTR) + StringSource(const ::byte *string, size_t length, bool pumpAll, BufferedTransformation *attachment = NULLPTR) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string, length)));} //! \brief Construct a StringSource diff --git a/fips140.h b/fips140.h index eb276125..29a4200e 100644 --- a/fips140.h +++ b/fips140.h @@ -54,7 +54,7 @@ enum PowerUpSelfTestStatus { //! POWER_UP_SELF_TEST_PASSED or POWER_UP_SELF_TEST_FAILED. //! \details The self tests for an algorithm are performed by the Algortihm class //! when CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 is defined. -CRYPTOPP_DLL void CRYPTOPP_API DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac); +CRYPTOPP_DLL void CRYPTOPP_API DoPowerUpSelfTest(const char *moduleFilename, const ::byte *expectedModuleMac); //! \brief Performs the power-up self test on the DLL //! \details Performs the power-up self test using the filename of this DLL and the @@ -86,7 +86,7 @@ CRYPTOPP_DLL MessageAuthenticationCode * CRYPTOPP_API NewIntegrityCheckingMAC(); //! \param pActualMac the actual MAC of the components calculated by the integrity check //! \param pMacFileLocation the offest of the MAC in the PE/PE+ module //! \returns true if the MAC is valid, false otherwise -CRYPTOPP_DLL bool CRYPTOPP_API IntegrityCheckModule(const char *moduleFilename, const byte *expectedModuleMac, SecByteBlock *pActualMac = NULLPTR, unsigned long *pMacFileLocation = NULLPTR); +CRYPTOPP_DLL bool CRYPTOPP_API IntegrityCheckModule(const char *moduleFilename, const ::byte *expectedModuleMac, SecByteBlock *pActualMac = NULLPTR, unsigned long *pMacFileLocation = NULLPTR); #ifndef CRYPTOPP_DOXYGEN_PROCESSING // this is used by Algorithm constructor to allow Algorithm objects to be constructed for the self test diff --git a/fipstest.cpp b/fipstest.cpp index a7419821..e2a4bf29 100644 --- a/fipstest.cpp +++ b/fipstest.cpp @@ -63,14 +63,14 @@ unsigned long g_macFileLocation = 0; const void* g_BaseAddressOfMAC = reinterpret_cast(0x42900000); // use a random dummy string here, to be searched/replaced later with the real MAC -static const byte s_moduleMac[CryptoPP::HMAC::DIGESTSIZE] = CRYPTOPP_DUMMY_DLL_MAC; +static const ::byte s_moduleMac[CryptoPP::HMAC::DIGESTSIZE] = CRYPTOPP_DUMMY_DLL_MAC; CRYPTOPP_COMPILE_ASSERT(sizeof(s_moduleMac) == CryptoPP::SHA1::DIGESTSIZE); #ifdef CRYPTOPP_WIN32_AVAILABLE static HMODULE s_hModule = NULLPTR; #endif -const byte * CRYPTOPP_API GetActualMacAndLocation(unsigned int &macSize, unsigned int &fileLocation) +const ::byte * CRYPTOPP_API GetActualMacAndLocation(unsigned int &macSize, unsigned int &fileLocation) { macSize = (unsigned int)g_actualMac.size(); fileLocation = g_macFileLocation; @@ -102,7 +102,7 @@ void X917RNG_KnownAnswerTest( StringSource(deterministicTimeVector, true, new HexDecoder(new StringSink(decodedDeterministicTimeVector))); AutoSeededX917RNG rng(false, false); - rng.Reseed((const byte *)decodedKey.data(), decodedKey.size(), (const byte *)decodedSeed.data(), (const byte *)decodedDeterministicTimeVector.data()); + rng.Reseed((const ::byte *)decodedKey.data(), decodedKey.size(), (const ::byte *)decodedSeed.data(), (const ::byte *)decodedDeterministicTimeVector.data()); KnownAnswerTest(rng, output); #else throw 0; @@ -137,8 +137,8 @@ void SymmetricEncryptionKnownAnswerTest( std::string decodedKey; StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); - typename CIPHER::Encryption encryption((const byte *)decodedKey.data(), decodedKey.size()); - typename CIPHER::Decryption decryption((const byte *)decodedKey.data(), decodedKey.size()); + typename CIPHER::Encryption encryption((const ::byte *)decodedKey.data(), decodedKey.size()); + typename CIPHER::Decryption decryption((const ::byte *)decodedKey.data(), decodedKey.size()); SecByteBlock iv(encryption.BlockSize()); StringSource(hexIV, true, new HexDecoder(new ArraySink(iv, iv.size()))); @@ -178,7 +178,7 @@ void MAC_KnownAnswerTest(const char *key, const char *message, const char *diges std::string decodedKey; StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); - MAC mac((const byte *)decodedKey.data(), decodedKey.size()); + MAC mac((const ::byte *)decodedKey.data(), decodedKey.size()); KnownAnswerTest(mac, message, digest); } @@ -270,11 +270,11 @@ void SignaturePairwiseConsistencyTest(const char *key) MessageAuthenticationCode * NewIntegrityCheckingMAC() { - byte key[] = {0x47, 0x1E, 0x33, 0x96, 0x65, 0xB1, 0x6A, 0xED, 0x0B, 0xF8, 0x6B, 0xFD, 0x01, 0x65, 0x05, 0xCC}; + ::byte key[] = {0x47, 0x1E, 0x33, 0x96, 0x65, 0xB1, 0x6A, 0xED, 0x0B, 0xF8, 0x6B, 0xFD, 0x01, 0x65, 0x05, 0xCC}; return new HMAC(key, sizeof(key)); } -bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModuleMac, SecByteBlock *pActualMac, unsigned long *pMacFileLocation) +bool IntegrityCheckModule(const char *moduleFilename, const ::byte *expectedModuleMac, SecByteBlock *pActualMac, unsigned long *pMacFileLocation) { member_ptr mac(NewIntegrityCheckingMAC()); unsigned int macSize = mac->DigestSize(); @@ -350,16 +350,16 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule #ifdef CRYPTOPP_WIN32_AVAILABLE // try to hash from memory first - const byte *memBase = (const byte *)h; + const ::byte *memBase = (const ::byte *)h; const IMAGE_DOS_HEADER *ph = (IMAGE_DOS_HEADER *)memBase; const IMAGE_NT_HEADERS *phnt = (IMAGE_NT_HEADERS *)(memBase + ph->e_lfanew); const IMAGE_SECTION_HEADER *phs = IMAGE_FIRST_SECTION(phnt); DWORD nSections = phnt->FileHeader.NumberOfSections; size_t currentFilePos = 0; - size_t checksumPos = (byte *)&phnt->OptionalHeader.CheckSum - memBase; + size_t checksumPos = (::byte *)&phnt->OptionalHeader.CheckSum - memBase; size_t checksumSize = sizeof(phnt->OptionalHeader.CheckSum); - size_t certificateTableDirectoryPos = (byte *)&phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY] - memBase; + size_t certificateTableDirectoryPos = (::byte *)&phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY] - memBase; size_t certificateTableDirectorySize = sizeof(phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]); size_t certificateTablePos = phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress; size_t certificateTableSize = phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].Size; @@ -377,13 +377,13 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule case IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ: case IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ: unsigned int sectionSize = STDMIN(phs->SizeOfRawData, phs->Misc.VirtualSize); - const byte *sectionMemStart = memBase + phs->VirtualAddress; + const ::byte *sectionMemStart = memBase + phs->VirtualAddress; unsigned int sectionFileStart = phs->PointerToRawData; size_t subSectionStart = 0, nextSubSectionStart; do { - const byte *subSectionMemStart = sectionMemStart + subSectionStart; + const ::byte *subSectionMemStart = sectionMemStart + subSectionStart; size_t subSectionFileStart = sectionFileStart + subSectionStart; size_t subSectionSize = sectionSize - subSectionStart; nextSubSectionStart = 0; @@ -392,7 +392,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule for (unsigned int i=0; iOptionalHeader.DataDirectory[entriesToReadFromDisk[i]]; - const byte *entryMemStart = memBase + entry.VirtualAddress; + const ::byte *entryMemStart = memBase + entry.VirtualAddress; if (subSectionMemStart <= entryMemStart && entryMemStart < subSectionMemStart + subSectionSize) { subSectionSize = entryMemStart - subSectionMemStart; @@ -404,10 +404,10 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule // first byte of _CRT_DEBUGGER_HOOK gets modified in memory by the debugger invisibly, so read it from file if (IsDebuggerPresent()) { - if (subSectionMemStart <= (byte *)&_CRT_DEBUGGER_HOOK && (byte *)&_CRT_DEBUGGER_HOOK < subSectionMemStart + subSectionSize) + if (subSectionMemStart <= (::byte *)&_CRT_DEBUGGER_HOOK && (::byte *)&_CRT_DEBUGGER_HOOK < subSectionMemStart + subSectionSize) { - subSectionSize = (byte *)&_CRT_DEBUGGER_HOOK - subSectionMemStart; - nextSubSectionStart = (byte *)&_CRT_DEBUGGER_HOOK - sectionMemStart + 1; + subSectionSize = (::byte *)&_CRT_DEBUGGER_HOOK - subSectionMemStart; + nextSubSectionStart = (::byte *)&_CRT_DEBUGGER_HOOK - sectionMemStart + 1; } } #endif @@ -460,7 +460,7 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule return false; } -void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac) +void DoPowerUpSelfTest(const char *moduleFilename, const ::byte *expectedModuleMac) { g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_NOT_DONE; SetPowerUpSelfTestInProgressOnThisThread(true); diff --git a/gcm.cpp b/gcm.cpp index 6d86bac1..2d019640 100644 --- a/gcm.cpp +++ b/gcm.cpp @@ -194,7 +194,7 @@ __m128i _mm_clmulepi64_si128(const __m128i &a, const __m128i &b, int i) #endif #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE -inline static void SSE2_Xor16(byte *a, const byte *b, const byte *c) +inline static void SSE2_Xor16(::byte *a, const ::byte *b, const ::byte *c) { // SunCC 5.14 crash (bewildering since asserts are not in effect in release builds) // Also see http://github.com/weidai11/cryptopp/issues/226 and http://github.com/weidai11/cryptopp/issues/284 @@ -221,7 +221,7 @@ inline static void NEON_Xor16(byte *a, const byte *b, const byte *c) } #endif -inline static void Xor16(byte *a, const byte *b, const byte *c) +inline static void Xor16(::byte *a, const ::byte *b, const ::byte *c) { CRYPTOPP_ASSERT(IsAlignedOn(a,GetAlignmentOf())); CRYPTOPP_ASSERT(IsAlignedOn(b,GetAlignmentOf())); @@ -320,7 +320,7 @@ inline uint64x2_t PMULL_GF_Mul(const uint64x2_t &x, const uint64x2_t &h, const u } #endif -void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms) +void GCM_Base::SetKeyWithoutResync(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms) { BlockCipher &blockCipher = AccessBlockCipher(); blockCipher.SetKey(userKey, keylength, params); @@ -360,8 +360,8 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const } m_buffer.resize(3*REQUIRED_BLOCKSIZE + tableSize); - byte *table = MulTable(); - byte *hashKey = HashKey(); + ::byte *table = MulTable(); + ::byte *hashKey = HashKey(); memset(hashKey, 0, REQUIRED_BLOCKSIZE); blockCipher.ProcessBlock(hashKey); @@ -532,10 +532,10 @@ inline void GCM_Base::ReverseHashBufferIfNeeded() #endif } -void GCM_Base::Resync(const byte *iv, size_t len) +void GCM_Base::Resync(const ::byte *iv, size_t len) { BlockCipher &cipher = AccessBlockCipher(); - byte *hashBuffer = HashBuffer(); + ::byte *hashBuffer = HashBuffer(); if (len == 12) { @@ -603,7 +603,7 @@ void GCM_AuthenticateBlocks_64K(const byte *data, size_t blocks, word64 *hashBuf #ifndef CRYPTOPP_GENERATE_X64_MASM -size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len) +size_t GCM_Base::AuthenticateBlocks(const ::byte *data, size_t len) { #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE if (HasCLMUL()) @@ -756,7 +756,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len) { case 0: // non-SSE2 and 2K tables { - byte *table = MulTable(); + ::byte *table = MulTable(); word64 x0 = hashBuffer[0], x1 = hashBuffer[1]; do @@ -824,7 +824,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len) case 2: // non-SSE2 and 64K tables { - byte *table = MulTable(); + ::byte *table = MulTable(); word64 x0 = hashBuffer[0], x1 = hashBuffer[1]; do @@ -1176,7 +1176,7 @@ void GCM_Base::AuthenticateLastConfidentialBlock() GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE); } -void GCM_Base::AuthenticateLastFooterBlock(byte *mac, size_t macSize) +void GCM_Base::AuthenticateLastFooterBlock(::byte *mac, size_t macSize) { m_ctr.Seek(0); ReverseHashBufferIfNeeded(); diff --git a/gcm.h b/gcm.h index de5fe8b5..089f595e 100644 --- a/gcm.h +++ b/gcm.h @@ -62,21 +62,21 @@ protected: {return false;} unsigned int AuthenticationBlockSize() const {return HASH_BLOCKSIZE;} - void SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms); - void Resync(const byte *iv, size_t len); - size_t AuthenticateBlocks(const byte *data, size_t len); + void SetKeyWithoutResync(const ::byte *userKey, size_t keylength, const NameValuePairs ¶ms); + void Resync(const ::byte *iv, size_t len); + size_t AuthenticateBlocks(const ::byte *data, size_t len); void AuthenticateLastHeaderBlock(); void AuthenticateLastConfidentialBlock(); - void AuthenticateLastFooterBlock(byte *mac, size_t macSize); + void AuthenticateLastFooterBlock(::byte *mac, size_t macSize); SymmetricCipher & AccessSymmetricCipher() {return m_ctr;} virtual BlockCipher & AccessBlockCipher() =0; virtual GCM_TablesOption GetTablesOption() const =0; const BlockCipher & GetBlockCipher() const {return const_cast(this)->AccessBlockCipher();}; - byte *HashBuffer() {return m_buffer+REQUIRED_BLOCKSIZE;} - byte *HashKey() {return m_buffer+2*REQUIRED_BLOCKSIZE;} - byte *MulTable() {return m_buffer+3*REQUIRED_BLOCKSIZE;} + ::byte *HashBuffer() {return m_buffer+REQUIRED_BLOCKSIZE;} + ::byte *HashKey() {return m_buffer+2*REQUIRED_BLOCKSIZE;} + ::byte *MulTable() {return m_buffer+3*REQUIRED_BLOCKSIZE;} inline void ReverseHashBufferIfNeeded(); class CRYPTOPP_DLL GCTR : public CTR_Mode_ExternalCipher::Encryption diff --git a/gf256.h b/gf256.h index 4a3cd83d..c786b4ba 100644 --- a/gf256.h +++ b/gf256.h @@ -15,10 +15,10 @@ NAMESPACE_BEGIN(CryptoPP) class GF256 { public: - typedef byte Element; + typedef ::byte Element; typedef int RandomizationParameter; - GF256(byte modulus) : m_modulus(modulus) {} + GF256(::byte modulus) : m_modulus(modulus) {} Element RandomElement(RandomNumberGenerator &rng, int ignored = 0) const {CRYPTOPP_UNUSED(ignored); return rng.GenerateByte();} diff --git a/gf2n.cpp b/gf2n.cpp index a1d24ff3..5dada067 100644 --- a/gf2n.cpp +++ b/gf2n.cpp @@ -53,7 +53,7 @@ void PolynomialMod2::Randomize(RandomNumberGenerator &rng, size_t nbits) const size_t nbytes = nbits/8 + 1; SecByteBlock buf(nbytes); rng.GenerateBlock(buf, nbytes); - buf[0] = (byte)Crop(buf[0], nbits % 8); + buf[0] = (::byte)Crop(buf[0], nbits % 8); Decode(buf, nbytes); } @@ -80,15 +80,15 @@ void PolynomialMod2::SetBit(size_t n, int value) } } -byte PolynomialMod2::GetByte(size_t n) const +::byte PolynomialMod2::GetByte(size_t n) const { if (n/WORD_SIZE >= reg.size()) return 0; else - return byte(reg[n/WORD_SIZE] >> ((n%WORD_SIZE)*8)); + return ::byte(reg[n/WORD_SIZE] >> ((n%WORD_SIZE)*8)); } -void PolynomialMod2::SetByte(size_t n, byte value) +void PolynomialMod2::SetByte(size_t n, ::byte value) { reg.CleanGrow(BytesToWords(n+1)); reg[n/WORD_SIZE] &= ~(word(0xff) << 8*(n%WORD_SIZE)); @@ -141,13 +141,13 @@ const PolynomialMod2 &PolynomialMod2::One() return Singleton >().Ref(); } -void PolynomialMod2::Decode(const byte *input, size_t inputLen) +void PolynomialMod2::Decode(const ::byte *input, size_t inputLen) { StringStore store(input, inputLen); Decode(store, inputLen); } -void PolynomialMod2::Encode(byte *output, size_t outputLen) const +void PolynomialMod2::Encode(::byte *output, size_t outputLen) const { ArraySink sink(output, outputLen); Encode(sink, outputLen); @@ -163,7 +163,7 @@ void PolynomialMod2::Decode(BufferedTransformation &bt, size_t inputLen) for (size_t i=inputLen; i > 0; i--) { - byte b; + ::byte b; (void)bt.Get(b); reg[(i-1)/WORD_SIZE] |= word(b) << ((i-1)%WORD_SIZE)*8; } diff --git a/gf2n.h b/gf2n.h index 032876a1..7e55b85f 100644 --- a/gf2n.h +++ b/gf2n.h @@ -52,7 +52,7 @@ public: PolynomialMod2(word value, size_t bitLength=WORD_BITS); //! \brief Construct a PolynomialMod2 from big-endian byte array - PolynomialMod2(const byte *encodedPoly, size_t byteCount) + PolynomialMod2(const ::byte *encodedPoly, size_t byteCount) {Decode(encodedPoly, byteCount);} //! \brief Construct a PolynomialMod2 from big-endian form stored in a BufferedTransformation @@ -94,12 +94,12 @@ public: //! encode in big-endian format //! \details if outputLen < MinEncodedSize, the most significant bytes will be dropped //! if outputLen > MinEncodedSize, the most significant bytes will be padded - void Encode(byte *output, size_t outputLen) const; + void Encode(::byte *output, size_t outputLen) const; //! void Encode(BufferedTransformation &bt, size_t outputLen) const; //! - void Decode(const byte *input, size_t inputLen); + void Decode(const ::byte *input, size_t inputLen); //! //* Precondition: bt.MaxRetrievable() >= inputLen void Decode(BufferedTransformation &bt, size_t inputLen); @@ -122,7 +122,7 @@ public: //! return the n-th bit, n=0 being the least significant bit bool GetBit(size_t n) const {return GetCoefficient(n)!=0;} //! return the n-th byte - byte GetByte(size_t n) const; + ::byte GetByte(size_t n) const; //! the zero polynomial will return a degree of -1 signed int Degree() const {return (signed int)(BitCount()-1U);} @@ -169,7 +169,7 @@ public: //! void SetBit(size_t i, int value = 1); //! set the n-th byte to value - void SetByte(size_t n, byte value); + void SetByte(size_t n, ::byte value); //! void SetCoefficient(size_t i, int value) {SetBit(i, value);} diff --git a/gfpcrypt.cpp b/gfpcrypt.cpp index 6494b084..0acc5b51 100644 --- a/gfpcrypt.cpp +++ b/gfpcrypt.cpp @@ -80,9 +80,9 @@ bool DL_GroupParameters_DSA::ValidateGroup(RandomNumberGenerator &rng, unsigned } void DL_SignatureMessageEncodingMethod_DSA::ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const + ::byte *representative, size_t representativeBitLength) const { CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(recoverableMessageLength); CRYPTOPP_UNUSED(messageEmpty), CRYPTOPP_UNUSED(hashIdentifier); @@ -105,9 +105,9 @@ void DL_SignatureMessageEncodingMethod_DSA::ComputeMessageRepresentative(RandomN } void DL_SignatureMessageEncodingMethod_NR::ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const + ::byte *representative, size_t representativeBitLength) const { CRYPTOPP_UNUSED(rng);CRYPTOPP_UNUSED(recoverableMessage); CRYPTOPP_UNUSED(recoverableMessageLength); CRYPTOPP_UNUSED(hash); CRYPTOPP_UNUSED(hashIdentifier); CRYPTOPP_UNUSED(messageEmpty); @@ -229,7 +229,7 @@ void DL_GroupParameters_IntegerBased::GenerateRandom(RandomNumberGenerator &rng, Initialize(p, q, g); } -void DL_GroupParameters_IntegerBased::EncodeElement(bool reversible, const Element &element, byte *encoded) const +void DL_GroupParameters_IntegerBased::EncodeElement(bool reversible, const Element &element, ::byte *encoded) const { CRYPTOPP_UNUSED(reversible); element.Encode(encoded, GetModulus().ByteCount()); @@ -241,7 +241,7 @@ unsigned int DL_GroupParameters_IntegerBased::GetEncodedElementSize(bool reversi return GetModulus().ByteCount(); } -Integer DL_GroupParameters_IntegerBased::DecodeElement(const byte *encoded, bool checkForGroupMembership) const +Integer DL_GroupParameters_IntegerBased::DecodeElement(const ::byte *encoded, bool checkForGroupMembership) const { CRYPTOPP_UNUSED(checkForGroupMembership); Integer g(encoded, GetModulus().ByteCount()); diff --git a/gfpcrypt.h b/gfpcrypt.h index 5addf8ed..57cb3956 100644 --- a/gfpcrypt.h +++ b/gfpcrypt.h @@ -84,10 +84,10 @@ public: bool FastSubgroupCheckAvailable() const {return GetCofactor() == 2;} // Cygwin i386 crash at -O3; see http://github.com/weidai11/cryptopp/issues/40. - void EncodeElement(bool reversible, const Element &element, byte *encoded) const; + void EncodeElement(bool reversible, const Element &element, ::byte *encoded) const; unsigned int GetEncodedElementSize(bool reversible) const; - Integer DecodeElement(const byte *encoded, bool checkForGroupMembership) const; + Integer DecodeElement(const ::byte *encoded, bool checkForGroupMembership) const; Integer ConvertElementToInteger(const Element &element) const {return element;} Integer GetMaxExponent() const; @@ -249,7 +249,7 @@ public: // Deterministic K Integer GenerateRandom(const Integer &x, const Integer &q, const Integer &e) const { - static const byte zero = 0, one = 1; + static const ::byte zero = 0, one = 1; const size_t qlen = q.BitCount(); const size_t rlen = BitsToBytes(qlen); @@ -808,10 +808,10 @@ public: {return plaintextLength + static_cast(MAC::DIGESTSIZE);} size_t GetMaxSymmetricPlaintextLength(size_t ciphertextLength) const {return SaturatingSubtract(ciphertextLength, static_cast(MAC::DIGESTSIZE));} - void SymmetricEncrypt(RandomNumberGenerator &rng, const byte *key, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters) const + void SymmetricEncrypt(RandomNumberGenerator &rng, const ::byte *key, const ::byte *plaintext, size_t plaintextLength, ::byte *ciphertext, const NameValuePairs ¶meters) const { CRYPTOPP_UNUSED(rng); - const byte *cipherKey = NULLPTR, *macKey = NULLPTR; + const ::byte *cipherKey = NULLPTR, *macKey = NULLPTR; if (DHAES_MODE) { macKey = key; @@ -834,16 +834,16 @@ public: mac.Update(encodingParameters.begin(), encodingParameters.size()); if (DHAES_MODE) { - byte L[8]; + ::byte L[8]; PutWord(false, BIG_ENDIAN_ORDER, L, (LABEL_OCTETS ? word64(encodingParameters.size()) : 8 * word64(encodingParameters.size()))); mac.Update(L, 8); } mac.Final(ciphertext + plaintextLength); } - DecodingResult SymmetricDecrypt(const byte *key, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters) const + DecodingResult SymmetricDecrypt(const ::byte *key, const ::byte *ciphertext, size_t ciphertextLength, ::byte *plaintext, const NameValuePairs ¶meters) const { size_t plaintextLength = GetMaxSymmetricPlaintextLength(ciphertextLength); - const byte *cipherKey, *macKey; + const ::byte *cipherKey, *macKey; if (DHAES_MODE) { macKey = key; @@ -863,7 +863,7 @@ public: mac.Update(encodingParameters.begin(), encodingParameters.size()); if (DHAES_MODE) { - byte L[8]; + ::byte L[8]; PutWord(false, BIG_ENDIAN_ORDER, L, (LABEL_OCTETS ? word64(encodingParameters.size()) : 8 * word64(encodingParameters.size()))); mac.Update(L, 8); } @@ -885,7 +885,7 @@ public: virtual ~DL_KeyDerivationAlgorithm_P1363() {} bool ParameterSupported(const char *name) const {return strcmp(name, Name::KeyDerivationParameters()) == 0;} - void Derive(const DL_GroupParameters ¶ms, byte *derivedKey, size_t derivedLength, const T &agreedElement, const T &ephemeralPublicKey, const NameValuePairs ¶meters) const + void Derive(const DL_GroupParameters ¶ms, ::byte *derivedKey, size_t derivedLength, const T &agreedElement, const T &ephemeralPublicKey, const NameValuePairs ¶meters) const { SecByteBlock agreedSecret; if (DHAES_MODE) diff --git a/gost.cpp b/gost.cpp index dbeff911..be6da2d2 100644 --- a/gost.cpp +++ b/gost.cpp @@ -5,7 +5,7 @@ NAMESPACE_BEGIN(CryptoPP) // these are the S-boxes given in Applied Cryptography 2nd Ed., p. 333 -const byte GOST::Base::sBox[8][16]={ +const ::byte GOST::Base::sBox[8][16]={ {4, 10, 9, 2, 13, 8, 0, 14, 6, 11, 1, 12, 7, 15, 5, 3}, {14, 11, 4, 12, 6, 13, 15, 10, 2, 3, 8, 1, 0, 7, 5, 9}, {5, 8, 1, 13, 10, 3, 4, 2, 14, 15, 12, 7, 6, 0, 9, 11}, @@ -30,7 +30,7 @@ const byte GOST::Base::sBox[8][16]={ volatile bool GOST::Base::sTableCalculated = false; word32 GOST::Base::sTable[4][256]; -void GOST::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &) +void GOST::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); @@ -60,7 +60,7 @@ void GOST::Base::PrecalculateSTable() typedef BlockGetAndPut Block; -void GOST::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void GOST::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 n1, n2, t; @@ -90,7 +90,7 @@ void GOST::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by Block::Put(xorBlock, outBlock)(n2)(n1); } -void GOST::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void GOST::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 n1, n2, t; diff --git a/gost.h b/gost.h index 153bfbb0..a29cdb8c 100644 --- a/gost.h +++ b/gost.h @@ -28,12 +28,12 @@ class GOST : public GOST_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: static void PrecalculateSTable(); - static const byte sBox[8][16]; + static const ::byte sBox[8][16]; static volatile bool sTableCalculated; static word32 sTable[4][256]; @@ -45,7 +45,7 @@ class GOST : public GOST_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 @@ -53,7 +53,7 @@ class GOST : public GOST_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: diff --git a/gzip.cpp b/gzip.cpp index 2007bf80..11f5430f 100644 --- a/gzip.cpp +++ b/gzip.cpp @@ -36,9 +36,9 @@ void Gzip::WritePrestreamHeader() AttachedTransformation()->Put(MAGIC1); AttachedTransformation()->Put(MAGIC2); AttachedTransformation()->Put(DEFLATED); - AttachedTransformation()->Put((byte)flags); // general flag + AttachedTransformation()->Put((::byte)flags); // general flag AttachedTransformation()->PutWord32(m_filetime, LITTLE_ENDIAN_ORDER); // time stamp - byte extra = (GetDeflateLevel() == 1) ? FAST : ((GetDeflateLevel() == 9) ? SLOW : 0); + ::byte extra = (GetDeflateLevel() == 1) ? FAST : ((GetDeflateLevel() == 9) ? SLOW : 0); AttachedTransformation()->Put(extra); AttachedTransformation()->Put(GZIP_OS_CODE); @@ -51,7 +51,7 @@ void Gzip::WritePrestreamHeader() AttachedTransformation()->Put((const unsigned char*)m_comment.data(), m_comment.size() +1); } -void Gzip::ProcessUncompressedData(const byte *inString, size_t length) +void Gzip::ProcessUncompressedData(const ::byte *inString, size_t length) { m_crc.Update(inString, length); m_totalLen += (word32)length; @@ -113,8 +113,8 @@ void Gunzip::ProcessPrestreamHeader() m_filename.clear(); m_comment.clear(); - byte buf[6]; - byte b, flags; + ::byte buf[6]; + ::byte b, flags; if (m_inQueue.Get(buf, 2)!=2) throw HeaderErr(); if (buf[0] != MAGIC1 || buf[1] != MAGIC2) throw HeaderErr(); @@ -152,7 +152,7 @@ void Gunzip::ProcessPrestreamHeader() } } -void Gunzip::ProcessDecompressedData(const byte *inString, size_t length) +void Gunzip::ProcessDecompressedData(const ::byte *inString, size_t length) { AttachedTransformation()->Put(inString, length); m_crc.Update(inString, length); diff --git a/gzip.h b/gzip.h index 0c3f53df..cf66106f 100644 --- a/gzip.h +++ b/gzip.h @@ -66,7 +66,7 @@ protected: FILENAME=8, COMMENTS=16}; void WritePrestreamHeader(); - void ProcessUncompressedData(const byte *string, size_t length); + void ProcessUncompressedData(const ::byte *string, size_t length); void WritePoststreamTail(); word32 m_totalLen; @@ -133,7 +133,7 @@ protected: unsigned int MaxPrestreamHeaderSize() const {return 1024;} void ProcessPrestreamHeader(); - void ProcessDecompressedData(const byte *string, size_t length); + void ProcessDecompressedData(const ::byte *string, size_t length); unsigned int MaxPoststreamTailSize() const {return 8;} void ProcessPoststreamTail(); diff --git a/hex.cpp b/hex.cpp index 3871c4bd..60e06916 100644 --- a/hex.cpp +++ b/hex.cpp @@ -10,8 +10,8 @@ NAMESPACE_BEGIN(CryptoPP) namespace { - const byte s_vecUpper[] = "0123456789ABCDEF"; - const byte s_vecLower[] = "0123456789abcdef"; + const ::byte s_vecUpper[] = "0123456789ABCDEF"; + const ::byte s_vecLower[] = "0123456789abcdef"; } void HexEncoder::IsolatedInitialize(const NameValuePairs ¶meters) diff --git a/hkdf.h b/hkdf.h index a77d9876..1b8edf3c 100644 --- a/hkdf.h +++ b/hkdf.h @@ -22,7 +22,7 @@ public: virtual size_t MaxDerivedKeyLength() const =0; virtual bool Usesinfo() const =0; //! derive a key from secret - virtual unsigned int DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const byte *salt, size_t saltLen, const byte* info=NULLPTR, size_t infoLen=0) const =0; + virtual unsigned int DeriveKey(::byte *derived, size_t derivedLen, const ::byte *secret, size_t secretLen, const ::byte *salt, size_t saltLen, const ::byte* info=NULLPTR, size_t infoLen=0) const =0; virtual ~KeyDerivationFunction() {} }; @@ -44,12 +44,12 @@ public: } size_t MaxDerivedKeyLength() const {return static_cast(T::DIGESTSIZE) * 255;} bool Usesinfo() const {return true;} - unsigned int DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const byte *salt, size_t saltLen, const byte* info, size_t infoLen) const; + unsigned int DeriveKey(::byte *derived, size_t derivedLen, const ::byte *secret, size_t secretLen, const ::byte *salt, size_t saltLen, const ::byte* info, size_t infoLen) const; protected: // If salt is missing (NULLPTR), then use the NULL vector. Missing is different than EMPTY (0 length). The length // of s_NullVector used depends on the Hash function. SHA-256 will use 32 bytes of s_NullVector. - typedef byte NullVectorType[SALTSIZE]; + typedef ::byte NullVectorType[SALTSIZE]; static const NullVectorType& GetNullVector() { static const NullVectorType s_NullVector = {0}; return s_NullVector; @@ -57,7 +57,7 @@ protected: }; template -unsigned int HKDF::DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const byte *salt, size_t saltLen, const byte* info, size_t infoLen) const +unsigned int HKDF::DeriveKey(::byte *derived, size_t derivedLen, const ::byte *secret, size_t secretLen, const ::byte *salt, size_t saltLen, const ::byte* info, size_t infoLen) const { static const size_t DIGEST_SIZE = static_cast(T::DIGESTSIZE); const unsigned int req = static_cast(derivedLen); @@ -70,10 +70,10 @@ unsigned int HKDF::DeriveKey(byte *derived, size_t derivedLen, const byte *se throw InvalidArgument("HKDF: derivedLen must be less than or equal to MaxDerivedKeyLength"); HMAC hmac; - FixedSizeSecBlock prk, buffer; + FixedSizeSecBlock< ::byte, DIGEST_SIZE> prk, buffer; // Extract - const byte* key = (salt ? salt : GetNullVector()); + const ::byte* key = (salt ? salt : GetNullVector()); const size_t klen = (salt ? saltLen : DIGEST_SIZE); hmac.SetKey(key, klen); @@ -81,7 +81,7 @@ unsigned int HKDF::DeriveKey(byte *derived, size_t derivedLen, const byte *se // Expand hmac.SetKey(prk.data(), prk.size()); - byte block = 0; + ::byte block = 0; while (derivedLen > 0) { diff --git a/hmac.cpp b/hmac.cpp index bda66530..71aa007f 100644 --- a/hmac.cpp +++ b/hmac.cpp @@ -8,7 +8,7 @@ NAMESPACE_BEGIN(CryptoPP) -void HMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &) +void HMAC_Base::UncheckedSetKey(const ::byte *userKey, unsigned int keylength, const NameValuePairs &) { AssertValidKeyLength(keylength); @@ -57,14 +57,14 @@ void HMAC_Base::Restart() } } -void HMAC_Base::Update(const byte *input, size_t length) +void HMAC_Base::Update(const ::byte *input, size_t length) { if (!m_innerHashKeyed) KeyInnerHash(); AccessHash().Update(input, length); } -void HMAC_Base::TruncatedFinal(byte *mac, size_t size) +void HMAC_Base::TruncatedFinal(::byte *mac, size_t size) { ThrowIfInvalidTruncatedSize(size); diff --git a/hmac.h b/hmac.h index f4f60f7b..3c9ce793 100644 --- a/hmac.h +++ b/hmac.h @@ -19,19 +19,19 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE HMAC_Base : public VariableKeyLength<16, 0 public: //! \brief Construct a HMAC_Base HMAC_Base() : m_innerHashKeyed(false) {} - void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int keylength, const NameValuePairs ¶ms); void Restart(); - void Update(const byte *input, size_t length); - void TruncatedFinal(byte *mac, size_t size); + void Update(const ::byte *input, size_t length); + void TruncatedFinal(::byte *mac, size_t size); unsigned int OptimalBlockSize() const {return const_cast(this)->AccessHash().OptimalBlockSize();} unsigned int DigestSize() const {return const_cast(this)->AccessHash().DigestSize();} protected: virtual HashTransformation & AccessHash() =0; - byte * AccessIpad() {return m_buf;} - byte * AccessOpad() {return m_buf + AccessHash().BlockSize();} - byte * AccessInnerHash() {return m_buf + 2*AccessHash().BlockSize();} + ::byte * AccessIpad() {return m_buf;} + ::byte * AccessOpad() {return m_buf + AccessHash().BlockSize();} + ::byte * AccessInnerHash() {return m_buf + 2*AccessHash().BlockSize();} private: void KeyInnerHash(); @@ -58,7 +58,7 @@ public: //! \brief Construct a HMAC //! \param key the HMAC key //! \param length the size of the HMAC key - HMAC(const byte *key, size_t length=HMAC_Base::DEFAULT_KEYLENGTH) + HMAC(const ::byte *key, size_t length=HMAC_Base::DEFAULT_KEYLENGTH) {this->SetKey(key, length);} static std::string StaticAlgorithmName() {return std::string("HMAC(") + T::StaticAlgorithmName() + ")";} diff --git a/hmqv.h b/hmqv.h index c25e5f1b..bebc0bb5 100644 --- a/hmqv.h +++ b/hmqv.h @@ -74,7 +74,7 @@ public: //! generate static private key /*! \pre size of privateKey == PrivateStaticKeyLength() */ - void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GenerateStaticPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const { Integer x(rng, Integer::One(), GetAbstractGroupParameters().GetMaxExponent()); x.Encode(privateKey, StaticPrivateKeyLength()); @@ -82,7 +82,7 @@ public: //! generate static public key /*! \pre size of publicKey == PublicStaticKeyLength() */ - void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GenerateStaticPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const { CRYPTOPP_UNUSED(rng); const DL_GroupParameters ¶ms = GetAbstractGroupParameters(); @@ -95,7 +95,7 @@ public: unsigned int EphemeralPublicKeyLength() const{return StaticPublicKeyLength();} //! return length of ephemeral private keys in this domain - void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const { const DL_GroupParameters ¶ms = GetAbstractGroupParameters(); Integer x(rng, Integer::One(), params.GetMaxExponent()); @@ -105,7 +105,7 @@ public: } //! return length of ephemeral public keys in this domain - void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const { CRYPTOPP_UNUSED(rng); memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength()); @@ -120,12 +120,12 @@ public: \pre length of staticOtherPublicKey == StaticPublicKeyLength() \pre length of ephemeralOtherPublicKey == EphemeralPublicKeyLength() */ - bool Agree(byte *agreedValue, - const byte *staticPrivateKey, const byte *ephemeralPrivateKey, - const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, + bool Agree(::byte *agreedValue, + const ::byte *staticPrivateKey, const ::byte *ephemeralPrivateKey, + const ::byte *staticOtherPublicKey, const ::byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const { - byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; + ::byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; size_t xxs = 0, yys = 0, aas = 0, bbs = 0; // Depending on the role, this will hold either A's or B's static @@ -142,11 +142,11 @@ public: Element B = params.ExponentiateBase(b); params.EncodeElement(true, B, tt); - XX = const_cast(ephemeralOtherPublicKey); + XX = const_cast< ::byte*>(ephemeralOtherPublicKey); xxs = EphemeralPublicKeyLength(); - YY = const_cast(ephemeralPrivateKey) + StaticPrivateKeyLength(); + YY = const_cast< ::byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength(); yys = EphemeralPublicKeyLength(); - AA = const_cast(staticOtherPublicKey); + AA = const_cast< ::byte*>(staticOtherPublicKey); aas = StaticPublicKeyLength(); BB = tt.BytePtr(); bbs = tt.SizeInBytes(); @@ -157,13 +157,13 @@ public: Element A = params.ExponentiateBase(a); params.EncodeElement(true, A, tt); - XX = const_cast(ephemeralPrivateKey) + StaticPrivateKeyLength(); + XX = const_cast< ::byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength(); xxs = EphemeralPublicKeyLength(); - YY = const_cast(ephemeralOtherPublicKey); + YY = const_cast< ::byte*>(ephemeralOtherPublicKey); yys = EphemeralPublicKeyLength(); AA = tt.BytePtr(); aas = tt.SizeInBytes(); - BB = const_cast(staticOtherPublicKey); + BB = const_cast< ::byte*>(staticOtherPublicKey); bbs = StaticPublicKeyLength(); } else @@ -245,9 +245,9 @@ protected: // each provides. inline void Hash(const Element* sigma, - const byte* e1, size_t e1len, // Ephemeral key and key length - const byte* s1, size_t s1len, // Static key and key length - byte* digest, size_t dlen) const + const ::byte* e1, size_t e1len, // Ephemeral key and key length + const ::byte* s1, size_t s1len, // Static key and key length + ::byte* digest, size_t dlen) const { HASH hash; size_t idx = 0, req = dlen; diff --git a/ida.cpp b/ida.cpp index 125ab979..9a9408d8 100644 --- a/ida.cpp +++ b/ida.cpp @@ -18,11 +18,11 @@ NAMESPACE_BEGIN(CryptoPP) #if (defined(_MSC_VER) && (_MSC_VER < 1400)) && !defined(__MWERKS__) // VC60 and VC7 workaround: built-in reverse_iterator has two template parameters, Dinkumware only has one - typedef std::reverse_bidirectional_iterator RevIt; + typedef std::reverse_bidirectional_iterator RevIt; #elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator RevIt; + typedef std::reverse_iterator RevIt; #else - typedef std::reverse_iterator RevIt; + typedef std::reverse_iterator RevIt; #endif void RawIDA::IsolatedInitialize(const NameValuePairs ¶meters) @@ -95,7 +95,7 @@ unsigned int RawIDA::LookupInputChannel(word32 channelId) const return it->second; } -void RawIDA::ChannelData(word32 channelId, const byte *inString, size_t length, bool messageEnd) +void RawIDA::ChannelData(word32 channelId, const ::byte *inString, size_t length, bool messageEnd) { int i = InsertInputChannel(channelId); if (i < m_threshold) @@ -250,7 +250,7 @@ void SecretSharing::IsolatedInitialize(const NameValuePairs ¶meters) m_ida.IsolatedInitialize(parameters); } -size_t SecretSharing::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t SecretSharing::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { if (!blocking) throw BlockingInputOnly("SecretSharing"); @@ -322,7 +322,7 @@ void InformationDispersal::IsolatedInitialize(const NameValuePairs ¶meters) m_ida.IsolatedInitialize(parameters); } -size_t InformationDispersal::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t InformationDispersal::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { if (!blocking) throw BlockingInputOnly("InformationDispersal"); @@ -380,16 +380,16 @@ void InformationRecovery::OutputMessageEnds() AttachedTransformation()->MessageEnd(GetAutoSignalPropagation()-1); } -size_t PaddingRemover::Put2(const byte *begin, size_t length, int messageEnd, bool blocking) +size_t PaddingRemover::Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { if (!blocking) throw BlockingInputOnly("PaddingRemover"); - const byte *const end = begin + length; + const ::byte *const end = begin + length; if (m_possiblePadding) { - size_t len = std::find_if(begin, end, std::bind2nd(std::not_equal_to(), byte(0))) - begin; + size_t len = std::find_if(begin, end, std::bind2nd(std::not_equal_to< ::byte>(), ::byte(0))) - begin; m_zeroCount += len; begin += len; if (begin == end) @@ -402,7 +402,7 @@ size_t PaddingRemover::Put2(const byte *begin, size_t length, int messageEnd, bo m_possiblePadding = false; } - const byte *x = std::find_if(RevIt(end), RevIt(begin), std::bind2nd(std::not_equal_to(), byte(0))).base(); + const ::byte *x = std::find_if(RevIt(end), RevIt(begin), std::bind2nd(std::not_equal_to< ::byte>(), ::byte(0))).base(); if (x != begin && *(x-1) == 1) { AttachedTransformation()->Put(begin, x-begin-1); diff --git a/ida.h b/ida.h index a1e29067..b023cab5 100644 --- a/ida.h +++ b/ida.h @@ -28,11 +28,11 @@ public: unsigned int GetThreshold() const {return m_threshold;} void AddOutputChannel(word32 channelId); - void ChannelData(word32 channelId, const byte *inString, size_t length, bool messageEnd); + void ChannelData(word32 channelId, const ::byte *inString, size_t length, bool messageEnd); lword InputBuffered(word32 channelId) const; void IsolatedInitialize(const NameValuePairs ¶meters=g_nullNameValuePairs); - size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) + size_t ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking) { if (!blocking) throw BlockingInputOnly("RawIDA"); @@ -80,7 +80,7 @@ public: } void IsolatedInitialize(const NameValuePairs ¶meters=g_nullNameValuePairs); - size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking); bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) {return m_ida.Flush(hardFlush, propagation, blocking);} protected: @@ -130,7 +130,7 @@ public: } void IsolatedInitialize(const NameValuePairs ¶meters=g_nullNameValuePairs); - size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking); bool Flush(bool hardFlush, int propagation=-1, bool blocking=true) {return m_ida.Flush(hardFlush, propagation, blocking);} protected: @@ -170,7 +170,7 @@ public: void IsolatedInitialize(const NameValuePairs ¶meters) {CRYPTOPP_UNUSED(parameters); m_possiblePadding = false;} - size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking); // GetPossiblePadding() == false at the end of a message indicates incorrect padding bool GetPossiblePadding() const {return m_possiblePadding;} diff --git a/idea.cpp b/idea.cpp index dde2fdb4..567edec2 100644 --- a/idea.cpp +++ b/idea.cpp @@ -77,7 +77,7 @@ inline void IDEA::Base::LookupMUL(IDEA::Word &a, IDEA::Word b) } #endif // IDEA_LARGECACHE -void IDEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &) +void IDEA::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); @@ -95,7 +95,7 @@ void IDEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const #endif } -void IDEA::Base::EnKey (const byte *userKey) +void IDEA::Base::EnKey (const ::byte *userKey) { unsigned int i; @@ -154,7 +154,7 @@ void IDEA::Base::DeKey() #define MUL(a,b) DirectMUL(a,b) #endif -void IDEA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void IDEA::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { typedef BlockGetAndPut Block; diff --git a/idea.h b/idea.h index ec1f8c83..f1b30ead 100644 --- a/idea.h +++ b/idea.h @@ -37,12 +37,12 @@ private: { public: unsigned int OptimalDataAlignment() const {return 2;} - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); private: - void EnKey(const byte *); + void EnKey(const ::byte *); void DeKey(); FixedSizeSecBlock m_key; diff --git a/integer.cpp b/integer.cpp index 13a58a4e..5c7e6357 100644 --- a/integer.cpp +++ b/integer.cpp @@ -3040,7 +3040,7 @@ Integer::Integer(BufferedTransformation &encodedInteger, size_t byteCount, Signe Decode(encodedInteger, byteCount, s); } -Integer::Integer(const byte *encodedInteger, size_t byteCount, Signedness s, ByteOrder o) +Integer::Integer(const ::byte *encodedInteger, size_t byteCount, Signedness s, ByteOrder o) { CRYPTOPP_ASSERT(encodedInteger && byteCount); // NULL buffer CRYPTOPP_ASSERT(o == BIG_ENDIAN_ORDER || o == LITTLE_ENDIAN_ORDER); @@ -3152,17 +3152,17 @@ void Integer::SetBit(size_t n, bool value) } } -byte Integer::GetByte(size_t n) const +::byte Integer::GetByte(size_t n) const { // Profiling tells us the original Else was dominant, so it was promoted to the first If statement. // The code change occurred at Commit dc99266599a0e72d. if (n/WORD_SIZE < reg.size()) - return byte(reg[n/WORD_SIZE] >> ((n%WORD_SIZE)*8)); + return ::byte(reg[n/WORD_SIZE] >> ((n%WORD_SIZE)*8)); else return 0; } -void Integer::SetByte(size_t n, byte value) +void Integer::SetByte(size_t n, ::byte value) { reg.CleanGrow(RoundupSize(BytesToWords(n+1))); reg[n/WORD_SIZE] &= ~(word(0xff) << 8*(n%WORD_SIZE)); @@ -3377,7 +3377,7 @@ unsigned int Integer::BitCount() const return 0; } -void Integer::Decode(const byte *input, size_t inputLen, Signedness s) +void Integer::Decode(const ::byte *input, size_t inputLen, Signedness s) { CRYPTOPP_ASSERT(input && inputLen); // NULL buffer StringStore store(input, inputLen); @@ -3390,7 +3390,7 @@ void Integer::Decode(BufferedTransformation &bt, size_t inputLen, Signedness s) if (bt.MaxRetrievable() < inputLen) throw InvalidArgument("Integer: input length is too small"); - byte b; + ::byte b; bt.Peek(b); sign = ((s==SIGNED) && (b & 0x80)) ? NEGATIVE : POSITIVE; @@ -3432,7 +3432,7 @@ size_t Integer::MinEncodedSize(Signedness signedness) const } // PKCS12_PBKDF and other classes use undersized buffers -void Integer::Encode(byte *output, size_t outputLen, Signedness signedness) const +void Integer::Encode(::byte *output, size_t outputLen, Signedness signedness) const { CRYPTOPP_ASSERT(output && outputLen); // NULL buffer ArraySink sink(output, outputLen); @@ -3461,7 +3461,7 @@ void Integer::DEREncode(BufferedTransformation &bt) const enc.MessageEnd(); } -void Integer::BERDecode(const byte *input, size_t len) +void Integer::BERDecode(const ::byte *input, size_t len) { CRYPTOPP_ASSERT(input && len); // NULL buffer StringStore store(input, len); @@ -3493,7 +3493,7 @@ void Integer::BERDecodeAsOctetString(BufferedTransformation &bt, size_t length) dec.MessageEnd(); } -size_t Integer::OpenPGPEncode(byte *output, size_t bufferSize) const +size_t Integer::OpenPGPEncode(::byte *output, size_t bufferSize) const { CRYPTOPP_ASSERT(output && bufferSize); // NULL buffer CRYPTOPP_ASSERT(bufferSize >= MinEncodedSize()); // Undersized buffer @@ -3510,7 +3510,7 @@ size_t Integer::OpenPGPEncode(BufferedTransformation &bt) const return 2 + byteCount; } -void Integer::OpenPGPDecode(const byte *input, size_t len) +void Integer::OpenPGPDecode(const ::byte *input, size_t len) { CRYPTOPP_ASSERT(input && len); // NULL buffer StringStore store(input, len); @@ -3531,7 +3531,7 @@ void Integer::Randomize(RandomNumberGenerator &rng, size_t nbits) SecByteBlock buf(nbytes); rng.GenerateBlock(buf, nbytes); if (nbytes) - buf[0] = (byte)Crop(buf[0], nbits % 8); + buf[0] = (::byte)Crop(buf[0], nbits % 8); Decode(buf, nbytes, UNSIGNED); } @@ -3560,13 +3560,13 @@ bool Integer::Randomize(RandomNumberGenerator &rng, const Integer &min, const In class KDF2_RNG : public RandomNumberGenerator { public: - KDF2_RNG(const byte *seed, size_t seedSize) + KDF2_RNG(const ::byte *seed, size_t seedSize) : m_counter(0), m_counterAndSeed(seedSize + 4) { memcpy(m_counterAndSeed + 4, seed, seedSize); } - void GenerateBlock(byte *output, size_t size) + void GenerateBlock(::byte *output, size_t size) { CRYPTOPP_ASSERT(output && size); // NULL buffer PutWord(false, BIG_ENDIAN_ORDER, m_counterAndSeed, m_counter); diff --git a/integer.h b/integer.h index 41700447..aaa3f4c6 100644 --- a/integer.h +++ b/integer.h @@ -142,7 +142,7 @@ public: //! \param order the ByteOrder of the array to be processed //! \details Byte order was added at Crypto++ 5.7 to allow use of little-endian //! integers with curve25519, Poly1305 and Microsoft CAPI. - Integer(const byte *encodedInteger, size_t byteCount, Signedness sign=UNSIGNED, ByteOrder order = BIG_ENDIAN_ORDER); + Integer(const ::byte *encodedInteger, size_t byteCount, Signedness sign=UNSIGNED, ByteOrder order = BIG_ENDIAN_ORDER); //! \brief Convert from a big-endian array //! \param bt BufferedTransformation object with big-endian byte array @@ -214,7 +214,7 @@ public: //! \details Unsigned means encode absolute value, signed means encode two's complement if negative. //! \details outputLen can be used to ensure an Integer is encoded to an exact size (rather than a //! minimum size). An exact size is useful, for example, when encoding to a field element size. - void Encode(byte *output, size_t outputLen, Signedness sign=UNSIGNED) const; + void Encode(::byte *output, size_t outputLen, Signedness sign=UNSIGNED) const; //! \brief Encode in big-endian format //! \param bt BufferedTransformation object @@ -242,7 +242,7 @@ public: //! \returns length of the output //! \details OpenPGPEncode places result into the buffer and returns the //! number of bytes used for the encoding - size_t OpenPGPEncode(byte *output, size_t bufferSize) const; + size_t OpenPGPEncode(::byte *output, size_t bufferSize) const; //! \brief Encode absolute value in OpenPGP format //! \param bt BufferedTransformation object @@ -255,7 +255,7 @@ public: //! \param input big-endian byte array //! \param inputLen length of the byte array //! \param sign enumeration indicating Signedness - void Decode(const byte *input, size_t inputLen, Signedness sign=UNSIGNED); + void Decode(const ::byte *input, size_t inputLen, Signedness sign=UNSIGNED); //! \brief Decode nonnegative value from big-endian byte array //! \param bt BufferedTransformation object @@ -267,7 +267,7 @@ public: //! \brief Decode from BER format //! \param input big-endian byte array //! \param inputLen length of the byte array - void BERDecode(const byte *input, size_t inputLen); + void BERDecode(const ::byte *input, size_t inputLen); //! \brief Decode from BER format //! \param bt BufferedTransformation object @@ -288,7 +288,7 @@ public: //! \brief Decode from OpenPGP format //! \param input big-endian byte array //! \param inputLen length of the byte array - void OpenPGPDecode(const byte *input, size_t inputLen); + void OpenPGPDecode(const ::byte *input, size_t inputLen); //! \brief Decode from OpenPGP format //! \param bt BufferedTransformation object void OpenPGPDecode(BufferedTransformation &bt); @@ -320,7 +320,7 @@ public: bool GetBit(size_t i) const; //! \brief Provides the i-th byte of the Integer //! \returns the i-th byte - byte GetByte(size_t i) const; + ::byte GetByte(size_t i) const; //! \brief Provides the low order bits of the Integer //! \returns n lowest bits of *this >> i lword GetBits(size_t i, size_t n) const; @@ -460,7 +460,7 @@ public: //! \brief Set the n-th byte to value //! \details 0-based numbering. - void SetByte(size_t n, byte value); + void SetByte(size_t n, ::byte value); //! \brief Reverse the Sign of the Integer void Negate(); diff --git a/iterhash.cpp b/iterhash.cpp index eedd5172..5eb46ad9 100644 --- a/iterhash.cpp +++ b/iterhash.cpp @@ -10,7 +10,7 @@ NAMESPACE_BEGIN(CryptoPP) -template void IteratedHashBase::Update(const byte *input, size_t len) +template void IteratedHashBase::Update(const ::byte *input, size_t len) { HashWordType oldCountLo = m_countLo, oldCountHi = m_countHi; if ((m_countLo = oldCountLo + HashWordType(len)) < oldCountLo) @@ -23,7 +23,7 @@ template void IteratedHashBase::Update(const byte unsigned int num = ModPowerOf2(oldCountLo, blockSize); T* dataBuf = this->DataBuf(); - byte* data = (byte *)dataBuf; + ::byte* data = (::byte *)dataBuf; CRYPTOPP_ASSERT(dataBuf && data); if (num != 0) // process left over data @@ -73,12 +73,12 @@ template void IteratedHashBase::Update(const byte memcpy(data, input, len); } -template byte * IteratedHashBase::CreateUpdateSpace(size_t &size) +template ::byte * IteratedHashBase::CreateUpdateSpace(size_t &size) { unsigned int blockSize = this->BlockSize(); unsigned int num = ModPowerOf2(m_countLo, blockSize); size = blockSize - num; - return (byte *)DataBuf() + num; + return (::byte *)DataBuf() + num; } template size_t IteratedHashBase::HashMultipleBlocks(const T *input, size_t length) @@ -103,12 +103,12 @@ template size_t IteratedHashBase::HashMultipleBlo return length; } -template void IteratedHashBase::PadLastBlock(unsigned int lastBlockSize, byte padFirst) +template void IteratedHashBase::PadLastBlock(unsigned int lastBlockSize, ::byte padFirst) { unsigned int blockSize = this->BlockSize(); unsigned int num = ModPowerOf2(m_countLo, blockSize); T* dataBuf = this->DataBuf(); - byte* data = (byte *)dataBuf; + ::byte* data = (::byte *)dataBuf; data[num++] = padFirst; if (num <= lastBlockSize) memset(data+num, 0, lastBlockSize-num); @@ -126,7 +126,7 @@ template void IteratedHashBase::Restart() Init(); } -template void IteratedHashBase::TruncatedFinal(byte *digest, size_t size) +template void IteratedHashBase::TruncatedFinal(::byte *digest, size_t size) { this->ThrowIfInvalidTruncatedSize(size); diff --git a/iterhash.h b/iterhash.h index 5ab38825..7ffc6d90 100644 --- a/iterhash.h +++ b/iterhash.h @@ -57,7 +57,7 @@ public: //! \brief Updates a hash with additional input //! \param input the additional input as a buffer //! \param length the size of the buffer, in bytes - void Update(const byte *input, size_t length); + void Update(const ::byte *input, size_t length); //! \brief Requests space which can be written into by the caller //! \param size the requested size of the buffer @@ -67,7 +67,7 @@ public: //! the array returned to the caller. //! \details The base class implementation sets size to 0 and returns NULL. //! \note Some objects, like ArraySink, cannot create a space because its fixed. - byte * CreateUpdateSpace(size_t &size); + ::byte * CreateUpdateSpace(size_t &size); //! \brief Restart the hash //! \details Discards the current state, and restart for a new message @@ -78,13 +78,13 @@ public: //! \param digestSize the size of the truncated digest, in bytes //! \details TruncatedFinal() call Final() and then copies digestSize bytes to digest. //! The hash is restarted the hash for the next message. - void TruncatedFinal(byte *digest, size_t digestSize); + void TruncatedFinal(::byte *digest, size_t digestSize); protected: inline T GetBitCountHi() const {return (m_countLo >> (8*sizeof(T)-3)) + (m_countHi << 3);} inline T GetBitCountLo() const {return m_countLo << 3;} - void PadLastBlock(unsigned int lastBlockSize, byte padFirst=0x80); + void PadLastBlock(unsigned int lastBlockSize, ::byte padFirst=0x80); virtual void Init() =0; virtual ByteOrder GetByteOrder() const =0; diff --git a/kalyna.cpp b/kalyna.cpp index f4c3cc0e..615c5369 100644 --- a/kalyna.cpp +++ b/kalyna.cpp @@ -23,8 +23,8 @@ NAMESPACE_BEGIN(KalynaTab) // T can be shared between Kupyna and Kalyna; IT, S and IS are Kalyna specific extern const word64 T[8][256]; // Columns extern const word64 IT[8][256]; // Inverse -extern const byte S[4][256]; // Substitution -extern const byte IS[4][256]; // Inverse +extern const ::byte S[4][256]; // Substitution +extern const ::byte IS[4][256]; // Inverse NAMESPACE_END NAMESPACE_END @@ -73,8 +73,8 @@ inline void MakeOddKey(const word64 evenkey[NB], word64 oddkey[NB]) static const unsigned int U = (NB == 2) ? 16 : (NB == 4) ? 32 : (NB == 8) ? 64 : -1; static const unsigned int V = (NB == 2) ? 7 : (NB == 4) ? 11 : (NB == 8) ? 19 : -1; - const byte* even = reinterpret_cast(evenkey); - byte* odd = reinterpret_cast(oddkey); + const ::byte* even = reinterpret_cast(evenkey); + ::byte* odd = reinterpret_cast< ::byte*>(oddkey); memcpy(odd, even + V, U - V); memcpy(odd + U - V, even, V); @@ -169,242 +169,242 @@ static inline void AddConstant(word64 src[NB], word64 dst[NB], word64 constant) inline void G0128(const word64 x[2], word64 y[2]) { - y[0] = T[0][(byte)x[0]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[1] >> 56)]; - y[1] = T[0][(byte)x[1]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[0] >> 56)]; + y[0] = T[0][(::byte)x[0]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]; + y[1] = T[0][(::byte)x[1]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]; } inline void G0256(const word64 x[4], word64 y[4]) { - y[0] = T[0][(byte)x[0]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[3] >> 16)] ^ T[3][(byte)(x[3] >> 24)] ^ - T[4][(byte)(x[2] >> 32)] ^ T[5][(byte)(x[2] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[1] >> 56)]; - y[1] = T[0][(byte)x[1]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[3] >> 32)] ^ T[5][(byte)(x[3] >> 40)] ^ T[6][(byte)(x[2] >> 48)] ^ T[7][(byte)(x[2] >> 56)]; - y[2] = T[0][(byte)x[2]] ^ T[1][(byte)(x[2] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[3] >> 48)] ^ T[7][(byte)(x[3] >> 56)]; - y[3] = T[0][(byte)x[3]] ^ T[1][(byte)(x[3] >> 8)] ^ T[2][(byte)(x[2] >> 16)] ^ T[3][(byte)(x[2] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[0] >> 56)]; + y[0] = T[0][(::byte)x[0]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[3] >> 16)] ^ T[3][(::byte)(x[3] >> 24)] ^ + T[4][(::byte)(x[2] >> 32)] ^ T[5][(::byte)(x[2] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]; + y[1] = T[0][(::byte)x[1]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[3] >> 32)] ^ T[5][(::byte)(x[3] >> 40)] ^ T[6][(::byte)(x[2] >> 48)] ^ T[7][(::byte)(x[2] >> 56)]; + y[2] = T[0][(::byte)x[2]] ^ T[1][(::byte)(x[2] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[3] >> 48)] ^ T[7][(::byte)(x[3] >> 56)]; + y[3] = T[0][(::byte)x[3]] ^ T[1][(::byte)(x[3] >> 8)] ^ T[2][(::byte)(x[2] >> 16)] ^ T[3][(::byte)(x[2] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]; } inline void G0512(const word64 x[8], word64 y[8]) { - y[0] = T[0][(byte)x[0]] ^ T[1][(byte)(x[7] >> 8)] ^ T[2][(byte)(x[6] >> 16)] ^ T[3][(byte)(x[5] >> 24)] ^ - T[4][(byte)(x[4] >> 32)] ^ T[5][(byte)(x[3] >> 40)] ^ T[6][(byte)(x[2] >> 48)] ^ T[7][(byte)(x[1] >> 56)]; - y[1] = T[0][(byte)x[1]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[7] >> 16)] ^ T[3][(byte)(x[6] >> 24)] ^ - T[4][(byte)(x[5] >> 32)] ^ T[5][(byte)(x[4] >> 40)] ^ T[6][(byte)(x[3] >> 48)] ^ T[7][(byte)(x[2] >> 56)]; - y[2] = T[0][(byte)x[2]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[7] >> 24)] ^ - T[4][(byte)(x[6] >> 32)] ^ T[5][(byte)(x[5] >> 40)] ^ T[6][(byte)(x[4] >> 48)] ^ T[7][(byte)(x[3] >> 56)]; - y[3] = T[0][(byte)x[3]] ^ T[1][(byte)(x[2] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[7] >> 32)] ^ T[5][(byte)(x[6] >> 40)] ^ T[6][(byte)(x[5] >> 48)] ^ T[7][(byte)(x[4] >> 56)]; - y[4] = T[0][(byte)x[4]] ^ T[1][(byte)(x[3] >> 8)] ^ T[2][(byte)(x[2] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[7] >> 40)] ^ T[6][(byte)(x[6] >> 48)] ^ T[7][(byte)(x[5] >> 56)]; - y[5] = T[0][(byte)x[5]] ^ T[1][(byte)(x[4] >> 8)] ^ T[2][(byte)(x[3] >> 16)] ^ T[3][(byte)(x[2] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[7] >> 48)] ^ T[7][(byte)(x[6] >> 56)]; - y[6] = T[0][(byte)x[6]] ^ T[1][(byte)(x[5] >> 8)] ^ T[2][(byte)(x[4] >> 16)] ^ T[3][(byte)(x[3] >> 24)] ^ - T[4][(byte)(x[2] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[7] >> 56)]; - y[7] = T[0][(byte)x[7]] ^ T[1][(byte)(x[6] >> 8)] ^ T[2][(byte)(x[5] >> 16)] ^ T[3][(byte)(x[4] >> 24)] ^ - T[4][(byte)(x[3] >> 32)] ^ T[5][(byte)(x[2] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[0] >> 56)]; + y[0] = T[0][(::byte)x[0]] ^ T[1][(::byte)(x[7] >> 8)] ^ T[2][(::byte)(x[6] >> 16)] ^ T[3][(::byte)(x[5] >> 24)] ^ + T[4][(::byte)(x[4] >> 32)] ^ T[5][(::byte)(x[3] >> 40)] ^ T[6][(::byte)(x[2] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]; + y[1] = T[0][(::byte)x[1]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[7] >> 16)] ^ T[3][(::byte)(x[6] >> 24)] ^ + T[4][(::byte)(x[5] >> 32)] ^ T[5][(::byte)(x[4] >> 40)] ^ T[6][(::byte)(x[3] >> 48)] ^ T[7][(::byte)(x[2] >> 56)]; + y[2] = T[0][(::byte)x[2]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[7] >> 24)] ^ + T[4][(::byte)(x[6] >> 32)] ^ T[5][(::byte)(x[5] >> 40)] ^ T[6][(::byte)(x[4] >> 48)] ^ T[7][(::byte)(x[3] >> 56)]; + y[3] = T[0][(::byte)x[3]] ^ T[1][(::byte)(x[2] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[7] >> 32)] ^ T[5][(::byte)(x[6] >> 40)] ^ T[6][(::byte)(x[5] >> 48)] ^ T[7][(::byte)(x[4] >> 56)]; + y[4] = T[0][(::byte)x[4]] ^ T[1][(::byte)(x[3] >> 8)] ^ T[2][(::byte)(x[2] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[7] >> 40)] ^ T[6][(::byte)(x[6] >> 48)] ^ T[7][(::byte)(x[5] >> 56)]; + y[5] = T[0][(::byte)x[5]] ^ T[1][(::byte)(x[4] >> 8)] ^ T[2][(::byte)(x[3] >> 16)] ^ T[3][(::byte)(x[2] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[7] >> 48)] ^ T[7][(::byte)(x[6] >> 56)]; + y[6] = T[0][(::byte)x[6]] ^ T[1][(::byte)(x[5] >> 8)] ^ T[2][(::byte)(x[4] >> 16)] ^ T[3][(::byte)(x[3] >> 24)] ^ + T[4][(::byte)(x[2] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[7] >> 56)]; + y[7] = T[0][(::byte)x[7]] ^ T[1][(::byte)(x[6] >> 8)] ^ T[2][(::byte)(x[5] >> 16)] ^ T[3][(::byte)(x[4] >> 24)] ^ + T[4][(::byte)(x[3] >> 32)] ^ T[5][(::byte)(x[2] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]; } inline void GL128(const word64 x[2], word64 y[2], const word64 k[2]) { - y[0] = k[0] + (T[0][(byte)x[0]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[1] >> 56)]); - y[1] = k[1] + (T[0][(byte)x[1]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[0] >> 56)]); + y[0] = k[0] + (T[0][(::byte)x[0]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]); + y[1] = k[1] + (T[0][(::byte)x[1]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]); } inline void GL256(const word64 x[4], word64 y[4], const word64 k[4]) { - y[0] = k[0] + (T[0][(byte)x[0]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[3] >> 16)] ^ T[3][(byte)(x[3] >> 24)] ^ - T[4][(byte)(x[2] >> 32)] ^ T[5][(byte)(x[2] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[1] >> 56)]); - y[1] = k[1] + (T[0][(byte)x[1]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[3] >> 32)] ^ T[5][(byte)(x[3] >> 40)] ^ T[6][(byte)(x[2] >> 48)] ^ T[7][(byte)(x[2] >> 56)]); - y[2] = k[2] + (T[0][(byte)x[2]] ^ T[1][(byte)(x[2] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[3] >> 48)] ^ T[7][(byte)(x[3] >> 56)]); - y[3] = k[3] + (T[0][(byte)x[3]] ^ T[1][(byte)(x[3] >> 8)] ^ T[2][(byte)(x[2] >> 16)] ^ T[3][(byte)(x[2] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[0] >> 56)]); + y[0] = k[0] + (T[0][(::byte)x[0]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[3] >> 16)] ^ T[3][(::byte)(x[3] >> 24)] ^ + T[4][(::byte)(x[2] >> 32)] ^ T[5][(::byte)(x[2] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]); + y[1] = k[1] + (T[0][(::byte)x[1]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[3] >> 32)] ^ T[5][(::byte)(x[3] >> 40)] ^ T[6][(::byte)(x[2] >> 48)] ^ T[7][(::byte)(x[2] >> 56)]); + y[2] = k[2] + (T[0][(::byte)x[2]] ^ T[1][(::byte)(x[2] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[3] >> 48)] ^ T[7][(::byte)(x[3] >> 56)]); + y[3] = k[3] + (T[0][(::byte)x[3]] ^ T[1][(::byte)(x[3] >> 8)] ^ T[2][(::byte)(x[2] >> 16)] ^ T[3][(::byte)(x[2] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]); } inline void GL512(const word64 x[8], word64 y[8], const word64 k[8]) { - y[0] = k[0] + (T[0][(byte)x[0]] ^ T[1][(byte)(x[7] >> 8)] ^ T[2][(byte)(x[6] >> 16)] ^ T[3][(byte)(x[5] >> 24)] ^ - T[4][(byte)(x[4] >> 32)] ^ T[5][(byte)(x[3] >> 40)] ^ T[6][(byte)(x[2] >> 48)] ^ T[7][(byte)(x[1] >> 56)]); - y[1] = k[1] + (T[0][(byte)x[1]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[7] >> 16)] ^ T[3][(byte)(x[6] >> 24)] ^ - T[4][(byte)(x[5] >> 32)] ^ T[5][(byte)(x[4] >> 40)] ^ T[6][(byte)(x[3] >> 48)] ^ T[7][(byte)(x[2] >> 56)]); - y[2] = k[2] + (T[0][(byte)x[2]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[7] >> 24)] ^ - T[4][(byte)(x[6] >> 32)] ^ T[5][(byte)(x[5] >> 40)] ^ T[6][(byte)(x[4] >> 48)] ^ T[7][(byte)(x[3] >> 56)]); - y[3] = k[3] + (T[0][(byte)x[3]] ^ T[1][(byte)(x[2] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[7] >> 32)] ^ T[5][(byte)(x[6] >> 40)] ^ T[6][(byte)(x[5] >> 48)] ^ T[7][(byte)(x[4] >> 56)]); - y[4] = k[4] + (T[0][(byte)x[4]] ^ T[1][(byte)(x[3] >> 8)] ^ T[2][(byte)(x[2] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[7] >> 40)] ^ T[6][(byte)(x[6] >> 48)] ^ T[7][(byte)(x[5] >> 56)]); - y[5] = k[5] + (T[0][(byte)x[5]] ^ T[1][(byte)(x[4] >> 8)] ^ T[2][(byte)(x[3] >> 16)] ^ T[3][(byte)(x[2] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[7] >> 48)] ^ T[7][(byte)(x[6] >> 56)]); - y[6] = k[6] + (T[0][(byte)x[6]] ^ T[1][(byte)(x[5] >> 8)] ^ T[2][(byte)(x[4] >> 16)] ^ T[3][(byte)(x[3] >> 24)] ^ - T[4][(byte)(x[2] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[7] >> 56)]); - y[7] = k[7] + (T[0][(byte)x[7]] ^ T[1][(byte)(x[6] >> 8)] ^ T[2][(byte)(x[5] >> 16)] ^ T[3][(byte)(x[4] >> 24)] ^ - T[4][(byte)(x[3] >> 32)] ^ T[5][(byte)(x[2] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[0] >> 56)]); + y[0] = k[0] + (T[0][(::byte)x[0]] ^ T[1][(::byte)(x[7] >> 8)] ^ T[2][(::byte)(x[6] >> 16)] ^ T[3][(::byte)(x[5] >> 24)] ^ + T[4][(::byte)(x[4] >> 32)] ^ T[5][(::byte)(x[3] >> 40)] ^ T[6][(::byte)(x[2] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]); + y[1] = k[1] + (T[0][(::byte)x[1]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[7] >> 16)] ^ T[3][(::byte)(x[6] >> 24)] ^ + T[4][(::byte)(x[5] >> 32)] ^ T[5][(::byte)(x[4] >> 40)] ^ T[6][(::byte)(x[3] >> 48)] ^ T[7][(::byte)(x[2] >> 56)]); + y[2] = k[2] + (T[0][(::byte)x[2]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[7] >> 24)] ^ + T[4][(::byte)(x[6] >> 32)] ^ T[5][(::byte)(x[5] >> 40)] ^ T[6][(::byte)(x[4] >> 48)] ^ T[7][(::byte)(x[3] >> 56)]); + y[3] = k[3] + (T[0][(::byte)x[3]] ^ T[1][(::byte)(x[2] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[7] >> 32)] ^ T[5][(::byte)(x[6] >> 40)] ^ T[6][(::byte)(x[5] >> 48)] ^ T[7][(::byte)(x[4] >> 56)]); + y[4] = k[4] + (T[0][(::byte)x[4]] ^ T[1][(::byte)(x[3] >> 8)] ^ T[2][(::byte)(x[2] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[7] >> 40)] ^ T[6][(::byte)(x[6] >> 48)] ^ T[7][(::byte)(x[5] >> 56)]); + y[5] = k[5] + (T[0][(::byte)x[5]] ^ T[1][(::byte)(x[4] >> 8)] ^ T[2][(::byte)(x[3] >> 16)] ^ T[3][(::byte)(x[2] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[7] >> 48)] ^ T[7][(::byte)(x[6] >> 56)]); + y[6] = k[6] + (T[0][(::byte)x[6]] ^ T[1][(::byte)(x[5] >> 8)] ^ T[2][(::byte)(x[4] >> 16)] ^ T[3][(::byte)(x[3] >> 24)] ^ + T[4][(::byte)(x[2] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[7] >> 56)]); + y[7] = k[7] + (T[0][(::byte)x[7]] ^ T[1][(::byte)(x[6] >> 8)] ^ T[2][(::byte)(x[5] >> 16)] ^ T[3][(::byte)(x[4] >> 24)] ^ + T[4][(::byte)(x[3] >> 32)] ^ T[5][(::byte)(x[2] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]); } inline void IMC128(word64 x[2]) { - x[0] = IT[0][S[0][(byte)x[0]]] ^ IT[1][S[1][(byte)(x[0] >> 8)]] ^ IT[2][S[2][(byte)(x[0] >> 16)]] ^ IT[3][S[3][(byte)(x[0] >> 24)]] ^ - IT[4][S[0][(byte)(x[0] >> 32)]] ^ IT[5][S[1][(byte)(x[0] >> 40)]] ^ IT[6][S[2][(byte)(x[0] >> 48)]] ^ IT[7][S[3][(byte)(x[0] >> 56)]]; - x[1] = IT[0][S[0][(byte)x[1]]] ^ IT[1][S[1][(byte)(x[1] >> 8)]] ^ IT[2][S[2][(byte)(x[1] >> 16)]] ^ IT[3][S[3][(byte)(x[1] >> 24)]] ^ - IT[4][S[0][(byte)(x[1] >> 32)]] ^ IT[5][S[1][(byte)(x[1] >> 40)]] ^ IT[6][S[2][(byte)(x[1] >> 48)]] ^ IT[7][S[3][(byte)(x[1] >> 56)]]; + x[0] = IT[0][S[0][(::byte)x[0]]] ^ IT[1][S[1][(::byte)(x[0] >> 8)]] ^ IT[2][S[2][(::byte)(x[0] >> 16)]] ^ IT[3][S[3][(::byte)(x[0] >> 24)]] ^ + IT[4][S[0][(::byte)(x[0] >> 32)]] ^ IT[5][S[1][(::byte)(x[0] >> 40)]] ^ IT[6][S[2][(::byte)(x[0] >> 48)]] ^ IT[7][S[3][(::byte)(x[0] >> 56)]]; + x[1] = IT[0][S[0][(::byte)x[1]]] ^ IT[1][S[1][(::byte)(x[1] >> 8)]] ^ IT[2][S[2][(::byte)(x[1] >> 16)]] ^ IT[3][S[3][(::byte)(x[1] >> 24)]] ^ + IT[4][S[0][(::byte)(x[1] >> 32)]] ^ IT[5][S[1][(::byte)(x[1] >> 40)]] ^ IT[6][S[2][(::byte)(x[1] >> 48)]] ^ IT[7][S[3][(::byte)(x[1] >> 56)]]; } inline void IMC256(word64 x[4]) { - x[0] = IT[0][S[0][(byte)x[0]]] ^ IT[1][S[1][(byte)(x[0] >> 8)]] ^ IT[2][S[2][(byte)(x[0] >> 16)]] ^ IT[3][S[3][(byte)(x[0] >> 24)]] ^ - IT[4][S[0][(byte)(x[0] >> 32)]] ^ IT[5][S[1][(byte)(x[0] >> 40)]] ^ IT[6][S[2][(byte)(x[0] >> 48)]] ^ IT[7][S[3][(byte)(x[0] >> 56)]]; - x[1] = IT[0][S[0][(byte)x[1]]] ^ IT[1][S[1][(byte)(x[1] >> 8)]] ^ IT[2][S[2][(byte)(x[1] >> 16)]] ^ IT[3][S[3][(byte)(x[1] >> 24)]] ^ - IT[4][S[0][(byte)(x[1] >> 32)]] ^ IT[5][S[1][(byte)(x[1] >> 40)]] ^ IT[6][S[2][(byte)(x[1] >> 48)]] ^ IT[7][S[3][(byte)(x[1] >> 56)]]; - x[2] = IT[0][S[0][(byte)x[2]]] ^ IT[1][S[1][(byte)(x[2] >> 8)]] ^ IT[2][S[2][(byte)(x[2] >> 16)]] ^ IT[3][S[3][(byte)(x[2] >> 24)]] ^ - IT[4][S[0][(byte)(x[2] >> 32)]] ^ IT[5][S[1][(byte)(x[2] >> 40)]] ^ IT[6][S[2][(byte)(x[2] >> 48)]] ^ IT[7][S[3][(byte)(x[2] >> 56)]]; - x[3] = IT[0][S[0][(byte)x[3]]] ^ IT[1][S[1][(byte)(x[3] >> 8)]] ^ IT[2][S[2][(byte)(x[3] >> 16)]] ^ IT[3][S[3][(byte)(x[3] >> 24)]] ^ - IT[4][S[0][(byte)(x[3] >> 32)]] ^ IT[5][S[1][(byte)(x[3] >> 40)]] ^ IT[6][S[2][(byte)(x[3] >> 48)]] ^ IT[7][S[3][(byte)(x[3] >> 56)]]; + x[0] = IT[0][S[0][(::byte)x[0]]] ^ IT[1][S[1][(::byte)(x[0] >> 8)]] ^ IT[2][S[2][(::byte)(x[0] >> 16)]] ^ IT[3][S[3][(::byte)(x[0] >> 24)]] ^ + IT[4][S[0][(::byte)(x[0] >> 32)]] ^ IT[5][S[1][(::byte)(x[0] >> 40)]] ^ IT[6][S[2][(::byte)(x[0] >> 48)]] ^ IT[7][S[3][(::byte)(x[0] >> 56)]]; + x[1] = IT[0][S[0][(::byte)x[1]]] ^ IT[1][S[1][(::byte)(x[1] >> 8)]] ^ IT[2][S[2][(::byte)(x[1] >> 16)]] ^ IT[3][S[3][(::byte)(x[1] >> 24)]] ^ + IT[4][S[0][(::byte)(x[1] >> 32)]] ^ IT[5][S[1][(::byte)(x[1] >> 40)]] ^ IT[6][S[2][(::byte)(x[1] >> 48)]] ^ IT[7][S[3][(::byte)(x[1] >> 56)]]; + x[2] = IT[0][S[0][(::byte)x[2]]] ^ IT[1][S[1][(::byte)(x[2] >> 8)]] ^ IT[2][S[2][(::byte)(x[2] >> 16)]] ^ IT[3][S[3][(::byte)(x[2] >> 24)]] ^ + IT[4][S[0][(::byte)(x[2] >> 32)]] ^ IT[5][S[1][(::byte)(x[2] >> 40)]] ^ IT[6][S[2][(::byte)(x[2] >> 48)]] ^ IT[7][S[3][(::byte)(x[2] >> 56)]]; + x[3] = IT[0][S[0][(::byte)x[3]]] ^ IT[1][S[1][(::byte)(x[3] >> 8)]] ^ IT[2][S[2][(::byte)(x[3] >> 16)]] ^ IT[3][S[3][(::byte)(x[3] >> 24)]] ^ + IT[4][S[0][(::byte)(x[3] >> 32)]] ^ IT[5][S[1][(::byte)(x[3] >> 40)]] ^ IT[6][S[2][(::byte)(x[3] >> 48)]] ^ IT[7][S[3][(::byte)(x[3] >> 56)]]; } inline void IMC512(word64 x[8]) { - x[0] = IT[0][S[0][(byte)x[0]]] ^ IT[1][S[1][(byte)(x[0] >> 8)]] ^ IT[2][S[2][(byte)(x[0] >> 16)]] ^ IT[3][S[3][(byte)(x[0] >> 24)]] ^ - IT[4][S[0][(byte)(x[0] >> 32)]] ^ IT[5][S[1][(byte)(x[0] >> 40)]] ^ IT[6][S[2][(byte)(x[0] >> 48)]] ^ IT[7][S[3][(byte)(x[0] >> 56)]]; - x[1] = IT[0][S[0][(byte)x[1]]] ^ IT[1][S[1][(byte)(x[1] >> 8)]] ^ IT[2][S[2][(byte)(x[1] >> 16)]] ^ IT[3][S[3][(byte)(x[1] >> 24)]] ^ - IT[4][S[0][(byte)(x[1] >> 32)]] ^ IT[5][S[1][(byte)(x[1] >> 40)]] ^ IT[6][S[2][(byte)(x[1] >> 48)]] ^ IT[7][S[3][(byte)(x[1] >> 56)]]; - x[2] = IT[0][S[0][(byte)x[2]]] ^ IT[1][S[1][(byte)(x[2] >> 8)]] ^ IT[2][S[2][(byte)(x[2] >> 16)]] ^ IT[3][S[3][(byte)(x[2] >> 24)]] ^ - IT[4][S[0][(byte)(x[2] >> 32)]] ^ IT[5][S[1][(byte)(x[2] >> 40)]] ^ IT[6][S[2][(byte)(x[2] >> 48)]] ^ IT[7][S[3][(byte)(x[2] >> 56)]]; - x[3] = IT[0][S[0][(byte)x[3]]] ^ IT[1][S[1][(byte)(x[3] >> 8)]] ^ IT[2][S[2][(byte)(x[3] >> 16)]] ^ IT[3][S[3][(byte)(x[3] >> 24)]] ^ - IT[4][S[0][(byte)(x[3] >> 32)]] ^ IT[5][S[1][(byte)(x[3] >> 40)]] ^ IT[6][S[2][(byte)(x[3] >> 48)]] ^ IT[7][S[3][(byte)(x[3] >> 56)]]; - x[4] = IT[0][S[0][(byte)x[4]]] ^ IT[1][S[1][(byte)(x[4] >> 8)]] ^ IT[2][S[2][(byte)(x[4] >> 16)]] ^ IT[3][S[3][(byte)(x[4] >> 24)]] ^ - IT[4][S[0][(byte)(x[4] >> 32)]] ^ IT[5][S[1][(byte)(x[4] >> 40)]] ^ IT[6][S[2][(byte)(x[4] >> 48)]] ^ IT[7][S[3][(byte)(x[4] >> 56)]]; - x[5] = IT[0][S[0][(byte)x[5]]] ^ IT[1][S[1][(byte)(x[5] >> 8)]] ^ IT[2][S[2][(byte)(x[5] >> 16)]] ^ IT[3][S[3][(byte)(x[5] >> 24)]] ^ - IT[4][S[0][(byte)(x[5] >> 32)]] ^ IT[5][S[1][(byte)(x[5] >> 40)]] ^ IT[6][S[2][(byte)(x[5] >> 48)]] ^ IT[7][S[3][(byte)(x[5] >> 56)]]; - x[6] = IT[0][S[0][(byte)x[6]]] ^ IT[1][S[1][(byte)(x[6] >> 8)]] ^ IT[2][S[2][(byte)(x[6] >> 16)]] ^ IT[3][S[3][(byte)(x[6] >> 24)]] ^ - IT[4][S[0][(byte)(x[6] >> 32)]] ^ IT[5][S[1][(byte)(x[6] >> 40)]] ^ IT[6][S[2][(byte)(x[6] >> 48)]] ^ IT[7][S[3][(byte)(x[6] >> 56)]]; - x[7] = IT[0][S[0][(byte)x[7]]] ^ IT[1][S[1][(byte)(x[7] >> 8)]] ^ IT[2][S[2][(byte)(x[7] >> 16)]] ^ IT[3][S[3][(byte)(x[7] >> 24)]] ^ - IT[4][S[0][(byte)(x[7] >> 32)]] ^ IT[5][S[1][(byte)(x[7] >> 40)]] ^ IT[6][S[2][(byte)(x[7] >> 48)]] ^ IT[7][S[3][(byte)(x[7] >> 56)]]; + x[0] = IT[0][S[0][(::byte)x[0]]] ^ IT[1][S[1][(::byte)(x[0] >> 8)]] ^ IT[2][S[2][(::byte)(x[0] >> 16)]] ^ IT[3][S[3][(::byte)(x[0] >> 24)]] ^ + IT[4][S[0][(::byte)(x[0] >> 32)]] ^ IT[5][S[1][(::byte)(x[0] >> 40)]] ^ IT[6][S[2][(::byte)(x[0] >> 48)]] ^ IT[7][S[3][(::byte)(x[0] >> 56)]]; + x[1] = IT[0][S[0][(::byte)x[1]]] ^ IT[1][S[1][(::byte)(x[1] >> 8)]] ^ IT[2][S[2][(::byte)(x[1] >> 16)]] ^ IT[3][S[3][(::byte)(x[1] >> 24)]] ^ + IT[4][S[0][(::byte)(x[1] >> 32)]] ^ IT[5][S[1][(::byte)(x[1] >> 40)]] ^ IT[6][S[2][(::byte)(x[1] >> 48)]] ^ IT[7][S[3][(::byte)(x[1] >> 56)]]; + x[2] = IT[0][S[0][(::byte)x[2]]] ^ IT[1][S[1][(::byte)(x[2] >> 8)]] ^ IT[2][S[2][(::byte)(x[2] >> 16)]] ^ IT[3][S[3][(::byte)(x[2] >> 24)]] ^ + IT[4][S[0][(::byte)(x[2] >> 32)]] ^ IT[5][S[1][(::byte)(x[2] >> 40)]] ^ IT[6][S[2][(::byte)(x[2] >> 48)]] ^ IT[7][S[3][(::byte)(x[2] >> 56)]]; + x[3] = IT[0][S[0][(::byte)x[3]]] ^ IT[1][S[1][(::byte)(x[3] >> 8)]] ^ IT[2][S[2][(::byte)(x[3] >> 16)]] ^ IT[3][S[3][(::byte)(x[3] >> 24)]] ^ + IT[4][S[0][(::byte)(x[3] >> 32)]] ^ IT[5][S[1][(::byte)(x[3] >> 40)]] ^ IT[6][S[2][(::byte)(x[3] >> 48)]] ^ IT[7][S[3][(::byte)(x[3] >> 56)]]; + x[4] = IT[0][S[0][(::byte)x[4]]] ^ IT[1][S[1][(::byte)(x[4] >> 8)]] ^ IT[2][S[2][(::byte)(x[4] >> 16)]] ^ IT[3][S[3][(::byte)(x[4] >> 24)]] ^ + IT[4][S[0][(::byte)(x[4] >> 32)]] ^ IT[5][S[1][(::byte)(x[4] >> 40)]] ^ IT[6][S[2][(::byte)(x[4] >> 48)]] ^ IT[7][S[3][(::byte)(x[4] >> 56)]]; + x[5] = IT[0][S[0][(::byte)x[5]]] ^ IT[1][S[1][(::byte)(x[5] >> 8)]] ^ IT[2][S[2][(::byte)(x[5] >> 16)]] ^ IT[3][S[3][(::byte)(x[5] >> 24)]] ^ + IT[4][S[0][(::byte)(x[5] >> 32)]] ^ IT[5][S[1][(::byte)(x[5] >> 40)]] ^ IT[6][S[2][(::byte)(x[5] >> 48)]] ^ IT[7][S[3][(::byte)(x[5] >> 56)]]; + x[6] = IT[0][S[0][(::byte)x[6]]] ^ IT[1][S[1][(::byte)(x[6] >> 8)]] ^ IT[2][S[2][(::byte)(x[6] >> 16)]] ^ IT[3][S[3][(::byte)(x[6] >> 24)]] ^ + IT[4][S[0][(::byte)(x[6] >> 32)]] ^ IT[5][S[1][(::byte)(x[6] >> 40)]] ^ IT[6][S[2][(::byte)(x[6] >> 48)]] ^ IT[7][S[3][(::byte)(x[6] >> 56)]]; + x[7] = IT[0][S[0][(::byte)x[7]]] ^ IT[1][S[1][(::byte)(x[7] >> 8)]] ^ IT[2][S[2][(::byte)(x[7] >> 16)]] ^ IT[3][S[3][(::byte)(x[7] >> 24)]] ^ + IT[4][S[0][(::byte)(x[7] >> 32)]] ^ IT[5][S[1][(::byte)(x[7] >> 40)]] ^ IT[6][S[2][(::byte)(x[7] >> 48)]] ^ IT[7][S[3][(::byte)(x[7] >> 56)]]; } inline void IG128(const word64 x[2], word64 y[2], const word64 k[2]) { - y[0] = k[0] ^ IT[0][(byte)x[0]] ^ IT[1][(byte)(x[0] >> 8)] ^ IT[2][(byte)(x[0] >> 16)] ^ IT[3][(byte)(x[0] >> 24)] ^ - IT[4][(byte)(x[1] >> 32)] ^ IT[5][(byte)(x[1] >> 40)] ^ IT[6][(byte)(x[1] >> 48)] ^ IT[7][(byte)(x[1] >> 56)]; - y[1] = k[1] ^ IT[0][(byte)x[1]] ^ IT[1][(byte)(x[1] >> 8)] ^ IT[2][(byte)(x[1] >> 16)] ^ IT[3][(byte)(x[1] >> 24)] ^ - IT[4][(byte)(x[0] >> 32)] ^ IT[5][(byte)(x[0] >> 40)] ^ IT[6][(byte)(x[0] >> 48)] ^ IT[7][(byte)(x[0] >> 56)]; + y[0] = k[0] ^ IT[0][(::byte)x[0]] ^ IT[1][(::byte)(x[0] >> 8)] ^ IT[2][(::byte)(x[0] >> 16)] ^ IT[3][(::byte)(x[0] >> 24)] ^ + IT[4][(::byte)(x[1] >> 32)] ^ IT[5][(::byte)(x[1] >> 40)] ^ IT[6][(::byte)(x[1] >> 48)] ^ IT[7][(::byte)(x[1] >> 56)]; + y[1] = k[1] ^ IT[0][(::byte)x[1]] ^ IT[1][(::byte)(x[1] >> 8)] ^ IT[2][(::byte)(x[1] >> 16)] ^ IT[3][(::byte)(x[1] >> 24)] ^ + IT[4][(::byte)(x[0] >> 32)] ^ IT[5][(::byte)(x[0] >> 40)] ^ IT[6][(::byte)(x[0] >> 48)] ^ IT[7][(::byte)(x[0] >> 56)]; } inline void IG256(const word64 x[4], word64 y[4], const word64 k[4]) { - y[0] = k[0] ^ IT[0][(byte)x[0]] ^ IT[1][(byte)(x[0] >> 8)] ^ IT[2][(byte)(x[1] >> 16)] ^ IT[3][(byte)(x[1] >> 24)] ^ - IT[4][(byte)(x[2] >> 32)] ^ IT[5][(byte)(x[2] >> 40)] ^ IT[6][(byte)(x[3] >> 48)] ^ IT[7][(byte)(x[3] >> 56)]; - y[1] = k[1] ^ IT[0][(byte)x[1]] ^ IT[1][(byte)(x[1] >> 8)] ^ IT[2][(byte)(x[2] >> 16)] ^ IT[3][(byte)(x[2] >> 24)] ^ - IT[4][(byte)(x[3] >> 32)] ^ IT[5][(byte)(x[3] >> 40)] ^ IT[6][(byte)(x[0] >> 48)] ^ IT[7][(byte)(x[0] >> 56)]; - y[2] = k[2] ^ IT[0][(byte)x[2]] ^ IT[1][(byte)(x[2] >> 8)] ^ IT[2][(byte)(x[3] >> 16)] ^ IT[3][(byte)(x[3] >> 24)] ^ - IT[4][(byte)(x[0] >> 32)] ^ IT[5][(byte)(x[0] >> 40)] ^ IT[6][(byte)(x[1] >> 48)] ^ IT[7][(byte)(x[1] >> 56)]; - y[3] = k[3] ^ IT[0][(byte)x[3]] ^ IT[1][(byte)(x[3] >> 8)] ^ IT[2][(byte)(x[0] >> 16)] ^ IT[3][(byte)(x[0] >> 24)] ^ - IT[4][(byte)(x[1] >> 32)] ^ IT[5][(byte)(x[1] >> 40)] ^ IT[6][(byte)(x[2] >> 48)] ^ IT[7][(byte)(x[2] >> 56)]; + y[0] = k[0] ^ IT[0][(::byte)x[0]] ^ IT[1][(::byte)(x[0] >> 8)] ^ IT[2][(::byte)(x[1] >> 16)] ^ IT[3][(::byte)(x[1] >> 24)] ^ + IT[4][(::byte)(x[2] >> 32)] ^ IT[5][(::byte)(x[2] >> 40)] ^ IT[6][(::byte)(x[3] >> 48)] ^ IT[7][(::byte)(x[3] >> 56)]; + y[1] = k[1] ^ IT[0][(::byte)x[1]] ^ IT[1][(::byte)(x[1] >> 8)] ^ IT[2][(::byte)(x[2] >> 16)] ^ IT[3][(::byte)(x[2] >> 24)] ^ + IT[4][(::byte)(x[3] >> 32)] ^ IT[5][(::byte)(x[3] >> 40)] ^ IT[6][(::byte)(x[0] >> 48)] ^ IT[7][(::byte)(x[0] >> 56)]; + y[2] = k[2] ^ IT[0][(::byte)x[2]] ^ IT[1][(::byte)(x[2] >> 8)] ^ IT[2][(::byte)(x[3] >> 16)] ^ IT[3][(::byte)(x[3] >> 24)] ^ + IT[4][(::byte)(x[0] >> 32)] ^ IT[5][(::byte)(x[0] >> 40)] ^ IT[6][(::byte)(x[1] >> 48)] ^ IT[7][(::byte)(x[1] >> 56)]; + y[3] = k[3] ^ IT[0][(::byte)x[3]] ^ IT[1][(::byte)(x[3] >> 8)] ^ IT[2][(::byte)(x[0] >> 16)] ^ IT[3][(::byte)(x[0] >> 24)] ^ + IT[4][(::byte)(x[1] >> 32)] ^ IT[5][(::byte)(x[1] >> 40)] ^ IT[6][(::byte)(x[2] >> 48)] ^ IT[7][(::byte)(x[2] >> 56)]; } inline void IG512(const word64 x[8], word64 y[8], const word64 k[8]) { - y[0] = k[0] ^ IT[0][(byte)x[0]] ^ IT[1][(byte)(x[1] >> 8)] ^ IT[2][(byte)(x[2] >> 16)] ^ IT[3][(byte)(x[3] >> 24)] ^ - IT[4][(byte)(x[4] >> 32)] ^ IT[5][(byte)(x[5] >> 40)] ^ IT[6][(byte)(x[6] >> 48)] ^ IT[7][(byte)(x[7] >> 56)]; - y[1] = k[1] ^ IT[0][(byte)x[1]] ^ IT[1][(byte)(x[2] >> 8)] ^ IT[2][(byte)(x[3] >> 16)] ^ IT[3][(byte)(x[4] >> 24)] ^ - IT[4][(byte)(x[5] >> 32)] ^ IT[5][(byte)(x[6] >> 40)] ^ IT[6][(byte)(x[7] >> 48)] ^ IT[7][(byte)(x[0] >> 56)]; - y[2] = k[2] ^ IT[0][(byte)x[2]] ^ IT[1][(byte)(x[3] >> 8)] ^ IT[2][(byte)(x[4] >> 16)] ^ IT[3][(byte)(x[5] >> 24)] ^ - IT[4][(byte)(x[6] >> 32)] ^ IT[5][(byte)(x[7] >> 40)] ^ IT[6][(byte)(x[0] >> 48)] ^ IT[7][(byte)(x[1] >> 56)]; - y[3] = k[3] ^ IT[0][(byte)x[3]] ^ IT[1][(byte)(x[4] >> 8)] ^ IT[2][(byte)(x[5] >> 16)] ^ IT[3][(byte)(x[6] >> 24)] ^ - IT[4][(byte)(x[7] >> 32)] ^ IT[5][(byte)(x[0] >> 40)] ^ IT[6][(byte)(x[1] >> 48)] ^ IT[7][(byte)(x[2] >> 56)]; - y[4] = k[4] ^ IT[0][(byte)x[4]] ^ IT[1][(byte)(x[5] >> 8)] ^ IT[2][(byte)(x[6] >> 16)] ^ IT[3][(byte)(x[7] >> 24)] ^ - IT[4][(byte)(x[0] >> 32)] ^ IT[5][(byte)(x[1] >> 40)] ^ IT[6][(byte)(x[2] >> 48)] ^ IT[7][(byte)(x[3] >> 56)]; - y[5] = k[5] ^ IT[0][(byte)x[5]] ^ IT[1][(byte)(x[6] >> 8)] ^ IT[2][(byte)(x[7] >> 16)] ^ IT[3][(byte)(x[0] >> 24)] ^ - IT[4][(byte)(x[1] >> 32)] ^ IT[5][(byte)(x[2] >> 40)] ^ IT[6][(byte)(x[3] >> 48)] ^ IT[7][(byte)(x[4] >> 56)]; - y[6] = k[6] ^ IT[0][(byte)x[6]] ^ IT[1][(byte)(x[7] >> 8)] ^ IT[2][(byte)(x[0] >> 16)] ^ IT[3][(byte)(x[1] >> 24)] ^ - IT[4][(byte)(x[2] >> 32)] ^ IT[5][(byte)(x[3] >> 40)] ^ IT[6][(byte)(x[4] >> 48)] ^ IT[7][(byte)(x[5] >> 56)]; - y[7] = k[7] ^ IT[0][(byte)x[7]] ^ IT[1][(byte)(x[0] >> 8)] ^ IT[2][(byte)(x[1] >> 16)] ^ IT[3][(byte)(x[2] >> 24)] ^ - IT[4][(byte)(x[3] >> 32)] ^ IT[5][(byte)(x[4] >> 40)] ^ IT[6][(byte)(x[5] >> 48)] ^ IT[7][(byte)(x[6] >> 56)]; + y[0] = k[0] ^ IT[0][(::byte)x[0]] ^ IT[1][(::byte)(x[1] >> 8)] ^ IT[2][(::byte)(x[2] >> 16)] ^ IT[3][(::byte)(x[3] >> 24)] ^ + IT[4][(::byte)(x[4] >> 32)] ^ IT[5][(::byte)(x[5] >> 40)] ^ IT[6][(::byte)(x[6] >> 48)] ^ IT[7][(::byte)(x[7] >> 56)]; + y[1] = k[1] ^ IT[0][(::byte)x[1]] ^ IT[1][(::byte)(x[2] >> 8)] ^ IT[2][(::byte)(x[3] >> 16)] ^ IT[3][(::byte)(x[4] >> 24)] ^ + IT[4][(::byte)(x[5] >> 32)] ^ IT[5][(::byte)(x[6] >> 40)] ^ IT[6][(::byte)(x[7] >> 48)] ^ IT[7][(::byte)(x[0] >> 56)]; + y[2] = k[2] ^ IT[0][(::byte)x[2]] ^ IT[1][(::byte)(x[3] >> 8)] ^ IT[2][(::byte)(x[4] >> 16)] ^ IT[3][(::byte)(x[5] >> 24)] ^ + IT[4][(::byte)(x[6] >> 32)] ^ IT[5][(::byte)(x[7] >> 40)] ^ IT[6][(::byte)(x[0] >> 48)] ^ IT[7][(::byte)(x[1] >> 56)]; + y[3] = k[3] ^ IT[0][(::byte)x[3]] ^ IT[1][(::byte)(x[4] >> 8)] ^ IT[2][(::byte)(x[5] >> 16)] ^ IT[3][(::byte)(x[6] >> 24)] ^ + IT[4][(::byte)(x[7] >> 32)] ^ IT[5][(::byte)(x[0] >> 40)] ^ IT[6][(::byte)(x[1] >> 48)] ^ IT[7][(::byte)(x[2] >> 56)]; + y[4] = k[4] ^ IT[0][(::byte)x[4]] ^ IT[1][(::byte)(x[5] >> 8)] ^ IT[2][(::byte)(x[6] >> 16)] ^ IT[3][(::byte)(x[7] >> 24)] ^ + IT[4][(::byte)(x[0] >> 32)] ^ IT[5][(::byte)(x[1] >> 40)] ^ IT[6][(::byte)(x[2] >> 48)] ^ IT[7][(::byte)(x[3] >> 56)]; + y[5] = k[5] ^ IT[0][(::byte)x[5]] ^ IT[1][(::byte)(x[6] >> 8)] ^ IT[2][(::byte)(x[7] >> 16)] ^ IT[3][(::byte)(x[0] >> 24)] ^ + IT[4][(::byte)(x[1] >> 32)] ^ IT[5][(::byte)(x[2] >> 40)] ^ IT[6][(::byte)(x[3] >> 48)] ^ IT[7][(::byte)(x[4] >> 56)]; + y[6] = k[6] ^ IT[0][(::byte)x[6]] ^ IT[1][(::byte)(x[7] >> 8)] ^ IT[2][(::byte)(x[0] >> 16)] ^ IT[3][(::byte)(x[1] >> 24)] ^ + IT[4][(::byte)(x[2] >> 32)] ^ IT[5][(::byte)(x[3] >> 40)] ^ IT[6][(::byte)(x[4] >> 48)] ^ IT[7][(::byte)(x[5] >> 56)]; + y[7] = k[7] ^ IT[0][(::byte)x[7]] ^ IT[1][(::byte)(x[0] >> 8)] ^ IT[2][(::byte)(x[1] >> 16)] ^ IT[3][(::byte)(x[2] >> 24)] ^ + IT[4][(::byte)(x[3] >> 32)] ^ IT[5][(::byte)(x[4] >> 40)] ^ IT[6][(::byte)(x[5] >> 48)] ^ IT[7][(::byte)(x[6] >> 56)]; } inline void IGL128(const word64 x[2], word64 y[2], const word64 k[2]) { - y[0] = (word64(IS[0][(byte)x[0]]) ^ word64(IS[1][(byte)(x[0] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[0] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[0] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[1] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[1] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[1] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[1] >> 56)]) << 56) - k[0]; - y[1] = (word64(IS[0][(byte)x[1]]) ^ word64(IS[1][(byte)(x[1] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[1] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[1] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[0] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[0] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[0] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[0] >> 56)]) << 56) - k[1]; + y[0] = (word64(IS[0][(::byte)x[0]]) ^ word64(IS[1][(::byte)(x[0] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[0] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[0] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[1] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[1] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[1] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[1] >> 56)]) << 56) - k[0]; + y[1] = (word64(IS[0][(::byte)x[1]]) ^ word64(IS[1][(::byte)(x[1] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[1] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[1] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[0] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[0] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[0] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[0] >> 56)]) << 56) - k[1]; } inline void IGL256(const word64 x[4], word64 y[4], const word64 k[4]) { - y[0] = (word64(IS[0][(byte)x[0]]) ^ word64(IS[1][(byte)(x[0] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[1] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[1] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[2] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[2] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[3] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[3] >> 56)]) << 56) - k[0]; - y[1] = (word64(IS[0][(byte)x[1]]) ^ word64(IS[1][(byte)(x[1] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[2] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[2] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[3] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[3] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[0] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[0] >> 56)]) << 56) - k[1]; - y[2] = (word64(IS[0][(byte)x[2]]) ^ word64(IS[1][(byte)(x[2] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[3] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[3] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[0] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[0] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[1] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[1] >> 56)]) << 56) - k[2]; - y[3] = (word64(IS[0][(byte)x[3]]) ^ word64(IS[1][(byte)(x[3] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[0] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[0] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[1] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[1] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[2] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[2] >> 56)]) << 56) - k[3]; + y[0] = (word64(IS[0][(::byte)x[0]]) ^ word64(IS[1][(::byte)(x[0] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[1] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[1] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[2] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[2] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[3] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[3] >> 56)]) << 56) - k[0]; + y[1] = (word64(IS[0][(::byte)x[1]]) ^ word64(IS[1][(::byte)(x[1] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[2] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[2] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[3] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[3] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[0] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[0] >> 56)]) << 56) - k[1]; + y[2] = (word64(IS[0][(::byte)x[2]]) ^ word64(IS[1][(::byte)(x[2] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[3] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[3] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[0] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[0] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[1] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[1] >> 56)]) << 56) - k[2]; + y[3] = (word64(IS[0][(::byte)x[3]]) ^ word64(IS[1][(::byte)(x[3] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[0] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[0] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[1] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[1] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[2] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[2] >> 56)]) << 56) - k[3]; } inline void IGL512(const word64 x[8], word64 y[8], const word64 k[8]) { - y[0] = (word64(IS[0][(byte)x[0]]) ^ word64(IS[1][(byte)(x[1] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[2] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[3] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[4] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[5] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[6] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[7] >> 56)]) << 56) - k[0]; - y[1] = (word64(IS[0][(byte)x[1]]) ^ word64(IS[1][(byte)(x[2] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[3] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[4] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[5] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[6] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[7] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[0] >> 56)]) << 56) - k[1]; - y[2] = (word64(IS[0][(byte)x[2]]) ^ word64(IS[1][(byte)(x[3] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[4] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[5] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[6] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[7] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[0] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[1] >> 56)]) << 56) - k[2]; - y[3] = (word64(IS[0][(byte)x[3]]) ^ word64(IS[1][(byte)(x[4] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[5] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[6] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[7] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[0] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[1] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[2] >> 56)]) << 56) - k[3]; - y[4] = (word64(IS[0][(byte)x[4]]) ^ word64(IS[1][(byte)(x[5] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[6] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[7] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[0] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[1] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[2] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[3] >> 56)]) << 56) - k[4]; - y[5] = (word64(IS[0][(byte)x[5]]) ^ word64(IS[1][(byte)(x[6] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[7] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[0] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[1] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[2] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[3] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[4] >> 56)]) << 56) - k[5]; - y[6] = (word64(IS[0][(byte)x[6]]) ^ word64(IS[1][(byte)(x[7] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[0] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[1] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[2] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[3] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[4] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[5] >> 56)]) << 56) - k[6]; - y[7] = (word64(IS[0][(byte)x[7]]) ^ word64(IS[1][(byte)(x[0] >> 8)]) << 8 ^ word64(IS[2][(byte)(x[1] >> 16)]) << 16 ^ word64(IS[3][(byte)(x[2] >> 24)]) << 24 ^ - word64(IS[0][(byte)(x[3] >> 32)]) << 32 ^ word64(IS[1][(byte)(x[4] >> 40)]) << 40 ^ word64(IS[2][(byte)(x[5] >> 48)]) << 48 ^ word64(IS[3][(byte)(x[6] >> 56)]) << 56) - k[7]; + y[0] = (word64(IS[0][(::byte)x[0]]) ^ word64(IS[1][(::byte)(x[1] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[2] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[3] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[4] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[5] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[6] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[7] >> 56)]) << 56) - k[0]; + y[1] = (word64(IS[0][(::byte)x[1]]) ^ word64(IS[1][(::byte)(x[2] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[3] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[4] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[5] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[6] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[7] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[0] >> 56)]) << 56) - k[1]; + y[2] = (word64(IS[0][(::byte)x[2]]) ^ word64(IS[1][(::byte)(x[3] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[4] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[5] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[6] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[7] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[0] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[1] >> 56)]) << 56) - k[2]; + y[3] = (word64(IS[0][(::byte)x[3]]) ^ word64(IS[1][(::byte)(x[4] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[5] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[6] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[7] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[0] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[1] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[2] >> 56)]) << 56) - k[3]; + y[4] = (word64(IS[0][(::byte)x[4]]) ^ word64(IS[1][(::byte)(x[5] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[6] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[7] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[0] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[1] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[2] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[3] >> 56)]) << 56) - k[4]; + y[5] = (word64(IS[0][(::byte)x[5]]) ^ word64(IS[1][(::byte)(x[6] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[7] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[0] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[1] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[2] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[3] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[4] >> 56)]) << 56) - k[5]; + y[6] = (word64(IS[0][(::byte)x[6]]) ^ word64(IS[1][(::byte)(x[7] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[0] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[1] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[2] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[3] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[4] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[5] >> 56)]) << 56) - k[6]; + y[7] = (word64(IS[0][(::byte)x[7]]) ^ word64(IS[1][(::byte)(x[0] >> 8)]) << 8 ^ word64(IS[2][(::byte)(x[1] >> 16)]) << 16 ^ word64(IS[3][(::byte)(x[2] >> 24)]) << 24 ^ + word64(IS[0][(::byte)(x[3] >> 32)]) << 32 ^ word64(IS[1][(::byte)(x[4] >> 40)]) << 40 ^ word64(IS[2][(::byte)(x[5] >> 48)]) << 48 ^ word64(IS[3][(::byte)(x[6] >> 56)]) << 56) - k[7]; } inline void G128(const word64 x[2], word64 y[2], const word64 k[2]) { - y[0] = k[0] ^ T[0][(byte)x[0]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[1] >> 56)]; - y[1] = k[1] ^ T[0][(byte)x[1]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[0] >> 56)]; + y[0] = k[0] ^ T[0][(::byte)x[0]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]; + y[1] = k[1] ^ T[0][(::byte)x[1]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]; } inline void G256(const word64 x[4], word64 y[4], const word64 k[4]) { - y[0] = k[0] ^ T[0][(byte)x[0]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[3] >> 16)] ^ T[3][(byte)(x[3] >> 24)] ^ - T[4][(byte)(x[2] >> 32)] ^ T[5][(byte)(x[2] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[1] >> 56)]; - y[1] = k[1] ^ T[0][(byte)x[1]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[3] >> 32)] ^ T[5][(byte)(x[3] >> 40)] ^ T[6][(byte)(x[2] >> 48)] ^ T[7][(byte)(x[2] >> 56)]; - y[2] = k[2] ^ T[0][(byte)x[2]] ^ T[1][(byte)(x[2] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[3] >> 48)] ^ T[7][(byte)(x[3] >> 56)]; - y[3] = k[3] ^ T[0][(byte)x[3]] ^ T[1][(byte)(x[3] >> 8)] ^ T[2][(byte)(x[2] >> 16)] ^ T[3][(byte)(x[2] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[0] >> 56)]; + y[0] = k[0] ^ T[0][(::byte)x[0]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[3] >> 16)] ^ T[3][(::byte)(x[3] >> 24)] ^ + T[4][(::byte)(x[2] >> 32)] ^ T[5][(::byte)(x[2] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]; + y[1] = k[1] ^ T[0][(::byte)x[1]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[3] >> 32)] ^ T[5][(::byte)(x[3] >> 40)] ^ T[6][(::byte)(x[2] >> 48)] ^ T[7][(::byte)(x[2] >> 56)]; + y[2] = k[2] ^ T[0][(::byte)x[2]] ^ T[1][(::byte)(x[2] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[3] >> 48)] ^ T[7][(::byte)(x[3] >> 56)]; + y[3] = k[3] ^ T[0][(::byte)x[3]] ^ T[1][(::byte)(x[3] >> 8)] ^ T[2][(::byte)(x[2] >> 16)] ^ T[3][(::byte)(x[2] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]; } inline void G512(const word64 x[8], word64 y[8], const word64 k[8]) { - y[0] = k[0] ^ T[0][(byte)x[0]] ^ T[1][(byte)(x[7] >> 8)] ^ T[2][(byte)(x[6] >> 16)] ^ T[3][(byte)(x[5] >> 24)] ^ - T[4][(byte)(x[4] >> 32)] ^ T[5][(byte)(x[3] >> 40)] ^ T[6][(byte)(x[2] >> 48)] ^ T[7][(byte)(x[1] >> 56)]; - y[1] = k[1] ^ T[0][(byte)x[1]] ^ T[1][(byte)(x[0] >> 8)] ^ T[2][(byte)(x[7] >> 16)] ^ T[3][(byte)(x[6] >> 24)] ^ - T[4][(byte)(x[5] >> 32)] ^ T[5][(byte)(x[4] >> 40)] ^ T[6][(byte)(x[3] >> 48)] ^ T[7][(byte)(x[2] >> 56)]; - y[2] = k[2] ^ T[0][(byte)x[2]] ^ T[1][(byte)(x[1] >> 8)] ^ T[2][(byte)(x[0] >> 16)] ^ T[3][(byte)(x[7] >> 24)] ^ - T[4][(byte)(x[6] >> 32)] ^ T[5][(byte)(x[5] >> 40)] ^ T[6][(byte)(x[4] >> 48)] ^ T[7][(byte)(x[3] >> 56)]; - y[3] = k[3] ^ T[0][(byte)x[3]] ^ T[1][(byte)(x[2] >> 8)] ^ T[2][(byte)(x[1] >> 16)] ^ T[3][(byte)(x[0] >> 24)] ^ - T[4][(byte)(x[7] >> 32)] ^ T[5][(byte)(x[6] >> 40)] ^ T[6][(byte)(x[5] >> 48)] ^ T[7][(byte)(x[4] >> 56)]; - y[4] = k[4] ^ T[0][(byte)x[4]] ^ T[1][(byte)(x[3] >> 8)] ^ T[2][(byte)(x[2] >> 16)] ^ T[3][(byte)(x[1] >> 24)] ^ - T[4][(byte)(x[0] >> 32)] ^ T[5][(byte)(x[7] >> 40)] ^ T[6][(byte)(x[6] >> 48)] ^ T[7][(byte)(x[5] >> 56)]; - y[5] = k[5] ^ T[0][(byte)x[5]] ^ T[1][(byte)(x[4] >> 8)] ^ T[2][(byte)(x[3] >> 16)] ^ T[3][(byte)(x[2] >> 24)] ^ - T[4][(byte)(x[1] >> 32)] ^ T[5][(byte)(x[0] >> 40)] ^ T[6][(byte)(x[7] >> 48)] ^ T[7][(byte)(x[6] >> 56)]; - y[6] = k[6] ^ T[0][(byte)x[6]] ^ T[1][(byte)(x[5] >> 8)] ^ T[2][(byte)(x[4] >> 16)] ^ T[3][(byte)(x[3] >> 24)] ^ - T[4][(byte)(x[2] >> 32)] ^ T[5][(byte)(x[1] >> 40)] ^ T[6][(byte)(x[0] >> 48)] ^ T[7][(byte)(x[7] >> 56)]; - y[7] = k[7] ^ T[0][(byte)x[7]] ^ T[1][(byte)(x[6] >> 8)] ^ T[2][(byte)(x[5] >> 16)] ^ T[3][(byte)(x[4] >> 24)] ^ - T[4][(byte)(x[3] >> 32)] ^ T[5][(byte)(x[2] >> 40)] ^ T[6][(byte)(x[1] >> 48)] ^ T[7][(byte)(x[0] >> 56)]; + y[0] = k[0] ^ T[0][(::byte)x[0]] ^ T[1][(::byte)(x[7] >> 8)] ^ T[2][(::byte)(x[6] >> 16)] ^ T[3][(::byte)(x[5] >> 24)] ^ + T[4][(::byte)(x[4] >> 32)] ^ T[5][(::byte)(x[3] >> 40)] ^ T[6][(::byte)(x[2] >> 48)] ^ T[7][(::byte)(x[1] >> 56)]; + y[1] = k[1] ^ T[0][(::byte)x[1]] ^ T[1][(::byte)(x[0] >> 8)] ^ T[2][(::byte)(x[7] >> 16)] ^ T[3][(::byte)(x[6] >> 24)] ^ + T[4][(::byte)(x[5] >> 32)] ^ T[5][(::byte)(x[4] >> 40)] ^ T[6][(::byte)(x[3] >> 48)] ^ T[7][(::byte)(x[2] >> 56)]; + y[2] = k[2] ^ T[0][(::byte)x[2]] ^ T[1][(::byte)(x[1] >> 8)] ^ T[2][(::byte)(x[0] >> 16)] ^ T[3][(::byte)(x[7] >> 24)] ^ + T[4][(::byte)(x[6] >> 32)] ^ T[5][(::byte)(x[5] >> 40)] ^ T[6][(::byte)(x[4] >> 48)] ^ T[7][(::byte)(x[3] >> 56)]; + y[3] = k[3] ^ T[0][(::byte)x[3]] ^ T[1][(::byte)(x[2] >> 8)] ^ T[2][(::byte)(x[1] >> 16)] ^ T[3][(::byte)(x[0] >> 24)] ^ + T[4][(::byte)(x[7] >> 32)] ^ T[5][(::byte)(x[6] >> 40)] ^ T[6][(::byte)(x[5] >> 48)] ^ T[7][(::byte)(x[4] >> 56)]; + y[4] = k[4] ^ T[0][(::byte)x[4]] ^ T[1][(::byte)(x[3] >> 8)] ^ T[2][(::byte)(x[2] >> 16)] ^ T[3][(::byte)(x[1] >> 24)] ^ + T[4][(::byte)(x[0] >> 32)] ^ T[5][(::byte)(x[7] >> 40)] ^ T[6][(::byte)(x[6] >> 48)] ^ T[7][(::byte)(x[5] >> 56)]; + y[5] = k[5] ^ T[0][(::byte)x[5]] ^ T[1][(::byte)(x[4] >> 8)] ^ T[2][(::byte)(x[3] >> 16)] ^ T[3][(::byte)(x[2] >> 24)] ^ + T[4][(::byte)(x[1] >> 32)] ^ T[5][(::byte)(x[0] >> 40)] ^ T[6][(::byte)(x[7] >> 48)] ^ T[7][(::byte)(x[6] >> 56)]; + y[6] = k[6] ^ T[0][(::byte)x[6]] ^ T[1][(::byte)(x[5] >> 8)] ^ T[2][(::byte)(x[4] >> 16)] ^ T[3][(::byte)(x[3] >> 24)] ^ + T[4][(::byte)(x[2] >> 32)] ^ T[5][(::byte)(x[1] >> 40)] ^ T[6][(::byte)(x[0] >> 48)] ^ T[7][(::byte)(x[7] >> 56)]; + y[7] = k[7] ^ T[0][(::byte)x[7]] ^ T[1][(::byte)(x[6] >> 8)] ^ T[2][(::byte)(x[5] >> 16)] ^ T[3][(::byte)(x[4] >> 24)] ^ + T[4][(::byte)(x[3] >> 32)] ^ T[5][(::byte)(x[2] >> 40)] ^ T[6][(::byte)(x[1] >> 48)] ^ T[7][(::byte)(x[0] >> 56)]; } ANONYMOUS_NAMESPACE_END @@ -1209,7 +1209,7 @@ void Kalyna::Base::ProcessBlock_88(const word64 inBlock[8], const word64 xorBloc // *********************** Library routines *********************** // -void Kalyna::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs ¶ms) +void Kalyna::Base::UncheckedSetKey(const ::byte *key, unsigned int keylen, const NameValuePairs ¶ms) { switch (keylen) { @@ -1279,14 +1279,14 @@ void Kalyna::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const N } } -void Kalyna::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Kalyna::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { // Timing attack countermeasure. see comments in Rijndael for more details const int cacheLineSize = GetCacheLineSize(); volatile word64 _u = 0; word64 u = _u; - const byte* p = reinterpret_cast(KalynaTab::S); + const ::byte* p = reinterpret_cast(KalynaTab::S); for (unsigned int i=0; i<256; i+=cacheLineSize) u ^= *reinterpret_cast(p+i); m_wspace[0] = u; diff --git a/kalyna.h b/kalyna.h index 047685ef..be9bf637 100644 --- a/kalyna.h +++ b/kalyna.h @@ -118,8 +118,8 @@ public: } protected: - void UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *key, unsigned int keylen, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; protected: // Visual Studio and C2910: 'Kalyna::Base::SetKey_Template': cannot be explicitly specialized diff --git a/kalynatab.cpp b/kalynatab.cpp index 1c9c225b..bdbc1cd1 100644 --- a/kalynatab.cpp +++ b/kalynatab.cpp @@ -1076,7 +1076,7 @@ const word64 IT[8][256] = }; EXPORT_TABLE -const byte S[4][256] = +const ::byte S[4][256] = { { 0xA8, 0x43, 0x5F, 0x06, 0x6B, 0x75, 0x6C, 0x59, 0x71, 0xDF, 0x87, 0x95, 0x17, 0xF0, 0xD8, 0x09, @@ -1153,7 +1153,7 @@ const byte S[4][256] = }; EXPORT_TABLE -const byte IS[4][256] = +const ::byte IS[4][256] = { { 0xA4, 0xA2, 0xA9, 0xC5, 0x4E, 0xC9, 0x03, 0xD9, 0x7E, 0x0F, 0xD2, 0xAD, 0xE7, 0xD3, 0x27, 0x5B, diff --git a/keccak.cpp b/keccak.cpp index b9abd396..874a6761 100644 --- a/keccak.cpp +++ b/keccak.cpp @@ -249,7 +249,7 @@ static void KeccakF1600(word64 *state) } } -void Keccak::Update(const byte *input, size_t length) +void Keccak::Update(const ::byte *input, size_t length) { CRYPTOPP_ASSERT((input && length) || !(input || length)); if (!length) { return; } @@ -276,7 +276,7 @@ void Keccak::Restart() m_counter = 0; } -void Keccak::TruncatedFinal(byte *hash, size_t size) +void Keccak::TruncatedFinal(::byte *hash, size_t size) { ThrowIfInvalidTruncatedSize(size); diff --git a/keccak.h b/keccak.h index 649e1e55..7d0588e8 100644 --- a/keccak.h +++ b/keccak.h @@ -53,9 +53,9 @@ public: CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "Keccak"; } unsigned int OptimalDataAlignment() const {return GetAlignmentOf();} - void Update(const byte *input, size_t length); + void Update(const ::byte *input, size_t length); void Restart(); - void TruncatedFinal(byte *hash, size_t size); + void TruncatedFinal(::byte *hash, size_t size); //unsigned int BlockSize() const { return r(); } // that's the idea behind it diff --git a/luc.cpp b/luc.cpp index 702fc9f6..0046816e 100644 --- a/luc.cpp +++ b/luc.cpp @@ -158,7 +158,7 @@ void InvertibleLUCFunction::DEREncode(BufferedTransformation &bt) const { DERSequenceEncoder seq(bt); - const byte version[] = {INTEGER, 1, 0}; + const ::byte version[] = {INTEGER, 1, 0}; seq.Put(version, sizeof(version)); m_n.DEREncode(seq); m_e.DEREncode(seq); diff --git a/mars.cpp b/mars.cpp index 9fff388b..19ef45c6 100644 --- a/mars.cpp +++ b/mars.cpp @@ -8,7 +8,7 @@ NAMESPACE_BEGIN(CryptoPP) -void MARS::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &) +void MARS::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); @@ -53,7 +53,7 @@ void MARS::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const typedef BlockGetAndPut Block; -void MARS::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void MARS::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { unsigned int i; word32 a, b, c, d, l, m, r, t; @@ -102,7 +102,7 @@ void MARS::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by Block::Put(xorBlock, outBlock)(a)(b)(c)(d); } -void MARS::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void MARS::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { unsigned int i; word32 a, b, c, d, l, m, r, t; diff --git a/mars.h b/mars.h index c9a1ce2f..af22ee0b 100644 --- a/mars.h +++ b/mars.h @@ -26,7 +26,7 @@ class MARS : public MARS_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: static const word32 Sbox[512]; @@ -37,13 +37,13 @@ class MARS : public MARS_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 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: diff --git a/md2.cpp b/md2.cpp index b0dc7e8b..bbe5f44f 100644 --- a/md2.cpp +++ b/md2.cpp @@ -35,9 +35,9 @@ void MD2::Init() m_count = 0; } -void MD2::Update(const byte *buf, size_t len) +void MD2::Update(const ::byte *buf, size_t len) { - static const byte S[256] = { + static const ::byte S[256] = { 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, @@ -67,7 +67,7 @@ void MD2::Update(const byte *buf, size_t len) len-=L; if (m_count==16) { - byte t; + ::byte t; int i,j; m_count=0; @@ -93,22 +93,22 @@ void MD2::Update(const byte *buf, size_t len) t=m_X[j+6]^=S[t]; t=m_X[j+7]^=S[t]; } - t = byte((t+i) & 0xFF); + t = ::byte((t+i) & 0xFF); } } } } -void MD2::TruncatedFinal(byte *hash, size_t size) +void MD2::TruncatedFinal(::byte *hash, size_t size) { ThrowIfInvalidTruncatedSize(size); - byte padding[16]; + ::byte padding[16]; word32 padlen; unsigned int i; padlen= 16-m_count; - for(i=0; iinput to reseed the //! generator. If fewer bytes are provided, then the seed is padded with 0's. - void IncorporateEntropy(const byte *input, size_t length) + void IncorporateEntropy(const ::byte *input, size_t length) { word32 temp = 0; ::memcpy(&temp, input, STDMIN(sizeof(temp), length)); @@ -67,7 +67,7 @@ public: //! is not a multiple of word32, then unused bytes are not accumulated for subsequent //! calls to GenerateBlock. Rather, the unused tail bytes are discarded, and the //! stream is continued at the next word32 boundary from the state array. - void GenerateBlock(byte *output, size_t size) + void GenerateBlock(::byte *output, size_t size) { // Handle word32 size blocks word32 temp; diff --git a/misc.cpp b/misc.cpp index be3d6bf1..f63bebe3 100644 --- a/misc.cpp +++ b/misc.cpp @@ -25,7 +25,7 @@ NAMESPACE_BEGIN(CryptoPP) -void xorbuf(byte *buf, const byte *mask, size_t count) +void xorbuf(::byte *buf, const ::byte *mask, size_t count) { CRYPTOPP_ASSERT(buf != NULLPTR); CRYPTOPP_ASSERT(mask != NULLPTR); @@ -58,7 +58,7 @@ void xorbuf(byte *buf, const byte *mask, size_t count) buf[i] ^= mask[i]; } -void xorbuf(byte *output, const byte *input, const byte *mask, size_t count) +void xorbuf(::byte *output, const ::byte *input, const ::byte *mask, size_t count) { CRYPTOPP_ASSERT(output != NULLPTR); CRYPTOPP_ASSERT(input != NULLPTR); @@ -93,14 +93,14 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count) output[i] = input[i] ^ mask[i]; } -bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count) +bool VerifyBufsEqual(const ::byte *buf, const ::byte *mask, size_t count) { CRYPTOPP_ASSERT(buf != NULLPTR); CRYPTOPP_ASSERT(mask != NULLPTR); CRYPTOPP_ASSERT(count > 0); size_t i=0; - byte acc8 = 0; + ::byte acc8 = 0; if (IsAligned(buf) && IsAligned(mask)) { @@ -125,7 +125,7 @@ bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count) return acc32 == 0; buf += 4*i; mask += 4*i; - acc8 = byte(acc32) | byte(acc32>>8) | byte(acc32>>16) | byte(acc32>>24); + acc8 = ::byte(acc32) | ::byte(acc32>>8) | ::byte(acc32>>16) | ::byte(acc32>>24); } for (i=0; i(Integer value, unsigned int base); #define RETURN_IF_NONZERO(x) size_t returnedValue = x; if (returnedValue) return returnedValue // this version of the macro is fastest on Pentium 3 and Pentium 4 with MSVC 6 SP5 w/ Processor Pack -#define GETBYTE(x, y) (unsigned int)byte((x)>>(8*(y))) +#define GETBYTE(x, y) (unsigned int)::byte((x)>>(8*(y))) // these may be faster on other CPUs/compilers // #define GETBYTE(x, y) (unsigned int)(((x)>>(8*(y)))&255) -// #define GETBYTE(x, y) (((byte *)&(x))[y]) +// #define GETBYTE(x, y) (((::byte *)&(x))[y]) -#define CRYPTOPP_GET_BYTE_AS_BYTE(x, y) byte((x)>>(8*(y))) +#define CRYPTOPP_GET_BYTE_AS_BYTE(x, y) ::byte((x)>>(8*(y))) //! \brief Returns the parity of a value //! \tparam T class or type @@ -834,7 +834,7 @@ inline size_t BitsToDwords(size_t bitCount) //! \param count the size of the buffers, in bytes //! \details The function effectively visits each element in the buffers and performs //! buf[i] ^= mask[i]. buf and mask must be of equal size. -CRYPTOPP_DLL void CRYPTOPP_API xorbuf(byte *buf, const byte *mask, size_t count); +CRYPTOPP_DLL void CRYPTOPP_API xorbuf(::byte *buf, const ::byte *mask, size_t count); //! Performs an XOR of an input buffer with a mask and stores the result in an output buffer //! \param output the destination buffer @@ -843,7 +843,7 @@ CRYPTOPP_DLL void CRYPTOPP_API xorbuf(byte *buf, const byte *mask, size_t count) //! \param count the size of the buffers, in bytes //! \details The function effectively visits each element in the buffers and performs //! output[i] = input[i] ^ mask[i]. output, input and mask must be of equal size. -CRYPTOPP_DLL void CRYPTOPP_API xorbuf(byte *output, const byte *input, const byte *mask, size_t count); +CRYPTOPP_DLL void CRYPTOPP_API xorbuf(::byte *output, const ::byte *input, const ::byte *mask, size_t count); //! \brief Performs a near constant-time comparison of two equally sized buffers //! \param buf1 the first buffer @@ -854,7 +854,7 @@ CRYPTOPP_DLL void CRYPTOPP_API xorbuf(byte *output, const byte *input, const byt //! CPU micro-code timings could affect the "constant-ness". Calling code is responsible for //! mitigating timing attacks if the buffers are \a not equally sized. //! \sa ModPowerOf2 -CRYPTOPP_DLL bool CRYPTOPP_API VerifyBufsEqual(const byte *buf1, const byte *buf2, size_t count); +CRYPTOPP_DLL bool CRYPTOPP_API VerifyBufsEqual(const ::byte *buf1, const ::byte *buf2, size_t count); //! \brief Tests whether a value is a power of 2 //! \param value the value to test @@ -1111,7 +1111,7 @@ CRYPTOPP_DLL void CRYPTOPP_API CallNewHandler(); //! \details Performs an addition with carry by adding 1 on a block of bytes starting at the least //! significant byte. Once carry is 0, the function terminates and returns to the caller. //! \note The function is not constant time because it stops processing when the carry is 0. -inline void IncrementCounterByOne(byte *inout, unsigned int size) +inline void IncrementCounterByOne(::byte *inout, unsigned int size) { CRYPTOPP_ASSERT(inout != NULLPTR); CRYPTOPP_ASSERT(size < INT_MAX); for (int i=int(size-1), carry=1; i>=0 && carry; i--) @@ -1125,7 +1125,7 @@ inline void IncrementCounterByOne(byte *inout, unsigned int size) //! \details Performs an addition with carry on a block of bytes starting at the least significant //! byte. Once carry is 0, the remaining bytes from input are copied to output using memcpy. //! \details The function is \a close to near-constant time because it operates on all the bytes in the blocks. -inline void IncrementCounterByOne(byte *output, const byte *input, unsigned int size) +inline void IncrementCounterByOne(::byte *output, const ::byte *input, unsigned int size) { CRYPTOPP_ASSERT(output != NULLPTR); CRYPTOPP_ASSERT(input != NULLPTR); CRYPTOPP_ASSERT(size < INT_MAX); @@ -1184,13 +1184,13 @@ void SecureWipeBuffer(T *buf, size_t n) //! \param buf an array of bytes //! \param n the number of elements in the array //! \details The operation performs a wipe or zeroization. The function attempts to survive optimizations and dead code removal. -template<> inline void SecureWipeBuffer(byte *buf, size_t n) +template<> inline void SecureWipeBuffer(::byte *buf, size_t n) { - volatile byte *p = buf; + volatile ::byte *p = buf; #ifdef __GNUC__ asm volatile("rep stosb" : "+c"(n), "+D"(p) : "a"(0) : "memory"); #else - __stosb((byte *)(size_t)p, 0, n); + __stosb((::byte *)(size_t)p, 0, n); #endif } @@ -1243,7 +1243,7 @@ template<> inline void SecureWipeBuffer(word64 *buf, size_t n) #endif // #if (_MSC_VER >= 1400 || defined(__GNUC__)) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86) #if (_MSC_VER >= 1700) && defined(_M_ARM) -template<> inline void SecureWipeBuffer(byte *buf, size_t n) +template<> inline void SecureWipeBuffer(::byte *buf, size_t n) { char *p = reinterpret_cast(buf+n); while (n--) @@ -1287,7 +1287,7 @@ inline void SecureWipeArray(T *buf, size_t n) else if (sizeof(T) % 2 == 0 && GetAlignmentOf() % GetAlignmentOf() == 0) SecureWipeBuffer((word16 *)(void *)buf, n * (sizeof(T)/2)); else - SecureWipeBuffer((byte *)(void *)buf, n * sizeof(T)); + SecureWipeBuffer((::byte *)(void *)buf, n * sizeof(T)); } //! \brief Converts a wide character C-string to a multibyte string @@ -1475,7 +1475,7 @@ template<> inline word32 rotlFixed(word32 x, unsigned int y) { // Uses Microsoft call, bound to C/C++ language rules. CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return y ? _lrotl(x, static_cast(y)) : x; + return y ? _lrotl(x, static_cast< ::byte>(y)) : x; } //! \brief Performs a right rotate @@ -1490,7 +1490,7 @@ template<> inline word32 rotrFixed(word32 x, unsigned int y) { // Uses Microsoft call, bound to C/C++ language rules. CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return y ? _lrotr(x, static_cast(y)) : x; + return y ? _lrotr(x, static_cast< ::byte>(y)) : x; } //! \brief Performs a left rotate @@ -1504,7 +1504,7 @@ template<> inline word32 rotrFixed(word32 x, unsigned int y) template<> inline word32 rotlVariable(word32 x, unsigned int y) { CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return _lrotl(x, static_cast(y)); + return _lrotl(x, static_cast< ::byte>(y)); } //! \brief Performs a right rotate @@ -1518,7 +1518,7 @@ template<> inline word32 rotlVariable(word32 x, unsigned int y) template<> inline word32 rotrVariable(word32 x, unsigned int y) { CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return _lrotr(x, static_cast(y)); + return _lrotr(x, static_cast< ::byte>(y)); } //! \brief Performs a left rotate @@ -1531,7 +1531,7 @@ template<> inline word32 rotrVariable(word32 x, unsigned int y) template<> inline word32 rotlMod(word32 x, unsigned int y) { y %= 8*sizeof(x); - return _lrotl(x, static_cast(y)); + return _lrotl(x, static_cast< ::byte>(y)); } //! \brief Performs a right rotate @@ -1544,7 +1544,7 @@ template<> inline word32 rotlMod(word32 x, unsigned int y) template<> inline word32 rotrMod(word32 x, unsigned int y) { y %= 8*sizeof(x); - return _lrotr(x, static_cast(y)); + return _lrotr(x, static_cast< ::byte>(y)); } #endif // #ifdef _MSC_VER @@ -1564,7 +1564,7 @@ template<> inline word64 rotlFixed(word64 x, unsigned int y) { // Uses Microsoft call, bound to C/C++ language rules. CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return y ? _rotl64(x, static_cast(y)) : x; + return y ? _rotl64(x, static_cast< ::byte>(y)) : x; } //! \brief Performs a right rotate @@ -1579,7 +1579,7 @@ template<> inline word64 rotrFixed(word64 x, unsigned int y) { // Uses Microsoft call, bound to C/C++ language rules. CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return y ? _rotr64(x, static_cast(y)) : x; + return y ? _rotr64(x, static_cast< ::byte>(y)) : x; } //! \brief Performs a left rotate @@ -1593,7 +1593,7 @@ template<> inline word64 rotrFixed(word64 x, unsigned int y) template<> inline word64 rotlVariable(word64 x, unsigned int y) { CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return _rotl64(x, static_cast(y)); + return _rotl64(x, static_cast< ::byte>(y)); } //! \brief Performs a right rotate @@ -1607,7 +1607,7 @@ template<> inline word64 rotlVariable(word64 x, unsigned int y) template<> inline word64 rotrVariable(word64 x, unsigned int y) { CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return y ? _rotr64(x, static_cast(y)) : x; + return y ? _rotr64(x, static_cast< ::byte>(y)) : x; } //! \brief Performs a left rotate @@ -1620,7 +1620,7 @@ template<> inline word64 rotrVariable(word64 x, unsigned int y) template<> inline word64 rotlMod(word64 x, unsigned int y) { CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return y ? _rotl64(x, static_cast(y)) : x; + return y ? _rotl64(x, static_cast< ::byte>(y)) : x; } //! \brief Performs a right rotate @@ -1633,7 +1633,7 @@ template<> inline word64 rotlMod(word64 x, unsigned int y) template<> inline word64 rotrMod(word64 x, unsigned int y) { CRYPTOPP_ASSERT(y < 8*sizeof(x)); - return y ? _rotr64(x, static_cast(y)) : x; + return y ? _rotr64(x, static_cast< ::byte>(y)) : x; } #endif // #if _MSC_VER >= 1310 @@ -1644,65 +1644,65 @@ template<> inline word64 rotrMod(word64 x, unsigned int y) template<> inline word16 rotlFixed(word16 x, unsigned int y) { // Intrinsic, not bound to C/C++ language rules. - return _rotl16(x, static_cast(y)); + return _rotl16(x, static_cast< ::byte>(y)); } template<> inline word16 rotrFixed(word16 x, unsigned int y) { // Intrinsic, not bound to C/C++ language rules. - return _rotr16(x, static_cast(y)); + return _rotr16(x, static_cast< ::byte>(y)); } template<> inline word16 rotlVariable(word16 x, unsigned int y) { - return _rotl16(x, static_cast(y)); + return _rotl16(x, static_cast< ::byte>(y)); } template<> inline word16 rotrVariable(word16 x, unsigned int y) { - return _rotr16(x, static_cast(y)); + return _rotr16(x, static_cast< ::byte>(y)); } template<> inline word16 rotlMod(word16 x, unsigned int y) { - return _rotl16(x, static_cast(y)); + return _rotl16(x, static_cast< ::byte>(y)); } template<> inline word16 rotrMod(word16 x, unsigned int y) { - return _rotr16(x, static_cast(y)); + return _rotr16(x, static_cast< ::byte>(y)); } -template<> inline byte rotlFixed(byte x, unsigned int y) +template<> inline ::byte rotlFixed< ::byte>(::byte x, unsigned int y) { // Intrinsic, not bound to C/C++ language rules. - return _rotl8(x, static_cast(y)); + return _rotl8(x, static_cast< ::byte>(y)); } -template<> inline byte rotrFixed(byte x, unsigned int y) +template<> inline ::byte rotrFixed< ::byte>(::byte x, unsigned int y) { // Intrinsic, not bound to C/C++ language rules. - return _rotr8(x, static_cast(y)); + return _rotr8(x, static_cast< ::byte>(y)); } -template<> inline byte rotlVariable(byte x, unsigned int y) +template<> inline ::byte rotlVariable< ::byte>(::byte x, unsigned int y) { - return _rotl8(x, static_cast(y)); + return _rotl8(x, static_cast< ::byte>(y)); } -template<> inline byte rotrVariable(byte x, unsigned int y) +template<> inline ::byte rotrVariable< ::byte>(::byte x, unsigned int y) { - return _rotr8(x, static_cast(y)); + return _rotr8(x, static_cast< ::byte>(y)); } -template<> inline byte rotlMod(byte x, unsigned int y) +template<> inline ::byte rotlMod< ::byte>(::byte x, unsigned int y) { - return _rotl8(x, static_cast(y)); + return _rotl8(x, static_cast< ::byte>(y)); } -template<> inline byte rotrMod(byte x, unsigned int y) +template<> inline ::byte rotrMod< ::byte>(::byte x, unsigned int y) { - return _rotr8(x, static_cast(y)); + return _rotr8(x, static_cast< ::byte>(y)); } #endif // #if _MSC_VER >= 1400 @@ -1763,7 +1763,7 @@ inline unsigned int GetByte(ByteOrder order, T value, unsigned int index) //! \brief Reverses bytes in a 8-bit value //! \param value the 8-bit value to reverse //! \note ByteReverse returns the value passed to it since there is nothing to reverse -inline byte ByteReverse(byte value) +inline ::byte ByteReverse(::byte value) { return value; } @@ -1842,10 +1842,10 @@ inline word64 ByteReverse(word64 value) //! \brief Reverses bits in a 8-bit value //! \param value the 8-bit value to reverse //! \details BitReverse performs a combination of shifts on the byte -inline byte BitReverse(byte value) +inline ::byte BitReverse(::byte value) { - value = byte((value & 0xAA) >> 1) | byte((value & 0x55) << 1); - value = byte((value & 0xCC) >> 2) | byte((value & 0x33) << 2); + value = ::byte((value & 0xAA) >> 1) | ::byte((value & 0x55) << 1); + value = ::byte((value & 0xCC) >> 2) | ::byte((value & 0x33) << 2); return rotlFixed(value, 4U); } @@ -1896,7 +1896,7 @@ template inline T BitReverse(T value) { if (sizeof(T) == 1) - return (T)BitReverse((byte)value); + return (T)BitReverse((::byte)value); else if (sizeof(T) == 2) return (T)BitReverse((word16)value); else if (sizeof(T) == 4) @@ -1988,37 +1988,37 @@ inline void ConditionalByteReverse(ByteOrder order, T *out, const T *in, size_t } template -inline void GetUserKey(ByteOrder order, T *out, size_t outlen, const byte *in, size_t inlen) +inline void GetUserKey(ByteOrder order, T *out, size_t outlen, const ::byte *in, size_t inlen) { const size_t U = sizeof(T); CRYPTOPP_ASSERT(inlen <= outlen*U); memcpy_s(out, outlen*U, in, inlen); - memset_z((byte *)out+inlen, 0, outlen*U-inlen); + memset_z((::byte *)out+inlen, 0, outlen*U-inlen); ConditionalByteReverse(order, out, out, RoundUpToMultipleOf(inlen, U)); } #ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS -inline byte UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const byte *) +inline ::byte UnalignedGetWordNonTemplate(ByteOrder order, const ::byte *block, const ::byte *) { CRYPTOPP_UNUSED(order); return block[0]; } -inline word16 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word16 *) +inline word16 UnalignedGetWordNonTemplate(ByteOrder order, const ::byte *block, const word16 *) { return (order == BIG_ENDIAN_ORDER) ? block[1] | (block[0] << 8) : block[0] | (block[1] << 8); } -inline word32 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word32 *) +inline word32 UnalignedGetWordNonTemplate(ByteOrder order, const ::byte *block, const word32 *) { return (order == BIG_ENDIAN_ORDER) ? word32(block[3]) | (word32(block[2]) << 8) | (word32(block[1]) << 16) | (word32(block[0]) << 24) : word32(block[0]) | (word32(block[1]) << 8) | (word32(block[2]) << 16) | (word32(block[3]) << 24); } -inline word64 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word64 *) +inline word64 UnalignedGetWordNonTemplate(ByteOrder order, const ::byte *block, const word64 *) { return (order == BIG_ENDIAN_ORDER) ? @@ -2041,13 +2041,13 @@ inline word64 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, co (word64(block[7]) << 56)); } -inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, byte value, const byte *xorBlock) +inline void UnalignedbyteNonTemplate(ByteOrder order, ::byte *block, ::byte value, const ::byte *xorBlock) { CRYPTOPP_UNUSED(order); - block[0] = (byte)(xorBlock ? (value ^ xorBlock[0]) : value); + block[0] = (::byte)(xorBlock ? (value ^ xorBlock[0]) : value); } -inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word16 value, const byte *xorBlock) +inline void UnalignedbyteNonTemplate(ByteOrder order, ::byte *block, word16 value, const ::byte *xorBlock) { if (order == BIG_ENDIAN_ORDER) { @@ -2077,7 +2077,7 @@ inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word16 value, } } -inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word32 value, const byte *xorBlock) +inline void UnalignedbyteNonTemplate(ByteOrder order, ::byte *block, word32 value, const ::byte *xorBlock) { if (order == BIG_ENDIAN_ORDER) { @@ -2115,7 +2115,7 @@ inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word32 value, } } -inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word64 value, const byte *xorBlock) +inline void UnalignedbyteNonTemplate(ByteOrder order, ::byte *block, word64 value, const ::byte *xorBlock) { if (order == BIG_ENDIAN_ORDER) { @@ -2187,7 +2187,7 @@ inline void UnalignedbyteNonTemplate(ByteOrder order, byte *block, word64 value, //! w = GetWord(false, LITTLE_ENDIAN_ORDER, buffer); //! template -inline T GetWord(bool assumeAligned, ByteOrder order, const byte *block) +inline T GetWord(bool assumeAligned, ByteOrder order, const ::byte *block) { CRYPTOPP_UNUSED(assumeAligned); #ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS @@ -2216,7 +2216,7 @@ inline T GetWord(bool assumeAligned, ByteOrder order, const byte *block) //! w = GetWord(false, LITTLE_ENDIAN_ORDER, buffer); //! template -inline void GetWord(bool assumeAligned, ByteOrder order, T &result, const byte *block) +inline void GetWord(bool assumeAligned, ByteOrder order, T &result, const ::byte *block) { result = GetWord(assumeAligned, order, block); } @@ -2232,7 +2232,7 @@ inline void GetWord(bool assumeAligned, ByteOrder order, T &result, const byte * //! if the memory block is aligned for class or type T. The enumeration ByteOrder is BIG_ENDIAN_ORDER or //! LITTLE_ENDIAN_ORDER. template -inline void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, const byte *xorBlock = NULLPTR) +inline void PutWord(bool assumeAligned, ByteOrder order, ::byte *block, T value, const ::byte *xorBlock = NULLPTR) { CRYPTOPP_UNUSED(assumeAligned); #ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS @@ -2268,7 +2268,7 @@ public: //! \brief Construct a GetBlock //! \param block the memory block GetBlock(const void *block) - : m_block((const byte *)block) {} + : m_block((const ::byte *)block) {} //! \brief Access a block of memory //! \tparam U class or type @@ -2284,7 +2284,7 @@ public: } private: - const byte *m_block; + const ::byte *m_block; }; //! \class PutBlock @@ -2311,7 +2311,7 @@ public: //! \param block the memory block //! \param xorBlock optional mask PutBlock(const void *xorBlock, void *block) - : m_xorBlock((const byte *)xorBlock), m_block((byte *)block) {} + : m_xorBlock((const ::byte *)xorBlock), m_block((::byte *)block) {} //! \brief Access a block of memory //! \tparam U class or type @@ -2328,8 +2328,8 @@ public: } private: - const byte *m_xorBlock; - byte *m_block; + const ::byte *m_xorBlock; + ::byte *m_block; }; //! \class BlockGetAndPut diff --git a/modes.cpp b/modes.cpp index 0d9849ce..a7a2dd03 100644 --- a/modes.cpp +++ b/modes.cpp @@ -30,7 +30,7 @@ void CipherModeBase::ResizeBuffers() m_register.New(m_cipher->BlockSize()); } -void CFB_ModePolicy::Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount) +void CFB_ModePolicy::Iterate(::byte *output, const ::byte *input, CipherDir dir, size_t iterationCount) { CRYPTOPP_ASSERT(input); CRYPTOPP_ASSERT(output); @@ -64,7 +64,7 @@ void CFB_ModePolicy::TransformRegister() memcpy_s(m_register+updateSize, m_register.size()-updateSize, m_temp, m_feedbackSize); } -void CFB_ModePolicy::CipherResynchronize(const byte *iv, size_t length) +void CFB_ModePolicy::CipherResynchronize(const ::byte *iv, size_t length) { CRYPTOPP_ASSERT(length == BlockSize()); CopyOrZero(m_register, m_register.size(), iv, length); @@ -84,7 +84,7 @@ void CFB_ModePolicy::ResizeBuffers() m_temp.New(BlockSize()); } -void OFB_ModePolicy::WriteKeystream(byte *keystreamBuffer, size_t iterationCount) +void OFB_ModePolicy::WriteKeystream(::byte *keystreamBuffer, size_t iterationCount) { CRYPTOPP_ASSERT(m_cipher->IsForwardTransformation()); // OFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt unsigned int s = BlockSize(); @@ -94,7 +94,7 @@ void OFB_ModePolicy::WriteKeystream(byte *keystreamBuffer, size_t iterationCount memcpy(m_register, keystreamBuffer+s*(iterationCount-1), s); } -void OFB_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length) +void OFB_ModePolicy::CipherResynchronize(::byte *keystreamBuffer, const ::byte *iv, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(length == BlockSize()); @@ -107,8 +107,8 @@ void CTR_ModePolicy::SeekToIteration(lword iterationCount) int carry=0; for (int i=BlockSize()-1; i>=0; i--) { - unsigned int sum = m_register[i] + byte(iterationCount) + carry; - m_counterArray[i] = (byte) sum; + unsigned int sum = m_register[i] + ::byte(iterationCount) + carry; + m_counterArray[i] = (::byte) sum; carry = sum >> 8; iterationCount >>= 8; } @@ -119,7 +119,7 @@ void CTR_ModePolicy::IncrementCounterBy256() IncrementCounterByOne(m_counterArray, BlockSize()-1); } -void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, byte *output, const byte *input, size_t iterationCount) +void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, ::byte *output, const ::byte *input, size_t iterationCount) { CRYPTOPP_ASSERT(m_cipher->IsForwardTransformation()); // CTR mode needs the "encrypt" direction of the underlying block cipher, even to decrypt unsigned int s = BlockSize(); @@ -127,10 +127,10 @@ void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, byte *ou while (iterationCount) { - byte lsb = m_counterArray[s-1]; + ::byte lsb = m_counterArray[s-1]; size_t blocks = UnsignedMin(iterationCount, 256U-lsb); m_cipher->AdvancedProcessBlocks(m_counterArray, input, output, blocks*s, BlockTransformation::BT_InBlockIsCounter|BlockTransformation::BT_AllowParallel); - if ((m_counterArray[s-1] = lsb + (byte)blocks) == 0) + if ((m_counterArray[s-1] = lsb + (::byte)blocks) == 0) IncrementCounterBy256(); output += blocks*s; @@ -139,7 +139,7 @@ void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, byte *ou } } -void CTR_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length) +void CTR_ModePolicy::CipherResynchronize(::byte *keystreamBuffer, const ::byte *iv, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(length == BlockSize()); @@ -148,14 +148,14 @@ void CTR_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, m_counterArray = m_register; } -void BlockOrientedCipherModeBase::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) +void BlockOrientedCipherModeBase::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { m_cipher->SetKey(key, length, params); ResizeBuffers(); if (IsResynchronizable()) { size_t ivLength; - const byte *iv = GetIVAndThrowIfInvalid(params, ivLength); + const ::byte *iv = GetIVAndThrowIfInvalid(params, ivLength); Resynchronize(iv, (int)ivLength); } } @@ -166,13 +166,13 @@ void BlockOrientedCipherModeBase::ResizeBuffers() m_buffer.New(BlockSize()); } -void ECB_OneWay::ProcessData(byte *outString, const byte *inString, size_t length) +void ECB_OneWay::ProcessData(::byte *outString, const ::byte *inString, size_t length) { CRYPTOPP_ASSERT(length%BlockSize()==0); m_cipher->AdvancedProcessBlocks(inString, NULLPTR, outString, length, BlockTransformation::BT_AllowParallel); } -void CBC_Encryption::ProcessData(byte *outString, const byte *inString, size_t length) +void CBC_Encryption::ProcessData(::byte *outString, const ::byte *inString, size_t length) { if (!length) return; @@ -185,7 +185,7 @@ void CBC_Encryption::ProcessData(byte *outString, const byte *inString, size_t l memcpy(m_register, outString + length - blockSize, blockSize); } -void CBC_CTS_Encryption::ProcessLastBlock(byte *outString, const byte *inString, size_t length) +void CBC_CTS_Encryption::ProcessLastBlock(::byte *outString, const ::byte *inString, size_t length) { if (length <= BlockSize()) { @@ -218,7 +218,7 @@ void CBC_Decryption::ResizeBuffers() m_temp.New(BlockSize()); } -void CBC_Decryption::ProcessData(byte *outString, const byte *inString, size_t length) +void CBC_Decryption::ProcessData(::byte *outString, const ::byte *inString, size_t length) { if (!length) return; @@ -232,9 +232,9 @@ void CBC_Decryption::ProcessData(byte *outString, const byte *inString, size_t l m_register.swap(m_temp); } -void CBC_CTS_Decryption::ProcessLastBlock(byte *outString, const byte *inString, size_t length) +void CBC_CTS_Decryption::ProcessLastBlock(::byte *outString, const ::byte *inString, size_t length) { - const byte *pn, *pn1; + const ::byte *pn, *pn1; bool stealIV = length <= BlockSize(); if (stealIV) diff --git a/modes.h b/modes.h index 05be7b52..72bcb86f 100644 --- a/modes.h +++ b/modes.h @@ -70,7 +70,7 @@ public: this->ResizeBuffers(); } - void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize = 0) + void SetCipherWithIV(BlockCipher &cipher, const ::byte *iv, int feedbackSize = 0) { this->ThrowIfInvalidIV(iv); this->m_cipher = &cipher; @@ -102,11 +102,11 @@ template class CRYPTOPP_NO_VTABLE ModePolicyCommonTemplate : public CipherModeBase, public POLICY_INTERFACE { unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();} - void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); + void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length); }; template -void ModePolicyCommonTemplate::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) +void ModePolicyCommonTemplate::CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length) { m_cipher->SetKey(key, length, params); ResizeBuffers(); @@ -126,11 +126,11 @@ public: protected: unsigned int GetBytesPerIteration() const {return m_feedbackSize;} - byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;} + ::byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;} bool CanIterate() const {return m_feedbackSize == BlockSize();} - void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount); + void Iterate(::byte *output, const ::byte *input, CipherDir dir, size_t iterationCount); void TransformRegister(); - void CipherResynchronize(const byte *iv, size_t length); + void CipherResynchronize(const ::byte *iv, size_t length); void SetFeedbackSize(unsigned int feedbackSize); void ResizeBuffers(); @@ -162,8 +162,8 @@ public: private: unsigned int GetBytesPerIteration() const {return BlockSize();} unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();} - void WriteKeystream(byte *keystreamBuffer, size_t iterationCount); - void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); + void WriteKeystream(::byte *keystreamBuffer, size_t iterationCount); + void CipherResynchronize(::byte *keystreamBuffer, const ::byte *iv, size_t length); }; //! \class CTR_ModePolicy @@ -182,11 +182,11 @@ protected: unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();} unsigned int GetBytesPerIteration() const {return BlockSize();} unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();} - void WriteKeystream(byte *buffer, size_t iterationCount) + void WriteKeystream(::byte *buffer, size_t iterationCount) {OperateKeystream(WRITE_KEYSTREAM, buffer, NULLPTR, iterationCount);} bool CanOperateKeystream() const {return true;} - void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); - void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); + void OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount); + void CipherResynchronize(::byte *keystreamBuffer, const ::byte *iv, size_t length); void SeekToIteration(lword iterationCount); AlignedSecByteBlock m_counterArray; @@ -198,12 +198,12 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockOrientedCipherModeBase : public Ciphe { public: virtual ~BlockOrientedCipherModeBase() {} - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); unsigned int MandatoryBlockSize() const {return BlockSize();} bool IsRandomAccess() const {return false;} bool IsSelfInverting() const {return false;} bool IsForwardTransformation() const {return m_cipher->IsForwardTransformation();} - void Resynchronize(const byte *iv, int length=-1) {memcpy_s(m_register, m_register.size(), iv, ThrowIfInvalidIVLength(length));} + void Resynchronize(const ::byte *iv, int length=-1) {memcpy_s(m_register, m_register.size(), iv, ThrowIfInvalidIVLength(length));} protected: bool RequireAlignedInput() const {return true;} @@ -219,11 +219,11 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : public BlockOrientedCipherMod public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "ECB";} - void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms = g_nullNameValuePairs) + void SetKey(const ::byte *key, size_t length, const NameValuePairs ¶ms = g_nullNameValuePairs) {m_cipher->SetKey(key, length, params); BlockOrientedCipherModeBase::ResizeBuffers();} IV_Requirement IVRequirement() const {return NOT_RESYNCHRONIZABLE;} unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();} - void ProcessData(byte *outString, const byte *inString, size_t length); + void ProcessData(::byte *outString, const ::byte *inString, size_t length); }; //! \class CBC_ModeBase @@ -243,7 +243,7 @@ public: class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Encryption : public CBC_ModeBase { public: - void ProcessData(byte *outString, const byte *inString, size_t length); + void ProcessData(::byte *outString, const ::byte *inString, size_t length); }; //! \class CBC_CTS_Encryption @@ -253,18 +253,18 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Encryption : public CBC_Encryption public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CBC/CTS";} - void SetStolenIV(byte *iv) {m_stolenIV = iv;} + void SetStolenIV(::byte *iv) {m_stolenIV = iv;} unsigned int MinLastBlockSize() const {return BlockSize()+1;} - void ProcessLastBlock(byte *outString, const byte *inString, size_t length); + void ProcessLastBlock(::byte *outString, const ::byte *inString, size_t length); protected: - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { CBC_Encryption::UncheckedSetKey(key, length, params); - m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULLPTR); + m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (::byte *)NULLPTR); } - byte *m_stolenIV; + ::byte *m_stolenIV; }; //! \class CBC_Decryption @@ -273,7 +273,7 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Decryption : public CBC_ModeBase { public: virtual ~CBC_Decryption() {} - void ProcessData(byte *outString, const byte *inString, size_t length); + void ProcessData(::byte *outString, const ::byte *inString, size_t length); protected: virtual void ResizeBuffers(); @@ -287,7 +287,7 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Decryption : public CBC_Decryption { public: unsigned int MinLastBlockSize() const {return BlockSize()+1;} - void ProcessLastBlock(byte *outString, const byte *inString, size_t length); + void ProcessLastBlock(::byte *outString, const ::byte *inString, size_t length); }; //! \class CipherModeFinalTemplate_CipherHolder @@ -304,17 +304,17 @@ public: this->m_cipher = &this->m_object; this->ResizeBuffers(); } - CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length) + CipherModeFinalTemplate_CipherHolder(const ::byte *key, size_t length) { this->m_cipher = &this->m_object; this->SetKey(key, length); } - CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv) + CipherModeFinalTemplate_CipherHolder(const ::byte *key, size_t length, const ::byte *iv) { this->m_cipher = &this->m_object; this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize()))); } - CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv, int feedbackSize) + CipherModeFinalTemplate_CipherHolder(const ::byte *key, size_t length, const ::byte *iv, int feedbackSize) { this->m_cipher = &this->m_object; this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize()))(Name::FeedbackSize(), feedbackSize)); @@ -331,7 +331,7 @@ public: CipherModeFinalTemplate_ExternalCipher() {} CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher) {this->SetCipher(cipher);} - CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0) + CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const ::byte *iv, int feedbackSize = 0) {this->SetCipherWithIV(cipher, iv, feedbackSize);} std::string AlgorithmName() const diff --git a/mqueue.cpp b/mqueue.cpp index 3e473025..ea5f993d 100644 --- a/mqueue.cpp +++ b/mqueue.cpp @@ -62,9 +62,9 @@ void MessageQueue::swap(MessageQueue &rhs) m_lengths.swap(rhs.m_lengths); } -const byte * MessageQueue::Spy(size_t &contiguousSize) const +const ::byte * MessageQueue::Spy(size_t &contiguousSize) const { - const byte *result = m_queue.Spy(contiguousSize); + const ::byte *result = m_queue.Spy(contiguousSize); contiguousSize = UnsignedMin(contiguousSize, MaxRetrievable()); return result; } @@ -81,7 +81,7 @@ unsigned int EqualityComparisonFilter::MapChannel(const std::string &channel) co return 2; } -size_t EqualityComparisonFilter::ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking) +size_t EqualityComparisonFilter::ChannelPut2(const std::string &channel, const ::byte *inString, size_t length, int messageEnd, bool blocking) { if (!blocking) throw BlockingInputOnly("EqualityComparisonFilter"); @@ -102,7 +102,7 @@ size_t EqualityComparisonFilter::ChannelPut2(const std::string &channel, const b while (length > 0 && q2.AnyRetrievable()) { size_t len = length; - const byte *data = q2.Spy(len); + const ::byte *data = q2.Spy(len); len = STDMIN(len, length); if (memcmp(inString, data, len) != 0) goto mismatch; @@ -150,7 +150,7 @@ bool EqualityComparisonFilter::ChannelMessageSeriesEnd(const std::string &channe if (q2.AnyRetrievable() || q2.AnyMessages()) goto mismatch; else if (q2.NumberOfMessageSeries() > 0) - return Output(2, (const byte *)"\1", 1, 0, blocking) != 0; + return Output(2, (const ::byte *)"\1", 1, 0, blocking) != 0; else q1.MessageSeriesEnd(); @@ -166,7 +166,7 @@ bool EqualityComparisonFilter::HandleMismatchDetected(bool blocking) m_mismatchDetected = true; if (m_throwIfNotEqual) throw MismatchDetected(); - return Output(1, (const byte *)"\0", 1, 0, blocking) != 0; + return Output(1, (const ::byte *)"\0", 1, 0, blocking) != 0; } NAMESPACE_END diff --git a/mqueue.h b/mqueue.h index 5c9bcdc8..87ecb715 100644 --- a/mqueue.h +++ b/mqueue.h @@ -18,7 +18,7 @@ public: void IsolatedInitialize(const NameValuePairs ¶meters) {m_queue.IsolatedInitialize(parameters); m_lengths.assign(1, 0U); m_messageCounts.assign(1, 0U);} - size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *begin, size_t length, int messageEnd, bool blocking) { CRYPTOPP_UNUSED(blocking); m_queue.Put(begin, length); @@ -56,7 +56,7 @@ public: unsigned int CopyMessagesTo(BufferedTransformation &target, unsigned int count=UINT_MAX, const std::string &channel=DEFAULT_CHANNEL) const; - const byte * Spy(size_t &contiguousSize) const; + const ::byte * Spy(size_t &contiguousSize) const; void swap(MessageQueue &rhs); @@ -79,7 +79,7 @@ public: , m_firstChannel(firstChannel), m_secondChannel(secondChannel) {Detach(attachment);} - size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking); + size_t ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking); bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true); private: diff --git a/mqv.h b/mqv.h index c51a8452..0d3b10eb 100644 --- a/mqv.h +++ b/mqv.h @@ -116,7 +116,7 @@ public: //! \param privateKey a byte buffer for the generated private key in this domain //! \details The private key is a random scalar used as an exponent in the range [1,MaxExponent()]. //! \pre COUNTOF(privateKey) == PrivateStaticKeyLength() - void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GenerateStaticPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const { Integer x(rng, Integer::One(), GetAbstractGroupParameters().GetMaxExponent()); x.Encode(privateKey, StaticPrivateKeyLength()); @@ -129,7 +129,7 @@ public: //! \details The public key is an element or point on the curve, and its stored in a revrsible format. //! A reversible format means it has a presentation format, and its an ANS.1 encoded element or point. //! \pre COUNTOF(publicKey) == PublicStaticKeyLength() - void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GenerateStaticPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const { CRYPTOPP_UNUSED(rng); const DL_GroupParameters ¶ms = GetAbstractGroupParameters(); @@ -141,7 +141,7 @@ public: unsigned int EphemeralPrivateKeyLength() const {return StaticPrivateKeyLength() + StaticPublicKeyLength();} unsigned int EphemeralPublicKeyLength() const {return StaticPublicKeyLength();} - void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const { const DL_GroupParameters ¶ms = GetAbstractGroupParameters(); Integer x(rng, Integer::One(), params.GetMaxExponent()); @@ -150,15 +150,15 @@ public: params.EncodeElement(true, y, privateKey+StaticPrivateKeyLength()); } - void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const { CRYPTOPP_UNUSED(rng); memcpy(publicKey, privateKey+StaticPrivateKeyLength(), EphemeralPublicKeyLength()); } - bool Agree(byte *agreedValue, - const byte *staticPrivateKey, const byte *ephemeralPrivateKey, - const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, + bool Agree(::byte *agreedValue, + const ::byte *staticPrivateKey, const ::byte *ephemeralPrivateKey, + const ::byte *staticOtherPublicKey, const ::byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const { try diff --git a/network.cpp b/network.cpp index 9195e22b..d8677ef0 100644 --- a/network.cpp +++ b/network.cpp @@ -79,7 +79,7 @@ void LimitedBandwidth::GetWaitObjects(WaitObjectContainer &container, const Call size_t NonblockingSource::GeneralPump2( lword& byteCount, bool blockingOutput, - unsigned long maxTime, bool checkDelimiter, byte delimiter) + unsigned long maxTime, bool checkDelimiter, ::byte delimiter) { m_blockedBySpeedLimit = false; @@ -258,7 +258,7 @@ void NetworkSource::GetWaitObjects(WaitObjectContainer &container, CallStack con AttachedTransformation()->GetWaitObjects(container, CallStack("NetworkSource::GetWaitObjects() - attachment", &callStack)); } -size_t NetworkSource::DoPump(lword &byteCount, bool blockingOutput, unsigned long maxTime, bool checkDelimiter, byte delimiter) +size_t NetworkSource::DoPump(lword &byteCount, bool blockingOutput, unsigned long maxTime, bool checkDelimiter, ::byte delimiter) { NetworkReceiver &receiver = AccessReceiver(); @@ -419,7 +419,7 @@ void NetworkSink::GetWaitObjects(WaitObjectContainer &container, CallStack const AccessSender().GetWaitObjects(container, CallStack("NetworkSink::GetWaitObjects() - EOF pending", &callStack)); } -size_t NetworkSink::Put2(const byte *inString, size_t length, int messageEnd, bool blocking) +size_t NetworkSink::Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { if (m_eofState == EOF_DONE) { @@ -512,7 +512,7 @@ lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize) break; size_t contiguousSize = 0; - const byte *block = m_buffer.Spy(contiguousSize); + const ::byte *block = m_buffer.Spy(contiguousSize); #if CRYPTOPP_TRACE_NETWORK OutputDebugString((IntToString((unsigned int)this) + ": Sending " + IntToString(contiguousSize) + " bytes\n").c_str()); diff --git a/network.h b/network.h index 065ea49a..7470f22a 100644 --- a/network.h +++ b/network.h @@ -62,16 +62,16 @@ public: //! pump up to maxSize bytes using at most maxTime milliseconds /*! If checkDelimiter is true, pump up to delimiter, which itself is not extracted or pumped. */ - size_t GeneralPump2(lword &byteCount, bool blockingOutput=true, unsigned long maxTime=INFINITE_TIME, bool checkDelimiter=false, byte delimiter='\n'); + size_t GeneralPump2(lword &byteCount, bool blockingOutput=true, unsigned long maxTime=INFINITE_TIME, bool checkDelimiter=false, ::byte delimiter='\n'); - lword GeneralPump(lword maxSize=LWORD_MAX, unsigned long maxTime=INFINITE_TIME, bool checkDelimiter=false, byte delimiter='\n') + lword GeneralPump(lword maxSize=LWORD_MAX, unsigned long maxTime=INFINITE_TIME, bool checkDelimiter=false, ::byte delimiter='\n') { GeneralPump2(maxSize, true, maxTime, checkDelimiter, delimiter); return maxSize; } lword TimedPump(unsigned long maxTime) {return GeneralPump(LWORD_MAX, maxTime);} - lword PumpLine(byte delimiter='\n', lword maxSize=1024) + lword PumpLine(::byte delimiter='\n', lword maxSize=1024) {return GeneralPump(maxSize, INFINITE_TIME, true, delimiter);} size_t Pump2(lword &byteCount, bool blocking=true) @@ -81,7 +81,7 @@ public: protected: virtual size_t DoPump(lword &byteCount, bool blockingOutput, - unsigned long maxTime, bool checkDelimiter, byte delimiter) =0; + unsigned long maxTime, bool checkDelimiter, ::byte delimiter) =0; bool BlockedBySpeedLimit() const { return m_blockedBySpeedLimit; } @@ -96,7 +96,7 @@ public: virtual bool MustWaitToReceive() {return false;} virtual bool MustWaitForResult() {return false;} //! receive data from network source, returns whether result is immediately available - virtual bool Receive(byte* buf, size_t bufLen) =0; + virtual bool Receive(::byte* buf, size_t bufLen) =0; virtual unsigned int GetReceiveResult() =0; virtual bool EofReceived() const =0; }; @@ -153,7 +153,7 @@ class CRYPTOPP_NO_VTABLE NetworkSender : public Waitable public: virtual bool MustWaitToSend() {return false;} virtual bool MustWaitForResult() {return false;} - virtual void Send(const byte* buf, size_t bufLen) =0; + virtual void Send(const ::byte* buf, size_t bufLen) =0; virtual unsigned int GetSendResult() =0; virtual bool MustWaitForEof() {return false;} virtual void SendEof() =0; @@ -172,7 +172,7 @@ public: bool SourceExhausted() const {return m_dataBegin == m_dataEnd && GetReceiver().EofReceived();} protected: - size_t DoPump(lword &byteCount, bool blockingOutput, unsigned long maxTime, bool checkDelimiter, byte delimiter); + size_t DoPump(lword &byteCount, bool blockingOutput, unsigned long maxTime, bool checkDelimiter, ::byte delimiter); virtual NetworkReceiver & AccessReceiver() =0; const NetworkReceiver & GetReceiver() const {return const_cast(this)->AccessReceiver();} @@ -192,7 +192,7 @@ public: unsigned int GetMaxWaitObjectCount() const; void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); void SetMaxBufferSize(size_t maxBufferSize) {m_maxBufferSize = maxBufferSize; m_buffer.SetNodeSize(UnsignedMin(maxBufferSize, 16U*1024U+256U));} void SetAutoFlushBound(size_t bound) {m_autoFlushBound = bound;} diff --git a/oaep.cpp b/oaep.cpp index 08d75a99..5357cb61 100644 --- a/oaep.cpp +++ b/oaep.cpp @@ -17,7 +17,7 @@ size_t OAEP_Base::MaxUnpaddedLength(size_t paddedLength) const return SaturatingSubtract(paddedLength/8, 1+2*DigestSize()); } -void OAEP_Base::Pad(RandomNumberGenerator &rng, const byte *input, size_t inputLength, byte *oaepBlock, size_t oaepBlockLen, const NameValuePairs ¶meters) const +void OAEP_Base::Pad(RandomNumberGenerator &rng, const ::byte *input, size_t inputLength, ::byte *oaepBlock, size_t oaepBlockLen, const NameValuePairs ¶meters) const { CRYPTOPP_ASSERT (inputLength <= MaxUnpaddedLength(oaepBlockLen)); @@ -32,8 +32,8 @@ void OAEP_Base::Pad(RandomNumberGenerator &rng, const byte *input, size_t inputL member_ptr pHash(NewHash()); const size_t hLen = pHash->DigestSize(); const size_t seedLen = hLen, dbLen = oaepBlockLen-seedLen; - byte *const maskedSeed = oaepBlock; - byte *const maskedDB = oaepBlock+seedLen; + ::byte *const maskedSeed = oaepBlock; + ::byte *const maskedDB = oaepBlock+seedLen; ConstByteArrayParameter encodingParameters; parameters.GetValue(Name::EncodingParameters(), encodingParameters); @@ -50,7 +50,7 @@ void OAEP_Base::Pad(RandomNumberGenerator &rng, const byte *input, size_t inputL pMGF->GenerateAndMask(*pHash, maskedSeed, seedLen, maskedDB, dbLen); } -DecodingResult OAEP_Base::Unpad(const byte *oaepBlock, size_t oaepBlockLen, byte *output, const NameValuePairs ¶meters) const +DecodingResult OAEP_Base::Unpad(const ::byte *oaepBlock, size_t oaepBlockLen, ::byte *output, const NameValuePairs ¶meters) const { bool invalid = false; @@ -69,8 +69,8 @@ DecodingResult OAEP_Base::Unpad(const byte *oaepBlock, size_t oaepBlockLen, byte invalid = (oaepBlockLen < 2*hLen+1) || invalid; SecByteBlock t(oaepBlock, oaepBlockLen); - byte *const maskedSeed = t; - byte *const maskedDB = t+seedLen; + ::byte *const maskedSeed = t; + ::byte *const maskedDB = t+seedLen; member_ptr pMGF(NewMGF()); pMGF->GenerateAndMask(*pHash, maskedSeed, seedLen, maskedDB, dbLen); @@ -80,9 +80,9 @@ DecodingResult OAEP_Base::Unpad(const byte *oaepBlock, size_t oaepBlockLen, byte parameters.GetValue(Name::EncodingParameters(), encodingParameters); // DB = pHash' || 00 ... || 01 || M - byte *M = std::find(maskedDB+hLen, maskedDB+dbLen, 0x01); + ::byte *M = std::find(maskedDB+hLen, maskedDB+dbLen, 0x01); invalid = (M == maskedDB+dbLen) || invalid; - invalid = (std::find_if(maskedDB+hLen, M, std::bind2nd(std::not_equal_to(), byte(0))) != M) || invalid; + invalid = (std::find_if(maskedDB+hLen, M, std::bind2nd(std::not_equal_to< ::byte>(), ::byte(0))) != M) || invalid; invalid = !pHash->VerifyDigest(maskedDB, encodingParameters.begin(), encodingParameters.size()) || invalid; if (invalid) diff --git a/oaep.h b/oaep.h index 1809af43..6e107412 100644 --- a/oaep.h +++ b/oaep.h @@ -13,8 +13,8 @@ class CRYPTOPP_DLL OAEP_Base : public PK_EncryptionMessageEncodingMethod public: bool ParameterSupported(const char *name) const {return strcmp(name, Name::EncodingParameters()) == 0;} size_t MaxUnpaddedLength(size_t paddedLength) const; - void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const; - DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs ¶meters) const; + void Pad(RandomNumberGenerator &rng, const ::byte *raw, size_t inputLength, ::byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const; + DecodingResult Unpad(const ::byte *padded, size_t paddedLength, ::byte *raw, const NameValuePairs ¶meters) const; protected: virtual unsigned int DigestSize() const =0; diff --git a/osrng.cpp b/osrng.cpp index 6d36aaea..995f42f6 100644 --- a/osrng.cpp +++ b/osrng.cpp @@ -142,7 +142,7 @@ NonblockingRng::~NonblockingRng() #endif } -void NonblockingRng::GenerateBlock(byte *output, size_t size) +void NonblockingRng::GenerateBlock(::byte *output, size_t size) { #ifdef CRYPTOPP_WIN32_AVAILABLE // Acquiring a provider is expensive. Do it once and retain the reference. @@ -204,7 +204,7 @@ BlockingRng::~BlockingRng() close(m_fd); } -void BlockingRng::GenerateBlock(byte *output, size_t size) +void BlockingRng::GenerateBlock(::byte *output, size_t size) { while (size) { @@ -231,7 +231,7 @@ void BlockingRng::GenerateBlock(byte *output, size_t size) // ************************************************************* -void OS_GenerateRandomBlock(bool blocking, byte *output, size_t size) +void OS_GenerateRandomBlock(bool blocking, ::byte *output, size_t size) { #ifdef NONBLOCKING_RNG_AVAILABLE if (blocking) diff --git a/osrng.h b/osrng.h index 9e1934b0..d5d23add 100644 --- a/osrng.h +++ b/osrng.h @@ -98,7 +98,7 @@ public: //! \param output the byte buffer //! \param size the length of the buffer, in bytes //! \details GenerateIntoBufferedTransformation() calls are routed to GenerateBlock(). - void GenerateBlock(byte *output, size_t size); + void GenerateBlock(::byte *output, size_t size); protected: #ifdef CRYPTOPP_WIN32_AVAILABLE @@ -129,7 +129,7 @@ public: //! \param output the byte buffer //! \param size the length of the buffer, in bytes //! \details GenerateIntoBufferedTransformation() calls are routed to GenerateBlock(). - void GenerateBlock(byte *output, size_t size); + void GenerateBlock(::byte *output, size_t size); protected: int m_fd; @@ -147,7 +147,7 @@ protected: //! \details On Unix and compatibles, /dev/urandom is called if blocking is false using //! NonblockingRng. If blocking is true, then either /dev/randomd or /dev/srandom is used //! by way of BlockingRng, if available. -CRYPTOPP_DLL void CRYPTOPP_API OS_GenerateRandomBlock(bool blocking, byte *output, size_t size); +CRYPTOPP_DLL void CRYPTOPP_API OS_GenerateRandomBlock(bool blocking, ::byte *output, size_t size); //! \class AutoSeededRandomPool //! \brief Automatically Seeded Randomness Pool @@ -207,7 +207,7 @@ public: //! \details Internally, the generator uses SHA256 to extract the entropy from //! from the seed and then stretch the material for the block cipher's key //! and initialization vector. - void Reseed(bool blocking = false, const byte *additionalEntropy = NULLPTR, size_t length = 0); + void Reseed(bool blocking = false, const ::byte *additionalEntropy = NULLPTR, size_t length = 0); //! \brief Deterministically reseed an AutoSeededX917RNG for testing //! \param key the key to use for the deterministic reseeding @@ -216,10 +216,10 @@ public: //! \param timeVector a time vector to use for deterministic reseeding //! \details This is a testing interface for testing purposes, and should \a NOT //! be used in production. - void Reseed(const byte *key, size_t keylength, const byte *seed, const byte *timeVector); + void Reseed(const ::byte *key, size_t keylength, const ::byte *seed, const ::byte *timeVector); bool CanIncorporateEntropy() const {return true;} - void IncorporateEntropy(const byte *input, size_t length) {Reseed(false, input, length);} + void IncorporateEntropy(const ::byte *input, size_t length) {Reseed(false, input, length);} void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword length) {m_rng->GenerateIntoBufferedTransformation(target, channel, length);} @@ -228,16 +228,16 @@ private: }; template -void AutoSeededX917RNG::Reseed(const byte *key, size_t keylength, const byte *seed, const byte *timeVector) +void AutoSeededX917RNG::Reseed(const ::byte *key, size_t keylength, const ::byte *seed, const ::byte *timeVector) { m_rng.reset(new X917RNG(new typename BLOCK_CIPHER::Encryption(key, keylength), seed, timeVector)); } template -void AutoSeededX917RNG::Reseed(bool blocking, const byte *input, size_t length) +void AutoSeededX917RNG::Reseed(bool blocking, const ::byte *input, size_t length) { SecByteBlock seed(BLOCK_CIPHER::BLOCKSIZE + BLOCK_CIPHER::DEFAULT_KEYLENGTH); - const byte *key; + const ::byte *key; do { OS_GenerateRandomBlock(blocking, seed, seed.size()); diff --git a/panama.cpp b/panama.cpp index 7773d4a6..8dfc2cd9 100644 --- a/panama.cpp +++ b/panama.cpp @@ -324,14 +324,14 @@ void CRYPTOPP_NOINLINE Panama_SSE2_Pull(size_t count, word32 *state, word32 *z, #ifndef CRYPTOPP_GENERATE_X64_MASM template -void Panama::Iterate(size_t count, const word32 *p, byte *output, const byte *input, KeystreamOperation operation) +void Panama::Iterate(size_t count, const word32 *p, ::byte *output, const ::byte *input, KeystreamOperation operation) { CRYPTOPP_ASSERT(IsAlignedOn(m_state,GetAlignmentOf())); word32 bstart = m_state[17]; word32 *const aPtr = m_state; word32 cPtr[17]; -#define bPtr ((byte *)(aPtr+20)) +#define bPtr ((::byte *)(aPtr+20)) // reorder the state for SSE2 // a and c: 4 8 12 16 | 3 7 11 15 | 2 6 10 14 | 1 5 9 13 | 0 @@ -429,7 +429,7 @@ size_t PanamaHash::HashMultipleBlocks(const word32 *input, size_t length) } template -void PanamaHash::TruncatedFinal(byte *hash, size_t size) +void PanamaHash::TruncatedFinal(::byte *hash, size_t size) { this->ThrowIfInvalidTruncatedSize(size); @@ -449,7 +449,7 @@ void PanamaHash::TruncatedFinal(byte *hash, size_t size) } template -void PanamaCipherPolicy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) +void PanamaCipherPolicy::CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length) { CRYPTOPP_UNUSED(params); CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(length==32); @@ -457,7 +457,7 @@ void PanamaCipherPolicy::CipherSetKey(const NameValuePairs ¶ms, const byt } template -void PanamaCipherPolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length) +void PanamaCipherPolicy::CipherResynchronize(::byte *keystreamBuffer, const ::byte *iv, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer); CRYPTOPP_UNUSED(iv); CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(IsAlignedOn(iv,GetAlignmentOf())); @@ -497,7 +497,7 @@ unsigned int PanamaCipherPolicy::GetAlignment() const } template -void PanamaCipherPolicy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) +void PanamaCipherPolicy::OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount) { #if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM) if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2()) diff --git a/panama.h b/panama.h index 505de98a..5ba418aa 100644 --- a/panama.h +++ b/panama.h @@ -23,7 +23,7 @@ class CRYPTOPP_NO_VTABLE Panama { public: void Reset(); - void Iterate(size_t count, const word32 *p=NULLPTR, byte *output=NULLPTR, const byte *input=NULLPTR, KeystreamOperation operation=WRITE_KEYSTREAM); + void Iterate(size_t count, const word32 *p=NULLPTR, ::byte *output=NULLPTR, const ::byte *input=NULLPTR, KeystreamOperation operation=WRITE_KEYSTREAM); protected: typedef word32 Stage[8]; @@ -43,7 +43,7 @@ public: CRYPTOPP_CONSTANT(DIGESTSIZE = 32) PanamaHash() {Panama::Reset();} unsigned int DigestSize() const {return DIGESTSIZE;} - void TruncatedFinal(byte *hash, size_t size); + void TruncatedFinal(::byte *hash, size_t size); CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return B::ToEnum() == BIG_ENDIAN_ORDER ? "Panama-BE" : "Panama-LE";} protected: @@ -60,7 +60,7 @@ template class HermeticHashFunctionMAC : public AlgorithmImpl > >, T_Info> { public: - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { CRYPTOPP_UNUSED(params); @@ -74,14 +74,14 @@ public: m_keyed = false; } - void Update(const byte *input, size_t length) + void Update(const ::byte *input, size_t length) { if (!m_keyed) KeyHash(); m_hash.Update(input, length); } - void TruncatedFinal(byte *digest, size_t digestSize) + void TruncatedFinal(::byte *digest, size_t digestSize) { if (!m_keyed) KeyHash(); @@ -118,7 +118,7 @@ class PanamaMAC : public HermeticHashFunctionMAC > { public: PanamaMAC() {} - PanamaMAC(const byte *key, unsigned int length) + PanamaMAC(const ::byte *key, unsigned int length) {this->SetKey(key, length);} }; } @@ -139,10 +139,10 @@ class PanamaCipherPolicy : public AdditiveCipherConcretePolicy, protected Panama { protected: - void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); - void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); + void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length); + void OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount); bool CipherIsRandomAccess() const {return false;} - void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); + void CipherResynchronize(::byte *keystreamBuffer, const ::byte *iv, size_t length); unsigned int GetAlignment() const; FixedSizeSecBlock m_key; diff --git a/pkcspad.cpp b/pkcspad.cpp index 322a5a26..35463e3d 100644 --- a/pkcspad.cpp +++ b/pkcspad.cpp @@ -13,40 +13,40 @@ NAMESPACE_BEGIN(CryptoPP) // More in dll.cpp. Typedef/cast change due to Clang, http://github.com/weidai11/cryptopp/issues/300 -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x02,0x05,0x00,0x04,0x10}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x02,0x05,0x00,0x04,0x10}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x04,0x10}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00,0x04,0x10}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x24,0x03,0x02,0x01,0x05,0x00,0x04,0x14}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x24,0x03,0x02,0x01,0x05,0x00,0x04,0x14}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x29,0x30,0x0D,0x06,0x09,0x2B,0x06,0x01,0x04,0x01,0xDA,0x47,0x0C,0x02,0x05,0x00,0x04,0x18}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x29,0x30,0x0D,0x06,0x09,0x2B,0x06,0x01,0x04,0x01,0xDA,0x47,0x0C,0x02,0x05,0x00,0x04,0x18}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); // Inclusion based on DLL due to Clang, http://github.com/weidai11/cryptopp/issues/300 #ifndef CRYPTOPP_IS_DLL -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x2d,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,0x05,0x00,0x04,0x1c}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x2d,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,0x05,0x00,0x04,0x1c}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); -template<> const byte PKCS_DigestDecoration::decoration[] = {0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40}; +template<> const ::byte PKCS_DigestDecoration::decoration[] = {0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40}; template<> const unsigned int PKCS_DigestDecoration::length = (unsigned int)sizeof(PKCS_DigestDecoration::decoration); -template<> const byte EMSA2HashId::id = 0x33; -template<> const byte EMSA2HashId::id = 0x38; -template<> const byte EMSA2HashId::id = 0x34; -template<> const byte EMSA2HashId::id = 0x36; -template<> const byte EMSA2HashId::id = 0x35; +template<> const ::byte EMSA2HashId::id = 0x33; +template<> const ::byte EMSA2HashId::id = 0x38; +template<> const ::byte EMSA2HashId::id = 0x34; +template<> const ::byte EMSA2HashId::id = 0x36; +template<> const ::byte EMSA2HashId::id = 0x35; #endif size_t PKCS_EncryptionPaddingScheme::MaxUnpaddedLength(size_t paddedLength) const @@ -54,7 +54,7 @@ size_t PKCS_EncryptionPaddingScheme::MaxUnpaddedLength(size_t paddedLength) cons return SaturatingSubtract(paddedLength/8, 10U); } -void PKCS_EncryptionPaddingScheme::Pad(RandomNumberGenerator& rng, const byte *input, size_t inputLen, byte *pkcsBlock, size_t pkcsBlockLen, const NameValuePairs& parameters) const +void PKCS_EncryptionPaddingScheme::Pad(RandomNumberGenerator& rng, const ::byte *input, size_t inputLen, ::byte *pkcsBlock, size_t pkcsBlockLen, const NameValuePairs& parameters) const { CRYPTOPP_UNUSED(parameters); CRYPTOPP_ASSERT (inputLen <= MaxUnpaddedLength(pkcsBlockLen)); // this should be checked by caller @@ -71,13 +71,13 @@ void PKCS_EncryptionPaddingScheme::Pad(RandomNumberGenerator& rng, const byte *i // pad with non-zero random bytes for (unsigned i = 1; i < pkcsBlockLen-inputLen-1; i++) - pkcsBlock[i] = (byte)rng.GenerateWord32(1, 0xff); + pkcsBlock[i] = (::byte)rng.GenerateWord32(1, 0xff); pkcsBlock[pkcsBlockLen-inputLen-1] = 0; // separator memcpy(pkcsBlock+pkcsBlockLen-inputLen, input, inputLen); } -DecodingResult PKCS_EncryptionPaddingScheme::Unpad(const byte *pkcsBlock, size_t pkcsBlockLen, byte *output, const NameValuePairs& parameters) const +DecodingResult PKCS_EncryptionPaddingScheme::Unpad(const ::byte *pkcsBlock, size_t pkcsBlockLen, ::byte *output, const NameValuePairs& parameters) const { CRYPTOPP_UNUSED(parameters); bool invalid = false; @@ -115,9 +115,9 @@ DecodingResult PKCS_EncryptionPaddingScheme::Unpad(const byte *pkcsBlock, size_t #ifndef CRYPTOPP_IMPORTS void PKCS1v15_SignatureMessageEncodingMethod::ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const + ::byte *representative, size_t representativeBitLength) const { CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(recoverableMessageLength); CRYPTOPP_UNUSED(messageEmpty), CRYPTOPP_UNUSED(hashIdentifier); @@ -135,10 +135,10 @@ void PKCS1v15_SignatureMessageEncodingMethod::ComputeMessageRepresentative(Rando representative[0] = 1; // block type 1 unsigned int digestSize = hash.DigestSize(); - byte *pPadding = representative + 1; - byte *pDigest = representative + pkcsBlockLen - digestSize; - byte *pHashId = pDigest - hashIdentifier.second; - byte *pSeparator = pHashId - 1; + ::byte *pPadding = representative + 1; + ::byte *pDigest = representative + pkcsBlockLen - digestSize; + ::byte *pHashId = pDigest - hashIdentifier.second; + ::byte *pSeparator = pHashId - 1; // pad with 0xff memset(pPadding, 0xff, pSeparator-pPadding); diff --git a/pkcspad.h b/pkcspad.h index b75bce6a..ea2a02ad 100644 --- a/pkcspad.h +++ b/pkcspad.h @@ -25,8 +25,8 @@ public: CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "EME-PKCS1-v1_5";} size_t MaxUnpaddedLength(size_t paddedLength) const; - void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const; - DecodingResult Unpad(const byte *padded, size_t paddedLength, byte *raw, const NameValuePairs ¶meters) const; + void Pad(RandomNumberGenerator &rng, const ::byte *raw, size_t inputLength, ::byte *padded, size_t paddedLength, const NameValuePairs ¶meters) const; + DecodingResult Unpad(const ::byte *padded, size_t paddedLength, ::byte *raw, const NameValuePairs ¶meters) const; }; //! \class PKCS_DigestDecoration @@ -34,7 +34,7 @@ public: template class PKCS_DigestDecoration { public: - static const byte decoration[]; + static const ::byte decoration[]; static const unsigned int length; }; @@ -73,9 +73,9 @@ public: {return 8 * (digestSize + hashIdentifierSize + 10);} void ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const; + ::byte *representative, size_t representativeBitLength) const; struct HashIdentifierLookup { diff --git a/poly1305.cpp b/poly1305.cpp index f580fc42..44041933 100644 --- a/poly1305.cpp +++ b/poly1305.cpp @@ -12,7 +12,7 @@ NAMESPACE_BEGIN(CryptoPP) #define CONSTANT_TIME_CARRY(a,b) ((a ^ ((a ^ b) | ((a - b) ^ b))) >> (sizeof(a) * 8 - 1)) template -void Poly1305_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) +void Poly1305_Base::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { if (key && length) { @@ -48,7 +48,7 @@ void Poly1305_Base::UncheckedSetKey(const byte *key, unsigned int length, con } template -void Poly1305_Base::Update(const byte *input, size_t length) +void Poly1305_Base::Update(const ::byte *input, size_t length) { CRYPTOPP_ASSERT((input && length) || !length); if (!length) return; @@ -89,7 +89,7 @@ void Poly1305_Base::Update(const byte *input, size_t length) } template -void Poly1305_Base::HashBlocks(const byte *input, size_t length, word32 padbit) +void Poly1305_Base::HashBlocks(const ::byte *input, size_t length, word32 padbit) { word32 r0, r1, r2, r3; word32 s1, s2, s3; @@ -162,7 +162,7 @@ void Poly1305_Base::HashBlocks(const byte *input, size_t length, word32 padbi } template -void Poly1305_Base::TruncatedFinal(byte *mac, size_t size) +void Poly1305_Base::TruncatedFinal(::byte *mac, size_t size) { CRYPTOPP_ASSERT(mac); // Pointer is valid CRYPTOPP_ASSERT(!m_used); // Nonce is fresh @@ -186,7 +186,7 @@ void Poly1305_Base::TruncatedFinal(byte *mac, size_t size) } template -void Poly1305_Base::HashFinal(byte *mac, size_t size) +void Poly1305_Base::HashFinal(::byte *mac, size_t size) { word32 h0, h1, h2, h3, h4; word32 g0, g1, g2, g3, g4; @@ -229,7 +229,7 @@ void Poly1305_Base::HashFinal(byte *mac, size_t size) } else { - FixedSizeAlignedSecBlock m; + FixedSizeAlignedSecBlock< ::byte, BLOCKSIZE> m; PutWord(false, LITTLE_ENDIAN_ORDER, m + 0, h0); PutWord(false, LITTLE_ENDIAN_ORDER, m + 4, h1); PutWord(false, LITTLE_ENDIAN_ORDER, m + 8, h2); @@ -239,7 +239,7 @@ void Poly1305_Base::HashFinal(byte *mac, size_t size) } template -void Poly1305_Base::Resynchronize(const byte *nonce, int nonceLength) +void Poly1305_Base::Resynchronize(const ::byte *nonce, int nonceLength) { CRYPTOPP_ASSERT(nonceLength == -1 || nonceLength == (int)BLOCKSIZE); nonceLength == -1 ? nonceLength = BLOCKSIZE : nonceLength; @@ -247,7 +247,7 @@ void Poly1305_Base::Resynchronize(const byte *nonce, int nonceLength) } template -void Poly1305_Base::GetNextIV(RandomNumberGenerator &rng, byte *iv) +void Poly1305_Base::GetNextIV(RandomNumberGenerator &rng, ::byte *iv) { rng.GenerateBlock(iv, BLOCKSIZE); } diff --git a/poly1305.h b/poly1305.h index 2e70dcf3..9099d827 100644 --- a/poly1305.h +++ b/poly1305.h @@ -70,20 +70,20 @@ public: Poly1305_Base() : m_idx(0), m_used(true) {} - void Resynchronize (const byte *iv, int ivLength=-1); - void GetNextIV (RandomNumberGenerator &rng, byte *iv); + void Resynchronize (const ::byte *iv, int ivLength=-1); + void GetNextIV (RandomNumberGenerator &rng, ::byte *iv); - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); - void Update(const byte *input, size_t length); - void TruncatedFinal(byte *mac, size_t size); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); + void Update(const ::byte *input, size_t length); + void TruncatedFinal(::byte *mac, size_t size); void Restart(); unsigned int BlockSize() const {return BLOCKSIZE;} unsigned int DigestSize() const {return DIGESTSIZE;} protected: - void HashBlocks(const byte *input, size_t length, word32 padbit); - void HashFinal(byte *mac, size_t length); + void HashBlocks(const ::byte *input, size_t length, word32 padbit); + void HashFinal(::byte *mac, size_t length); typename T::Encryption m_cipher; @@ -93,7 +93,7 @@ protected: FixedSizeAlignedSecBlock m_n; // Accumulated message bytes and index - FixedSizeAlignedSecBlock m_acc; + FixedSizeAlignedSecBlock< ::byte, BLOCKSIZE> m_acc; size_t m_idx; // Track nonce reuse; assert in debug but continue @@ -160,7 +160,7 @@ public: //! bytes used for r. //! \details Each message requires a unique security context. You can use GetNextIV() and //! Resynchronize() to set a new nonce under a key for a message. - Poly1305(const byte *key, size_t keyLength=DEFAULT_KEYLENGTH, const byte *nonce=NULLPTR, size_t nonceLength=0) + Poly1305(const ::byte *key, size_t keyLength=DEFAULT_KEYLENGTH, const ::byte *nonce=NULLPTR, size_t nonceLength=0) {this->SetKey(key, keyLength, MakeParameters(Name::IV(), ConstByteArrayParameter(nonce, nonceLength)));} }; diff --git a/polynomi.h b/polynomi.h index 2b904204..4a6a098c 100644 --- a/polynomi.h +++ b/polynomi.h @@ -76,10 +76,10 @@ public: PolynomialOver(const char *str, const Ring &ring) {FromStr(str, ring);} //! convert from big-endian byte array - PolynomialOver(const byte *encodedPolynomialOver, unsigned int byteCount); + PolynomialOver(const ::byte *encodedPolynomialOver, unsigned int byteCount); //! convert from Basic Encoding Rules encoded byte array - explicit PolynomialOver(const byte *BEREncodedPolynomialOver); + explicit PolynomialOver(const ::byte *BEREncodedPolynomialOver); //! convert from BER encoded byte array stored in a BufferedTransformation object explicit PolynomialOver(BufferedTransformation &bt); @@ -196,10 +196,10 @@ public: explicit PolynomialOverFixedRing(const char *str) : B(str, ms_fixedRing) {} //! convert from big-endian byte array - PolynomialOverFixedRing(const byte *encodedPoly, unsigned int byteCount) : B(encodedPoly, byteCount) {} + PolynomialOverFixedRing(const ::byte *encodedPoly, unsigned int byteCount) : B(encodedPoly, byteCount) {} //! convert from Basic Encoding Rules encoded byte array - explicit PolynomialOverFixedRing(const byte *BEREncodedPoly) : B(BEREncodedPoly) {} + explicit PolynomialOverFixedRing(const ::byte *BEREncodedPoly) : B(BEREncodedPoly) {} //! convert from BER encoded byte array stored in a BufferedTransformation object explicit PolynomialOverFixedRing(BufferedTransformation &bt) : B(bt) {} diff --git a/pssr.cpp b/pssr.cpp index 914b921f..6a338ecb 100644 --- a/pssr.cpp +++ b/pssr.cpp @@ -9,9 +9,9 @@ NAMESPACE_BEGIN(CryptoPP) // more in dll.cpp -template<> const byte EMSA2HashId::id = 0x31; -template<> const byte EMSA2HashId::id = 0x32; -template<> const byte EMSA2HashId::id = 0x37; +template<> const ::byte EMSA2HashId::id = 0x31; +template<> const ::byte EMSA2HashId::id = 0x32; +template<> const ::byte EMSA2HashId::id = 0x37; #ifndef CRYPTOPP_IMPORTS @@ -45,9 +45,9 @@ bool PSSR_MEM_Base::RecoverablePartFirst() const } void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const + ::byte *representative, size_t representativeBitLength) const { CRYPTOPP_UNUSED(rng), CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(recoverableMessageLength); CRYPTOPP_UNUSED(messageEmpty), CRYPTOPP_UNUSED(hashIdentifier); @@ -57,14 +57,14 @@ void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng, const size_t representativeByteLength = BitsToBytes(representativeBitLength); const size_t digestSize = hash.DigestSize(); const size_t saltSize = SaltLen(digestSize); - byte *const h = representative + representativeByteLength - u - digestSize; + ::byte *const h = representative + representativeByteLength - u - digestSize; SecByteBlock digest(digestSize), salt(saltSize); hash.Final(digest); rng.GenerateBlock(salt, saltSize); // compute H = hash of M' - byte c[8]; + ::byte c[8]; PutWord(false, BIG_ENDIAN_ORDER, c, (word32)SafeRightShift<29>(recoverableMessageLength)); PutWord(false, BIG_ENDIAN_ORDER, c+4, word32(recoverableMessageLength << 3)); hash.Update(c, 8); @@ -75,7 +75,7 @@ void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng, // compute representative GetMGF().GenerateAndMask(hash, representative, representativeByteLength - u - digestSize, h, digestSize, false); - byte *xorStart = representative + representativeByteLength - u - digestSize - salt.size() - recoverableMessageLength - 1; + ::byte *xorStart = representative + representativeByteLength - u - digestSize - salt.size() - recoverableMessageLength - 1; xorStart[0] ^= 1; if (recoverableMessage && recoverableMessageLength) xorbuf(xorStart + 1, recoverableMessage, recoverableMessageLength); @@ -90,13 +90,13 @@ void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng, representative[representativeByteLength - 1] = 0xbc; } if (representativeBitLength % 8 != 0) - representative[0] = (byte)Crop(representative[0], representativeBitLength % 8); + representative[0] = (::byte)Crop(representative[0], representativeBitLength % 8); } DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative( HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength, - byte *recoverableMessage) const + ::byte *representative, size_t representativeBitLength, + ::byte *recoverableMessage) const { CRYPTOPP_UNUSED(recoverableMessage), CRYPTOPP_UNUSED(messageEmpty), CRYPTOPP_UNUSED(hashIdentifier); CRYPTOPP_ASSERT(representativeBitLength >= MinRepresentativeBitLength(hashIdentifier.second, hash.DigestSize())); @@ -105,7 +105,7 @@ DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative( const size_t representativeByteLength = BitsToBytes(representativeBitLength); const size_t digestSize = hash.DigestSize(); const size_t saltSize = SaltLen(digestSize); - const byte *const h = representative + representativeByteLength - u - digestSize; + const ::byte *const h = representative + representativeByteLength - u - digestSize; SecByteBlock digest(digestSize); hash.Final(digest); @@ -121,11 +121,11 @@ DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative( GetMGF().GenerateAndMask(hash, representative, representativeByteLength - u - digestSize, h, digestSize); if (representativeBitLength % 8 != 0) - representative[0] = (byte)Crop(representative[0], representativeBitLength % 8); + representative[0] = (::byte)Crop(representative[0], representativeBitLength % 8); // extract salt and recoverableMessage from DB = 00 ... || 01 || M || salt - byte *salt = representative + representativeByteLength - u - digestSize - saltSize; - byte *M = std::find_if(representative, salt-1, std::bind2nd(std::not_equal_to(), byte(0))); + ::byte *salt = representative + representativeByteLength - u - digestSize - saltSize; + ::byte *M = std::find_if(representative, salt-1, std::bind2nd(std::not_equal_to< ::byte>(), ::byte(0))); recoverableMessageLength = salt-M-1; if (*M == 0x01 && (size_t)(M - representative - (representativeBitLength % 8 != 0)) >= MinPadLen(digestSize) && @@ -141,7 +141,7 @@ DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative( } // verify H = hash of M' - byte c[8]; + ::byte c[8]; PutWord(false, BIG_ENDIAN_ORDER, c, (word32)SafeRightShift<29>(recoverableMessageLength)); PutWord(false, BIG_ENDIAN_ORDER, c+4, word32(recoverableMessageLength << 3)); hash.Update(c, 8); diff --git a/pssr.h b/pssr.h index a66667c9..cbe628c7 100644 --- a/pssr.h +++ b/pssr.h @@ -35,13 +35,13 @@ private: bool AllowNonrecoverablePart() const; bool RecoverablePartFirst() const; void ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const; + ::byte *representative, size_t representativeBitLength) const; DecodingResult RecoverMessageFromRepresentative( HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength, - byte *recoverableMessage) const; + ::byte *representative, size_t representativeBitLength, + ::byte *recoverableMessage) const; }; //! \brief PSSR Message Encoding Method with Hash Identifier diff --git a/pubkey.cpp b/pubkey.cpp index 3a600906..ae21cf3c 100644 --- a/pubkey.cpp +++ b/pubkey.cpp @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(CryptoPP) -void P1363_MGF1KDF2_Common(HashTransformation &hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, const byte *derivationParams, size_t derivationParamsLength, bool mask, unsigned int counterStart) +void P1363_MGF1KDF2_Common(HashTransformation &hash, ::byte *output, size_t outputLength, const ::byte *input, size_t inputLength, const ::byte *derivationParams, size_t derivationParamsLength, bool mask, unsigned int counterStart) { ArraySink *sink; HashFilter filter(hash, sink = mask ? new ArrayXorSink(output, outputLength) : new ArraySink(output, outputLength)); @@ -27,7 +27,7 @@ void P1363_MGF1KDF2_Common(HashTransformation &hash, byte *output, size_t output bool PK_DeterministicSignatureMessageEncodingMethod::VerifyMessageRepresentative( HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const + ::byte *representative, size_t representativeBitLength) const { SecByteBlock computedRepresentative(BitsToBytes(representativeBitLength)); ComputeMessageRepresentative(NullRNG(), NULLPTR, 0, hash, hashIdentifier, messageEmpty, computedRepresentative, representativeBitLength); @@ -36,7 +36,7 @@ bool PK_DeterministicSignatureMessageEncodingMethod::VerifyMessageRepresentative bool PK_RecoverableSignatureMessageEncodingMethod::VerifyMessageRepresentative( HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const + ::byte *representative, size_t representativeBitLength) const { SecByteBlock recoveredMessage(MaxRecoverableLength(representativeBitLength, hashIdentifier.second, hash.DigestSize())); DecodingResult result = RecoverMessageFromRepresentative( @@ -44,7 +44,7 @@ bool PK_RecoverableSignatureMessageEncodingMethod::VerifyMessageRepresentative( return result.isValidCoding && result.messageLength == 0; } -void TF_SignerBase::InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const +void TF_SignerBase::InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const ::byte *recoverableMessage, size_t recoverableMessageLength) const { PK_MessageAccumulatorBase &ma = static_cast(messageAccumulator); HashIdentifier id = GetHashIdentifier(); @@ -67,7 +67,7 @@ void TF_SignerBase::InputRecoverableMessage(PK_MessageAccumulator &messageAccumu NULLPTR, 0, ma.m_semisignature); } -size_t TF_SignerBase::SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart) const +size_t TF_SignerBase::SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, ::byte *signature, bool restart) const { CRYPTOPP_UNUSED(restart); @@ -91,7 +91,7 @@ size_t TF_SignerBase::SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccum return signatureLength; } -void TF_VerifierBase::InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const +void TF_VerifierBase::InputSignature(PK_MessageAccumulator &messageAccumulator, const ::byte *signature, size_t signatureLength) const { PK_MessageAccumulatorBase &ma = static_cast(messageAccumulator); HashIdentifier id = GetHashIdentifier(); @@ -122,7 +122,7 @@ bool TF_VerifierBase::VerifyAndRestart(PK_MessageAccumulator &messageAccumulator return result; } -DecodingResult TF_VerifierBase::RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const +DecodingResult TF_VerifierBase::RecoverAndRestart(::byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const { PK_MessageAccumulatorBase &ma = static_cast(messageAccumulator); HashIdentifier id = GetHashIdentifier(); @@ -137,7 +137,7 @@ DecodingResult TF_VerifierBase::RecoverAndRestart(byte *recoveredMessage, PK_Mes return result; } -DecodingResult TF_DecryptorBase::Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters) const +DecodingResult TF_DecryptorBase::Decrypt(RandomNumberGenerator &rng, const ::byte *ciphertext, size_t ciphertextLength, ::byte *plaintext, const NameValuePairs ¶meters) const { if (ciphertextLength != FixedCiphertextLength()) throw InvalidArgument(AlgorithmName() + ": ciphertext length of " + IntToString(ciphertextLength) + " doesn't match the required length of " + IntToString(FixedCiphertextLength()) + " for this key"); @@ -150,7 +150,7 @@ DecodingResult TF_DecryptorBase::Decrypt(RandomNumberGenerator &rng, const byte return GetMessageEncodingInterface().Unpad(paddedBlock, PaddedBlockBitLength(), plaintext, parameters); } -void TF_EncryptorBase::Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters) const +void TF_EncryptorBase::Encrypt(RandomNumberGenerator &rng, const ::byte *plaintext, size_t plaintextLength, ::byte *ciphertext, const NameValuePairs ¶meters) const { if (plaintextLength > FixedMaxPlaintextLength()) { diff --git a/pubkey.h b/pubkey.h index 888ad3e6..21ef1f57 100644 --- a/pubkey.h +++ b/pubkey.h @@ -222,9 +222,9 @@ public: //! max size of unpadded message in bytes, given max size of padded message in bits (1 less than size of modulus) virtual size_t MaxUnpaddedLength(size_t paddedLength) const =0; - virtual void Pad(RandomNumberGenerator &rng, const byte *raw, size_t inputLength, byte *padded, size_t paddedBitLength, const NameValuePairs ¶meters) const =0; + virtual void Pad(RandomNumberGenerator &rng, const ::byte *raw, size_t inputLength, ::byte *padded, size_t paddedBitLength, const NameValuePairs ¶meters) const =0; - virtual DecodingResult Unpad(const byte *padded, size_t paddedBitLength, byte *raw, const NameValuePairs ¶meters) const =0; + virtual DecodingResult Unpad(const ::byte *padded, size_t paddedBitLength, ::byte *raw, const NameValuePairs ¶meters) const =0; }; // ******************************************************** @@ -295,7 +295,7 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE TF_DecryptorBase : public TF_CryptoSystemB public: virtual ~TF_DecryptorBase() {} - DecodingResult Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const; + DecodingResult Decrypt(RandomNumberGenerator &rng, const ::byte *ciphertext, size_t ciphertextLength, ::byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const; }; //! \class TF_DecryptorBase @@ -305,13 +305,13 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE TF_EncryptorBase : public TF_CryptoSystemB public: virtual ~TF_EncryptorBase() {} - void Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters = g_nullNameValuePairs) const; + void Encrypt(RandomNumberGenerator &rng, const ::byte *plaintext, size_t plaintextLength, ::byte *ciphertext, const NameValuePairs ¶meters = g_nullNameValuePairs) const; }; // ******************************************************** // Typedef change due to Clang, http://github.com/weidai11/cryptopp/issues/300 -typedef std::pair HashIdentifier; +typedef std::pair HashIdentifier; //! \class PK_SignatureMessageEncodingMethod //! \brief Interface for message encoding method for public key signature schemes. @@ -343,13 +343,13 @@ public: {throw NotImplemented("PK_MessageEncodingMethod: this signature scheme does not support message recovery");} // for verification, DL - virtual void ProcessSemisignature(HashTransformation &hash, const byte *semisignature, size_t semisignatureLength) const + virtual void ProcessSemisignature(HashTransformation &hash, const ::byte *semisignature, size_t semisignatureLength) const {CRYPTOPP_UNUSED(hash); CRYPTOPP_UNUSED(semisignature); CRYPTOPP_UNUSED(semisignatureLength);} // for signature virtual void ProcessRecoverableMessage(HashTransformation &hash, - const byte *recoverableMessage, size_t recoverableMessageLength, - const byte *presignature, size_t presignatureLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *presignature, size_t presignatureLength, SecByteBlock &semisignature) const { CRYPTOPP_UNUSED(hash);CRYPTOPP_UNUSED(recoverableMessage); CRYPTOPP_UNUSED(recoverableMessageLength); @@ -359,27 +359,27 @@ public: } virtual void ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const =0; + ::byte *representative, size_t representativeBitLength) const =0; virtual bool VerifyMessageRepresentative( HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const =0; + ::byte *representative, size_t representativeBitLength) const =0; virtual DecodingResult RecoverMessageFromRepresentative( // for TF HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength, - byte *recoveredMessage) const + ::byte *representative, size_t representativeBitLength, + ::byte *recoveredMessage) const {CRYPTOPP_UNUSED(hash);CRYPTOPP_UNUSED(hashIdentifier); CRYPTOPP_UNUSED(messageEmpty); CRYPTOPP_UNUSED(representative); CRYPTOPP_UNUSED(representativeBitLength); CRYPTOPP_UNUSED(recoveredMessage); throw NotImplemented("PK_MessageEncodingMethod: this signature scheme does not support message recovery");} virtual DecodingResult RecoverMessageFromSemisignature( // for DL HashTransformation &hash, HashIdentifier hashIdentifier, - const byte *presignature, size_t presignatureLength, - const byte *semisignature, size_t semisignatureLength, - byte *recoveredMessage) const + const ::byte *presignature, size_t presignatureLength, + const ::byte *semisignature, size_t semisignatureLength, + ::byte *recoveredMessage) const {CRYPTOPP_UNUSED(hash);CRYPTOPP_UNUSED(hashIdentifier); CRYPTOPP_UNUSED(presignature); CRYPTOPP_UNUSED(presignatureLength); CRYPTOPP_UNUSED(semisignature); CRYPTOPP_UNUSED(semisignatureLength); CRYPTOPP_UNUSED(recoveredMessage); throw NotImplemented("PK_MessageEncodingMethod: this signature scheme does not support message recovery");} @@ -391,7 +391,7 @@ public: { static HashIdentifier CRYPTOPP_API Lookup() { - return HashIdentifier((const byte *)NULLPTR, 0); + return HashIdentifier((const ::byte *)NULLPTR, 0); } }; }; @@ -406,7 +406,7 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_DeterministicSignatureMessageEncodingMe public: bool VerifyMessageRepresentative( HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const; + ::byte *representative, size_t representativeBitLength) const; }; //! \class PK_RecoverableSignatureMessageEncodingMethod @@ -418,7 +418,7 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_RecoverableSignatureMessageEncodingMeth public: bool VerifyMessageRepresentative( HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const; + ::byte *representative, size_t representativeBitLength) const; }; //! \class DL_SignatureMessageEncodingMethod_DSA @@ -429,9 +429,9 @@ class CRYPTOPP_DLL DL_SignatureMessageEncodingMethod_DSA : public PK_Determinist { public: void ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const; + ::byte *representative, size_t representativeBitLength) const; }; //! \class DL_SignatureMessageEncodingMethod_NR @@ -442,9 +442,9 @@ class CRYPTOPP_DLL DL_SignatureMessageEncodingMethod_NR : public PK_Deterministi { public: void ComputeMessageRepresentative(RandomNumberGenerator &rng, - const byte *recoverableMessage, size_t recoverableMessageLength, + const ::byte *recoverableMessage, size_t recoverableMessageLength, HashTransformation &hash, HashIdentifier hashIdentifier, bool messageEmpty, - byte *representative, size_t representativeBitLength) const; + ::byte *representative, size_t representativeBitLength) const; }; //! \class PK_MessageAccumulatorBase @@ -458,7 +458,7 @@ public: virtual HashTransformation & AccessHash() =0; - void Update(const byte *input, size_t length) + void Update(const ::byte *input, size_t length) { AccessHash().Update(input, length); m_empty = m_empty && length == 0; @@ -515,8 +515,8 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE TF_SignerBase : public TF_SignatureSchemeB public: virtual ~TF_SignerBase() {} - void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const; - size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart=true) const; + void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const ::byte *recoverableMessage, size_t recoverableMessageLength) const; + size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, ::byte *signature, bool restart=true) const; }; //! _ @@ -525,9 +525,9 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE TF_VerifierBase : public TF_SignatureSchem public: virtual ~TF_VerifierBase() {} - void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const; + void InputSignature(PK_MessageAccumulator &messageAccumulator, const ::byte *signature, size_t signatureLength) const; bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const; - DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &recoveryAccumulator) const; + DecodingResult RecoverAndRestart(::byte *recoveredMessage, PK_MessageAccumulator &recoveryAccumulator) const; }; // ******************************************************** @@ -675,7 +675,7 @@ public: //! \param input the message to hash //! \param inputLength the size of the message //! \param mask flag indicating whether to apply the mask - virtual void GenerateAndMask(HashTransformation &hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, bool mask = true) const =0; + virtual void GenerateAndMask(HashTransformation &hash, ::byte *output, size_t outputLength, const ::byte *input, size_t inputLength, bool mask = true) const =0; }; //! \fn P1363_MGF1KDF2_Common @@ -689,7 +689,7 @@ public: //! \param derivationParamsLength the size of the additional derivation parameters //! \param mask flag indicating whether to apply the mask //! \param counterStart starting counter value used in generation function -CRYPTOPP_DLL void CRYPTOPP_API P1363_MGF1KDF2_Common(HashTransformation &hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, const byte *derivationParams, size_t derivationParamsLength, bool mask, unsigned int counterStart); +CRYPTOPP_DLL void CRYPTOPP_API P1363_MGF1KDF2_Common(HashTransformation &hash, ::byte *output, size_t outputLength, const ::byte *input, size_t inputLength, const ::byte *derivationParams, size_t derivationParamsLength, bool mask, unsigned int counterStart); //! \class P1363_MGF1 //! \brief P1363 mask generation function @@ -697,7 +697,7 @@ class P1363_MGF1 : public MaskGeneratingFunction { public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "MGF1";} - void GenerateAndMask(HashTransformation &hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, bool mask = true) const + void GenerateAndMask(HashTransformation &hash, ::byte *output, size_t outputLength, const ::byte *input, size_t inputLength, bool mask = true) const { P1363_MGF1KDF2_Common(hash, output, outputLength, input, inputLength, NULLPTR, 0, mask, 0); } @@ -712,7 +712,7 @@ template class P1363_KDF2 { public: - static void CRYPTOPP_API DeriveKey(byte *output, size_t outputLength, const byte *input, size_t inputLength, const byte *derivationParams, size_t derivationParamsLength) + static void CRYPTOPP_API DeriveKey(::byte *output, size_t outputLength, const ::byte *input, size_t inputLength, const ::byte *derivationParams, size_t derivationParamsLength) { H h; P1363_MGF1KDF2_Common(h, output, outputLength, input, inputLength, derivationParams, derivationParamsLength, false, 1); @@ -861,7 +861,7 @@ public: //! \param encoded destination byte array for the encoded element //! \details EncodeElement() must be implemented in a derived class. //! \pre COUNTOF(encoded) == GetEncodedElementSize() - virtual void EncodeElement(bool reversible, const Element &element, byte *encoded) const =0; + virtual void EncodeElement(bool reversible, const Element &element, ::byte *encoded) const =0; //! \brief Decodes the element //! \param encoded byte array with the encoded element @@ -869,7 +869,7 @@ public: //! \return Element after decoding //! \details DecodeElement() must be implemented in a derived class. //! \pre COUNTOF(encoded) == GetEncodedElementSize() - virtual Element DecodeElement(const byte *encoded, bool checkForGroupMembership) const =0; + virtual Element DecodeElement(const ::byte *encoded, bool checkForGroupMembership) const =0; //! \brief Converts an element to an Integer //! \param element the element to convert to an Integer @@ -1308,7 +1308,7 @@ public: virtual bool ParameterSupported(const char *name) const {CRYPTOPP_UNUSED(name); return false;} - virtual void Derive(const DL_GroupParameters &groupParams, byte *derivedKey, size_t derivedLength, const T &agreedElement, const T &ephemeralPublicKey, const NameValuePairs &derivationParams) const =0; + virtual void Derive(const DL_GroupParameters &groupParams, ::byte *derivedKey, size_t derivedLength, const T &agreedElement, const T &ephemeralPublicKey, const NameValuePairs &derivationParams) const =0; }; //! \brief Interface for symmetric encryption algorithms used in DL cryptosystems @@ -1322,8 +1322,8 @@ public: virtual size_t GetSymmetricKeyLength(size_t plaintextLength) const =0; virtual size_t GetSymmetricCiphertextLength(size_t plaintextLength) const =0; virtual size_t GetMaxSymmetricPlaintextLength(size_t ciphertextLength) const =0; - virtual void SymmetricEncrypt(RandomNumberGenerator &rng, const byte *key, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters) const =0; - virtual DecodingResult SymmetricDecrypt(const byte *key, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters) const =0; + virtual void SymmetricEncrypt(RandomNumberGenerator &rng, const ::byte *key, const ::byte *plaintext, size_t plaintextLength, ::byte *ciphertext, const NameValuePairs ¶meters) const =0; + virtual DecodingResult SymmetricDecrypt(const ::byte *key, const ::byte *ciphertext, size_t ciphertextLength, ::byte *plaintext, const NameValuePairs ¶meters) const =0; }; //! \brief Discrete Log (DL) base interface @@ -1427,7 +1427,7 @@ public: alg.Sign(params, key.GetPrivateExponent(), k, e, r, s); } - void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const + void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const ::byte *recoverableMessage, size_t recoverableMessageLength) const { PK_MessageAccumulatorBase &ma = static_cast(messageAccumulator); ma.m_recoverableMessage.Assign(recoverableMessage, recoverableMessageLength); @@ -1437,7 +1437,7 @@ public: ma.m_semisignature); } - size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart) const + size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, ::byte *signature, bool restart) const { this->GetMaterial().DoQuickSanityCheck(); @@ -1521,7 +1521,7 @@ class CRYPTOPP_NO_VTABLE DL_VerifierBase : public DL_SignatureSchemeBase(messageAccumulator); @@ -1555,7 +1555,7 @@ public: return alg.Verify(params, key, e, r, ma.m_s); } - DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const + DecodingResult RecoverAndRestart(::byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const { this->GetMaterial().DoQuickSanityCheck(); @@ -1627,7 +1627,7 @@ public: virtual ~DL_DecryptorBase() {} - DecodingResult Decrypt(RandomNumberGenerator &rng, const byte *ciphertext, size_t ciphertextLength, byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const + DecodingResult Decrypt(RandomNumberGenerator &rng, const ::byte *ciphertext, size_t ciphertextLength, ::byte *plaintext, const NameValuePairs ¶meters = g_nullNameValuePairs) const { try { @@ -1667,7 +1667,7 @@ public: virtual ~DL_EncryptorBase() {} - void Encrypt(RandomNumberGenerator &rng, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters = g_nullNameValuePairs) const + void Encrypt(RandomNumberGenerator &rng, const ::byte *plaintext, size_t plaintextLength, ::byte *ciphertext, const NameValuePairs ¶meters = g_nullNameValuePairs) const { const DL_KeyAgreementAlgorithm &agreeAlg = this->GetKeyAgreementAlgorithm(); const DL_KeyDerivationAlgorithm &derivAlg = this->GetKeyDerivationAlgorithm(); @@ -1864,13 +1864,13 @@ public: unsigned int PrivateKeyLength() const {return GetAbstractGroupParameters().GetSubgroupOrder().ByteCount();} unsigned int PublicKeyLength() const {return GetAbstractGroupParameters().GetEncodedElementSize(true);} - void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const + void GeneratePrivateKey(RandomNumberGenerator &rng, ::byte *privateKey) const { Integer x(rng, Integer::One(), GetAbstractGroupParameters().GetMaxExponent()); x.Encode(privateKey, PrivateKeyLength()); } - void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const + void GeneratePublicKey(RandomNumberGenerator &rng, const ::byte *privateKey, ::byte *publicKey) const { CRYPTOPP_UNUSED(rng); const DL_GroupParameters ¶ms = GetAbstractGroupParameters(); @@ -1879,7 +1879,7 @@ public: params.EncodeElement(true, y, publicKey); } - bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const + bool Agree(::byte *agreedValue, const ::byte *privateKey, const ::byte *otherPublicKey, bool validateOtherPublicKey=true) const { try { diff --git a/pwdbased.h b/pwdbased.h index 1bb323d6..f59282f5 100644 --- a/pwdbased.h +++ b/pwdbased.h @@ -41,7 +41,7 @@ public: //! \details DeriveKey returns the actual iteration count achieved. If timeInSeconds == 0, then the complete number //! of iterations will be obtained. If timeInSeconds != 0, then DeriveKey will iterate until time elapsed, as //! measured by ThreadUserTimer. - virtual unsigned int DeriveKey(byte *derived, size_t derivedLen, byte purpose, const byte *password, size_t passwordLen, const byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds=0) const =0; + virtual unsigned int DeriveKey(::byte *derived, size_t derivedLen, ::byte purpose, const ::byte *password, size_t passwordLen, const ::byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds=0) const =0; }; //! \brief PBKDF1 from PKCS #5 @@ -53,7 +53,7 @@ public: size_t MaxDerivedKeyLength() const {return T::DIGESTSIZE;} bool UsesPurposeByte() const {return false;} // PKCS #5 says PBKDF1 should only take 8-byte salts. This implementation allows salts of any length. - unsigned int DeriveKey(byte *derived, size_t derivedLen, byte purpose, const byte *password, size_t passwordLen, const byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds=0) const; + unsigned int DeriveKey(::byte *derived, size_t derivedLen, ::byte purpose, const ::byte *password, size_t passwordLen, const ::byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds=0) const; }; //! \brief PBKDF2 from PKCS #5 @@ -64,7 +64,7 @@ class PKCS5_PBKDF2_HMAC : public PasswordBasedKeyDerivationFunction public: size_t MaxDerivedKeyLength() const {return 0xffffffffU;} // should multiply by T::DIGESTSIZE, but gets overflow that way bool UsesPurposeByte() const {return false;} - unsigned int DeriveKey(byte *derived, size_t derivedLen, byte purpose, const byte *password, size_t passwordLen, const byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds=0) const; + unsigned int DeriveKey(::byte *derived, size_t derivedLen, ::byte purpose, const ::byte *password, size_t passwordLen, const ::byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds=0) const; }; /* @@ -78,7 +78,7 @@ public: */ template -unsigned int PKCS5_PBKDF1::DeriveKey(byte *derived, size_t derivedLen, byte purpose, const byte *password, size_t passwordLen, const byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds) const +unsigned int PKCS5_PBKDF1::DeriveKey(::byte *derived, size_t derivedLen, ::byte purpose, const ::byte *password, size_t passwordLen, const ::byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds) const { CRYPTOPP_UNUSED(purpose); CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength()); @@ -108,7 +108,7 @@ unsigned int PKCS5_PBKDF1::DeriveKey(byte *derived, size_t derivedLen, byte p } template -unsigned int PKCS5_PBKDF2_HMAC::DeriveKey(byte *derived, size_t derivedLen, byte purpose, const byte *password, size_t passwordLen, const byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds) const +unsigned int PKCS5_PBKDF2_HMAC::DeriveKey(::byte *derived, size_t derivedLen, ::byte purpose, const ::byte *password, size_t passwordLen, const ::byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds) const { CRYPTOPP_UNUSED(purpose); CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength()); @@ -128,7 +128,7 @@ unsigned int PKCS5_PBKDF2_HMAC::DeriveKey(byte *derived, size_t derivedLen, b unsigned int j; for (j=0; j<4; j++) { - byte b = byte(i >> ((3-j)*8)); + ::byte b = ::byte(i >> ((3-j)*8)); hmac.Update(&b, 1); } hmac.Final(buffer); @@ -175,11 +175,11 @@ class PKCS12_PBKDF : public PasswordBasedKeyDerivationFunction public: size_t MaxDerivedKeyLength() const {return size_t(0)-1;} bool UsesPurposeByte() const {return true;} - unsigned int DeriveKey(byte *derived, size_t derivedLen, byte purpose, const byte *password, size_t passwordLen, const byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds) const; + unsigned int DeriveKey(::byte *derived, size_t derivedLen, ::byte purpose, const ::byte *password, size_t passwordLen, const ::byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds) const; }; template -unsigned int PKCS12_PBKDF::DeriveKey(byte *derived, size_t derivedLen, byte purpose, const byte *password, size_t passwordLen, const byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds) const +unsigned int PKCS12_PBKDF::DeriveKey(::byte *derived, size_t derivedLen, ::byte purpose, const ::byte *password, size_t passwordLen, const ::byte *salt, size_t saltLen, unsigned int iterations, double timeInSeconds) const { CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength()); CRYPTOPP_ASSERT(iterations > 0 || timeInSeconds > 0); @@ -191,7 +191,7 @@ unsigned int PKCS12_PBKDF::DeriveKey(byte *derived, size_t derivedLen, byte p const size_t DLen = v, SLen = RoundUpToMultipleOf(saltLen, v); const size_t PLen = RoundUpToMultipleOf(passwordLen, v), ILen = SLen + PLen; SecByteBlock buffer(DLen + SLen + PLen); - byte *D = buffer, *S = buffer+DLen, *P = buffer+DLen+SLen, *I = S; + ::byte *D = buffer, *S = buffer+DLen, *P = buffer+DLen+SLen, *I = S; memset(D, purpose, DLen); size_t i; diff --git a/queue.cpp b/queue.cpp index 8bf43d99..941c8117 100644 --- a/queue.cpp +++ b/queue.cpp @@ -39,7 +39,7 @@ public: m_head = m_tail = 0; } - inline size_t Put(const byte *begin, size_t length) + inline size_t Put(const ::byte *begin, size_t length) { // Avoid passing NULL to memcpy if (!begin || !length) return length; @@ -50,7 +50,7 @@ public: return l; } - inline size_t Peek(byte &outByte) const + inline size_t Peek(::byte &outByte) const { if (m_tail==m_head) return 0; @@ -59,7 +59,7 @@ public: return 1; } - inline size_t Peek(byte *target, size_t copyMax) const + inline size_t Peek(::byte *target, size_t copyMax) const { size_t len = STDMIN(copyMax, m_tail-m_head); memcpy(target, buf+m_head, len); @@ -80,14 +80,14 @@ public: return len; } - inline size_t Get(byte &outByte) + inline size_t Get(::byte &outByte) { size_t len = Peek(outByte); m_head += len; return len; } - inline size_t Get(byte *outString, size_t getMax) + inline size_t Get(::byte *outString, size_t getMax) { size_t len = Peek(outString, getMax); m_head += len; @@ -117,7 +117,7 @@ public: return len; } - inline byte operator[](size_t i) const + inline ::byte operator[](size_t i) const { return buf[m_head+i]; } @@ -217,7 +217,7 @@ void ByteQueue::Clear() m_lazyLength = 0; } -size_t ByteQueue::Put2(const byte *inString, size_t length, int messageEnd, bool blocking) +size_t ByteQueue::Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { CRYPTOPP_UNUSED(messageEnd), CRYPTOPP_UNUSED(blocking); @@ -257,7 +257,7 @@ void ByteQueue::CleanupUsedNodes() m_head->Clear(); } -void ByteQueue::LazyPut(const byte *inString, size_t size) +void ByteQueue::LazyPut(const ::byte *inString, size_t size) { if (m_lazyLength > 0) FinalizeLazyPut(); @@ -266,13 +266,13 @@ void ByteQueue::LazyPut(const byte *inString, size_t size) Put(inString, size); else { - m_lazyString = const_cast(inString); + m_lazyString = const_cast< ::byte *>(inString); m_lazyLength = size; m_lazyStringModifiable = false; } } -void ByteQueue::LazyPutModifiable(byte *inString, size_t size) +void ByteQueue::LazyPutModifiable(::byte *inString, size_t size) { if (m_lazyLength > 0) FinalizeLazyPut(); @@ -297,7 +297,7 @@ void ByteQueue::FinalizeLazyPut() Put(m_lazyString, len); } -size_t ByteQueue::Get(byte &outByte) +size_t ByteQueue::Get(::byte &outByte) { if (m_head->Get(outByte)) { @@ -315,13 +315,13 @@ size_t ByteQueue::Get(byte &outByte) return 0; } -size_t ByteQueue::Get(byte *outString, size_t getMax) +size_t ByteQueue::Get(::byte *outString, size_t getMax) { ArraySink sink(outString, getMax); return (size_t)TransferTo(sink, getMax); } -size_t ByteQueue::Peek(byte &outByte) const +size_t ByteQueue::Peek(::byte &outByte) const { if (m_head->Peek(outByte)) return 1; @@ -334,7 +334,7 @@ size_t ByteQueue::Peek(byte &outByte) const return 0; } -size_t ByteQueue::Peek(byte *outString, size_t peekMax) const +size_t ByteQueue::Peek(::byte *outString, size_t peekMax) const { ArraySink sink(outString, peekMax); return (size_t)CopyTo(sink, peekMax); @@ -382,12 +382,12 @@ size_t ByteQueue::CopyRangeTo2(BufferedTransformation &target, lword &begin, lwo return blockedBytes; } -void ByteQueue::Unget(byte inByte) +void ByteQueue::Unget(::byte inByte) { Unget(&inByte, 1); } -void ByteQueue::Unget(const byte *inString, size_t length) +void ByteQueue::Unget(const ::byte *inString, size_t length) { size_t len = STDMIN(length, m_head->m_head); length -= len; @@ -403,7 +403,7 @@ void ByteQueue::Unget(const byte *inString, size_t length) } } -const byte * ByteQueue::Spy(size_t &contiguousSize) const +const ::byte * ByteQueue::Spy(size_t &contiguousSize) const { contiguousSize = m_head->m_tail - m_head->m_head; if (contiguousSize == 0 && m_lazyLength > 0) @@ -415,7 +415,7 @@ const byte * ByteQueue::Spy(size_t &contiguousSize) const return m_head->buf + m_head->m_head; } -byte * ByteQueue::CreatePutSpace(size_t &size) +::byte * ByteQueue::CreatePutSpace(size_t &size) { if (m_lazyLength > 0) FinalizeLazyPut(); @@ -445,7 +445,7 @@ bool ByteQueue::operator==(const ByteQueue &rhs) const return false; Walker walker1(*this), walker2(rhs); - byte b1, b2; + ::byte b1, b2; while (walker1.Get(b1) && walker2.Get(b2)) if (b1 != b2) @@ -454,7 +454,7 @@ bool ByteQueue::operator==(const ByteQueue &rhs) const return true; } -byte ByteQueue::operator[](lword i) const +::byte ByteQueue::operator[](lword i) const { for (ByteQueueNode *current=m_head; current; current=current->next) { @@ -492,25 +492,25 @@ void ByteQueue::Walker::IsolatedInitialize(const NameValuePairs ¶meters) m_lazyLength = m_queue.m_lazyLength; } -size_t ByteQueue::Walker::Get(byte &outByte) +size_t ByteQueue::Walker::Get(::byte &outByte) { ArraySink sink(&outByte, 1); return (size_t)TransferTo(sink, 1); } -size_t ByteQueue::Walker::Get(byte *outString, size_t getMax) +size_t ByteQueue::Walker::Get(::byte *outString, size_t getMax) { ArraySink sink(outString, getMax); return (size_t)TransferTo(sink, getMax); } -size_t ByteQueue::Walker::Peek(byte &outByte) const +size_t ByteQueue::Walker::Peek(::byte &outByte) const { ArraySink sink(&outByte, 1); return (size_t)CopyTo(sink, 1); } -size_t ByteQueue::Walker::Peek(byte *outString, size_t peekMax) const +size_t ByteQueue::Walker::Peek(::byte *outString, size_t peekMax) const { ArraySink sink(outString, peekMax); return (size_t)CopyTo(sink, peekMax); diff --git a/queue.h b/queue.h index c9c9f76f..1cabc4c3 100644 --- a/queue.h +++ b/queue.h @@ -37,14 +37,14 @@ public: {return !IsEmpty();} void IsolatedInitialize(const NameValuePairs ¶meters); - byte * CreatePutSpace(size_t &size); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); + ::byte * CreatePutSpace(size_t &size); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); - size_t Get(byte &outByte); - size_t Get(byte *outString, size_t getMax); + size_t Get(::byte &outByte); + size_t Get(::byte *outString, size_t getMax); - size_t Peek(byte &outByte) const; - size_t Peek(byte *outString, size_t peekMax) const; + size_t Peek(::byte &outByte) const; + size_t Peek(::byte *outString, size_t peekMax) const; size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true); size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const; @@ -57,20 +57,20 @@ public: void Clear(); - void Unget(byte inByte); - void Unget(const byte *inString, size_t length); + void Unget(::byte inByte); + void Unget(const ::byte *inString, size_t length); - const byte * Spy(size_t &contiguousSize) const; + const ::byte * Spy(size_t &contiguousSize) const; - void LazyPut(const byte *inString, size_t size); - void LazyPutModifiable(byte *inString, size_t size); + void LazyPut(const ::byte *inString, size_t size); + void LazyPutModifiable(::byte *inString, size_t size); void UndoLazyPut(size_t size); void FinalizeLazyPut(); ByteQueue & operator=(const ByteQueue &rhs); bool operator==(const ByteQueue &rhs) const; bool operator!=(const ByteQueue &rhs) const {return !operator==(rhs);} - byte operator[](lword i) const; + ::byte operator[](lword i) const; void swap(ByteQueue &rhs); //! \class Walker @@ -91,11 +91,11 @@ public: void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Get(byte &outByte); - size_t Get(byte *outString, size_t getMax); + size_t Get(::byte &outByte); + size_t Get(::byte *outString, size_t getMax); - size_t Peek(byte &outByte) const; - size_t Peek(byte *outString, size_t peekMax) const; + size_t Peek(::byte &outByte) const; + size_t Peek(::byte *outString, size_t peekMax) const; size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true); size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const; @@ -105,7 +105,7 @@ public: const ByteQueueNode *m_node; lword m_position; size_t m_offset; - const byte *m_lazyString; + const ::byte *m_lazyString; size_t m_lazyLength; }; @@ -119,7 +119,7 @@ private: bool m_autoNodeSize; size_t m_nodeSize; ByteQueueNode *m_head, *m_tail; - byte *m_lazyString; + ::byte *m_lazyString; size_t m_lazyLength; bool m_lazyStringModifiable; }; @@ -128,7 +128,7 @@ private: class CRYPTOPP_DLL LazyPutter { public: - LazyPutter(ByteQueue &bq, const byte *inString, size_t size) + LazyPutter(ByteQueue &bq, const ::byte *inString, size_t size) : m_bq(bq) {bq.LazyPut(inString, size);} ~LazyPutter() {try {m_bq.FinalizeLazyPut();} catch(const Exception&) {CRYPTOPP_ASSERT(0);}} @@ -142,7 +142,7 @@ private: class LazyPutterModifiable : public LazyPutter { public: - LazyPutterModifiable(ByteQueue &bq, byte *inString, size_t size) + LazyPutterModifiable(ByteQueue &bq, ::byte *inString, size_t size) : LazyPutter(bq) {bq.LazyPutModifiable(inString, size);} }; diff --git a/randpool.cpp b/randpool.cpp index a7d2efdf..cefcbec1 100644 --- a/randpool.cpp +++ b/randpool.cpp @@ -23,7 +23,7 @@ RandomPool::RandomPool() memset(m_seed, 0, m_seed.SizeInBytes()); } -void RandomPool::IncorporateEntropy(const byte *input, size_t length) +void RandomPool::IncorporateEntropy(const ::byte *input, size_t length) { SHA256 hash; hash.Update(m_key, 32); diff --git a/randpool.h b/randpool.h index 3214e3c0..0043adb5 100644 --- a/randpool.h +++ b/randpool.h @@ -53,15 +53,15 @@ public: RandomPool(); bool CanIncorporateEntropy() const {return true;} - void IncorporateEntropy(const byte *input, size_t length); + void IncorporateEntropy(const ::byte *input, size_t length); void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size); // for backwards compatibility. use RandomNumberSource, RandomNumberStore, and RandomNumberSink for other BufferTransformation functionality - void Put(const byte *input, size_t length) {IncorporateEntropy(input, length);} + void Put(const ::byte *input, size_t length) {IncorporateEntropy(input, length);} private: - FixedSizeAlignedSecBlock m_seed; - FixedSizeAlignedSecBlock m_key; + FixedSizeAlignedSecBlock< ::byte, 16, true> m_seed; + FixedSizeAlignedSecBlock< ::byte, 32> m_key; member_ptr m_pCipher; bool m_keySet; }; diff --git a/rc2.cpp b/rc2.cpp index a4e0079f..44e59ae4 100644 --- a/rc2.cpp +++ b/rc2.cpp @@ -7,7 +7,7 @@ NAMESPACE_BEGIN(CryptoPP) -void RC2::Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const NameValuePairs ¶ms) +void RC2::Base::UncheckedSetKey(const ::byte *key, unsigned int keyLen, const NameValuePairs ¶ms) { AssertValidKeyLength(keyLen); @@ -41,7 +41,7 @@ void RC2::Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Name L[i] = PITABLE[(L[i-1] + L[i-keyLen]) & 255]; unsigned int T8 = (effectiveLen+7) / 8; - byte TM = byte((int)255 >> ((8-(effectiveLen%8))%8)); + ::byte TM = ::byte((int)255 >> ((8-(effectiveLen%8))%8)); L[128-T8] = PITABLE[L[128-T8] & TM]; for (i=127-T8; i>=0; i--) @@ -53,7 +53,7 @@ void RC2::Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Name typedef BlockGetAndPut Block; -void RC2::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void RC2::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word16 R0, R1, R2, R3; Block::Get(inBlock)(R0)(R1)(R2)(R3); @@ -84,7 +84,7 @@ void RC2::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byt Block::Put(xorBlock, outBlock)(R0)(R1)(R2)(R3); } -void RC2::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void RC2::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word16 R0, R1, R2, R3; Block::Get(inBlock)(R0)(R1)(R2)(R3); diff --git a/rc2.h b/rc2.h index 30c29e01..d903b8c6 100644 --- a/rc2.h +++ b/rc2.h @@ -32,7 +32,7 @@ class RC2 : public RC2_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); unsigned int OptimalDataAlignment() const {return GetAlignmentOf();} protected: @@ -45,7 +45,7 @@ class RC2 : public RC2_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 @@ -54,7 +54,7 @@ class RC2 : public RC2_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: @@ -66,9 +66,9 @@ public: { public: Encryption() {} - Encryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH) + Encryption(const ::byte *key, size_t keyLen=DEFAULT_KEYLENGTH) {SetKey(key, keyLen);} - Encryption(const byte *key, size_t keyLen, int effectiveKeyLen) + Encryption(const ::byte *key, size_t keyLen, int effectiveKeyLen) {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));} }; @@ -79,9 +79,9 @@ public: { public: Decryption() {} - Decryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH) + Decryption(const ::byte *key, size_t keyLen=DEFAULT_KEYLENGTH) {SetKey(key, keyLen);} - Decryption(const byte *key, size_t keyLen, int effectiveKeyLen) + Decryption(const ::byte *key, size_t keyLen, int effectiveKeyLen) {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));} }; }; diff --git a/rc5.cpp b/rc5.cpp index f17667f2..7b85092c 100644 --- a/rc5.cpp +++ b/rc5.cpp @@ -7,7 +7,7 @@ NAMESPACE_BEGIN(CryptoPP) -void RC5::Base::UncheckedSetKey(const byte *k, unsigned int keylen, const NameValuePairs ¶ms) +void RC5::Base::UncheckedSetKey(const ::byte *k, unsigned int keylen, const NameValuePairs ¶ms) { AssertValidKeyLength(keylen); @@ -39,7 +39,7 @@ void RC5::Base::UncheckedSetKey(const byte *k, unsigned int keylen, const NameVa typedef BlockGetAndPut Block; -void RC5::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void RC5::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { const RC5_WORD *sptr = sTable; RC5_WORD a, b; @@ -58,7 +58,7 @@ void RC5::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byt Block::Put(xorBlock, outBlock)(a)(b); } -void RC5::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void RC5::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { const RC5_WORD *sptr = sTable.end(); RC5_WORD a, b; diff --git a/rc5.h b/rc5.h index 3881160c..97c1a1e1 100644 --- a/rc5.h +++ b/rc5.h @@ -29,7 +29,7 @@ class RC5 : public RC5_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: unsigned int r; // number of rounds @@ -39,13 +39,13 @@ class RC5 : public RC5_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 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: diff --git a/rc6.cpp b/rc6.cpp index b5cd8448..248b9871 100644 --- a/rc6.cpp +++ b/rc6.cpp @@ -8,7 +8,7 @@ NAMESPACE_BEGIN(CryptoPP) -void RC6::Base::UncheckedSetKey(const byte *k, unsigned int keylen, const NameValuePairs ¶ms) +void RC6::Base::UncheckedSetKey(const ::byte *k, unsigned int keylen, const NameValuePairs ¶ms) { AssertValidKeyLength(keylen); @@ -40,7 +40,7 @@ void RC6::Base::UncheckedSetKey(const byte *k, unsigned int keylen, const NameVa typedef BlockGetAndPut Block; -void RC6::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void RC6::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { const RC6_WORD *sptr = sTable; RC6_WORD a, b, c, d, t, u; @@ -66,7 +66,7 @@ void RC6::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byt Block::Put(xorBlock, outBlock)(a)(b)(c)(d); } -void RC6::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void RC6::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { const RC6_WORD *sptr = sTable.end(); RC6_WORD a, b, c, d, t, u; diff --git a/rc6.h b/rc6.h index 2ab4455c..1e2331bf 100644 --- a/rc6.h +++ b/rc6.h @@ -27,7 +27,7 @@ class RC6 : public RC6_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: unsigned int r; // number of rounds @@ -37,13 +37,13 @@ class RC6 : public RC6_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 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: diff --git a/rdrand.cpp b/rdrand.cpp index b591407d..e8370f0f 100644 --- a/rdrand.cpp +++ b/rdrand.cpp @@ -210,7 +210,7 @@ RDRAND::RDRAND() throw RDRAND_Err("HasRDRAND"); } -void RDRAND::GenerateBlock(byte *output, size_t size) +void RDRAND::GenerateBlock(::byte *output, size_t size) { CRYPTOPP_ASSERT((output && size) || !(output || size)); if (size == 0) return; @@ -367,7 +367,7 @@ RDSEED::RDSEED() throw RDSEED_Err("HasRDSEED"); } -void RDSEED::GenerateBlock(byte *output, size_t size) +void RDSEED::GenerateBlock(::byte *output, size_t size) { CRYPTOPP_ASSERT((output && size) || !(output || size)); if (size == 0) return; diff --git a/rdrand.h b/rdrand.h index 33309017..af29ddbd 100644 --- a/rdrand.h +++ b/rdrand.h @@ -62,7 +62,7 @@ public: //! \brief Generate random array of bytes //! \param output the byte buffer //! \param size the length of the buffer, in bytes - virtual void GenerateBlock(byte *output, size_t size); + virtual void GenerateBlock(::byte *output, size_t size); //! \brief Generate and discard n bytes //! \param n the number of bytes to generate and discard @@ -75,7 +75,7 @@ public: //! \param input unused //! \param length unused //! \details The operation is a nop for this generator. - virtual void IncorporateEntropy(const byte *input, size_t length) + virtual void IncorporateEntropy(const ::byte *input, size_t length) { // Override to avoid the base class' throw. CRYPTOPP_UNUSED(input); CRYPTOPP_UNUSED(length); @@ -112,7 +112,7 @@ public: //! \brief Generate random array of bytes //! \param output the byte buffer //! \param size the length of the buffer, in bytes - virtual void GenerateBlock(byte *output, size_t size); + virtual void GenerateBlock(::byte *output, size_t size); //! \brief Generate and discard n bytes //! \param n the number of bytes to generate and discard @@ -125,7 +125,7 @@ public: //! \param input unused //! \param length unused //! \details The operation is a nop for this generator. - virtual void IncorporateEntropy(const byte *input, size_t length) + virtual void IncorporateEntropy(const ::byte *input, size_t length) { // Override to avoid the base class' throw. CRYPTOPP_UNUSED(input); CRYPTOPP_UNUSED(length); diff --git a/rdtables.cpp b/rdtables.cpp index 8b2cea5b..a4faeccc 100644 --- a/rdtables.cpp +++ b/rdtables.cpp @@ -20,7 +20,7 @@ Td2[x] = Si[x].[0d, 0b, 0e, 09]; Td3[x] = Si[x].[09, 0d, 0b, 0e]; */ -const byte Rijndael::Base::Se[256] = { +const ::byte Rijndael::Base::Se[256] = { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, @@ -87,7 +87,7 @@ const byte Rijndael::Base::Se[256] = { 0xb0, 0x54, 0xbb, 0x16, }; -const byte Rijndael::Base::Sd[256] = { +const ::byte Rijndael::Base::Sd[256] = { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, diff --git a/rijndael.cpp b/rijndael.cpp index efa2092e..72c3b104 100644 --- a/rijndael.cpp +++ b/rijndael.cpp @@ -110,23 +110,23 @@ static volatile bool s_TeFilled = false, s_TdFilled = false; // ************************* Portable Code ************************************ #define QUARTER_ROUND(L, T, t, a, b, c, d) \ - a ^= L(T, 3, byte(t)); t >>= 8;\ - b ^= L(T, 2, byte(t)); t >>= 8;\ - c ^= L(T, 1, byte(t)); t >>= 8;\ + a ^= L(T, 3, ::byte(t)); t >>= 8;\ + b ^= L(T, 2, ::byte(t)); t >>= 8;\ + c ^= L(T, 1, ::byte(t)); t >>= 8;\ d ^= L(T, 0, t); #define QUARTER_ROUND_LE(t, a, b, c, d) \ - tempBlock[a] = ((byte *)(Te+byte(t)))[1]; t >>= 8;\ - tempBlock[b] = ((byte *)(Te+byte(t)))[1]; t >>= 8;\ - tempBlock[c] = ((byte *)(Te+byte(t)))[1]; t >>= 8;\ - tempBlock[d] = ((byte *)(Te+t))[1]; + tempBlock[a] = ((::byte *)(Te+::byte(t)))[1]; t >>= 8;\ + tempBlock[b] = ((::byte *)(Te+::byte(t)))[1]; t >>= 8;\ + tempBlock[c] = ((::byte *)(Te+::byte(t)))[1]; t >>= 8;\ + tempBlock[d] = ((::byte *)(Te+t))[1]; #if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) || defined(CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS) #define QUARTER_ROUND_LD(t, a, b, c, d) \ - tempBlock[a] = ((byte *)(Td+byte(t)))[GetNativeByteOrder()*7]; t >>= 8;\ - tempBlock[b] = ((byte *)(Td+byte(t)))[GetNativeByteOrder()*7]; t >>= 8;\ - tempBlock[c] = ((byte *)(Td+byte(t)))[GetNativeByteOrder()*7]; t >>= 8;\ - tempBlock[d] = ((byte *)(Td+t))[GetNativeByteOrder()*7]; + tempBlock[a] = ((::byte *)(Td+::byte(t)))[GetNativeByteOrder()*7]; t >>= 8;\ + tempBlock[b] = ((::byte *)(Td+::byte(t)))[GetNativeByteOrder()*7]; t >>= 8;\ + tempBlock[c] = ((::byte *)(Td+::byte(t)))[GetNativeByteOrder()*7]; t >>= 8;\ + tempBlock[d] = ((::byte *)(Td+t))[GetNativeByteOrder()*7]; #else #define QUARTER_ROUND_LD(t, a, b, c, d) \ tempBlock[a] = Sd[byte(t)]; t >>= 8;\ @@ -142,8 +142,8 @@ static volatile bool s_TeFilled = false, s_TdFilled = false; #define QUARTER_ROUND_FE(t, a, b, c, d) QUARTER_ROUND(TL_F, Te, t, d, c, b, a) #define QUARTER_ROUND_FD(t, a, b, c, d) QUARTER_ROUND(TL_F, Td, t, d, c, b, a) #if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) || defined(CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS) - #define TL_F(T, i, x) (*(word32 *)(void *)((byte *)T + x*8 + (6-i)%4+1)) - #define TL_M(T, i, x) (*(word32 *)(void *)((byte *)T + x*8 + (i+3)%4+1)) + #define TL_F(T, i, x) (*(word32 *)(void *)((::byte *)T + x*8 + (6-i)%4+1)) + #define TL_M(T, i, x) (*(word32 *)(void *)((::byte *)T + x*8 + (i+3)%4+1)) #else #define TL_F(T, i, x) rotrFixed(T[x], (3-i)*8) #define TL_M(T, i, x) T[i*256 + x] @@ -175,7 +175,7 @@ void Rijndael::Base::FillEncTable() { for (int i=0; i<256; i++) { - byte x = Se[i]; + ::byte x = Se[i]; #if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) || defined(CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS) word32 y = word32(x)<<8 | word32(x)<<16 | word32(f2(x))<<24; Te[i] = word64(y | f3(x))<<32 | y; @@ -198,7 +198,7 @@ void Rijndael::Base::FillDecTable() { for (int i=0; i<256; i++) { - byte x = Sd[i]; + ::byte x = Sd[i]; #if defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) || defined(CRYPTOPP_ALLOW_RIJNDAEL_UNALIGNED_DATA_ACCESS) word32 y = word32(fd(x))<<8 | word32(f9(x))<<16 | word32(fe(x))<<24; Td[i] = word64(y | fb(x))<<32 | y | x; @@ -214,7 +214,7 @@ void Rijndael::Base::FillDecTable() s_TdFilled = true; } -void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keylen, const NameValuePairs &) +void Rijndael::Base::UncheckedSetKey(const ::byte *userKey, unsigned int keylen, const NameValuePairs &) { AssertValidKeyLength(keylen); @@ -385,7 +385,7 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keylen, c #endif } -void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Rijndael::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) || CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE #if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_RIJNDAEL_ASM) @@ -425,7 +425,7 @@ void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock #else for (i=0; i<1024; i+=cacheLineSize) #endif - u &= *(const word32 *)(const void *)(((const byte *)Te)+i); + u &= *(const word32 *)(const void *)(((const ::byte *)Te)+i); u &= Te[255]; s0 |= u; s1 |= u; s2 |= u; s3 |= u; @@ -456,7 +456,7 @@ void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock } while (--r); word32 tbw[4]; - byte *const tempBlock = (byte *)tbw; + ::byte *const tempBlock = (::byte *)tbw; QUARTER_ROUND_LE(t2, 15, 2, 5, 8) QUARTER_ROUND_LE(t1, 11, 14, 1, 4) @@ -466,7 +466,7 @@ void Rijndael::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock Block::Put(xorBlock, outBlock)(tbw[0]^rk[0])(tbw[1]^rk[1])(tbw[2]^rk[2])(tbw[3]^rk[3]); } -void Rijndael::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Rijndael::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE if (HasAESNI()) @@ -503,7 +503,7 @@ void Rijndael::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock #else for (i=0; i<1024; i+=cacheLineSize) #endif - u &= *(const word32 *)(const void *)(((const byte *)Td)+i); + u &= *(const word32 *)(const void *)(((const ::byte *)Td)+i); u &= Td[255]; s0 |= u; s1 |= u; s2 |= u; s3 |= u; @@ -545,7 +545,7 @@ void Rijndael::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock #endif word32 tbw[4]; - byte *const tempBlock = (byte *)tbw; + ::byte *const tempBlock = (::byte *)tbw; QUARTER_ROUND_LD(t2, 7, 2, 13, 8) QUARTER_ROUND_LD(t1, 3, 14, 9, 4) @@ -1072,7 +1072,7 @@ void Rijndael_Enc_AdvancedProcessBlocks(void *locals, const word32 *k); // |YYYYY| // +-----+ // -static inline bool AliasedWithTable(const byte *begin, const byte *end) +static inline bool AliasedWithTable(const ::byte *begin, const ::byte *end) { ptrdiff_t s0 = uintptr_t(begin)%4096, s1 = uintptr_t(end)%4096; ptrdiff_t t0 = uintptr_t(Te)%4096, t1 = (uintptr_t(Te)+sizeof(Te))%4096; @@ -1156,7 +1156,7 @@ CRYPTOPP_ALIGN_DATA(16) static const word32 s_one[] = {0, 0, 0, 1<<24}; template -inline size_t AESNI_AdvancedProcessBlocks(F1 func1, F4 func4, MAYBE_CONST __m128i *subkeys, unsigned int rounds, const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) +inline size_t AESNI_AdvancedProcessBlocks(F1 func1, F4 func4, MAYBE_CONST __m128i *subkeys, unsigned int rounds, const ::byte *inBlocks, const ::byte *xorBlocks, ::byte *outBlocks, size_t length, word32 flags) { size_t blockSize = 16; size_t inIncrement = (flags & (BlockTransformation::BT_InBlockIsCounter|BlockTransformation::BT_DontIncrementInOutPointers)) ? 0 : blockSize; @@ -1247,7 +1247,7 @@ inline size_t AESNI_AdvancedProcessBlocks(F1 func1, F4 func4, MAYBE_CONST __m128 block = _mm_xor_si128(block, _mm_loadu_si128((const __m128i *)(const void *)xorBlocks)); if (flags & BlockTransformation::BT_InBlockIsCounter) - const_cast(inBlocks)[15]++; + const_cast< ::byte *>(inBlocks)[15]++; func1(block, subkeys, rounds); @@ -1270,8 +1270,8 @@ inline size_t AESNI_AdvancedProcessBlocks(F1 func1, F4 func4, MAYBE_CONST __m128 struct Locals { word32 subkeys[4*12], workspace[8]; - const byte *inBlocks, *inXorBlocks, *outXorBlocks; - byte *outBlocks; + const ::byte *inBlocks, *inXorBlocks, *outXorBlocks; + ::byte *outBlocks; size_t inIncrement, inXorIncrement, outXorIncrement, outIncrement; size_t regSpill, lengthAndCounterFlag, keysBegin; }; @@ -1283,7 +1283,7 @@ const size_t s_sizeToAllocate = s_aliasPageSize + s_aliasBlockSize + sizeof(Loca Rijndael::Enc::Enc() : m_aliasBlock(s_sizeToAllocate) { } #endif -size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const +size_t Rijndael::Enc::AdvancedProcessBlocks(const ::byte *inBlocks, const ::byte *xorBlocks, ::byte *outBlocks, size_t length, word32 flags) const { #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE if (HasAESNI()) @@ -1296,8 +1296,8 @@ size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xo if (length < BLOCKSIZE) return length; - static const byte *zeros = (const byte*)(Te+256); - byte *space = NULLPTR, *originalSpace = const_cast(m_aliasBlock.data()); + static const ::byte *zeros = (const ::byte*)(Te+256); + ::byte *space = NULLPTR, *originalSpace = const_cast< ::byte*>(m_aliasBlock.data()); // round up to nearest 256 byte boundary space = originalSpace + (s_aliasBlockSize - (uintptr_t)originalSpace % s_aliasBlockSize) % s_aliasBlockSize; @@ -1345,7 +1345,7 @@ size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xo #endif #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 -size_t Rijndael::Dec::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const +size_t Rijndael::Dec::AdvancedProcessBlocks(const ::byte *inBlocks, const ::byte *xorBlocks, ::byte *outBlocks, size_t length, word32 flags) const { #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE if (HasAESNI()) diff --git a/rijndael.h b/rijndael.h index 32d69867..eff144e7 100644 --- a/rijndael.h +++ b/rijndael.h @@ -33,15 +33,15 @@ class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentat class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: static void FillEncTable(); static void FillDecTable(); // VS2005 workaround: have to put these on separate lines, or error C2487 is triggered in DLL build - static const byte Se[256]; - static const byte Sd[256]; + static const ::byte Se[256]; + static const ::byte Sd[256]; static const word32 rcon[]; @@ -54,10 +54,10 @@ class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentat class CRYPTOPP_DLL 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; #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 Enc(); - size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const; + size_t AdvancedProcessBlocks(const ::byte *inBlocks, const ::byte *xorBlocks, ::byte *outBlocks, size_t length, word32 flags) const; private: SecByteBlock m_aliasBlock; #endif @@ -68,9 +68,9 @@ class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentat class CRYPTOPP_DLL 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; #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 - size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const; + size_t AdvancedProcessBlocks(const ::byte *inBlocks, const ::byte *xorBlocks, ::byte *outBlocks, size_t length, word32 flags) const; #endif }; diff --git a/rng.cpp b/rng.cpp index c1763974..bd465ffd 100644 --- a/rng.cpp +++ b/rng.cpp @@ -36,7 +36,7 @@ const word16 LC_RNG::a=16807; const word16 LC_RNG::r=2836; #endif -void LC_RNG::GenerateBlock(byte *output, size_t size) +void LC_RNG::GenerateBlock(::byte *output, size_t size) { while (size--) { @@ -50,7 +50,7 @@ void LC_RNG::GenerateBlock(byte *output, size_t size) else seed = test+ m; - *output++ = byte((GETBYTE(seed, 0) ^ GETBYTE(seed, 1) ^ GETBYTE(seed, 2) ^ GETBYTE(seed, 3))); + *output++ = ::byte((GETBYTE(seed, 0) ^ GETBYTE(seed, 1) ^ GETBYTE(seed, 2) ^ GETBYTE(seed, 3))); } } @@ -58,7 +58,7 @@ void LC_RNG::GenerateBlock(byte *output, size_t size) #ifndef CRYPTOPP_IMPORTS -X917RNG::X917RNG(BlockTransformation *c, const byte *seed, const byte *deterministicTimeVector) +X917RNG::X917RNG(BlockTransformation *c, const ::byte *seed, const ::byte *deterministicTimeVector) : m_cipher(c), m_size(m_cipher->BlockSize()), m_datetime(m_size), @@ -77,10 +77,10 @@ X917RNG::X917RNG(BlockTransformation *c, const byte *seed, const byte *determini if (!deterministicTimeVector) { time_t tstamp1 = std::time(NULLPTR); - xorbuf(m_datetime, (byte *)&tstamp1, UnsignedMin(sizeof(tstamp1), m_size)); + xorbuf(m_datetime, (::byte *)&tstamp1, UnsignedMin(sizeof(tstamp1), m_size)); m_cipher->ProcessBlock(m_datetime); clock_t tstamp2 = clock(); - xorbuf(m_datetime, (byte *)&tstamp2, UnsignedMin(sizeof(tstamp2), m_size)); + xorbuf(m_datetime, (::byte *)&tstamp2, UnsignedMin(sizeof(tstamp2), m_size)); m_cipher->ProcessBlock(m_datetime); } @@ -101,9 +101,9 @@ void X917RNG::GenerateIntoBufferedTransformation(BufferedTransformation &target, else { clock_t c = clock(); - xorbuf(m_datetime, (byte *)&c, UnsignedMin(sizeof(c), m_size)); + xorbuf(m_datetime, (::byte *)&c, UnsignedMin(sizeof(c), m_size)); time_t t = std::time(NULLPTR); - xorbuf(m_datetime+m_size-UnsignedMin(sizeof(t), m_size), (byte *)&t, UnsignedMin(sizeof(t), m_size)); + xorbuf(m_datetime+m_size-UnsignedMin(sizeof(t), m_size), (::byte *)&t, UnsignedMin(sizeof(t), m_size)); m_cipher->ProcessBlock(m_datetime); } @@ -136,11 +136,11 @@ MaurerRandomnessTest::MaurerRandomnessTest() tab[i] = 0; } -size_t MaurerRandomnessTest::Put2(const byte *inString, size_t length, int /*messageEnd*/, bool /*blocking*/) +size_t MaurerRandomnessTest::Put2(const ::byte *inString, size_t length, int /*messageEnd*/, bool /*blocking*/) { while (length--) { - byte inByte = *inString++; + ::byte inByte = *inString++; if (n >= Q) sum += std::log(double(n - tab[inByte])); tab[inByte] = n; diff --git a/rng.h b/rng.h index dc18cb48..06b8e9d3 100644 --- a/rng.h +++ b/rng.h @@ -27,7 +27,7 @@ public: LC_RNG(word32 init_seed) : seed(init_seed) {} - void GenerateBlock(byte *output, size_t size); + void GenerateBlock(::byte *output, size_t size); word32 GetSeed() {return seed;} @@ -64,7 +64,7 @@ public: //! OS_GenerateRandomBlock(false, seed, seed.size()); //! X917RNG prng(new AES::Encryption(key, AES::DEFAULT_KEYLENGTH), seed, NULLPTR); //! \sa AutoSeededX917RNG - X917RNG(BlockTransformation *cipher, const byte *seed, const byte *deterministicTimeVector = NULLPTR); + X917RNG(BlockTransformation *cipher, const ::byte *seed, const ::byte *deterministicTimeVector = NULLPTR); void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size); @@ -87,7 +87,7 @@ public: //! \brief Construct a MaurerRandomnessTest MaurerRandomnessTest(); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); //! \brief Provides the number of bytes of input is needed by the test //! \returns how many more bytes of input is needed by the test diff --git a/safer.cpp b/safer.cpp index 583f8b3b..45d56a54 100644 --- a/safer.cpp +++ b/safer.cpp @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(CryptoPP) -const byte SAFER::Base::exp_tab[256] = +const ::byte SAFER::Base::exp_tab[256] = {1, 45, 226, 147, 190, 69, 21, 174, 120, 3, 135, 164, 184, 56, 207, 63, 8, 103, 9, 148, 235, 38, 168, 107, 189, 24, 52, 27, 187, 191, 114, 247, 64, 53, 72, 156, 81, 47, 59, 85, 227, 192, 159, 216, 211, 243, 141, 177, @@ -29,7 +29,7 @@ const byte SAFER::Base::exp_tab[256] = 253, 77, 124, 183, 11, 238, 173, 75, 34, 245, 231, 115, 35, 33, 200, 5, 225, 102, 221, 179, 88, 105, 99, 86, 15, 161, 49, 149, 23, 7, 58, 40}; -const byte SAFER::Base::log_tab[256] = +const ::byte SAFER::Base::log_tab[256] = {128, 0, 176, 9, 96, 239, 185, 253, 16, 18, 159, 228, 105, 186, 173, 248, 192, 56, 194, 101, 79, 6, 148, 252, 25, 222, 106, 27, 93, 78, 168, 130, 112, 237, 232, 236, 114, 179, 21, 195, 255, 171, 182, 71, 68, 1, 172, 37, @@ -55,16 +55,16 @@ const byte SAFER::Base::log_tab[256] = static const unsigned int BLOCKSIZE = 8; static const unsigned int MAX_ROUNDS = 13; -void SAFER::Base::UncheckedSetKey(const byte *userkey_1, unsigned int length, const NameValuePairs ¶ms) +void SAFER::Base::UncheckedSetKey(const ::byte *userkey_1, unsigned int length, const NameValuePairs ¶ms) { bool strengthened = Strengthened(); unsigned int nof_rounds = params.GetIntValueWithDefault(Name::Rounds(), length == 8 ? (strengthened ? 8 : 6) : 10); - const byte *userkey_2 = length == 8 ? userkey_1 : userkey_1 + 8; + const ::byte *userkey_2 = length == 8 ? userkey_1 : userkey_1 + 8; keySchedule.New(1 + BLOCKSIZE * (1 + 2 * nof_rounds)); unsigned int i, j; - byte *key = keySchedule; + ::byte *key = keySchedule; SecByteBlock ka(BLOCKSIZE + 1), kb(BLOCKSIZE + 1); if (MAX_ROUNDS < nof_rounds) @@ -100,12 +100,12 @@ void SAFER::Base::UncheckedSetKey(const byte *userkey_1, unsigned int length, co } } -typedef BlockGetAndPut Block; +typedef BlockGetAndPut< ::byte, BigEndian> Block; -void SAFER::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SAFER::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { - byte a, b, c, d, e, f, g, h, t; - const byte *key = keySchedule+1; + ::byte a, b, c, d, e, f, g, h, t; + const ::byte *key = keySchedule+1; unsigned int round = keySchedule[0]; Block::Get(inBlock)(a)(b)(c)(d)(e)(f)(g)(h); @@ -128,11 +128,11 @@ void SAFER::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, b Block::Put(xorBlock, outBlock)(a)(b)(c)(d)(e)(f)(g)(h); } -void SAFER::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SAFER::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { - byte a, b, c, d, e, f, g, h, t; + ::byte a, b, c, d, e, f, g, h, t; unsigned int round = keySchedule[0]; - const byte *key = keySchedule + BLOCKSIZE * (1 + 2 * round) - 7; + const ::byte *key = keySchedule + BLOCKSIZE * (1 + 2 * round) - 7; Block::Get(inBlock)(a)(b)(c)(d)(e)(f)(g)(h); h ^= key[7]; g -= key[6]; f -= key[5]; e ^= key[4]; diff --git a/safer.h b/safer.h index 0972ac1e..eb5fcb83 100644 --- a/safer.h +++ b/safer.h @@ -22,14 +22,14 @@ public: { public: unsigned int OptimalDataAlignment() const {return 1;} - void UncheckedSetKey(const byte *userkey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userkey, unsigned int length, const NameValuePairs ¶ms); protected: virtual bool Strengthened() const =0; SecByteBlock keySchedule; - static const byte exp_tab[256]; - static const byte log_tab[256]; + static const ::byte exp_tab[256]; + static const ::byte log_tab[256]; }; //! \class Enc @@ -37,7 +37,7 @@ public: 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 @@ -45,7 +45,7 @@ public: 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; }; }; diff --git a/salsa.cpp b/salsa.cpp index eb58164e..9ee0bec5 100644 --- a/salsa.cpp +++ b/salsa.cpp @@ -40,7 +40,7 @@ void Salsa20_TestInstantiations() } #endif -void Salsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) +void Salsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length) { m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20); @@ -60,7 +60,7 @@ void Salsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, m_state[3] = 0x6b206574; } -void Salsa20_Policy::CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length) +void Salsa20_Policy::CipherResynchronize(::byte *keystreamBuffer, const ::byte *IV, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(length==8); @@ -108,7 +108,7 @@ void Salsa20_OperateKeystream(byte *output, const byte *input, size_t iterationC # pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code #endif -void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) +void Salsa20_Policy::OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount) { #endif // #ifdef CRYPTOPP_GENERATE_X64_MASM @@ -571,7 +571,7 @@ Salsa20_OperateKeystream ENDP } } // see comment above if an internal compiler error occurs here -void XSalsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) +void XSalsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length) { m_rounds = params.GetIntValueWithDefault(Name::Rounds(), 20); @@ -589,7 +589,7 @@ void XSalsa20_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key m_state[3] = 0x6b206574; } -void XSalsa20_Policy::CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length) +void XSalsa20_Policy::CipherResynchronize(::byte *keystreamBuffer, const ::byte *IV, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(length==24); diff --git a/salsa.h b/salsa.h index f3bede3b..e43427dd 100644 --- a/salsa.h +++ b/salsa.h @@ -30,9 +30,9 @@ struct Salsa20_Info : public VariableKeyLength<32, 16, 32, 16, SimpleKeyingInter class CRYPTOPP_NO_VTABLE Salsa20_Policy : public AdditiveCipherConcretePolicy { protected: - void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); - void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); - void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length); + void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length); + void OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount); + void CipherResynchronize(::byte *keystreamBuffer, const ::byte *IV, size_t length); bool CipherIsRandomAccess() const {return true;} void SeekToIteration(lword iterationCount); #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SALSA_ASM) @@ -66,8 +66,8 @@ struct XSalsa20_Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_I class CRYPTOPP_NO_VTABLE XSalsa20_Policy : public Salsa20_Policy { public: - void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); - void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length); + void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length); + void CipherResynchronize(::byte *keystreamBuffer, const ::byte *IV, size_t length); protected: FixedSizeSecBlock m_key; diff --git a/seal.cpp b/seal.cpp index 4108feb5..f08707f6 100644 --- a/seal.cpp +++ b/seal.cpp @@ -20,7 +20,7 @@ void SEAL_TestInstantiations() struct SEAL_Gamma { - SEAL_Gamma(const byte *key) + SEAL_Gamma(const ::byte *key) : H(5), Z(5), D(16), lastIndex(0xffffffff) { GetUserKey(BIG_ENDIAN_ORDER, H.begin(), 5, key, 20); @@ -52,7 +52,7 @@ word32 SEAL_Gamma::Apply(word32 i) } template -void SEAL_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) +void SEAL_Policy::CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length) { CRYPTOPP_UNUSED(length); m_insideCounter = m_outsideCounter = m_startCount = 0; @@ -76,7 +76,7 @@ void SEAL_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, } template -void SEAL_Policy::CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length) +void SEAL_Policy::CipherResynchronize(::byte *keystreamBuffer, const ::byte *IV, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(IV), CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(length==4); @@ -94,7 +94,7 @@ void SEAL_Policy::SeekToIteration(lword iterationCount) } template -void SEAL_Policy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) +void SEAL_Policy::OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount) { word32 a, b, c, d, n1, n2, n3, n4; unsigned int p, q; @@ -102,7 +102,7 @@ void SEAL_Policy::OperateKeystream(KeystreamOperation operation, byte *output CRYPTOPP_ASSERT(IsAlignedOn(m_T.begin(),GetAlignmentOf())); for (size_t iteration = 0; iteration < iterationCount; ++iteration) { - #define Ttab(x) *(word32 *)(void*)((byte *)m_T.begin()+x) + #define Ttab(x) *(word32 *)(void*)((::byte *)m_T.begin()+x) a = m_outsideCounter ^ m_R[4*m_insideCounter]; b = rotrFixed(m_outsideCounter, 8U) ^ m_R[4*m_insideCounter+1]; diff --git a/seal.h b/seal.h index 2e101535..c7e12288 100644 --- a/seal.h +++ b/seal.h @@ -27,9 +27,9 @@ template class CRYPTOPP_NO_VTABLE SEAL_Policy : public AdditiveCipherConcretePolicy, public SEAL_Info { protected: - void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); - void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); - void CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length); + void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length); + void OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount); + void CipherResynchronize(::byte *keystreamBuffer, const ::byte *IV, size_t length); bool CipherIsRandomAccess() const {return true;} void SeekToIteration(lword iterationCount); diff --git a/secblock.h b/secblock.h index 8f5aa71a..41e4f993 100644 --- a/secblock.h +++ b/secblock.h @@ -258,7 +258,7 @@ public: #endif }; -CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup; +CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup< ::byte>; CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup; CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup; CRYPTOPP_DLL_TEMPLATE_CLASS AllocatorWithCleanup; @@ -467,7 +467,7 @@ private: T* GetAlignedArray() {return m_array;} T m_array[S]; #else - T* GetAlignedArray() {return (CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? (T*)(void *)(((byte *)m_array) + (0-(size_t)m_array)%16) : m_array;} + T* GetAlignedArray() {return (CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? (T*)(void *)(((::byte *)m_array) + (0-(size_t)m_array)%16) : m_array;} CRYPTOPP_ALIGN_DATA(8) T m_array[(CRYPTOPP_BOOL_ALIGN16 && T_Align16) ? S+8/sizeof(T) : S]; #endif @@ -574,10 +574,10 @@ public: //! \brief Provides a byte pointer to the first element in the memory block //! \returns byte pointer to the first element in the memory block - byte * BytePtr() {return (byte *)m_ptr;} + ::byte * BytePtr() {return (::byte *)m_ptr;} //! \brief Return a byte pointer to the first element in the memory block //! \returns constant byte pointer to the first element in the memory block - const byte * BytePtr() const {return (const byte *)m_ptr;} + const ::byte * BytePtr() const {return (const ::byte *)m_ptr;} //! \brief Provides the number of bytes in the SecBlock //! \return the number of bytes in the memory block //! \note the return value is the number of bytes, and not count of elements. @@ -691,7 +691,7 @@ public: bool operator==(const SecBlock &t) const { return m_size == t.m_size && - VerifyBufsEqual(reinterpret_cast(m_ptr), reinterpret_cast(t.m_ptr), m_size*sizeof(T)); + VerifyBufsEqual(reinterpret_cast(m_ptr), reinterpret_cast(t.m_ptr), m_size*sizeof(T)); } //! \brief Bitwise compare two SecBlocks @@ -807,17 +807,17 @@ public: #ifdef CRYPTOPP_DOXYGEN_PROCESSING //! \class SecByteBlock //! \brief \ref SecBlock "SecBlock" typedef. -class SecByteBlock : public SecBlock {}; +class SecByteBlock : public SecBlock< ::byte> {}; //! \class SecWordBlock //! \brief \ref SecBlock "SecBlock" typedef. class SecWordBlock : public SecBlock {}; //! \class AlignedSecByteBlock -//! \brief SecBlock using \ref AllocatorWithCleanup "AllocatorWithCleanup" typedef -class AlignedSecByteBlock : public SecBlock > {}; +//! \brief SecBlock using \ref AllocatorWithCleanup "AllocatorWithCleanup< ::byte, true>" typedef +class AlignedSecByteBlock : public SecBlock< ::byte, AllocatorWithCleanup< ::byte, true> > {}; #else -typedef SecBlock SecByteBlock; +typedef SecBlock< ::byte> SecByteBlock; typedef SecBlock SecWordBlock; -typedef SecBlock > AlignedSecByteBlock; +typedef SecBlock< ::byte, AllocatorWithCleanup< ::byte, true> > AlignedSecByteBlock; #endif // No need for move semantics on derived class *if* the class does not add any diff --git a/seckey.h b/seckey.h index 76d73605..33c9772b 100644 --- a/seckey.h +++ b/seckey.h @@ -505,7 +505,7 @@ public: //! \param key a byte array used to key the cipher //! \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls //! SimpleKeyingInterface::SetKey. - BlockCipherFinal(const byte *key) + BlockCipherFinal(const ::byte *key) {this->SetKey(key, this->DEFAULT_KEYLENGTH);} //! \brief Construct a BlockCipherFinal @@ -513,7 +513,7 @@ public: //! \param length the length of the byte array //! \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls //! SimpleKeyingInterface::SetKey. - BlockCipherFinal(const byte *key, size_t length) + BlockCipherFinal(const ::byte *key, size_t length) {this->SetKey(key, length);} //! \brief Construct a BlockCipherFinal @@ -522,7 +522,7 @@ public: //! \param rounds the number of rounds //! \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls //! SimpleKeyingInterface::SetKeyWithRounds. - BlockCipherFinal(const byte *key, size_t length, unsigned int rounds) + BlockCipherFinal(const ::byte *key, size_t length, unsigned int rounds) {this->SetKeyWithRounds(key, length, rounds);} //! \brief Provides the direction of the cipher @@ -559,14 +559,14 @@ public: //! \param key a byte array used to key the algorithm //! \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls //! SimpleKeyingInterface::SetKey. - MessageAuthenticationCodeFinal(const byte *key) + MessageAuthenticationCodeFinal(const ::byte *key) {this->SetKey(key, this->DEFAULT_KEYLENGTH);} //! \brief Construct a BlockCipherFinal //! \param key a byte array used to key the algorithm //! \param length the length of the byte array //! \details key must be at least DEFAULT_KEYLENGTH in length. Internally, the function calls //! SimpleKeyingInterface::SetKey. - MessageAuthenticationCodeFinal(const byte *key, size_t length) + MessageAuthenticationCodeFinal(const ::byte *key, size_t length) {this->SetKey(key, length);} }; diff --git a/seed.cpp b/seed.cpp index 75410c01..d519f175 100644 --- a/seed.cpp +++ b/seed.cpp @@ -10,7 +10,7 @@ static const word32 s_kc[16] = { 0x9e3779b9, 0x3c6ef373, 0x78dde6e6, 0xf1bbcdcc, 0xe3779b99, 0xc6ef3733, 0x8dde6e67, 0x1bbcdccf, 0x3779b99e, 0x6ef3733c, 0xdde6e678, 0xbbcdccf1, 0x779b99e3, 0xef3733c6, 0xde6e678d, 0xbcdccf1b}; -static const byte s_s0[256] = { +static const ::byte s_s0[256] = { 0xA9, 0x85, 0xD6, 0xD3, 0x54, 0x1D, 0xAC, 0x25, 0x5D, 0x43, 0x18, 0x1E, 0x51, 0xFC, 0xCA, 0x63, 0x28, 0x44, 0x20, 0x9D, 0xE0, 0xE2, 0xC8, 0x17, 0xA5, 0x8F, 0x03, 0x7B, 0xBB, 0x13, 0xD2, 0xEE, 0x70, 0x8C, 0x3F, 0xA8, 0x32, 0xDD, 0xF6, 0x74, 0xEC, 0x95, 0x0B, 0x57, 0x5C, 0x5B, 0xBD, 0x01, 0x24, 0x1C, 0x73, @@ -28,7 +28,7 @@ static const byte s_s0[256] = { 0xCD, 0x88, 0x16, 0x3A, 0x58, 0xD4, 0x62, 0x29, 0x07, 0x33, 0xE8, 0x1B, 0x05, 0x79, 0x90, 0x6A, 0x2A, 0x9A}; -static const byte s_s1[256] = { +static const ::byte s_s1[256] = { 0x38, 0xE8, 0x2D, 0xA6, 0xCF, 0xDE, 0xB3, 0xB8, 0xAF, 0x60, 0x55, 0xC7, 0x44, 0x6F, 0x6B, 0x5B, 0xC3, 0x62, 0x33, 0xB5, 0x29, 0xA0, 0xE2, 0xA7, 0xD3, 0x91, 0x11, 0x06, 0x1C, 0xBC, 0x36, 0x4B, 0xEF, 0x88, 0x6C, 0xA8, 0x17, 0xC4, 0x16, 0xF4, 0xC2, 0x45, 0xE1, 0xD6, 0x3F, 0x3D, 0x8E, 0x98, 0x28, 0x4E, 0xF6, @@ -52,7 +52,7 @@ static const byte s_s1[256] = { #define SS3(x) ((s_s1[x]*0x01010101UL) & 0xCFF3FC3F) #define G(x) (SS0(GETBYTE(x, 0)) ^ SS1(GETBYTE(x, 1)) ^ SS2(GETBYTE(x, 2)) ^ SS3(GETBYTE(x, 3))) -void SEED::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs& /*params*/) +void SEED::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs& /*params*/) { AssertValidKeyLength(length); @@ -81,7 +81,7 @@ void SEED::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const } } -void SEED::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SEED::Base::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { typedef BlockGetAndPut Block; word32 a0, a1, b0, b1, t0, t1; diff --git a/seed.h b/seed.h index 554db308..05f651bb 100644 --- a/seed.h +++ b/seed.h @@ -29,8 +29,8 @@ class SEED : public SEED_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; protected: FixedSizeSecBlock m_k; diff --git a/serpent.cpp b/serpent.cpp index 4b41808c..e2edd4cf 100644 --- a/serpent.cpp +++ b/serpent.cpp @@ -10,7 +10,7 @@ NAMESPACE_BEGIN(CryptoPP) -void Serpent_KeySchedule(word32 *k, unsigned int rounds, const byte *userKey, size_t keylen) +void Serpent_KeySchedule(word32 *k, unsigned int rounds, const ::byte *userKey, size_t keylen) { FixedSizeSecBlock k0; GetUserKey(LITTLE_ENDIAN_ORDER, k0.begin(), 8, userKey, keylen); @@ -41,7 +41,7 @@ void Serpent_KeySchedule(word32 *k, unsigned int rounds, const byte *userKey, si afterS2(LK); afterS2(S3); afterS3(SK); } -void Serpent::Base::UncheckedSetKey(const byte *userKey, unsigned int keylen, const NameValuePairs &) +void Serpent::Base::UncheckedSetKey(const ::byte *userKey, unsigned int keylen, const NameValuePairs &) { AssertValidKeyLength(keylen); Serpent_KeySchedule(m_key, 32, userKey, keylen); @@ -49,7 +49,7 @@ void Serpent::Base::UncheckedSetKey(const byte *userKey, unsigned int keylen, co typedef BlockGetAndPut Block; -void Serpent::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Serpent::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 a, b, c, d, e; @@ -88,7 +88,7 @@ void Serpent::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, Block::Put(xorBlock, outBlock)(d)(e)(b)(a); } -void Serpent::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Serpent::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 a, b, c, d, e; diff --git a/serpent.h b/serpent.h index d5f12499..a85f3b26 100644 --- a/serpent.h +++ b/serpent.h @@ -26,7 +26,7 @@ class Serpent : public Serpent_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: FixedSizeSecBlock m_key; @@ -35,13 +35,13 @@ class Serpent : public Serpent_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 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: diff --git a/serpentp.h b/serpentp.h index a38b39a7..eeca5e16 100644 --- a/serpentp.h +++ b/serpentp.h @@ -429,6 +429,6 @@ NAMESPACE_BEGIN(CryptoPP) k[(8-r)*4 + 6] = c; \ k[(8-r)*4 + 7] = d;} -void Serpent_KeySchedule(word32 *k, unsigned int rounds, const byte *userKey, size_t keylen); +void Serpent_KeySchedule(word32 *k, unsigned int rounds, const ::byte *userKey, size_t keylen); NAMESPACE_END diff --git a/sha.cpp b/sha.cpp index 9c691eb6..25b4a5cd 100644 --- a/sha.cpp +++ b/sha.cpp @@ -675,7 +675,7 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 #if defined(__GNUC__) #if CRYPTOPP_BOOL_X64 - FixedSizeAlignedSecBlock workspace; + FixedSizeAlignedSecBlock< ::byte, LOCALS_SIZE> workspace; #endif __asm__ __volatile__ ( diff --git a/sha3.cpp b/sha3.cpp index 6cfcaa67..d7c76944 100644 --- a/sha3.cpp +++ b/sha3.cpp @@ -249,7 +249,7 @@ static void KeccakF1600(word64 *state) } } -void SHA3::Update(const byte *input, size_t length) +void SHA3::Update(const ::byte *input, size_t length) { CRYPTOPP_ASSERT((input && length) || !(input || length)); if (!length) { return; } @@ -276,7 +276,7 @@ void SHA3::Restart() m_counter = 0; } -void SHA3::TruncatedFinal(byte *hash, size_t size) +void SHA3::TruncatedFinal(::byte *hash, size_t size) { ThrowIfInvalidTruncatedSize(size); diff --git a/sha3.h b/sha3.h index e551767f..bda781df 100644 --- a/sha3.h +++ b/sha3.h @@ -39,9 +39,9 @@ public: CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "SHA3"; } unsigned int OptimalDataAlignment() const {return GetAlignmentOf();} - void Update(const byte *input, size_t length); + void Update(const ::byte *input, size_t length); void Restart(); - void TruncatedFinal(byte *hash, size_t size); + void TruncatedFinal(::byte *hash, size_t size); // unsigned int BlockSize() const { return r(); } // that's the idea behind it protected: diff --git a/shacal2.cpp b/shacal2.cpp index 7ddc94da..8222cb2e 100644 --- a/shacal2.cpp +++ b/shacal2.cpp @@ -31,7 +31,7 @@ NAMESPACE_BEGIN(CryptoPP) #define P(a,b,c,d,e,f,g,h,k) \ h-=S0(a)+Maj(a,b,c);d-=h;h-=S1(e)+Ch(e,f,g)+*--k; -void SHACAL2::Base::UncheckedSetKey(const byte *userKey, unsigned int keylen, const NameValuePairs &) +void SHACAL2::Base::UncheckedSetKey(const ::byte *userKey, unsigned int keylen, const NameValuePairs &) { AssertValidKeyLength(keylen); @@ -52,7 +52,7 @@ void SHACAL2::Base::UncheckedSetKey(const byte *userKey, unsigned int keylen, co typedef BlockGetAndPut Block; -void SHACAL2::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SHACAL2::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 a, b, c, d, e, f, g, h; const word32 *rk = m_key; @@ -84,7 +84,7 @@ void SHACAL2::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, Block::Put(xorBlock, outBlock)(a)(b)(c)(d)(e)(f)(g)(h); } -void SHACAL2::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SHACAL2::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 a, b, c, d, e, f, g, h; const word32 *rk = m_key + 64; diff --git a/shacal2.h b/shacal2.h index 2a92cb6d..00e46ecb 100644 --- a/shacal2.h +++ b/shacal2.h @@ -26,7 +26,7 @@ class SHACAL2 : public SHACAL2_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: FixedSizeSecBlock m_key; @@ -37,13 +37,13 @@ class SHACAL2 : public SHACAL2_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 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: diff --git a/shark.cpp b/shark.cpp index 0eb5eaeb..7b8f9101 100644 --- a/shark.cpp +++ b/shark.cpp @@ -14,7 +14,7 @@ NAMESPACE_BEGIN(CryptoPP) static word64 SHARKTransform(word64 a) { - static const byte iG[8][8] = { + static const ::byte iG[8][8] = { 0xe7, 0x30, 0x90, 0x85, 0xd0, 0x4b, 0x91, 0x41, 0x53, 0x95, 0x9b, 0xa5, 0x96, 0xbc, 0xa1, 0x68, 0x02, 0x45, 0xf7, 0x65, 0x5c, 0x1f, 0xb6, 0x52, @@ -33,7 +33,7 @@ static word64 SHARKTransform(word64 a) return result; } -void SHARK::Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const NameValuePairs ¶ms) +void SHARK::Base::UncheckedSetKey(const ::byte *key, unsigned int keyLen, const NameValuePairs ¶ms) { AssertValidKeyLength(keyLen); @@ -42,14 +42,14 @@ void SHARK::Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Na // concatenate key enought times to fill a for (unsigned int i=0; i<(m_rounds+1)*8; i++) - ((byte *)m_roundKeys.begin())[i] = key[i%keyLen]; + ((::byte *)m_roundKeys.begin())[i] = key[i%keyLen]; SHARK::Encryption e; e.InitForKeySetup(); - byte IV[8] = {0,0,0,0,0,0,0,0}; + ::byte IV[8] = {0,0,0,0,0,0,0,0}; CFB_Mode_ExternalCipher::Encryption cfb(e, IV); - cfb.ProcessString((byte *)m_roundKeys.begin(), (m_rounds+1)*8); + cfb.ProcessString((::byte *)m_roundKeys.begin(), (m_rounds+1)*8); ConditionalByteReverse(BIG_ENDIAN_ORDER, m_roundKeys.begin(), m_roundKeys.begin(), (m_rounds+1)*8); @@ -90,7 +90,7 @@ void SHARK::Enc::InitForKeySetup() #endif } -void SHARK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SHARK::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { CRYPTOPP_ASSERT(IsAlignedOn(inBlock,GetAlignmentOf())); word64 tmp = *(word64 *)(void *)inBlock ^ m_roundKeys[0]; @@ -111,7 +111,7 @@ void SHARK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, b ^ m_roundKeys[i]; } - PutBlock(xorBlock, outBlock) + PutBlock< ::byte, BigEndian>(xorBlock, outBlock) (sbox[GETBYTE(tmp, 7)]) (sbox[GETBYTE(tmp, 6)]) (sbox[GETBYTE(tmp, 5)]) @@ -125,7 +125,7 @@ void SHARK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, b *(word64 *)(void *)outBlock ^= m_roundKeys[m_rounds]; } -void SHARK::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SHARK::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { CRYPTOPP_ASSERT(IsAlignedOn(inBlock,GetAlignmentOf())); word64 tmp = *(word64 *)(void *)inBlock ^ m_roundKeys[0]; @@ -146,7 +146,7 @@ void SHARK::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, b ^ m_roundKeys[i]; } - PutBlock(xorBlock, outBlock) + PutBlock< ::byte, BigEndian>(xorBlock, outBlock) (sbox[GETBYTE(tmp, 7)]) (sbox[GETBYTE(tmp, 6)]) (sbox[GETBYTE(tmp, 5)]) diff --git a/shark.h b/shark.h index 8e2f92e5..70ebbf5b 100644 --- a/shark.h +++ b/shark.h @@ -29,7 +29,7 @@ class SHARK : public SHARK_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶m); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶m); protected: unsigned int m_rounds; @@ -41,13 +41,13 @@ class SHARK : public SHARK_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; // used by Base to do key setup void InitForKeySetup(); private: - static const byte sbox[256]; + static const ::byte sbox[256]; static const word64 cbox[8][256]; }; @@ -56,10 +56,10 @@ class SHARK : public SHARK_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; private: - static const byte sbox[256]; + static const ::byte sbox[256]; static const word64 cbox[8][256]; }; diff --git a/sharkbox.cpp b/sharkbox.cpp index 1a50c171..19eaebf0 100644 --- a/sharkbox.cpp +++ b/sharkbox.cpp @@ -7,7 +7,7 @@ NAMESPACE_BEGIN(CryptoPP) -const byte SHARK::Enc::sbox[256] = { +const ::byte SHARK::Enc::sbox[256] = { 177, 206, 195, 149, 90, 173, 231, 2, 77, 68, 251, 145, 12, 135, 161, 80, 203, 103, 84, 221, 70, 143, 225, 78, 240, 253, 252, 235, 249, 196, 26, 110, 94, 245, 204, 141, 28, 86, 67, 254, 7, 97, 248, 117, 89, 255, 3, 34, @@ -26,7 +26,7 @@ const byte SHARK::Enc::sbox[256] = { 214, 120, 134, 250, 228, 43, 169, 30, 137, 96, 107, 234, 85, 76, 247, 226, }; -const byte SHARK::Dec::sbox[256] = { +const ::byte SHARK::Dec::sbox[256] = { 53, 190, 7, 46, 83, 105, 219, 40, 111, 183, 118, 107, 12, 125, 54, 139, 146, 188, 169, 50, 172, 56, 156, 66, 99, 200, 30, 79, 36, 229, 247, 201, 97, 141, 47, 63, 179, 101, 127, 112, 175, 154, 234, 245, 91, 152, 144, 177, diff --git a/simple.h b/simple.h index 8be4d422..26194b0f 100644 --- a/simple.h +++ b/simple.h @@ -143,7 +143,7 @@ public: //! \throws InputRejected //! \returns the number of bytes that remain in the block (i.e., bytes not processed) //! \details Internally, the default implementation throws InputRejected. - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) {CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); throw InputRejected();} //@} @@ -153,7 +153,7 @@ public: {CRYPTOPP_UNUSED(hardFlush); CRYPTOPP_UNUSED(blocking); return false;} bool IsolatedMessageSeriesEnd(bool blocking) {CRYPTOPP_UNUSED(blocking); throw InputRejected();} - size_t ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking) + size_t ChannelPut2(const std::string &channel, const ::byte *inString, size_t length, int messageEnd, bool blocking) {CRYPTOPP_UNUSED(channel); CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); throw InputRejected();} bool ChannelMessageSeriesEnd(const std::string& channel, int messageEnd, bool blocking) {CRYPTOPP_UNUSED(channel); CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); throw InputRejected();} @@ -246,7 +246,7 @@ public: //! \details The base class implementation sets size to 0 and returns NULL. //! \note Some objects, like ArraySink, cannot create a space because its fixed. In the case of //! an ArraySink, the pointer to the array is returned and the size is remaining size. - byte * CreatePutSpace(size_t &size) + ::byte * CreatePutSpace(size_t &size) {return this->ChannelCreatePutSpace(DEFAULT_CHANNEL, size);} //! \brief Input multiple bytes for processing @@ -255,7 +255,7 @@ public: //! \param messageEnd means how many filters to signal MessageEnd() to, including this one //! \param blocking specifies whether the object should block when processing input //! \details Derived classes must implement Put2(). - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) {return this->ChannelPut2(DEFAULT_CHANNEL, inString, length, messageEnd, blocking);} //! \brief Input multiple bytes that may be modified by callee. @@ -264,18 +264,18 @@ public: //! \param messageEnd means how many filters to signal MessageEnd() to, including this one. //! \param blocking specifies whether the object should block when processing input. //! \details Internally, PutModifiable2() calls Put2(). - size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking) + size_t PutModifiable2(::byte *inString, size_t length, int messageEnd, bool blocking) {return this->ChannelPutModifiable2(DEFAULT_CHANNEL, inString, length, messageEnd, blocking);} // void ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1) // {PropagateMessageSeriesEnd(propagation, channel);} - byte * ChannelCreatePutSpace(const std::string &channel, size_t &size) + ::byte * ChannelCreatePutSpace(const std::string &channel, size_t &size) {CRYPTOPP_UNUSED(channel); size = 0; return NULLPTR;} - bool ChannelPutModifiable(const std::string &channel, byte *inString, size_t length) + bool ChannelPutModifiable(const std::string &channel, ::byte *inString, size_t length) {this->ChannelPut(channel, inString, length); return false;} - virtual size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) =0; - size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking) + virtual size_t ChannelPut2(const std::string &channel, const ::byte *begin, size_t length, int messageEnd, bool blocking) =0; + size_t ChannelPutModifiable2(const std::string &channel, ::byte *begin, size_t length, int messageEnd, bool blocking) {return ChannelPut2(channel, begin, length, messageEnd, blocking);} virtual bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true) =0; @@ -356,7 +356,7 @@ public: std::string AlgorithmName() const {return "BitBucket";} void IsolatedInitialize(const NameValuePairs ¶ms) {CRYPTOPP_UNUSED(params);} - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) {CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); return 0;} }; diff --git a/siphash.h b/siphash.h index ce4249f2..275404bf 100644 --- a/siphash.h +++ b/siphash.h @@ -79,12 +79,12 @@ public: virtual unsigned int OptimalDataAlignment () const {return GetAlignmentOf();} - virtual void Update(const byte *input, size_t length); - virtual void TruncatedFinal(byte *digest, size_t digestSize); + virtual void Update(const ::byte *input, size_t length); + virtual void TruncatedFinal(::byte *digest, size_t digestSize); protected: - virtual void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); + virtual void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); virtual void Restart(); inline void SIPROUND() @@ -111,7 +111,7 @@ private: FixedSizeSecBlock m_b; // Tail bytes - FixedSizeSecBlock m_acc; + FixedSizeSecBlock< ::byte, 8> m_acc; size_t m_idx; }; @@ -150,12 +150,12 @@ public: //! \brief Create a SipHash //! \param key a byte array used to key the cipher //! \param length the size of the byte array, in bytes - SipHash(const byte *key, unsigned int length) + SipHash(const ::byte *key, unsigned int length) {this->UncheckedSetKey(key, length, g_nullNameValuePairs);} }; template -void SipHash_Base::Update(const byte *input, size_t length) +void SipHash_Base::Update(const ::byte *input, size_t length) { CRYPTOPP_ASSERT((input && length) || !length); if (!length) return; @@ -204,7 +204,7 @@ void SipHash_Base::Update(const byte *input, size_t length) } template -void SipHash_Base::TruncatedFinal(byte *digest, size_t digestSize) +void SipHash_Base::TruncatedFinal(::byte *digest, size_t digestSize) { CRYPTOPP_ASSERT(digest); // Pointer is valid @@ -266,7 +266,7 @@ void SipHash_Base::TruncatedFinal(byte *digest, size_t digestSize) } template -void SipHash_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) +void SipHash_Base::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { CRYPTOPP_UNUSED(params); if (key && length) diff --git a/skipjack.cpp b/skipjack.cpp index d3f59ff7..08d989bf 100644 --- a/skipjack.cpp +++ b/skipjack.cpp @@ -20,7 +20,7 @@ NAMESPACE_BEGIN(CryptoPP) /** * The F-table byte permutation (see description of the G-box permutation) */ -const byte SKIPJACK::Base::fTable[256] = { +const ::byte SKIPJACK::Base::fTable[256] = { 0xa3,0xd7,0x09,0x83,0xf8,0x48,0xf6,0xf4,0xb3,0x21,0x15,0x78,0x99,0xb1,0xaf,0xf9, 0xe7,0x2d,0x4d,0x8a,0xce,0x4c,0xca,0x2e,0x52,0x95,0xd9,0x1e,0x4e,0x38,0x44,0x28, 0x0a,0xdf,0x02,0xa0,0x17,0xf1,0x60,0x68,0x12,0xb7,0x7a,0xc3,0xe9,0xfa,0x3d,0x53, @@ -78,14 +78,14 @@ const byte SKIPJACK::Base::fTable[256] = { /** * Preprocess a user key into a table to save an XOR at each F-table access. */ -void SKIPJACK::Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &) +void SKIPJACK::Base::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); /* tab[i][c] = fTable[c ^ key[i]] */ int i; for (i = 0; i < 10; i++) { - byte *t = tab+i*256, k = key[9-i]; + ::byte *t = tab+i*256, k = key[9-i]; int c; for (c = 0; c < 256; c++) { t[c] = fTable[c ^ k]; @@ -98,7 +98,7 @@ typedef BlockGetAndPut Block; /** * Encrypt a single block of data. */ -void SKIPJACK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SKIPJACK::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word16 w1, w2, w3, w4; Block::Get(inBlock)(w4)(w3)(w2)(w1); @@ -149,7 +149,7 @@ void SKIPJACK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock /** * Decrypt a single block of data. */ -void SKIPJACK::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void SKIPJACK::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word16 w1, w2, w3, w4; Block::Get(inBlock)(w4)(w3)(w2)(w1); diff --git a/skipjack.h b/skipjack.h index acc5bc98..18b017df 100644 --- a/skipjack.h +++ b/skipjack.h @@ -28,13 +28,13 @@ class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); unsigned int OptimalDataAlignment() const {return GetAlignmentOf();} protected: - static const byte fTable[256]; + static const ::byte fTable[256]; - FixedSizeSecBlock tab; + FixedSizeSecBlock< ::byte, 10*256> tab; }; //! \class Enc @@ -42,9 +42,9 @@ class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation class CRYPTOPP_DLL 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; private: - static const byte Se[256]; + static const ::byte Se[256]; static const word32 Te[4][256]; }; @@ -53,9 +53,9 @@ class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation class CRYPTOPP_DLL 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; private: - static const byte Sd[256]; + static const ::byte Sd[256]; static const word32 Td[4][256]; }; diff --git a/socketft.cpp b/socketft.cpp index 54e52289..2e4f19c7 100644 --- a/socketft.cpp +++ b/socketft.cpp @@ -288,7 +288,7 @@ void Socket::GetPeerName(sockaddr *psa, socklen_t *psaLen) CheckAndHandleError_int("getpeername", getpeername(m_s, psa, psaLen)); } -unsigned int Socket::Send(const byte* buf, size_t bufLen, int flags) +unsigned int Socket::Send(const ::byte* buf, size_t bufLen, int flags) { CRYPTOPP_ASSERT(m_s != INVALID_SOCKET); int result = send(m_s, (const char *)buf, UnsignedMin(INT_MAX, bufLen), flags); @@ -296,7 +296,7 @@ unsigned int Socket::Send(const byte* buf, size_t bufLen, int flags) return result; } -unsigned int Socket::Receive(byte* buf, size_t bufLen, int flags) +unsigned int Socket::Receive(::byte* buf, size_t bufLen, int flags) { CRYPTOPP_ASSERT(m_s != INVALID_SOCKET); int result = recv(m_s, (char *)buf, UnsignedMin(INT_MAX, bufLen), flags); @@ -615,7 +615,7 @@ void SocketReceiver::GetWaitObjects(WaitObjectContainer &container, CallStack co container.AddReadFd(m_s, CallStack("SocketReceiver::GetWaitObjects()", &callStack)); } -bool SocketReceiver::Receive(byte* buf, size_t bufLen) +bool SocketReceiver::Receive(::byte* buf, size_t bufLen) { m_lastResult = m_s.Receive(buf, bufLen); if (bufLen > 0 && m_lastResult == 0) @@ -633,7 +633,7 @@ SocketSender::SocketSender(Socket &s) { } -void SocketSender::Send(const byte* buf, size_t bufLen) +void SocketSender::Send(const ::byte* buf, size_t bufLen) { m_lastResult = m_s.Send(buf, bufLen); } diff --git a/socketft.h b/socketft.h index c9942d8e..a25b6e24 100644 --- a/socketft.h +++ b/socketft.h @@ -80,8 +80,8 @@ public: bool Accept(Socket& s, sockaddr *psa=NULLPTR, socklen_t *psaLen=NULLPTR); void GetSockName(sockaddr *psa, socklen_t *psaLen); void GetPeerName(sockaddr *psa, socklen_t *psaLen); - unsigned int Send(const byte* buf, size_t bufLen, int flags=0); - unsigned int Receive(byte* buf, size_t bufLen, int flags=0); + unsigned int Send(const ::byte* buf, size_t bufLen, int flags=0); + unsigned int Receive(::byte* buf, size_t bufLen, int flags=0); void ShutDown(int how = SD_SEND); void IOCtl(long cmd, unsigned long *argp); @@ -136,7 +136,7 @@ public: ~SocketReceiver(); bool MustWaitForResult() {return true;} #endif - bool Receive(byte* buf, size_t bufLen); + bool Receive(::byte* buf, size_t bufLen); unsigned int GetReceiveResult(); bool EofReceived() const {return m_eofReceived;} @@ -171,7 +171,7 @@ public: bool MustWaitForEof() { return true; } bool EofSent(); #endif - void Send(const byte* buf, size_t bufLen); + void Send(const ::byte* buf, size_t bufLen); unsigned int GetSendResult(); void SendEof(); diff --git a/sosemanuk.cpp b/sosemanuk.cpp index b96192b8..af0a4b21 100644 --- a/sosemanuk.cpp +++ b/sosemanuk.cpp @@ -19,13 +19,13 @@ NAMESPACE_BEGIN(CryptoPP) -void SosemanukPolicy::CipherSetKey(const NameValuePairs ¶ms, const byte *userKey, size_t keylen) +void SosemanukPolicy::CipherSetKey(const NameValuePairs ¶ms, const ::byte *userKey, size_t keylen) { CRYPTOPP_UNUSED(params); Serpent_KeySchedule(m_key, 24, userKey, keylen); } -void SosemanukPolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length) +void SosemanukPolicy::CipherResynchronize(::byte *keystreamBuffer, const ::byte *iv, size_t length) { CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(iv), CRYPTOPP_UNUSED(length); CRYPTOPP_ASSERT(length==16); @@ -324,7 +324,7 @@ void Sosemanuk_OperateKeystream(size_t iterationCount, const byte *input, byte * } #endif -void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) +void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount) { #endif // #ifdef CRYPTOPP_GENERATE_X64_MASM @@ -354,7 +354,7 @@ void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *outpu { #ifdef __GNUC__ #if CRYPTOPP_BOOL_X64 - FixedSizeAlignedSecBlock workspace; + FixedSizeAlignedSecBlock< ::byte, 80*4*2+12*4+8*WORD_SZ> workspace; #endif __asm__ __volatile__ ( @@ -626,12 +626,12 @@ void SosemanukPolicy::OperateKeystream(KeystreamOperation operation, byte *outpu #ifndef CRYPTOPP_GENERATE_X64_MASM { #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM) -#define MUL_A(x) (x = rotlFixed(x, 8), x ^ s_sosemanukMulTables[byte(x)]) +#define MUL_A(x) (x = rotlFixed(x, 8), x ^ s_sosemanukMulTables[::byte(x)]) #else #define MUL_A(x) (((x) << 8) ^ s_sosemanukMulTables[(x) >> 24]) #endif -#define DIV_A(x) (((x) >> 8) ^ s_sosemanukMulTables[256 + byte(x)]) +#define DIV_A(x) (((x) >> 8) ^ s_sosemanukMulTables[256 + ::byte(x)]) #define r1(i) ((i%2) ? reg2 : reg1) #define r2(i) ((i%2) ? reg1 : reg2) diff --git a/sosemanuk.h b/sosemanuk.h index a1f3f2f5..2f053997 100644 --- a/sosemanuk.h +++ b/sosemanuk.h @@ -32,9 +32,9 @@ struct SosemanukInfo : public VariableKeyLength<16, 1, 32, 1, SimpleKeyingInterf class SosemanukPolicy : public AdditiveCipherConcretePolicy, public SosemanukInfo { protected: - void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); - void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); - void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); + void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length); + void OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount); + void CipherResynchronize(::byte *keystreamBuffer, const ::byte *iv, size_t length); bool CipherIsRandomAccess() const {return false;} #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) && !defined(CRYPTOPP_DISABLE_SOSEMANUK_ASM) unsigned int GetAlignment() const; diff --git a/square.cpp b/square.cpp index 0b960323..f341f329 100644 --- a/square.cpp +++ b/square.cpp @@ -21,7 +21,7 @@ NAMESPACE_BEGIN(CryptoPP) // apply theta to a roundkey static void SquareTransform (word32 in[4], word32 out[4]) { - static const byte G[4][4] = + static const ::byte G[4][4] = { 0x02U, 0x01U, 0x01U, 0x03U, 0x03U, 0x02U, 0x01U, 0x01U, @@ -44,7 +44,7 @@ static void SquareTransform (word32 in[4], word32 out[4]) #define roundkeys(i, j) m_roundkeys[(i)*4+(j)] #define roundkeys4(i) (m_roundkeys+(i)*4) -void Square::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &) +void Square::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs &) { AssertValidKeyLength(length); @@ -134,7 +134,7 @@ void Square::Base::UncheckedSetKey(const byte *userKey, unsigned int length, con typedef BlockGetAndPut Block; -void Square::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Square::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 text[4], temp[4]; Block::Get(inBlock)(text[0])(text[1])(text[2])(text[3]); @@ -159,7 +159,7 @@ void Square::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, Block::Put(xorBlock, outBlock)(text[0])(text[1])(text[2])(text[3]); } -void Square::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Square::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 text[4], temp[4]; Block::Get(inBlock)(text[0])(text[1])(text[2])(text[3]); diff --git a/square.h b/square.h index 0b743f67..e18b7d1c 100644 --- a/square.h +++ b/square.h @@ -26,7 +26,7 @@ class Square : public Square_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: FixedSizeSecBlock m_roundkeys; @@ -35,18 +35,18 @@ class Square : public Square_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; private: - static const byte Se[256]; + static const ::byte Se[256]; static const word32 Te[4][256]; }; 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; private: - static const byte Sd[256]; + static const ::byte Sd[256]; static const word32 Td[4][256]; }; diff --git a/squaretb.cpp b/squaretb.cpp index e806f610..e4d3e57f 100644 --- a/squaretb.cpp +++ b/squaretb.cpp @@ -3,7 +3,7 @@ NAMESPACE_BEGIN(CryptoPP) -const byte Square::Enc::Se[256] = { +const ::byte Square::Enc::Se[256] = { 177, 206, 195, 149, 90, 173, 231, 2, 77, 68, 251, 145, 12, 135, 161, 80, 203, 103, 84, 221, 70, 143, 225, 78, 240, 253, 252, 235, 249, 196, 26, 110, 94, 245, 204, 141, 28, 86, 67, 254, 7, 97, 248, 117, 89, 255, 3, 34, @@ -22,7 +22,7 @@ const byte Square::Enc::Se[256] = { 214, 120, 134, 250, 228, 43, 169, 30, 137, 96, 107, 234, 85, 76, 247, 226, }; -const byte Square::Dec::Sd[256] = { +const ::byte Square::Dec::Sd[256] = { 53, 190, 7, 46, 83, 105, 219, 40, 111, 183, 118, 107, 12, 125, 54, 139, 146, 188, 169, 50, 172, 56, 156, 66, 99, 200, 30, 79, 36, 229, 247, 201, 97, 141, 47, 63, 179, 101, 127, 112, 175, 154, 234, 245, 91, 152, 144, 177, diff --git a/strciphr.cpp b/strciphr.cpp index 6aae6318..f45953a6 100644 --- a/strciphr.cpp +++ b/strciphr.cpp @@ -9,7 +9,7 @@ NAMESPACE_BEGIN(CryptoPP) template -void AdditiveCipherTemplate::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) +void AdditiveCipherTemplate::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { PolicyInterface &policy = this->AccessPolicy(); policy.CipherSetKey(params, key, length); @@ -20,13 +20,13 @@ void AdditiveCipherTemplate::UncheckedSetKey(const byte *key, unsigned int le if (this->IsResynchronizable()) { size_t ivLength; - const byte *iv = this->GetIVAndThrowIfInvalid(params, ivLength); + const ::byte *iv = this->GetIVAndThrowIfInvalid(params, ivLength); policy.CipherResynchronize(m_buffer, iv, ivLength); } } template -void AdditiveCipherTemplate::GenerateBlock(byte *outString, size_t length) +void AdditiveCipherTemplate::GenerateBlock(::byte *outString, size_t length) { if (m_leftOver > 0) { @@ -64,7 +64,7 @@ void AdditiveCipherTemplate::GenerateBlock(byte *outString, size_t length) } template -void AdditiveCipherTemplate::ProcessData(byte *outString, const byte *inString, size_t length) +void AdditiveCipherTemplate::ProcessData(::byte *outString, const ::byte *inString, size_t length) { if (m_leftOver > 0) { @@ -123,7 +123,7 @@ void AdditiveCipherTemplate::ProcessData(byte *outString, const byte *inStrin } template -void AdditiveCipherTemplate::Resynchronize(const byte *iv, int length) +void AdditiveCipherTemplate::Resynchronize(const ::byte *iv, int length) { PolicyInterface &policy = this->AccessPolicy(); m_leftOver = 0; @@ -150,7 +150,7 @@ void AdditiveCipherTemplate::Seek(lword position) } template -void CFB_CipherTemplate::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) +void CFB_CipherTemplate::UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { PolicyInterface &policy = this->AccessPolicy(); policy.CipherSetKey(params, key, length); @@ -158,7 +158,7 @@ void CFB_CipherTemplate::UncheckedSetKey(const byte *key, unsigned int len if (this->IsResynchronizable()) { size_t ivLength; - const byte *iv = this->GetIVAndThrowIfInvalid(params, ivLength); + const ::byte *iv = this->GetIVAndThrowIfInvalid(params, ivLength); policy.CipherResynchronize(iv, ivLength); } @@ -166,7 +166,7 @@ void CFB_CipherTemplate::UncheckedSetKey(const byte *key, unsigned int len } template -void CFB_CipherTemplate::Resynchronize(const byte *iv, int length) +void CFB_CipherTemplate::Resynchronize(const ::byte *iv, int length) { PolicyInterface &policy = this->AccessPolicy(); policy.CipherResynchronize(iv, this->ThrowIfInvalidIVLength(length)); @@ -174,14 +174,14 @@ void CFB_CipherTemplate::Resynchronize(const byte *iv, int length) } template -void CFB_CipherTemplate::ProcessData(byte *outString, const byte *inString, size_t length) +void CFB_CipherTemplate::ProcessData(::byte *outString, const ::byte *inString, size_t length) { CRYPTOPP_ASSERT(length % this->MandatoryBlockSize() == 0); PolicyInterface &policy = this->AccessPolicy(); unsigned int bytesPerIteration = policy.GetBytesPerIteration(); unsigned int alignment = policy.GetAlignment(); - byte *reg = policy.GetRegisterBegin(); + ::byte *reg = policy.GetRegisterBegin(); if (m_leftOver) { @@ -230,18 +230,18 @@ void CFB_CipherTemplate::ProcessData(byte *outString, const byte *inString } template -void CFB_EncryptionTemplate::CombineMessageAndShiftRegister(byte *output, byte *reg, const byte *message, size_t length) +void CFB_EncryptionTemplate::CombineMessageAndShiftRegister(::byte *output, ::byte *reg, const ::byte *message, size_t length) { xorbuf(reg, message, length); memcpy(output, reg, length); } template -void CFB_DecryptionTemplate::CombineMessageAndShiftRegister(byte *output, byte *reg, const byte *message, size_t length) +void CFB_DecryptionTemplate::CombineMessageAndShiftRegister(::byte *output, ::byte *reg, const ::byte *message, size_t length) { for (unsigned int i=0; i - void ProcessData(byte *outString, const byte *inString, size_t length); + void ProcessData(::byte *outString, const ::byte *inString, size_t length); //! \brief Resynchronize the cipher //! \param iv a byte array used to resynchronize the cipher //! \param length the size of the IV array - void Resynchronize(const byte *iv, int length=-1); + void Resynchronize(const ::byte *iv, int length=-1); //! \brief Provides number of ideal bytes to process //! \returns the ideal number of bytes to process @@ -334,12 +334,12 @@ public: typedef typename BASE::PolicyInterface PolicyInterface; protected: - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); unsigned int GetBufferByteSize(const PolicyInterface &policy) const {return policy.GetBytesPerIteration() * policy.GetIterationsToBuffer();} - inline byte * KeystreamBufferBegin() {return this->m_buffer.data();} - inline byte * KeystreamBufferEnd() {return (this->m_buffer.data() + this->m_buffer.size());} + inline ::byte * KeystreamBufferBegin() {return this->m_buffer.data();} + inline ::byte * KeystreamBufferEnd() {return (this->m_buffer.data() + this->m_buffer.size());} SecByteBlock m_buffer; size_t m_leftOver; @@ -365,7 +365,7 @@ public: //! \brief Access the feedback register //! \returns pointer to the first byte of the feedback register - virtual byte * GetRegisterBegin() =0; + virtual ::byte * GetRegisterBegin() =0; //! \brief TODO virtual void TransformRegister() =0; @@ -380,7 +380,7 @@ public: //! \param dir the direction of the cipher //! \param iterationCount the number of iterations to perform on the input //! \sa IsSelfInverting() and IsForwardTransformation() - virtual void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount) + virtual void Iterate(::byte *output, const ::byte *input, CipherDir dir, size_t iterationCount) {CRYPTOPP_UNUSED(output); CRYPTOPP_UNUSED(input); CRYPTOPP_UNUSED(dir); CRYPTOPP_UNUSED(iterationCount); CRYPTOPP_ASSERT(false); /*throw 0;*/ throw Exception(Exception::OTHER_ERROR, "SimpleKeyingInterface: unexpected error");} @@ -388,12 +388,12 @@ public: //! \param params set of NameValuePairs use to initialize this object //! \param key a byte array used to key the cipher //! \param length the size of the key array - virtual void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) =0; + virtual void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length) =0; //! \brief Resynchronize the cipher //! \param iv a byte array used to resynchronize the cipher //! \param length the size of the IV array - virtual void CipherResynchronize(const byte *iv, size_t length) + virtual void CipherResynchronize(const ::byte *iv, size_t length) {CRYPTOPP_UNUSED(iv); CRYPTOPP_UNUSED(length); throw NotImplemented("SimpleKeyingInterface: this object doesn't support resynchronization");} }; @@ -433,7 +433,7 @@ struct CRYPTOPP_NO_VTABLE CFB_CipherConcretePolicy : public BASE template struct RegisterOutput { - RegisterOutput(byte *output, const byte *input, CipherDir dir) + RegisterOutput(::byte *output, const ::byte *input, CipherDir dir) : m_output(output), m_input(input), m_dir(dir) {} //! \brief XOR feedback register with data @@ -476,8 +476,8 @@ struct CRYPTOPP_NO_VTABLE CFB_CipherConcretePolicy : public BASE return *this; } - byte *m_output; - const byte *m_input; + ::byte *m_output; + const ::byte *m_input; CipherDir m_dir; }; }; @@ -502,12 +502,12 @@ public: //! ChaCha20 chacha(key, keySize); //! chacha.ProcessData(cipher, plain, size); //! - void ProcessData(byte *outString, const byte *inString, size_t length); + void ProcessData(::byte *outString, const ::byte *inString, size_t length); //! \brief Resynchronize the cipher //! \param iv a byte array used to resynchronize the cipher //! \param length the size of the IV array - void Resynchronize(const byte *iv, int length=-1); + void Resynchronize(const ::byte *iv, int length=-1); //! \brief Provides number of ideal bytes to process //! \returns the ideal number of bytes to process @@ -538,9 +538,9 @@ public: typedef typename BASE::PolicyInterface PolicyInterface; protected: - virtual void CombineMessageAndShiftRegister(byte *output, byte *reg, const byte *message, size_t length) =0; + virtual void CombineMessageAndShiftRegister(::byte *output, ::byte *reg, const ::byte *message, size_t length) =0; - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms); size_t m_leftOver; }; @@ -552,7 +552,7 @@ template { bool IsForwardTransformation() const {return true;} - void CombineMessageAndShiftRegister(byte *output, byte *reg, const byte *message, size_t length); + void CombineMessageAndShiftRegister(::byte *output, ::byte *reg, const ::byte *message, size_t length); }; //! \class CFB_DecryptionTemplate @@ -562,7 +562,7 @@ template { bool IsForwardTransformation() const {return false;} - void CombineMessageAndShiftRegister(byte *output, byte *reg, const byte *message, size_t length); + void CombineMessageAndShiftRegister(::byte *output, ::byte *reg, const ::byte *message, size_t length); }; //! \class CFB_RequireFullDataBlocks @@ -592,20 +592,20 @@ public: //! \brief Construct a stream cipher //! \param key a byte array used to key the cipher //! \details This overload uses DEFAULT_KEYLENGTH - SymmetricCipherFinal(const byte *key) + SymmetricCipherFinal(const ::byte *key) {this->SetKey(key, this->DEFAULT_KEYLENGTH);} //! \brief Construct a stream cipher //! \param key a byte array used to key the cipher //! \param length the size of the key array - SymmetricCipherFinal(const byte *key, size_t length) + SymmetricCipherFinal(const ::byte *key, size_t length) {this->SetKey(key, length);} //! \brief Construct a stream cipher //! \param key a byte array used to key the cipher //! \param length the size of the key array //! \param iv a byte array used as an initialization vector - SymmetricCipherFinal(const byte *key, size_t length, const byte *iv) + SymmetricCipherFinal(const ::byte *key, size_t length, const ::byte *iv) {this->SetKeyWithIV(key, length, iv);} //! \brief Clone a SymmetricCipher diff --git a/tea.cpp b/tea.cpp index 3c0daa4c..9bebbf90 100644 --- a/tea.cpp +++ b/tea.cpp @@ -9,7 +9,7 @@ NAMESPACE_BEGIN(CryptoPP) static const word32 DELTA = 0x9e3779b9; typedef BlockGetAndPut Block; -void TEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms) +void TEA::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms) { AssertValidKeyLength(length); @@ -17,7 +17,7 @@ void TEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const m_limit = GetRoundsAndThrowIfInvalid(params, this) * DELTA; } -void TEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void TEA::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 y, z; Block::Get(inBlock)(y)(z); @@ -33,7 +33,7 @@ void TEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byt Block::Put(xorBlock, outBlock)(y)(z); } -void TEA::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void TEA::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 y, z; Block::Get(inBlock)(y)(z); @@ -49,7 +49,7 @@ void TEA::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byt Block::Put(xorBlock, outBlock)(y)(z); } -void XTEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms) +void XTEA::Base::UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms) { AssertValidKeyLength(length); @@ -57,7 +57,7 @@ void XTEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, cons m_limit = GetRoundsAndThrowIfInvalid(params, this) * DELTA; } -void XTEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void XTEA::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 y, z; Block::Get(inBlock)(y)(z); @@ -79,7 +79,7 @@ void XTEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by Block::Put(xorBlock, outBlock)(y)(z); } -void XTEA::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void XTEA::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 y, z; Block::Get(inBlock)(y)(z); @@ -103,7 +103,7 @@ void XTEA::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by #define MX ((z>>5^y<<2)+(y>>3^z<<4))^((sum^y)+(m_k[(p&3)^e]^z)) -void BTEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void BTEA::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { CRYPTOPP_UNUSED(xorBlock); CRYPTOPP_ASSERT(IsAlignedOn(inBlock,GetAlignmentOf())); @@ -133,7 +133,7 @@ void BTEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by ConditionalByteReverse(BIG_ENDIAN_ORDER, v, v, m_blockSize); } -void BTEA::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void BTEA::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { CRYPTOPP_UNUSED(xorBlock); CRYPTOPP_ASSERT(IsAlignedOn(inBlock,GetAlignmentOf())); diff --git a/tea.h b/tea.h index 200c8fbb..e171bdde 100644 --- a/tea.h +++ b/tea.h @@ -29,7 +29,7 @@ class TEA : public TEA_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: FixedSizeSecBlock m_k; @@ -41,7 +41,7 @@ class TEA : public TEA_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 @@ -49,7 +49,7 @@ class TEA : public TEA_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: @@ -77,7 +77,7 @@ class XTEA : public XTEA_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: FixedSizeSecBlock m_k; @@ -89,7 +89,7 @@ class XTEA : public XTEA_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 @@ -97,7 +97,7 @@ class XTEA : public XTEA_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: @@ -123,7 +123,7 @@ class BTEA : public BTEA_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public AlgorithmImpl, BTEA_Info>, public BTEA_Info { public: - void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) + void UncheckedSetKey(const ::byte *key, unsigned int length, const NameValuePairs ¶ms) { CRYPTOPP_UNUSED(length), CRYPTOPP_UNUSED(params); m_blockSize = params.GetIntValueWithDefault("BlockSize", 60*4); @@ -142,7 +142,7 @@ class BTEA : public BTEA_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 @@ -150,7 +150,7 @@ class BTEA : public BTEA_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: diff --git a/test.cpp b/test.cpp index a4e02bc5..3d0c14ce 100644 --- a/test.cpp +++ b/test.cpp @@ -153,7 +153,7 @@ int CRYPTOPP_API main(int argc, char *argv[]) // Fetch the SymmetricCipher interface, not the RandomNumberGenerator interface, to key the underlying cipher OFB_Mode::Encryption& aesg = dynamic_cast::Encryption&>(Test::GlobalRNG()); - aesg.SetKeyWithIV((byte *)seed.data(), 16, (byte *)seed.data()); + aesg.SetKeyWithIV((::byte *)seed.data(), 16, (::byte *)seed.data()); std::string command, executableName, macFilename; @@ -263,8 +263,8 @@ int CRYPTOPP_API main(int argc, char *argv[]) std::cerr << "Warning: certificate table (IMAGE_DIRECTORY_ENTRY_SECURITY) of target image is not empty.\n"; // find where to place computed MAC - byte mac[] = CRYPTOPP_DUMMY_DLL_MAC; - byte *found = std::search(buf.begin(), buf.end(), mac+0, mac+sizeof(mac)); + ::byte mac[] = CRYPTOPP_DUMMY_DLL_MAC; + ::byte *found = std::search(buf.begin(), buf.end(), mac+0, mac+sizeof(mac)); if (found == buf.end()) { std::cerr << "MAC placeholder not found. The MAC may already be placed.\n"; @@ -287,7 +287,7 @@ int CRYPTOPP_API main(int argc, char *argv[]) HexEncoder encoder; encoder.Put(mac, sizeof(mac)), encoder.MessageEnd(); hexMac.resize(static_cast(encoder.MaxRetrievable())); - encoder.Get(reinterpret_cast(&hexMac[0]), hexMac.size()); + encoder.Get(reinterpret_cast< ::byte*>(&hexMac[0]), hexMac.size()); // Report MAC and location std::cout << "Placing MAC " << hexMac << " in " << fname << " at file offset " << macPos; @@ -456,7 +456,7 @@ SecByteBlock HexDecodeString(const char *hex) void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed) { RandomPool randPool; - randPool.IncorporateEntropy((byte *)seed, strlen(seed)); + randPool.IncorporateEntropy((::byte *)seed, strlen(seed)); RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength); HexEncoder privFile(new FileSink(privFilename)); @@ -475,7 +475,7 @@ std::string RSAEncryptString(const char *pubFilename, const char *seed, const ch RSAES_OAEP_SHA_Encryptor pub(pubFile); RandomPool randPool; - randPool.IncorporateEntropy((byte *)seed, strlen(seed)); + randPool.IncorporateEntropy((::byte *)seed, strlen(seed)); std::string result; StringSource(message, true, new PK_EncryptorFilter(randPool, pub, new HexEncoder(new StringSink(result)))); @@ -561,7 +561,7 @@ void HmacFile(const char *hexKey, const char *file) { std::string decodedKey; StringSource(hexKey, true, new HexDecoder(new StringSink(decodedKey))); - mac.reset(new HMAC((const byte *)decodedKey.data(), decodedKey.size())); + mac.reset(new HMAC((const ::byte *)decodedKey.data(), decodedKey.size())); } FileSource(file, true, new HashFilter(*mac, new HexEncoder(new FileSink(std::cout)))); } @@ -579,7 +579,7 @@ std::string EncryptString(const char *instr, const char *passPhrase) std::string outstr; DefaultEncryptorWithMAC encryptor(passPhrase, new HexEncoder(new StringSink(outstr))); - encryptor.Put((byte *)instr, strlen(instr)); + encryptor.Put((::byte *)instr, strlen(instr)); encryptor.MessageEnd(); return outstr; @@ -590,7 +590,7 @@ std::string DecryptString(const char *instr, const char *passPhrase) std::string outstr; HexDecoder decryptor(new DefaultDecryptorWithMAC(passPhrase, new StringSink(outstr))); - decryptor.Put((byte *)instr, strlen(instr)); + decryptor.Put((::byte *)instr, strlen(instr)); decryptor.MessageEnd(); return outstr; @@ -613,7 +613,7 @@ void SecretShareFile(int threshold, int nShares, const char *filename, const cha throw InvalidArgument("SecretShareFile: " + IntToString(nShares) + " is not in range [1, 1000]"); RandomPool rng; - rng.IncorporateEntropy((byte *)seed, strlen(seed)); + rng.IncorporateEntropy((::byte *)seed, strlen(seed)); ChannelSwitch *channelSwitch = NULLPTR; FileSource source(filename, false, new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch)); @@ -625,13 +625,13 @@ void SecretShareFile(int threshold, int nShares, const char *filename, const cha for (int i=0; i(i); - fileSinks[i]->Put((const byte *)channel.data(), 4); + fileSinks[i]->Put((const ::byte *)channel.data(), 4); channelSwitch->AddRoute(channel, *fileSinks[i], DEFAULT_CHANNEL); } @@ -681,13 +681,13 @@ void InformationDisperseFile(int threshold, int nShares, const char *filename) for (int i=0; i(i); - fileSinks[i]->Put((const byte *)channel.data(), 4); + fileSinks[i]->Put((const ::byte *)channel.data(), 4); channelSwitch->AddRoute(channel, *fileSinks[i], DEFAULT_CHANNEL); } @@ -858,7 +858,7 @@ bool Validate(int alg, bool thorough, const char *seedInput) std::string seed = (seedInput ? seedInput : IntToString(std::time(NULLPTR))); seed.resize(16, ' '); OFB_Mode::Encryption& prng = dynamic_cast::Encryption&>(Test::GlobalRNG()); - prng.SetKeyWithIV((byte *)seed.data(), 16, (byte *)seed.data()); + prng.SetKeyWithIV((::byte *)seed.data(), 16, (::byte *)seed.data()); Test::g_testBegin = std::time(NULLPTR); PrintSeedAndThreads(seed); diff --git a/tftables.cpp b/tftables.cpp index 00bb6bac..f5d3560d 100644 --- a/tftables.cpp +++ b/tftables.cpp @@ -11,7 +11,7 @@ NAMESPACE_BEGIN(CryptoPP) -const byte Twofish::Base::q[2][256] = { +const ::byte Twofish::Base::q[2][256] = { 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30, diff --git a/threefish.cpp b/threefish.cpp index bb472851..0c754cb7 100644 --- a/threefish.cpp +++ b/threefish.cpp @@ -236,7 +236,7 @@ ANONYMOUS_NAMESPACE_END NAMESPACE_BEGIN(CryptoPP) -void Threefish::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs ¶ms) +void Threefish::Base::UncheckedSetKey(const ::byte *key, unsigned int keylen, const NameValuePairs ¶ms) { switch (keylen) { @@ -285,7 +285,7 @@ void Threefish::Base::UncheckedSetKey(const byte *key, unsigned int keylen, cons } } -void Threefish::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Threefish::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { switch(m_blocksize) { @@ -303,7 +303,7 @@ void Threefish::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBloc } } -void Threefish::Enc::ProcessAndXorBlock_256(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Threefish::Enc::ProcessAndXorBlock_256(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word64 &G0=m_wspace[0], &G1=m_wspace[1], &G2=m_wspace[2], &G3=m_wspace[3]; @@ -324,7 +324,7 @@ void Threefish::Enc::ProcessAndXorBlock_256(const byte *inBlock, const byte *xor oblk(G0)(G1)(G2)(G3); } -void Threefish::Enc::ProcessAndXorBlock_512(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Threefish::Enc::ProcessAndXorBlock_512(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word64 &G0=m_wspace[0], &G1=m_wspace[1], &G2=m_wspace[2], &G3=m_wspace[3]; word64 &G4=m_wspace[4], &G5=m_wspace[5], &G6=m_wspace[6], &G7=m_wspace[7]; @@ -348,7 +348,7 @@ void Threefish::Enc::ProcessAndXorBlock_512(const byte *inBlock, const byte *xor oblk(G0)(G1)(G2)(G3)(G4)(G5)(G6)(G7); } -void Threefish::Enc::ProcessAndXorBlock_1024(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Threefish::Enc::ProcessAndXorBlock_1024(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word64 &G0=m_wspace[0], &G1=m_wspace[1], &G2=m_wspace[2], &G3=m_wspace[3]; word64 &G4=m_wspace[4], &G5=m_wspace[5], &G6=m_wspace[6], &G7=m_wspace[7]; @@ -375,7 +375,7 @@ void Threefish::Enc::ProcessAndXorBlock_1024(const byte *inBlock, const byte *xo oblk(G0)(G1)(G2)(G3)(G4)(G5)(G6)(G7)(G8)(G9)(G10)(G11)(G12)(G13)(G14)(G15); } -void Threefish::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Threefish::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { switch(m_blocksize) { @@ -393,7 +393,7 @@ void Threefish::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBloc } } -void Threefish::Dec::ProcessAndXorBlock_256(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Threefish::Dec::ProcessAndXorBlock_256(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word64 &G0=m_wspace[0], &G1=m_wspace[1], &G2=m_wspace[2], &G3=m_wspace[3]; @@ -414,7 +414,7 @@ void Threefish::Dec::ProcessAndXorBlock_256(const byte *inBlock, const byte *xor oblk(G0)(G1)(G2)(G3); } -void Threefish::Dec::ProcessAndXorBlock_512(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Threefish::Dec::ProcessAndXorBlock_512(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word64 &G0=m_wspace[0], &G1=m_wspace[1], &G2=m_wspace[2], &G3=m_wspace[3]; word64 &G4=m_wspace[4], &G5=m_wspace[5], &G6=m_wspace[6], &G7=m_wspace[7]; @@ -437,7 +437,7 @@ void Threefish::Dec::ProcessAndXorBlock_512(const byte *inBlock, const byte *xor oblk(G0)(G1)(G2)(G3)(G4)(G5)(G6)(G7); } -void Threefish::Dec::ProcessAndXorBlock_1024(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Threefish::Dec::ProcessAndXorBlock_1024(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word64 &G0=m_wspace[0], &G1=m_wspace[1], &G2=m_wspace[2], &G3=m_wspace[3]; word64 &G4=m_wspace[4], &G5=m_wspace[5], &G6=m_wspace[6], &G7=m_wspace[7]; diff --git a/threefish.h b/threefish.h index 087e52a0..809b8f37 100644 --- a/threefish.h +++ b/threefish.h @@ -77,7 +77,7 @@ public: } protected: - void UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *key, unsigned int keylen, const NameValuePairs ¶ms); typedef SecBlock > AlignedSecBlock64; mutable AlignedSecBlock64 m_wspace; // workspace @@ -88,21 +88,21 @@ public: class CRYPTOPP_NO_VTABLE Enc : public Base { protected: - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; - void ProcessAndXorBlock_256(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; - void ProcessAndXorBlock_512(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; - void ProcessAndXorBlock_1024(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void ProcessAndXorBlock_256(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; + void ProcessAndXorBlock_512(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; + void ProcessAndXorBlock_1024(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; }; class CRYPTOPP_NO_VTABLE Dec : public Base { protected: - void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; - void ProcessAndXorBlock_256(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; - void ProcessAndXorBlock_512(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; - void ProcessAndXorBlock_1024(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; + void ProcessAndXorBlock_256(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; + void ProcessAndXorBlock_512(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; + void ProcessAndXorBlock_1024(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const; }; public: diff --git a/tiger.cpp b/tiger.cpp index b048c9a6..37400e38 100644 --- a/tiger.cpp +++ b/tiger.cpp @@ -23,7 +23,7 @@ void Tiger::InitState(HashWordType *state) state[2] = W64LIT(0xF096A5B4C3B2E187); } -void Tiger::TruncatedFinal(byte *hash, size_t size) +void Tiger::TruncatedFinal(::byte *hash, size_t size) { ThrowIfInvalidTruncatedSize(size); diff --git a/tiger.h b/tiger.h index aaca69a0..6d1bde31 100644 --- a/tiger.h +++ b/tiger.h @@ -18,7 +18,7 @@ class Tiger : public IteratedHashWithStaticTransform Block; -void Twofish::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Twofish::Enc::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 x, y, a, b, c, d; @@ -137,7 +137,7 @@ void Twofish::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, Block::Put(xorBlock, outBlock)(c)(d)(a)(b); } -void Twofish::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const +void Twofish::Dec::ProcessAndXorBlock(const ::byte *inBlock, const ::byte *xorBlock, ::byte *outBlock) const { word32 x, y, a, b, c, d; diff --git a/twofish.h b/twofish.h index d6940f04..05216841 100644 --- a/twofish.h +++ b/twofish.h @@ -26,13 +26,13 @@ class Twofish : public Twofish_Info, public BlockCipherDocumentation class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl { public: - void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); + void UncheckedSetKey(const ::byte *userKey, unsigned int length, const NameValuePairs ¶ms); protected: static word32 h0(word32 x, const word32 *key, unsigned int kLen); static word32 h(word32 x, const word32 *key, unsigned int kLen); - static const byte q[2][256]; + static const ::byte q[2][256]; static const word32 mds[4][256]; FixedSizeSecBlock m_k; @@ -42,13 +42,13 @@ class Twofish : public Twofish_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 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: diff --git a/validat1.cpp b/validat1.cpp index c10efdf4..b6dac4a6 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -211,13 +211,13 @@ bool TestSettings() std::cout << "\nTesting Settings...\n\n"; word32 w; - const byte s[] = "\x01\x02\x03\x04"; + const ::byte s[] = "\x01\x02\x03\x04"; #if (_MSC_FULL_VER >= 140050727) std::copy(s, s+4, - stdext::make_checked_array_iterator(reinterpret_cast(&w), sizeof(w))); + stdext::make_checked_array_iterator(reinterpret_cast< ::byte*>(&w), sizeof(w))); #else - std::copy(s, s+4, reinterpret_cast(&w)); + std::copy(s, s+4, reinterpret_cast< ::byte*>(&w)); #endif if (w == 0x04030201L) @@ -274,14 +274,14 @@ bool TestSettings() std::cout << "passed: CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS is not defined. Will restrict to aligned data access.\n"; #endif - if (sizeof(byte) == 1) + if (sizeof(::byte) == 1) std::cout << "passed: "; else { std::cout << "FAILED: "; pass = false; } - std::cout << "sizeof(byte) == " << sizeof(byte) << std::endl; + std::cout << "sizeof(::byte) == " << sizeof(::byte) << std::endl; if (sizeof(word16) == 2) std::cout << "passed: "; @@ -467,11 +467,11 @@ bool TestOS_RNG() (void)prng.AlgorithmName(); word32 result = prng.GenerateWord32(); result = prng.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff)); - prng.GenerateBlock(reinterpret_cast(&result), 4); - prng.GenerateBlock(reinterpret_cast(&result), 3); - prng.GenerateBlock(reinterpret_cast(&result), 2); - prng.GenerateBlock(reinterpret_cast(&result), 1); - prng.GenerateBlock(reinterpret_cast(&result), 0); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 4); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 3); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 2); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 1); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 0); pass = true; } catch (const Exception&) @@ -517,11 +517,11 @@ bool TestOS_RNG() (void)prng.AlgorithmName(); word32 result = prng.GenerateWord32(); result = prng.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff)); - prng.GenerateBlock(reinterpret_cast(&result), 4); - prng.GenerateBlock(reinterpret_cast(&result), 3); - prng.GenerateBlock(reinterpret_cast(&result), 2); - prng.GenerateBlock(reinterpret_cast(&result), 1); - prng.GenerateBlock(reinterpret_cast(&result), 0); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 4); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 3); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 2); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 1); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 0); pass = true; } catch (const Exception&) @@ -612,10 +612,10 @@ bool TestRandomPool() (void)prng.AlgorithmName(); // "unknown" word32 result = prng.GenerateWord32(); result = prng.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff)); - prng.GenerateBlock(reinterpret_cast(&result), 4); - prng.GenerateBlock(reinterpret_cast(&result), 3); - prng.GenerateBlock(reinterpret_cast(&result), 2); - prng.GenerateBlock(reinterpret_cast(&result), 1); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 4); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 3); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 2); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 1); } catch (const Exception&) { @@ -700,10 +700,10 @@ bool TestRandomPool() (void)prng.AlgorithmName(); // "unknown" word32 result = prng.GenerateWord32(); result = prng.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff)); - prng.GenerateBlock(reinterpret_cast(&result), 4); - prng.GenerateBlock(reinterpret_cast(&result), 3); - prng.GenerateBlock(reinterpret_cast(&result), 2); - prng.GenerateBlock(reinterpret_cast(&result), 1); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 4); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 3); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 2); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 1); } catch (const Exception&) { @@ -796,10 +796,10 @@ bool TestAutoSeededX917() (void)prng.AlgorithmName(); // "unknown" word32 result = prng.GenerateWord32(); result = prng.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff)); - prng.GenerateBlock(reinterpret_cast(&result), 4); - prng.GenerateBlock(reinterpret_cast(&result), 3); - prng.GenerateBlock(reinterpret_cast(&result), 2); - prng.GenerateBlock(reinterpret_cast(&result), 1); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 4); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 3); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 2); + prng.GenerateBlock(reinterpret_cast< ::byte*>(&result), 1); } catch (const Exception&) { @@ -1006,10 +1006,10 @@ bool TestRDRAND() word32 result = rdrand.GenerateWord32(); result = rdrand.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff)); - rdrand.GenerateBlock(reinterpret_cast(&result), 4); - rdrand.GenerateBlock(reinterpret_cast(&result), 3); - rdrand.GenerateBlock(reinterpret_cast(&result), 2); - rdrand.GenerateBlock(reinterpret_cast(&result), 1); + rdrand.GenerateBlock(reinterpret_cast< ::byte*>(&result), 4); + rdrand.GenerateBlock(reinterpret_cast< ::byte*>(&result), 3); + rdrand.GenerateBlock(reinterpret_cast< ::byte*>(&result), 2); + rdrand.GenerateBlock(reinterpret_cast< ::byte*>(&result), 1); fail = false; } catch (const Exception&) @@ -1108,10 +1108,10 @@ bool TestRDSEED() word32 result = rdseed.GenerateWord32(); result = rdseed.GenerateWord32((result & 0xff), 0xffffffff - (result & 0xff)); - rdseed.GenerateBlock(reinterpret_cast(&result), 4); - rdseed.GenerateBlock(reinterpret_cast(&result), 3); - rdseed.GenerateBlock(reinterpret_cast(&result), 2); - rdseed.GenerateBlock(reinterpret_cast(&result), 1); + rdseed.GenerateBlock(reinterpret_cast< ::byte*>(&result), 4); + rdseed.GenerateBlock(reinterpret_cast< ::byte*>(&result), 3); + rdseed.GenerateBlock(reinterpret_cast< ::byte*>(&result), 2); + rdseed.GenerateBlock(reinterpret_cast< ::byte*>(&result), 1); fail = false; } catch (const Exception&) @@ -1145,9 +1145,9 @@ bool ValidateHashDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 0], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x16\x10\xb8\x28\xcc\xd2\x7d\xe0\x8c\xee\xa0\x32\xa2\x0e\x92\x08"; - const byte entropy2[] = "\x72\xd2\x8c\x90\x8e\xda\xf9\xa4\xd1\xe5\x26\xd8\xf2\xde\xd5\x44"; - const byte nonce[] = "\x49\x2c\xf1\x70\x92\x42\xf6\xb5"; + const ::byte entropy1[] = "\x16\x10\xb8\x28\xcc\xd2\x7d\xe0\x8c\xee\xa0\x32\xa2\x0e\x92\x08"; + const ::byte entropy2[] = "\x72\xd2\x8c\x90\x8e\xda\xf9\xa4\xd1\xe5\x26\xd8\xf2\xde\xd5\x44"; + const ::byte nonce[] = "\x49\x2c\xf1\x70\x92\x42\xf6\xb5"; Hash_DRBG drbg(entropy1, 16, nonce, 8); drbg.IncorporateEntropy(entropy2, 16); @@ -1156,7 +1156,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(result, result.size()); drbg.GenerateBlock(result, result.size()); - const byte expected[] = "\x56\xF3\x3D\x4F\xDB\xB9\xA5\xB6\x4D\x26\x23\x44\x97\xE9\xDC\xB8\x77\x98\xC6\x8D" + const ::byte expected[] = "\x56\xF3\x3D\x4F\xDB\xB9\xA5\xB6\x4D\x26\x23\x44\x97\xE9\xDC\xB8\x77\x98\xC6\x8D" "\x08\xF7\xC4\x11\x99\xD4\xBD\xDF\x97\xEB\xBF\x6C\xB5\x55\x0E\x5D\x14\x9F\xF4\xD5" "\xBD\x0F\x05\xF2\x5A\x69\x88\xC1\x74\x36\x39\x62\x27\x18\x4A\xF8\x4A\x56\x43\x35" "\x65\x8E\x2F\x85\x72\xBE\xA3\x33\xEE\xE2\xAB\xFF\x22\xFF\xA6\xDE\x3E\x22\xAC\xA2"; @@ -1170,9 +1170,9 @@ bool ValidateHashDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 0], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x55\x08\x75\xb7\x4e\xc1\x1f\x90\x67\x78\xa3\x1a\x37\xa3\x29\xfd"; - const byte entropy2[] = "\x96\xc6\x39\xec\x14\x9f\x6b\x28\xe2\x79\x3b\xb9\x37\x9e\x60\x67"; - const byte nonce[] = "\x08\xdd\x8c\xd3\x5b\xfa\x00\x94"; + const ::byte entropy1[] = "\x55\x08\x75\xb7\x4e\xc1\x1f\x90\x67\x78\xa3\x1a\x37\xa3\x29\xfd"; + const ::byte entropy2[] = "\x96\xc6\x39\xec\x14\x9f\x6b\x28\xe2\x79\x3b\xb9\x37\x9e\x60\x67"; + const ::byte nonce[] = "\x08\xdd\x8c\xd3\x5b\xfa\x00\x94"; Hash_DRBG drbg(entropy1, 16, nonce, 8); drbg.IncorporateEntropy(entropy2, 16); @@ -1181,7 +1181,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(result, result.size()); drbg.GenerateBlock(result, result.size()); - const byte expected[] = "\xEE\x44\xC6\xCF\x2C\x0C\x73\xA8\xAC\x4C\xA5\x6C\x0E\x71\x2C\xA5\x50\x9A\x19\x5D" + const ::byte expected[] = "\xEE\x44\xC6\xCF\x2C\x0C\x73\xA8\xAC\x4C\xA5\x6C\x0E\x71\x2C\xA5\x50\x9A\x19\x5D" "\xE4\x5B\x8D\x2B\xC9\x40\xA7\xDB\x66\xC3\xEB\x2A\xA1\xBD\xB4\xDD\x76\x85\x12\x45" "\x80\x2E\x68\x05\x4A\xAB\xA8\x7C\xD6\x3A\xD3\xE5\xC9\x7C\x06\xE7\xA3\x9F\xF6\xF9" "\x8E\xB3\xD9\x72\xD4\x11\x35\xE5\xE7\x46\x1B\x49\x9C\x56\x45\x6A\xBE\x7F\x77\xD4"; @@ -1195,12 +1195,12 @@ bool ValidateHashDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 0], [AdditionalInputLen = 128], [ReturnedBitsLen = 640] - const byte entropy1[] = "\xd9\xba\xb5\xce\xdc\xa9\x6f\x61\x78\xd6\x45\x09\xa0\xdf\xdc\x5e"; - const byte entropy2[] = "\xc6\xba\xd0\x74\xc5\x90\x67\x86\xf5\xe1\xf3\x20\x99\xf5\xb4\x91"; - const byte nonce[] = "\xda\xd8\x98\x94\x14\x45\x0e\x01"; - const byte additional1[] = "\x3e\x6b\xf4\x6f\x4d\xaa\x38\x25\xd7\x19\x4e\x69\x4e\x77\x52\xf7"; - const byte additional2[] = "\x04\xfa\x28\x95\xaa\x5a\x6f\x8c\x57\x43\x34\x3b\x80\x5e\x5e\xa4"; - const byte additional3[] = "\xdf\x5d\xc4\x59\xdf\xf0\x2a\xa2\xf0\x52\xd7\x21\xec\x60\x72\x30"; + const ::byte entropy1[] = "\xd9\xba\xb5\xce\xdc\xa9\x6f\x61\x78\xd6\x45\x09\xa0\xdf\xdc\x5e"; + const ::byte entropy2[] = "\xc6\xba\xd0\x74\xc5\x90\x67\x86\xf5\xe1\xf3\x20\x99\xf5\xb4\x91"; + const ::byte nonce[] = "\xda\xd8\x98\x94\x14\x45\x0e\x01"; + const ::byte additional1[] = "\x3e\x6b\xf4\x6f\x4d\xaa\x38\x25\xd7\x19\x4e\x69\x4e\x77\x52\xf7"; + const ::byte additional2[] = "\x04\xfa\x28\x95\xaa\x5a\x6f\x8c\x57\x43\x34\x3b\x80\x5e\x5e\xa4"; + const ::byte additional3[] = "\xdf\x5d\xc4\x59\xdf\xf0\x2a\xa2\xf0\x52\xd7\x21\xec\x60\x72\x30"; Hash_DRBG drbg(entropy1, 16, nonce, 8); drbg.IncorporateEntropy(entropy2, 16, additional1, 16); @@ -1209,7 +1209,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(additional2, 16, result, result.size()); drbg.GenerateBlock(additional3, 16, result, result.size()); - const byte expected[] = "\xC4\x8B\x89\xF9\xDA\x3F\x74\x82\x45\x55\x5D\x5D\x03\x3B\x69\x3D\xD7\x1A\x4D\xF5" + const ::byte expected[] = "\xC4\x8B\x89\xF9\xDA\x3F\x74\x82\x45\x55\x5D\x5D\x03\x3B\x69\x3D\xD7\x1A\x4D\xF5" "\x69\x02\x05\xCE\xFC\xD7\x20\x11\x3C\xC2\x4E\x09\x89\x36\xFF\x5E\x77\xB5\x41\x53" "\x58\x70\xB3\x39\x46\x8C\xDD\x8D\x6F\xAF\x8C\x56\x16\x3A\x70\x0A\x75\xB2\x3E\x59" "\x9B\x5A\xEC\xF1\x6F\x3B\xAF\x6D\x5F\x24\x19\x97\x1F\x24\xF4\x46\x72\x0F\xEA\xBE"; @@ -1223,12 +1223,12 @@ bool ValidateHashDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 0], [AdditionalInputLen = 128], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x28\x00\x0f\xbf\xf0\x57\x22\xc8\x89\x93\x06\xc2\x9b\x50\x78\x0a"; - const byte entropy2[] = "\xd9\x95\x8e\x8c\x08\xaf\x5a\x41\x0e\x91\x9b\xdf\x40\x8e\x5a\x0a"; - const byte nonce[] = "\x11\x2f\x6e\x20\xc0\x29\xed\x3f"; - const byte additional1[] = "\x91\x1d\x96\x5b\x6e\x77\xa9\x6c\xfe\x3f\xf2\xd2\xe3\x0e\x2a\x86"; - const byte additional2[] = "\xcd\x44\xd9\x96\xab\x05\xef\xe8\x27\xd3\x65\x83\xf1\x43\x18\x2c"; - const byte additional3[] = "\x9f\x6a\x31\x82\x12\x18\x4e\x70\xaf\x5d\x00\x14\x1f\x42\x82\xf6"; + const ::byte entropy1[] = "\x28\x00\x0f\xbf\xf0\x57\x22\xc8\x89\x93\x06\xc2\x9b\x50\x78\x0a"; + const ::byte entropy2[] = "\xd9\x95\x8e\x8c\x08\xaf\x5a\x41\x0e\x91\x9b\xdf\x40\x8e\x5a\x0a"; + const ::byte nonce[] = "\x11\x2f\x6e\x20\xc0\x29\xed\x3f"; + const ::byte additional1[] = "\x91\x1d\x96\x5b\x6e\x77\xa9\x6c\xfe\x3f\xf2\xd2\xe3\x0e\x2a\x86"; + const ::byte additional2[] = "\xcd\x44\xd9\x96\xab\x05\xef\xe8\x27\xd3\x65\x83\xf1\x43\x18\x2c"; + const ::byte additional3[] = "\x9f\x6a\x31\x82\x12\x18\x4e\x70\xaf\x5d\x00\x14\x1f\x42\x82\xf6"; Hash_DRBG drbg(entropy1, 16, nonce, 8); drbg.IncorporateEntropy(entropy2, 16, additional1, 16); @@ -1237,7 +1237,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(additional2, 16, result, result.size()); drbg.GenerateBlock(additional3, 16, result, result.size()); - const byte expected[] = "\x54\x61\x65\x92\x1E\x71\x4A\xD1\x39\x02\x2F\x97\xD2\x65\x3F\x0D\x47\x69\xB1\x4A" + const ::byte expected[] = "\x54\x61\x65\x92\x1E\x71\x4A\xD1\x39\x02\x2F\x97\xD2\x65\x3F\x0D\x47\x69\xB1\x4A" "\x3E\x6E\xEF\xA1\xA0\x16\xD6\x9E\xA9\x7F\x51\xD5\x81\xDC\xAA\xCF\x66\xF9\xB1\xE8" "\x06\x94\x41\xD6\xB5\xC5\x44\x60\x54\x07\xE8\xE7\xDC\x1C\xD8\xE4\x70\xAD\x84\x77" "\x5A\x65\x31\xBE\xE0\xFC\x81\x36\xE2\x8F\x0B\xFE\xEB\xE1\x98\x62\x7E\x98\xE0\xC1"; @@ -1251,10 +1251,10 @@ bool ValidateHashDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 128], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x0e\xd5\x4c\xef\x44\x5c\x61\x7d\x58\x86\xe0\x34\xc0\x97\x36\xd4"; - const byte entropy2[] = "\x0b\x90\x27\xb8\x01\xe7\xf7\x2e\xe6\xec\x50\x2b\x8b\x6b\xd7\x11"; - const byte nonce[] = "\x2c\x8b\x07\x13\x55\x6c\x91\x6f"; - const byte personalization[] = "\xf3\x37\x8e\xa1\x45\x34\x30\x41\x12\xe0\xee\x57\xe9\xb3\x4a\x4b"; + const ::byte entropy1[] = "\x0e\xd5\x4c\xef\x44\x5c\x61\x7d\x58\x86\xe0\x34\xc0\x97\x36\xd4"; + const ::byte entropy2[] = "\x0b\x90\x27\xb8\x01\xe7\xf7\x2e\xe6\xec\x50\x2b\x8b\x6b\xd7\x11"; + const ::byte nonce[] = "\x2c\x8b\x07\x13\x55\x6c\x91\x6f"; + const ::byte personalization[] = "\xf3\x37\x8e\xa1\x45\x34\x30\x41\x12\xe0\xee\x57\xe9\xb3\x4a\x4b"; Hash_DRBG drbg(entropy1, 16, nonce, 8, personalization, 16); drbg.IncorporateEntropy(entropy2, 16); @@ -1263,7 +1263,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(result, result.size()); drbg.GenerateBlock(result, result.size()); - const byte expected[] = "\x55\x37\x0E\xD4\xB7\xCA\xA4\xBB\x67\x3A\x0F\x58\x40\xB3\x9F\x76\x4E\xDA\xD2\x85" + const ::byte expected[] = "\x55\x37\x0E\xD4\xB7\xCA\xA4\xBB\x67\x3A\x0F\x58\x40\xB3\x9F\x76\x4E\xDA\xD2\x85" "\xD5\x6F\x01\x8F\x2D\xA7\x54\x4B\x0E\x66\x39\x62\x35\x96\x1D\xB7\xF6\xDA\xFB\x30" "\xB6\xC5\x68\xD8\x40\x6E\x2B\xD4\x3D\x23\xEB\x0F\x10\xBA\x5F\x24\x9C\xC9\xE9\x4A" "\xD3\xA5\xF1\xDF\xA4\xF2\xB4\x80\x40\x91\xED\x8C\xD6\x6D\xE7\xB7\x53\xB2\x09\xD5"; @@ -1277,10 +1277,10 @@ bool ValidateHashDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 128], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x8f\x2a\x33\x9f\x5f\x45\x21\x30\xa4\x57\xa9\x6f\xcb\xe2\xe6\x36"; - const byte entropy2[] = "\x1f\xff\x9e\x4f\x4d\x66\x3a\x1f\x9e\x85\x4a\x15\x7d\xad\x97\xe0"; - const byte nonce[] = "\x0e\xd0\xe9\xa5\xa4\x54\x8a\xd0"; - const byte personalization[] = "\x45\xe4\xb3\xe2\x63\x87\x62\x57\x2c\x99\xe4\x03\x45\xd6\x32\x6f"; + const ::byte entropy1[] = "\x8f\x2a\x33\x9f\x5f\x45\x21\x30\xa4\x57\xa9\x6f\xcb\xe2\xe6\x36"; + const ::byte entropy2[] = "\x1f\xff\x9e\x4f\x4d\x66\x3a\x1f\x9e\x85\x4a\x15\x7d\xad\x97\xe0"; + const ::byte nonce[] = "\x0e\xd0\xe9\xa5\xa4\x54\x8a\xd0"; + const ::byte personalization[] = "\x45\xe4\xb3\xe2\x63\x87\x62\x57\x2c\x99\xe4\x03\x45\xd6\x32\x6f"; Hash_DRBG drbg(entropy1, 16, nonce, 8, personalization, 16); drbg.IncorporateEntropy(entropy2, 16); @@ -1289,7 +1289,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(result, result.size()); drbg.GenerateBlock(result, result.size()); - const byte expected[] = "\x4F\xE8\x96\x41\xF8\xD3\x95\xC4\x43\x6E\xFB\xF8\x05\x75\xA7\x69\x74\x6E\x0C\x5F" + const ::byte expected[] = "\x4F\xE8\x96\x41\xF8\xD3\x95\xC4\x43\x6E\xFB\xF8\x05\x75\xA7\x69\x74\x6E\x0C\x5F" "\x54\x14\x35\xB4\xE6\xA6\xB3\x40\x7C\xA2\xC4\x42\xA2\x2F\x66\x28\x28\xCF\x4A\xA8" "\xDC\x16\xBC\x5F\x69\xE5\xBB\x05\xD1\x43\x8F\x80\xAB\xC5\x8F\x9C\x3F\x75\x57\xEB" "\x44\x0D\xF5\x0C\xF4\x95\x23\x94\x67\x11\x55\x98\x14\x43\xFF\x13\x14\x85\x5A\xBC"; @@ -1303,13 +1303,13 @@ bool ValidateHashDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 128], [AdditionalInputLen = 16], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x48\xa1\xa9\x7c\xcc\x49\xd7\xcc\xf6\xe3\x78\xa2\xf1\x6b\x0f\xcd"; - const byte entropy2[] = "\xba\x5d\xa6\x79\x12\x37\x24\x3f\xea\x60\x50\xf5\xb9\x9e\xcd\xf5"; - const byte nonce[] = "\xb0\x91\xd2\xec\x12\xa8\x39\xfe"; - const byte personalization[] = "\x3d\xc1\x6c\x1a\xdd\x9c\xac\x4e\xbb\xb0\xb8\x89\xe4\x3b\x9e\x12"; - const byte additional1[] = "\xd1\x23\xe3\x8e\x4c\x97\xe8\x29\x94\xa9\x71\x7a\xc6\xf1\x7c\x08"; - const byte additional2[] = "\x80\x0b\xed\x97\x29\xcf\xad\xe6\x68\x0d\xfe\x53\xba\x0c\x1e\x28"; - const byte additional3[] = "\x25\x1e\x66\xb9\xe3\x85\xac\x1c\x17\xfb\x77\x1b\x5d\xc7\x6c\xf2"; + const ::byte entropy1[] = "\x48\xa1\xa9\x7c\xcc\x49\xd7\xcc\xf6\xe3\x78\xa2\xf1\x6b\x0f\xcd"; + const ::byte entropy2[] = "\xba\x5d\xa6\x79\x12\x37\x24\x3f\xea\x60\x50\xf5\xb9\x9e\xcd\xf5"; + const ::byte nonce[] = "\xb0\x91\xd2\xec\x12\xa8\x39\xfe"; + const ::byte personalization[] = "\x3d\xc1\x6c\x1a\xdd\x9c\xac\x4e\xbb\xb0\xb8\x89\xe4\x3b\x9e\x12"; + const ::byte additional1[] = "\xd1\x23\xe3\x8e\x4c\x97\xe8\x29\x94\xa9\x71\x7a\xc6\xf1\x7c\x08"; + const ::byte additional2[] = "\x80\x0b\xed\x97\x29\xcf\xad\xe6\x68\x0d\xfe\x53\xba\x0c\x1e\x28"; + const ::byte additional3[] = "\x25\x1e\x66\xb9\xe3\x85\xac\x1c\x17\xfb\x77\x1b\x5d\xc7\x6c\xf2"; Hash_DRBG drbg(entropy1, 16, nonce, 8, personalization, 16); drbg.IncorporateEntropy(entropy2, 16, additional1, 16); @@ -1318,7 +1318,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(additional2, 16, result, result.size()); drbg.GenerateBlock(additional3, 16, result, result.size()); - const byte expected[] = "\xA1\xB2\xEE\x86\xA0\xF1\xDA\xB7\x93\x83\x13\x3A\x62\x27\x99\x08\x95\x3A\x1C\x9A" + const ::byte expected[] = "\xA1\xB2\xEE\x86\xA0\xF1\xDA\xB7\x93\x83\x13\x3A\x62\x27\x99\x08\x95\x3A\x1C\x9A" "\x98\x77\x60\x12\x11\x19\xCC\x78\xB8\x51\x2B\xD5\x37\xA1\x9D\xB9\x73\xCA\x39\x7A" "\xDD\x92\x33\x78\x6D\x5D\x41\xFF\xFA\xE9\x80\x59\x04\x85\x21\xE2\x52\x84\xBC\x6F" "\xDB\x97\xF3\x4E\x6A\x12\x7A\xCD\x41\x0F\x50\x68\x28\x46\xBE\x56\x9E\x9A\x6B\xC8"; @@ -1332,13 +1332,13 @@ bool ValidateHashDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 128], [AdditionalInputLen = 16], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x3b\xcb\xa8\x3b\x6d\xfb\x06\x79\x80\xef\xc3\x1e\xd2\x9e\x68\x57"; - const byte entropy2[] = "\x2f\xc9\x87\x49\x19\xcb\x52\x4a\x5b\xac\xf0\xcd\x96\x4e\xf8\x6e"; - const byte nonce[] = "\x23\xfe\x20\x9f\xac\x70\x45\xde"; - const byte personalization[] = "\xf2\x25\xf4\xd9\x6b\x9c\xab\x49\x1e\xab\x18\x14\xb2\x5e\x78\xef"; - const byte additional1[] = "\x57\x5b\x9a\x11\x32\x7a\xab\x89\x08\xfe\x46\x11\x9a\xed\x14\x5d"; - const byte additional2[] = "\x5d\x19\xcd\xed\xb7\xe3\x44\x66\x8e\x11\x42\x96\xa0\x38\xb1\x7f"; - const byte additional3[] = "\x2b\xaf\xa0\x15\xed\xdd\x5c\x76\x32\x75\x34\x35\xd1\x37\x72\xfb"; + const ::byte entropy1[] = "\x3b\xcb\xa8\x3b\x6d\xfb\x06\x79\x80\xef\xc3\x1e\xd2\x9e\x68\x57"; + const ::byte entropy2[] = "\x2f\xc9\x87\x49\x19\xcb\x52\x4a\x5b\xac\xf0\xcd\x96\x4e\xf8\x6e"; + const ::byte nonce[] = "\x23\xfe\x20\x9f\xac\x70\x45\xde"; + const ::byte personalization[] = "\xf2\x25\xf4\xd9\x6b\x9c\xab\x49\x1e\xab\x18\x14\xb2\x5e\x78\xef"; + const ::byte additional1[] = "\x57\x5b\x9a\x11\x32\x7a\xab\x89\x08\xfe\x46\x11\x9a\xed\x14\x5d"; + const ::byte additional2[] = "\x5d\x19\xcd\xed\xb7\xe3\x44\x66\x8e\x11\x42\x96\xa0\x38\xb1\x7f"; + const ::byte additional3[] = "\x2b\xaf\xa0\x15\xed\xdd\x5c\x76\x32\x75\x34\x35\xd1\x37\x72\xfb"; Hash_DRBG drbg(entropy1, 16, nonce, 8, personalization, 16); drbg.IncorporateEntropy(entropy2, 16, additional1, 16); @@ -1347,7 +1347,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(additional2, 16, result, result.size()); drbg.GenerateBlock(additional3, 16, result, result.size()); - const byte expected[] = "\x1D\x12\xEB\x6D\x42\x60\xBD\xFB\xA7\x99\xB8\x53\xCC\x6F\x19\xB1\x64\xFE\x2F\x55" + const ::byte expected[] = "\x1D\x12\xEB\x6D\x42\x60\xBD\xFB\xA7\x99\xB8\x53\xCC\x6F\x19\xB1\x64\xFE\x2F\x55" "\xBA\xA2\x1C\x89\xD4\xD0\xE9\xB4\xBA\xD4\xE5\xF8\xC5\x30\x06\x41\xBA\xC4\x3D\x2B" "\x73\x91\x27\xE9\x31\xC0\x55\x55\x11\xE8\xB6\x57\x02\x0D\xCE\x90\xAC\x31\xB9\x00" "\x31\xC1\xD4\x4F\xE7\x12\x3B\xCC\x85\x16\x2F\x12\x8F\xB2\xDF\x84\x4E\xF7\x06\xBE"; @@ -1361,13 +1361,13 @@ bool ValidateHashDRBG() { // [SHA-256], [PredictionResistance = False], [EntropyInputLen = 256], [NonceLen = 128] // [PersonalizationStringLen = 256], [AdditionalInputLen = 256], [ReturnedBitsLen = 1024] - const byte entropy1[] = "\xf0\x5b\xab\x56\xc7\xac\x6e\xeb\x31\xa0\xcf\x8a\x8a\x06\x2a\x49\x17\x9a\xcf\x3c\x5b\x20\x4d\x60\xdd\x7a\x3e\xb7\x8f\x5d\x8e\x3b"; - const byte entropy2[] = "\x72\xd4\x02\xa2\x59\x7b\x98\xa3\xb8\xf5\x0b\x71\x6c\x63\xc6\xdb\xa7\x3a\x07\xe6\x54\x89\x06\x3f\x02\xc5\x32\xf5\xda\xc4\xd4\x18"; - const byte nonce[] = "\xa1\x45\x08\x53\x41\x68\xb6\x88\xf0\x5f\x1e\x41\x9c\x88\xcc\x30"; - const byte personalization[] = "\xa0\x34\x72\xf4\x04\x59\xe2\x87\xea\xcb\x21\x32\xc0\xb6\x54\x02\x7d\xa3\xe6\x69\x25\xb4\x21\x25\x54\xc4\x48\x18\x8c\x0e\x86\x01"; - const byte additional1[] = "\xb3\x0d\x28\xaf\xa4\x11\x6b\xbc\x13\x6e\x65\x09\xb5\x82\xa6\x93\xbc\x91\x71\x40\x46\xaa\x3c\x66\xb6\x77\xb3\xef\xf9\xad\xfd\x49"; - const byte additional2[] = "\x77\xfd\x1d\x68\xd6\xa4\xdd\xd5\xf3\x27\x25\x2d\x3f\x6b\xdf\xee\x8c\x35\xce\xd3\x83\xbe\xaf\xc9\x32\x77\xef\xf2\x1b\x6f\xf4\x1b"; - const byte additional3[] = "\x59\xa0\x1f\xf8\x6a\x58\x72\x1e\x85\xd2\xf8\x3f\x73\x99\xf1\x96\x4e\x27\xf8\x7f\xcd\x1b\xf5\xc1\xeb\xf3\x37\x10\x9b\x13\xbd\x24"; + const ::byte entropy1[] = "\xf0\x5b\xab\x56\xc7\xac\x6e\xeb\x31\xa0\xcf\x8a\x8a\x06\x2a\x49\x17\x9a\xcf\x3c\x5b\x20\x4d\x60\xdd\x7a\x3e\xb7\x8f\x5d\x8e\x3b"; + const ::byte entropy2[] = "\x72\xd4\x02\xa2\x59\x7b\x98\xa3\xb8\xf5\x0b\x71\x6c\x63\xc6\xdb\xa7\x3a\x07\xe6\x54\x89\x06\x3f\x02\xc5\x32\xf5\xda\xc4\xd4\x18"; + const ::byte nonce[] = "\xa1\x45\x08\x53\x41\x68\xb6\x88\xf0\x5f\x1e\x41\x9c\x88\xcc\x30"; + const ::byte personalization[] = "\xa0\x34\x72\xf4\x04\x59\xe2\x87\xea\xcb\x21\x32\xc0\xb6\x54\x02\x7d\xa3\xe6\x69\x25\xb4\x21\x25\x54\xc4\x48\x18\x8c\x0e\x86\x01"; + const ::byte additional1[] = "\xb3\x0d\x28\xaf\xa4\x11\x6b\xbc\x13\x6e\x65\x09\xb5\x82\xa6\x93\xbc\x91\x71\x40\x46\xaa\x3c\x66\xb6\x77\xb3\xef\xf9\xad\xfd\x49"; + const ::byte additional2[] = "\x77\xfd\x1d\x68\xd6\xa4\xdd\xd5\xf3\x27\x25\x2d\x3f\x6b\xdf\xee\x8c\x35\xce\xd3\x83\xbe\xaf\xc9\x32\x77\xef\xf2\x1b\x6f\xf4\x1b"; + const ::byte additional3[] = "\x59\xa0\x1f\xf8\x6a\x58\x72\x1e\x85\xd2\xf8\x3f\x73\x99\xf1\x96\x4e\x27\xf8\x7f\xcd\x1b\xf5\xc1\xeb\xf3\x37\x10\x9b\x13\xbd\x24"; Hash_DRBG drbg(entropy1, 32, nonce, 16, personalization, 32); drbg.IncorporateEntropy(entropy2, 32, additional1, 32); @@ -1376,7 +1376,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(additional2, 32, result, result.size()); drbg.GenerateBlock(additional3, 32, result, result.size()); - const byte expected[] = "\xFF\x27\x96\x38\x5C\x32\xBF\x84\x3D\xFA\xBB\xF0\x3E\x70\x5A\x39\xCB\xA3\x4C\xF1" + const ::byte expected[] = "\xFF\x27\x96\x38\x5C\x32\xBF\x84\x3D\xFA\xBB\xF0\x3E\x70\x5A\x39\xCB\xA3\x4C\xF1" "\x4F\xAE\xC3\x05\x63\xDF\x5A\xDD\xBD\x2D\x35\x83\xF5\x7E\x05\xF9\x40\x30\x56\x18" "\xF2\x00\x88\x14\x03\xC2\xD9\x81\x36\x39\xE6\x67\x55\xDC\xFC\x4E\x88\xEA\x71\xDD" "\xB2\x25\x2E\x09\x91\x49\x40\xEB\xE2\x3D\x63\x44\xA0\xF4\xDB\x5E\xE8\x39\xE6\x70" @@ -1393,13 +1393,13 @@ bool ValidateHashDRBG() { // [SHA-256], [PredictionResistance = False], [EntropyInputLen = 256], [NonceLen = 128] // [PersonalizationStringLen = 256], [AdditionalInputLen = 256], [ReturnedBitsLen = 1024] - const byte entropy1[] = "\xfe\x61\x50\x79\xf1\xad\x2a\x71\xea\x7f\x0f\x5a\x14\x34\xee\xc8\x46\x35\x54\x4a\x95\x6a\x4f\xbd\x64\xff\xba\xf6\x1d\x34\x61\x83"; - const byte entropy2[] = "\x18\x89\x7b\xd8\x3e\xff\x38\xab\xb5\x6e\x82\xa8\x1b\x8c\x5e\x59\x3c\x3d\x85\x62\x2a\xe2\x88\xe5\xb2\xc6\xc5\xd2\xad\x7d\xc9\x45"; - const byte nonce[] = "\x9d\xa7\x87\x56\xb7\x49\x17\x02\x4c\xd2\x00\x65\x11\x9b\xe8\x7e"; - const byte personalization[] = "\x77\x5d\xbf\x32\xf3\x5c\xf3\x51\xf4\xb8\x1c\xd3\xfa\x7f\x65\x0b\xcf\x31\x88\xa1\x25\x57\x0c\xdd\xac\xaa\xfe\xa1\x7b\x3b\x29\xbc"; - const byte additional1[] = "\xef\x96\xc7\x9c\xb1\x73\x1d\x82\x85\x0a\x6b\xca\x9b\x5c\x34\x39\xba\xd3\x4e\x4d\x82\x6f\x35\x9f\x61\x5c\xf6\xf2\xa3\x3e\x91\x05"; - const byte additional2[] = "\xaf\x25\xc4\x6e\x21\xfc\xc3\xaf\x1f\xbb\xf8\x76\xb4\x57\xab\x1a\x94\x0a\x85\x16\x47\x81\xa4\xab\xda\xc8\xab\xca\xd0\x84\xda\xae"; - const byte additional3[] = "\x59\x5b\x44\x94\x38\x86\x36\xff\x8e\x45\x1a\x0c\x42\xc8\xcc\x21\x06\x38\x3a\xc5\xa6\x30\x96\xb9\x14\x81\xb3\xa1\x2b\xc8\xcd\xf6"; + const ::byte entropy1[] = "\xfe\x61\x50\x79\xf1\xad\x2a\x71\xea\x7f\x0f\x5a\x14\x34\xee\xc8\x46\x35\x54\x4a\x95\x6a\x4f\xbd\x64\xff\xba\xf6\x1d\x34\x61\x83"; + const ::byte entropy2[] = "\x18\x89\x7b\xd8\x3e\xff\x38\xab\xb5\x6e\x82\xa8\x1b\x8c\x5e\x59\x3c\x3d\x85\x62\x2a\xe2\x88\xe5\xb2\xc6\xc5\xd2\xad\x7d\xc9\x45"; + const ::byte nonce[] = "\x9d\xa7\x87\x56\xb7\x49\x17\x02\x4c\xd2\x00\x65\x11\x9b\xe8\x7e"; + const ::byte personalization[] = "\x77\x5d\xbf\x32\xf3\x5c\xf3\x51\xf4\xb8\x1c\xd3\xfa\x7f\x65\x0b\xcf\x31\x88\xa1\x25\x57\x0c\xdd\xac\xaa\xfe\xa1\x7b\x3b\x29\xbc"; + const ::byte additional1[] = "\xef\x96\xc7\x9c\xb1\x73\x1d\x82\x85\x0a\x6b\xca\x9b\x5c\x34\x39\xba\xd3\x4e\x4d\x82\x6f\x35\x9f\x61\x5c\xf6\xf2\xa3\x3e\x91\x05"; + const ::byte additional2[] = "\xaf\x25\xc4\x6e\x21\xfc\xc3\xaf\x1f\xbb\xf8\x76\xb4\x57\xab\x1a\x94\x0a\x85\x16\x47\x81\xa4\xab\xda\xc8\xab\xca\xd0\x84\xda\xae"; + const ::byte additional3[] = "\x59\x5b\x44\x94\x38\x86\x36\xff\x8e\x45\x1a\x0c\x42\xc8\xcc\x21\x06\x38\x3a\xc5\xa6\x30\x96\xb9\x14\x81\xb3\xa1\x2b\xc8\xcd\xf6"; Hash_DRBG drbg(entropy1, 32, nonce, 16, personalization, 32); drbg.IncorporateEntropy(entropy2, 32, additional1, 32); @@ -1408,7 +1408,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(additional2, 32, result, result.size()); drbg.GenerateBlock(additional3, 32, result, result.size()); - const byte expected[] = "\x8B\x1C\x9C\x76\xC4\x9B\x3B\xAE\xFD\x6E\xEB\x6C\xFF\xA3\xA1\x03\x3A\x8C\xAF\x09" + const ::byte expected[] = "\x8B\x1C\x9C\x76\xC4\x9B\x3B\xAE\xFD\x6E\xEB\x6C\xFF\xA3\xA1\x03\x3A\x8C\xAF\x09" "\xFE\xBD\x44\x00\xFC\x0F\xD3\xA8\x26\x9C\xEE\x01\xAC\xE3\x73\x0E\xBE\xDA\x9A\xC6" "\x23\x44\x6D\xA1\x56\x94\x29\xEC\x4B\xCD\x01\x84\x32\x25\xEF\x00\x91\x0B\xCC\xF3" "\x06\x3B\x80\xF5\x46\xAC\xD2\xED\x5F\x70\x2B\x56\x2F\x21\x0A\xE9\x80\x87\x38\xAD" @@ -1425,13 +1425,13 @@ bool ValidateHashDRBG() { // [SHA-512], [PredictionResistance = False], [EntropyInputLen = 256], [NonceLen = 128] // [PersonalizationStringLen = 256], [AdditionalInputLen = 256], [ReturnedBitsLen = 2048] - const byte entropy1[] = "\x55\x4e\x8f\xfd\xc4\x9a\xd8\xf9\x9a\xe5\xd5\xf8\x1a\xf5\xda\xfb\x7f\x75\x53\xd7\xcb\x56\x8e\xa7\x3c\xc0\x82\xdd\x80\x76\x25\xc0"; - const byte entropy2[] = "\x78\x07\x3e\x86\x79\x4b\x10\x95\x88\xf4\x22\xf9\xbd\x04\x7e\xc0\xce\xab\xd6\x78\x6b\xdf\xe2\x89\xb3\x16\x43\x9c\x32\x2d\xb2\x59"; - const byte nonce[] = "\xf0\x89\x78\xde\x2d\xc2\xcd\xd9\xc0\xfd\x3d\x84\xd9\x8b\x8e\x8e"; - const byte personalization[] = "\x3e\x52\x7a\xb5\x81\x2b\x0c\x0e\x98\x2a\x95\x78\x93\x98\xd9\xeb\xf1\xb9\xeb\xd6\x1d\x02\x05\xed\x42\x21\x2d\x24\xb8\x37\xf8\x41"; - const byte additional1[] = "\xf2\x6b\xb1\xef\x30\xca\x8f\x97\xc0\x19\xd0\x79\xe5\xc6\x5e\xae\xd1\xa3\x9a\x52\xaf\x12\xe8\x28\xde\x03\x70\x79\x9a\x70\x11\x8b"; - const byte additional2[] = "\xb0\x9d\xb5\xa8\x45\xec\x79\x7a\x4b\x60\x7e\xe4\xd5\x58\x56\x70\x35\x20\x9b\xd8\xe5\x01\x6c\x78\xff\x1f\x6b\x93\xbf\x7c\x34\xca"; - const byte additional3[] = "\x45\x92\x2f\xb3\x5a\xd0\x6a\x84\x5f\xc9\xca\x16\x4a\x42\xbb\x59\x84\xb4\x38\x57\xa9\x16\x23\x48\xf0\x2f\x51\x61\x24\x35\xb8\x62"; + const ::byte entropy1[] = "\x55\x4e\x8f\xfd\xc4\x9a\xd8\xf9\x9a\xe5\xd5\xf8\x1a\xf5\xda\xfb\x7f\x75\x53\xd7\xcb\x56\x8e\xa7\x3c\xc0\x82\xdd\x80\x76\x25\xc0"; + const ::byte entropy2[] = "\x78\x07\x3e\x86\x79\x4b\x10\x95\x88\xf4\x22\xf9\xbd\x04\x7e\xc0\xce\xab\xd6\x78\x6b\xdf\xe2\x89\xb3\x16\x43\x9c\x32\x2d\xb2\x59"; + const ::byte nonce[] = "\xf0\x89\x78\xde\x2d\xc2\xcd\xd9\xc0\xfd\x3d\x84\xd9\x8b\x8e\x8e"; + const ::byte personalization[] = "\x3e\x52\x7a\xb5\x81\x2b\x0c\x0e\x98\x2a\x95\x78\x93\x98\xd9\xeb\xf1\xb9\xeb\xd6\x1d\x02\x05\xed\x42\x21\x2d\x24\xb8\x37\xf8\x41"; + const ::byte additional1[] = "\xf2\x6b\xb1\xef\x30\xca\x8f\x97\xc0\x19\xd0\x79\xe5\xc6\x5e\xae\xd1\xa3\x9a\x52\xaf\x12\xe8\x28\xde\x03\x70\x79\x9a\x70\x11\x8b"; + const ::byte additional2[] = "\xb0\x9d\xb5\xa8\x45\xec\x79\x7a\x4b\x60\x7e\xe4\xd5\x58\x56\x70\x35\x20\x9b\xd8\xe5\x01\x6c\x78\xff\x1f\x6b\x93\xbf\x7c\x34\xca"; + const ::byte additional3[] = "\x45\x92\x2f\xb3\x5a\xd0\x6a\x84\x5f\xc9\xca\x16\x4a\x42\xbb\x59\x84\xb4\x38\x57\xa9\x16\x23\x48\xf0\x2f\x51\x61\x24\x35\xb8\x62"; Hash_DRBG drbg(entropy1, 32, nonce, 16, personalization, 32); drbg.IncorporateEntropy(entropy2, 32, additional1, 32); @@ -1440,7 +1440,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(additional2, 32, result, result.size()); drbg.GenerateBlock(additional3, 32, result, result.size()); - const byte expected[] = "\x1F\x20\x83\x9E\x22\x55\x3B\x1E\x6C\xD4\xF6\x3A\x47\xC3\x99\x54\x0F\x69\xA3\xBB" + const ::byte expected[] = "\x1F\x20\x83\x9E\x22\x55\x3B\x1E\x6C\xD4\xF6\x3A\x47\xC3\x99\x54\x0F\x69\xA3\xBB" "\x37\x47\xA0\x2A\x12\xAC\xC7\x00\x85\xC5\xCC\xF4\x7B\x12\x5A\x4A\xEA\xED\x2F\xE5" "\x31\x51\x0D\xC1\x8E\x50\x29\xE2\xA6\xCB\x8F\x34\xBA\xDA\x8B\x47\x32\x33\x81\xF1" "\x2D\xF6\x8B\x73\x8C\xFF\x15\xC8\x8E\x8C\x31\x48\xFA\xC3\xC4\x9F\x52\x81\x23\xC2" @@ -1463,13 +1463,13 @@ bool ValidateHashDRBG() { // [SHA-512], [PredictionResistance = False], [EntropyInputLen = 256], [NonceLen = 128] // [PersonalizationStringLen = 256], [AdditionalInputLen = 256], [ReturnedBitsLen = 2048] - const byte entropy1[] = "\x0c\x9f\xcd\x06\x21\x3c\xb2\xf6\x3c\xdf\x79\x76\x4b\x46\x74\xfc\xdf\x68\xb0\xff\xae\xc7\x21\x8a\xa2\xaf\x4e\x4c\xb9\xe6\x60\x78"; - const byte entropy2[] = "\x75\xb8\x49\x54\xdf\x30\x10\x16\x2c\x06\x8c\x12\xeb\x6c\x1d\x03\x64\x5c\xad\x10\x5c\xc3\x17\x69\xb2\x5a\xc1\x7c\xb8\x33\x5b\x45"; - const byte nonce[] = "\x43\x1c\x4d\x65\x93\x96\xad\xdc\xc1\x6d\x17\x9f\x7f\x57\x24\x4d"; - const byte personalization[] = "\x7e\x54\xbd\x87\xd2\x0a\x95\xd7\xc4\x0c\x3b\x1b\x32\x15\x26\xd2\x06\x67\xa4\xac\xc1\xaa\xfb\x55\x91\x68\x2c\xb5\xc9\xcd\x66\x05"; - const byte additional1[] = "\xd5\x74\x9e\x56\xfb\x5f\xf3\xf8\x2c\x73\x2b\x7a\x83\xe0\xde\x06\x85\x0b\xf0\x57\x50\xc8\x55\x60\x4a\x41\x4f\x86\xb1\x68\x14\x03"; - const byte additional2[] = "\x9a\x83\xbb\x06\xdf\x4d\x53\x89\xf5\x3f\x24\xff\xf7\xcd\x0c\xcf\x4f\xbe\x46\x79\x8e\xce\x82\xa8\xc4\x6b\x5f\x8e\x58\x32\x62\x23"; - const byte additional3[] = "\x48\x13\xc4\x95\x10\x99\xdd\x7f\xd4\x77\x3c\x9b\x8a\xa4\x1c\x3d\xb0\x93\x92\x50\xba\x23\x98\xef\x4b\x1b\xd2\x53\xc1\x61\xda\xc6"; + const ::byte entropy1[] = "\x0c\x9f\xcd\x06\x21\x3c\xb2\xf6\x3c\xdf\x79\x76\x4b\x46\x74\xfc\xdf\x68\xb0\xff\xae\xc7\x21\x8a\xa2\xaf\x4e\x4c\xb9\xe6\x60\x78"; + const ::byte entropy2[] = "\x75\xb8\x49\x54\xdf\x30\x10\x16\x2c\x06\x8c\x12\xeb\x6c\x1d\x03\x64\x5c\xad\x10\x5c\xc3\x17\x69\xb2\x5a\xc1\x7c\xb8\x33\x5b\x45"; + const ::byte nonce[] = "\x43\x1c\x4d\x65\x93\x96\xad\xdc\xc1\x6d\x17\x9f\x7f\x57\x24\x4d"; + const ::byte personalization[] = "\x7e\x54\xbd\x87\xd2\x0a\x95\xd7\xc4\x0c\x3b\x1b\x32\x15\x26\xd2\x06\x67\xa4\xac\xc1\xaa\xfb\x55\x91\x68\x2c\xb5\xc9\xcd\x66\x05"; + const ::byte additional1[] = "\xd5\x74\x9e\x56\xfb\x5f\xf3\xf8\x2c\x73\x2b\x7a\x83\xe0\xde\x06\x85\x0b\xf0\x57\x50\xc8\x55\x60\x4a\x41\x4f\x86\xb1\x68\x14\x03"; + const ::byte additional2[] = "\x9a\x83\xbb\x06\xdf\x4d\x53\x89\xf5\x3f\x24\xff\xf7\xcd\x0c\xcf\x4f\xbe\x46\x79\x8e\xce\x82\xa8\xc4\x6b\x5f\x8e\x58\x32\x62\x23"; + const ::byte additional3[] = "\x48\x13\xc4\x95\x10\x99\xdd\x7f\xd4\x77\x3c\x9b\x8a\xa4\x1c\x3d\xb0\x93\x92\x50\xba\x23\x98\xef\x4b\x1b\xd2\x53\xc1\x61\xda\xc6"; Hash_DRBG drbg(entropy1, 32, nonce, 16, personalization, 32); drbg.IncorporateEntropy(entropy2, 32, additional1, 32); @@ -1478,7 +1478,7 @@ bool ValidateHashDRBG() drbg.GenerateBlock(additional2, 32, result, result.size()); drbg.GenerateBlock(additional3, 32, result, result.size()); - const byte expected[] = "\xE1\x7E\x4B\xEE\xD1\x65\x4F\xB2\xFC\xC8\xE8\xD7\xC6\x72\x7D\xD2\xE3\x15\x73\xC0" + const ::byte expected[] = "\xE1\x7E\x4B\xEE\xD1\x65\x4F\xB2\xFC\xC8\xE8\xD7\xC6\x72\x7D\xD2\xE3\x15\x73\xC0" "\x23\xC8\x55\x5D\x2B\xD8\x28\xD8\x31\xE4\xC9\x87\x42\x51\x87\x66\x43\x1F\x2C\xA4" "\x73\xED\x4E\x50\x12\xC4\x50\x0E\x4C\xDD\x14\x73\xA2\xFB\xB3\x07\x0C\x66\x97\x4D" "\x89\xDE\x35\x1C\x93\xE7\xE6\x8F\x20\x3D\x84\xE6\x73\x46\x0F\x7C\xF4\x3B\x6C\x02" @@ -1513,9 +1513,9 @@ bool ValidateHmacDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 0], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x79\x34\x9b\xbf\x7c\xdd\xa5\x79\x95\x57\x86\x66\x21\xc9\x13\x83"; - const byte entropy2[] = "\xc7\x21\x5b\x5b\x96\xc4\x8e\x9b\x33\x8c\x74\xe3\xe9\x9d\xfe\xdf"; - const byte nonce[] = "\x11\x46\x73\x3a\xbf\x8c\x35\xc8"; + const ::byte entropy1[] = "\x79\x34\x9b\xbf\x7c\xdd\xa5\x79\x95\x57\x86\x66\x21\xc9\x13\x83"; + const ::byte entropy2[] = "\xc7\x21\x5b\x5b\x96\xc4\x8e\x9b\x33\x8c\x74\xe3\xe9\x9d\xfe\xdf"; + const ::byte nonce[] = "\x11\x46\x73\x3a\xbf\x8c\x35\xc8"; HMAC_DRBG drbg(entropy1, 16, nonce, 8); drbg.IncorporateEntropy(entropy2, 16); @@ -1524,7 +1524,7 @@ bool ValidateHmacDRBG() drbg.GenerateBlock(result, result.size()); drbg.GenerateBlock(result, result.size()); - const byte expected[] = "\xc6\xa1\x6a\xb8\xd4\x20\x70\x6f\x0f\x34\xab\x7f\xec\x5a\xdc\xa9\xd8\xca\x3a\x13" + const ::byte expected[] = "\xc6\xa1\x6a\xb8\xd4\x20\x70\x6f\x0f\x34\xab\x7f\xec\x5a\xdc\xa9\xd8\xca\x3a\x13" "\x3e\x15\x9c\xa6\xac\x43\xc6\xf8\xa2\xbe\x22\x83\x4a\x4c\x0a\x0a\xff\xb1\x0d\x71" "\x94\xf1\xc1\xa5\xcf\x73\x22\xec\x1a\xe0\x96\x4e\xd4\xbf\x12\x27\x46\xe0\x87\xfd" "\xb5\xb3\xe9\x1b\x34\x93\xd5\xbb\x98\xfa\xed\x49\xe8\x5f\x13\x0f\xc8\xa4\x59\xb7"; @@ -1538,9 +1538,9 @@ bool ValidateHmacDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 0], [AdditionalInputLen = 0], [ReturnedBitsLen = 640] - const byte entropy1[] = "\xee\x57\xfc\x23\x60\x0f\xb9\x02\x9a\x9e\xc6\xc8\x2e\x7b\x51\xe4"; - const byte entropy2[] = "\x84\x1d\x27\x6c\xa9\x51\x90\x61\xd9\x2d\x7d\xdf\xa6\x62\x8c\xa3"; - const byte nonce[] = "\x3e\x97\x21\xe4\x39\x3e\xf9\xad"; + const ::byte entropy1[] = "\xee\x57\xfc\x23\x60\x0f\xb9\x02\x9a\x9e\xc6\xc8\x2e\x7b\x51\xe4"; + const ::byte entropy2[] = "\x84\x1d\x27\x6c\xa9\x51\x90\x61\xd9\x2d\x7d\xdf\xa6\x62\x8c\xa3"; + const ::byte nonce[] = "\x3e\x97\x21\xe4\x39\x3e\xf9\xad"; HMAC_DRBG drbg(entropy1, 16, nonce, 8); drbg.IncorporateEntropy(entropy2, 16); @@ -1549,7 +1549,7 @@ bool ValidateHmacDRBG() drbg.GenerateBlock(result, result.size()); drbg.GenerateBlock(result, result.size()); - const byte expected[] = "\xee\x26\xa5\xc8\xef\x08\xa1\xca\x8f\x14\x15\x4d\x67\xc8\x8f\x5e\x7e\xd8\x21\x9d" + const ::byte expected[] = "\xee\x26\xa5\xc8\xef\x08\xa1\xca\x8f\x14\x15\x4d\x67\xc8\x8f\x5e\x7e\xd8\x21\x9d" "\x93\x1b\x98\x42\xac\x00\x39\xf2\x14\x55\x39\xf2\x14\x2b\x44\x11\x7a\x99\x8c\x22" "\xf5\x90\xf6\xc9\xb3\x8b\x46\x5b\x78\x3e\xcf\xf1\x3a\x77\x50\x20\x1f\x7e\xcf\x1b" "\x8a\xb3\x93\x60\x4c\x73\xb2\x38\x93\x36\x60\x9a\xf3\x44\x0c\xde\x43\x29\x8b\x84"; @@ -1565,12 +1565,12 @@ bool ValidateHmacDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 0], [AdditionalInputLen = 16], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x7d\x70\x52\xa7\x76\xfd\x2f\xb3\xd7\x19\x1f\x73\x33\x04\xee\x8b"; - const byte entropy2[] = "\x49\x04\x7e\x87\x9d\x61\x09\x55\xee\xd9\x16\xe4\x06\x0e\x00\xc9"; - const byte nonce[] = "\xbe\x4a\x0c\xee\xdc\xa8\x02\x07"; - const byte additional1[] = "\xfd\x8b\xb3\x3a\xab\x2f\x6c\xdf\xbc\x54\x18\x11\x86\x1d\x51\x8d"; - const byte additional2[] = "\x99\xaf\xe3\x47\x54\x04\x61\xdd\xf6\xab\xeb\x49\x1e\x07\x15\xb4"; - const byte additional3[] = "\x02\xf7\x73\x48\x2d\xd7\xae\x66\xf7\x6e\x38\x15\x98\xa6\x4e\xf0"; + const ::byte entropy1[] = "\x7d\x70\x52\xa7\x76\xfd\x2f\xb3\xd7\x19\x1f\x73\x33\x04\xee\x8b"; + const ::byte entropy2[] = "\x49\x04\x7e\x87\x9d\x61\x09\x55\xee\xd9\x16\xe4\x06\x0e\x00\xc9"; + const ::byte nonce[] = "\xbe\x4a\x0c\xee\xdc\xa8\x02\x07"; + const ::byte additional1[] = "\xfd\x8b\xb3\x3a\xab\x2f\x6c\xdf\xbc\x54\x18\x11\x86\x1d\x51\x8d"; + const ::byte additional2[] = "\x99\xaf\xe3\x47\x54\x04\x61\xdd\xf6\xab\xeb\x49\x1e\x07\x15\xb4"; + const ::byte additional3[] = "\x02\xf7\x73\x48\x2d\xd7\xae\x66\xf7\x6e\x38\x15\x98\xa6\x4e\xf0"; HMAC_DRBG drbg(entropy1, 16, nonce, 8); drbg.IncorporateEntropy(entropy2, 16, additional1, 16); @@ -1579,7 +1579,7 @@ bool ValidateHmacDRBG() drbg.GenerateBlock(additional2, 16, result, result.size()); drbg.GenerateBlock(additional3, 16, result, result.size()); - const byte expected[] = "\xa7\x36\x34\x38\x44\xfc\x92\x51\x13\x91\xdb\x0a\xdd\xd9\x06\x4d\xbe\xe2\x4c\x89" + const ::byte expected[] = "\xa7\x36\x34\x38\x44\xfc\x92\x51\x13\x91\xdb\x0a\xdd\xd9\x06\x4d\xbe\xe2\x4c\x89" "\x76\xaa\x25\x9a\x9e\x3b\x63\x68\xaa\x6d\xe4\xc9\xbf\x3a\x0e\xff\xcd\xa9\xcb\x0e" "\x9d\xc3\x36\x52\xab\x58\xec\xb7\x65\x0e\xd8\x04\x67\xf7\x6a\x84\x9f\xb1\xcf\xc1" "\xed\x0a\x09\xf7\x15\x50\x86\x06\x4d\xb3\x24\xb1\xe1\x24\xf3\xfc\x9e\x61\x4f\xcb"; @@ -1593,12 +1593,12 @@ bool ValidateHmacDRBG() { // [SHA-1], [PredictionResistance = False], [EntropyInputLen = 128], [NonceLen = 64] // [PersonalizationStringLen = 0], [AdditionalInputLen = 16], [ReturnedBitsLen = 640] - const byte entropy1[] = "\x29\xc6\x2a\xfa\x3c\x52\x20\x8a\x3f\xde\xcb\x43\xfa\x61\x3f\x15"; - const byte entropy2[] = "\xbd\x87\xbe\x99\xd1\x84\x16\x54\x12\x31\x41\x40\xd4\x02\x71\x41"; - const byte nonce[] = "\x6c\x9e\xb5\x9a\xc3\xc2\xd4\x8b"; - const byte additional1[] = "\x43\x3d\xda\xf2\x59\xd1\x4b\xcf\x89\x76\x30\xcc\xaa\x27\x33\x8c"; - const byte additional2[] = "\x14\x11\x46\xd4\x04\xf2\x84\xc2\xd0\x2b\x6a\x10\x15\x6e\x33\x82"; - const byte additional3[] = "\xed\xc3\x43\xdb\xff\xe7\x1a\xb4\x11\x4a\xc3\x63\x9d\x44\x5b\x65"; + const ::byte entropy1[] = "\x29\xc6\x2a\xfa\x3c\x52\x20\x8a\x3f\xde\xcb\x43\xfa\x61\x3f\x15"; + const ::byte entropy2[] = "\xbd\x87\xbe\x99\xd1\x84\x16\x54\x12\x31\x41\x40\xd4\x02\x71\x41"; + const ::byte nonce[] = "\x6c\x9e\xb5\x9a\xc3\xc2\xd4\x8b"; + const ::byte additional1[] = "\x43\x3d\xda\xf2\x59\xd1\x4b\xcf\x89\x76\x30\xcc\xaa\x27\x33\x8c"; + const ::byte additional2[] = "\x14\x11\x46\xd4\x04\xf2\x84\xc2\xd0\x2b\x6a\x10\x15\x6e\x33\x82"; + const ::byte additional3[] = "\xed\xc3\x43\xdb\xff\xe7\x1a\xb4\x11\x4a\xc3\x63\x9d\x44\x5b\x65"; HMAC_DRBG drbg(entropy1, 16, nonce, 8); drbg.IncorporateEntropy(entropy2, 16, additional1, 16); @@ -1607,7 +1607,7 @@ bool ValidateHmacDRBG() drbg.GenerateBlock(additional2, 16, result, result.size()); drbg.GenerateBlock(additional3, 16, result, result.size()); - const byte expected[] = "\x8c\x73\x0f\x05\x26\x69\x4d\x5a\x9a\x45\xdb\xab\x05\x7a\x19\x75\x35\x7d\x65\xaf" + const ::byte expected[] = "\x8c\x73\x0f\x05\x26\x69\x4d\x5a\x9a\x45\xdb\xab\x05\x7a\x19\x75\x35\x7d\x65\xaf" "\xd3\xef\xf3\x03\x32\x0b\xd1\x40\x61\xf9\xad\x38\x75\x91\x02\xb6\xc6\x01\x16\xf6" "\xdb\x7a\x6e\x8e\x7a\xb9\x4c\x05\x50\x0b\x4d\x1e\x35\x7d\xf8\xe9\x57\xac\x89\x37" "\xb0\x5f\xb3\xd0\x80\xa0\xf9\x06\x74\xd4\x4d\xe1\xbd\x6f\x94\xd2\x95\xc4\x51\x9d"; @@ -1627,8 +1627,8 @@ public: virtual unsigned int BlockSize() const =0; virtual unsigned int KeyLength() const =0; - virtual BlockTransformation* NewEncryption(const byte *keyStr) const =0; - virtual BlockTransformation* NewDecryption(const byte *keyStr) const =0; + virtual BlockTransformation* NewEncryption(const ::byte *keyStr) const =0; + virtual BlockTransformation* NewDecryption(const ::byte *keyStr) const =0; }; template class FixedRoundsCipherFactory : public CipherFactory @@ -1638,9 +1638,9 @@ public: unsigned int BlockSize() const {return E::BLOCKSIZE;} unsigned int KeyLength() const {return m_keylen;} - BlockTransformation* NewEncryption(const byte *keyStr) const + BlockTransformation* NewEncryption(const ::byte *keyStr) const {return new E(keyStr, m_keylen);} - BlockTransformation* NewDecryption(const byte *keyStr) const + BlockTransformation* NewDecryption(const ::byte *keyStr) const {return new D(keyStr, m_keylen);} unsigned int m_keylen; @@ -1654,9 +1654,9 @@ public: unsigned int BlockSize() const {return E::BLOCKSIZE;} unsigned int KeyLength() const {return m_keylen;} - BlockTransformation* NewEncryption(const byte *keyStr) const + BlockTransformation* NewEncryption(const ::byte *keyStr) const {return new E(keyStr, m_keylen, m_rounds);} - BlockTransformation* NewDecryption(const byte *keyStr) const + BlockTransformation* NewDecryption(const ::byte *keyStr) const {return new D(keyStr, m_keylen, m_rounds);} unsigned int m_keylen, m_rounds; @@ -1699,9 +1699,9 @@ bool BlockTransformationTest(const CipherFactory &cg, BufferedTransformation &va class FilterTester : public Unflushable { public: - FilterTester(const byte *validOutput, size_t outputLen) + FilterTester(const ::byte *validOutput, size_t outputLen) : validOutput(validOutput), outputLen(outputLen), counter(0), fail(false) {} - void PutByte(byte inByte) + void PutByte(::byte inByte) { if (counter >= outputLen || validOutput[counter] != inByte) { @@ -1711,7 +1711,7 @@ public: } counter++; } - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { CRYPTOPP_UNUSED(messageEnd), CRYPTOPP_UNUSED(blocking); @@ -1732,12 +1732,12 @@ public: return !fail; } - const byte *validOutput; + const ::byte *validOutput; size_t outputLen, counter; bool fail; }; -bool TestFilter(BufferedTransformation &bt, const byte *in, size_t inLen, const byte *out, size_t outLen) +bool TestFilter(BufferedTransformation &bt, const ::byte *in, size_t inLen, const ::byte *out, size_t outLen) { FilterTester *ft; bt.Attach(ft = new FilterTester(out, outLen)); @@ -1803,9 +1803,9 @@ bool TestModeIV(SymmetricCipher &e, SymmetricCipher &d) bool ValidateCipherModes() { std::cout << "\nTesting DES modes...\n\n"; - const byte key[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; - const byte iv[] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef}; - const byte plain[] = { // "Now is the time for all " without tailing 0 + const ::byte key[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; + const ::byte iv[] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef}; + const ::byte plain[] = { // "Now is the time for all " without tailing 0 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74, 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20, 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20}; @@ -1815,7 +1815,7 @@ bool ValidateCipherModes() { // from FIPS 81 - const byte encrypted[] = { + const ::byte encrypted[] = { 0x3f, 0xa4, 0x0e, 0x8a, 0x98, 0x4d, 0x48, 0x15, 0x6a, 0x27, 0x17, 0x87, 0xab, 0x88, 0x83, 0xf9, 0x89, 0x3d, 0x51, 0xec, 0x4b, 0x56, 0x3b, 0x53}; @@ -1834,7 +1834,7 @@ bool ValidateCipherModes() } { // from FIPS 81 - const byte encrypted[] = { + const ::byte encrypted[] = { 0xE5, 0xC7, 0xCD, 0xDE, 0x87, 0x2B, 0xF2, 0x7C, 0x43, 0xE9, 0x34, 0x00, 0x8C, 0x38, 0x9C, 0x0F, 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6}; @@ -1858,7 +1858,7 @@ bool ValidateCipherModes() { // generated with Crypto++, matches FIPS 81 // but has extra 8 bytes as result of padding - const byte encrypted[] = { + const ::byte encrypted[] = { 0xE5, 0xC7, 0xCD, 0xDE, 0x87, 0x2B, 0xF2, 0x7C, 0x43, 0xE9, 0x34, 0x00, 0x8C, 0x38, 0x9C, 0x0F, 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6, @@ -1879,7 +1879,7 @@ bool ValidateCipherModes() { // generated with Crypto++ 5.2, matches FIPS 81 // but has extra 8 bytes as result of padding - const byte encrypted[] = { + const ::byte encrypted[] = { 0xE5, 0xC7, 0xCD, 0xDE, 0x87, 0x2B, 0xF2, 0x7C, 0x43, 0xE9, 0x34, 0x00, 0x8C, 0x38, 0x9C, 0x0F, 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6, @@ -1898,9 +1898,9 @@ bool ValidateCipherModes() std::cout << (fail ? "FAILED " : "passed ") << "CBC decryption with one-and-zeros padding" << std::endl; } { - const byte plain_1[] = {'a', 0, 0, 0, 0, 0, 0, 0}; + const ::byte plain_1[] = {'a', 0, 0, 0, 0, 0, 0, 0}; // generated with Crypto++ - const byte encrypted[] = { + const ::byte encrypted[] = { 0x9B, 0x47, 0x57, 0x59, 0xD6, 0x9C, 0xF6, 0xD0}; CBC_Mode_ExternalCipher::Encryption modeE(desE, iv); @@ -1918,7 +1918,7 @@ bool ValidateCipherModes() { // generated with Crypto++, matches FIPS 81 // but with last two blocks swapped as result of CTS - const byte encrypted[] = { + const ::byte encrypted[] = { 0xE5, 0xC7, 0xCD, 0xDE, 0x87, 0x2B, 0xF2, 0x7C, 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6, 0x43, 0xE9, 0x34, 0x00, 0x8C, 0x38, 0x9C, 0x0F}; @@ -1941,10 +1941,10 @@ bool ValidateCipherModes() } { // generated with Crypto++ - const byte decryptionIV[] = {0x4D, 0xD0, 0xAC, 0x8F, 0x47, 0xCF, 0x79, 0xCE}; - const byte encrypted[] = {0x12, 0x34, 0x56}; + const ::byte decryptionIV[] = {0x4D, 0xD0, 0xAC, 0x8F, 0x47, 0xCF, 0x79, 0xCE}; + const ::byte encrypted[] = {0x12, 0x34, 0x56}; - byte stolenIV[8]; + ::byte stolenIV[8]; CBC_CTS_Mode_ExternalCipher::Encryption modeE(desE, iv); modeE.SetStolenIV(stolenIV); @@ -1961,7 +1961,7 @@ bool ValidateCipherModes() std::cout << (fail ? "FAILED " : "passed ") << "CBC decryption with ciphertext and IV stealing" << std::endl; } { - const byte encrypted[] = { // from FIPS 81 + const ::byte encrypted[] = { // from FIPS 81 0xF3,0x09,0x62,0x49,0xC7,0xF4,0x6E,0x51, 0xA6,0x9E,0x83,0x9B,0x1A,0x92,0xF7,0x84, 0x03,0x46,0x71,0x33,0x89,0x8E,0xA6,0x22}; @@ -1983,9 +1983,9 @@ bool ValidateCipherModes() std::cout << (fail ? "FAILED " : "passed ") << "CFB mode IV generation" << std::endl; } { - const byte plain_2[] = { // "Now is the." without tailing 0 + const ::byte plain_2[] = { // "Now is the." without tailing 0 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,0x68,0x65}; - const byte encrypted[] = { // from FIPS 81 + const ::byte encrypted[] = { // from FIPS 81 0xf3,0x1f,0xda,0x07,0x01,0x14,0x62,0xee,0x18,0x7f}; CFB_Mode_ExternalCipher::Encryption modeE(desE, iv, 1); @@ -2005,7 +2005,7 @@ bool ValidateCipherModes() std::cout << (fail ? "FAILED " : "passed ") << "CFB (8-bit feedback) IV generation" << std::endl; } { - const byte encrypted[] = { // from Eric Young's libdes + const ::byte encrypted[] = { // from Eric Young's libdes 0xf3,0x09,0x62,0x49,0xc7,0xf4,0x6e,0x51, 0x35,0xf2,0x4a,0x24,0x2e,0xeb,0x3d,0x3f, 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3}; @@ -2027,7 +2027,7 @@ bool ValidateCipherModes() std::cout << (fail ? "FAILED " : "passed ") << "OFB IV generation" << std::endl; } { - const byte encrypted[] = { // generated with Crypto++ + const ::byte encrypted[] = { // generated with Crypto++ 0xF3, 0x09, 0x62, 0x49, 0xC7, 0xF4, 0x6E, 0x51, 0x16, 0x3A, 0x8C, 0xA0, 0xFF, 0xC9, 0x4C, 0x27, 0xFA, 0x2F, 0x80, 0xF4, 0x80, 0xB8, 0x6F, 0x75}; @@ -2049,14 +2049,14 @@ bool ValidateCipherModes() std::cout << (fail ? "FAILED " : "passed ") << "Counter Mode IV generation" << std::endl; } { - const byte plain_3[] = { // "7654321 Now is the time for " + const ::byte plain_3[] = { // "7654321 Now is the time for " 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20, 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20}; - const byte mac1[] = { // from FIPS 113 + const ::byte mac1[] = { // from FIPS 113 0xf1, 0xd3, 0x0f, 0x68, 0x49, 0x31, 0x2c, 0xa4}; - const byte mac2[] = { // generated with Crypto++ + const ::byte mac2[] = { // generated with Crypto++ 0x35, 0x80, 0xC5, 0xC4, 0x6B, 0x81, 0x24, 0xE2}; CBC_MAC cbcmac(key); @@ -2136,7 +2136,7 @@ bool ValidateRC2() while (valdata.MaxRetrievable()) { - byte keyLen, effectiveLen; + ::byte keyLen, effectiveLen; valdata.Get(keyLen); valdata.Get(effectiveLen); @@ -2556,17 +2556,17 @@ bool ValidateBlowfish() HexEncoder output(new FileSink(std::cout)); const char *key[]={"abcdefghijklmnopqrstuvwxyz", "Who is John Galt?"}; - byte *plain[]={(byte *)"BLOWFISH", (byte *)"\xfe\xdc\xba\x98\x76\x54\x32\x10"}; - byte *cipher[]={(byte *)"\x32\x4e\xd0\xfe\xf4\x13\xa2\x03", (byte *)"\xcc\x91\x73\x2b\x80\x22\xf6\x84"}; - byte out[8], outplain[8]; + ::byte *plain[]={(::byte *)"BLOWFISH", (::byte *)"\xfe\xdc\xba\x98\x76\x54\x32\x10"}; + ::byte *cipher[]={(::byte *)"\x32\x4e\xd0\xfe\xf4\x13\xa2\x03", (::byte *)"\xcc\x91\x73\x2b\x80\x22\xf6\x84"}; + ::byte out[8], outplain[8]; for (int i=0; i<2; i++) { - ECB_Mode::Encryption enc2((byte *)key[i], strlen(key[i])); + ECB_Mode::Encryption enc2((::byte *)key[i], strlen(key[i])); enc2.ProcessData(out, plain[i], 8); fail = memcmp(out, cipher[i], 8) != 0; - ECB_Mode::Decryption dec2((byte *)key[i], strlen(key[i])); + ECB_Mode::Decryption dec2((::byte *)key[i], strlen(key[i])); dec2.ProcessData(outplain, cipher[i], 8); fail = fail || memcmp(outplain, plain[i], 8); pass3 = pass3 && !fail; @@ -2766,10 +2766,10 @@ bool ValidateSKIPJACK() bool ValidateSEAL() { - const byte input[] = {0x37,0xa0,0x05,0x95,0x9b,0x84,0xc4,0x9c,0xa4,0xbe,0x1e,0x05,0x06,0x73,0x53,0x0f,0x5f,0xb0,0x97,0xfd,0xf6,0xa1,0x3f,0xbd,0x6c,0x2c,0xde,0xcd,0x81,0xfd,0xee,0x7c}; - const byte key[] = {0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0}; - const byte iv[] = {0x01, 0x35, 0x77, 0xaf}; - byte output[32]; + const ::byte input[] = {0x37,0xa0,0x05,0x95,0x9b,0x84,0xc4,0x9c,0xa4,0xbe,0x1e,0x05,0x06,0x73,0x53,0x0f,0x5f,0xb0,0x97,0xfd,0xf6,0xa1,0x3f,0xbd,0x6c,0x2c,0xde,0xcd,0x81,0xfd,0xee,0x7c}; + const ::byte key[] = {0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0}; + const ::byte iv[] = {0x01, 0x35, 0x77, 0xaf}; + ::byte output[32]; std::cout << "\nSEAL validation suite running...\n\n"; @@ -2795,9 +2795,9 @@ bool ValidateSEAL() bool ValidateBaseCode() { bool pass = true, fail; - byte data[255]; + ::byte data[255]; for (unsigned int i=0; i<255; i++) - data[i] = byte(i); + data[i] = ::byte(i); const char hexEncoded[] = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627" @@ -2837,56 +2837,56 @@ bool ValidateBaseCode() std::cout << "\nBase64, Base64URL, Base32 and Base16 coding validation suite running...\n\n"; - fail = !TestFilter(HexEncoder().Ref(), data, 255, (const byte *)hexEncoded, strlen(hexEncoded)); + fail = !TestFilter(HexEncoder().Ref(), data, 255, (const ::byte *)hexEncoded, strlen(hexEncoded)); try {HexEncoder().IsolatedInitialize(g_nullNameValuePairs);} catch (const Exception&) {fail=true;} std::cout << (fail ? "FAILED:" : "passed:"); std::cout << " Hex Encoding\n"; pass = pass && !fail; - fail = !TestFilter(HexDecoder().Ref(), (const byte *)hexEncoded, strlen(hexEncoded), data, 255); + fail = !TestFilter(HexDecoder().Ref(), (const ::byte *)hexEncoded, strlen(hexEncoded), data, 255); try {HexDecoder().IsolatedInitialize(g_nullNameValuePairs);} catch (const Exception&) {fail=true;} std::cout << (fail ? "FAILED:" : "passed:"); std::cout << " Hex Decoding\n"; pass = pass && !fail; - fail = !TestFilter(Base32Encoder().Ref(), data, 255, (const byte *)base32Encoded, strlen(base32Encoded)); + fail = !TestFilter(Base32Encoder().Ref(), data, 255, (const ::byte *)base32Encoded, strlen(base32Encoded)); try {Base32Encoder().IsolatedInitialize(g_nullNameValuePairs);} catch (const Exception&) {fail=true;} std::cout << (fail ? "FAILED:" : "passed:"); std::cout << " Base32 Encoding\n"; pass = pass && !fail; - fail = !TestFilter(Base32Decoder().Ref(), (const byte *)base32Encoded, strlen(base32Encoded), data, 255); + fail = !TestFilter(Base32Decoder().Ref(), (const ::byte *)base32Encoded, strlen(base32Encoded), data, 255); try {Base32Decoder().IsolatedInitialize(g_nullNameValuePairs);} catch (const Exception&) {fail=true;} std::cout << (fail ? "FAILED:" : "passed:"); std::cout << " Base32 Decoding\n"; pass = pass && !fail; - fail = !TestFilter(Base64Encoder(new HexEncoder).Ref(), data, 255, (const byte *)base64AndHexEncoded, strlen(base64AndHexEncoded)); + fail = !TestFilter(Base64Encoder(new HexEncoder).Ref(), data, 255, (const ::byte *)base64AndHexEncoded, strlen(base64AndHexEncoded)); try {Base64Encoder().IsolatedInitialize(g_nullNameValuePairs);} catch (const Exception&) {fail=true;} std::cout << (fail ? "FAILED:" : "passed:"); std::cout << " Base64 Encoding\n"; pass = pass && !fail; - fail = !TestFilter(HexDecoder(new Base64Decoder).Ref(), (const byte *)base64AndHexEncoded, strlen(base64AndHexEncoded), data, 255); + fail = !TestFilter(HexDecoder(new Base64Decoder).Ref(), (const ::byte *)base64AndHexEncoded, strlen(base64AndHexEncoded), data, 255); try {Base64Decoder().IsolatedInitialize(g_nullNameValuePairs);} catch (const Exception&) {fail=true;} std::cout << (fail ? "FAILED:" : "passed:"); std::cout << " Base64 Decoding\n"; pass = pass && !fail; - fail = !TestFilter(Base64URLEncoder(new HexEncoder).Ref(), data, 255, (const byte *)base64URLAndHexEncoded, strlen(base64URLAndHexEncoded)); + fail = !TestFilter(Base64URLEncoder(new HexEncoder).Ref(), data, 255, (const ::byte *)base64URLAndHexEncoded, strlen(base64URLAndHexEncoded)); try {Base64URLEncoder().IsolatedInitialize(g_nullNameValuePairs);} catch (const Exception&) {fail=true;} std::cout << (fail ? "FAILED:" : "passed:"); std::cout << " Base64 URL Encoding\n"; pass = pass && !fail; - fail = !TestFilter(HexDecoder(new Base64URLDecoder).Ref(), (const byte *)base64URLAndHexEncoded, strlen(base64URLAndHexEncoded), data, 255); + fail = !TestFilter(HexDecoder(new Base64URLDecoder).Ref(), (const ::byte *)base64URLAndHexEncoded, strlen(base64URLAndHexEncoded), data, 255); try {Base64URLDecoder().IsolatedInitialize(g_nullNameValuePairs);} catch (const Exception&) {fail=true;} std::cout << (fail ? "FAILED:" : "passed:"); diff --git a/validat2.cpp b/validat2.cpp index 3d984e92..3b45196a 100644 --- a/validat2.cpp +++ b/validat2.cpp @@ -63,7 +63,7 @@ class FixedRNG : public RandomNumberGenerator public: FixedRNG(BufferedTransformation &source) : m_source(source) {} - void GenerateBlock(byte *output, size_t size) + void GenerateBlock(::byte *output, size_t size) { m_source.Get(output, size); } @@ -83,16 +83,16 @@ bool ValidateBBS() bool pass = true, fail; int j; - static const byte output1[] = { + static const ::byte output1[] = { 0x49,0xEA,0x2C,0xFD,0xB0,0x10,0x64,0xA0,0xBB,0xB9, 0x2A,0xF1,0x01,0xDA,0xC1,0x8A,0x94,0xF7,0xB7,0xCE}; - static const byte output2[] = { + static const ::byte output2[] = { 0x74,0x45,0x48,0xAE,0xAC,0xB7,0x0E,0xDF,0xAF,0xD7, 0xD5,0x0E,0x8E,0x29,0x83,0x75,0x6B,0x27,0x46,0xA1}; // Coverity finding, also see http://stackoverflow.com/a/34509163/608639. StreamState ss(std::cout); - byte buf[20]; + ::byte buf[20]; bbs.GenerateBlock(buf, 20); fail = memcmp(output1, buf, 20) != 0; @@ -136,7 +136,7 @@ bool SignatureValidate(PK_Signer &priv, PK_Verifier &pub, bool thorough = false) std::cout << (fail ? "FAILED " : "passed "); std::cout << "signature key validation\n"; - const byte *message = (byte *)"test message"; + const ::byte *message = (::byte *)"test message"; const int messageLen = 12; SecByteBlock signature(priv.MaxSignatureLength()); @@ -187,7 +187,7 @@ bool CryptoSystemValidate(PK_Decryptor &priv, PK_Encryptor &pub, bool thorough = std::cout << (fail ? "FAILED " : "passed "); std::cout << "cryptosystem key validation\n"; - const byte *message = (byte *)"test message"; + const ::byte *message = (::byte *)"test message"; const int messageLen = 12; SecByteBlock ciphertext(priv.CiphertextLength(messageLen)); SecByteBlock plaintext(priv.MaxPlaintextLength(ciphertext.size())); @@ -283,12 +283,12 @@ bool ValidateRSA() { std::cout << "\nRSA validation suite running...\n\n"; - byte out[100], outPlain[100]; + ::byte out[100], outPlain[100]; bool pass = true, fail; { const char *plain = "Everyone gets Friday off."; - static const byte signature[] = + static const ::byte signature[] = "\x05\xfa\x6a\x81\x2f\xc7\xdf\x8b\xf4\xf2\x54\x25\x09\xe0\x3e\x84" "\x6e\x11\xb9\xc6\x20\xbe\x20\x09\xef\xb4\x40\xef\xbc\xc6\x69\x21" "\x69\x94\xac\x04\xf3\x41\xb5\x7d\x05\x20\x2d\x42\x8f\xb2\xa2\x7b" @@ -298,21 +298,21 @@ bool ValidateRSA() Weak::RSASSA_PKCS1v15_MD2_Signer rsaPriv(keys); Weak::RSASSA_PKCS1v15_MD2_Verifier rsaPub(rsaPriv); - size_t signatureLength = rsaPriv.SignMessage(GlobalRNG(), (byte *)plain, strlen(plain), out); + size_t signatureLength = rsaPriv.SignMessage(GlobalRNG(), (::byte *)plain, strlen(plain), out); fail = memcmp(signature, out, 64) != 0; pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed "); std::cout << "signature check against test vector\n"; - fail = !rsaPub.VerifyMessage((byte *)plain, strlen(plain), out, signatureLength); + fail = !rsaPub.VerifyMessage((::byte *)plain, strlen(plain), out, signatureLength); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed "); std::cout << "verification check against test vector\n"; out[10]++; - fail = rsaPub.VerifyMessage((byte *)plain, strlen(plain), out, signatureLength); + fail = rsaPub.VerifyMessage((::byte *)plain, strlen(plain), out, signatureLength); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed "); @@ -332,14 +332,14 @@ bool ValidateRSA() pass = CryptoSystemValidate(rsaPriv, rsaPub) && pass; } { - byte *plain = (byte *) + ::byte *plain = (::byte *) "\x54\x85\x9b\x34\x2c\x49\xea\x2a"; - static const byte encrypted[] = + static const ::byte encrypted[] = "\x14\xbd\xdd\x28\xc9\x83\x35\x19\x23\x80\xe8\xe5\x49\xb1\x58\x2a" "\x8b\x40\xb4\x48\x6d\x03\xa6\xa5\x31\x1f\x1f\xd5\xf0\xa1\x80\xe4" "\x17\x53\x03\x29\xa9\x34\x90\x74\xb1\x52\x13\x54\x29\x08\x24\x52" "\x62\x51"; - static const byte oaepSeed[] = + static const ::byte oaepSeed[] = "\xaa\xfd\x12\xf6\x59\xca\xe6\x34\x89\xb4\x79\xe5\x07\x6d\xde\xc2" "\xf0\x6c\xb5\x8f"; ByteQueue bq; @@ -901,12 +901,12 @@ bool ValidateECDSA() // from Sample Test Vectors for P1363 GF2NT gf2n(191, 9, 0); - byte a[]="\x28\x66\x53\x7B\x67\x67\x52\x63\x6A\x68\xF5\x65\x54\xE1\x26\x40\x27\x6B\x64\x9E\xF7\x52\x62\x67"; - byte b[]="\x2E\x45\xEF\x57\x1F\x00\x78\x6F\x67\xB0\x08\x1B\x94\x95\xA3\xD9\x54\x62\xF5\xDE\x0A\xA1\x85\xEC"; + ::byte a[]="\x28\x66\x53\x7B\x67\x67\x52\x63\x6A\x68\xF5\x65\x54\xE1\x26\x40\x27\x6B\x64\x9E\xF7\x52\x62\x67"; + ::byte b[]="\x2E\x45\xEF\x57\x1F\x00\x78\x6F\x67\xB0\x08\x1B\x94\x95\xA3\xD9\x54\x62\xF5\xDE\x0A\xA1\x85\xEC"; EC2N ec(gf2n, PolynomialMod2(a,24), PolynomialMod2(b,24)); EC2N::Point P; - bool result = ec.DecodePoint(P, (byte *)"\x04\x36\xB3\xDA\xF8\xA2\x32\x06\xF9\xC4\xF2\x99\xD7\xB2\x1A\x9C\x36\x91\x37\xF2\xC8\x4A\xE1\xAA\x0D" + bool result = ec.DecodePoint(P, (::byte *)"\x04\x36\xB3\xDA\xF8\xA2\x32\x06\xF9\xC4\xF2\x99\xD7\xB2\x1A\x9C\x36\x91\x37\xF2\xC8\x4A\xE1\xAA\x0D" "\x76\x5B\xE7\x34\x33\xB3\xF9\x5E\x33\x29\x32\xE7\x0E\xA2\x45\xCA\x24\x18\xEA\x0E\xF9\x80\x18\xFB", ec.EncodedPointSize()); CRYPTOPP_ASSERT(result); CRYPTOPP_UNUSED(result); @@ -918,7 +918,7 @@ bool ValidateECDSA() Integer h("A9993E364706816ABA3E25717850C26C9CD0D89DH"); Integer k("3eeace72b4919d991738d521879f787cb590aff8189d2b69H"); - static const byte sig[]="\x03\x8e\x5a\x11\xfb\x55\xe4\xc6\x54\x71\xdc\xd4\x99\x84\x52\xb1\xe0\x2d\x8a\xf7\x09\x9b\xb9\x30" + static const ::byte sig[]="\x03\x8e\x5a\x11\xfb\x55\xe4\xc6\x54\x71\xdc\xd4\x99\x84\x52\xb1\xe0\x2d\x8a\xf7\x09\x9b\xb9\x30" "\x0c\x9a\x08\xc3\x44\x68\xc2\x44\xb4\xe5\xd6\xb2\x1b\x3c\x68\x36\x28\x07\x41\x60\x20\x32\x8b\x6e"; Integer r(sig, 24); Integer s(sig+24, 24); @@ -933,13 +933,13 @@ bool ValidateECDSA() std::cout << (fail ? "FAILED " : "passed "); std::cout << "signature check against test vector\n"; - fail = !pub.VerifyMessage((byte *)"abc", 3, sig, sizeof(sig)); + fail = !pub.VerifyMessage((::byte *)"abc", 3, sig, sizeof(sig)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed "); std::cout << "verification check against test vector\n"; - fail = pub.VerifyMessage((byte *)"xyz", 3, sig, sizeof(sig)); + fail = pub.VerifyMessage((::byte *)"xyz", 3, sig, sizeof(sig)); pass = pass && !fail; pass = SignatureValidate(priv, pub) && pass; @@ -974,10 +974,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; + const ::byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; const size_t len = strlen((char*)msg); - byte signature[48]; + ::byte signature[48]; r.Encode(signature+0, 24); s.Encode(signature+24, 24); @@ -1011,10 +1011,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; + const ::byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; const size_t len = strlen((char*)msg); - byte signature[64]; + ::byte signature[64]; r.Encode(signature+0, 32); s.Encode(signature+32, 32); @@ -1048,10 +1048,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; + const ::byte msg[] = "Example of ECGDSA with the hash function RIPEMD-160"; const size_t len = strlen((char*)msg); - byte signature[80]; + ::byte signature[80]; r.Encode(signature+0, 40); s.Encode(signature+40, 40); @@ -1085,10 +1085,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function SHA-1"; + const ::byte msg[] = "Example of ECGDSA with the hash function SHA-1"; const size_t len = strlen((char*)msg); - byte signature[48]; + ::byte signature[48]; r.Encode(signature+0, 24); s.Encode(signature+24, 24); @@ -1122,10 +1122,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function SHA-224"; + const ::byte msg[] = "Example of ECGDSA with the hash function SHA-224"; const size_t len = strlen((char*)msg); - byte signature[64]; + ::byte signature[64]; r.Encode(signature+0, 32); s.Encode(signature+32, 32); @@ -1159,10 +1159,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function SHA-224"; + const ::byte msg[] = "Example of ECGDSA with the hash function SHA-224"; const size_t len = strlen((char*)msg); - byte signature[80]; + ::byte signature[80]; r.Encode(signature+0, 40); s.Encode(signature+40, 40); @@ -1196,10 +1196,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function SHA-256"; + const ::byte msg[] = "Example of ECGDSA with the hash function SHA-256"; const size_t len = strlen((char*)msg); - byte signature[80]; + ::byte signature[80]; r.Encode(signature+0, 40); s.Encode(signature+40, 40); @@ -1233,10 +1233,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function SHA-384"; + const ::byte msg[] = "Example of ECGDSA with the hash function SHA-384"; const size_t len = strlen((char*)msg); - byte signature[128]; + ::byte signature[128]; r.Encode(signature+0, 64); s.Encode(signature+64, 64); @@ -1270,10 +1270,10 @@ bool ValidateECGDSA() fail = (r != rExp) || (s != sExp); pass = pass && !fail; - const byte msg[] = "Example of ECGDSA with the hash function SHA-512"; + const ::byte msg[] = "Example of ECGDSA with the hash function SHA-512"; const size_t len = strlen((char*)msg); - byte signature[128]; + ::byte signature[128]; r.Encode(signature+0, 64); s.Encode(signature+64, 64); @@ -1297,7 +1297,7 @@ bool ValidateESIGN() bool pass = true, fail; static const char plain[] = "test"; - static const byte signature[] = + static const ::byte signature[] = "\xA3\xE3\x20\x65\xDE\xDA\xE7\xEC\x05\xC1\xBF\xCD\x25\x79\x7D\x99\xCD\xD5\x73\x9D\x9D\xF3\xA4\xAA\x9A\xA4\x5A\xC8\x23\x3D\x0D\x37" "\xFE\xBC\x76\x3F\xF1\x84\xF6\x59\x14\x91\x4F\x0C\x34\x1B\xAE\x9A\x5C\x2E\x2E\x38\x08\x78\x77\xCB\xDC\x3C\x7E\xA0\x34\x44\x5B\x0F" "\x67\xD9\x35\x2A\x79\x47\x1A\x52\x37\x71\xDB\x12\x67\xC1\xB6\xC6\x66\x73\xB3\x40\x2E\xD6\xF2\x1A\x84\x0A\xB6\x7B\x0F\xEB\x8B\x88" @@ -1312,14 +1312,14 @@ bool ValidateESIGN() fail = !SignatureValidate(signer, verifier); pass = pass && !fail; - fail = !verifier.VerifyMessage((byte *)plain, strlen(plain), signature, verifier.SignatureLength()); + fail = !verifier.VerifyMessage((::byte *)plain, strlen(plain), signature, verifier.SignatureLength()); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed "); std::cout << "verification check against test vector\n"; std::cout << "Generating signature key from seed..." << std::endl; - signer.AccessKey().GenerateRandom(GlobalRNG(), MakeParameters("Seed", ConstByteArrayParameter((const byte *)"test", 4))("KeySize", 3*512)); + signer.AccessKey().GenerateRandom(GlobalRNG(), MakeParameters("Seed", ConstByteArrayParameter((const ::byte *)"test", 4))("KeySize", 3*512)); verifier = signer; fail = !SignatureValidate(signer, verifier); diff --git a/validat3.cpp b/validat3.cpp index 81257ec8..114c0a3d 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -54,12 +54,12 @@ NAMESPACE_BEGIN(Test) struct HashTestTuple { HashTestTuple(const char *input, const char *output, unsigned int repeatTimes=1) - : input((byte *)input), output((byte *)output), inputLen(strlen(input)), repeatTimes(repeatTimes) {} + : input((::byte *)input), output((::byte *)output), inputLen(strlen(input)), repeatTimes(repeatTimes) {} HashTestTuple(const char *input, unsigned int inputLen, const char *output, unsigned int repeatTimes) - : input((byte *)input), output((byte *)output), inputLen(inputLen), repeatTimes(repeatTimes) {} + : input((::byte *)input), output((::byte *)output), inputLen(inputLen), repeatTimes(repeatTimes) {} - const byte *input, *output; + const ::byte *input, *output; size_t inputLen; unsigned int repeatTimes; }; @@ -514,7 +514,7 @@ bool ValidateXMACC() bool ValidateTTMAC() { - const byte key[TTMAC::KEYLENGTH]={ + const ::byte key[TTMAC::KEYLENGTH]={ 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99, 0xaa,0xbb,0xcc,0xdd,0xee,0xff,0x01,0x23,0x45,0x67}; @@ -528,7 +528,7 @@ bool ValidateTTMAC() "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "12345678901234567890123456789012345678901234567890123456789012345678901234567890"}; - const byte output[8][TTMAC::DIGESTSIZE]={ + const ::byte output[8][TTMAC::DIGESTSIZE]={ {0x2d,0xec,0x8e,0xd4,0xa0,0xfd,0x71,0x2e,0xd9,0xfb,0xf2,0xab,0x46,0x6e,0xc2,0xdf,0x21,0x21,0x5e,0x4a}, {0x58,0x93,0xe3,0xe6,0xe3,0x06,0x70,0x4d,0xd7,0x7a,0xd6,0xe6,0xed,0x43,0x2c,0xde,0x32,0x1a,0x77,0x56}, {0x70,0xbf,0xd1,0x02,0x97,0x97,0xa5,0xc1,0x6d,0xa5,0xb5,0x57,0xa1,0xf0,0xb2,0x77,0x9b,0x78,0x49,0x7e}, @@ -541,7 +541,7 @@ bool ValidateTTMAC() // Coverity finding, also see http://stackoverflow.com/a/34509163/608639. StreamState ss(std::cout); - byte digest[TTMAC::DIGESTSIZE]; + ::byte digest[TTMAC::DIGESTSIZE]; bool pass=true, fail; std::cout << "\nTwo-Track-MAC validation suite running...\n"; @@ -549,10 +549,10 @@ bool ValidateTTMAC() TTMAC mac(key, sizeof(key)); for (unsigned int k = 0; k::DIGESTSIZE]; + ::byte digest[Poly1305::DIGESTSIZE]; // Positive tests for (unsigned int i=0; i poly1305((const byte*)tests[i].key, tests[i].klen); - poly1305.Resynchronize((const byte*)tests[i].nonce, (int)tests[i].nlen); - poly1305.Update((const byte*)tests[i].message, tests[i].mlen); + Poly1305 poly1305((const ::byte*)tests[i].key, tests[i].klen); + poly1305.Resynchronize((const ::byte*)tests[i].nonce, (int)tests[i].nlen); + poly1305.Update((const ::byte*)tests[i].message, tests[i].mlen); poly1305.Final(digest); fail = !!memcmp(digest, tests[i].digest, tests[i].dlen) != 0; @@ -859,8 +859,8 @@ bool ValidatePoly1305() // Positive tests for (unsigned int i=0; i poly1305((const byte*)tests[i].key, tests[i].klen,(const byte*)tests[i].nonce, (int)tests[i].nlen); - poly1305.Update((const byte*)tests[i].message, tests[i].mlen); + Poly1305 poly1305((const ::byte*)tests[i].key, tests[i].klen,(const ::byte*)tests[i].nonce, (int)tests[i].nlen); + poly1305.Update((const ::byte*)tests[i].message, tests[i].mlen); poly1305.Final(digest); fail = !!memcmp(digest, tests[i].digest, tests[i].dlen) != 0; @@ -876,9 +876,9 @@ bool ValidatePoly1305() // Negative tests for (unsigned int i=0; i poly1305((const byte*)tests[i].key, tests[i].klen); - poly1305.Resynchronize((const byte*)tests[i].nonce, (int)tests[i].nlen); - poly1305.Update((const byte*)tests[i].message, tests[i].mlen); + Poly1305 poly1305((const ::byte*)tests[i].key, tests[i].klen); + poly1305.Resynchronize((const ::byte*)tests[i].nonce, (int)tests[i].nlen); + poly1305.Update((const ::byte*)tests[i].message, tests[i].mlen); poly1305.Final(digest); unsigned int next = (i+1) % COUNTOF(tests); @@ -930,31 +930,31 @@ bool ValidateSipHash() // Siphash-2-4, 64-bit MAC { - const byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; + const ::byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; SipHash<2,4, false> hash(key, 16); - byte digest[SipHash<2,4, false>::DIGESTSIZE]; + ::byte digest[SipHash<2,4, false>::DIGESTSIZE]; - hash.Update((const byte*)"", 0); + hash.Update((const ::byte*)"", 0); hash.Final(digest); fail = !!memcmp("\x31\x0E\x0E\xDD\x47\xDB\x6F\x72", digest, COUNTOF(digest)); pass1 = !fail && pass1; - hash.Update((const byte*)"\x00", 1); + hash.Update((const ::byte*)"\x00", 1); hash.Final(digest); fail = !!memcmp("\xFD\x67\xDC\x93\xC5\x39\xF8\x74", digest, COUNTOF(digest)); pass1 = !fail && pass1; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); hash.Final(digest); fail = !!memcmp("\x37\xD1\x01\x8B\xF5\x00\x02\xAB", digest, COUNTOF(digest)); pass1 = !fail && pass1; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); hash.Final(digest); fail = !!memcmp("\x62\x24\x93\x9A\x79\xF5\xF5\x93", digest, COUNTOF(digest)); pass1 = !fail && pass1; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); hash.Final(digest); fail = !!memcmp("\xB0\xE4\xA9\x0B\xDF\x82\x00\x9E", digest, COUNTOF(digest)); pass1 = !fail && pass1; @@ -965,31 +965,31 @@ bool ValidateSipHash() // Siphash-2-4, 128-bit MAC { - const byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; + const ::byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; SipHash<2,4, true> hash(key, 16); - byte digest[SipHash<2,4, true>::DIGESTSIZE]; + ::byte digest[SipHash<2,4, true>::DIGESTSIZE]; - hash.Update((const byte*)"", 0); + hash.Update((const ::byte*)"", 0); hash.Final(digest); fail = !!memcmp("\xA3\x81\x7F\x04\xBA\x25\xA8\xE6\x6D\xF6\x72\x14\xC7\x55\x02\x93", digest, COUNTOF(digest)); pass3 = !fail && pass3; - hash.Update((const byte*)"\x00", 1); + hash.Update((const ::byte*)"\x00", 1); hash.Final(digest); fail = !!memcmp("\xDA\x87\xC1\xD8\x6B\x99\xAF\x44\x34\x76\x59\x11\x9B\x22\xFC\x45", digest, COUNTOF(digest)); pass3 = !fail && pass3; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); hash.Final(digest); fail = !!memcmp("\xA1\xF1\xEB\xBE\xD8\xDB\xC1\x53\xC0\xB8\x4A\xA6\x1F\xF0\x82\x39", digest, COUNTOF(digest)); pass3 = !fail && pass3; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); hash.Final(digest); fail = !!memcmp("\x3B\x62\xA9\xBA\x62\x58\xF5\x61\x0F\x83\xE2\x64\xF3\x14\x97\xB4", digest, COUNTOF(digest)); pass3 = !fail && pass3; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); hash.Final(digest); fail = !!memcmp("\x26\x44\x99\x06\x0A\xD9\xBA\xAB\xC4\x7F\x8B\x02\xBB\x6D\x71\xED", digest, COUNTOF(digest)); pass3 = !fail && pass3; @@ -1000,31 +1000,31 @@ bool ValidateSipHash() // Siphash-4-8, 64-bit MAC { - const byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; + const ::byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; SipHash<4, 8, false> hash(key, 16); - byte digest[SipHash<4, 8, false>::DIGESTSIZE]; + ::byte digest[SipHash<4, 8, false>::DIGESTSIZE]; - hash.Update((const byte*)"", 0); + hash.Update((const ::byte*)"", 0); hash.Final(digest); fail = !!memcmp("\x41\xDA\x38\x99\x2B\x05\x79\xC8", digest, COUNTOF(digest)); pass2 = !fail && pass2; - hash.Update((const byte*)"\x00", 1); + hash.Update((const ::byte*)"\x00", 1); hash.Final(digest); fail = !!memcmp("\x51\xB8\x95\x52\xF9\x14\x59\xC8", digest, COUNTOF(digest)); pass2 = !fail && pass2; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); hash.Final(digest); fail = !!memcmp("\x47\xD7\x3F\x71\x5A\xBE\xFD\x4E", digest, COUNTOF(digest)); pass2 = !fail && pass2; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); hash.Final(digest); fail = !!memcmp("\x20\xB5\x8B\x9C\x07\x2F\xDB\x50", digest, COUNTOF(digest)); pass2 = !fail && pass2; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); hash.Final(digest); fail = !!memcmp("\x36\x31\x9A\xF3\x5E\xE1\x12\x53", digest, COUNTOF(digest)); pass2 = !fail && pass2; @@ -1035,31 +1035,31 @@ bool ValidateSipHash() // Siphash-4-8, 128-bit MAC { - const byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; + const ::byte key[] = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"; SipHash<4, 8, true> hash(key, 16); - byte digest[SipHash<4, 8, true>::DIGESTSIZE]; + ::byte digest[SipHash<4, 8, true>::DIGESTSIZE]; - hash.Update((const byte*)"", 0); + hash.Update((const ::byte*)"", 0); hash.Final(digest); fail = !!memcmp("\x1F\x64\xCE\x58\x6D\xA9\x04\xE9\xCF\xEC\xE8\x54\x83\xA7\x0A\x6C", digest, COUNTOF(digest)); pass4 = !fail && pass4; - hash.Update((const byte*)"\x00", 1); + hash.Update((const ::byte*)"\x00", 1); hash.Final(digest); fail = !!memcmp("\x47\x34\x5D\xA8\xEF\x4C\x79\x47\x6A\xF2\x7C\xA7\x91\xC7\xA2\x80", digest, COUNTOF(digest)); pass4 = !fail && pass4; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06", 7); hash.Final(digest); fail = !!memcmp("\xED\x00\xE1\x3B\x18\x4B\xF1\xC2\x72\x6B\x8B\x54\xFF\xD2\xEE\xE0", digest, COUNTOF(digest)); pass4 = !fail && pass4; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06\x07", 8); hash.Final(digest); fail = !!memcmp("\xA7\xD9\x46\x13\x8F\xF9\xED\xF5\x36\x4A\x5A\x23\xAF\xCA\xE0\x63", digest, COUNTOF(digest)); pass4 = !fail && pass4; - hash.Update((const byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); + hash.Update((const ::byte*)"\x00\x01\x02\x03\x04\x05\x06\x07\x08", 9); hash.Final(digest); fail = !!memcmp("\x9E\x73\x14\xB7\x54\x5C\xEC\xA3\x8B\x9A\x55\x49\xE4\xFB\x0B\xE8", digest, COUNTOF(digest)); pass4 = !fail && pass4; @@ -1475,7 +1475,7 @@ bool ValidateBLAKE2s() } }; - byte digest[BLAKE2s::DIGESTSIZE]; + ::byte digest[BLAKE2s::DIGESTSIZE]; for (unsigned int i=0; i(BIG_ENDIAN_ORDER, m_nhKey(), m_nhKey(), m_nhKeySize()*sizeof(word64)); /* Fill poly key */ @@ -107,21 +107,21 @@ void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con m_padCached = false; size_t nonceLength; - const byte *nonce = GetIVAndThrowIfInvalid(params, nonceLength); + const ::byte *nonce = GetIVAndThrowIfInvalid(params, nonceLength); Resynchronize(nonce, (int)nonceLength); } -void VMAC_Base::GetNextIV(RandomNumberGenerator &rng, byte *IV) +void VMAC_Base::GetNextIV(RandomNumberGenerator &rng, ::byte *IV) { SimpleKeyingInterface::GetNextIV(rng, IV); IV[0] &= 0x7f; } -void VMAC_Base::Resynchronize(const byte *nonce, int len) +void VMAC_Base::Resynchronize(const ::byte *nonce, int len) { size_t length = ThrowIfInvalidIVLength(len); size_t s = IVSize(); - byte *storedNonce = m_nonce(); + ::byte *storedNonce = m_nonce(); if (m_is128) { @@ -866,7 +866,7 @@ static word64 L3Hash(const word64 *input, const word64 *l3Key, size_t len) return rl; } -void VMAC_Base::TruncatedFinal(byte *mac, size_t size) +void VMAC_Base::TruncatedFinal(::byte *mac, size_t size) { CRYPTOPP_ASSERT(IsAlignedOn(DataBuf(),GetAlignmentOf())); CRYPTOPP_ASSERT(IsAlignedOn(m_polyState(),GetAlignmentOf())); diff --git a/vmac.h b/vmac.h index 535e2075..2a9eaea9 100644 --- a/vmac.h +++ b/vmac.h @@ -28,11 +28,11 @@ public: std::string AlgorithmName() const {return std::string("VMAC(") + GetCipher().AlgorithmName() + ")-" + IntToString(DigestSize()*8);} unsigned int IVSize() const {return GetCipher().BlockSize();} unsigned int MinIVLength() const {return 1;} - void Resynchronize(const byte *nonce, int length=-1); - void GetNextIV(RandomNumberGenerator &rng, byte *IV); + void Resynchronize(const ::byte *nonce, int length=-1); + void GetNextIV(RandomNumberGenerator &rng, ::byte *IV); unsigned int DigestSize() const {return m_is128 ? 16 : 8;}; - void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs ¶ms); - void TruncatedFinal(byte *mac, size_t size); + void UncheckedSetKey(const ::byte *userKey, unsigned int keylength, const NameValuePairs ¶ms); + void TruncatedFinal(::byte *mac, size_t size); unsigned int BlockSize() const {return m_L1KeyLength;} ByteOrder GetByteOrder() const {return LITTLE_ENDIAN_ORDER;} unsigned int OptimalDataAlignment() const; @@ -54,10 +54,10 @@ protected: CRYPTOPP_BLOCK_1(polyState, word64, 4*(m_is128+1)) CRYPTOPP_BLOCK_2(nhKey, word64, m_L1KeyLength/sizeof(word64) + 2*m_is128) - CRYPTOPP_BLOCK_3(data, byte, m_L1KeyLength) + CRYPTOPP_BLOCK_3(data, ::byte, m_L1KeyLength) CRYPTOPP_BLOCK_4(l3Key, word64, 2*(m_is128+1)) - CRYPTOPP_BLOCK_5(nonce, byte, IVSize()) - CRYPTOPP_BLOCK_6(pad, byte, IVSize()) + CRYPTOPP_BLOCK_5(nonce, ::byte, IVSize()) + CRYPTOPP_BLOCK_6(pad, ::byte, IVSize()) CRYPTOPP_BLOCKS_END(6) bool m_is128, m_padCached, m_isFirstBlock; diff --git a/wake.cpp b/wake.cpp index 8501bcf7..360202af 100644 --- a/wake.cpp +++ b/wake.cpp @@ -55,14 +55,14 @@ void WAKE_Base::GenKey(word32 k0, word32 k1, word32 k2, word32 k3) t[p]=(t[p] & 0x00ffffff) ^ x ; } t[256]=t[0] ; - byte y=byte(x); + ::byte y=::byte(x); for (p=0 ; p<256 ; p++) { // further change perm. - t[p]=t[y=byte(t[p^y]^y)] ; // and other digits + t[p]=t[y=::byte(t[p^y]^y)] ; // and other digits t[y]=t[p+1] ; } } template -void WAKE_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length) +void WAKE_Policy::CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length) { CRYPTOPP_UNUSED(params); CRYPTOPP_UNUSED(key); CRYPTOPP_UNUSED(length); word32 k0, k1, k2, k3; @@ -72,7 +72,7 @@ void WAKE_Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *key, // OFB template -void WAKE_Policy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) +void WAKE_Policy::OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount) { #define WAKE_OUTPUT(x)\ while (iterationCount--)\ diff --git a/wake.h b/wake.h index 81060801..f611303e 100644 --- a/wake.h +++ b/wake.h @@ -40,9 +40,9 @@ template class CRYPTOPP_NO_VTABLE WAKE_Policy : public AdditiveCipherConcretePolicy, protected WAKE_Base { protected: - void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); + void CipherSetKey(const NameValuePairs ¶ms, const ::byte *key, size_t length); // OFB - void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); + void OperateKeystream(KeystreamOperation operation, ::byte *output, const ::byte *input, size_t iterationCount); bool CipherIsRandomAccess() const {return false;} }; diff --git a/whrlpool.cpp b/whrlpool.cpp index 1278ad8a..4e72b552 100644 --- a/whrlpool.cpp +++ b/whrlpool.cpp @@ -97,7 +97,7 @@ void Whirlpool::InitState(HashWordType *state) memset(state, 0, 8*sizeof(state[0])); } -void Whirlpool::TruncatedFinal(byte *hash, size_t size) +void Whirlpool::TruncatedFinal(::byte *hash, size_t size) { ThrowIfInvalidTruncatedSize(size); @@ -613,23 +613,23 @@ void Whirlpool::Transform(word64 *digest, const word64 *block) #define KSL(op, i, a, b, c, d) \ t = (word32)k[i];\ - w##a = Whirlpool_C[3*256 + (byte)t] ^ (op ? w##a : 0);\ + w##a = Whirlpool_C[3*256 + (::byte)t] ^ (op ? w##a : 0);\ t >>= 8;\ - w##b = Whirlpool_C[2*256 + (byte)t] ^ (op ? w##b : 0);\ + w##b = Whirlpool_C[2*256 + (::byte)t] ^ (op ? w##b : 0);\ t >>= 8;\ - w##c = Whirlpool_C[1*256 + (byte)t] ^ (op ? w##c : 0);\ + w##c = Whirlpool_C[1*256 + (::byte)t] ^ (op ? w##c : 0);\ t >>= 8;\ w##d = Whirlpool_C[0*256 + t] ^ (op ? w##d : 0); #define KSH(op, i, a, b, c, d) \ t = (word32)(k[(i+4)%8]>>32);\ - w##a = Whirlpool_C[3*256 + (byte)t] ^ (op ? w##a : rotrFixed(w##a, 32));\ + w##a = Whirlpool_C[3*256 + (::byte)t] ^ (op ? w##a : rotrFixed(w##a, 32));\ if (op==2) k[a] = w##a;\ t >>= 8;\ - w##b = Whirlpool_C[2*256 + (byte)t] ^ (op ? w##b : rotrFixed(w##b, 32));\ + w##b = Whirlpool_C[2*256 + (::byte)t] ^ (op ? w##b : rotrFixed(w##b, 32));\ if (op==2) k[b] = w##b;\ t >>= 8;\ - w##c = Whirlpool_C[1*256 + (byte)t] ^ (op ? w##c : rotrFixed(w##c, 32));\ + w##c = Whirlpool_C[1*256 + (::byte)t] ^ (op ? w##c : rotrFixed(w##c, 32));\ if (op==2) k[c] = w##c;\ t >>= 8;\ w##d = Whirlpool_C[0*256 + t] ^ (op ? w##d : rotrFixed(w##d, 32));\ @@ -637,16 +637,16 @@ void Whirlpool::Transform(word64 *digest, const word64 *block) #define TSL(op, i, a, b, c, d) \ t = (word32)s[i];\ - w##a = Whirlpool_C[3*256 + (byte)t] ^ (op ? w##a : 0);\ + w##a = Whirlpool_C[3*256 + (::byte)t] ^ (op ? w##a : 0);\ t >>= 8;\ - w##b = Whirlpool_C[2*256 + (byte)t] ^ (op ? w##b : 0);\ + w##b = Whirlpool_C[2*256 + (::byte)t] ^ (op ? w##b : 0);\ t >>= 8;\ - w##c = Whirlpool_C[1*256 + (byte)t] ^ (op ? w##c : 0);\ + w##c = Whirlpool_C[1*256 + (::byte)t] ^ (op ? w##c : 0);\ t >>= 8;\ w##d = Whirlpool_C[0*256 + t] ^ (op ? w##d : 0); #define TSH_OP(op, a, b) \ - w##a = Whirlpool_C[b*256 + (byte)t] ^ (op ? w##a : rotrFixed(w##a, 32) ^ k[a]);\ + w##a = Whirlpool_C[b*256 + (::byte)t] ^ (op ? w##a : rotrFixed(w##a, 32) ^ k[a]);\ if (op==2) s[a] = w##a;\ if (op==3) digest[a] ^= w##a;\ diff --git a/whrlpool.h b/whrlpool.h index dd6a0742..4c05cd2c 100644 --- a/whrlpool.h +++ b/whrlpool.h @@ -12,7 +12,7 @@ class Whirlpool : public IteratedHashWithStaticTransform= 8) { - m_outputBuffer[m_bytesBuffered++] = (byte)m_buffer; + m_outputBuffer[m_bytesBuffered++] = (::byte)m_buffer; if (m_bytesBuffered == m_outputBuffer.size()) { AttachedTransformation()->PutModifiable(m_outputBuffer, m_bytesBuffered); @@ -77,7 +77,7 @@ void LowFirstBitWriter::FlushBitBuffer() } if (m_bitsBuffered > 0) { - AttachedTransformation()->Put((byte)m_buffer); + AttachedTransformation()->Put((::byte)m_buffer); m_buffer = 0; m_bitsBuffered = 0; } @@ -301,10 +301,10 @@ void Deflator::Reset(bool forceReset) m_detectSkip = 0; // m_prev will be initialized automatically in InsertString - std::fill(m_head.begin(), m_head.end(), byte(0)); + std::fill(m_head.begin(), m_head.end(), ::byte(0)); - std::fill(m_literalCounts.begin(), m_literalCounts.end(), byte(0)); - std::fill(m_distanceCounts.begin(), m_distanceCounts.end(), byte(0)); + std::fill(m_literalCounts.begin(), m_literalCounts.end(), ::byte(0)); + std::fill(m_distanceCounts.begin(), m_distanceCounts.end(), ::byte(0)); } void Deflator::SetDeflateLevel(int deflateLevel) @@ -337,7 +337,7 @@ void Deflator::SetDeflateLevel(int deflateLevel) m_deflateLevel = deflateLevel; } -unsigned int Deflator::FillWindow(const byte *str, size_t length) +unsigned int Deflator::FillWindow(const ::byte *str, size_t length) { unsigned int maxBlockSize = (unsigned int)STDMIN(2UL*DSIZE, 0xffffUL); @@ -376,7 +376,7 @@ unsigned int Deflator::FillWindow(const byte *str, size_t length) return accepted; } -inline unsigned int Deflator::ComputeHash(const byte *str) const +inline unsigned int Deflator::ComputeHash(const ::byte *str) const { CRYPTOPP_ASSERT(str+3 <= m_byteBuffer + m_stringStart + m_lookahead); return ((str[0] << 10) ^ (str[1] << 5) ^ str[2]) & HMASK; @@ -391,7 +391,7 @@ unsigned int Deflator::LongestMatch(unsigned int &bestMatch) const if (m_lookahead <= bestLength) return 0; - const byte *scan = m_byteBuffer + m_stringStart, *scanEnd = scan + STDMIN((unsigned int)MAX_MATCH, m_lookahead); + const ::byte *scan = m_byteBuffer + m_stringStart, *scanEnd = scan + STDMIN((unsigned int)MAX_MATCH, m_lookahead); unsigned int limit = m_stringStart > (DSIZE-MAX_MATCH) ? m_stringStart - (DSIZE-MAX_MATCH) : 0; unsigned int current = m_head[ComputeHash(scan)]; @@ -401,7 +401,7 @@ unsigned int Deflator::LongestMatch(unsigned int &bestMatch) const while (current > limit && --chainLength > 0) { - const byte *match = m_byteBuffer + current; + const ::byte *match = m_byteBuffer + current; CRYPTOPP_ASSERT(scan + bestLength < m_byteBuffer + m_stringStart + m_lookahead); if (scan[bestLength-1] == match[bestLength-1] && scan[bestLength] == match[bestLength] && scan[0] == match[0] && scan[1] == match[1]) { @@ -512,7 +512,7 @@ void Deflator::ProcessBuffer() } } -size_t Deflator::Put2(const byte *str, size_t length, int messageEnd, bool blocking) +size_t Deflator::Put2(const ::byte *str, size_t length, int messageEnd, bool blocking) { if (!blocking) throw BlockingInputOnly("Deflator"); @@ -556,7 +556,7 @@ bool Deflator::IsolatedFlush(bool hardFlush, bool blocking) return false; } -void Deflator::LiteralByte(byte b) +void Deflator::LiteralByte(::byte b) { if (m_matchBufferEnd == m_matchBuffer.size()) EndBlock(false); diff --git a/zdeflate.h b/zdeflate.h index e9c51b1c..d5bbe280 100644 --- a/zdeflate.h +++ b/zdeflate.h @@ -34,7 +34,7 @@ protected: unsigned long m_bitCount; unsigned long m_buffer; unsigned int m_bitsBuffered, m_bytesBuffered; - FixedSizeSecBlock m_outputBuffer; + FixedSizeSecBlock< ::byte, 256> m_outputBuffer; }; //! \class HuffmanEncoder @@ -125,12 +125,12 @@ public: int GetLog2WindowSize() const {return m_log2WindowSize;} void IsolatedInitialize(const NameValuePairs ¶meters); - size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); + size_t Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking); bool IsolatedFlush(bool hardFlush, bool blocking); protected: virtual void WritePrestreamHeader() {} - virtual void ProcessUncompressedData(const byte *string, size_t length) + virtual void ProcessUncompressedData(const ::byte *string, size_t length) {CRYPTOPP_UNUSED(string), CRYPTOPP_UNUSED(length);} virtual void WritePoststreamTail() {} @@ -139,13 +139,13 @@ protected: void InitializeStaticEncoders(); void Reset(bool forceReset = false); - unsigned int FillWindow(const byte *str, size_t length); - unsigned int ComputeHash(const byte *str) const; + unsigned int FillWindow(const ::byte *str, size_t length); + unsigned int ComputeHash(const ::byte *str) const; unsigned int LongestMatch(unsigned int &bestMatch) const; void InsertString(unsigned int start); void ProcessBuffer(); - void LiteralByte(byte b); + void LiteralByte(::byte b); void MatchFound(unsigned int distance, unsigned int length); void EncodeBlock(bool eof, unsigned int blockType); void EndBlock(bool eof); diff --git a/zinflate.cpp b/zinflate.cpp index 41690ef9..3bd453bb 100644 --- a/zinflate.cpp +++ b/zinflate.cpp @@ -26,7 +26,7 @@ inline bool LowFirstBitReader::FillBuffer(unsigned int length) { while (m_bitsBuffered < length) { - byte b; + ::byte b; if (!m_store.Get(b)) return false; m_buffer |= (unsigned long)b << m_bitsBuffered; @@ -238,7 +238,7 @@ void Inflator::IsolatedInitialize(const NameValuePairs ¶meters) m_reader.SkipBits(m_reader.BitsBuffered()); } -void Inflator::OutputByte(byte b) +void Inflator::OutputByte(::byte b) { m_window[m_current++] = b; if (m_current == m_window.size()) @@ -250,7 +250,7 @@ void Inflator::OutputByte(byte b) } } -void Inflator::OutputString(const byte *string, size_t length) +void Inflator::OutputString(const ::byte *string, size_t length) { while (length) { @@ -298,7 +298,7 @@ void Inflator::OutputPast(unsigned int length, unsigned int distance) } } -size_t Inflator::Put2(const byte *inString, size_t length, int messageEnd, bool blocking) +size_t Inflator::Put2(const ::byte *inString, size_t length, int messageEnd, bool blocking) { if (!blocking) throw BlockingInputOnly("Inflator"); @@ -376,7 +376,7 @@ void Inflator::DecodeHeader() if (!m_reader.FillBuffer(3)) throw UnexpectedEndErr(); m_eof = m_reader.GetBits(1) != 0; - m_blockType = (byte)m_reader.GetBits(2); + m_blockType = (::byte)m_reader.GetBits(2); switch (m_blockType) { case 0: // stored @@ -486,7 +486,7 @@ bool Inflator::DecodeBody() while (!m_inQueue.IsEmpty() && !blockEnd) { size_t size; - const byte *block = m_inQueue.Spy(size); + const ::byte *block = m_inQueue.Spy(size); size = UnsignedMin(m_storedLen, size); CRYPTOPP_ASSERT(size <= 0xffff); @@ -528,7 +528,7 @@ bool Inflator::DecodeBody() break; } if (m_literal < 256) - OutputByte((byte)m_literal); + OutputByte((::byte)m_literal); else if (m_literal == 256) // end of block { blockEnd = true; @@ -588,9 +588,9 @@ bool Inflator::DecodeBody() if (m_reader.BitsBuffered()) { // undo too much lookahead - SecBlockWithHint buffer(m_reader.BitsBuffered() / 8); + SecBlockWithHint< ::byte, 4> buffer(m_reader.BitsBuffered() / 8); for (unsigned int i=0; iPut(string, length);} virtual unsigned int MaxPoststreamTailSize() const {return 0;} virtual void ProcessPoststreamTail() {} @@ -132,8 +132,8 @@ private: void DecodeHeader(); bool DecodeBody(); void FlushOutput(); - void OutputByte(byte b); - void OutputString(const byte *string, size_t length); + void OutputByte(::byte b); + void OutputString(const ::byte *string, size_t length); void OutputPast(unsigned int length, unsigned int distance); static const HuffmanDecoder *FixedLiteralDecoder(); @@ -145,7 +145,7 @@ private: enum State {PRE_STREAM, WAIT_HEADER, DECODING_BODY, POST_STREAM, AFTER_END}; State m_state; bool m_repeat, m_eof, m_wrappedAround; - byte m_blockType; + ::byte m_blockType; word16 m_storedLen; enum NextDecode {LITERAL, LENGTH_BITS, DISTANCE, DISTANCE_BITS}; NextDecode m_nextDecode; diff --git a/zlib.cpp b/zlib.cpp index 58dd8bc2..6039e460 100644 --- a/zlib.cpp +++ b/zlib.cpp @@ -13,8 +13,8 @@ NAMESPACE_BEGIN(CryptoPP) -static const byte DEFLATE_METHOD = 8; -static const byte FDICT_FLAG = (1 << 5); +static const ::byte DEFLATE_METHOD = 8; +static const ::byte FDICT_FLAG = (1 << 5); // ************************************************************* @@ -22,20 +22,20 @@ void ZlibCompressor::WritePrestreamHeader() { m_adler32.Restart(); CRYPTOPP_ASSERT(((GetLog2WindowSize()-8) << 4) <= 255); - byte cmf = byte(DEFLATE_METHOD | ((GetLog2WindowSize()-8) << 4)); + ::byte cmf = ::byte(DEFLATE_METHOD | ((GetLog2WindowSize()-8) << 4)); CRYPTOPP_ASSERT((GetCompressionLevel() << 6) <= 255); - byte flags = byte(GetCompressionLevel() << 6); + ::byte flags = ::byte(GetCompressionLevel() << 6); AttachedTransformation()->PutWord16(RoundUpToMultipleOf(word16(cmf*256+flags), word16(31))); } -void ZlibCompressor::ProcessUncompressedData(const byte *inString, size_t length) +void ZlibCompressor::ProcessUncompressedData(const ::byte *inString, size_t length) { m_adler32.Update(inString, length); } void ZlibCompressor::WritePoststreamTail() { - FixedSizeSecBlock adler32; + FixedSizeSecBlock< ::byte, 4> adler32; m_adler32.Final(adler32); AttachedTransformation()->Put(adler32, 4); } @@ -57,8 +57,8 @@ void ZlibDecompressor::ProcessPrestreamHeader() { m_adler32.Restart(); - byte cmf; - byte flags; + ::byte cmf; + ::byte flags; if (!m_inQueue.Get(cmf) || !m_inQueue.Get(flags)) throw HeaderErr(); @@ -75,7 +75,7 @@ void ZlibDecompressor::ProcessPrestreamHeader() m_log2WindowSize = 8 + (cmf >> 4); } -void ZlibDecompressor::ProcessDecompressedData(const byte *inString, size_t length) +void ZlibDecompressor::ProcessDecompressedData(const ::byte *inString, size_t length) { AttachedTransformation()->Put(inString, length); m_adler32.Update(inString, length); @@ -83,7 +83,7 @@ void ZlibDecompressor::ProcessDecompressedData(const byte *inString, size_t leng void ZlibDecompressor::ProcessPoststreamTail() { - FixedSizeSecBlock adler32; + FixedSizeSecBlock< ::byte, 4> adler32; if (m_inQueue.Get(adler32, 4) != 4) throw Adler32Err(); if (!m_adler32.Verify(adler32)) diff --git a/zlib.h b/zlib.h index b8e87f99..f274eec4 100644 --- a/zlib.h +++ b/zlib.h @@ -21,7 +21,7 @@ public: protected: void WritePrestreamHeader(); - void ProcessUncompressedData(const byte *string, size_t length); + void ProcessUncompressedData(const ::byte *string, size_t length); void WritePoststreamTail(); Adler32 m_adler32; @@ -47,7 +47,7 @@ public: private: unsigned int MaxPrestreamHeaderSize() const {return 2;} void ProcessPrestreamHeader(); - void ProcessDecompressedData(const byte *string, size_t length); + void ProcessDecompressedData(const ::byte *string, size_t length); unsigned int MaxPoststreamTailSize() const {return 4;} void ProcessPoststreamTail();