20 #ifndef _ANCH_CRYPTO_OFB_H_    21 #define _ANCH_CRYPTO_OFB_H_    23 #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       OFB(
const std::array<uint8_t,Cipher::getBlockSize()>& initVect, 
unsigned int nbThread = 1):
    91       virtual std::size_t 
cipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
    92                                       std::streamsize nbRead,
    93                                       std::array<uint8_t,Cipher::getBlockSize()>& output,
    94                                       uint32_t, Cipher& 
cipher)
 override {
    95         std::array<uint8_t,Cipher::getBlockSize()> data;
    96         cipher.cipher(_ctxtVect, data);
    97         for(std::streamsize i = 0 ; i < nbRead ; ++i) {
    98           output[i] = input[i] ^ data[i];
    99           _ctxtVect[i] = data[i];
   115       virtual std::size_t 
decipherBlock(std::array<uint8_t,Cipher::getBlockSize()>& input,
   116                                         std::array<uint8_t,Cipher::getBlockSize()>&,
   117                                         std::streamsize nbRead,
   119                                         std::array<uint8_t,Cipher::getBlockSize()>& output,
   120                                         uint32_t, Cipher& 
cipher)
 override {
   121         std::array<uint8_t,Cipher::getBlockSize()> data;
   122         cipher.cipher(_ctxtVect, data);
   123         for(std::streamsize i = 0 ; i < nbRead ; ++i) {
   124           output[i] = input[i] ^ data[i];
   125           _ctxtVect[i] = data[i];
   135       virtual const std::array<uint8_t,Cipher::getBlockSize()>& 
reset() {
   136         _ctxtVect = _initVect;
   146 #endif // _ANCH_CRYPTO_OFB_H_ 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:115
 
virtual const std::array< uint8_t, Cipher::getBlockSize()> & reset()
Definition: ofb.hpp:135
 
AnCH framework base namespace. 
Definition: base64.hpp:28
 
void cipher(std::istream &input, std::ostream &output, const std::string &key)
Definition: bcModOp.hpp:133
 
virtual ~OFB()
Definition: ofb.hpp:72
 
Block cipher mode of operation interface. 
Definition: bcModOp.hpp:49
 
OFB(const std::array< uint8_t, Cipher::getBlockSize()> &initVect, unsigned int nbThread=1)
Definition: ofb.hpp:59
 
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:91
 
Output feedback implementation. 
Definition: ofb.hpp:38