Botan  1.10.9
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 
34 
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;
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 
68 
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;
83  SecureVector<byte> temp;
84  };
85 
86 }
87 
88 #endif
bool valid_keylength(size_t key_len) const
Definition: ecb.h:29
unsigned char byte
Definition: types.h:22
void set_key(const SymmetricKey &key)
Definition: ecb.h:27
bool valid_keylength(size_t key_len) const
Definition: ecb.h:63
void set_key(const SymmetricKey &key)
Definition: ecb.h:61