Fabcoin Core  0.16.2
P2P Digital Currency
modes.h
Go to the documentation of this file.
1 // modes.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_MODES_H
7 #define CRYPTOPP_MODES_H
8 
9 #include "cryptlib.h"
10 #include "secblock.h"
11 #include "misc.h"
12 #include "strciphr.h"
13 #include "argnames.h"
14 #include "algparam.h"
15 
16 // Issue 340
17 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
18 # pragma GCC diagnostic push
19 # pragma GCC diagnostic ignored "-Wconversion"
20 # pragma GCC diagnostic ignored "-Wsign-conversion"
21 #endif
22 
24 
38 {
39 };
40 
44 {
45 public:
46  virtual ~CipherModeBase() {}
47  size_t MinKeyLength() const {return m_cipher->MinKeyLength();}
48  size_t MaxKeyLength() const {return m_cipher->MaxKeyLength();}
49  size_t DefaultKeyLength() const {return m_cipher->DefaultKeyLength();}
50  size_t GetValidKeyLength(size_t n) const {return m_cipher->GetValidKeyLength(n);}
51  bool IsValidKeyLength(size_t n) const {return m_cipher->IsValidKeyLength(n);}
52 
53  unsigned int OptimalDataAlignment() const {return m_cipher->OptimalDataAlignment();}
54 
55  unsigned int IVSize() const {return BlockSize();}
56  virtual IV_Requirement IVRequirement() const =0;
57 
58  void SetCipher(BlockCipher &cipher)
59  {
61  this->m_cipher = &cipher;
62  this->ResizeBuffers();
63  }
64 
65  void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize = 0)
66  {
67  this->ThrowIfInvalidIV(iv);
68  this->m_cipher = &cipher;
69  this->ResizeBuffers();
70  this->SetFeedbackSize(feedbackSize);
71  if (this->IsResynchronizable())
72  this->Resynchronize(iv);
73  }
74 
75 protected:
76  CipherModeBase() : m_cipher(NULL) {}
77  inline unsigned int BlockSize() const {CRYPTOPP_ASSERT(m_register.size() > 0); return (unsigned int)m_register.size();}
78  virtual void SetFeedbackSize(unsigned int feedbackSize)
79  {
80  if (!(feedbackSize == 0 || feedbackSize == BlockSize()))
81  throw InvalidArgument("CipherModeBase: feedback size cannot be specified for this cipher mode");
82  }
83 
84  virtual void ResizeBuffers();
85 
88 };
89 
93 template <class POLICY_INTERFACE>
94 class CRYPTOPP_NO_VTABLE ModePolicyCommonTemplate : public CipherModeBase, public POLICY_INTERFACE
95 {
96  unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();}
97  void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
98 };
99 
100 template <class POLICY_INTERFACE>
102 {
103  m_cipher->SetKey(key, length, params);
104  ResizeBuffers();
105  int feedbackSize = params.GetIntValueWithDefault(Name::FeedbackSize(), 0);
106  SetFeedbackSize(feedbackSize);
107 }
108 
112 {
113 public:
115 
116  virtual ~CFB_ModePolicy() {}
117  IV_Requirement IVRequirement() const {return RANDOM_IV;}
118 
119 protected:
120  unsigned int GetBytesPerIteration() const {return m_feedbackSize;}
121  byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;}
122  bool CanIterate() const {return m_feedbackSize == BlockSize();}
123  void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
124  void TransformRegister();
125  void CipherResynchronize(const byte *iv, size_t length);
126  void SetFeedbackSize(unsigned int feedbackSize);
127  void ResizeBuffers();
128 
130  unsigned int m_feedbackSize;
131 };
132 
133 inline void CopyOrZero(void *dest, const void *src, size_t s)
134 {
135  if (src)
136  memcpy_s(dest, s, src, s);
137  else
138  memset(dest, 0, s);
139 }
140 
143 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
144 {
145 public:
147 
148  bool CipherIsRandomAccess() const {return false;}
149  IV_Requirement IVRequirement() const {return UNIQUE_IV;}
150 
151 private:
152  unsigned int GetBytesPerIteration() const {return BlockSize();}
153  unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();}
154  void WriteKeystream(byte *keystreamBuffer, size_t iterationCount);
155  void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
156 };
157 
160 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
161 {
162 public:
164 
165  virtual ~CTR_ModePolicy() {}
166  bool CipherIsRandomAccess() const {return true;}
167  IV_Requirement IVRequirement() const {return RANDOM_IV;}
168 
169 protected:
170  virtual void IncrementCounterBy256();
171  unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();}
172  unsigned int GetBytesPerIteration() const {return BlockSize();}
173  unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();}
174  void WriteKeystream(byte *buffer, size_t iterationCount)
175  {OperateKeystream(WRITE_KEYSTREAM, buffer, NULL, iterationCount);}
176  bool CanOperateKeystream() const {return true;}
177  void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
178  void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
179  void SeekToIteration(lword iterationCount);
180 
182 };
183 
187 {
188 public:
190  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
191  unsigned int MandatoryBlockSize() const {return BlockSize();}
192  bool IsRandomAccess() const {return false;}
193  bool IsSelfInverting() const {return false;}
194  bool IsForwardTransformation() const {return m_cipher->IsForwardTransformation();}
195  void Resynchronize(const byte *iv, int length=-1) {memcpy_s(m_register, m_register.size(), iv, ThrowIfInvalidIVLength(length));}
196 
197 protected:
198  bool RequireAlignedInput() const {return true;}
199  virtual void ResizeBuffers();
200 
202 };
203 
207 {
208 public:
210 
211  void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs)
212  {m_cipher->SetKey(key, length, params); BlockOrientedCipherModeBase::ResizeBuffers();}
213  IV_Requirement IVRequirement() const {return NOT_RESYNCHRONIZABLE;}
214  unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();}
215  void ProcessData(byte *outString, const byte *inString, size_t length);
216 };
217 
221 {
222 public:
224 
225  IV_Requirement IVRequirement() const {return UNPREDICTABLE_RANDOM_IV;}
226  bool RequireAlignedInput() const {return false;}
227  unsigned int MinLastBlockSize() const {return 0;}
228 };
229 
233 {
234 public:
235  void ProcessData(byte *outString, const byte *inString, size_t length);
236 };
237 
241 {
242 public:
244 
245  void SetStolenIV(byte *iv) {m_stolenIV = iv;}
246  unsigned int MinLastBlockSize() const {return BlockSize()+1;}
247  void ProcessLastBlock(byte *outString, const byte *inString, size_t length);
248 
249 protected:
250  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
251  {
252  CBC_Encryption::UncheckedSetKey(key, length, params);
253  m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULL);
254  }
255 
257 };
258 
262 {
263 public:
264  virtual ~CBC_Decryption() {}
265  void ProcessData(byte *outString, const byte *inString, size_t length);
266 
267 protected:
268  virtual void ResizeBuffers();
269 
271 };
272 
276 {
277 public:
278  unsigned int MinLastBlockSize() const {return BlockSize()+1;}
279  void ProcessLastBlock(byte *outString, const byte *inString, size_t length);
280 };
281 
284 template <class CIPHER, class BASE>
285 class CipherModeFinalTemplate_CipherHolder : protected ObjectHolder<CIPHER>, public AlgorithmImpl<BASE, CipherModeFinalTemplate_CipherHolder<CIPHER, BASE> >
286 {
287 public:
288  static std::string CRYPTOPP_API StaticAlgorithmName()
289  {return CIPHER::StaticAlgorithmName() + "/" + BASE::StaticAlgorithmName();}
290 
292  {
293  this->m_cipher = &this->m_object;
294  this->ResizeBuffers();
295  }
296  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length)
297  {
298  this->m_cipher = &this->m_object;
299  this->SetKey(key, length);
300  }
301  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv)
302  {
303  this->m_cipher = &this->m_object;
304  this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize())));
305  }
306  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv, int feedbackSize)
307  {
308  this->m_cipher = &this->m_object;
309  this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize()))(Name::FeedbackSize(), feedbackSize));
310  }
311 };
312 
316 template <class BASE>
318 {
319 public:
322  {this->SetCipher(cipher);}
323  CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0)
324  {this->SetCipherWithIV(cipher, iv, feedbackSize);}
325 
326  std::string AlgorithmName() const
327  {return (this->m_cipher ? this->m_cipher->AlgorithmName() + "/" : std::string("")) + BASE::StaticAlgorithmName();}
328 };
329 
333 
336 template <class CIPHER>
338 {
341 };
342 
346 {
349 };
350 
354 template <class CIPHER>
356 {
359 };
360 
365 {
368 };
369 
371 
374 template <class CIPHER>
376 {
378  typedef Encryption Decryption;
379 };
380 
384 {
386  typedef Encryption Decryption;
387 };
388 
391 
394 template <class CIPHER>
396 {
398  typedef Encryption Decryption;
399 };
400 
404 {
406  typedef Encryption Decryption;
407 };
408 
411 template <class CIPHER>
413 {
416 };
417 
419 
423 {
425  typedef Encryption Decryption;
426 };
427 
429 template <class CIPHER>
431 {
434 };
435 
438 
441 {
444 };
445 
447 template <class CIPHER>
449 {
452 };
453 
456 
460 {
463 };
464 
465 //#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
466 //typedef CFB_Mode_ExternalCipher::Encryption CFBEncryption;
467 //typedef CFB_Mode_ExternalCipher::Decryption CFBDecryption;
468 //typedef OFB_Mode_ExternalCipher::Encryption OFB;
469 //typedef CTR_Mode_ExternalCipher::Encryption CounterMode;
470 //#endif
471 
473 
474 // Issue 340
475 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
476 # pragma GCC diagnostic pop
477 #endif
478 
479 #endif
bool IsSelfInverting() const
Determines whether the cipher is self-inverting.
Definition: modes.h:193
Used to pass byte array input as part of a NameValuePairs object.
Definition: algparam.h:29
CipherModeFinalTemplate_ExternalCipher< CBC_CTS_Encryption > Encryption
Definition: modes.h:461
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, ConcretePolicyHolder< Empty, CFB_RequireFullDataBlocks< CFB_DecryptionTemplate< AbstractPolicyHolder< CFB_CipherAbstractPolicy, CFB_ModePolicy > > > > > Decryption
Definition: modes.h:358
Standard names for retrieving values by name when working with NameValuePairs.
An invalid argument was detected.
Definition: cryptlib.h:184
BlockCipher * m_cipher
Definition: modes.h:86
CipherModeFinalTemplate_ExternalCipher< ConcretePolicyHolder< Empty, CFB_RequireFullDataBlocks< CFB_EncryptionTemplate< AbstractPolicyHolder< CFB_CipherAbstractPolicy, CFB_ModePolicy > > > > > Encryption
Definition: modes.h:366
void Resynchronize(const byte *iv, int length=-1)
Resynchronize with an IV.
Definition: modes.h:195
Classes for working with NameValuePairs.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
Definition: modes.h:50
uint8_t byte
Definition: Common.h:57
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Decryption, ECB_OneWay > Decryption
Definition: modes.h:415
Utility functions for the Crypto++ library.
#define CRYPTOPP_STATIC_CONSTEXPR
Definition: config.h:892
virtual ~BlockOrientedCipherModeBase()
Definition: modes.h:189
CFB mode, external cipher, providing FIPS validated cryptography.
Definition: modes.h:364
void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize=0)
Definition: modes.h:65
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:117
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
Definition: cryptlib.h:350
bool IsRandomAccess() const
Determines whether the cipher supports random access.
Definition: modes.h:192
virtual void SetFeedbackSize(unsigned int feedbackSize)
Definition: modes.h:78
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: modes.h:146
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: modes.h:209
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, ConcretePolicyHolder< Empty, CFB_DecryptionTemplate< AbstractPolicyHolder< CFB_CipherAbstractPolicy, CFB_ModePolicy > > > > Decryption
Definition: modes.h:340
virtual ~CipherModeBase()
Definition: modes.h:46
void ThrowIfInvalidIV(const byte *iv)
Validates the IV.
Definition: cryptlib.cpp:125
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, CBC_Encryption > Encryption
Definition: modes.h:432
SecByteBlock m_buffer
Definition: modes.h:201
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize=0)
Definition: modes.h:323
#define CRYPTOPP_DLL_TEMPLATE_CLASS
Definition: config.h:720
bool CanIterate() const
Flag indicating iteration support.
Definition: modes.h:122
void CopyOrZero(void *dest, const void *src, size_t s)
Definition: modes.h:133
CipherDir
Specifies a direction for a cipher to operate.
Definition: cryptlib.h:104
size_t MinKeyLength() const
Returns smallest valid key length.
Definition: modes.h:47
Abstract base classes that provide a uniform interface to this library.
void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t count)
Bounds checking replacement for memcpy()
Definition: misc.h:366
void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length)
Definition: modes.h:101
Base class for feedback based stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:489
virtual void ResizeBuffers()
Definition: modes.cpp:163
unsigned int GetBytesPerIteration() const
Provides number of bytes operated upon during an iteration.
Definition: modes.h:152
CipherModeFinalTemplate_ExternalCipher< ConcretePolicyHolder< Empty, AdditiveCipherTemplate< AbstractPolicyHolder< AdditiveCipherAbstractPolicy, OFB_ModePolicy > > > > Encryption
Definition: modes.h:385
Wirte the keystream to the output buffer, input is NULL.
Definition: strciphr.h:92
CipherModeFinalTemplate_ExternalCipher< ConcretePolicyHolder< Empty, CFB_EncryptionTemplate< AbstractPolicyHolder< CFB_CipherAbstractPolicy, CFB_ModePolicy > > > > Encryption
Definition: modes.h:347
CBC mode with ciphertext stealing.
Definition: modes.h:448
CipherModeFinalTemplate_ExternalCipher< CBC_CTS_Decryption > Decryption
Definition: modes.h:462
CTR block cipher mode of operation.
Definition: modes.h:395
virtual ~CFB_ModePolicy()
Definition: modes.h:116
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, ConcretePolicyHolder< Empty, AdditiveCipherTemplate< AbstractPolicyHolder< AdditiveCipherAbstractPolicy, OFB_ModePolicy > > > > Encryption
Definition: modes.h:377
CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length)
Definition: modes.h:296
unsigned int GetAlignment() const
Provides data alignment requirements.
Definition: modes.h:171
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:167
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1095
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, ECB_OneWay > Encryption
Definition: modes.h:414
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Decryption, CBC_Decryption > Decryption
Definition: modes.h:433
unsigned int GetAlignment() const
Definition: modes.h:96
OFB block cipher mode of operation.
Definition: modes.h:143
CBC-CTS block cipher mode of operation decryption operation.
Definition: modes.h:275
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, ConcretePolicyHolder< Empty, AdditiveCipherTemplate< AbstractPolicyHolder< AdditiveCipherAbstractPolicy, CTR_ModePolicy > > > > Encryption
Definition: modes.h:397
Classes and functions for secure memory allocations.
Encryption Decryption
Definition: modes.h:398
virtual ~CBC_Decryption()
Definition: modes.h:264
ECB block cipher mode of operation.
Definition: modes.h:412
bool RequireAlignedInput() const
Definition: modes.h:226
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: modes.h:194
CipherModeFinalTemplate_ExternalCipher< ECB_OneWay > Encryption
Definition: modes.h:424
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:149
Base class for feedback based stream ciphers in the reverse direction with SymmetricCipher interface...
Definition: strciphr.h:562
Uses encapsulation to hide an object in derived classes.
Definition: misc.h:205
void SetCipher(BlockCipher &cipher)
Definition: modes.h:58
byte * GetRegisterBegin()
Access the feedback register.
Definition: modes.h:121
CBC-CTS block cipher mode of operation encryption operation.
Definition: modes.h:240
unsigned int GetBytesPerIteration() const
Provides number of bytes operated upon during an iteration.
Definition: modes.h:120
virtual IV_Requirement IVRequirement() const =0
Minimal requirement for secure IVs.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
Definition: modes.h:55
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
Sets the key for this object without performing parameter validation.
Definition: modes.h:250
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition: algparam.h:498
unsigned int GetIterationsToBuffer() const
Provides buffer size based on iterations.
Definition: modes.h:173
Block cipher mode of operation aggregate.
Definition: modes.h:285
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, CBC_CTS_Encryption > Encryption
Definition: modes.h:450
CFB mode, external cipher.
Definition: modes.h:345
CBC block cipher mode of operation default implementation.
Definition: modes.h:220
bool IsResynchronizable() const
Determines if the object can be resynchronized.
Definition: cryptlib.h:619
std::string AlgorithmName() const
Definition: modes.h:326
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Definition: cryptlib.h:382
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition: modes.h:53
virtual void Resynchronize(const byte *iv, int ivLength=-1)
Resynchronize with an IV.
Definition: cryptlib.h:662
size_t DefaultKeyLength() const
Returns default key length.
Definition: modes.h:49
void SetKey(const byte *key, size_t length, const NameValuePairs &params=g_nullNameValuePairs)
Sets or reset the key of this object.
Definition: modes.h:211
Block cipher mode of operation information.
Definition: modes.h:37
CipherModeFinalTemplate_ExternalCipher< ConcretePolicyHolder< Empty, CFB_DecryptionTemplate< AbstractPolicyHolder< CFB_CipherAbstractPolicy, CFB_ModePolicy > > > > Decryption
Definition: modes.h:348
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Definition: cryptlib.h:1103
void ThrowIfResynchronizable()
Validates the object.
Definition: cryptlib.cpp:119
Block cipher mode of operation default implementation.
Definition: modes.h:186
Encryption Decryption
Definition: modes.h:378
ECB mode, external cipher.
Definition: modes.h:422
static std::string CRYPTOPP_API StaticAlgorithmName()
Definition: modes.h:288
Encryption Decryption
Definition: modes.h:406
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: modes.h:114
#define CRYPTOPP_API
Definition: config.h:705
bool CanOperateKeystream() const
Flag indicating.
Definition: modes.h:176
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:246
unsigned int OptimalBlockSize() const
Provides the input block size most efficient for this cipher.
Definition: modes.h:214
Base class for feedback based stream ciphers in the forward direction with SymmetricCipher interface...
Definition: strciphr.h:552
OFB block cipher mode of operation.
Definition: modes.h:375
size_t MaxKeyLength() const
Returns largest valid key length.
Definition: modes.h:48
CBC mode, external cipher.
Definition: modes.h:440
CipherModeFinalTemplate_ExternalCipher< ConcretePolicyHolder< Empty, CFB_RequireFullDataBlocks< CFB_DecryptionTemplate< AbstractPolicyHolder< CFB_CipherAbstractPolicy, CFB_ModePolicy > > > > > Decryption
Definition: modes.h:367
unsigned int GetBytesPerIteration() const
Provides number of bytes operated upon during an iteration.
Definition: modes.h:172
#define CRYPTOPP_ASSERT(exp)
Definition: trap.h:92
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
Definition: cryptlib.cpp:76
CipherModeFinalTemplate_ExternalCipher< CBC_Encryption > Encryption
Definition: modes.h:442
CFB block cipher mode of operation.
Definition: modes.h:337
CTR block cipher mode of operation.
Definition: modes.h:160
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: modes.h:243
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
Definition: modes.h:51
OFB mode, external cipher.
Definition: modes.h:383
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, ConcretePolicyHolder< Empty, CFB_RequireFullDataBlocks< CFB_EncryptionTemplate< AbstractPolicyHolder< CFB_CipherAbstractPolicy, CFB_ModePolicy > > > > > Encryption
Definition: modes.h:357
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv)
Definition: modes.h:301
byte * m_stolenIV
Definition: modes.h:256
Classes for implementing stream ciphers.
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher...
Definition: seckey.h:424
CipherModeBase()
Definition: modes.h:76
AlignedSecByteBlock m_register
Definition: modes.h:87
void WriteKeystream(byte *buffer, size_t iterationCount)
Generate the keystream.
Definition: modes.h:174
IV_Requirement
Secure IVs requirements as enumerated values.
Definition: cryptlib.h:598
unsigned int m_feedbackSize
Definition: modes.h:130
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition: modes.h:166
void SetStolenIV(byte *iv)
Definition: modes.h:245
Block cipher mode of operation information.
Definition: modes.h:43
CBC block cipher mode of operation decryption operation.
Definition: modes.h:261
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Decryption, CBC_CTS_Decryption > Decryption
Definition: modes.h:451
CTR mode, external cipher.
Definition: modes.h:403
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:278
CBC block cipher mode of operation encryption operation.
Definition: modes.h:232
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
Sets the key for this object without performing parameter validation.
Definition: modes.cpp:151
CipherModeFinalTemplate_CipherHolder< typename CIPHER::Encryption, ConcretePolicyHolder< Empty, CFB_EncryptionTemplate< AbstractPolicyHolder< CFB_CipherAbstractPolicy, CFB_ModePolicy > > > > Encryption
Definition: modes.h:339
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:225
AlignedSecByteBlock m_temp
Definition: modes.h:270
Block cipher mode of operation common operations.
Definition: modes.h:94
#define NAMESPACE_END
Definition: config.h:201
KeystreamOperation
Keystream operation flags.
Definition: strciphr.h:90
bool RequireAlignedInput() const
Definition: modes.h:198
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition: modes.h:148
unsigned int MandatoryBlockSize() const
Provides the mandatory block size of the cipher.
Definition: modes.h:191
unsigned int GetIterationsToBuffer() const
Provides buffer size based on iterations.
Definition: modes.h:153
word64 lword
Definition: config.h:245
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:227
SecByteBlock m_temp
Definition: modes.h:129
virtual ~CTR_ModePolicy()
Definition: modes.h:165
CFB block cipher mode of operation.
Definition: modes.h:111
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: modes.h:163
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:213
#define CRYPTOPP_DLL
Definition: config.h:704
CipherModeFinalTemplate_ExternalCipher< CBC_Decryption > Decryption
Definition: modes.h:443
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: modes.h:223
Base class for additive stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:267
CipherModeFinalTemplate_ExternalCipher< ConcretePolicyHolder< Empty, AdditiveCipherTemplate< AbstractPolicyHolder< AdditiveCipherAbstractPolicy, CTR_ModePolicy > > > > Encryption
Definition: modes.h:405
CFB block cipher mode of operation providing FIPS validated cryptography.
Definition: modes.h:355
Encryption Decryption
Definition: modes.h:386
unsigned int BlockSize() const
Definition: modes.h:77
AlignedSecByteBlock m_counterArray
Definition: modes.h:181
ECB block cipher mode of operation default implementation.
Definition: modes.h:206
CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher)
Definition: modes.h:321
Interface for retrieving values given their names.
Definition: cryptlib.h:279
CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv, int feedbackSize)
Definition: modes.h:306
CBC mode.
Definition: modes.h:430
CBC mode with ciphertext stealing, external cipher.
Definition: modes.h:459
Base class for identifying alogorithm.
Definition: simple.h:38
Encryption Decryption
Definition: modes.h:425