From 866f75e49a3f1a83ad937acb6dd66f84fe422d8e Mon Sep 17 00:00:00 2001 From: weidai Date: Mon, 16 Apr 2007 00:34:13 +0000 Subject: rename STRUCTURED_IV to UNIQUE_IV. assert correct cipher direction git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@311 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- modes.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'modes.h') diff --git a/modes.h b/modes.h index 98547d4..a4f5bbe 100644 --- a/modes.h +++ b/modes.h @@ -87,6 +87,7 @@ protected: byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;} void TransformRegister() { + assert(m_cipher->IsForwardTransformation()); // CFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt m_cipher->ProcessBlock(m_register, m_temp); unsigned int updateSize = BlockSize()-m_feedbackSize; memmove_s(m_register, m_register.size(), m_register+m_feedbackSize, updateSize); @@ -125,7 +126,7 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTe { public: bool IsRandomAccess() const {return false;} - IV_Requirement IVRequirement() const {return STRUCTURED_IV;} + IV_Requirement IVRequirement() const {return UNIQUE_IV;} static const char * CRYPTOPP_API StaticAlgorithmName() {return "OFB";} private: @@ -134,6 +135,7 @@ private: void WriteKeystream(byte *keystreamBuffer, size_t iterationCount) { assert(iterationCount == 1); + assert(m_cipher->IsForwardTransformation()); // OFB mode needs the "encrypt" direction of the underlying block cipher, even to decrypt m_cipher->ProcessBlock(keystreamBuffer); memcpy_s(m_register, m_register.size(), keystreamBuffer, BlockSize()); } @@ -147,7 +149,7 @@ class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTe { public: bool IsRandomAccess() const {return true;} - IV_Requirement IVRequirement() const {return STRUCTURED_IV;} + IV_Requirement IVRequirement() const {return UNIQUE_IV;} void CipherGetNextIV(byte *IV); static const char * CRYPTOPP_API StaticAlgorithmName() {return "CTR";} @@ -192,6 +194,8 @@ protected: class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : public BlockOrientedCipherModeBase { public: + void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms = g_nullNameValuePairs) + {m_cipher->SetKey(key, length, params); BlockOrientedCipherModeBase::ResizeBuffers();} IV_Requirement IVRequirement() const {return NOT_RESYNCHRONIZABLE;} unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();} void ProcessBlocks(byte *outString, const byte *inString, size_t numberOfBlocks) -- cgit v1.2.1