Crypto++  5.6.4
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 NAMESPACE_BEGIN(CryptoPP)
17 
18 //! \class CipherModeDocumentation
19 //! \brief Block cipher mode of operation information
20 //! \details Each class derived from this one defines two types, Encryption and Decryption,
21 //! both of which implement the SymmetricCipher interface.
22 //! For each mode there are two classes, one of which is a template class,
23 //! and the other one has a name that ends in "_ExternalCipher".
24 //! The "external cipher" mode objects hold a reference to the underlying block cipher,
25 //! instead of holding an instance of it. The reference must be passed in to the constructor.
26 //! For the "cipher holder" classes, the CIPHER template parameter should be a class
27 //! derived from BlockCipherDocumentation, for example DES or AES.
28 //! \details See NIST SP 800-38A for definitions of these modes. See
29 //! AuthenticatedSymmetricCipherDocumentation for authenticated encryption modes.
31 {
32 };
33 
34 //! \class CipherModeBase
35 //! \brief Block cipher mode of operation information
36 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CipherModeBase : public SymmetricCipher
37 {
38 public:
39  size_t MinKeyLength() const {return m_cipher->MinKeyLength();}
40  size_t MaxKeyLength() const {return m_cipher->MaxKeyLength();}
41  size_t DefaultKeyLength() const {return m_cipher->DefaultKeyLength();}
42  size_t GetValidKeyLength(size_t n) const {return m_cipher->GetValidKeyLength(n);}
43  bool IsValidKeyLength(size_t n) const {return m_cipher->IsValidKeyLength(n);}
44 
45  unsigned int OptimalDataAlignment() const {return m_cipher->OptimalDataAlignment();}
46 
47  unsigned int IVSize() const {return BlockSize();}
48  virtual IV_Requirement IVRequirement() const =0;
49 
50  void SetCipher(BlockCipher &cipher)
51  {
52  this->ThrowIfResynchronizable();
53  this->m_cipher = &cipher;
54  this->ResizeBuffers();
55  }
56 
57  void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize = 0)
58  {
59  this->ThrowIfInvalidIV(iv);
60  this->m_cipher = &cipher;
61  this->ResizeBuffers();
62  this->SetFeedbackSize(feedbackSize);
63  if (this->IsResynchronizable())
64  this->Resynchronize(iv);
65  }
66 
67 protected:
68  CipherModeBase() : m_cipher(NULL) {}
69  inline unsigned int BlockSize() const {CRYPTOPP_ASSERT(m_register.size() > 0); return (unsigned int)m_register.size();}
70  virtual void SetFeedbackSize(unsigned int feedbackSize)
71  {
72  if (!(feedbackSize == 0 || feedbackSize == BlockSize()))
73  throw InvalidArgument("CipherModeBase: feedback size cannot be specified for this cipher mode");
74  }
75 
76 // Thanks to Zireael, http://github.com/weidai11/cryptopp/pull/46
77 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
78  virtual void ResizeBuffers();
79 #else
80  virtual void ResizeBuffers()
81  {
82  m_register.New(m_cipher->BlockSize());
83  }
84 #endif
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:
115  CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "CFB";}
116 
117 protected:
118  unsigned int GetBytesPerIteration() const {return m_feedbackSize;}
119  byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;}
120  bool CanIterate() const {return m_feedbackSize == BlockSize();}
121  void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount);
122  void TransformRegister();
123  void CipherResynchronize(const byte *iv, size_t length);
124  void SetFeedbackSize(unsigned int feedbackSize);
125  void ResizeBuffers();
126 
127  SecByteBlock m_temp;
128  unsigned int m_feedbackSize;
129 };
130 
131 inline void CopyOrZero(void *dest, const void *src, size_t s)
132 {
133  if (src)
134  memcpy_s(dest, s, src, s);
135  else
136  memset(dest, 0, s);
137 }
138 
139 //! \class OFB_ModePolicy
140 //! \brief OFB block cipher mode of operation
141 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
142 {
143 public:
144  bool CipherIsRandomAccess() const {return false;}
146  CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "OFB";}
147 
148 private:
149  unsigned int GetBytesPerIteration() const {return BlockSize();}
150  unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();}
151  void WriteKeystream(byte *keystreamBuffer, size_t iterationCount);
152  void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
153 };
154 
155 //! \class CTR_ModePolicy
156 //! \brief CTR block cipher mode of operation
157 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy>
158 {
159 public:
160  bool CipherIsRandomAccess() const {return true;}
162  CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "CTR";}
163 
164 protected:
165  virtual void IncrementCounterBy256();
166 
167  unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();}
168  unsigned int GetBytesPerIteration() const {return BlockSize();}
169  unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();}
170  void WriteKeystream(byte *buffer, size_t iterationCount)
171  {OperateKeystream(WRITE_KEYSTREAM, buffer, NULL, iterationCount);}
172  bool CanOperateKeystream() const {return true;}
173  void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
174  void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
175  void SeekToIteration(lword iterationCount);
176 
177  AlignedSecByteBlock m_counterArray;
178 };
179 
180 //! \class BlockOrientedCipherModeBase
181 //! \brief Block cipher mode of operation default implementation
182 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockOrientedCipherModeBase : public CipherModeBase
183 {
184 public:
185  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
186  unsigned int MandatoryBlockSize() const {return BlockSize();}
187  bool IsRandomAccess() const {return false;}
188  bool IsSelfInverting() const {return false;}
189  bool IsForwardTransformation() const {return m_cipher->IsForwardTransformation();}
190  void Resynchronize(const byte *iv, int length=-1) {memcpy_s(m_register, m_register.size(), iv, ThrowIfInvalidIVLength(length));}
191 
192 protected:
193  bool RequireAlignedInput() const {return true;}
194 
195  // Thanks to Zireael, http://github.com/weidai11/cryptopp/pull/46
196 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
197  void ResizeBuffers();
198 #else
199  void ResizeBuffers()
200  {
201  CipherModeBase::ResizeBuffers();
202  m_buffer.New(BlockSize());
203  }
204 #endif
205 
206  SecByteBlock m_buffer;
207 };
208 
209 //! \class ECB_OneWay
210 //! \brief ECB block cipher mode of operation default implementation
211 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : public BlockOrientedCipherModeBase
212 {
213 public:
214  void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs)
215  {m_cipher->SetKey(key, length, params); BlockOrientedCipherModeBase::ResizeBuffers();}
217  unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();}
218  void ProcessData(byte *outString, const byte *inString, size_t length);
219  CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "ECB";}
220 };
221 
222 //! \class CBC_ModeBase
223 //! \brief CBC block cipher mode of operation default implementation
224 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_ModeBase : public BlockOrientedCipherModeBase
225 {
226 public:
228  bool RequireAlignedInput() const {return false;}
229  unsigned int MinLastBlockSize() const {return 0;}
230  CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "CBC";}
231 };
232 
233 //! \class CBC_Encryption
234 //! \brief CBC block cipher mode of operation encryption operation
235 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Encryption : public CBC_ModeBase
236 {
237 public:
238  void ProcessData(byte *outString, const byte *inString, size_t length);
239 };
240 
241 //! \class CBC_CTS_Encryption
242 //! \brief CBC-CTS block cipher mode of operation encryption operation
243 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Encryption : public CBC_Encryption
244 {
245 public:
246  void SetStolenIV(byte *iv) {m_stolenIV = iv;}
247  unsigned int MinLastBlockSize() const {return BlockSize()+1;}
248  void ProcessLastBlock(byte *outString, const byte *inString, size_t length);
249  CRYPTOPP_CONSTEXPR static const char * CRYPTOPP_API StaticAlgorithmName() {return "CBC/CTS";}
250 
251 protected:
252  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
253  {
254  CBC_Encryption::UncheckedSetKey(key, length, params);
255  m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULL);
256  }
257 
258  byte *m_stolenIV;
259 };
260 
261 //! \class CBC_Decryption
262 //! \brief CBC block cipher mode of operation decryption operation
263 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Decryption : public CBC_ModeBase
264 {
265 public:
266  void ProcessData(byte *outString, const byte *inString, size_t length);
267 
268 protected:
269 
270  // Thanks to Zireael, http://github.com/weidai11/cryptopp/pull/46
271 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
272  void ResizeBuffers();
273 #else
274  void ResizeBuffers()
275  {
276  BlockOrientedCipherModeBase::ResizeBuffers();
277  m_temp.New(BlockSize());
278  }
279 #endif
280 
281  AlignedSecByteBlock m_temp;
282 };
283 
284 //! \class CBC_CTS_Decryption
285 //! \brief CBC-CTS block cipher mode of operation decryption operation
286 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Decryption : public CBC_Decryption
287 {
288 public:
289  unsigned int MinLastBlockSize() const {return BlockSize()+1;}
290  void ProcessLastBlock(byte *outString, const byte *inString, size_t length);
291 };
292 
293 //! \class CipherModeFinalTemplate_CipherHolder
294 //! \brief Block cipher mode of operation aggregate
295 template <class CIPHER, class BASE>
296 class CipherModeFinalTemplate_CipherHolder : protected ObjectHolder<CIPHER>, public AlgorithmImpl<BASE, CipherModeFinalTemplate_CipherHolder<CIPHER, BASE> >
297 {
298 public:
300  {
301  this->m_cipher = &this->m_object;
302  this->ResizeBuffers();
303  }
304  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length)
305  {
306  this->m_cipher = &this->m_object;
307  this->SetKey(key, length);
308  }
309  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv)
310  {
311  this->m_cipher = &this->m_object;
312  this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize())));
313  }
314  CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv, int feedbackSize)
315  {
316  this->m_cipher = &this->m_object;
317  this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize()))(Name::FeedbackSize(), feedbackSize));
318  }
319 
320  static std::string CRYPTOPP_API StaticAlgorithmName()
321  {return CIPHER::StaticAlgorithmName() + "/" + BASE::StaticAlgorithmName();}
322 };
323 
324 //! \class CipherModeFinalTemplate_ExternalCipher
325 //! \tparam BASE CipherModeFinalTemplate_CipherHolder base class
326 //! \details
327 template <class BASE>
329 {
330 public:
333  {this->SetCipher(cipher);}
334  CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0)
335  {this->SetCipherWithIV(cipher, iv, feedbackSize);}
336 
337  std::string AlgorithmName() const
338  {return (this->m_cipher ? this->m_cipher->AlgorithmName() + "/" : std::string("")) + BASE::StaticAlgorithmName();}
339 };
340 
344 
345 //! \class CFB_Mode
346 //! \brief CFB block cipher mode of operation.
347 template <class CIPHER>
349 {
352 };
353 
354 //! \class CFB_Mode_ExternalCipher
355 //! \brief CFB mode, external cipher.
357 {
360 };
361 
362 //! \class CFB_FIPS_Mode
363 //! \brief CFB block cipher mode of operation providing FIPS validated cryptography.
364 //! \details Requires full block plaintext according to FIPS 800-38A
365 template <class CIPHER>
367 {
370 };
371 
372 //! \class CFB_FIPS_Mode_ExternalCipher
373 //! \brief CFB mode, external cipher, providing FIPS validated cryptography.
374 //! \details Requires full block plaintext according to FIPS 800-38A
376 {
379 };
380 
382 
383 //! \class OFB_Mode
384 //! \brief OFB block cipher mode of operation.
385 template <class CIPHER>
387 {
389  typedef Encryption Decryption;
390 };
391 
392 //! \class OFB_Mode_ExternalCipher
393 //! \brief OFB mode, external cipher.
395 {
397  typedef Encryption Decryption;
398 };
399 
402 
403 //! \class CTR_Mode
404 //! \brief CTR block cipher mode of operation.
405 template <class CIPHER>
407 {
409  typedef Encryption Decryption;
410 };
411 
412 //! \class CTR_Mode_ExternalCipher
413 //! \brief CTR mode, external cipher.
415 {
416  typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > > Encryption;
417  typedef Encryption Decryption;
418 };
419 
420 //! \class ECB_Mode
421 //! \brief ECB block cipher mode of operation.
422 template <class CIPHER>
424 {
427 };
428 
429 CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<ECB_OneWay>;
430 
431 //! \class ECB_Mode_ExternalCipher
432 //! \brief ECB mode, external cipher.
434 {
435  typedef CipherModeFinalTemplate_ExternalCipher<ECB_OneWay> Encryption;
436  typedef Encryption Decryption;
437 };
438 
439 //! CBC mode
440 template <class CIPHER>
442 {
445 };
446 
449 
450 //! CBC mode, external cipher
452 {
453  typedef CipherModeFinalTemplate_ExternalCipher<CBC_Encryption> Encryption;
454  typedef CipherModeFinalTemplate_ExternalCipher<CBC_Decryption> Decryption;
455 };
456 
457 //! CBC mode with ciphertext stealing
458 template <class CIPHER>
460 {
463 };
464 
467 
468 //! \class CBC_CTS_Mode_ExternalCipher
469 //! \brief CBC mode with ciphertext stealing, external cipher
471 {
472  typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Encryption> Encryption;
473  typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Decryption> Decryption;
474 };
475 
476 #ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY
477 typedef CFB_Mode_ExternalCipher::Encryption CFBEncryption;
478 typedef CFB_Mode_ExternalCipher::Decryption CFBDecryption;
480 typedef CTR_Mode_ExternalCipher::Encryption CounterMode;
481 #endif
482 
483 NAMESPACE_END
484 
485 #endif
bool IsSelfInverting() const
Determines whether the cipher is self-inverting.
Definition: modes.h:188
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:187
const char * FeedbackSize()
int
Definition: argnames.h:24
void Resynchronize(const byte *iv, int length=-1)
Resynchronize with an IV.
Definition: modes.h:190
Classes for working with NameValuePairs.
size_t GetValidKeyLength(size_t n) const
Definition: modes.h:42
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:375
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:114
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
Definition: cryptlib.h:353
bool IsRandomAccess() const
Determines whether the cipher supports random access.
Definition: modes.h:187
CipherDir
Specifies a direction for a cipher to operate.
Definition: cryptlib.h:108
size_t MinKeyLength() const
Returns smallest valid key length in bytes.
Definition: modes.h:39
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:356
Base class for feedback based stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:489
The object does not use an IV.
Definition: cryptlib.h:605
Wirte the keystream to the output buffer, input is NULL.
Definition: strciphr.h:94
SecBlock typedef.
Definition: secblock.h:731
CBC mode with ciphertext stealing.
Definition: modes.h:459
CTR block cipher mode of operation.
Definition: modes.h:406
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:161
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1098
const char * StolenIV()
byte *
Definition: argnames.h:22
OFB block cipher mode of operation.
Definition: modes.h:141
CBC-CTS block cipher mode of operation decryption operation.
Definition: modes.h:286
Classes and functions for secure memory allocations.
ECB block cipher mode of operation.
Definition: modes.h:423
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: modes.h:189
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:145
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:198
CBC-CTS block cipher mode of operation encryption operation.
Definition: modes.h:243
unsigned int IVSize() const
Returns length of the IV accepted by this object.
Definition: modes.h:47
int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Definition: cryptlib.h:385
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition: algparam.h:554
Block cipher mode of operation aggregate.
Definition: modes.h:296
CFB mode, external cipher.
Definition: modes.h:356
CBC block cipher mode of operation default implementation.
Definition: modes.h:224
bool IsResynchronizable() const
Determines if the object can be resynchronized.
Definition: cryptlib.h:616
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition: modes.h:45
virtual void Resynchronize(const byte *iv, int ivLength=-1)
Resynchronize with an IV.
Definition: cryptlib.h:659
size_t DefaultKeyLength() const
Returns default (recommended) key length in bytes.
Definition: modes.h:41
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:30
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Definition: cryptlib.h:1106
Block cipher mode of operation default implementation.
Definition: modes.h:182
ECB mode, external cipher.
Definition: modes.h:433
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:247
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:217
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:386
size_t MaxKeyLength() const
Returns largest valid key length in bytes.
Definition: modes.h:40
CBC mode, external cipher.
Definition: modes.h:451
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
Definition: trap.h:62
const char * BlockSize()
int, in bytes
Definition: argnames.h:26
CFB block cipher mode of operation.
Definition: modes.h:348
CTR block cipher mode of operation.
Definition: modes.h:157
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
Definition: modes.h:43
OFB mode, external cipher.
Definition: modes.h:394
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:439
IV_Requirement
Secure IVs requirements as enumerated values.
Definition: cryptlib.h:595
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition: modes.h:160
Block cipher mode of operation information.
Definition: modes.h:36
CBC block cipher mode of operation decryption operation.
Definition: modes.h:263
CTR mode, external cipher.
Definition: modes.h:414
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:289
CBC block cipher mode of operation encryption operation.
Definition: modes.h:235
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
Sets the key for this object without performing parameter validation.
Definition: modes.cpp:154
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:227
Block cipher mode of operation common operations.
Definition: modes.h:94
KeystreamOperation
Keystream operation flags.
Definition: strciphr.h:92
Crypto++ library namespace.
bool CipherIsRandomAccess() const
Flag indicating random access.
Definition: modes.h:144
unsigned int MandatoryBlockSize() const
Provides the mandatory block size of the cipher.
Definition: modes.h:186
The IV must be random and unpredictable.
Definition: cryptlib.h:601
unsigned int MinLastBlockSize() const
Provides the size of the last block.
Definition: modes.h:229
CFB block cipher mode of operation.
Definition: modes.h:111
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Definition: modes.h:216
Base class for additive stream ciphers with SymmetricCipher interface.
Definition: strciphr.h:269
CFB block cipher mode of operation providing FIPS validated cryptography.
Definition: modes.h:366
ECB block cipher mode of operation default implementation.
Definition: modes.h:211
The IV must be unique.
Definition: cryptlib.h:597
Interface for retrieving values given their names.
Definition: cryptlib.h:282
The IV must be random and possibly predictable.
Definition: cryptlib.h:599
CBC mode.
Definition: modes.h:441
CBC mode with ciphertext stealing, external cipher.
Definition: modes.h:470
Base class for identifying alogorithm.
Definition: simple.h:38