Applied GCC 3.4 patch from Crypto++ website, with slight workaround to avoid adding fips140.h. Now compiles on Linux with GCC 3.4.
This commit is contained in:
@@ -54,7 +54,7 @@ template <class T> const T& AbstractEuclideanDomain<T>::Gcd(const Element &a, co
|
||||
Element g[3]={b, a};
|
||||
unsigned int i0=0, i1=1, i2=2;
|
||||
|
||||
while (!Equal(g[i1], Identity()))
|
||||
while (!Equal(g[i1], this->Identity()))
|
||||
{
|
||||
g[i2] = Mod(g[i0], g[i1]);
|
||||
unsigned int t = i0; i0 = i1; i1 = i2; i2 = t;
|
||||
|
||||
@@ -221,8 +221,8 @@ public:
|
||||
}
|
||||
void DEREncode(BufferedTransformation &out)
|
||||
{
|
||||
if (get() != NULL)
|
||||
get()->DEREncode(out);
|
||||
if (this->get() != NULL)
|
||||
this->get()->DEREncode(out);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -106,7 +106,8 @@ unsigned int FileStore::CopyRangeTo2(BufferedTransformation &target, unsigned lo
|
||||
streampos endPosition = m_stream->seekg(0, ios::end).tellg();
|
||||
streampos newPosition = current + (streamoff)begin;
|
||||
|
||||
if (newPosition >= endPosition)
|
||||
// if (newPosition >= endPosition)
|
||||
if (std::streamoff(newPosition) >= std::streamoff(endPosition))
|
||||
{
|
||||
m_stream->seekg(current);
|
||||
return 0; // don't try to seek beyond the end of file
|
||||
|
||||
@@ -82,7 +82,7 @@ class IteratedHashWithStaticTransform : public IteratedHash<T, B, S>
|
||||
{
|
||||
protected:
|
||||
IteratedHashWithStaticTransform(unsigned int digestSize) : IteratedHash<T, B, S>(digestSize) {}
|
||||
void vTransform(const T *data) {M::Transform(m_digest, data);}
|
||||
void vTransform(const T *data) {M::Transform(this->m_digest, data);}
|
||||
std::string AlgorithmName() const {return M::StaticAlgorithmName();}
|
||||
};
|
||||
|
||||
@@ -90,19 +90,19 @@ protected:
|
||||
|
||||
template <class T, class B, class BASE> void IteratedHashBase2<T, B, BASE>::TruncatedFinal(byte *hash, unsigned int size)
|
||||
{
|
||||
ThrowIfInvalidTruncatedSize(size);
|
||||
this->ThrowIfInvalidTruncatedSize(size);
|
||||
|
||||
PadLastBlock(BlockSize() - 2*sizeof(HashWordType));
|
||||
CorrectEndianess(m_data, m_data, BlockSize() - 2*sizeof(HashWordType));
|
||||
PadLastBlock(this->BlockSize() - 2*sizeof(HashWordType));
|
||||
CorrectEndianess(this->m_data, this->m_data, this->BlockSize() - 2*sizeof(HashWordType));
|
||||
|
||||
m_data[m_data.size()-2] = B::ToEnum() ? GetBitCountHi() : GetBitCountLo();
|
||||
m_data[m_data.size()-1] = B::ToEnum() ? GetBitCountLo() : GetBitCountHi();
|
||||
this->m_data[this->m_data.size()-2] = B::ToEnum() ? this->GetBitCountHi() : this->GetBitCountLo();
|
||||
this->m_data[this->m_data.size()-1] = B::ToEnum() ? this->GetBitCountLo() : this->GetBitCountHi();
|
||||
|
||||
vTransform(m_data);
|
||||
CorrectEndianess(m_digest, m_digest, DigestSize());
|
||||
memcpy(hash, m_digest, size);
|
||||
vTransform(this->m_data);
|
||||
CorrectEndianess(this->m_digest, this->m_digest, this->DigestSize());
|
||||
memcpy(hash, this->m_digest, size);
|
||||
|
||||
Restart(); // reinit for next use
|
||||
this->Restart(); // reinit for next use
|
||||
}
|
||||
|
||||
template <class T, class B, class BASE> void IteratedHashBase2<T, B, BASE>::HashBlock(const HashWordType *input)
|
||||
@@ -111,8 +111,8 @@ template <class T, class B, class BASE> void IteratedHashBase2<T, B, BASE>::Hash
|
||||
vTransform(input);
|
||||
else
|
||||
{
|
||||
ByteReverse(m_data.begin(), input, BlockSize());
|
||||
vTransform(m_data);
|
||||
ByteReverse(this->m_data.begin(), input, this->BlockSize());
|
||||
vTransform(this->m_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,22 +30,22 @@ class MDC : public MDC_Info<T>
|
||||
void UncheckedSetKey(CipherDir direction, const byte *userKey, unsigned int length)
|
||||
{
|
||||
assert(direction == ENCRYPTION);
|
||||
AssertValidKeyLength(length);
|
||||
memcpy(Key(), userKey, KEYLENGTH);
|
||||
T::CorrectEndianess(Key(), Key(), KEYLENGTH);
|
||||
this->AssertValidKeyLength(length);
|
||||
memcpy(Key(), userKey, this->KEYLENGTH);
|
||||
T::CorrectEndianess(Key(), Key(), this->KEYLENGTH);
|
||||
}
|
||||
|
||||
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
||||
{
|
||||
T::CorrectEndianess(Buffer(), (HashWordType *)inBlock, BLOCKSIZE);
|
||||
T::CorrectEndianess(Buffer(), (HashWordType *)inBlock, this->BLOCKSIZE);
|
||||
T::Transform(Buffer(), Key());
|
||||
if (xorBlock)
|
||||
{
|
||||
T::CorrectEndianess(Buffer(), Buffer(), BLOCKSIZE);
|
||||
xorbuf(outBlock, xorBlock, m_buffer, BLOCKSIZE);
|
||||
T::CorrectEndianess(Buffer(), Buffer(), this->BLOCKSIZE);
|
||||
xorbuf(outBlock, xorBlock, m_buffer, this->BLOCKSIZE);
|
||||
}
|
||||
else
|
||||
T::CorrectEndianess((HashWordType *)outBlock, Buffer(), BLOCKSIZE);
|
||||
T::CorrectEndianess((HashWordType *)outBlock, Buffer(), this->BLOCKSIZE);
|
||||
}
|
||||
|
||||
bool IsPermutation() const {return false;}
|
||||
|
||||
@@ -188,18 +188,18 @@ class CipherModeFinalTemplate_CipherHolder : public ObjectHolder<CIPHER>, public
|
||||
public:
|
||||
CipherModeFinalTemplate_CipherHolder()
|
||||
{
|
||||
m_cipher = &m_object;
|
||||
ResizeBuffers();
|
||||
this->m_cipher = &this->m_object;
|
||||
this->ResizeBuffers();
|
||||
}
|
||||
CipherModeFinalTemplate_CipherHolder(const byte *key, unsigned int length)
|
||||
{
|
||||
m_cipher = &m_object;
|
||||
SetKey(key, length);
|
||||
this->m_cipher = &this->m_object;
|
||||
this->SetKey(key, length);
|
||||
}
|
||||
CipherModeFinalTemplate_CipherHolder(const byte *key, unsigned int length, const byte *iv, int feedbackSize = 0)
|
||||
{
|
||||
m_cipher = &m_object;
|
||||
SetKey(key, length, MakeParameters("IV", iv)("FeedbackSize", feedbackSize));
|
||||
this->m_cipher = &this->m_object;
|
||||
this->SetKey(key, length, MakeParameters("IV", iv)("FeedbackSize", feedbackSize));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "randpool.h"
|
||||
#include "rng.h"
|
||||
|
||||
//added
|
||||
#include "cryptlib.h"
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
//! Exception class for Operating-System Random Number Generator.
|
||||
@@ -147,7 +150,11 @@ byte AutoSeededX917RNG<BLOCK_CIPHER>::GenerateByte()
|
||||
if (m_counter == m_lastBlock.size())
|
||||
{
|
||||
if (!m_isDifferent)
|
||||
throw SelfTestFailure("AutoSeededX917RNG: Continuous random number generator test failed.");
|
||||
// This originally threw a SelfTestFailure, which is
|
||||
// only available from fips140.h, which I figure
|
||||
// probably was excluded for a good reason. Here's
|
||||
// my workaround.
|
||||
throw Exception(Exception::OTHER_ERROR, "AutoSeededX917RNG: Continuous random number generator test failed.");
|
||||
m_counter = 0;
|
||||
m_isDifferent = false;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "argnames.h"
|
||||
#include <memory>
|
||||
|
||||
#include "modarith.h"
|
||||
|
||||
// VC60 workaround: this macro is defined in shlobj.h and conflicts with a template parameter used in this file
|
||||
#undef INTERFACE
|
||||
|
||||
@@ -140,12 +142,12 @@ template <class INTERFACE, class BASE>
|
||||
class TF_CryptoSystemBase : public INTERFACE, protected BASE
|
||||
{
|
||||
public:
|
||||
unsigned int FixedMaxPlaintextLength() const {return GetMessageEncodingInterface().MaxUnpaddedLength(PaddedBlockBitLength());}
|
||||
unsigned int FixedCiphertextLength() const {return GetTrapdoorFunctionBounds().MaxImage().ByteCount();}
|
||||
unsigned int FixedMaxPlaintextLength() const {return this->GetMessageEncodingInterface().MaxUnpaddedLength(PaddedBlockBitLength());}
|
||||
unsigned int FixedCiphertextLength() const {return this->GetTrapdoorFunctionBounds().MaxImage().ByteCount();}
|
||||
|
||||
protected:
|
||||
unsigned int PaddedBlockByteLength() const {return BitsToBytes(PaddedBlockBitLength());}
|
||||
unsigned int PaddedBlockBitLength() const {return GetTrapdoorFunctionBounds().PreimageBound().BitCount()-1;}
|
||||
unsigned int PaddedBlockBitLength() const {return this->GetTrapdoorFunctionBounds().PreimageBound().BitCount()-1;}
|
||||
};
|
||||
|
||||
//! .
|
||||
@@ -286,7 +288,7 @@ template <class HASH_ALGORITHM>
|
||||
class PK_MessageAccumulatorImpl : public PK_MessageAccumulatorBase, protected ObjectHolder<HASH_ALGORITHM>
|
||||
{
|
||||
public:
|
||||
HashTransformation & AccessHash() {return m_object;}
|
||||
HashTransformation & AccessHash() {return this->m_object;}
|
||||
};
|
||||
|
||||
//! .
|
||||
@@ -295,22 +297,22 @@ class TF_SignatureSchemeBase : public INTERFACE, protected BASE
|
||||
{
|
||||
public:
|
||||
unsigned int SignatureLength() const
|
||||
{return GetTrapdoorFunctionBounds().MaxPreimage().ByteCount();}
|
||||
{return this->GetTrapdoorFunctionBounds().MaxPreimage().ByteCount();}
|
||||
unsigned int MaxRecoverableLength() const
|
||||
{return GetMessageEncodingInterface().MaxRecoverableLength(MessageRepresentativeBitLength(), GetHashIdentifier().second, GetDigestSize());}
|
||||
{return this->GetMessageEncodingInterface().MaxRecoverableLength(MessageRepresentativeBitLength(), GetHashIdentifier().second, GetDigestSize());}
|
||||
unsigned int MaxRecoverableLengthFromSignatureLength(unsigned int signatureLength) const
|
||||
{return MaxRecoverableLength();}
|
||||
{return this->MaxRecoverableLength();}
|
||||
|
||||
bool IsProbabilistic() const
|
||||
{return GetTrapdoorFunctionInterface().IsRandomized() || GetMessageEncodingInterface().IsProbabilistic();}
|
||||
{return this->GetTrapdoorFunctionInterface().IsRandomized() || this->GetMessageEncodingInterface().IsProbabilistic();}
|
||||
bool AllowNonrecoverablePart() const
|
||||
{return GetMessageEncodingInterface().AllowNonrecoverablePart();}
|
||||
{return this->GetMessageEncodingInterface().AllowNonrecoverablePart();}
|
||||
bool RecoverablePartFirst() const
|
||||
{return GetMessageEncodingInterface().RecoverablePartFirst();}
|
||||
{return this->GetMessageEncodingInterface().RecoverablePartFirst();}
|
||||
|
||||
protected:
|
||||
unsigned int MessageRepresentativeLength() const {return BitsToBytes(MessageRepresentativeBitLength());}
|
||||
unsigned int MessageRepresentativeBitLength() const {return GetTrapdoorFunctionBounds().ImageBound().BitCount()-1;}
|
||||
unsigned int MessageRepresentativeBitLength() const {return this->GetTrapdoorFunctionBounds().ImageBound().BitCount()-1;}
|
||||
virtual HashIdentifier GetHashIdentifier() const =0;
|
||||
virtual unsigned int GetDigestSize() const =0;
|
||||
};
|
||||
@@ -399,8 +401,12 @@ protected:
|
||||
// for signature scheme
|
||||
HashIdentifier GetHashIdentifier() const
|
||||
{
|
||||
typedef CPP_TYPENAME SchemeOptions::MessageEncodingMethod::HashIdentifierLookup::HashIdentifierLookup2<CPP_TYPENAME SchemeOptions::HashFunction> L;
|
||||
return L::Lookup();
|
||||
typedef CPP_TYPENAME SchemeOptions::MessageEncodingMethod::HashIdentifierLookup::template HashIdentifierLookup2<CPP_TYPENAME SchemeOptions::HashFunction> L;
|
||||
return L::Lookup();
|
||||
/* typedef typename SchemeOptions::MessageEncodingMethod MEnMeth;
|
||||
typedef typename MEnMeth::HashIdentifierLookup HLookup;
|
||||
typedef typename SchemeOptions::HashFunction HashF;
|
||||
return HLookup::template HashIdentifierLookup2<HashF>::Lookup(); */
|
||||
}
|
||||
unsigned int GetDigestSize() const
|
||||
{
|
||||
@@ -444,7 +450,7 @@ template <class BASE, class SCHEME_OPTIONS>
|
||||
class TF_PublicObjectImpl : public TF_ObjectImpl<BASE, SCHEME_OPTIONS, typename SCHEME_OPTIONS::PublicKey>, public PublicKeyCopier<SCHEME_OPTIONS>
|
||||
{
|
||||
public:
|
||||
void CopyKeyInto(typename SCHEME_OPTIONS::PublicKey &key) const {key = GetKey();}
|
||||
void CopyKeyInto(typename SCHEME_OPTIONS::PublicKey &key) const {key = this->GetKey();}
|
||||
};
|
||||
|
||||
//! .
|
||||
@@ -452,8 +458,8 @@ template <class BASE, class SCHEME_OPTIONS>
|
||||
class TF_PrivateObjectImpl : public TF_ObjectImpl<BASE, SCHEME_OPTIONS, typename SCHEME_OPTIONS::PrivateKey>, public PrivateKeyCopier<SCHEME_OPTIONS>
|
||||
{
|
||||
public:
|
||||
void CopyKeyInto(typename SCHEME_OPTIONS::PrivateKey &key) const {key = GetKey();}
|
||||
void CopyKeyInto(typename SCHEME_OPTIONS::PublicKey &key) const {key = GetKey();}
|
||||
void CopyKeyInto(typename SCHEME_OPTIONS::PrivateKey &key) const {key = this->GetKey();}
|
||||
void CopyKeyInto(typename SCHEME_OPTIONS::PublicKey &key) const {key = this->GetKey();}
|
||||
};
|
||||
|
||||
//! .
|
||||
@@ -542,107 +548,107 @@ public:
|
||||
PK_FinalTemplate() {}
|
||||
|
||||
PK_FinalTemplate(const Integer &v1)
|
||||
{AccessKey().Initialize(v1);}
|
||||
{this->AccessKey().Initialize(v1);}
|
||||
|
||||
PK_FinalTemplate(const typename BASE::KeyClass &key) {AccessKey().operator=(key);}
|
||||
PK_FinalTemplate(const typename BASE::KeyClass &key) {this->AccessKey().operator=(key);}
|
||||
|
||||
template <class T>
|
||||
PK_FinalTemplate(const PublicKeyCopier<T> &key)
|
||||
{key.CopyKeyInto(AccessKey());}
|
||||
{key.CopyKeyInto(this->AccessKey());}
|
||||
|
||||
template <class T>
|
||||
PK_FinalTemplate(const PrivateKeyCopier<T> &key)
|
||||
{key.CopyKeyInto(AccessKey());}
|
||||
{key.CopyKeyInto(this->AccessKey());}
|
||||
|
||||
PK_FinalTemplate(BufferedTransformation &bt) {AccessKey().BERDecode(bt);}
|
||||
PK_FinalTemplate(BufferedTransformation &bt) {this->AccessKey().BERDecode(bt);}
|
||||
|
||||
#if (defined(_MSC_VER) && _MSC_VER < 1300)
|
||||
|
||||
template <class T1, class T2>
|
||||
PK_FinalTemplate(T1 &v1, T2 &v2)
|
||||
{AccessKey().Initialize(v1, v2);}
|
||||
{this->AccessKey().Initialize(v1, v2);}
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
PK_FinalTemplate(T1 &v1, T2 &v2, T3 &v3)
|
||||
{AccessKey().Initialize(v1, v2, v3);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
PK_FinalTemplate(T1 &v1, T2 &v2, T3 &v3, T4 &v4)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
PK_FinalTemplate(T1 &v1, T2 &v2, T3 &v3, T4 &v4, T5 &v5)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
PK_FinalTemplate(T1 &v1, T2 &v2, T3 &v3, T4 &v4, T5 &v5, T6 &v6)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
||||
PK_FinalTemplate(T1 &v1, T2 &v2, T3 &v3, T4 &v4, T5 &v5, T6 &v6, T7 &v7)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
||||
PK_FinalTemplate(T1 &v1, T2 &v2, T3 &v3, T4 &v4, T5 &v5, T6 &v6, T7 &v7, T8 &v8)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7, v8);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7, v8);}
|
||||
|
||||
#else
|
||||
|
||||
template <class T1, class T2>
|
||||
PK_FinalTemplate(const T1 &v1, const T2 &v2)
|
||||
{AccessKey().Initialize(v1, v2);}
|
||||
{this->AccessKey().Initialize(v1, v2);}
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
PK_FinalTemplate(const T1 &v1, const T2 &v2, const T3 &v3)
|
||||
{AccessKey().Initialize(v1, v2, v3);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
PK_FinalTemplate(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
PK_FinalTemplate(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
PK_FinalTemplate(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
||||
PK_FinalTemplate(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, const T7 &v7)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
||||
PK_FinalTemplate(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, const T7 &v7, const T8 &v8)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7, v8);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7, v8);}
|
||||
|
||||
template <class T1, class T2>
|
||||
PK_FinalTemplate(T1 &v1, const T2 &v2)
|
||||
{AccessKey().Initialize(v1, v2);}
|
||||
{this->AccessKey().Initialize(v1, v2);}
|
||||
|
||||
template <class T1, class T2, class T3>
|
||||
PK_FinalTemplate(T1 &v1, const T2 &v2, const T3 &v3)
|
||||
{AccessKey().Initialize(v1, v2, v3);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4>
|
||||
PK_FinalTemplate(T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5>
|
||||
PK_FinalTemplate(T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6>
|
||||
PK_FinalTemplate(T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
||||
PK_FinalTemplate(T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, const T7 &v7)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7);}
|
||||
|
||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
||||
PK_FinalTemplate(T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, const T7 &v7, const T8 &v8)
|
||||
{AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7, v8);}
|
||||
{this->AccessKey().Initialize(v1, v2, v3, v4, v5, v6, v7, v8);}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -188,7 +188,10 @@ template <class T, class A = AllocatorWithCleanup<T> >
|
||||
class SecBlock
|
||||
{
|
||||
public:
|
||||
explicit SecBlock(unsigned int size=0)
|
||||
//added
|
||||
typedef T value_type;
|
||||
|
||||
explicit SecBlock(unsigned int size=0)
|
||||
: m_size(size) {m_ptr = m_alloc.allocate(size, NULL);}
|
||||
SecBlock(const SecBlock<T, A> &t)
|
||||
: m_size(t.m_size) {m_ptr = m_alloc.allocate(m_size, NULL); memcpy(m_ptr, t.m_ptr, m_size*sizeof(T));}
|
||||
@@ -205,26 +208,26 @@ public:
|
||||
~SecBlock()
|
||||
{m_alloc.deallocate(m_ptr, m_size);}
|
||||
|
||||
#if defined(__GNUC__) || defined(__BCPLUSPLUS__)
|
||||
//#if defined(__GNUC__) || defined(__BCPLUSPLUS__)
|
||||
operator const void *() const
|
||||
{return m_ptr;}
|
||||
operator void *()
|
||||
{return m_ptr;}
|
||||
#endif
|
||||
/*#endif
|
||||
#if defined(__GNUC__) // reduce warnings
|
||||
operator const void *()
|
||||
{return m_ptr;}
|
||||
#endif
|
||||
|
||||
*/
|
||||
operator const T *() const
|
||||
{return m_ptr;}
|
||||
operator T *()
|
||||
{return m_ptr;}
|
||||
#if defined(__GNUC__) // reduce warnings
|
||||
/*#if defined(__GNUC__) // reduce warnings
|
||||
operator const T *()
|
||||
{return m_ptr;}
|
||||
#endif
|
||||
|
||||
*/
|
||||
template <typename I>
|
||||
T *operator +(I offset)
|
||||
{return m_ptr+offset;}
|
||||
|
||||
@@ -156,7 +156,7 @@ template <class INFO, class INTERFACE = BlockCipher>
|
||||
class BlockCipherBaseTemplate : public AlgorithmImpl<SimpleKeyingInterfaceImpl<TwoBases<INFO, INTERFACE> > >
|
||||
{
|
||||
public:
|
||||
unsigned int BlockSize() const {return BLOCKSIZE;}
|
||||
unsigned int BlockSize() const {return this->BLOCKSIZE;}
|
||||
};
|
||||
|
||||
//! .
|
||||
@@ -166,11 +166,11 @@ class BlockCipherTemplate : public BASE
|
||||
public:
|
||||
BlockCipherTemplate() {}
|
||||
BlockCipherTemplate(const byte *key)
|
||||
{SetKey(key, DEFAULT_KEYLENGTH);}
|
||||
{SetKey(key, this->DEFAULT_KEYLENGTH);}
|
||||
BlockCipherTemplate(const byte *key, unsigned int length)
|
||||
{SetKey(key, length);}
|
||||
BlockCipherTemplate(const byte *key, unsigned int length, unsigned int rounds)
|
||||
{SetKeyWithRounds(key, length, rounds);}
|
||||
{this->SetKeyWithRounds(key, length, rounds);}
|
||||
|
||||
bool IsForwardTransformation() const {return DIR == ENCRYPTION;}
|
||||
|
||||
@@ -194,11 +194,11 @@ class MessageAuthenticationCodeTemplate : public
|
||||
public:
|
||||
MessageAuthenticationCodeTemplate() {}
|
||||
MessageAuthenticationCodeTemplate(const byte *key)
|
||||
{SetKey(key, DEFAULT_KEYLENGTH);}
|
||||
{SetKey(key, this->DEFAULT_KEYLENGTH);}
|
||||
MessageAuthenticationCodeTemplate(const byte *key, unsigned int length)
|
||||
{SetKey(key, length);}
|
||||
|
||||
std::string AlgorithmName() const {return StaticAlgorithmName();}
|
||||
std::string AlgorithmName() const {return this->StaticAlgorithmName();}
|
||||
|
||||
void SetKey(const byte *key, unsigned int length, const NameValuePairs ¶m = g_nullNameValuePairs)
|
||||
{
|
||||
|
||||
@@ -58,6 +58,8 @@ template <class T>
|
||||
class Unflushable : public T
|
||||
{
|
||||
public:
|
||||
using T::NULL_CHANNEL;
|
||||
|
||||
Unflushable() {}
|
||||
Unflushable(BufferedTransformation *q) : T(q) {}
|
||||
bool Flush(bool completeFlush, int propagation=-1, bool blocking=true)
|
||||
@@ -70,7 +72,7 @@ public:
|
||||
throw CannotFlush("Unflushable<T>: this object has buffered input that cannot be flushed");
|
||||
else
|
||||
{
|
||||
BufferedTransformation *attached = AttachedTransformation();
|
||||
BufferedTransformation *attached = this->AttachedTransformation();
|
||||
return attached && propagation ? attached->ChannelFlush(channel, hardFlush, propagation-1, blocking) : false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||
template <class S>
|
||||
byte AdditiveCipherTemplate<S>::GenerateByte()
|
||||
{
|
||||
PolicyInterface &policy = AccessPolicy();
|
||||
PolicyInterface &policy = this->AccessPolicy();
|
||||
|
||||
if (m_leftOver == 0)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ inline void AdditiveCipherTemplate<S>::ProcessData(byte *outString, const byte *
|
||||
|
||||
assert(m_leftOver == 0);
|
||||
|
||||
PolicyInterface &policy = AccessPolicy();
|
||||
PolicyInterface &policy = this->AccessPolicy();
|
||||
unsigned int bytesPerIteration = policy.GetBytesPerIteration();
|
||||
unsigned int alignment = policy.GetAlignment();
|
||||
|
||||
@@ -81,7 +81,7 @@ inline void AdditiveCipherTemplate<S>::ProcessData(byte *outString, const byte *
|
||||
template <class S>
|
||||
void AdditiveCipherTemplate<S>::Resynchronize(const byte *iv)
|
||||
{
|
||||
PolicyInterface &policy = AccessPolicy();
|
||||
PolicyInterface &policy = this->AccessPolicy();
|
||||
m_leftOver = 0;
|
||||
m_buffer.New(GetBufferByteSize(policy));
|
||||
policy.CipherResynchronize(m_buffer, iv);
|
||||
@@ -90,7 +90,7 @@ void AdditiveCipherTemplate<S>::Resynchronize(const byte *iv)
|
||||
template <class BASE>
|
||||
void AdditiveCipherTemplate<BASE>::Seek(dword position)
|
||||
{
|
||||
PolicyInterface &policy = AccessPolicy();
|
||||
PolicyInterface &policy = this->AccessPolicy();
|
||||
unsigned int bytesPerIteration = policy.GetBytesPerIteration();
|
||||
|
||||
policy.SeekToIteration(position / bytesPerIteration);
|
||||
@@ -108,7 +108,7 @@ void AdditiveCipherTemplate<BASE>::Seek(dword position)
|
||||
template <class BASE>
|
||||
void CFB_CipherTemplate<BASE>::Resynchronize(const byte *iv)
|
||||
{
|
||||
PolicyInterface &policy = AccessPolicy();
|
||||
PolicyInterface &policy = this->AccessPolicy();
|
||||
policy.CipherResynchronize(iv);
|
||||
m_leftOver = policy.GetBytesPerIteration();
|
||||
}
|
||||
@@ -116,7 +116,7 @@ void CFB_CipherTemplate<BASE>::Resynchronize(const byte *iv)
|
||||
template <class BASE>
|
||||
void CFB_CipherTemplate<BASE>::ProcessData(byte *outString, const byte *inString, unsigned int length)
|
||||
{
|
||||
PolicyInterface &policy = AccessPolicy();
|
||||
PolicyInterface &policy = this->AccessPolicy();
|
||||
unsigned int bytesPerIteration = policy.GetBytesPerIteration();
|
||||
unsigned int alignment = policy.GetAlignment();
|
||||
byte *reg = policy.GetRegisterBegin();
|
||||
|
||||
@@ -123,12 +123,12 @@ public:
|
||||
byte GenerateByte();
|
||||
void ProcessData(byte *outString, const byte *inString, unsigned int length);
|
||||
void Resynchronize(const byte *iv);
|
||||
unsigned int OptimalBlockSize() const {return GetPolicy().GetBytesPerIteration();}
|
||||
unsigned int OptimalBlockSize() const {return this->GetPolicy().GetBytesPerIteration();}
|
||||
unsigned int GetOptimalNextBlockSize() const {return m_leftOver;}
|
||||
unsigned int OptimalDataAlignment() const {return GetPolicy().GetAlignment();}
|
||||
unsigned int OptimalDataAlignment() const {return this->GetPolicy().GetAlignment();}
|
||||
bool IsSelfInverting() const {return true;}
|
||||
bool IsForwardTransformation() const {return true;}
|
||||
bool IsRandomAccess() const {return GetPolicy().IsRandomAccess();}
|
||||
bool IsRandomAccess() const {return this->GetPolicy().IsRandomAccess();}
|
||||
void Seek(dword position);
|
||||
|
||||
typedef typename BASE::PolicyInterface PolicyInterface;
|
||||
@@ -165,7 +165,7 @@ struct CFB_CipherConcretePolicy : public BASE
|
||||
unsigned int GetAlignment() const {return sizeof(WordType);}
|
||||
unsigned int GetBytesPerIteration() const {return sizeof(WordType) * W;}
|
||||
bool CanIterate() const {return true;}
|
||||
void TransformRegister() {Iterate(NULL, NULL, ENCRYPTION, 1);}
|
||||
void TransformRegister() {this->Iterate(NULL, NULL, ENCRYPTION, 1);}
|
||||
|
||||
template <class B>
|
||||
struct RegisterOutput
|
||||
@@ -215,9 +215,9 @@ class CFB_CipherTemplate : public BASE
|
||||
public:
|
||||
void ProcessData(byte *outString, const byte *inString, unsigned int length);
|
||||
void Resynchronize(const byte *iv);
|
||||
unsigned int OptimalBlockSize() const {return GetPolicy().GetBytesPerIteration();}
|
||||
unsigned int OptimalBlockSize() const {return this->GetPolicy().GetBytesPerIteration();}
|
||||
unsigned int GetOptimalNextBlockSize() const {return m_leftOver;}
|
||||
unsigned int OptimalDataAlignment() const {return GetPolicy().GetAlignment();}
|
||||
unsigned int OptimalDataAlignment() const {return this->GetPolicy().GetAlignment();}
|
||||
bool IsRandomAccess() const {return false;}
|
||||
bool IsSelfInverting() const {return false;}
|
||||
|
||||
@@ -251,16 +251,16 @@ class SymmetricCipherFinalTemplate : public AlgorithmImpl<SimpleKeyingInterfaceI
|
||||
public:
|
||||
SymmetricCipherFinalTemplate() {}
|
||||
SymmetricCipherFinalTemplate(const byte *key)
|
||||
{SetKey(key, DEFAULT_KEYLENGTH);}
|
||||
{SetKey(key, this->DEFAULT_KEYLENGTH);}
|
||||
SymmetricCipherFinalTemplate(const byte *key, unsigned int length)
|
||||
{SetKey(key, length);}
|
||||
SymmetricCipherFinalTemplate(const byte *key, unsigned int length, const byte *iv)
|
||||
{SetKey(key, length); Resynchronize(iv);}
|
||||
{SetKey(key, length); this->Resynchronize(iv);}
|
||||
|
||||
void SetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms = g_nullNameValuePairs)
|
||||
{
|
||||
ThrowIfInvalidKeyLength(length);
|
||||
UncheckedSetKey(params, key, length);
|
||||
this->ThrowIfInvalidKeyLength(length);
|
||||
this->UncheckedSetKey(params, key, length);
|
||||
}
|
||||
|
||||
Clonable * Clone() const {return static_cast<SymmetricCipher *>(new SymmetricCipherFinalTemplate<BASE, INFO>(*this));}
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
template <class S>
|
||||
void AdditiveCipherTemplate<S>::UncheckedSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length)
|
||||
{
|
||||
PolicyInterface &policy = AccessPolicy();
|
||||
PolicyInterface &policy = this->AccessPolicy();
|
||||
policy.CipherSetKey(params, key, length);
|
||||
m_buffer.New(GetBufferByteSize(policy));
|
||||
m_leftOver = 0;
|
||||
@@ -278,7 +278,7 @@ void AdditiveCipherTemplate<S>::UncheckedSetKey(const NameValuePairs ¶ms, co
|
||||
template <class BASE>
|
||||
void CFB_CipherTemplate<BASE>::UncheckedSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length)
|
||||
{
|
||||
PolicyInterface &policy = AccessPolicy();
|
||||
PolicyInterface &policy = this->AccessPolicy();
|
||||
policy.CipherSetKey(params, key, length);
|
||||
m_leftOver = policy.GetBytesPerIteration();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user