Crypto++  7.0
Free C++ class library of cryptographic schemes
modes.h
Go to the documentation of this file.
1 // modes.h - originally written and placed in the public domain by Wei Dai
2 
3 /// \file modes.h
4 /// \brief Classes for block cipher modes of operation
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 
23 #if CRYPTOPP_MSC_VERSION
24 # pragma warning(push)
25 # pragma warning(disable: 4231 4275)
26 # if (CRYPTOPP_MSC_VERSION >= 1400)
27 # pragma warning(disable: 6011 6386 28193)
28 # endif
29 #endif
30 
31 NAMESPACE_BEGIN(CryptoPP)
32 
33 /// \brief Block cipher mode of operation information
34 /// \details Each class derived from this one defines two types, Encryption and Decryption,
35 /// both of which implement the SymmetricCipher interface.
36 /// For each mode there are two classes, one of which is a template class,
37 /// and the other one has a name that ends in "_ExternalCipher".
38 /// The "external cipher" mode objects hold a reference to the underlying block cipher,
39 /// instead of holding an instance of it. The reference must be passed in to the constructor.
40 /// For the "cipher holder" classes, the CIPHER template parameter should be a class
41 /// derived from BlockCipherDocumentation, for example DES or AES.
42 /// \details See NIST SP 800-38A for definitions of these modes. See
43 /// AuthenticatedSymmetricCipherDocumentation for authenticated encryption modes.
45 {
46 };
47 
48 /// \brief Block cipher mode of operation information
49 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CipherModeBase : public SymmetricCipher
50 {
51 public:
52  virtual ~CipherModeBase() {}
53  size_t MinKeyLength() const {return m_cipher->MinKeyLength();}
54  size_t MaxKeyLength() const {return m_cipher->MaxKeyLength();}
55  size_t DefaultKeyLength() const {return m_cipher->DefaultKeyLength();}
56  size_t GetValidKeyLength(size_t n) const {return m_cipher->GetValidKeyLength(n);}
57  bool IsValidKeyLength(size_t n) const {return m_cipher->IsValidKeyLength(n);}
58 
59  unsigned int OptimalDataAlignment() const {return m_cipher->OptimalDataAlignment();}
60 
61  unsigned int IVSize() const {return BlockSize();}
62  virtual IV_Requirement IVRequirement() const =0;
63 
64  void SetCipher(BlockCipher &cipher)
65  {
66  this->ThrowIfResynchronizable();
67  this->m_cipher = &cipher;
68  this->ResizeBuffers();
69  }
70 
71  void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize = 0)
72  {
73  this->ThrowIfInvalidIV(iv);
74  this->m_cipher = &cipher;
75  this->ResizeBuffers();
76  this->SetFeedbackSize(feedbackSize);
77  if (this->IsResynchronizable())
78  this->Resynchronize(iv);
79  }
80 
81 protected:
82  CipherModeBase() : m_cipher(NULLPTR) {}
83  inline unsigned int BlockSize() const {CRYPTOPP_ASSERT(m_register.size() > 0); return (unsigned int)m_register.size();}
84  virtual void SetFeedbackSize(unsigned int feedbackSize)
85  {
86  if (!(feedbackSize == 0 || feedbackSize == BlockSize()))
87  throw InvalidArgument("CipherModeBase: feedback size cannot be specified for this cipher mode");
88  }
89 
90  virtual void ResizeBuffers();
91 
92  BlockCipher *m_cipher;
93  AlignedSecByteBlock m_register;
94 };
95 
96 /// \brief Block cipher mode of operation common operations
97 /// \tparam POLICY_INTERFACE common operations
98 template <class POLICY_INTERFACE>
99 class CRYPTOPP_NO_VTABLE ModePolicyCommonTemplate : public CipherModeBase, public POLICY_INTERFACE
100 {
101  unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();}
102  void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
103 };
104 
105 template <class POLICY_INTERFACE>
106 void ModePolicyCommonTemplate<POLICY_INTERFACE>::CipherSetKey(const NameValuePairs &params, const byte *key, size_t length)
107 {
108  m_cipher->SetKey(key, length, params);
109  ResizeBuffers();
110  int feedbackSize = params.GetIntValueWithDefault(Name::FeedbackSize(), 0);
111  SetFeedbackSize(feedbackSize);
112 }
113 
114 /// \brief CFB block cipher mode of operation
115 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CFB_ModePolicy : public ModePolicyCommonTemplate<CFB_CipherAbstractPolicy>
116 {
117 public:
118  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CFB";}
119 
120  virtual ~CFB_ModePolicy() {}
121  IV_Requirement IVRequirement() const {return RANDOM_IV;}
122 
123 protected:
124  unsigned int GetBytesPerIteration() const {return m_feedbackSize;}
125  byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;}
126  bool CanIterate() const {return m_feedbackSize == BlockSize();}
127  void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
128  void TransformRegister();
129  void CipherResynchronize(const byte *iv, size_t length);
130  void SetFeedbackSize(unsigned int feedbackSize);
131  void ResizeBuffers();
132 
133  SecByteBlock m_temp;
134  unsigned int m_feedbackSize;
135 };
136 
137 inline void CopyOrZero(void *dest, size_t d, const void *src, size_t s)
138 {
139  CRYPTOPP_ASSERT(dest);
140  CRYPTOPP_ASSERT(d >= s);
141 
142  if (src)
143  memcpy_s(dest, d, src, s);
144  else
145  memset(dest, 0, d);
146 }
147 
148 /// \brief OFB block cipher mode of operation
149 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
150 {
151 public:
152  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "OFB";}
153 
154  bool CipherIsRandomAccess() const {return false;}
155  IV_Requirement IVRequirement() const {return UNIQUE_IV;}
156 
157 private:
158  unsigned int GetBytesPerIteration() const {return BlockSize();}
159  unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();}
160  void WriteKeystream(byte *keystreamBuffer, size_t iterationCount);
161  void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
162 };
163 
164 /// \brief CTR block cipher mode of operation
165 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
166 {
167 public:
168  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CTR";}
169 
170  virtual ~CTR_ModePolicy() {}
171  bool CipherIsRandomAccess() const {return true;}
172  IV_Requirement IVRequirement() const {return RANDOM_IV;}
173 
174 protected:
175  virtual void IncrementCounterBy256();
176  unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();}
177  unsigned int GetBytesPerIteration() const {return BlockSize();}
178  unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();}
179  void WriteKeystream(byte *buffer, size_t iterationCount)
180  {OperateKeystream(WRITE_KEYSTREAM, buffer, NULLPTR, iterationCount);}
181  bool CanOperateKeystream() const {return true;}
182  void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
183  void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
184  void SeekToIteration(lword iterationCount);
185 
186  AlignedSecByteBlock m_counterArray;
187 };
188 
189 /// \brief Block cipher mode of operation default implementation
190 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockOrientedCipherModeBase : public CipherModeBase
191 {
192 public:
193  virtual ~BlockOrientedCipherModeBase() {}
194  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
195  unsigned int MandatoryBlockSize() const {return BlockSize();}
196  bool IsRandomAccess() const {return false;}
197  bool IsSelfInverting() const {return false;}
198  bool IsForwardTransformation() const {return m_cipher->IsForwardTransformation();}
199  void Resynchronize(const byte *iv, int length=-1) {memcpy_s(m_register, m_register.size(), iv, ThrowIfInvalidIVLength(length));}
200 
201 protected:
202  bool RequireAlignedInput() const {return true;}
203  virtual void ResizeBuffers();
204 
205  SecByteBlock m_buffer;
206 };
207 
208 /// \brief ECB block cipher mode of operation default implementation
209 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : public BlockOrientedCipherModeBase
210 {
211 public:
212  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "ECB";}
213 
214  void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs)
215  {m_cipher->SetKey(key, length, params); BlockOrientedCipherModeBase::ResizeBuffers();}
216  IV_Requirement IVRequirement() const {return NOT_RESYNCHRONIZABLE;}
217  unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();}
218  void ProcessData(byte *outString, const byte *inString, size_t length);
219 };
220 
221 /// \brief CBC block cipher mode of operation default implementation
222 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_ModeBase : public BlockOrientedCipherModeBase
223 {
224 public:
225  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CBC";}
226 
227  IV_Requirement IVRequirement() const {return UNPREDICTABLE_RANDOM_IV;}
228  bool RequireAlignedInput() const {return false;}
229  unsigned int MinLastBlockSize() const {return 0;}
230 };
231 
232 /// \brief CBC block cipher mode of operation encryption operation
233 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Encryption : public CBC_ModeBase
234 {
235 public:
236  void ProcessData(byte *outString, const byte *inString, size_t length);
237 };
238 
239 /// \brief CBC-CTS block cipher mode of operation encryption operation
240 /// \since Crypto++ 3.0
241 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Encryption : public CBC_Encryption
242 {
243 public:
244  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CBC/CTS";}
245 
246  void SetStolenIV(byte *iv) {m_stolenIV = iv;}
247  unsigned int MinLastBlockSize() const {return BlockSize()+1;}
248  size_t ProcessLastBlock(byte *outString, size_t outLength, const byte *inString, size_t inLength);
249 
250 protected:
251  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
252  {
253  CBC_Encryption::UncheckedSetKey(key, length, params);
254  m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULLPTR);
255  }
256 
257  byte *m_stolenIV;
258 };
259 
260 /// \brief CBC block cipher mode of operation decryption operation
261 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Decryption : public CBC_ModeBase
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 
270  AlignedSecByteBlock m_temp;
271 };
272 
273 /// \brief CBC-CTS block cipher mode of operation decryption operation
274 /// \since Crypto++ 3.0
275 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Decryption : public CBC_Decryption
276 {
277 public:
278  unsigned int MinLastBlockSize() const {return BlockSize()+1;}
279  size_t ProcessLastBlock(byte *outString, size_t outLength, const byte *inString, size_t inLength);
280 };
281 
282 /// \brief Block cipher mode of operation aggregate
283 template <class CIPHER, class BASE>
284 class CipherModeFinalTemplate_CipherHolder : protected ObjectHolder<CIPHER>, public AlgorithmImpl<BASE, CipherModeFinalTemplate_CipherHolder<CIPHER, BASE> >
285 {
286 public:
287  static std::string CRYPTOPP_API StaticAlgorithmName()
288  {return CIPHER::StaticAlgorithmName() + "/" + BASE::StaticAlgorithmName();}
289 
291  {
292  this->m_cipher = &this->m_object;
293  this->ResizeBuffers();
294  }
295  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length)
296  {
297  this->m_cipher = &this->m_object;
298  this->SetKey(key, length);
299  }
300  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv)
301  {
302  this->m_cipher = &this->m_object;
303  this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize())));
304  }
305  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv, int feedbackSize)
306  {
307  this->m_cipher = &this->m_object;
308  this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize()))(Name::FeedbackSize(), feedbackSize));
309  }
310 };
311 
312 /// \tparam BASE CipherModeFinalTemplate_CipherHolder base class
313 /// \details Base class for external mode cipher combinations
314 template <class BASE>
316 {
317 public:
320  {this->SetCipher(cipher);}
321  CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0)
322  {this->SetCipherWithIV(cipher, iv, feedbackSize);}
323 
324  std::string AlgorithmName() const
325  {return (this->m_cipher ? this->m_cipher->AlgorithmName() + "/" : std::string("")) + BASE::StaticAlgorithmName();}
326 };
327 
331 
332 /// \brief CFB block cipher mode of operation
333 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
334 /// on the Crypto++ wiki.
335 template <class CIPHER>
337 {
340 };
341 
342 /// \brief CFB mode, external cipher.
343 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
344 /// on the Crypto++ wiki.
346 {
349 };
350 
351 /// \brief CFB block cipher mode of operation providing FIPS validated cryptography.
352 /// \details Requires full block plaintext according to FIPS 800-38A
353 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
354 /// on the Crypto++ wiki.
355 template <class CIPHER>
357 {
360 };
361 
362 /// \brief CFB mode, external cipher, providing FIPS validated cryptography.
363 /// \details Requires full block plaintext according to FIPS 800-38A
364 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
365 /// on the Crypto++ wiki.
367 {
370 };
371 
373 
374 /// \brief OFB block cipher mode of operation
375 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
376 /// on the Crypto++ wiki.
377 template <class CIPHER>
379 {
381  typedef Encryption Decryption;
382 };
383 
384 /// \brief OFB mode, external cipher.
385 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
386 /// on the Crypto++ wiki.
388 {
390  typedef Encryption Decryption;
391 };
392 
395 
396 /// \brief CTR block cipher mode of operation
397 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
398 /// on the Crypto++ wiki.
399 template <class CIPHER>
401 {
403  typedef Encryption Decryption;
404 };
405 
406 /// \brief CTR mode, external cipher.
407 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
408 /// on the Crypto++ wiki.
410 {
412  typedef Encryption Decryption;
413 };
414 
415 /// \brief ECB block cipher mode of operation
416 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
417 /// on the Crypto++ wiki.
418 template <class CIPHER>
420 {
423 };
424 
425 CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<ECB_OneWay>;
426 
427 /// \brief ECB mode, external cipher.
428 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
429 /// on the Crypto++ wiki.
431 {
433  typedef Encryption Decryption;
434 };
435 
436 /// \brief CBC block cipher mode of operation
437 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
438 /// on the Crypto++ wiki.
439 template <class CIPHER>
441 {
444 };
445 
448 
449 /// \brief CBC mode, external cipher
450 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
451 /// on the Crypto++ wiki.
453 {
456 };
457 
458 /// \brief CBC-CTS block cipher mode of operation
459 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
460 /// on the Crypto++ wiki.
461 /// \since Crypto++ 3.0
462 template <class CIPHER>
464 {
467 };
468 
471 
472 /// \brief CBC mode with ciphertext stealing, external cipher
473 /// \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A>
474 /// on the Crypto++ wiki.
475 /// \since Crypto++ 3.0
477 {
480 };
481 
482 NAMESPACE_END
483 
484 // Issue 340
485 #if CRYPTOPP_MSC_VERSION
486 # pragma warning(pop)
487 #endif
488 
489 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE
490 # pragma GCC diagnostic pop
491 #endif
492 
493 #endif
Used to pass byte array input as part of a NameValuePairs object.
Definition: algparam.h:20
int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Definition: cryptlib.h:392
Standard names for retrieving values by name when working with NameValuePairs.
An invalid argument was detected.
Definition: cryptlib.h:199
const char * FeedbackSize()
int
Definition: argnames.h:25
void Resynchronize(const byte *iv, int length=-1)
Resynchronize with an IV.
Definition: modes.h:199
Classes for working with NameValuePairs.
Utility functions for the Crypto++ library.
virtual void SetKey(const byte *key, size_t length, const NameValuePairs &params=g_nullNameValuePairs)
Sets or reset the key of this object.
Definition: cryptlib.cpp:64
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
Definition: modes.h:56
CFB mode, external cipher, providing FIPS validated cryptography.
Definition: modes.h:366
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: modes.h:198
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
Definition: cryptlib.h:360
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:172
CipherDir
Specifies a direction for a cipher to operate.
Definition: cryptlib.h:120
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:383
Base class for feedback based stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:480
Wirte the keystream to the output buffer, input is NULL.
Definition: strciphr.h:90
SecBlock<byte> typedef.
Definition: secblock.h:822
CBC-CTS block cipher mode of operation.
Definition: modes.h:463
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition: modes.h:171
size_t MinKeyLength() const
Returns smallest valid key length.
Definition: modes.h:53
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
Definition: modes.h:57
CTR block cipher mode of operation.
Definition: modes.h:400
unsigned int OptimalBlockSize() const
Provides the input block size most efficient for this cipher.
Definition: modes.h:217
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1229
const char * StolenIV()
byte *
Definition: argnames.h:22
OFB block cipher mode of operation.
Definition: modes.h:149
CBC-CTS block cipher mode of operation decryption operation.
Definition: modes.h:275
size_t MaxKeyLength() const
Returns largest valid key length.
Definition: modes.h:54
Classes and functions for secure memory allocations.
ECB block cipher mode of operation.
Definition: modes.h:419
Base class for feedback based stream ciphers in the reverse direction with SymmetricCipher interface...
Definition: strciphr.h:551
Uses encapsulation to hide an object in derived classes.
Definition: misc.h:217
CBC-CTS block cipher mode of operation encryption operation.
Definition: modes.h:241
virtual IV_Requirement IVRequirement() const =0
Minimal requirement for secure IVs.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition: algparam.h:502
Block cipher mode of operation aggregate.
Definition: modes.h:284
CFB mode, external cipher.
Definition: modes.h:345
CBC block cipher mode of operation default implementation.
Definition: modes.h:222
bool IsSelfInverting() const
Determines whether the cipher is self-inverting.
Definition: modes.h:197
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:278
virtual void Resynchronize(const byte *iv, int ivLength=-1)
Resynchronize with an IV.
Definition: cryptlib.h:736
void SetKey(const byte *key, size_t length, const NameValuePairs &params=g_nullNameValuePairs)
Sets or reset the key of this object.
Definition: modes.h:214
Block cipher mode of operation information.
Definition: modes.h:44
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Definition: cryptlib.h:1237
unsigned int MandatoryBlockSize() const
Provides the mandatory block size of the cipher.
Definition: modes.h:195
Block cipher mode of operation default implementation.
Definition: modes.h:190
ECB mode, external cipher.
Definition: modes.h:430
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:247
size_t DefaultKeyLength() const
Returns default key length.
Definition: modes.h:55
SecBlock using AllocatorWithCleanup<byte, true> typedef.
Definition: secblock.h:826
Base class for feedback based stream ciphers in the forward direction with SymmetricCipher interface...
Definition: strciphr.h:542
OFB block cipher mode of operation.
Definition: modes.h:378
CBC mode, external cipher.
Definition: modes.h:452
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
Definition: trap.h:60
const char * BlockSize()
int, in bytes
Definition: argnames.h:27
CFB block cipher mode of operation.
Definition: modes.h:336
CTR block cipher mode of operation.
Definition: modes.h:165
OFB mode, external cipher.
Definition: modes.h:387
const char * IV()
ConstByteArrayParameter, also accepts const byte * for backwards compatibility.
Definition: argnames.h:21
Classes for implementing stream ciphers.
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher...
Definition: seckey.h:435
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition: modes.h:59
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:121
const NameValuePairs g_nullNameValuePairs
An empty set of name-value pairs.
Definition: cryptlib.h:494
IV_Requirement
Secure IVs requirements as enumerated values.
Definition: cryptlib.h:672
Block cipher mode of operation information.
Definition: modes.h:49
CBC block cipher mode of operation decryption operation.
Definition: modes.h:261
CTR mode, external cipher.
Definition: modes.h:409
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:229
CBC block cipher mode of operation encryption operation.
Definition: modes.h:233
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
Block cipher mode of operation common operations.
Definition: modes.h:99
KeystreamOperation
Keystream operation flags.
Definition: strciphr.h:88
Crypto++ library namespace.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:216
unsigned int IVSize() const
Returns length of the IV accepted by this object.
Definition: modes.h:61
bool IsResynchronizable() const
Determines if the object can be resynchronized.
Definition: cryptlib.h:693
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition: modes.h:154
CFB block cipher mode of operation.
Definition: modes.h:115
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:227
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:155
Base class for additive stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:261
CFB block cipher mode of operation providing FIPS validated cryptography.
Definition: modes.h:356
ECB block cipher mode of operation default implementation.
Definition: modes.h:209
bool IsRandomAccess() const
Determines whether the cipher supports random access.
Definition: modes.h:196
Interface for retrieving values given their names.
Definition: cryptlib.h:290
CBC block cipher mode of operation.
Definition: modes.h:440
CBC mode with ciphertext stealing, external cipher.
Definition: modes.h:476
Base class information.
Definition: simple.h:36