22#include "anch-crypto-export.hpp"
24#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);
81 virtual std::size_t
cipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
82 std::streamsize nbRead,
83 std::array<uint8_t,Cipher::getBlockSize()>& output,
84 uint64_t, Cipher&
cipher)
override;
98 virtual std::size_t
decipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
99 std::array<uint8_t,Cipher::getBlockSize()>&,
100 std::streamsize nbRead,
102 std::array<uint8_t,Cipher::getBlockSize()>& output,
103 uint64_t, Cipher&
cipher)
override;
110 virtual const std::array<uint8_t,Cipher::getBlockSize()>&
reset()
override;
116 template<
typename Cipher,
typename Padding>
125 template<
typename Cipher,
typename Padding>
133 template<
typename Cipher,
typename Padding>
136 std::streamsize nbRead,
137 std::array<uint8_t,Cipher::getBlockSize()>& output,
138 uint64_t, Cipher&
cipher) {
139 if(
static_cast<std::size_t
>(nbRead) != Cipher::getBlockSize()) {
140 Padding::pad(input.data(),
static_cast<std::size_t
>(nbRead), Cipher::getBlockSize());
142 cipher.cipher(input, output);
143 return Cipher::getBlockSize();
146 template<
typename Cipher,
typename Padding>
149 std::array<uint8_t,Cipher::getBlockSize()>&,
150 std::streamsize nbRead,
152 std::array<uint8_t,Cipher::getBlockSize()>& output,
153 uint64_t, Cipher&
cipher) {
154 if(lastBlock &&
static_cast<std::size_t
>(nbRead) != Cipher::getBlockSize()) {
157 cipher.decipher(input, output);
159 return Padding::length(output.data(), Cipher::getBlockSize());
161 return Cipher::getBlockSize();
165 template<
typename Cipher,
typename Padding>
166 const std::array<uint8_t,Cipher::getBlockSize()>&
BlockCipherModeOfOperation(bool cipherParallelizable, bool decipherParallelizable, unsigned int nbThread=1)
Definition bcModOp.hpp:273
void cipher(std::istream &input, std::ostream &output, const std::string &key)
Definition bcModOp.hpp:304
ECB(unsigned int nbThread=1)
Definition ecb.hpp:117
virtual ~ECB()
Definition ecb.hpp:126
virtual const std::array< uint8_t, Cipher::getBlockSize()> & reset() override
Definition ecb.hpp:167
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, uint64_t, Cipher &cipher) override
Definition ecb.hpp:148
virtual std::size_t cipherBlock(std::array< uint8_t, Cipher::getBlockSize()> &input, std::streamsize nbRead, std::array< uint8_t, Cipher::getBlockSize()> &output, uint64_t, Cipher &cipher) override
Definition ecb.hpp:135
InvalidBlockException(const std::string &message)
Cryptography namespace.
Definition base64.hpp:30