Crypto++  5.6.3
Free C++ class library of cryptographic schemes
Classes | Macros | Enumerations
strciphr.h File Reference

Go to the source code of this file.

Classes

class  AbstractPolicyHolder< POLICY_INTERFACE, BASE >
 
class  ConcretePolicyHolder< POLICY, BASE, POLICY_INTERFACE >
 
struct  AdditiveCipherAbstractPolicy
 
struct  AdditiveCipherConcretePolicy< WT, W, X, BASE >
 
class  AdditiveCipherTemplate< BASE >
 
class  CFB_CipherAbstractPolicy
 
struct  CFB_CipherConcretePolicy< WT, W, BASE >
 
struct  CFB_CipherConcretePolicy< WT, W, BASE >::RegisterOutput< B >
 
class  CFB_CipherTemplate< BASE >
 
class  CFB_EncryptionTemplate< BASE >
 
class  CFB_DecryptionTemplate< BASE >
 
class  CFB_RequireFullDataBlocks< BASE >
 
class  SymmetricCipherFinal< BASE, INFO >
 _ More...
 

Macros

#define CRYPTOPP_KEYSTREAM_OUTPUT_WORD(x, b, i, a)   PutWord(bool(x & OUTPUT_ALIGNED), b, output+i*sizeof(WordType), (x & INPUT_NULL) ? (a) : (a) ^ GetWord<WordType>(bool(x & INPUT_ALIGNED), b, input+i*sizeof(WordType)));
 
#define CRYPTOPP_KEYSTREAM_OUTPUT_XMM(x, i, a)
 
#define CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH(x, y)
 

Enumerations

enum  KeystreamOperationFlags { OUTPUT_ALIGNED =1, INPUT_ALIGNED =2, INPUT_NULL = 4 }
 
enum  KeystreamOperation {
  WRITE_KEYSTREAM = INPUT_NULL, WRITE_KEYSTREAM_ALIGNED = INPUT_NULL | OUTPUT_ALIGNED, XOR_KEYSTREAM = 0, XOR_KEYSTREAM_INPUT_ALIGNED = INPUT_ALIGNED,
  XOR_KEYSTREAM_OUTPUT_ALIGNED = OUTPUT_ALIGNED, XOR_KEYSTREAM_BOTH_ALIGNED = OUTPUT_ALIGNED | INPUT_ALIGNED
}
 

Detailed Description

This file contains helper classes for implementing stream ciphers.

All this infrastructure may look very complex compared to what's in Crypto++ 4.x, but stream ciphers implementations now support a lot of new functionality, including better performance (minimizing copying), resetting of keys and IVs, and methods to query which features are supported by a cipher.

Here's an explanation of these classes. The word "policy" is used here to mean a class with a set of methods that must be implemented by individual stream cipher implementations. This is usually much simpler than the full stream cipher API, which is implemented by either AdditiveCipherTemplate or CFB_CipherTemplate using the policy. So for example, an implementation of SEAL only needs to implement the AdditiveCipherAbstractPolicy interface (since it's an additive cipher, i.e., it xors a keystream into the plaintext). See this line in seal.h:

typedef SymmetricCipherFinal<ConcretePolicyHolder<SEAL_Policy<B>, AdditiveCipherTemplate<> > > Encryption;

AdditiveCipherTemplate and CFB_CipherTemplate are designed so that they don't need to take a policy class as a template parameter (although this is allowed), so that their code is not duplicated for each new cipher. Instead they each get a reference to an abstract policy interface by calling AccessPolicy() on itself, so AccessPolicy() must be overriden to return the actual policy reference. This is done by the ConceretePolicyHolder class. Finally, SymmetricCipherFinal implements the constructors and other functions that must be implemented by the most derived class.

Definition in file strciphr.h.

Macro Definition Documentation

#define CRYPTOPP_KEYSTREAM_OUTPUT_XMM (   x,
  i,
 
)
Value:
{\
__m128i t = (x & INPUT_NULL) ? a : _mm_xor_si128(a, (x & INPUT_ALIGNED) ? _mm_load_si128((__m128i *)input+i) : _mm_loadu_si128((__m128i *)input+i));\
if (x & OUTPUT_ALIGNED) _mm_store_si128((__m128i *)output+i, t);\
else _mm_storeu_si128((__m128i *)output+i, t);}

Definition at line 112 of file strciphr.h.

#define CRYPTOPP_KEYSTREAM_OUTPUT_SWITCH (   x,
 
)
Value:
switch (operation) \
{ \
case WRITE_KEYSTREAM: \
x(WRITE_KEYSTREAM) \
break; \
case XOR_KEYSTREAM: \
x(XOR_KEYSTREAM) \
input += y; \
break; \
case XOR_KEYSTREAM_INPUT_ALIGNED: \
x(XOR_KEYSTREAM_INPUT_ALIGNED) \
input += y; \
break; \
case XOR_KEYSTREAM_OUTPUT_ALIGNED: \
x(XOR_KEYSTREAM_OUTPUT_ALIGNED) \
input += y; \
break; \
case WRITE_KEYSTREAM_ALIGNED: \
x(WRITE_KEYSTREAM_ALIGNED) \
break; \
case XOR_KEYSTREAM_BOTH_ALIGNED: \
x(XOR_KEYSTREAM_BOTH_ALIGNED) \
input += y; \
break; \
} \
output += y;

Definition at line 116 of file strciphr.h.