From c3bad1afc1564f3bfac8434d45d6694811139333 Mon Sep 17 00:00:00 2001 From: weidai Date: Sun, 10 Dec 2006 02:12:23 +0000 Subject: port to GCC 4, reorganize implementations of SetKey git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@248 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- strciphr.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'strciphr.h') diff --git a/strciphr.h b/strciphr.h index 76d7b3d..e905d7b 100644 --- a/strciphr.h +++ b/strciphr.h @@ -135,7 +135,7 @@ public: typedef typename BASE::PolicyInterface PolicyInterface; protected: - void UncheckedSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length, const byte *iv); + void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); unsigned int GetBufferByteSize(const PolicyInterface &policy) const {return policy.GetBytesPerIteration() * policy.GetIterationsToBuffer();} @@ -233,7 +233,7 @@ public: protected: virtual void CombineMessageAndShiftRegister(byte *output, byte *reg, const byte *message, size_t length) =0; - void UncheckedSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length, const byte *iv); + void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms); size_t m_leftOver; }; @@ -266,23 +266,17 @@ class SymmetricCipherFinal : public AlgorithmImplDEFAULT_KEYLENGTH);} + {this->SetKey(key, this->DEFAULT_KEYLENGTH);} SymmetricCipherFinal(const byte *key, size_t length) - {SetKey(key, length);} + {this->SetKey(key, length);} SymmetricCipherFinal(const byte *key, size_t length, const byte *iv) {this->SetKeyWithIV(key, length, iv);} - void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms = g_nullNameValuePairs) - { - this->ThrowIfInvalidKeyLength(length); - this->UncheckedSetKey(params, key, (unsigned int)length, this->GetIVAndThrowIfInvalid(params)); - } - Clonable * Clone() const {return static_cast(new SymmetricCipherFinal(*this));} }; template -void AdditiveCipherTemplate::UncheckedSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length, const byte *iv) +void AdditiveCipherTemplate::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) { PolicyInterface &policy = this->AccessPolicy(); policy.CipherSetKey(params, key, length); @@ -290,17 +284,17 @@ void AdditiveCipherTemplate::UncheckedSetKey(const NameValuePairs ¶ms, co m_buffer.New(GetBufferByteSize(policy)); if (this->IsResynchronizable()) - policy.CipherResynchronize(m_buffer, iv); + policy.CipherResynchronize(m_buffer, this->GetIVAndThrowIfInvalid(params)); } template -void CFB_CipherTemplate::UncheckedSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length, const byte *iv) +void CFB_CipherTemplate::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) { PolicyInterface &policy = this->AccessPolicy(); policy.CipherSetKey(params, key, length); if (this->IsResynchronizable()) - policy.CipherResynchronize(iv); + policy.CipherResynchronize(this->GetIVAndThrowIfInvalid(params)); m_leftOver = policy.GetBytesPerIteration(); } -- cgit v1.2.1