20 #ifndef _ANCH_CRYPTO_ECB_H_ 21 #define _ANCH_CRYPTO_ECB_H_ 23 #include "crypto/cipher/bcModOp.hpp" 38 template<
typename Cipher,
typename Padding>
44 std::array<uint8_t,Cipher::getBlockSize()> _initVect;
56 ECB(
unsigned int nbThread = 1):
86 virtual std::size_t
cipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
87 std::streamsize nbRead,
88 std::array<uint8_t,Cipher::getBlockSize()>& output,
89 uint32_t, Cipher&
cipher)
override {
90 if(static_cast<std::size_t>(nbRead) != Cipher::getBlockSize()) {
91 Padding::pad(input.data(), nbRead, Cipher::getBlockSize());
93 cipher.cipher(input, output);
94 return Cipher::getBlockSize();
109 virtual std::size_t
decipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
110 std::array<uint8_t,Cipher::getBlockSize()>&,
111 std::streamsize nbRead,
113 std::array<uint8_t,Cipher::getBlockSize()>& output,
114 uint32_t, Cipher&
cipher)
override {
115 if(lastBlock && static_cast<std::size_t>(nbRead) != Cipher::getBlockSize()) {
118 cipher.decipher(input, output);
120 return Padding::length(output.data(), Cipher::getBlockSize());
122 return Cipher::getBlockSize();
131 virtual const std::array<uint8_t,Cipher::getBlockSize()>&
reset() {
141 #endif // _ANCH_CRYPTO_ECB_H_ virtual ~ECB()
Definition: ecb.hpp:67
virtual std::size_t cipherBlock(std::array< uint8_t, Cipher::getBlockSize()> &input, std::streamsize nbRead, std::array< uint8_t, Cipher::getBlockSize()> &output, uint32_t, Cipher &cipher) override
Definition: ecb.hpp:86
Exception on receiving an invalid block.
Definition: invalidBlockException.hpp:39
AnCH framework base namespace.
Definition: base64.hpp:28
void cipher(std::istream &input, std::ostream &output, const std::string &key)
Definition: bcModOp.hpp:133
Block cipher mode of operation interface.
Definition: bcModOp.hpp:49
ECB(unsigned int nbThread=1)
Definition: ecb.hpp:56
virtual const std::array< uint8_t, Cipher::getBlockSize()> & reset()
Definition: ecb.hpp:131
virtual std::size_t decipherBlock(std::array< uint8_t, Cipher::getBlockSize()> &input, std::array< uint8_t, Cipher::getBlockSize()> &, std::streamsize nbRead, bool lastBlock, std::array< uint8_t, Cipher::getBlockSize()> &output, uint32_t, Cipher &cipher) override
Definition: ecb.hpp:109
Electronic codebook implementation.
Definition: ecb.hpp:39