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
14namespace Botan {
15
16/**
17* CFB Encryption
18*/
19class 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
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*/
53class 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
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
CFB_Decryption(BlockCipher *cipher, size_t feedback=0)
Definition cfb.cpp:95
std::string name() const
Definition cfb.h:56
bool valid_iv_length(size_t iv_len) const
Definition cfb.h:65
bool valid_keylength(size_t key_len) const
Definition cfb.h:62
void set_key(const SymmetricKey &key)
Definition cfb.h:60
std::string name() const
Definition cfb.h:22
void set_key(const SymmetricKey &key)
Definition cfb.h:26
bool valid_keylength(size_t key_len) const
Definition cfb.h:28
bool valid_iv_length(size_t iv_len) const
Definition cfb.h:31
CFB_Encryption(BlockCipher *cipher, size_t feedback=0)
Definition cfb.cpp:18
OctetString SymmetricKey
Definition symkey.h:147
OctetString InitializationVector
Definition symkey.h:152