fix whitespace problems

pull/2/head
weidai 2003-02-24 01:06:41 +00:00
parent db22cfbee3
commit 7c7958ccc0
2 changed files with 143 additions and 143 deletions

View File

@ -74,23 +74,23 @@ void CTR_ModePolicy::SeekToIteration(dword iterationCount)
static inline void IncrementCounterByOne(byte *inout, unsigned int s) static inline void IncrementCounterByOne(byte *inout, unsigned int s)
{ {
for (int i=s-1, carry=1; i>=0 && carry; i--) for (int i=s-1, carry=1; i>=0 && carry; i--)
carry = !++inout[i]; carry = !++inout[i];
} }
static inline void IncrementCounterByOne(byte *output, const byte *input, unsigned int s) static inline void IncrementCounterByOne(byte *output, const byte *input, unsigned int s)
{ {
for (int i=s-1, carry=1; i>=0; i--) for (int i=s-1, carry=1; i>=0; i--)
carry = !(output[i] = input[i]+carry) && carry; carry = !(output[i] = input[i]+carry) && carry;
} }
inline void CTR_ModePolicy::ProcessMultipleBlocks(byte *output, const byte *input, unsigned int n) inline void CTR_ModePolicy::ProcessMultipleBlocks(byte *output, const byte *input, unsigned int n)
{ {
unsigned int s = BlockSize(), j = 0; unsigned int s = BlockSize(), j = 0;
for (unsigned int i=1; i<n; i++, j+=s) for (unsigned int i=1; i<n; i++, j+=s)
IncrementCounterByOne(m_counterArray + j + s, m_counterArray + j, s); IncrementCounterByOne(m_counterArray + j + s, m_counterArray + j, s);
m_cipher->ProcessAndXorMultipleBlocks(m_counterArray, input, output, n); m_cipher->ProcessAndXorMultipleBlocks(m_counterArray, input, output, n);
IncrementCounterByOne(m_counterArray, m_counterArray + s*(n-1), s); IncrementCounterByOne(m_counterArray, m_counterArray + s*(n-1), s);
} }
void CTR_ModePolicy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount) void CTR_ModePolicy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount)

270
modes.h
View File

@ -1,7 +1,7 @@
#ifndef CRYPTOPP_MODES_H #ifndef CRYPTOPP_MODES_H
#define CRYPTOPP_MODES_H #define CRYPTOPP_MODES_H
/*! \file /*! \file
*/ */
#include "cryptlib.h" #include "cryptlib.h"
@ -13,67 +13,67 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
//! Cipher mode documentation. See NIST SP 800-38A for definitions of these modes. //! Cipher mode documentation. See NIST SP 800-38A for definitions of these modes.
/*! Each class derived from this one defines two types, Encryption and Decryption, /*! Each class derived from this one defines two types, Encryption and Decryption,
both of which implement the SymmetricCipher interface. both of which implement the SymmetricCipher interface.
For each mode there are two classes, one of which is a template class, For each mode there are two classes, one of which is a template class,
and the other one has a name that ends in "_ExternalCipher". and the other one has a name that ends in "_ExternalCipher".
The "external cipher" mode objects hold a reference to the underlying block cipher, The "external cipher" mode objects hold a reference to the underlying block cipher,
instead of holding an instance of it. The reference must be passed in to the constructor. instead of holding an instance of it. The reference must be passed in to the constructor.
For the "cipher holder" classes, the CIPHER template parameter should be a class For the "cipher holder" classes, the CIPHER template parameter should be a class
derived from BlockCipherDocumentation, for example DES or AES. derived from BlockCipherDocumentation, for example DES or AES.
*/ */
struct CipherModeDocumentation : public SymmetricCipherDocumentation struct CipherModeDocumentation : public SymmetricCipherDocumentation
{ {
}; };
class CipherModeBase : public SymmetricCipher class CipherModeBase : public SymmetricCipher
{ {
public: public:
unsigned int MinKeyLength() const {return m_cipher->MinKeyLength();} unsigned int MinKeyLength() const {return m_cipher->MinKeyLength();}
unsigned int MaxKeyLength() const {return m_cipher->MaxKeyLength();} unsigned int MaxKeyLength() const {return m_cipher->MaxKeyLength();}
unsigned int DefaultKeyLength() const {return m_cipher->DefaultKeyLength();} unsigned int DefaultKeyLength() const {return m_cipher->DefaultKeyLength();}
unsigned int GetValidKeyLength(unsigned int n) const {return m_cipher->GetValidKeyLength(n);} unsigned int GetValidKeyLength(unsigned int n) const {return m_cipher->GetValidKeyLength(n);}
bool IsValidKeyLength(unsigned int n) const {return m_cipher->IsValidKeyLength(n);} bool IsValidKeyLength(unsigned int n) const {return m_cipher->IsValidKeyLength(n);}
void SetKey(const byte *key, unsigned int length, const NameValuePairs &params = g_nullNameValuePairs); void SetKey(const byte *key, unsigned int length, const NameValuePairs &params = g_nullNameValuePairs);
unsigned int OptimalDataAlignment() const {return BlockSize();} unsigned int OptimalDataAlignment() const {return BlockSize();}
unsigned int IVSize() const {return BlockSize();} unsigned int IVSize() const {return BlockSize();}
void GetNextIV(byte *IV); void GetNextIV(byte *IV);
virtual IV_Requirement IVRequirement() const =0; virtual IV_Requirement IVRequirement() const =0;
protected: protected:
inline unsigned int BlockSize() const {assert(m_register.size() > 0); return m_register.size();} inline unsigned int BlockSize() const {assert(m_register.size() > 0); return m_register.size();}
void SetIV(const byte *iv); void SetIV(const byte *iv);
virtual void SetFeedbackSize(unsigned int feedbackSize) virtual void SetFeedbackSize(unsigned int feedbackSize)
{ {
if (!(feedbackSize == 0 || feedbackSize == BlockSize())) if (!(feedbackSize == 0 || feedbackSize == BlockSize()))
throw InvalidArgument("CipherModeBase: feedback size cannot be specified for this cipher mode"); throw InvalidArgument("CipherModeBase: feedback size cannot be specified for this cipher mode");
} }
virtual void ResizeBuffers() virtual void ResizeBuffers()
{ {
m_register.New(m_cipher->BlockSize()); m_register.New(m_cipher->BlockSize());
} }
virtual void UncheckedSetKey(const NameValuePairs &params, const byte *key, unsigned int length) =0; virtual void UncheckedSetKey(const NameValuePairs &params, const byte *key, unsigned int length) =0;
BlockCipher *m_cipher; BlockCipher *m_cipher;
SecByteBlock m_register; SecByteBlock m_register;
}; };
template <class POLICY_INTERFACE> template <class POLICY_INTERFACE>
class ModePolicyCommonTemplate : public CipherModeBase, public POLICY_INTERFACE class ModePolicyCommonTemplate : public CipherModeBase, public POLICY_INTERFACE
{ {
unsigned int GetAlignment() const {return m_cipher->BlockAlignment();} unsigned int GetAlignment() const {return m_cipher->BlockAlignment();}
void CipherSetKey(const NameValuePairs &params, const byte *key, unsigned int length) void CipherSetKey(const NameValuePairs &params, const byte *key, unsigned int length)
{ {
m_cipher->SetKey(key, length, params); m_cipher->SetKey(key, length, params);
ResizeBuffers(); ResizeBuffers();
int feedbackSize = params.GetIntValueWithDefault(Name::FeedbackSize(), 0); int feedbackSize = params.GetIntValueWithDefault(Name::FeedbackSize(), 0);
SetFeedbackSize(feedbackSize); SetFeedbackSize(feedbackSize);
const byte *iv = params.GetValueWithDefault(Name::IV(), (const byte *)NULL); const byte *iv = params.GetValueWithDefault(Name::IV(), (const byte *)NULL);
SetIV(iv); SetIV(iv);
} }
}; };
@ -84,15 +84,15 @@ public:
IV_Requirement IVRequirement() const {return RANDOM_IV;} IV_Requirement IVRequirement() const {return RANDOM_IV;}
protected: protected:
unsigned int GetBytesPerIteration() const {return m_feedbackSize;} unsigned int GetBytesPerIteration() const {return m_feedbackSize;}
byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;} byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;}
void TransformRegister() void TransformRegister()
{ {
m_cipher->ProcessBlock(m_register, m_temp); m_cipher->ProcessBlock(m_register, m_temp);
memmove(m_register, m_register+m_feedbackSize, BlockSize()-m_feedbackSize); memmove(m_register, m_register+m_feedbackSize, BlockSize()-m_feedbackSize);
memcpy(m_register+BlockSize()-m_feedbackSize, m_temp, m_feedbackSize); memcpy(m_register+BlockSize()-m_feedbackSize, m_temp, m_feedbackSize);
} }
void CipherResynchronize(const byte *iv) void CipherResynchronize(const byte *iv)
{ {
memcpy(m_register, iv, BlockSize()); memcpy(m_register, iv, BlockSize());
TransformRegister(); TransformRegister();
@ -101,7 +101,7 @@ protected:
{ {
if (feedbackSize > BlockSize()) if (feedbackSize > BlockSize())
throw InvalidArgument("CFB_Mode: invalid feedback size"); throw InvalidArgument("CFB_Mode: invalid feedback size");
m_feedbackSize = feedbackSize ? feedbackSize : BlockSize(); m_feedbackSize = feedbackSize ? feedbackSize : BlockSize();
} }
void ResizeBuffers() void ResizeBuffers()
{ {
@ -115,53 +115,53 @@ protected:
class OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy> class OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
{ {
unsigned int GetBytesPerIteration() const {return BlockSize();} unsigned int GetBytesPerIteration() const {return BlockSize();}
unsigned int GetIterationsToBuffer() const {return 1;} unsigned int GetIterationsToBuffer() const {return 1;}
void WriteKeystream(byte *keystreamBuffer, unsigned int iterationCount) void WriteKeystream(byte *keystreamBuffer, unsigned int iterationCount)
{ {
assert(iterationCount == 1); assert(iterationCount == 1);
m_cipher->ProcessBlock(keystreamBuffer); m_cipher->ProcessBlock(keystreamBuffer);
} }
void CipherResynchronize(byte *keystreamBuffer, const byte *iv) void CipherResynchronize(byte *keystreamBuffer, const byte *iv)
{ {
memcpy(keystreamBuffer, iv, BlockSize()); memcpy(keystreamBuffer, iv, BlockSize());
} }
bool IsRandomAccess() const {return false;} bool IsRandomAccess() const {return false;}
IV_Requirement IVRequirement() const {return STRUCTURED_IV;} IV_Requirement IVRequirement() const {return STRUCTURED_IV;}
}; };
class CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy> class CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
{ {
unsigned int GetBytesPerIteration() const {return BlockSize();} unsigned int GetBytesPerIteration() const {return BlockSize();}
unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();} unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();}
void WriteKeystream(byte *buffer, unsigned int iterationCount) void WriteKeystream(byte *buffer, unsigned int iterationCount)
{OperateKeystream(WRITE_KEYSTREAM, buffer, NULL, iterationCount);} {OperateKeystream(WRITE_KEYSTREAM, buffer, NULL, iterationCount);}
bool CanOperateKeystream() const {return true;} bool CanOperateKeystream() const {return true;}
void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount); void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount);
void CipherResynchronize(byte *keystreamBuffer, const byte *iv); void CipherResynchronize(byte *keystreamBuffer, const byte *iv);
bool IsRandomAccess() const {return true;} bool IsRandomAccess() const {return true;}
void SeekToIteration(dword iterationCount); void SeekToIteration(dword iterationCount);
IV_Requirement IVRequirement() const {return STRUCTURED_IV;} IV_Requirement IVRequirement() const {return STRUCTURED_IV;}
inline void ProcessMultipleBlocks(byte *output, const byte *input, unsigned int n); inline void ProcessMultipleBlocks(byte *output, const byte *input, unsigned int n);
SecByteBlock m_counterArray; SecByteBlock m_counterArray;
}; };
class BlockOrientedCipherModeBase : public CipherModeBase class BlockOrientedCipherModeBase : public CipherModeBase
{ {
public: public:
void UncheckedSetKey(const NameValuePairs &params, const byte *key, unsigned int length); void UncheckedSetKey(const NameValuePairs &params, const byte *key, unsigned int length);
unsigned int MandatoryBlockSize() const {return BlockSize();} unsigned int MandatoryBlockSize() const {return BlockSize();}
bool IsRandomAccess() const {return false;} bool IsRandomAccess() const {return false;}
bool IsSelfInverting() const {return false;} bool IsSelfInverting() const {return false;}
bool IsForwardTransformation() const {return m_cipher->IsForwardTransformation();} bool IsForwardTransformation() const {return m_cipher->IsForwardTransformation();}
void Resynchronize(const byte *iv) {memcpy(m_register, iv, BlockSize());} void Resynchronize(const byte *iv) {memcpy(m_register, iv, BlockSize());}
void ProcessData(byte *outString, const byte *inString, unsigned int length); void ProcessData(byte *outString, const byte *inString, unsigned int length);
protected: protected:
bool RequireAlignedInput() const {return true;} bool RequireAlignedInput() const {return true;}
virtual void ProcessBlocks(byte *outString, const byte *inString, unsigned int numberOfBlocks) =0; virtual void ProcessBlocks(byte *outString, const byte *inString, unsigned int numberOfBlocks) =0;
void ResizeBuffers() void ResizeBuffers()
{ {
CipherModeBase::ResizeBuffers(); CipherModeBase::ResizeBuffers();
@ -175,37 +175,37 @@ class ECB_OneWay : public BlockOrientedCipherModeBase
{ {
public: public:
IV_Requirement IVRequirement() const {return NOT_RESYNCHRONIZABLE;} IV_Requirement IVRequirement() const {return NOT_RESYNCHRONIZABLE;}
unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();} unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();}
void ProcessBlocks(byte *outString, const byte *inString, unsigned int numberOfBlocks) void ProcessBlocks(byte *outString, const byte *inString, unsigned int numberOfBlocks)
{m_cipher->ProcessAndXorMultipleBlocks(inString, NULL, outString, numberOfBlocks);} {m_cipher->ProcessAndXorMultipleBlocks(inString, NULL, outString, numberOfBlocks);}
}; };
class CBC_ModeBase : public BlockOrientedCipherModeBase class CBC_ModeBase : public BlockOrientedCipherModeBase
{ {
public: public:
IV_Requirement IVRequirement() const {return UNPREDICTABLE_RANDOM_IV;} IV_Requirement IVRequirement() const {return UNPREDICTABLE_RANDOM_IV;}
bool RequireAlignedInput() const {return false;} bool RequireAlignedInput() const {return false;}
unsigned int MinLastBlockSize() const {return 0;} unsigned int MinLastBlockSize() const {return 0;}
}; };
class CBC_Encryption : public CBC_ModeBase class CBC_Encryption : public CBC_ModeBase
{ {
public: public:
void ProcessBlocks(byte *outString, const byte *inString, unsigned int numberOfBlocks); void ProcessBlocks(byte *outString, const byte *inString, unsigned int numberOfBlocks);
}; };
class CBC_CTS_Encryption : public CBC_Encryption class CBC_CTS_Encryption : public CBC_Encryption
{ {
public: public:
void SetStolenIV(byte *iv) {m_stolenIV = iv;} void SetStolenIV(byte *iv) {m_stolenIV = iv;}
unsigned int MinLastBlockSize() const {return BlockSize()+1;} unsigned int MinLastBlockSize() const {return BlockSize()+1;}
void ProcessLastBlock(byte *outString, const byte *inString, unsigned int length); void ProcessLastBlock(byte *outString, const byte *inString, unsigned int length);
protected: protected:
void UncheckedSetKey(const NameValuePairs &params, const byte *key, unsigned int length) void UncheckedSetKey(const NameValuePairs &params, const byte *key, unsigned int length)
{ {
CBC_Encryption::UncheckedSetKey(params, key, length); CBC_Encryption::UncheckedSetKey(params, key, length);
m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULL); m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULL);
} }
byte *m_stolenIV; byte *m_stolenIV;
@ -214,7 +214,7 @@ protected:
class CBC_Decryption : public CBC_ModeBase class CBC_Decryption : public CBC_ModeBase
{ {
public: public:
void ProcessBlocks(byte *outString, const byte *inString, unsigned int numberOfBlocks); void ProcessBlocks(byte *outString, const byte *inString, unsigned int numberOfBlocks);
protected: protected:
void ResizeBuffers() void ResizeBuffers()
@ -228,13 +228,13 @@ protected:
class CBC_CTS_Decryption : public CBC_Decryption class CBC_CTS_Decryption : public CBC_Decryption
{ {
public: public:
unsigned int MinLastBlockSize() const {return BlockSize()+1;} unsigned int MinLastBlockSize() const {return BlockSize()+1;}
void ProcessLastBlock(byte *outString, const byte *inString, unsigned int length); void ProcessLastBlock(byte *outString, const byte *inString, unsigned int length);
}; };
//! . //! .
template <class CIPHER, class BASE> template <class CIPHER, class BASE>
class CipherModeFinalTemplate_CipherHolder : public ObjectHolder<CIPHER>, public BASE class CipherModeFinalTemplate_CipherHolder : public ObjectHolder<CIPHER>, public BASE
{ {
public: public:
CipherModeFinalTemplate_CipherHolder() CipherModeFinalTemplate_CipherHolder()
@ -242,24 +242,24 @@ public:
m_cipher = &m_object; m_cipher = &m_object;
ResizeBuffers(); ResizeBuffers();
} }
CipherModeFinalTemplate_CipherHolder(const byte *key, unsigned int length) CipherModeFinalTemplate_CipherHolder(const byte *key, unsigned int length)
{ {
m_cipher = &m_object; m_cipher = &m_object;
SetKey(key, length); SetKey(key, length);
} }
CipherModeFinalTemplate_CipherHolder(const byte *key, unsigned int length, const byte *iv, int feedbackSize = 0) CipherModeFinalTemplate_CipherHolder(const byte *key, unsigned int length, const byte *iv, int feedbackSize = 0)
{ {
m_cipher = &m_object; m_cipher = &m_object;
SetKey(key, length, MakeParameters("IV", iv)("FeedbackSize", feedbackSize)); SetKey(key, length, MakeParameters("IV", iv)("FeedbackSize", feedbackSize));
} }
}; };
//! . //! .
template <class BASE> template <class BASE>
class CipherModeFinalTemplate_ExternalCipher : public BASE class CipherModeFinalTemplate_ExternalCipher : public BASE
{ {
public: public:
CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv = NULL, int feedbackSize = 0) CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv = NULL, int feedbackSize = 0)
{ {
m_cipher = &cipher; m_cipher = &cipher;
ResizeBuffers(); ResizeBuffers();
@ -268,101 +268,101 @@ public:
} }
}; };
//! CFB mode //! CFB mode
template <class CIPHER> template <class CIPHER>
struct CFB_Mode : public CipherModeDocumentation struct CFB_Mode : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Encryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Encryption;
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Decryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Decryption;
}; };
//! CFB mode, external cipher //! CFB mode, external cipher
struct CFB_Mode_ExternalCipher : public CipherModeDocumentation struct CFB_Mode_ExternalCipher : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Encryption; typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Encryption;
typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Decryption; typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Decryption;
}; };
//! OFB mode //! OFB mode
template <class CIPHER> template <class CIPHER>
struct OFB_Mode : public CipherModeDocumentation struct OFB_Mode : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> > > > Encryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> > > > Encryption;
typedef Encryption Decryption; typedef Encryption Decryption;
}; };
//! OFB mode, external cipher //! OFB mode, external cipher
struct OFB_Mode_ExternalCipher : public CipherModeDocumentation struct OFB_Mode_ExternalCipher : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> > > > Encryption; typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> > > > Encryption;
typedef Encryption Decryption; typedef Encryption Decryption;
}; };
//! CTR mode //! CTR mode
template <class CIPHER> template <class CIPHER>
struct CTR_Mode : public CipherModeDocumentation struct CTR_Mode : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > > Encryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > > Encryption;
typedef Encryption Decryption; typedef Encryption Decryption;
}; };
//! CTR mode, external cipher //! CTR mode, external cipher
struct CTR_Mode_ExternalCipher : public CipherModeDocumentation struct CTR_Mode_ExternalCipher : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > > Encryption; typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > > Encryption;
typedef Encryption Decryption; typedef Encryption Decryption;
}; };
//! ECB mode //! ECB mode
template <class CIPHER> template <class CIPHER>
struct ECB_Mode : public CipherModeDocumentation struct ECB_Mode : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ECB_OneWay> Encryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, ECB_OneWay> Encryption;
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Decryption, ECB_OneWay> Decryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Decryption, ECB_OneWay> Decryption;
}; };
//! ECB mode, external cipher //! ECB mode, external cipher
struct ECB_Mode_ExternalCipher : public CipherModeDocumentation struct ECB_Mode_ExternalCipher : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_ExternalCipher<ECB_OneWay> Encryption; typedef CipherModeFinalTemplate_ExternalCipher<ECB_OneWay> Encryption;
typedef Encryption Decryption; typedef Encryption Decryption;
}; };
//! CBC mode //! CBC mode
template <class CIPHER> template <class CIPHER>
struct CBC_Mode : public CipherModeDocumentation struct CBC_Mode : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, CBC_Encryption> Encryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, CBC_Encryption> Encryption;
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Decryption, CBC_Decryption> Decryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Decryption, CBC_Decryption> Decryption;
}; };
//! CBC mode, external cipher //! CBC mode, external cipher
struct CBC_Mode_ExternalCipher : public CipherModeDocumentation struct CBC_Mode_ExternalCipher : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_ExternalCipher<CBC_Encryption> Encryption; typedef CipherModeFinalTemplate_ExternalCipher<CBC_Encryption> Encryption;
typedef CipherModeFinalTemplate_ExternalCipher<CBC_Decryption> Decryption; typedef CipherModeFinalTemplate_ExternalCipher<CBC_Decryption> Decryption;
}; };
//! CBC mode with ciphertext stealing //! CBC mode with ciphertext stealing
template <class CIPHER> template <class CIPHER>
struct CBC_CTS_Mode : public CipherModeDocumentation struct CBC_CTS_Mode : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, CBC_CTS_Encryption> Encryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Encryption, CBC_CTS_Encryption> Encryption;
typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Decryption, CBC_CTS_Decryption> Decryption; typedef CipherModeFinalTemplate_CipherHolder<CPP_TYPENAME CIPHER::Decryption, CBC_CTS_Decryption> Decryption;
}; };
//! CBC mode with ciphertext stealing, external cipher //! CBC mode with ciphertext stealing, external cipher
struct CBC_CTS_Mode_ExternalCipher : public CipherModeDocumentation struct CBC_CTS_Mode_ExternalCipher : public CipherModeDocumentation
{ {
typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Encryption> Encryption; typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Encryption> Encryption;
typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Decryption> Decryption; typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Decryption> Decryption;
}; };
#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY #ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
typedef CFB_Mode_ExternalCipher::Encryption CFBEncryption; typedef CFB_Mode_ExternalCipher::Encryption CFBEncryption;
typedef CFB_Mode_ExternalCipher::Decryption CFBDecryption; typedef CFB_Mode_ExternalCipher::Decryption CFBDecryption;
typedef OFB_Mode_ExternalCipher::Encryption OFB; typedef OFB_Mode_ExternalCipher::Encryption OFB;
typedef CTR_Mode_ExternalCipher::Encryption CounterMode; typedef CTR_Mode_ExternalCipher::Encryption CounterMode;
#endif #endif
NAMESPACE_END NAMESPACE_END