Crypto++ 8.2 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
| Determines if the transformation is a permutation. 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
| Algorithm (bool checkSelfTestStatus=true)
| Interface for all crypto algorithms. More...
virtual std::string | AlgorithmName () const
| Provides the name of this algorithm. More...
virtual std::string | AlgorithmProvider () const
| Retrieve the provider of this algorithm. More...
Public Member Functions inherited from Clonable
virtual Clonable * | Clone () 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 855 of file cryptlib.h.

## Member Enumeration Documentation

## ◆ FlagsForAdvancedProcessBlocks

enum BlockTransformation::FlagsForAdvancedProcessBlocks

Bit flags that control AdvancedProcessBlocks() behavior.

Enumerator
BT_InBlockIsCounter | inBlock is a counter
BT_DontIncrementInOutPointers | should not modify block pointers
BT_XorInput | Xor inputs before transformation.
BT_ReverseDirection | perform the transformation in reverse
BT_AllowParallel | Allow parallel transformations.

Definition at line 915 of file cryptlib.h.

## Member Function Documentation

## ◆ ProcessAndXorBlock()

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

Encrypt or decrypt a block.

Parameters

  inBlock | the input message before processing
  outBlock | the output message after processing
  xorBlock | an 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.

## ◆ ProcessBlock() [1/2]

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

Encrypt or decrypt a block.

Parameters

  inBlock | the input message before processing
  outBlock | the 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 879 of file cryptlib.h.

## ◆ ProcessBlock() [2/2]

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

Encrypt or decrypt a block in place.

Parameters

  inoutBlock | the 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 888 of file cryptlib.h.

## ◆ BlockSize()

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

Provides the block size of the cipher.

Returns
  the block size of the cipher, in bytes

## ◆ OptimalDataAlignment()

unsigned int BlockTransformation::OptimalDataAlignment | ( |  | ) | const
| virtual

Provides input and output data alignment for optimal performance.

Returns
  the input data alignment that provides optimal performance

See also
  GetAlignment() and OptimalBlockSize()

Reimplemented in SAFER::Base.

Definition at line 190 of file cryptlib.cpp.

## ◆ IsPermutation()

virtual bool BlockTransformation::IsPermutation | ( |  | ) | const
| inline virtual

Determines if the transformation is a permutation.

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

Definition at line 902 of file cryptlib.h.

## ◆ IsForwardTransformation()

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

## ◆ OptimalNumberOfParallelBlocks()

virtual unsigned int BlockTransformation::OptimalNumberOfParallelBlocks | ( |  | ) | const
| inline virtual

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 912 of file cryptlib.h.

## ◆ AdvancedProcessBlocks()

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

  inBlocks | the input message before processing
  xorBlocks | an optional XOR mask
  outBlocks | the output message after processing
  length | the size of the blocks, in bytes
  flags | additional 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 141 of file cryptlib.cpp.

## ◆ GetCipherDirection()

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 940 of file cryptlib.h.

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

- cryptlib.h
- cryptlib.cpp