fix infinite recursive call in IsRandomAccess (reported by ASBai)

This commit is contained in:
weidai 2008-02-02 08:40:27 +00:00
parent c8fe7e0718
commit 244f99c027
7 changed files with 10 additions and 10 deletions

View File

@ -140,7 +140,7 @@ inline void CopyOrZero(void *dest, const void *src, size_t s)
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
{
public:
bool IsRandomAccess() const {return false;}
bool CipherIsRandomAccess() const {return false;}
IV_Requirement IVRequirement() const {return UNIQUE_IV;}
static const char * CRYPTOPP_API StaticAlgorithmName() {return "OFB";}
@ -162,7 +162,7 @@ private:
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
{
public:
bool IsRandomAccess() const {return true;}
bool CipherIsRandomAccess() const {return true;}
IV_Requirement IVRequirement() const {return UNIQUE_IV;}
static const char * CRYPTOPP_API StaticAlgorithmName() {return "CTR";}

View File

@ -122,7 +122,7 @@ class PanamaCipherPolicy : public AdditiveCipherConcretePolicy<word32, 8>,
protected:
void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
bool IsRandomAccess() const {return false;}
bool CipherIsRandomAccess() const {return false;}
void CipherResynchronize(byte *keystreamBuffer, const byte *iv);
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64
unsigned int GetAlignment() const;

View File

@ -19,7 +19,7 @@ protected:
void CipherSetKey(const NameValuePairs &params, 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);
bool IsRandomAccess() const {return true;}
bool CipherIsRandomAccess() const {return true;}
void SeekToIteration(lword iterationCount);
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64
unsigned int GetAlignment() const;

2
seal.h
View File

@ -19,7 +19,7 @@ protected:
void CipherSetKey(const NameValuePairs &params, 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);
bool IsRandomAccess() const {return true;}
bool CipherIsRandomAccess() const {return true;}
void SeekToIteration(lword iterationCount);
private:

View File

@ -18,7 +18,7 @@ protected:
void CipherSetKey(const NameValuePairs &params, 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);
bool IsRandomAccess() const {return false;}
bool CipherIsRandomAccess() const {return false;}
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64
unsigned int GetAlignment() const;
unsigned int GetOptimalBlockSize() const;

View File

@ -75,8 +75,8 @@ struct CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AdditiveCipherAbstractPolicy
virtual void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount) {assert(false);}
virtual void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length) =0;
virtual void CipherResynchronize(byte *keystreamBuffer, const byte *iv) {throw NotImplemented("SimpleKeyingInterface: this object doesn't support resynchronization");}
virtual bool IsRandomAccess() const =0;
virtual void SeekToIteration(lword iterationCount) {assert(!IsRandomAccess()); throw NotImplemented("StreamTransformation: this object doesn't support random access");}
virtual bool CipherIsRandomAccess() const =0;
virtual void SeekToIteration(lword iterationCount) {assert(!CipherIsRandomAccess()); throw NotImplemented("StreamTransformation: this object doesn't support random access");}
};
template <typename WT, unsigned int W, unsigned int X = 1, class BASE = AdditiveCipherAbstractPolicy>
@ -141,7 +141,7 @@ public:
unsigned int OptimalDataAlignment() const {return this->GetPolicy().GetAlignment();}
bool IsSelfInverting() const {return true;}
bool IsForwardTransformation() const {return true;}
bool IsRandomAccess() const {return this->GetPolicy().IsRandomAccess();}
bool IsRandomAccess() const {return this->GetPolicy().CipherIsRandomAccess();}
void Seek(lword position);
typedef typename BASE::PolicyInterface PolicyInterface;

2
wake.h
View File

@ -44,7 +44,7 @@ protected:
void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
// OFB
void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
bool IsRandomAccess() const {return false;}
bool CipherIsRandomAccess() const {return false;}
};
namespace Weak {