22#include "crypto/cipher/bcModOp.hpp"
36 template<
typename Cipher>
42 std::array<uint8_t,Cipher::getBlockSize()> _initVect;
45 std::array<uint8_t,Cipher::getBlockSize()> _ctxtVect;
58 OFB(
const std::array<uint8_t,Cipher::getBlockSize()>& initVect,
unsigned int nbThread = 1);
83 virtual std::size_t
cipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
84 std::streamsize nbRead,
85 std::array<uint8_t,Cipher::getBlockSize()>& output,
86 uint32_t, Cipher&
cipher)
override;
99 virtual std::size_t
decipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
100 std::array<uint8_t,Cipher::getBlockSize()>&,
101 std::streamsize nbRead,
103 std::array<uint8_t,Cipher::getBlockSize()>& output,
104 uint32_t, Cipher&
cipher)
override;
111 virtual const std::array<uint8_t,Cipher::getBlockSize()>&
reset();
117 template<
typename Cipher>
118 OFB<Cipher>::OFB(
const std::array<uint8_t,Cipher::getBlockSize()>& initVect,
unsigned int nbThread):
128 template<
typename Cipher>
136 template<
typename Cipher>
139 std::streamsize nbRead,
140 std::array<uint8_t,Cipher::getBlockSize()>& output,
141 uint32_t, Cipher&
cipher) {
142 std::array<uint8_t,Cipher::getBlockSize()> data;
143 cipher.cipher(_ctxtVect, data);
144 for(std::size_t i = 0 ; i < static_cast<std::size_t>(nbRead) ; ++i) {
145 output[i] = input[i] ^ data[i];
146 _ctxtVect[i] = data[i];
148 return static_cast<std::size_t
>(nbRead);
151 template<
typename Cipher>
154 std::array<uint8_t,Cipher::getBlockSize()>&,
155 std::streamsize nbRead,
157 std::array<uint8_t,Cipher::getBlockSize()>& output,
158 uint32_t, Cipher&
cipher) {
159 std::array<uint8_t,Cipher::getBlockSize()> data;
160 cipher.cipher(_ctxtVect, data);
161 for(std::size_t i = 0 ; i < static_cast<std::size_t>(nbRead) ; ++i) {
162 output[i] = input[i] ^ data[i];
163 _ctxtVect[i] = data[i];
165 return static_cast<std::size_t
>(nbRead);
168 template<
typename Cipher>
169 const std::array<uint8_t,Cipher::getBlockSize()>&
171 _ctxtVect = _initVect;
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, std::array< uint8_t, Cipher::getBlockSize()> &output, uint32_t, Cipher &cipher) override
Definition ofb.hpp:153
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 ofb.hpp:138
OFB(const std::array< uint8_t, Cipher::getBlockSize()> &initVect, unsigned int nbThread=1)
Definition ofb.hpp:118
virtual const std::array< uint8_t, Cipher::getBlockSize()> & reset()
Definition ofb.hpp:170
virtual ~OFB()
Definition ofb.hpp:129
Cryptography namespace.
Definition base64.hpp:28
AnCH framework base namespace.
Definition app.hpp:28