22#include "crypto/cipher/bcModOp.hpp"
37 template<
typename Cipher,
typename Padding>
43 std::array<uint8_t,Cipher::getBlockSize()> _initVect;
55 ECB(
unsigned int nbThread = 1);
80 virtual std::size_t
cipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
81 std::streamsize nbRead,
82 std::array<uint8_t,Cipher::getBlockSize()>& output,
83 uint32_t, Cipher&
cipher)
override;
97 virtual std::size_t
decipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
98 std::array<uint8_t,Cipher::getBlockSize()>&,
99 std::streamsize nbRead,
101 std::array<uint8_t,Cipher::getBlockSize()>& output,
102 uint32_t, Cipher&
cipher)
override;
109 virtual const std::array<uint8_t,Cipher::getBlockSize()>&
reset();
115 template<
typename Cipher,
typename Padding>
124 template<
typename Cipher,
typename Padding>
132 template<
typename Cipher,
typename Padding>
135 std::streamsize nbRead,
136 std::array<uint8_t,Cipher::getBlockSize()>& output,
137 uint32_t, Cipher&
cipher) {
138 if(
static_cast<std::size_t
>(nbRead) != Cipher::getBlockSize()) {
139 Padding::pad(input.data(),
static_cast<std::size_t
>(nbRead), Cipher::getBlockSize());
141 cipher.cipher(input, output);
142 return Cipher::getBlockSize();
145 template<
typename Cipher,
typename Padding>
148 std::array<uint8_t,Cipher::getBlockSize()>&,
149 std::streamsize nbRead,
151 std::array<uint8_t,Cipher::getBlockSize()>& output,
152 uint32_t, Cipher&
cipher) {
153 if(lastBlock &&
static_cast<std::size_t
>(nbRead) != Cipher::getBlockSize()) {
156 cipher.decipher(input, output);
158 return Padding::length(output.data(), Cipher::getBlockSize());
160 return Cipher::getBlockSize();
164 template<
typename Cipher,
typename Padding>
165 const std::array<uint8_t,Cipher::getBlockSize()>&
BlockCipherModeOfOperation(bool cipherParallelizable, bool decipherParallelizable, unsigned int nbThread=1)
Definition bcModOp.hpp:269
void cipher(std::istream &input, std::ostream &output, const std::string &key)
Definition bcModOp.hpp:300
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:147
ECB(unsigned int nbThread=1)
Definition ecb.hpp:116
virtual ~ECB()
Definition ecb.hpp:125
virtual const std::array< uint8_t, Cipher::getBlockSize()> & reset()
Definition ecb.hpp:166
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:134
Exception on receiving an invalid block.
Definition invalidBlockException.hpp:38
Cryptography namespace.
Definition base64.hpp:28
AnCH framework base namespace.
Definition app.hpp:28