diff options
author | lloyd <[email protected]> | 2009-10-14 23:23:29 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-10-14 23:23:29 +0000 |
commit | 1d54dbb30e97097ef74b302032430a97e56fb328 (patch) | |
tree | 1f417d6a51a48ec1700e974d0e3c4e0a90d6191f /src/modes | |
parent | 01ea6faf1b9fb3ccd7233b1117e09c642c22d238 (diff) |
Similiar treatment for OFB which is also just a plain stream cipher
Diffstat (limited to 'src/modes')
-rw-r--r-- | src/modes/ofb/info.txt | 14 | ||||
-rw-r--r-- | src/modes/ofb/ofb.cpp | 66 | ||||
-rw-r--r-- | src/modes/ofb/ofb.h | 33 |
3 files changed, 0 insertions, 113 deletions
diff --git a/src/modes/ofb/info.txt b/src/modes/ofb/info.txt deleted file mode 100644 index 3cba4151e..000000000 --- a/src/modes/ofb/info.txt +++ /dev/null @@ -1,14 +0,0 @@ -realname "OFB block cipher mode" - -define OFB - -load_on auto - -<add> -ofb.cpp -ofb.h -</add> - -<requires> -block -</requires> diff --git a/src/modes/ofb/ofb.cpp b/src/modes/ofb/ofb.cpp deleted file mode 100644 index cb40fdeaa..000000000 --- a/src/modes/ofb/ofb.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* -* OFB Mode -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/ofb.h> -#include <botan/xor_buf.h> -#include <algorithm> - -namespace Botan { - -/* -* OFB Constructor -*/ -OFB::OFB(BlockCipher* ciph) : - BlockCipherMode(ciph, "OFB", ciph->BLOCK_SIZE, 2) - { - } - -/* -* OFB Constructor -*/ -OFB::OFB(BlockCipher* ciph, const SymmetricKey& key, - const InitializationVector& iv) : - BlockCipherMode(ciph, "OFB", ciph->BLOCK_SIZE, 2) - { - set_key(key); - set_iv(iv); - } - -/* -* OFB Encryption/Decryption -*/ -void OFB::write(const byte input[], u32bit length) - { - u32bit copied = std::min(BLOCK_SIZE - position, length); - xor_buf(buffer, input, state + position, copied); - send(buffer, copied); - input += copied; - length -= copied; - position += copied; - - if(position == BLOCK_SIZE) - { - cipher->encrypt(state); - position = 0; - } - - while(length >= BLOCK_SIZE) - { - xor_buf(buffer, input, state, BLOCK_SIZE); - send(buffer, BLOCK_SIZE); - - input += BLOCK_SIZE; - length -= BLOCK_SIZE; - cipher->encrypt(state); - } - - xor_buf(buffer, input, state + position, length); - send(buffer, length); - position += length; - } - -} diff --git a/src/modes/ofb/ofb.h b/src/modes/ofb/ofb.h deleted file mode 100644 index a3aadc137..000000000 --- a/src/modes/ofb/ofb.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -* OFB Mode -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_OUTPUT_FEEDBACK_MODE_H__ -#define BOTAN_OUTPUT_FEEDBACK_MODE_H__ - -#include <botan/modebase.h> -#include <botan/block_cipher.h> - -namespace Botan { - -/* -* OFB Mode -*/ -class BOTAN_DLL OFB : public BlockCipherMode - { - public: - OFB(BlockCipher* cipher); - - OFB(BlockCipher* cipher, - const SymmetricKey& key, - const InitializationVector& iv); - private: - void write(const byte[], u32bit); - }; - -} - -#endif |