diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2007-12-05 13:50:44 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2007-12-05 13:50:44 +0000 |
commit | 2af82878ebad135d0fecc53e54077862810a7273 (patch) | |
tree | b324c64f49ed44cd44191a5ef805d1297c2a9758 /modes.h | |
parent | 1b0c2eed48748ebeddf3e39cf3b626e939070a9f (diff) | |
download | cryptopp-2af82878ebad135d0fecc53e54077862810a7273.tar.gz |
fix AlgorithmName() for ExternalCipher classes and move SetCipher() into CipherModeBase
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@417 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'modes.h')
-rw-r--r-- | modes.h | 40 |
1 files changed, 19 insertions, 21 deletions
@@ -42,6 +42,23 @@ public: unsigned int IVSize() const {return BlockSize();} virtual IV_Requirement IVRequirement() const =0; + void SetCipher(BlockCipher &cipher) + { + this->ThrowIfResynchronizable(); + this->m_cipher = &cipher; + this->ResizeBuffers(); + } + + void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize = 0) + { + this->ThrowIfInvalidIV(iv); + this->m_cipher = &cipher; + this->ResizeBuffers(); + this->SetFeedbackSize(feedbackSize); + if (this->IsResynchronizable()) + this->Resynchronize(iv); + } + protected: inline unsigned int BlockSize() const {assert(m_register.size() > 0); return (unsigned int)m_register.size();} virtual void SetFeedbackSize(unsigned int feedbackSize) @@ -295,29 +312,10 @@ public: CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0) {SetCipherWithIV(cipher, iv, feedbackSize);} - void SetCipher(BlockCipher &cipher); - void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize = 0); + std::string AlgorithmName() const + {return m_cipher->AlgorithmName() + "/" + BASE::StaticAlgorithmName();} }; -template <class BASE> -void CipherModeFinalTemplate_ExternalCipher<BASE>::SetCipher(BlockCipher &cipher) -{ - this->ThrowIfResynchronizable(); - this->m_cipher = &cipher; - this->ResizeBuffers(); -} - -template <class BASE> -void CipherModeFinalTemplate_ExternalCipher<BASE>::SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize) -{ - this->ThrowIfInvalidIV(iv); - this->m_cipher = &cipher; - this->ResizeBuffers(); - this->SetFeedbackSize(feedbackSize); - if (this->IsResynchronizable()) - this->Resynchronize(iv); -} - CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >; CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >; CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >; |