Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | List of all members
Botan::StreamCipher_Filter Class Reference

`#include <filters.h>`

Inheritance diagram for Botan::StreamCipher_Filter:

## Public Member Functions
virtual bool | attachable ()
virtual void | end_msg ()
Key_Length_Specification | key_spec () const override
std::string | name () const override
void | set_iv (const InitializationVector &iv) override
void | set_key (const SymmetricKey &key) override
virtual void | start_msg ()
| StreamCipher_Filter (StreamCipher *cipher)
| StreamCipher_Filter (StreamCipher *cipher, const SymmetricKey &key)
| StreamCipher_Filter (const std::string &cipher)
| StreamCipher_Filter (const std::string &cipher, const SymmetricKey &key)
bool | valid_iv_length (size_t iv_len) const override
bool | valid_keylength (size_t length) const
void | write (const uint8_t input[], size_t input_len) override

## Protected Member Functions
virtual void | send (const uint8_t in[], size_t length)
void | send (uint8_t in)
void | send (const secure_vector< uint8_t > &in)
void | send (const std::vector< uint8_t > &in)
void | send (const secure_vector< uint8_t > &in, size_t length)
void | send (const std::vector< uint8_t > &in, size_t length)

## Detailed Description

Stream Cipher Filter

Definition at line 31 of file filters.h.

## Constructor & Destructor Documentation

Botan::StreamCipher_Filter::StreamCipher_Filter | ( | StreamCipher * | cipher | ) |
| explicit

Construct a stream cipher filter.

Parameters

  cipher | a cipher object to use

Definition at line 13 of file algo_filt.cpp.

13 :
14 m_buffer(DEFAULT_BUFFERSIZE),
15 m_cipher(cipher)
16 {
17 }

Botan::StreamCipher_Filter::StreamCipher_Filter | ( | StreamCipher * | cipher,
|  | const SymmetricKey & | key
| ) |  |

Construct a stream cipher filter.

Parameters

  cipher | a cipher object to use
  key | the key to use inside this filter

Definition at line 19 of file algo_filt.cpp.

19 :
20 m_buffer(DEFAULT_BUFFERSIZE),
21 m_cipher(cipher)
22 {
23 m_cipher->set_key(key);
24 }

Botan::StreamCipher_Filter::StreamCipher_Filter | ( | const std::string & | cipher | ) |
| explicit

Construct a stream cipher filter.

Parameters

  cipher | the name of the desired cipher

Definition at line 26 of file algo_filt.cpp.

26 :
27 m_buffer(DEFAULT_BUFFERSIZE),
28 m_cipher(StreamCipher::create_or_throw(sc_name))
29 {
30 }
Botan::StreamCipher::create_or_throw
static std::unique_ptr< StreamCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: stream_cipher.cpp:123

Botan::StreamCipher_Filter::StreamCipher_Filter | ( | const std::string & | cipher,
|  | const SymmetricKey & | key
| ) |  |

Construct a stream cipher filter.

Parameters

  cipher | the name of the desired cipher
  key | the key to use inside this filter

Definition at line 32 of file algo_filt.cpp.

32 :
33 m_buffer(DEFAULT_BUFFERSIZE),
34 m_cipher(StreamCipher::create_or_throw(sc_name))
35 {
36 m_cipher->set_key(key);
37 }
Botan::StreamCipher::create_or_throw
static std::unique_ptr< StreamCipher > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: stream_cipher.cpp:123

## Member Function Documentation

virtual bool Botan::Filter::attachable | ( |  | ) |
| inline virtual inherited

Check whether this filter is an attachable filter.

Returns
  true if this filter is attachable, false otherwise

Reimplemented in Botan::SecureQueue, and Botan::DataSink.

Definition at line 52 of file filter.h.

52 { return true; }

virtual void Botan::Filter::end_msg | ( |  | ) |
| inline virtual inherited

Notify that the current message is finished; flush buffers and do end-of-message processing (if any).

Reimplemented in Botan::MAC_Filter, Botan::Hash_Filter, Botan::Base64_Decoder, Botan::Hex_Decoder, Botan::Base64_Encoder, and Botan::Hex_Encoder.

Definition at line 46 of file filter.h.

46 {}

Key_Length_Specification Botan::StreamCipher_Filter::key_spec | ( |  | ) | const
| inline override virtual

Returns
  object describing limits on key size

Implements Botan::Keyed_Filter.

Definition at line 62 of file filters.h.

62 { return m_cipher->key_spec(); }

std::string Botan::StreamCipher_Filter::name | ( |  | ) | const
| inline override virtual

Returns
  descriptive name for this filter

Implements Botan::Filter.

Definition at line 35 of file filters.h.

35 { return m_cipher->name(); }

void Botan::Filter::send | ( | const uint8_t | in[],
|  | size_t | length
| ) |  |
| protected virtual inherited

Parameters

  in | some input for the filter
  length | the length of in

Definition at line 27 of file filter.cpp.

References Botan::Filter::write().

Referenced by Botan::Hex_Encoder::end_msg(), Botan::Base64_Encoder::end_msg(), Botan::Hex_Decoder::end_msg(), Botan::Base64_Decoder::end_msg(), Botan::Hash_Filter::end_msg(), Botan::MAC_Filter::end_msg(), write(), Botan::Hex_Decoder::write(), and Botan::Base64_Decoder::write().

28 {
29 if(!length)
30 return;
31
32 bool nothing_attached = true;
33 for(size_t j = 0; j != total_ports(); ++j)
34 if(m_next[j])
35 {
36 if(m_write_queue.size())
37 m_next[j]->write(m_write_queue.data(), m_write_queue.size());
38 m_next[j]->write(input, length);
39 nothing_attached = false;
40 }
41
42 if(nothing_attached)
43 m_write_queue += std::make_pair(input, length);
44 else
45 m_write_queue.clear();
46 }
Botan::Filter::write
virtual void write(const uint8_t input[], size_t length)=0

void Botan::Filter::send | ( | uint8_t | in | ) |
| inline protected inherited

Parameters

  in | some input for the filter

Definition at line 65 of file filter.h.

References Botan::Filter::send().

Referenced by Botan::Filter::send().

65 { send(&in, 1); }
Botan::Filter::send
virtual void send(const uint8_t in[], size_t length)
Definition: filter.cpp:27

void Botan::Filter::send | ( | const secure_vector< uint8_t > & | in | ) |
| inline protected inherited

Parameters

  in | some input for the filter

Definition at line 70 of file filter.h.

References Botan::Filter::send().

Referenced by Botan::Filter::send().

70 { send(in.data(), in.size()); }
Botan::Filter::send
virtual void send(const uint8_t in[], size_t length)
Definition: filter.cpp:27

void Botan::Filter::send | ( | const std::vector< uint8_t > & | in | ) |
| inline protected inherited

Parameters

  in | some input for the filter

Definition at line 75 of file filter.h.

References Botan::Filter::send().

Referenced by Botan::Filter::send().

75 { send(in.data(), in.size()); }
Botan::Filter::send
virtual void send(const uint8_t in[], size_t length)
Definition: filter.cpp:27

void Botan::Filter::send | ( | const secure_vector< uint8_t > & | in,
|  | size_t | length
| ) |  |
| inline protected inherited

Parameters

  in | some input for the filter
  length | the number of bytes of in to send

Definition at line 81 of file filter.h.

82 {
83 send(in.data(), length);
84 }
Botan::Filter::send
virtual void send(const uint8_t in[], size_t length)
Definition: filter.cpp:27

void Botan::Filter::send | ( | const std::vector< uint8_t > & | in,
|  | size_t | length
| ) |  |
| inline protected inherited

Parameters

  in | some input for the filter
  length | the number of bytes of in to send

Definition at line 90 of file filter.h.

91 {
92 send(in.data(), length);
93 }
Botan::Filter::send
virtual void send(const uint8_t in[], size_t length)
Definition: filter.cpp:27

void Botan::StreamCipher_Filter::set_iv | ( | const InitializationVector & | iv | ) |
| inline override virtual

Set the initialization vector for this filter.

Parameters

  iv | the initialization vector to set

Reimplemented from Botan::Keyed_Filter.

Definition at line 51 of file filters.h.

References Botan::OctetString::begin(), and Botan::OctetString::length().

52 {
53 m_cipher->set_iv(iv.begin(), iv.length());
54 }

void Botan::StreamCipher_Filter::set_key | ( | const SymmetricKey & | key | ) |
| inline override virtual

Set the key of this filter.

Parameters

  key | the key to set

Implements Botan::Keyed_Filter.

Definition at line 60 of file filters.h.

60 { m_cipher->set_key(key); }

virtual void Botan::Filter::start_msg | ( |  | ) |
| inline virtual inherited

Start a new message. Must be closed by end_msg() before another message can be started.

Definition at line 40 of file filter.h.

40 {}

bool Botan::StreamCipher_Filter::valid_iv_length | ( | size_t | length | ) | const
| inline override virtual

Check whether an IV length is valid for this filter

Parameters

  length | the IV length to be checked for validity

Returns
  true if the IV length is valid, false otherwise

Reimplemented from Botan::Keyed_Filter.

Definition at line 44 of file filters.h.

45 { return m_cipher->valid_iv_length(iv_len); }

bool Botan::Keyed_Filter::valid_keylength | ( | size_t | length | ) | const
| inline inherited

Check whether a key length is valid for this filter

Parameters

  length | the key length to be checked for validity

Returns
  true if the key length is valid, false otherwise

Definition at line 42 of file key_filt.h.

43 {
44 return key_spec().valid_keylength(length);
45 }
Botan::Key_Length_Specification::valid_keylength
bool valid_keylength(size_t length) const
Definition: key_spec.h:51
Botan::Keyed_Filter::key_spec
virtual Key_Length_Specification key_spec() const =0

void Botan::StreamCipher_Filter::write | ( | const uint8_t | input[],
|  | size_t | input_len
| ) |  |
| override virtual

Write input data

Parameters

  input | data
  input_len | length of input in bytes

Implements Botan::Filter.

Definition at line 39 of file algo_filt.cpp.

References Botan::Filter::send().

40 {
41 while(length)
42 {
43 size_t copied = std::min<size_t>(length, m_buffer.size());
44 m_cipher->cipher(input, m_buffer.data(), copied);
45 send(m_buffer, copied);
46 input += copied;
47 length -= copied;
48 }
49 }
Botan::Filter::send
virtual void send(const uint8_t in[], size_t length)
Definition: filter.cpp:27

The documentation for this class was generated from the following files:

- src/lib/filters/filters.h
- src/lib/filters/algo_filt.cpp