Crypto++  5.6.5
Free C++ class library of cryptographic schemes
modes.h
Go to the documentation of this file.
1 // modes.h - written and placed in the public domain by Wei Dai
2 
3 //! \file modes.h
4 //! \brief Class file for 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 NAMESPACE_BEGIN(CryptoPP)
24 
25 //! \class CipherModeDocumentation
26 //! \brief Block cipher mode of operation information
27 //! \details Each class derived from this one defines two types, Encryption and Decryption,
28 //! both of which implement the SymmetricCipher interface.
29 //! For each mode there are two classes, one of which is a template class,
30 //! and the other one has a name that ends in "_ExternalCipher".
31 //! The "external cipher" mode objects hold a reference to the underlying block cipher,
32 //! instead of holding an instance of it. The reference must be passed in to the constructor.
33 //! For the "cipher holder" classes, the CIPHER template parameter should be a class
34 //! derived from BlockCipherDocumentation, for example DES or AES.
35 //! \details See NIST SP 800-38A for definitions of these modes. See
36 //! AuthenticatedSymmetricCipherDocumentation for authenticated encryption modes.
38 {
39 };
40 
41 //! \class CipherModeBase
42 //! \brief Block cipher mode of operation information
43 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CipherModeBase : public SymmetricCipher
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  {
60  this->ThrowIfResynchronizable();
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 
86  BlockCipher *m_cipher;
87  AlignedSecByteBlock m_register;
88 };
89 
90 //! \class ModePolicyCommonTemplate
91 //! \brief Block cipher mode of operation common operations
92 //! \tparam POLICY_INTERFACE common operations
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>
101 void ModePolicyCommonTemplate<POLICY_INTERFACE>::CipherSetKey(const NameValuePairs &params, const byte *key, size_t length)
102 {
103  m_cipher->SetKey(key, length, params);
104  ResizeBuffers();
105  int feedbackSize = params.GetIntValueWithDefault(Name::FeedbackSize(), 0);
106  SetFeedbackSize(feedbackSize);
107 }
108 
109 //! \class CFB_ModePolicy
110 //! \brief CFB block cipher mode of operation
111 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CFB_ModePolicy : public ModePolicyCommonTemplate<CFB_CipherAbstractPolicy>
112 {
113 public:
114  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CFB";}
115 
116  virtual ~CFB_ModePolicy() {}
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 
129  SecByteBlock m_temp;
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 
141 //! \class OFB_ModePolicy
142 //! \brief OFB block cipher mode of operation
143 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
144 {
145 public:
146  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "OFB";}
147 
148  bool CipherIsRandomAccess() const {return false;}
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 
158 //! \class CTR_ModePolicy
159 //! \brief CTR block cipher mode of operation
160 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
161 {
162 public:
163  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CTR";}
164 
165  virtual ~CTR_ModePolicy() {}
166  bool CipherIsRandomAccess() const {return true;}
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 
181  AlignedSecByteBlock m_counterArray;
182 };
183 
184 //! \class BlockOrientedCipherModeBase
185 //! \brief Block cipher mode of operation default implementation
186 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockOrientedCipherModeBase : public CipherModeBase
187 {
188 public:
189  virtual ~BlockOrientedCipherModeBase() {}
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 
201  SecByteBlock m_buffer;
202 };
203 
204 //! \class ECB_OneWay
205 //! \brief ECB block cipher mode of operation default implementation
206 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : public BlockOrientedCipherModeBase
207 {
208 public:
209  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "ECB";}
210 
211  void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs)
212  {m_cipher->SetKey(key, length, params); BlockOrientedCipherModeBase::ResizeBuffers();}
214  unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();}
215  void ProcessData(byte *outString, const byte *inString, size_t length);
216 };
217 
218 //! \class CBC_ModeBase
219 //! \brief CBC block cipher mode of operation default implementation
220 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_ModeBase : public BlockOrientedCipherModeBase
221 {
222 public:
223  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CBC";}
224 
226  bool RequireAlignedInput() const {return false;}
227  unsigned int MinLastBlockSize() const {return 0;}
228 };
229 
230 //! \class CBC_Encryption
231 //! \brief CBC block cipher mode of operation encryption operation
232 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Encryption : public CBC_ModeBase
233 {
234 public:
235  void ProcessData(byte *outString, const byte *inString, size_t length);
236 };
237 
238 //! \class CBC_CTS_Encryption
239 //! \brief CBC-CTS block cipher mode of operation encryption operation
240 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Encryption : public CBC_Encryption
241 {
242 public:
243  CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CBC/CTS";}
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 
256  byte *m_stolenIV;
257 };
258 
259 //! \class CBC_Decryption
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 //! \class CBC_CTS_Decryption
274 //! \brief CBC-CTS block cipher mode of operation decryption operation
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  void ProcessLastBlock(byte *outString, const byte *inString, size_t length);
280 };
281 
282 //! \class CipherModeFinalTemplate_CipherHolder
283 //! \brief Block cipher mode of operation aggregate
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 
313 //! \class CipherModeFinalTemplate_ExternalCipher
314 //! \tparam BASE CipherModeFinalTemplate_CipherHolder base class
315 //! \details
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 
334 //! \class CFB_Mode
335 //! \brief CFB block cipher mode of operation.
336 template <class CIPHER>
338 {
341 };
342 
343 //! \class CFB_Mode_ExternalCipher
344 //! \brief CFB mode, external cipher.
346 {
349 };
350 
351 //! \class CFB_FIPS_Mode
352 //! \brief CFB block cipher mode of operation providing FIPS validated cryptography.
353 //! \details Requires full block plaintext according to FIPS 800-38A
354 template <class CIPHER>
356 {
359 };
360 
361 //! \class CFB_FIPS_Mode_ExternalCipher
362 //! \brief CFB mode, external cipher, providing FIPS validated cryptography.
363 //! \details Requires full block plaintext according to FIPS 800-38A
365 {
368 };
369 
371 
372 //! \class OFB_Mode
373 //! \brief OFB block cipher mode of operation.
374 template <class CIPHER>
376 {
378  typedef Encryption Decryption;
379 };
380 
381 //! \class OFB_Mode_ExternalCipher
382 //! \brief OFB mode, external cipher.
384 {
386  typedef Encryption Decryption;
387 };
388 
391 
392 //! \class CTR_Mode
393 //! \brief CTR block cipher mode of operation.
394 template <class CIPHER>
396 {
398  typedef Encryption Decryption;
399 };
400 
401 //! \class CTR_Mode_ExternalCipher
402 //! \brief CTR mode, external cipher.
404 {
405  typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > > Encryption;
406  typedef Encryption Decryption;
407 };
408 
409 //! \class ECB_Mode
410 //! \brief ECB block cipher mode of operation.
411 template <class CIPHER>
413 {
416 };
417 
418 CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<ECB_OneWay>;
419 
420 //! \class ECB_Mode_ExternalCipher
421 //! \brief ECB mode, external cipher.
423 {
424  typedef CipherModeFinalTemplate_ExternalCipher<ECB_OneWay> Encryption;
425  typedef Encryption Decryption;
426 };
427 
428 //! CBC mode
429 template <class CIPHER>
431 {
434 };
435 
438 
439 //! CBC mode, external cipher
441 {
442  typedef CipherModeFinalTemplate_ExternalCipher<CBC_Encryption> Encryption;
443  typedef CipherModeFinalTemplate_ExternalCipher<CBC_Decryption> Decryption;
444 };
445 
446 //! CBC mode with ciphertext stealing
447 template <class CIPHER>
449 {
452 };
453 
456 
457 //! \class CBC_CTS_Mode_ExternalCipher
458 //! \brief CBC mode with ciphertext stealing, external cipher
460 {
461  typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Encryption> Encryption;
462  typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Decryption> Decryption;
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 
472 NAMESPACE_END
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
virtual void ProcessLastBlock(byte *outString, const byte *inString, size_t length)
Encrypt or decrypt the last block of data.
Definition: cryptlib.cpp:244
Used to pass byte array input as part of a NameValuePairs object.
Definition: algparam.h:29
Standard names for retrieving values by name when working with NameValuePairs.
An invalid argument was detected.
Definition: cryptlib.h:184
const char * FeedbackSize()
int
Definition: argnames.h:25
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
virtual void ProcessData(byte *outString, const byte *inString, size_t length)=0
Encrypt or decrypt an array of bytes.
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:97
CFB mode, external cipher, providing FIPS validated cryptography.
Definition: modes.h:364
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
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
Base class for feedback based stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:489
The object does not use an IV.
Definition: cryptlib.h:608
Wirte the keystream to the output buffer, input is NULL.
Definition: strciphr.h:92
SecBlock typedef.
Definition: secblock.h:731
CBC mode with ciphertext stealing.
Definition: modes.h:448
CTR block cipher mode of operation.
Definition: modes.h:395
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
const char * StolenIV()
byte *
Definition: argnames.h:22
OFB block cipher mode of operation.
Definition: modes.h:143
CBC-CTS block cipher mode of operation decryption operation.
Definition: modes.h:275
Classes and functions for secure memory allocations.
ECB block cipher mode of operation.
Definition: modes.h:412
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: modes.h:194
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
CBC-CTS block cipher mode of operation encryption operation.
Definition: modes.h:240
unsigned int IVSize() const
Returns length of the IV accepted by this object.
Definition: modes.h:55
int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Definition: cryptlib.h:382
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition: algparam.h:500
Block cipher mode of operation aggregate.
Definition: modes.h:285
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
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
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Definition: cryptlib.h:1103
Block cipher mode of operation default implementation.
Definition: modes.h:186
ECB mode, external cipher.
Definition: modes.h:422
const NameValuePairs & g_nullNameValuePairs
An empty set of name-value pairs.
Definition: cryptlib.cpp:76
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:246
SecBlock using AllocatorWithCleanup typedef.
Definition: secblock.h:737
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
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
Definition: trap.h:62
const char * BlockSize()
int, in bytes
Definition: argnames.h:27
CFB block cipher mode of operation.
Definition: modes.h:337
CTR block cipher mode of operation.
Definition: modes.h:160
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
virtual IV_Requirement IVRequirement() const =0
Minimal requirement for secure IVs.
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:424
IV_Requirement
Secure IVs requirements as enumerated values.
Definition: cryptlib.h:598
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition: modes.h:166
Block cipher mode of operation information.
Definition: modes.h:43
CBC block cipher mode of operation decryption operation.
Definition: modes.h:261
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
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:225
Block cipher mode of operation common operations.
Definition: modes.h:94
KeystreamOperation
Keystream operation flags.
Definition: strciphr.h:90
Crypto++ library namespace.
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
The IV must be random and unpredictable.
Definition: cryptlib.h:604
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:227
CFB block cipher mode of operation.
Definition: modes.h:111
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:213
Base class for additive stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:267
CFB block cipher mode of operation providing FIPS validated cryptography.
Definition: modes.h:355
ECB block cipher mode of operation default implementation.
Definition: modes.h:206
The IV must be unique.
Definition: cryptlib.h:600
Interface for retrieving values given their names.
Definition: cryptlib.h:279
The IV must be random and possibly predictable.
Definition: cryptlib.h:602
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