22#include "anch-crypto-export.hpp"
24#include "crypto/cipher/bcModOp.hpp"
37 template<
typename Cipher>
43 std::array<uint8_t,Cipher::getBlockSize()> _initVect;
46 std::array<uint8_t,Cipher::getBlockSize()> _ctxtVect;
59 CFB(
const std::array<uint8_t,Cipher::getBlockSize()>& initVect,
unsigned int nbThread = 1);
84 virtual std::size_t
cipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
85 std::streamsize nbRead,
86 std::array<uint8_t,Cipher::getBlockSize()>& output,
87 uint64_t, Cipher&
cipher)
override;
101 virtual std::size_t
decipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
102 std::array<uint8_t,Cipher::getBlockSize()>& prevInput,
103 std::streamsize nbRead,
105 std::array<uint8_t,Cipher::getBlockSize()>& output,
106 uint64_t, Cipher&
cipher)
override;
113 virtual const std::array<uint8_t,Cipher::getBlockSize()>&
reset()
override;
119 template<
typename Cipher>
120 CFB<Cipher>::CFB(
const std::array<uint8_t,Cipher::getBlockSize()>& initVect,
unsigned int nbThread):
130 template<
typename Cipher>
138 template<
typename Cipher>
141 std::streamsize nbRead,
142 std::array<uint8_t,Cipher::getBlockSize()>& output,
143 uint64_t, Cipher&
cipher) {
144 std::array<uint8_t,Cipher::getBlockSize()> data;
145 cipher.cipher(_ctxtVect, data);
146 for(std::size_t i = 0 ; i < static_cast<std::size_t>(nbRead) ; ++i) {
147 output[i] = input[i] ^ data[i];
148 _ctxtVect[i] = output[i];
150 return static_cast<std::size_t
>(nbRead);
153 template<
typename Cipher>
156 std::array<uint8_t,Cipher::getBlockSize()>& prevInput,
157 std::streamsize nbRead,
159 std::array<uint8_t,Cipher::getBlockSize()>& output,
160 uint64_t, Cipher&
cipher) {
161 std::array<uint8_t,Cipher::getBlockSize()> data;
162 cipher.cipher(prevInput, data);
163 for(std::size_t i = 0 ; i < static_cast<std::size_t>(nbRead) ; ++i) {
164 output[i] = data[i] ^ input[i];
166 return static_cast<std::size_t
>(nbRead);
169 template<
typename Cipher>
170 const std::array<uint8_t,Cipher::getBlockSize()>&
172 _ctxtVect = _initVect;
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
CFB(const std::array< uint8_t, Cipher::getBlockSize()> &initVect, unsigned int nbThread=1)
Definition cfb.hpp:120
virtual std::size_t decipherBlock(std::array< uint8_t, Cipher::getBlockSize()> &input, std::array< uint8_t, Cipher::getBlockSize()> &prevInput, std::streamsize nbRead, bool, std::array< uint8_t, Cipher::getBlockSize()> &output, uint64_t, Cipher &cipher) override
Definition cfb.hpp:155
virtual ~CFB()
Definition cfb.hpp:131
virtual const std::array< uint8_t, Cipher::getBlockSize()> & reset() override
Definition cfb.hpp:171
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 cfb.hpp:140
Cryptography namespace.
Definition base64.hpp:30