aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/modes/cipher_mode.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-02-05 08:04:08 +0000
committerlloyd <[email protected]>2015-02-05 08:04:08 +0000
commitcb8606277d4b2f5ef1cf33e3d24b982ce1286373 (patch)
tree69acbc7a789268d498a06b655c77742228a30e83 /src/lib/modes/cipher_mode.h
parentcb0f83ae63c4555cbdd0607e3a5f6e9260c0d19c (diff)
Move Cipher_Mode enum out of types.h, move stream cipher mode to new header
Diffstat (limited to 'src/lib/modes/cipher_mode.h')
-rw-r--r--src/lib/modes/cipher_mode.h50
1 files changed, 5 insertions, 45 deletions
diff --git a/src/lib/modes/cipher_mode.h b/src/lib/modes/cipher_mode.h
index 19c0af150..110053489 100644
--- a/src/lib/modes/cipher_mode.h
+++ b/src/lib/modes/cipher_mode.h
@@ -26,51 +26,11 @@ class BOTAN_DLL Cipher_Mode : public Keyed_Transform
virtual bool authenticated() const { return false; }
};
-class BOTAN_DLL Stream_Cipher_Mode : public Cipher_Mode
- {
- public:
- Stream_Cipher_Mode(StreamCipher* cipher) : m_cipher(cipher) {}
-
- void update(secure_vector<byte>& buf, size_t offset) override
- {
- if(offset < buf.size())
- m_cipher->cipher1(&buf[offset], buf.size() - offset);
- }
-
- void finish(secure_vector<byte>& buf, size_t offset) override
- { return update(buf, offset); }
-
- size_t output_length(size_t input_length) const override { return input_length; }
-
- size_t update_granularity() const override { return 64; /* arbitrary */ }
-
- size_t minimum_final_size() const override { return 0; }
-
- size_t default_nonce_length() const override { return 0; }
-
- bool valid_nonce_length(size_t nonce_len) const override
- { return m_cipher->valid_iv_length(nonce_len); }
-
- Key_Length_Specification key_spec() const override { return m_cipher->key_spec(); }
-
- std::string name() const override { return m_cipher->name(); }
-
- void clear() override { return m_cipher->clear(); }
-
- private:
- secure_vector<byte> start_raw(const byte nonce[], size_t nonce_len) override
- {
- m_cipher->set_iv(nonce, nonce_len);
- return secure_vector<byte>();
- }
-
- void key_schedule(const byte key[], size_t length)
- {
- m_cipher->set_key(key, length);
- }
-
- std::unique_ptr<StreamCipher> m_cipher;
- };
+/**
+* The two possible directions for cipher filters, determining whether they
+* actually perform encryption or decryption.
+*/
+enum Cipher_Dir { ENCRYPTION, DECRYPTION };
BOTAN_DLL Cipher_Mode* get_cipher_mode(const std::string& algo_spec, Cipher_Dir direction);