[C++17] Use ::byte instead of byte.
parent
aaf62695fc
commit
790e9372e7
6
3way.cpp
6
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<word32, BigEndian> 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<word32, LittleEndian> Block;
|
||||
|
||||
|
|
|
|||
6
3way.h
6
3way.h
|
|
@ -30,7 +30,7 @@ class ThreeWay : public ThreeWay_Info, public BlockCipherDocumentation
|
|||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<ThreeWay_Info>
|
||||
{
|
||||
public:
|
||||
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶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:
|
||||
|
|
|
|||
12
adler32.cpp
12
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:
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -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();}
|
||||
|
|
|
|||
22
algparam.h
22
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;
|
||||
};
|
||||
|
||||
|
|
|
|||
36
arc4.cpp
36
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 <class T>
|
||||
static inline unsigned int MakeByte(T &x, T &y, byte *s)
|
||||
static inline unsigned int MakeByte(T &x, T &y, ::byte *s)
|
||||
{
|
||||
unsigned int a = s[x];
|
||||
y = byte((y+a) & 0xff);
|
||||
y = ::byte((y+a) & 0xff);
|
||||
unsigned int b = s[y];
|
||||
s[x] = byte(b);
|
||||
s[y] = byte(a);
|
||||
x = byte((x+1) & 0xff);
|
||||
s[x] = ::byte(b);
|
||||
s[y] = ::byte(a);
|
||||
x = ::byte((x+1) & 0xff);
|
||||
return s[(a+b) & 0xff];
|
||||
}
|
||||
|
||||
void ARC4_Base::GenerateBlock(byte *output, size_t size)
|
||||
void ARC4_Base::GenerateBlock(::byte *output, size_t size)
|
||||
{
|
||||
while (size--)
|
||||
*output++ = static_cast<byte>(MakeByte(m_x, m_y, m_state));
|
||||
*output++ = static_cast< ::byte>(MakeByte(m_x, m_y, m_state));
|
||||
}
|
||||
|
||||
void ARC4_Base::ProcessData(byte *outString, const byte *inString, size_t length)
|
||||
void ARC4_Base::ProcessData(::byte *outString, const ::byte *inString, size_t length)
|
||||
{
|
||||
if (length == 0)
|
||||
return;
|
||||
|
||||
byte *const s = m_state;
|
||||
::byte *const s = m_state;
|
||||
unsigned int x = m_x;
|
||||
unsigned int y = m_y;
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
10
arc4.h
10
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<ARC4_Base> 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<byte, 256> m_state;
|
||||
byte m_x, m_y;
|
||||
FixedSizeSecBlock< ::byte, 256> m_state;
|
||||
::byte m_x, m_y;
|
||||
};
|
||||
|
||||
//! \class ARC4
|
||||
|
|
|
|||
78
aria.cpp
78
aria.cpp
|
|
@ -179,7 +179,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
typedef BlockGetAndPut<word32, BigEndian, false, false> BigEndianBlock;
|
||||
typedef BlockGetAndPut<word32, NativeByteOrder, true, true> 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 <unsigned int N>
|
||||
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<const byte*>(m_rk.data());
|
||||
const ::byte *rk = reinterpret_cast<const ::byte*>(m_rk.data());
|
||||
word32 *t = const_cast<word32*>(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)] );
|
||||
|
|
|
|||
6
aria.h
6
aria.h
|
|
@ -44,12 +44,12 @@ public:
|
|||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<ARIA_Info>
|
||||
{
|
||||
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<byte, 16*17> m_rk; // round keys
|
||||
FixedSizeAlignedSecBlock< ::byte, 16*17> m_rk; // round keys
|
||||
FixedSizeAlignedSecBlock<word32, 4*7> m_w; // w0, w1, w2, w3, t and u
|
||||
unsigned int m_rounds;
|
||||
};
|
||||
|
|
|
|||
68
asn.cpp
68
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<m_values.size(); i++)
|
||||
EncodeValue(temp, m_values[i]);
|
||||
bt.Put(OBJECT_IDENTIFIER);
|
||||
|
|
@ -270,7 +270,7 @@ void OID::DEREncode(BufferedTransformation &bt) const
|
|||
|
||||
void OID::BERDecode(BufferedTransformation &bt)
|
||||
{
|
||||
byte b;
|
||||
::byte b;
|
||||
if (!bt.Get(b) || b != OBJECT_IDENTIFIER)
|
||||
BERDecodeError();
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ inline BufferedTransformation & EncodedObjectFilter::CurrentTarget()
|
|||
return TheBitBucket();
|
||||
}
|
||||
|
||||
void EncodedObjectFilter::Put(const byte *inString, size_t length)
|
||||
void EncodedObjectFilter::Put(const ::byte *inString, size_t length)
|
||||
{
|
||||
if (m_nCurrentObject == m_nObjects)
|
||||
{
|
||||
|
|
@ -333,7 +333,7 @@ void EncodedObjectFilter::Put(const byte *inString, size_t length)
|
|||
m_state = LENGTH; // fall through
|
||||
case LENGTH:
|
||||
{
|
||||
byte b;
|
||||
::byte b;
|
||||
if (m_level > 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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
62
asn.h
62
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<unsigned int> 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 <class T>
|
||||
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); i++)
|
||||
buf[i+1] = byte(w >> (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 <class T>
|
||||
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--;
|
||||
|
|
|
|||
16
authenc.cpp
16
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()));
|
||||
|
|
|
|||
22
authenc.h
22
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<AuthenticatedSymmetricCipherBase *>(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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
10
basecode.cpp
10
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)
|
||||
|
|
|
|||
14
basecode.h
14
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 2<sup>5</sup>)
|
||||
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;
|
||||
|
|
|
|||
2
bench.h
2
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;
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
74
blake2.cpp
74
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<word32, false>& state);
|
||||
static void BLAKE2_CXX_Compress64(const byte* input, BLAKE2_State<word64, true>& state);
|
||||
static void BLAKE2_CXX_Compress32(const ::byte* input, BLAKE2_State<word32, false>& state);
|
||||
static void BLAKE2_CXX_Compress64(const ::byte* input, BLAKE2_State<word64, true>& 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<word32, false>& state);
|
||||
static void BLAKE2_SSE2_Compress32(const ::byte* input, BLAKE2_State<word32, false>& state);
|
||||
# if (__SUNPRO_CC != 0x5120)
|
||||
static void BLAKE2_SSE2_Compress64(const byte* input, BLAKE2_State<word64, true>& state);
|
||||
static void BLAKE2_SSE2_Compress64(const ::byte* input, BLAKE2_State<word64, true>& state);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
|
||||
static void BLAKE2_SSE4_Compress32(const byte* input, BLAKE2_State<word32, false>& state);
|
||||
static void BLAKE2_SSE4_Compress64(const byte* input, BLAKE2_State<word64, true>& state);
|
||||
static void BLAKE2_SSE4_Compress32(const ::byte* input, BLAKE2_State<word32, false>& state);
|
||||
static void BLAKE2_SSE4_Compress64(const ::byte* input, BLAKE2_State<word64, true>& 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<false>
|
||||
{
|
||||
// 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<false>::sigma[10][16] = {
|
||||
const ::byte BLAKE2_Sigma<false>::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<true>
|
||||
{
|
||||
// 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<true>::sigma[12][16] = {
|
||||
const ::byte BLAKE2_Sigma<true>::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<true>::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<word32, false>&);
|
||||
typedef void (*pfnCompress64)(const byte*, BLAKE2_State<word64, true>&);
|
||||
typedef void (*pfnCompress32)(const ::byte*, BLAKE2_State<word32, false>&);
|
||||
typedef void (*pfnCompress64)(const ::byte*, BLAKE2_State<word64, true>&);
|
||||
|
||||
pfnCompress64 InitializeCompress64Fn()
|
||||
{
|
||||
|
|
@ -198,12 +198,12 @@ pfnCompress32 InitializeCompress32Fn()
|
|||
#endif // CRYPTOPP_DOXYGEN_PROCESSING
|
||||
|
||||
BLAKE2_ParameterBlock<false>::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<false>::BLAKE2_ParameterBlock(size_t digestLen, size_t key
|
|||
}
|
||||
|
||||
BLAKE2_ParameterBlock<true>::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<true>::BLAKE2_ParameterBlock(size_t digestLen, size_t keyL
|
|||
}
|
||||
|
||||
template <class W, bool T_64bit>
|
||||
void BLAKE2_Base<W, T_64bit>::UncheckedSetKey(const byte *key, unsigned int length, const CryptoPP::NameValuePairs& params)
|
||||
void BLAKE2_Base<W, T_64bit>::UncheckedSetKey(const ::byte *key, unsigned int length, const CryptoPP::NameValuePairs& params)
|
||||
{
|
||||
if (key && length)
|
||||
{
|
||||
|
|
@ -307,8 +307,8 @@ void BLAKE2_Base<W, T_64bit>::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<W, T_64bit>::BLAKE2_Base(bool treeMode, unsigned int digestSize) : m
|
|||
}
|
||||
|
||||
template <class W, bool T_64bit>
|
||||
BLAKE2_Base<W, T_64bit>::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<W, T_64bit>::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<W, T_64bit>::Restart(const BLAKE2_ParameterBlock<T_64bit>& 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<W, T_64bit>::Restart(const BLAKE2_ParameterBlock<T_64bit>& bloc
|
|||
}
|
||||
|
||||
template <class W, bool T_64bit>
|
||||
void BLAKE2_Base<W, T_64bit>::Update(const byte *input, size_t length)
|
||||
void BLAKE2_Base<W, T_64bit>::Update(const ::byte *input, size_t length)
|
||||
{
|
||||
State& state = *m_state.data();
|
||||
if (state.length + length > BLOCKSIZE)
|
||||
|
|
@ -443,7 +443,7 @@ void BLAKE2_Base<W, T_64bit>::Update(const byte *input, size_t length)
|
|||
}
|
||||
|
||||
template <class W, bool T_64bit>
|
||||
void BLAKE2_Base<W, T_64bit>::TruncatedFinal(byte *hash, size_t size)
|
||||
void BLAKE2_Base<W, T_64bit>::TruncatedFinal(::byte *hash, size_t size)
|
||||
{
|
||||
this->ThrowIfInvalidTruncatedSize(size);
|
||||
|
||||
|
|
@ -476,7 +476,7 @@ void BLAKE2_Base<W, T_64bit>::IncrementCounter(size_t count)
|
|||
}
|
||||
|
||||
template <>
|
||||
void BLAKE2_Base<word64, true>::Compress(const byte *input)
|
||||
void BLAKE2_Base<word64, true>::Compress(const ::byte *input)
|
||||
{
|
||||
// Selects the most advanced implementation at runtime
|
||||
static const pfnCompress64 s_pfn = InitializeCompress64Fn();
|
||||
|
|
@ -484,14 +484,14 @@ void BLAKE2_Base<word64, true>::Compress(const byte *input)
|
|||
}
|
||||
|
||||
template <>
|
||||
void BLAKE2_Base<word32, false>::Compress(const byte *input)
|
||||
void BLAKE2_Base<word32, false>::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<word64, true>& state)
|
||||
void BLAKE2_CXX_Compress64(const ::byte* input, BLAKE2_State<word64, true>& state)
|
||||
{
|
||||
#undef BLAKE2_G
|
||||
#undef BLAKE2_ROUND
|
||||
|
|
@ -554,7 +554,7 @@ void BLAKE2_CXX_Compress64(const byte* input, BLAKE2_State<word64, true>& state)
|
|||
state.h[i] = state.h[i] ^ ConditionalByteReverse(LittleEndian::ToEnum(), v[i] ^ v[i + 8]);
|
||||
}
|
||||
|
||||
void BLAKE2_CXX_Compress32(const byte* input, BLAKE2_State<word32, false>& state)
|
||||
void BLAKE2_CXX_Compress32(const ::byte* input, BLAKE2_State<word32, false>& state)
|
||||
{
|
||||
#undef BLAKE2_G
|
||||
#undef BLAKE2_ROUND
|
||||
|
|
@ -616,7 +616,7 @@ void BLAKE2_CXX_Compress32(const byte* input, BLAKE2_State<word32, false>& state
|
|||
}
|
||||
|
||||
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
|
||||
static void BLAKE2_SSE2_Compress32(const byte* input, BLAKE2_State<word32, false>& state)
|
||||
static void BLAKE2_SSE2_Compress32(const ::byte* input, BLAKE2_State<word32, false>& state)
|
||||
{
|
||||
word32 m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15;
|
||||
GetBlock<word32, LittleEndian, true> get(input);
|
||||
|
|
@ -1035,7 +1035,7 @@ static void BLAKE2_SSE2_Compress32(const byte* input, BLAKE2_State<word32, false
|
|||
}
|
||||
|
||||
# if (__SUNPRO_CC != 0x5120)
|
||||
static void BLAKE2_SSE2_Compress64(const byte* input, BLAKE2_State<word64, true>& state)
|
||||
static void BLAKE2_SSE2_Compress64(const ::byte* input, BLAKE2_State<word64, true>& state)
|
||||
{
|
||||
word64 m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15;
|
||||
GetBlock<word64, LittleEndian, true> get(input);
|
||||
|
|
@ -1930,7 +1930,7 @@ static void BLAKE2_SSE2_Compress64(const byte* input, BLAKE2_State<word64, true>
|
|||
#endif // CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
|
||||
|
||||
#if CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
|
||||
static void BLAKE2_SSE4_Compress32(const byte* input, BLAKE2_State<word32, false>& state)
|
||||
static void BLAKE2_SSE4_Compress32(const ::byte* input, BLAKE2_State<word32, false>& 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<word32, false
|
|||
_mm_storeu_si128((__m128i *)(void*)(&state.h[4]), _mm_xor_si128(ff1, _mm_xor_si128(row2, row4)));
|
||||
}
|
||||
|
||||
static void BLAKE2_SSE4_Compress64(const byte* input, BLAKE2_State<word64, true>& state)
|
||||
static void BLAKE2_SSE4_Compress64(const ::byte* input, BLAKE2_State<word64, true>& state)
|
||||
{
|
||||
__m128i row1l, row1h;
|
||||
__m128i row2l, row2h;
|
||||
|
|
|
|||
62
blake2.h
62
blake2.h
|
|
@ -73,20 +73,20 @@ struct CRYPTOPP_NO_VTABLE BLAKE2_ParameterBlock<true>
|
|||
{
|
||||
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<false>
|
|||
{
|
||||
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<W>());}
|
||||
|
||||
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) {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<word32, BigEndian> Block;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class Blowfish : public Blowfish_Info, public BlockCipherDocumentation
|
|||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Blowfish_Info>
|
||||
{
|
||||
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;
|
||||
|
|
|
|||
10
blumshub.cpp
10
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();
|
||||
|
|
|
|||
|
|
@ -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;}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ class Camellia : public Camellia_Info, public BlockCipherDocumentation
|
|||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Camellia_Info>
|
||||
{
|
||||
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;
|
||||
|
|
|
|||
10
cast.cpp
10
cast.cpp
|
|
@ -33,7 +33,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
|
||||
typedef BlockGetAndPut<word32, BigEndian> 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);
|
||||
|
||||
|
|
|
|||
10
cast.h
10
cast.h
|
|
@ -36,7 +36,7 @@ class CAST128 : public CAST128_Info, public BlockCipherDocumentation
|
|||
class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST128_Info>
|
||||
{
|
||||
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<CAST256_Info>
|
||||
{
|
||||
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];
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
8
cbcmac.h
8
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<CBC_MAC_Base*>(this)->AccessCipher().BlockSize();}
|
||||
|
||||
protected:
|
||||
|
|
@ -41,7 +41,7 @@ class CBC_MAC : public MessageAuthenticationCodeImpl<CBC_MAC_Base, CBC_MAC<T> >,
|
|||
{
|
||||
public:
|
||||
CBC_MAC() {}
|
||||
CBC_MAC(const byte *key, size_t length=SameKeyLengthAs<T>::DEFAULT_KEYLENGTH)
|
||||
CBC_MAC(const ::byte *key, size_t length=SameKeyLengthAs<T>::DEFAULT_KEYLENGTH)
|
||||
{this->SetKey(key, length);}
|
||||
|
||||
static std::string StaticAlgorithmName() {return std::string("CBC-MAC(") + T::StaticAlgorithmName() + ")";}
|
||||
|
|
|
|||
20
ccm.cpp
20
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<word64>(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);
|
||||
|
|
|
|||
10
ccm.h
10
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<CCM_Base *>(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;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ void ChaCha_TestInstantiations()
|
|||
#endif
|
||||
|
||||
template <unsigned int R>
|
||||
void ChaCha_Policy<R>::CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length)
|
||||
void ChaCha_Policy<R>::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<R>::CipherSetKey(const NameValuePairs ¶ms, const byte *ke
|
|||
}
|
||||
|
||||
template <unsigned int R>
|
||||
void ChaCha_Policy<R>::CipherResynchronize(byte *keystreamBuffer, const byte *IV, size_t length)
|
||||
void ChaCha_Policy<R>::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<R>::GetOptimalBlockSize() const
|
|||
}
|
||||
|
||||
template<unsigned int R>
|
||||
void ChaCha_Policy<R>::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
|
||||
void ChaCha_Policy<R>::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;
|
||||
|
||||
|
|
|
|||
6
chacha.h
6
chacha.h
|
|
@ -38,9 +38,9 @@ class CRYPTOPP_NO_VTABLE ChaCha_Policy : public AdditiveCipherConcretePolicy<wor
|
|||
protected:
|
||||
CRYPTOPP_CONSTANT(ROUNDS=FixedRounds<R>::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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
12
cmac.cpp
12
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);
|
||||
|
||||
|
|
|
|||
8
cmac.h
8
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<T>::DEFAULT_KEYLENGTH)
|
||||
CMAC(const ::byte *key, size_t length=SameKeyLengthAs<T>::DEFAULT_KEYLENGTH)
|
||||
{this->SetKey(key, length);}
|
||||
|
||||
static std::string StaticAlgorithmName() {return std::string("CMAC(") + T::StaticAlgorithmName() + ")";}
|
||||
|
|
|
|||
8
crc.cpp
8
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);
|
||||
|
||||
|
|
|
|||
16
crc.h
16
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;}
|
||||
|
|
|
|||
88
cryptlib.cpp
88
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<unsigned int>(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<byte *>(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<word32>();
|
||||
}
|
||||
|
||||
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<byte, 256> 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<PK_MessageAccumulator> 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<PK_MessageAccumulator> 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<PK_MessageAccumulator> 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<PK_MessageAccumulator> 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<PK_MessageAccumulator> 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<PK_MessageAccumulator> 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);
|
||||
|
|
|
|||
186
cryptlib.h
186
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 <tt>-1</tt> 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 <tt>-1</tt> 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. <tt>ivLength=-1</tt> 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 <tt>inString == outString</tt>, 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 <tt>COUNTOF(digest) == DigestSize()</tt> or <tt>COUNTOF(digest) == HASH::DIGESTSIZE</tt> 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 <tt>COUNTOF(digest) == DigestSize()</tt> or <tt>COUNTOF(digest) == HASH::DIGESTSIZE</tt> 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 <tt>COUNTOF(digest) == DigestSize()</tt> or <tt>COUNTOF(digest) == HASH::DIGESTSIZE</tt> 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 <tt>COUNTOF(digest) == DigestSize()</tt> or <tt>COUNTOF(digest) == HASH::DIGESTSIZE</tt> 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 <tt>COUNTOF(digest) == DigestSize()</tt> or <tt>COUNTOF(digest) == HASH::DIGESTSIZE</tt> 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 <tt>COUNTOF(digest) == DigestSize()</tt> or <tt>COUNTOF(digest) == HASH::DIGESTSIZE</tt> 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
|
||||
//! <tt>macSize < TagSize()</tt>.
|
||||
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 <tt>macLength < TagSize()</tt>.
|
||||
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 <tt>Put(byte)</tt> calls <tt>Put(byte*, size_t)</tt>.
|
||||
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 <tt>1</tt> means this
|
||||
//! object only. Setting propagation to <tt>-1</tt> 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 <tt>1</tt> means this
|
||||
//! object only. Setting propagation to <tt>-1</tt> 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 <tt>COUNTOF(plaintext) == MaxPlaintextLength(ciphertextLength)</tt> 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 <tt>COUNTOF(signature) == MaxSignatureLength()</tt>
|
||||
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 <tt>COUNTOF(signature) == MaxSignatureLength()</tt>
|
||||
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 <tt>COUNTOF(signature) == MaxSignatureLength()</tt>
|
||||
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 <tt>COUNTOF(signature) == MaxSignatureLength(recoverableMessageLength)</tt>
|
||||
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 <tt>COUNTOF(recoveredMessage) == MaxRecoverableLengthFromSignatureLength(signatureLength)</tt>
|
||||
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 <tt>COUNTOF(recoveredMessage) == MaxRecoverableLengthFromSignatureLength(signatureLength)</tt>
|
||||
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 <tt>COUNTOF(recoveredMessage) == MaxRecoverableLengthFromSignatureLength(signatureLength)</tt>
|
||||
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 <tt>COUNTOF(privateKey) == PrivateKeyLength()</tt>
|
||||
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 <tt>COUNTOF(publicKey) == PublicKeyLength()</tt>
|
||||
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 <tt>COUNTOF(privateKey) == PrivateKeyLength()</tt>
|
||||
//! \pre <tt>COUNTOF(publicKey) == PublicKeyLength()</tt>
|
||||
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 <tt>COUNTOF(agreedValue) == AgreedValueLength()</tt>
|
||||
//! \pre <tt>COUNTOF(privateKey) == PrivateKeyLength()</tt>
|
||||
//! \pre <tt>COUNTOF(otherPublicKey) == PublicKeyLength()</tt>
|
||||
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 <tt>COUNTOF(privateKey) == PrivateStaticKeyLength()</tt>
|
||||
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 <tt>COUNTOF(publicKey) == PublicStaticKeyLength()</tt>
|
||||
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 <tt>COUNTOF(privateKey) == PrivateStaticKeyLength()</tt>
|
||||
//! \pre <tt>COUNTOF(publicKey) == PublicStaticKeyLength()</tt>
|
||||
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 <tt>COUNTOF(privateKey) == PrivateEphemeralKeyLength()</tt>
|
||||
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 <tt>COUNTOF(publicKey) == PublicEphemeralKeyLength()</tt>
|
||||
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 <tt>COUNTOF(ephemeralPrivateKey) == EphemeralPrivateKeyLength()</tt>
|
||||
//! \pre <tt>COUNTOF(staticOtherPublicKey) == StaticPublicKeyLength()</tt>
|
||||
//! \pre <tt>COUNTOF(ephemeralOtherPublicKey) == EphemeralPublicKeyLength()</tt>
|
||||
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};
|
||||
|
||||
|
|
|
|||
36
datatest.cpp
36
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<ConstByteArrayParameter *>(pValue)->Assign((const byte *)m_temp.data(), m_temp.size(), false);
|
||||
reinterpret_cast<ConstByteArrayParameter *>(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<AuthenticatedSymmetricCipher> asc1, asc2;
|
||||
asc1.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, ENCRYPTION>::Registry().CreateObject(name.c_str()));
|
||||
asc2.reset(ObjectFactoryRegistry<AuthenticatedSymmetricCipher, DECRYPTION>::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<MessageAuthenticationCode>::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<KeyDerivationFunction>::Registry().CreateObject(name.c_str()));
|
||||
|
||||
std::string calc; calc.resize(length);
|
||||
unsigned int ret = kdf->DeriveKey(reinterpret_cast<byte*>(&calc[0]), calc.size(),
|
||||
reinterpret_cast<const byte*>(key.data()), key.size(),
|
||||
reinterpret_cast<const byte*>(salt.data()), salt.size(),
|
||||
reinterpret_cast<const byte*>(info.data()), info.size());
|
||||
unsigned int ret = kdf->DeriveKey(reinterpret_cast< ::byte*>(&calc[0]), calc.size(),
|
||||
reinterpret_cast<const ::byte*>(key.data()), key.size(),
|
||||
reinterpret_cast<const ::byte*>(salt.data()), salt.size(),
|
||||
reinterpret_cast<const ::byte*>(info.data()), info.size());
|
||||
|
||||
if(calc != derived || ret != length)
|
||||
SignalTestFailure();
|
||||
|
|
|
|||
50
default.cpp
50
default.cpp
|
|
@ -25,13 +25,13 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
// the amount of entropy in the input string, whichever is smaller.
|
||||
|
||||
template <class H>
|
||||
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<outLen; i+=H::DIGESTSIZE)
|
||||
{
|
||||
b[0] = (byte) (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<bufSize; i+=H::DIGESTSIZE)
|
||||
{
|
||||
b[0] = (byte) (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 <class BC, class H, class Info>
|
||||
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 <class BC, class H, class Info>
|
||||
DataEncryptor<BC,H,Info>::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 <class BC, class H, class Info>
|
||||
DataEncryptor<BC,H,Info>::DataEncryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment)
|
||||
DataEncryptor<BC,H,Info>::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<BC,H,Info>::DataEncryptor(const byte *passphrase, size_t passphras
|
|||
}
|
||||
|
||||
template <class BC, class H, class Info>
|
||||
void DataEncryptor<BC,H,Info>::FirstPut(const byte *)
|
||||
void DataEncryptor<BC,H,Info>::FirstPut(const ::byte *)
|
||||
{
|
||||
SecByteBlock salt(DIGESTSIZE), keyCheck(DIGESTSIZE);
|
||||
H hash;
|
||||
|
|
@ -101,9 +101,9 @@ void DataEncryptor<BC,H,Info>::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<BC,H,Info>::FirstPut(const byte *)
|
|||
}
|
||||
|
||||
template <class BC, class H, class Info>
|
||||
void DataEncryptor<BC,H,Info>::LastPut(const byte *inString, size_t length)
|
||||
void DataEncryptor<BC,H,Info>::LastPut(const ::byte *inString, size_t length)
|
||||
{
|
||||
CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length);
|
||||
m_filter->MessageEnd();
|
||||
|
|
@ -137,7 +137,7 @@ template <class BC, class H, class Info>
|
|||
DataDecryptor<BC,H,Info>::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<BC,H,Info>::DataDecryptor(const char *p, BufferedTransformation *a
|
|||
}
|
||||
|
||||
template <class BC, class H, class Info>
|
||||
DataDecryptor<BC,H,Info>::DataDecryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException)
|
||||
DataDecryptor<BC,H,Info>::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<BC,H,Info>::DataDecryptor(const byte *passphrase, size_t passphras
|
|||
}
|
||||
|
||||
template <class BC, class H, class Info>
|
||||
void DataDecryptor<BC,H,Info>::FirstPut(const byte *inString)
|
||||
void DataDecryptor<BC,H,Info>::FirstPut(const ::byte *inString)
|
||||
{
|
||||
CheckKey(inString, inString+SALTLENGTH);
|
||||
}
|
||||
|
||||
template <class BC, class H, class Info>
|
||||
void DataDecryptor<BC,H,Info>::LastPut(const byte *inString, size_t length)
|
||||
void DataDecryptor<BC,H,Info>::LastPut(const ::byte *inString, size_t length)
|
||||
{
|
||||
CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length);
|
||||
if (m_filter.get() == NULLPTR)
|
||||
|
|
@ -179,7 +179,7 @@ void DataDecryptor<BC,H,Info>::LastPut(const byte *inString, size_t length)
|
|||
}
|
||||
|
||||
template <class BC, class H, class Info>
|
||||
void DataDecryptor<BC,H,Info>::CheckKey(const byte *salt, const byte *keyCheck)
|
||||
void DataDecryptor<BC,H,Info>::CheckKey(const ::byte *salt, const ::byte *keyCheck)
|
||||
{
|
||||
SecByteBlock check(STDMAX((unsigned int)2*BLOCKSIZE, (unsigned int)DIGESTSIZE));
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ void DataDecryptor<BC,H,Info>::CheckKey(const byte *salt, const byte *keyCheck)
|
|||
// ********************************************************
|
||||
|
||||
template <class H, class MAC>
|
||||
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 <class BC, class H, class MAC, class Info>
|
||||
DataEncryptorWithMAC<BC,H,MAC,Info>::DataEncryptorWithMAC(const char *passphrase, BufferedTransformation *attachment)
|
||||
: ProxyFilter(NULLPTR, 0, 0, attachment)
|
||||
, m_mac(NewDataEncryptorMAC<H,MAC>((const byte *)passphrase, strlen(passphrase)))
|
||||
, m_mac(NewDataEncryptorMAC<H,MAC>((const ::byte *)passphrase, strlen(passphrase)))
|
||||
{
|
||||
SetFilter(new HashFilter(*m_mac, new DataEncryptor<BC,H,Info>(passphrase), true));
|
||||
}
|
||||
|
||||
template <class BC, class H, class MAC, class Info>
|
||||
DataEncryptorWithMAC<BC,H,MAC,Info>::DataEncryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment)
|
||||
DataEncryptorWithMAC<BC,H,MAC,Info>::DataEncryptorWithMAC(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment)
|
||||
: ProxyFilter(NULLPTR, 0, 0, attachment)
|
||||
, m_mac(NewDataEncryptorMAC<H,MAC>(passphrase, passphraseLength))
|
||||
{
|
||||
|
|
@ -240,7 +240,7 @@ DataEncryptorWithMAC<BC,H,MAC,Info>::DataEncryptorWithMAC(const byte *passphrase
|
|||
}
|
||||
|
||||
template <class BC, class H, class MAC, class Info>
|
||||
void DataEncryptorWithMAC<BC,H,MAC,Info>::LastPut(const byte *inString, size_t length)
|
||||
void DataEncryptorWithMAC<BC,H,MAC,Info>::LastPut(const ::byte *inString, size_t length)
|
||||
{
|
||||
CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length);
|
||||
m_filter->MessageEnd();
|
||||
|
|
@ -251,14 +251,14 @@ void DataEncryptorWithMAC<BC,H,MAC,Info>::LastPut(const byte *inString, size_t l
|
|||
template <class BC, class H, class MAC, class Info>
|
||||
DataDecryptorWithMAC<BC,H,MAC,Info>::DataDecryptorWithMAC(const char *passphrase, BufferedTransformation *attachment, bool throwException)
|
||||
: ProxyFilter(NULLPTR, 0, 0, attachment)
|
||||
, m_mac(NewDataEncryptorMAC<H,MAC>((const byte *)passphrase, strlen(passphrase)))
|
||||
, m_mac(NewDataEncryptorMAC<H,MAC>((const ::byte *)passphrase, strlen(passphrase)))
|
||||
, m_throwException(throwException)
|
||||
{
|
||||
SetFilter(new DataDecryptor<BC,H,Info>(passphrase, m_hashVerifier=new HashVerificationFilter(*m_mac, NULLPTR, HashVerificationFilter::PUT_MESSAGE), throwException));
|
||||
}
|
||||
|
||||
template <class BC, class H, class MAC, class Info>
|
||||
DataDecryptorWithMAC<BC,H,MAC,Info>::DataDecryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException)
|
||||
DataDecryptorWithMAC<BC,H,MAC,Info>::DataDecryptorWithMAC(const ::byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException)
|
||||
: ProxyFilter(NULLPTR, 0, 0, attachment)
|
||||
, m_mac(NewDataEncryptorMAC<H,MAC>(passphrase, passphraseLength))
|
||||
, m_throwException(throwException)
|
||||
|
|
@ -279,7 +279,7 @@ bool DataDecryptorWithMAC<BC,H,MAC,Info>::CheckLastMAC() const
|
|||
}
|
||||
|
||||
template <class BC, class H, class MAC, class Info>
|
||||
void DataDecryptorWithMAC<BC,H,MAC,Info>::LastPut(const byte *inString, size_t length)
|
||||
void DataDecryptorWithMAC<BC,H,MAC,Info>::LastPut(const ::byte *inString, size_t length)
|
||||
{
|
||||
CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length);
|
||||
m_filter->MessageEnd();
|
||||
|
|
|
|||
26
default.h
26
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<BC>::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<MAC> 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<BC,H,Info>::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<MAC> m_mac;
|
||||
|
|
|
|||
36
des.cpp
36
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);
|
||||
|
|
|
|||
24
des.h
24
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<DES_Info>, 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, Base> Encryption;
|
||||
typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
|
||||
|
|
@ -79,8 +79,8 @@ class DES_EDE2 : public DES_EDE2_Info, public BlockCipherDocumentation
|
|||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE2_Info>
|
||||
{
|
||||
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<DES_EDE3_Info>
|
||||
{
|
||||
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<DES_XEX3_Info>
|
||||
{
|
||||
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<byte, BLOCKSIZE> 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<DES::Encryption> m_des;
|
||||
|
|
|
|||
2
dh.h
2
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 <tt>COUNTOF(publicKey) == PublicKeyLength()</tt>
|
||||
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);
|
||||
|
||||
|
|
|
|||
6
dh2.cpp
6
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)
|
||||
|
|
|
|||
18
dh2.h
18
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:
|
||||
|
|
|
|||
18
dlltest.cpp
18
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<DES_EDE3>::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);
|
||||
|
|
|
|||
22
dmac.h
22
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<T>::DEFAULT_KEYLENGTH)
|
||||
DMAC(const ::byte *key, size_t length=DMAC_Base<T>::DEFAULT_KEYLENGTH)
|
||||
{this->SetKey(key, length);}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void DMAC_Base<T>::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms)
|
||||
void DMAC_Base<T>::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<T>::UncheckedSetKey(const byte *key, unsigned int length, const N
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void DMAC_Base<T>::Update(const byte *input, size_t length)
|
||||
void DMAC_Base<T>::Update(const ::byte *input, size_t length)
|
||||
{
|
||||
m_mac1.Update(input, length);
|
||||
m_counter = (unsigned int)((m_counter + length) % T::BLOCKSIZE);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void DMAC_Base<T>::TruncatedFinal(byte *mac, size_t size)
|
||||
void DMAC_Base<T>::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<T>::TruncatedFinal(byte *mac, size_t size)
|
|||
}
|
||||
|
||||
template <class T>
|
||||
byte *DMAC_Base<T>::GenerateSubKeys(const byte *key, size_t keylength)
|
||||
::byte *DMAC_Base<T>::GenerateSubKeys(const ::byte *key, size_t keylength)
|
||||
{
|
||||
typename T::Encryption cipher(key, keylength);
|
||||
memset(m_subkeys, 0, m_subkeys.size());
|
||||
|
|
|
|||
114
drbg.h
114
drbg.h
|
|
@ -49,7 +49,7 @@ public:
|
|||
//! with at least <tt>MINIMUM_ENTROPY</tt> entropy. The byte array for <tt>input</tt> must
|
||||
//! meet <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
|
||||
//! SP 800-90C</A> 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:
|
|||
//! <tt>MINIMUM_ENTROPY</tt> entropy. The byte array for <tt>entropy</tt> must meet
|
||||
//! <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
|
||||
//!! SP 800-90C</A> 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 <tt>MAXIMUM_BYTES_PER_REQUEST</tt>
|
||||
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 <tt>additional</tt> 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<SHA256, 128/8, 440/8> drbg(entropy, 32, entropy+32, 16);
|
||||
//! drbg.GenerateBlock(result, result.size());
|
||||
//! </pre>
|
||||
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<SHA256, 128/8, 440/8> drbg(entropy, 32, entropy+32, 16);
|
||||
//! drbg.GenerateBlock(result, result.size());
|
||||
//! </pre>
|
||||
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 <typename HASH, unsigned int STRENGTH, unsigned int SEEDLENGTH>
|
||||
void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::DRBG_Instantiate(const byte* entropy, size_t entropyLength, const byte* nonce, size_t nonceLength,
|
||||
const byte* personalization, size_t personalizationLength)
|
||||
void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::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<HASH, STRENGTH, SEEDLENGTH>::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<HASH, STRENGTH, SEEDLENGTH>::DRBG_Instantiate(const byte* entropy
|
|||
|
||||
// 10.1.1.3 Reseeding a Hash_DRBG Instantiation (p.40)
|
||||
template <typename HASH, unsigned int STRENGTH, unsigned int SEEDLENGTH>
|
||||
void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::DRBG_Reseed(const byte* entropy, size_t entropyLength, const byte* additional, size_t additionaLength)
|
||||
void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::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<HASH, STRENGTH, SEEDLENGTH>::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<HASH, STRENGTH, SEEDLENGTH>::DRBG_Reseed(const byte* entropy, siz
|
|||
|
||||
// 10.1.1.4 Generating Pseudorandom Bits Using Hash_DRBG (p.41)
|
||||
template <typename HASH, unsigned int STRENGTH, unsigned int SEEDLENGTH>
|
||||
void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::Hash_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size)
|
||||
void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::Hash_Generate(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size)
|
||||
{
|
||||
// Step 1
|
||||
if (static_cast<word64>(m_reseed) >= static_cast<word64>(MaxRequestBeforeReseed()))
|
||||
|
|
@ -449,7 +449,7 @@ void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::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, STRENGTH, SEEDLENGTH>::Hash_Generate(const byte* additional
|
|||
while (j>=0)
|
||||
{
|
||||
carry = m_v[i] + w[j] + carry;
|
||||
m_v[i] = static_cast<byte>(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<byte>(carry);
|
||||
m_v[i] = static_cast< ::byte>(carry);
|
||||
i--; carry >>= 8;
|
||||
}
|
||||
}
|
||||
|
|
@ -492,7 +492,7 @@ void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::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, STRENGTH, SEEDLENGTH>::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<word64>(false, BIG_ENDIAN_ORDER, p1);
|
||||
const word64 w2 = GetWord<word64>(false, BIG_ENDIAN_ORDER, p2);
|
||||
|
|
@ -553,14 +553,14 @@ void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::Hash_Generate(const byte* additional
|
|||
while (j>=0)
|
||||
{
|
||||
carry = m_v[i] + m_c[i] + h[j] + carry;
|
||||
m_v[i] = static_cast<byte>(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<byte>(carry);
|
||||
m_v[i] = static_cast< ::byte>(carry);
|
||||
i--; carry >>= 8;
|
||||
}
|
||||
|
||||
|
|
@ -573,17 +573,17 @@ void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::Hash_Generate(const byte* additional
|
|||
|
||||
// 10.3.1 Derivation Function Using a Hash Function (Hash_df) (p.49)
|
||||
template <typename HASH, unsigned int STRENGTH, unsigned int SEEDLENGTH>
|
||||
void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::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, STRENGTH, SEEDLENGTH>::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<word32>(outlen*8));
|
||||
|
||||
while (outlen)
|
||||
{
|
||||
hash.Update(&counter, 1);
|
||||
hash.Update(reinterpret_cast<const byte*>(&bits), 4);
|
||||
hash.Update(reinterpret_cast<const ::byte*>(&bits), 4);
|
||||
|
||||
if (input1 && inlen1)
|
||||
hash.Update(input1, inlen1);
|
||||
|
|
@ -606,8 +606,8 @@ void Hash_DRBG<HASH, STRENGTH, SEEDLENGTH>::Hash_Update(const byte* input1, size
|
|||
|
||||
// 10.1.2.3 Instantiation of HMAC_DRBG (p.45)
|
||||
template <typename HASH, unsigned int STRENGTH, unsigned int SEEDLENGTH>
|
||||
void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::DRBG_Instantiate(const byte* entropy, size_t entropyLength, const byte* nonce, size_t nonceLength,
|
||||
const byte* personalization, size_t personalizationLength)
|
||||
void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::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<HASH, STRENGTH, SEEDLENGTH>::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<HASH, STRENGTH, SEEDLENGTH>::DRBG_Instantiate(const byte* entropy
|
|||
|
||||
// 10.1.2.4 Reseeding a HMAC_DRBG Instantiation (p.46)
|
||||
template <typename HASH, unsigned int STRENGTH, unsigned int SEEDLENGTH>
|
||||
void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::DRBG_Reseed(const byte* entropy, size_t entropyLength, const byte* additional, size_t additionaLength)
|
||||
void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::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<HASH, STRENGTH, SEEDLENGTH>::DRBG_Reseed(const byte* entropy, siz
|
|||
|
||||
// 10.1.2.5 Generating Pseudorandom Bits Using HMAC_DRBG (p.46)
|
||||
template <typename HASH, unsigned int STRENGTH, unsigned int SEEDLENGTH>
|
||||
void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::HMAC_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size)
|
||||
void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::HMAC_Generate(const ::byte* additional, size_t additionaLength, ::byte *output, size_t size)
|
||||
{
|
||||
// Step 1
|
||||
if (static_cast<word64>(m_reseed) >= static_cast<word64>(MaxRequestBeforeReseed()))
|
||||
|
|
@ -693,9 +693,9 @@ void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::HMAC_Generate(const byte* additional
|
|||
|
||||
// 10.1.2.2 Derivation Function Using a HMAC Function (HMAC_Update) (p.44)
|
||||
template <typename HASH, unsigned int STRENGTH, unsigned int SEEDLENGTH>
|
||||
void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::HMAC_Update(const byte* input1, size_t inlen1, const byte* input2, size_t inlen2, const byte* input3, size_t inlen3)
|
||||
void HMAC_DRBG<HASH, STRENGTH, SEEDLENGTH>::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<HASH> hmac;
|
||||
|
||||
// Step 1
|
||||
|
|
|
|||
2
dsa.cpp
2
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);
|
||||
|
|
|
|||
4
dsa.h
4
dsa.h
|
|
@ -34,8 +34,8 @@ enum DSASignatureFormat {
|
|||
//! of signature in the target format. If <tt>toFormat == DSA_P1363</tt>, then
|
||||
//! <tt>bufferSize</tt> must equal <tt>publicKey.SignatureLength()</tt>
|
||||
//! \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
|
||||
|
||||
|
|
|
|||
8
eax.cpp
8
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();
|
||||
|
|
|
|||
8
eax.h
8
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<EAX_Base *>(this)->AccessMAC();}
|
||||
virtual CMAC_Base & AccessMAC() =0;
|
||||
|
|
|
|||
6
ec2n.cpp
6
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);
|
||||
|
|
|
|||
4
ec2n.h
4
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;
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ void DL_GroupParameters_EC<EC>::GenerateRandom(RandomNumberGenerator &rng, const
|
|||
template <class EC>
|
||||
void DL_GroupParameters_EC<EC>::BERDecode(BufferedTransformation &bt)
|
||||
{
|
||||
byte b;
|
||||
::byte b;
|
||||
if (!bt.Peek(b))
|
||||
BERDecodeError();
|
||||
if (b == OBJECT_IDENTIFIER)
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public:
|
|||
bool ValidateGroup(RandomNumberGenerator &rng, unsigned int level) const;
|
||||
bool ValidateElement(unsigned int level, const Element &element, const DL_FixedBasePrecomputation<Element> *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)))
|
||||
|
|
|
|||
6
ecp.cpp
6
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);
|
||||
|
|
|
|||
4
ecp.h
4
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;
|
||||
|
|
|
|||
|
|
@ -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 <tt>encodedPoint</tt> 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
|
||||
|
|
|
|||
10
elgamal.h
10
elgamal.h
|
|
@ -26,7 +26,7 @@ class CRYPTOPP_NO_VTABLE ElGamalBase : public DL_KeyAgreementAlgorithm_DH<Intege
|
|||
public:
|
||||
virtual ~ElGamalBase() {}
|
||||
|
||||
void Derive(const DL_GroupParameters<Integer> &groupParams, byte *derivedKey, size_t derivedLength, const Integer &agreedElement, const Integer &ephemeralPublicKey, const NameValuePairs &derivationParams) const
|
||||
void Derive(const DL_GroupParameters<Integer> &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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
6
emsa2.h
6
emsa2.h
|
|
@ -19,7 +19,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
|||
template <class H> class EMSA2HashId
|
||||
{
|
||||
public:
|
||||
static const byte id;
|
||||
static const ::byte id;
|
||||
};
|
||||
|
||||
template <class BASE>
|
||||
|
|
@ -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
|
||||
|
|
|
|||
6
esign.h
6
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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
34
fhmqv.h
34
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<Element> ¶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<Element> ¶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<byte*>(ephemeralOtherPublicKey);
|
||||
XX = const_cast< ::byte*>(ephemeralOtherPublicKey);
|
||||
xxs = EphemeralPublicKeyLength();
|
||||
YY = const_cast<byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength();
|
||||
YY = const_cast< ::byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength();
|
||||
yys = EphemeralPublicKeyLength();
|
||||
AA = const_cast<byte*>(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<byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength();
|
||||
XX = const_cast< ::byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength();
|
||||
xxs = EphemeralPublicKeyLength();
|
||||
YY = const_cast<byte*>(ephemeralOtherPublicKey);
|
||||
YY = const_cast< ::byte*>(ephemeralOtherPublicKey);
|
||||
yys = EphemeralPublicKeyLength();
|
||||
AA = tt.BytePtr();
|
||||
aas = tt.SizeInBytes();
|
||||
BB = const_cast<byte*>(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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
4
files.h
4
files.h
|
|
@ -73,7 +73,7 @@ private:
|
|||
|
||||
member_ptr<std::ifstream> 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:
|
||||
|
|
|
|||
102
filters.cpp
102
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<byte *>(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<byte>(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<byte>(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<byte>(), 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));
|
||||
|
|
|
|||
154
filters.h
154
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<MessageRange> 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<byte *>(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
|
||||
//! </pre>
|
||||
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
|
||||
//! </pre>
|
||||
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
|
||||
//! </pre>
|
||||
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<BufferedTransformation> 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
|
||||
//! </pre>
|
||||
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<StringStore>(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string, length)));}
|
||||
|
||||
//! \brief Construct a StringSource
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
36
fipstest.cpp
36
fipstest.cpp
|
|
@ -63,14 +63,14 @@ unsigned long g_macFileLocation = 0;
|
|||
const void* g_BaseAddressOfMAC = reinterpret_cast<void*>(0x42900000);
|
||||
|
||||
// use a random dummy string here, to be searched/replaced later with the real MAC
|
||||
static const byte s_moduleMac[CryptoPP::HMAC<CryptoPP::SHA1>::DIGESTSIZE] = CRYPTOPP_DUMMY_DLL_MAC;
|
||||
static const ::byte s_moduleMac[CryptoPP::HMAC<CryptoPP::SHA1>::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<CIPHER> 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<SHA1>(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<MessageAuthenticationCode> 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; i<sizeof(entriesToReadFromDisk)/sizeof(entriesToReadFromDisk[0]); i++)
|
||||
{
|
||||
const IMAGE_DATA_DIRECTORY &entry = phnt->OptionalHeader.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);
|
||||
|
|
|
|||
22
gcm.cpp
22
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<word64>()));
|
||||
CRYPTOPP_ASSERT(IsAlignedOn(b,GetAlignmentOf<word64>()));
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
14
gcm.h
14
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<GCM_Base *>(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
|
||||
|
|
|
|||
4
gf256.h
4
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();}
|
||||
|
|
|
|||
14
gf2n.cpp
14
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<PolynomialMod2, NewPolynomialMod2<1> >().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;
|
||||
}
|
||||
|
|
|
|||
10
gf2n.h
10
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);}
|
||||
|
|
|
|||
12
gfpcrypt.cpp
12
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());
|
||||
|
|
|
|||
20
gfpcrypt.h
20
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<size_t>(MAC::DIGESTSIZE);}
|
||||
size_t GetMaxSymmetricPlaintextLength(size_t ciphertextLength) const
|
||||
{return SaturatingSubtract(ciphertextLength, static_cast<size_t>(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<T> ¶ms, byte *derivedKey, size_t derivedLength, const T &agreedElement, const T &ephemeralPublicKey, const NameValuePairs ¶meters) const
|
||||
void Derive(const DL_GroupParameters<T> ¶ms, ::byte *derivedKey, size_t derivedLength, const T &agreedElement, const T &ephemeralPublicKey, const NameValuePairs ¶meters) const
|
||||
{
|
||||
SecByteBlock agreedSecret;
|
||||
if (DHAES_MODE)
|
||||
|
|
|
|||
8
gost.cpp
8
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<word32, LittleEndian> 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;
|
||||
|
||||
|
|
|
|||
8
gost.h
8
gost.h
|
|
@ -28,12 +28,12 @@ class GOST : public GOST_Info, public BlockCipherDocumentation
|
|||
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<GOST_Info>
|
||||
{
|
||||
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:
|
||||
|
|
|
|||
12
gzip.cpp
12
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);
|
||||
|
|
|
|||
4
gzip.h
4
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();
|
||||
|
||||
|
|
|
|||
4
hex.cpp
4
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)
|
||||
|
|
|
|||
14
hkdf.h
14
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<size_t>(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 <class T>
|
||||
unsigned int HKDF<T>::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<T>::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<size_t>(T::DIGESTSIZE);
|
||||
const unsigned int req = static_cast<unsigned int>(derivedLen);
|
||||
|
|
@ -70,10 +70,10 @@ unsigned int HKDF<T>::DeriveKey(byte *derived, size_t derivedLen, const byte *se
|
|||
throw InvalidArgument("HKDF: derivedLen must be less than or equal to MaxDerivedKeyLength");
|
||||
|
||||
HMAC<T> hmac;
|
||||
FixedSizeSecBlock<byte, DIGEST_SIZE> 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<T>::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)
|
||||
{
|
||||
|
|
|
|||
6
hmac.cpp
6
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);
|
||||
|
||||
|
|
|
|||
14
hmac.h
14
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<HMAC_Base*>(this)->AccessHash().OptimalBlockSize();}
|
||||
unsigned int DigestSize() const {return const_cast<HMAC_Base*>(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() + ")";}
|
||||
|
|
|
|||
34
hmqv.h
34
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<Element> ¶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<Element> ¶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<byte*>(ephemeralOtherPublicKey);
|
||||
XX = const_cast< ::byte*>(ephemeralOtherPublicKey);
|
||||
xxs = EphemeralPublicKeyLength();
|
||||
YY = const_cast<byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength();
|
||||
YY = const_cast< ::byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength();
|
||||
yys = EphemeralPublicKeyLength();
|
||||
AA = const_cast<byte*>(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<byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength();
|
||||
XX = const_cast< ::byte*>(ephemeralPrivateKey) + StaticPrivateKeyLength();
|
||||
xxs = EphemeralPublicKeyLength();
|
||||
YY = const_cast<byte*>(ephemeralOtherPublicKey);
|
||||
YY = const_cast< ::byte*>(ephemeralOtherPublicKey);
|
||||
yys = EphemeralPublicKeyLength();
|
||||
AA = tt.BytePtr();
|
||||
aas = tt.SizeInBytes();
|
||||
BB = const_cast<byte*>(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;
|
||||
|
|
|
|||
20
ida.cpp
20
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<const byte *, const byte> RevIt;
|
||||
typedef std::reverse_bidirectional_iterator<const ::byte *, const ::byte> RevIt;
|
||||
#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
|
||||
typedef std::reverse_iterator<const byte *, std::random_access_iterator_tag, const byte> RevIt;
|
||||
typedef std::reverse_iterator<const ::byte *, std::random_access_iterator_tag, const ::byte> RevIt;
|
||||
#else
|
||||
typedef std::reverse_iterator<const byte *> RevIt;
|
||||
typedef std::reverse_iterator<const ::byte *> 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>(), 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>(), 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);
|
||||
|
|
|
|||
10
ida.h
10
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;}
|
||||
|
|
|
|||
6
idea.cpp
6
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<word16, BigEndian> Block;
|
||||
|
||||
|
|
|
|||
6
idea.h
6
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<Word, 6*ROUNDS+4> m_key;
|
||||
|
||||
|
|
|
|||
26
integer.cpp
26
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);
|
||||
|
|
|
|||
16
integer.h
16
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();
|
||||
|
|
|
|||
14
iterhash.cpp
14
iterhash.cpp
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
template <class T, class BASE> void IteratedHashBase<T, BASE>::Update(const byte *input, size_t len)
|
||||
template <class T, class BASE> void IteratedHashBase<T, BASE>::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 <class T, class BASE> void IteratedHashBase<T, BASE>::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 <class T, class BASE> void IteratedHashBase<T, BASE>::Update(const byte
|
|||
memcpy(data, input, len);
|
||||
}
|
||||
|
||||
template <class T, class BASE> byte * IteratedHashBase<T, BASE>::CreateUpdateSpace(size_t &size)
|
||||
template <class T, class BASE> ::byte * IteratedHashBase<T, BASE>::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 <class T, class BASE> size_t IteratedHashBase<T, BASE>::HashMultipleBlocks(const T *input, size_t length)
|
||||
|
|
@ -103,12 +103,12 @@ template <class T, class BASE> size_t IteratedHashBase<T, BASE>::HashMultipleBlo
|
|||
return length;
|
||||
}
|
||||
|
||||
template <class T, class BASE> void IteratedHashBase<T, BASE>::PadLastBlock(unsigned int lastBlockSize, byte padFirst)
|
||||
template <class T, class BASE> void IteratedHashBase<T, BASE>::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 <class T, class BASE> void IteratedHashBase<T, BASE>::Restart()
|
|||
Init();
|
||||
}
|
||||
|
||||
template <class T, class BASE> void IteratedHashBase<T, BASE>::TruncatedFinal(byte *digest, size_t size)
|
||||
template <class T, class BASE> void IteratedHashBase<T, BASE>::TruncatedFinal(::byte *digest, size_t size)
|
||||
{
|
||||
this->ThrowIfInvalidTruncatedSize(size);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue