Crypto++  5.6.5
Free C++ class library of cryptographic schemes
Public Types | Public Member Functions | List of all members
BlockTransformation Class Referenceabstract

Interface for the data processing part of block ciphers. More...

+ Inheritance diagram for BlockTransformation:

Public Types

enum  FlagsForAdvancedProcessBlocks {
  BT_InBlockIsCounter =1, BT_DontIncrementInOutPointers =2, BT_XorInput =4, BT_ReverseDirection =8,
  BT_AllowParallel =16
}
 Bit flags that control AdvancedProcessBlocks() behavior. More...
 

Public Member Functions

virtual void ProcessAndXorBlock (const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0
 Encrypt or decrypt a block. More...
 
void ProcessBlock (const byte *inBlock, byte *outBlock) const
 Encrypt or decrypt a block. More...
 
void ProcessBlock (byte *inoutBlock) const
 Encrypt or decrypt a block in place. More...
 
virtual unsigned int BlockSize () const =0
 Provides the block size of the cipher. More...
 
virtual unsigned int OptimalDataAlignment () const
 Provides input and output data alignment for optimal performance. More...
 
virtual bool IsPermutation () const
 returns true if this is a permutation (i.e. there is an inverse transformation)
 
virtual bool IsForwardTransformation () const =0
 Determines if the cipher is being operated in its forward direction. More...
 
virtual unsigned int OptimalNumberOfParallelBlocks () const
 Determines the number of blocks that can be processed in parallel. More...
 
virtual size_t AdvancedProcessBlocks (const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
 Encrypt and xor multiple blocks using additional flags. More...
 
CipherDir GetCipherDirection () const
 Provides the direction of the cipher. More...
 
- Public Member Functions inherited from Algorithm
 Algorithm (bool checkSelfTestStatus=true)
 Interface for all crypto algorithms. More...
 
virtual std::string AlgorithmName () const
 Provides the name of this algorithm. More...
 
- Public Member Functions inherited from Clonable
virtual ClonableClone () const
 Copies this object. More...
 

Detailed Description

Interface for the data processing part of block ciphers.

Classes derived from BlockTransformation are block ciphers in ECB mode (for example the DES::Encryption class), which are stateless. These classes should not be used directly, but only in combination with a mode class (see CipherModeDocumentation in modes.h).

Definition at line 734 of file cryptlib.h.

Member Enumeration Documentation

Bit flags that control AdvancedProcessBlocks() behavior.

Enumerator
BT_InBlockIsCounter 

inBlock is a counter

BT_DontIncrementInOutPointers 

should not modify block pointers

BT_ReverseDirection 

perform the transformation in reverse

Definition at line 792 of file cryptlib.h.

Member Function Documentation

virtual void BlockTransformation::ProcessAndXorBlock ( const byte *  inBlock,
const byte *  xorBlock,
byte *  outBlock 
) const
pure virtual

Encrypt or decrypt a block.

Parameters
inBlockthe input message before processing
outBlockthe output message after processing
xorBlockan optional XOR mask

ProcessAndXorBlock encrypts or decrypts inBlock, xor with xorBlock, and write to outBlock.

The size of the block is determined by the block cipher and its documentation. Use BLOCKSIZE at compile time, or BlockSize() at runtime.

Note
The message can be transformed in-place, or the buffers must not overlap
See also
FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize()

Implemented in SAFER::Dec, and SAFER::Enc.

void BlockTransformation::ProcessBlock ( const byte *  inBlock,
byte *  outBlock 
) const
inline

Encrypt or decrypt a block.

Parameters
inBlockthe input message before processing
outBlockthe output message after processing

ProcessBlock encrypts or decrypts inBlock and write to outBlock.

The size of the block is determined by the block cipher and its documentation. Use BLOCKSIZE at compile time, or BlockSize() at runtime.

See also
FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize()
Note
The message can be transformed in-place, or the buffers must not overlap

Definition at line 758 of file cryptlib.h.

void BlockTransformation::ProcessBlock ( byte *  inoutBlock) const
inline

Encrypt or decrypt a block in place.

Parameters
inoutBlockthe input message before processing

ProcessBlock encrypts or decrypts inoutBlock in-place.

The size of the block is determined by the block cipher and its documentation. Use BLOCKSIZE at compile time, or BlockSize() at runtime.

See also
FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize()

Definition at line 767 of file cryptlib.h.

virtual unsigned int BlockTransformation::BlockSize ( ) const
pure virtual

Provides the block size of the cipher.

Returns
the block size of the cipher, in bytes
unsigned int BlockTransformation::OptimalDataAlignment ( ) const
virtual

Provides input and output data alignment for optimal performance.

Returns
the input data alignment that provides optimal performance

Reimplemented in SAFER::Base.

Definition at line 229 of file cryptlib.cpp.

virtual bool BlockTransformation::IsForwardTransformation ( ) const
pure virtual

Determines if the cipher is being operated in its forward direction.

Returns
true if DIR is ENCRYPTION, false otherwise
See also
IsForwardTransformation(), IsPermutation(), GetCipherDirection()
virtual unsigned int BlockTransformation::OptimalNumberOfParallelBlocks ( ) const
inlinevirtual

Determines the number of blocks that can be processed in parallel.

Returns
the number of blocks that can be processed in parallel, for bit-slicing implementations

Bit-slicing is often used to improve throughput and minimize timing attacks.

Definition at line 789 of file cryptlib.h.

size_t BlockTransformation::AdvancedProcessBlocks ( const byte *  inBlocks,
const byte *  xorBlocks,
byte *  outBlocks,
size_t  length,
word32  flags 
) const
virtual

Encrypt and xor multiple blocks using additional flags.

Parameters
inBlocksthe input message before processing
xorBlocksan optional XOR mask
outBlocksthe output message after processing
lengththe size of the blocks, in bytes
flagsadditional flags to control processing

Encrypt and xor multiple blocks according to FlagsForAdvancedProcessBlocks flags.

Note
If BT_InBlockIsCounter is set, then the last byte of inBlocks may be modified.

Definition at line 178 of file cryptlib.cpp.

CipherDir BlockTransformation::GetCipherDirection ( ) const
inline

Provides the direction of the cipher.

Returns
ENCRYPTION if IsForwardTransformation() is true, DECRYPTION otherwise
See also
IsForwardTransformation(), IsPermutation()

Definition at line 817 of file cryptlib.h.


The documentation for this class was generated from the following files: