Botan 1.10.17

ecb.h
Go to the documentation of this file.
1 /*
2 * ECB Mode
3 * (C) 1999-2009 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #ifndef BOTAN_ECB_H__
9 #define BOTAN_ECB_H__
10
11 #include <botan/block_cipher.h>
12 #include <botan/mode_pad.h>
13 #include <botan/key_filt.h>
14 #include <botan/buf_filt.h>
15
16 namespace Botan {
17
18 /**
19 * ECB Encryption
20 */
21 class BOTAN_DLL ECB_Encryption : public Keyed_Filter,
22 private Buffered_Filter
23 {
24 public:
25 std::string name() const;
26
27 void set_key(const SymmetricKey& key) { cipher->set_key(key); }
28
29 bool valid_keylength(size_t key_len) const
30 { return cipher->valid_keylength(key_len); }
31
32 ECB_Encryption(BlockCipher* ciph,
33 BlockCipherModePaddingMethod* pad);
34
35 ECB_Encryption(BlockCipher* ciph,
36 BlockCipherModePaddingMethod* pad,
37 const SymmetricKey& key);
38
39 ~ECB_Encryption();
40 private:
41 void buffered_block(const byte input[], size_t input_length);
42 void buffered_final(const byte input[], size_t input_length);
43
44 void write(const byte input[], size_t input_length);
45 void end_msg();
46
47 BlockCipher* cipher;
48 BlockCipherModePaddingMethod* padder;
49 SecureVector<byte> temp;
50 };
51
52 /**
53 * ECB Decryption
54 */
55 class BOTAN_DLL ECB_Decryption : public Keyed_Filter,
56 public Buffered_Filter
57 {
58 public:
59 std::string name() const;
60
61 void set_key(const SymmetricKey& key) { cipher->set_key(key); }
62
63 bool valid_keylength(size_t key_len) const
64 { return cipher->valid_keylength(key_len); }
65
66 ECB_Decryption(BlockCipher* ciph,
67 BlockCipherModePaddingMethod* pad);
68
69 ECB_Decryption(BlockCipher* ciph,
70 BlockCipherModePaddingMethod* pad,
71 const SymmetricKey& key);
72
73 ~ECB_Decryption();
74 private:
75 void buffered_block(const byte input[], size_t input_length);
76 void buffered_final(const byte input[], size_t input_length);
77
78 void write(const byte input[], size_t input_length);
79 void end_msg();
80
81 BlockCipher* cipher;
82 BlockCipherModePaddingMethod* padder;
83 SecureVector<byte> temp;
84 };
85
86 }
87
88 #endif
Botan::Buffered_Filter
Definition: buf_filt.h:19
Botan::OctetString
Definition: symkey.h:19
Botan::Keyed_Filter
Definition: key_filt.h:20
Botan::ECB_Encryption::valid_keylength
bool valid_keylength(size_t key_len) const
Definition: ecb.h:29
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::ECB_Decryption
Definition: ecb.h:55
Botan::ECB_Encryption
Definition: ecb.h:21
Botan::ECB_Encryption::set_key
void set_key(const SymmetricKey &key)
Definition: ecb.h:27
Botan
Definition: algo_base.h:14
Botan::BlockCipherModePaddingMethod
Definition: mode_pad.h:25
Botan::ECB_Decryption::valid_keylength
bool valid_keylength(size_t key_len) const
Definition: ecb.h:63
Botan::ECB_Decryption::set_key
void set_key(const SymmetricKey &key)
Definition: ecb.h:61
Botan::SecureVector< byte >
Botan::BlockCipher
Definition: block_cipher.h:18