From 244f99c0271e9b146989f3bb2b22b81b8efdc28e Mon Sep 17 00:00:00 2001 From: weidai Date: Sat, 2 Feb 2008 08:40:27 +0000 Subject: [PATCH] fix infinite recursive call in IsRandomAccess (reported by ASBai) --- modes.h | 4 ++-- panama.h | 2 +- salsa.h | 2 +- seal.h | 2 +- sosemanuk.h | 2 +- strciphr.h | 6 +++--- wake.h | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modes.h b/modes.h index 28827fa6..d6822ff9 100644 --- a/modes.h +++ b/modes.h @@ -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 { 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 { 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";} diff --git a/panama.h b/panama.h index 672076df..466e5281 100644 --- a/panama.h +++ b/panama.h @@ -122,7 +122,7 @@ class PanamaCipherPolicy : public AdditiveCipherConcretePolicy, protected: void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); - 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; diff --git a/salsa.h b/salsa.h index 5b1431ac..46e0136c 100755 --- a/salsa.h +++ b/salsa.h @@ -19,7 +19,7 @@ protected: void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); void CipherResynchronize(byte *keystreamBuffer, const byte *IV); - 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; diff --git a/seal.h b/seal.h index c175a64e..f9142530 100644 --- a/seal.h +++ b/seal.h @@ -19,7 +19,7 @@ protected: void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); void CipherResynchronize(byte *keystreamBuffer, const byte *IV); - bool IsRandomAccess() const {return true;} + bool CipherIsRandomAccess() const {return true;} void SeekToIteration(lword iterationCount); private: diff --git a/sosemanuk.h b/sosemanuk.h index c68144c0..ee789142 100755 --- a/sosemanuk.h +++ b/sosemanuk.h @@ -18,7 +18,7 @@ protected: void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); void CipherResynchronize(byte *keystreamBuffer, const byte *iv); - 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; diff --git a/strciphr.h b/strciphr.h index 6a5cc97a..71a87e92 100644 --- a/strciphr.h +++ b/strciphr.h @@ -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 ¶ms, 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 @@ -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; diff --git a/wake.h b/wake.h index 2fa00a8e..e3c9390d 100644 --- a/wake.h +++ b/wake.h @@ -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 {