AnCH Framework  0.1
Another C++ Hack Framework
Public Member Functions | Protected Member Functions | List of all members
anch::crypto::CTR< Cipher > Class Template Reference

Counter implementation. More...

#include <ctr.hpp>

Inheritance diagram for anch::crypto::CTR< Cipher >:
Collaboration diagram for anch::crypto::CTR< Cipher >:

Public Member Functions

 CTR (const std::array< uint8_t, Cipher::getBlockSize()> &nonce, unsigned int nbThread=1)
 
virtual ~CTR ()
 
- Public Member Functions inherited from anch::crypto::BlockCipherModeOfOperation< CTR< Cipher >, Cipher >
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

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) override
 
virtual std::size_t decipherBlock (std::array< uint8_t, Cipher::getBlockSize()> &input, std::array< uint8_t, Cipher::getBlockSize()> &, std::streamsize nbRead, bool, std::array< uint8_t, Cipher::getBlockSize()> &output, uint32_t index, Cipher &cipher) override
 
virtual const std::array< uint8_t, Cipher::getBlockSize()> & reset ()
 
- Protected Member Functions inherited from anch::crypto::BlockCipherModeOfOperation< CTR< Cipher >, Cipher >
 BlockCipherModeOfOperation (bool cipherParallelizable, bool decipherParallelizable, unsigned int nbThread=1)
 
virtual ~BlockCipherModeOfOperation ()
 

Detailed Description

template<typename Cipher>
class anch::crypto::CTR< Cipher >

Counter implementation.

CTR mode is also known as ICM (integer counter mode) and SIC (segmented integer counter).

Since
0.1
Author
Vincent Lachenal

Constructor & Destructor Documentation

template<typename Cipher >
anch::crypto::CTR< Cipher >::CTR ( const std::array< uint8_t, Cipher::getBlockSize()> &  nonce,
unsigned int  nbThread = 1 
)
inline

CTR constructor

Parameters
noncethe nonce
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 Cipher >
virtual anch::crypto::CTR< Cipher >::~CTR ( )
inlinevirtual

CTR destructor

Member Function Documentation

template<typename Cipher >
virtual std::size_t anch::crypto::CTR< Cipher >::cipherBlock ( std::array< uint8_t, Cipher::getBlockSize()> &  input,
std::streamsize  nbRead,
std::array< uint8_t, Cipher::getBlockSize()> &  output,
uint32_t  index,
Cipher &  cipher 
)
inlineoverrideprotectedvirtual

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

Implements anch::crypto::BlockCipherModeOfOperation< CTR< Cipher >, Cipher >.

template<typename Cipher >
virtual std::size_t anch::crypto::CTR< Cipher >::decipherBlock ( std::array< uint8_t, Cipher::getBlockSize()> &  input,
std::array< uint8_t, Cipher::getBlockSize()> &  ,
std::streamsize  nbRead,
bool  ,
std::array< uint8_t, Cipher::getBlockSize()> &  output,
uint32_t  index,
Cipher &  cipher 
)
inlineoverrideprotectedvirtual

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

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

Implements anch::crypto::BlockCipherModeOfOperation< CTR< Cipher >, Cipher >.

template<typename Cipher >
virtual const std::array<uint8_t,Cipher::getBlockSize()>& anch::crypto::CTR< Cipher >::reset ( )
inlineprotectedvirtual

Reset block cipher mode of operation context

Returns
the initial context

Implements anch::crypto::BlockCipherModeOfOperation< CTR< Cipher >, Cipher >.


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