Botan 1.10.17

cfb.h
Go to the documentation of this file.
1 /*
2 * CFB Mode
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_CFB_H__
9 #define BOTAN_CFB_H__
10
11 #include <botan/block_cipher.h>
12 #include <botan/key_filt.h>
13
14 namespace Botan {
15
16 /**
17 * CFB Encryption
18 */
19 class BOTAN_DLL CFB_Encryption : public Keyed_Filter
20 {
21 public:
22 std::string name() const { return cipher->name() + "/CFB"; }
23
24 void set_iv(const InitializationVector&);
25
26 void set_key(const SymmetricKey& key) { cipher->set_key(key); }
27
28 bool valid_keylength(size_t key_len) const
29 { return cipher->valid_keylength(key_len); }
30
31 bool valid_iv_length(size_t iv_len) const
32 { return (iv_len == cipher->block_size()); }
33
34 CFB_Encryption(BlockCipher* cipher, size_t feedback = 0);
35
36 CFB_Encryption(BlockCipher* cipher,
37 const SymmetricKey& key,
38 const InitializationVector& iv,
39 size_t feedback = 0);
40
41 ~CFB_Encryption() { delete cipher; }
42 private:
43 void write(const byte[], size_t);
44
45 BlockCipher* cipher;
46 SecureVector<byte> buffer, state;
47 size_t position, feedback;
48 };
49
50 /**
51 * CFB Decryption
52 */
53 class BOTAN_DLL CFB_Decryption : public Keyed_Filter
54 {
55 public:
56 std::string name() const { return cipher->name() + "/CFB"; }
57
58 void set_iv(const InitializationVector&);
59
60 void set_key(const SymmetricKey& key) { cipher->set_key(key); }
61
62 bool valid_keylength(size_t key_len) const
63 { return cipher->valid_keylength(key_len); }
64
65 bool valid_iv_length(size_t iv_len) const
66 { return (iv_len == cipher->block_size()); }
67
68 CFB_Decryption(BlockCipher* cipher, size_t feedback = 0);
69
70 CFB_Decryption(BlockCipher* cipher,
71 const SymmetricKey& key,
72 const InitializationVector& iv,
73 size_t feedback = 0);
74
75 ~CFB_Decryption() { delete cipher; }
76 private:
77 void write(const byte[], size_t);
78
79 BlockCipher* cipher;
80 SecureVector<byte> buffer, state;
81 size_t position, feedback;
82 };
83
84 }
85
86 #endif
Botan::CFB_Encryption::valid_keylength
bool valid_keylength(size_t key_len) const
Definition: cfb.h:28
Botan::OctetString
Definition: symkey.h:19
Botan::CFB_Encryption::name
std::string name() const
Definition: cfb.h:22
Botan::Keyed_Filter
Definition: key_filt.h:20
Botan::CFB_Decryption::set_key
void set_key(const SymmetricKey &key)
Definition: cfb.h:60
Botan::CFB_Decryption::name
std::string name() const
Definition: cfb.h:56
Botan::CFB_Encryption::~CFB_Encryption
~CFB_Encryption()
Definition: cfb.h:41
Botan::byte
unsigned char byte
Definition: types.h:22
Botan
Definition: algo_base.h:14
Botan::CFB_Decryption::valid_keylength
bool valid_keylength(size_t key_len) const
Definition: cfb.h:62
Botan::CFB_Encryption::valid_iv_length
bool valid_iv_length(size_t iv_len) const
Definition: cfb.h:31
Botan::CFB_Decryption::~CFB_Decryption
~CFB_Decryption()
Definition: cfb.h:75
Botan::CFB_Decryption
Definition: cfb.h:53
Botan::CFB_Encryption::set_key
void set_key(const SymmetricKey &key)
Definition: cfb.h:26
Botan::SecureVector< byte >
Botan::CFB_Encryption
Definition: cfb.h:19
Botan::CFB_Decryption::valid_iv_length
bool valid_iv_length(size_t iv_len) const
Definition: cfb.h:65
Botan::BlockCipher
Definition: block_cipher.h:18