summaryrefslogtreecommitdiff
path: root/modes.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-12 11:24:12 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-12 11:24:12 +0000
commita36c71ecb6840ff799546ccaf665e55f6a6ed5dc (patch)
tree68edc0bccf003f5615716b3ae2d6b97067af39c4 /modes.h
parentce1fbfcba325116155a605b8519bc0b4e272348f (diff)
downloadcryptopp-a36c71ecb6840ff799546ccaf665e55f6a6ed5dc.tar.gz
- add EAX mode, XSalsa20
- speed up GCM key setup - wipe stack in AES assembly code - speed up CFB mode git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@444 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'modes.h')
-rw-r--r--modes.h34
1 files changed, 8 insertions, 26 deletions
diff --git a/modes.h b/modes.h
index 91a61b6..ff88d31 100644
--- a/modes.h
+++ b/modes.h
@@ -101,30 +101,12 @@ public:
protected:
unsigned int GetBytesPerIteration() const {return m_feedbackSize;}
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);
- memcpy_s(m_register+updateSize, m_register.size()-updateSize, m_temp, m_feedbackSize);
- }
- void CipherResynchronize(const byte *iv, size_t length)
- {
- memcpy_s(m_register, m_register.size(), iv, BlockSize());
- TransformRegister();
- }
- void SetFeedbackSize(unsigned int feedbackSize)
- {
- if (feedbackSize > BlockSize())
- throw InvalidArgument("CFB_Mode: invalid feedback size");
- m_feedbackSize = feedbackSize ? feedbackSize : BlockSize();
- }
- void ResizeBuffers()
- {
- CipherModeBase::ResizeBuffers();
- m_temp.New(BlockSize());
- }
+ bool CanIterate() const {return m_feedbackSize == BlockSize();}
+ void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
+ void TransformRegister();
+ void CipherResynchronize(const byte *iv, size_t length);
+ void SetFeedbackSize(unsigned int feedbackSize);
+ void ResizeBuffers();
SecByteBlock m_temp;
unsigned int m_feedbackSize;
@@ -279,12 +261,12 @@ public:
CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv)
{
this->m_cipher = &this->m_object;
- this->SetKey(key, length, MakeParameters(Name::IV(), iv));
+ this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize())));
}
CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv, int feedbackSize)
{
this->m_cipher = &this->m_object;
- this->SetKey(key, length, MakeParameters(Name::IV(), iv)(Name::FeedbackSize(), feedbackSize));
+ this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize()))(Name::FeedbackSize(), feedbackSize));
}
static std::string CRYPTOPP_API StaticAlgorithmName()