AnCH Framework  0.1
Another C++ Hack Framework
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
anch::crypto::BlockCipherModeOfOperation< Derived, Cipher > Class Template Referenceabstract

Block cipher mode of operation interface. More...

#include <bcModOp.hpp>

Inheritance diagram for anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >:
Collaboration diagram for anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >:

Public Member Functions

void cipher (std::istream &input, std::ostream &output, const std::string &key)
 
void decipher (std::istream &input, std::ostream &output, const std::string &key)
 
void setNbThread (unsigned int nbThread)
 

Protected Member Functions

 BlockCipherModeOfOperation (bool cipherParallelizable, bool decipherParallelizable, unsigned int nbThread=1)
 
virtual ~BlockCipherModeOfOperation ()
 
virtual std::size_t cipherBlock (std::array< uint8_t, Cipher::getBlockSize()> &input, std::streamsize nbRead, std::array< uint8_t, Cipher::getBlockSize()> &output, uint32_t index, Cipher &cipher)=0
 
virtual std::size_t decipherBlock (std::array< uint8_t, Cipher::getBlockSize()> &input, std::array< uint8_t, Cipher::getBlockSize()> &prevInput, std::streamsize nbRead, bool lastBlock, std::array< uint8_t, Cipher::getBlockSize()> &output, uint32_t index, Cipher &cipher)=0
 
virtual const std::array< uint8_t, Cipher::getBlockSize()> & reset ()=0
 

Friends

class anch::ThreadPool
 

Detailed Description

template<typename Derived, typename Cipher>
class anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >

Block cipher mode of operation interface.

Interface for all block cipher mode of operation implementations.

Since
0.1
Author
Vincent Lachenal

Constructor & Destructor Documentation

template<typename Derived, typename Cipher>
anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >::BlockCipherModeOfOperation ( bool  cipherParallelizable,
bool  decipherParallelizable,
unsigned int  nbThread = 1 
)
inlineprotected

BlockCipherModeOfOperation constructor

Parameters
cipherParallelizableIs cipher parallelizable
decipherParallelizableIs decipher parallelizable
nbThreadthe maximum number of thread to run in parallel (default to 1). If is set to 0, it will be set to the number of CPU if found (1 otherwise).
template<typename Derived, typename Cipher>
virtual anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >::~BlockCipherModeOfOperation ( )
inlineprotectedvirtual

Member Function Documentation

template<typename Derived, typename Cipher>
void anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >::cipher ( std::istream &  input,
std::ostream &  output,
const std::string &  key 
)
inline

Cipher input stream

Parameters
inputthe input stream to cipher
outputthe ouput stream to write in
keythe cipher key
template<typename Derived, typename Cipher>
virtual std::size_t anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >::cipherBlock ( std::array< uint8_t, Cipher::getBlockSize()> &  input,
std::streamsize  nbRead,
std::array< uint8_t, Cipher::getBlockSize()> &  output,
uint32_t  index,
Cipher &  cipher 
)
protectedpure virtual

Cipher a block.
This method will handle initialization vector management.

Parameters
inputthe input block to cipher
nbReadthe size of block which has been read
outputthe output block
indexthe block index
cipherthe cipher instance
Returns
the number of bytes to write

Implemented in anch::crypto::PCBC< Cipher, Padding >, anch::crypto::CBC< Cipher, Padding >, anch::crypto::CFB< Cipher >, anch::crypto::OFB< Cipher >, anch::crypto::CTR< Cipher >, and anch::crypto::ECB< Cipher, Padding >.

template<typename Derived, typename Cipher>
void anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >::decipher ( std::istream &  input,
std::ostream &  output,
const std::string &  key 
)
inline

Decipher input stream

Parameters
inputthe input stream to decipher
outputthe ouput stream to write in
keythe decipher key
template<typename Derived, typename Cipher>
virtual std::size_t anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >::decipherBlock ( std::array< uint8_t, Cipher::getBlockSize()> &  input,
std::array< uint8_t, Cipher::getBlockSize()> &  prevInput,
std::streamsize  nbRead,
bool  lastBlock,
std::array< uint8_t, Cipher::getBlockSize()> &  output,
uint32_t  index,
Cipher &  cipher 
)
protectedpure virtual

Decipher a block.
This method will handle initialization vector management.

Parameters
inputthe input block to decipher
prevInputthe previous input block to decipher
nbReadthe size of block which has been read
lastBlockis last block to decipher
outputthe output block
indexthe block index
cipherthe cipher instance
Returns
the number of bytes to write

Implemented in anch::crypto::PCBC< Cipher, Padding >, anch::crypto::CBC< Cipher, Padding >, anch::crypto::CFB< Cipher >, anch::crypto::CTR< Cipher >, anch::crypto::OFB< Cipher >, and anch::crypto::ECB< Cipher, Padding >.

template<typename Derived, typename Cipher>
virtual const std::array<uint8_t,Cipher::getBlockSize()>& anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >::reset ( )
protectedpure virtual
template<typename Derived, typename Cipher>
void anch::crypto::BlockCipherModeOfOperation< Derived, Cipher >::setNbThread ( unsigned int  nbThread)
inline

Maximum number of parallel thread setter

Parameters
nbThreadthe maximum number of parallel thread to set

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