Fabcoin Core  0.16.2
P2P Digital Currency
Public Types | Public Member Functions | List of all members
BlockTransformation Class Referenceabstract

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

#include <cryptlib.h>

Inheritance diagram for BlockTransformation:
[legend]
Collaboration diagram for BlockTransformation:
[legend]

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 ~BlockTransformation ()
 
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) More...
 
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
virtual ~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 ~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_XorInput 
BT_ReverseDirection 

perform the transformation in reverse

BT_AllowParallel 

Definition at line 792 of file cryptlib.h.

Constructor & Destructor Documentation

virtual BlockTransformation::~BlockTransformation ( )
inlinevirtual

Definition at line 737 of file cryptlib.h.

Member Function Documentation

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.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual unsigned int BlockTransformation::BlockSize ( ) const
pure virtual
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.

Here is the caller graph for this function:

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()

Here is the caller graph for this function:

virtual bool BlockTransformation::IsPermutation ( ) const
inlinevirtual

returns true if this is a permutation (i.e. there is an inverse transformation)

Reimplemented in MDC< T >::Enc.

Definition at line 779 of file cryptlib.h.

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 MDC< T >::Enc, IDEA::Base, RC2::Base, SKIPJACK::Base, and SAFER::Base.

Definition at line 229 of file cryptlib.cpp.

Here is the caller graph for this function:

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.

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 BTEA::Dec, BTEA::Enc, DES_XEX3::Base, DES_EDE3::Base, XTEA::Dec, LR< T >::Dec, XTEA::Enc, CAST256::Base, DES_EDE2::Base, Rijndael::Dec, LR< T >::Enc, CAST128::Dec, SHARK::Dec, RC2::Dec, Rijndael::Enc, GOST::Dec, SKIPJACK::Dec, ThreeWay::Dec, TEA::Dec, CAST128::Enc, DES::Base, Twofish::Dec, GOST::Enc, RC2::Enc, RC5::Dec, SAFER::Dec, Square::Dec, ThreeWay::Enc, MARS::Dec, RC6::Dec, SHACAL2::Dec, MDC< T >::Enc, SKIPJACK::Enc, Twofish::Enc, Serpent::Dec, SHARK::Enc, TEA::Enc, RC5::Enc, IDEA::Base, MARS::Enc, RC6::Enc, SAFER::Enc, SHACAL2::Enc, Serpent::Enc, Square::Enc, Blowfish::Base, SEED::Base, and Camellia::Base.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

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.


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