Botan  1.11.15
Public Member Functions | Protected Member Functions
Botan::SecureQueue Class Reference

#include <secqueue.h>

Inheritance diagram for Botan::SecureQueue:
Botan::Fanout_Filter Botan::DataSource Botan::Filter

List of all members.

Public Member Functions

bool attachable ()
size_t discard_next (size_t N)
bool empty () const
virtual void end_msg ()
bool end_of_data () const
size_t get_bytes_read () const
virtual std::string id () const
std::string name () const
SecureQueueoperator= (const SecureQueue &other)
size_t peek (byte[], size_t, size_t=0) const
size_t peek_byte (byte &out) const
size_t read (byte[], size_t)
size_t read_byte (byte &out)
 SecureQueue ()
 SecureQueue (const SecureQueue &other)
size_t size () const
virtual void start_msg ()
void write (const byte[], size_t)
 ~SecureQueue ()

Protected Member Functions

void attach (Filter *f)
void incr_owns ()
virtual void send (const byte in[], size_t length)
void send (byte in)
void send (const secure_vector< byte > &in)
void send (const std::vector< byte > &in)
void send (const secure_vector< byte > &in, size_t length)
void send (const std::vector< byte > &in, size_t length)
void set_next (Filter *f[], size_t n)
void set_port (size_t n)

Detailed Description

A queue that knows how to zeroize itself

Definition at line 20 of file secqueue.h.


Constructor & Destructor Documentation

SecureQueue default constructor (creates empty queue)

Definition at line 61 of file secqueue.cpp.

References Botan::Fanout_Filter::set_next().

   {
   bytes_read = 0;
   set_next(nullptr, 0);
   head = tail = new SecureQueueNode;
   }

SecureQueue copy constructor

Parameters:
otherthe queue to copy

Definition at line 71 of file secqueue.cpp.

References Botan::Fanout_Filter::set_next(), and write().

                                                 :
   Fanout_Filter(), DataSource()
   {
   bytes_read = 0;
   set_next(nullptr, 0);

   head = tail = new SecureQueueNode;
   SecureQueueNode* temp = input.head;
   while(temp)
      {
      write(&temp->buffer[temp->start], temp->end - temp->start);
      temp = temp->next;
      }
   }

Definition at line 59 of file secqueue.h.

{ destroy(); }

Member Function Documentation

void Botan::Fanout_Filter::attach ( Filter f) [inline, protected, inherited]

Attach another filter to this one

Parameters:
ffilter to attach

Reimplemented from Botan::Filter.

Definition at line 164 of file filter.h.

Referenced by Botan::Chain::Chain().

bool Botan::SecureQueue::attachable ( ) [inline, virtual]

Check whether this filter is an attachable filter.

Returns:
true if this filter is attachable, false otherwise

Reimplemented from Botan::Filter.

Definition at line 40 of file secqueue.h.

{ return false; }
size_t Botan::DataSource::discard_next ( size_t  N) [inherited]

Discard the next N bytes of the data

Parameters:
Nthe number of bytes to discard
Returns:
number of bytes actually discarded

Definition at line 35 of file data_src.cpp.

References n, and Botan::DataSource::read_byte().

   {
   size_t discarded = 0;
   byte dummy;
   for(size_t j = 0; j != n; ++j)
      discarded += read_byte(dummy);
   return discarded;
   }
bool Botan::SecureQueue::empty ( ) const

Definition at line 223 of file secqueue.cpp.

References size().

   {
   return (size() == 0);
   }
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, Botan::Hex_Encoder, and Botan::Compression_Decompression_Filter.

Definition at line 46 of file filter.h.

{}
bool Botan::SecureQueue::end_of_data ( ) const [virtual]

Test whether the source still has data that can be read.

Returns:
true if there is still data to read, false otherwise

Implements Botan::DataSource.

Definition at line 218 of file secqueue.cpp.

References size().

   {
   return (size() == 0);
   }
size_t Botan::SecureQueue::get_bytes_read ( ) const [virtual]

Return how many bytes have been read so far.

Implements Botan::DataSource.

Definition at line 194 of file secqueue.cpp.

Referenced by Botan::Output_Buffers::get_bytes_read().

   {
   return bytes_read;
   }
virtual std::string Botan::DataSource::id ( ) const [inline, virtual, inherited]

return the id of this data source

Returns:
std::string representing the id of this data source

Reimplemented in Botan::DataSource_Stream.

Definition at line 58 of file data_src.h.

{ return ""; }
void Botan::Fanout_Filter::incr_owns ( ) [inline, protected, inherited]

Increment the number of filters past us that we own

Definition at line 158 of file filter.h.

Referenced by Botan::Chain::Chain().

{ ++filter_owns; }
std::string Botan::SecureQueue::name ( ) const [inline, virtual]
Returns:
descriptive name for this filter

Implements Botan::Filter.

Definition at line 23 of file secqueue.h.

{ return "Queue"; }
SecureQueue & Botan::SecureQueue::operator= ( const SecureQueue other)

SecureQueue assignment

Parameters:
otherthe queue to copy

Definition at line 104 of file secqueue.cpp.

References write().

   {
   destroy();
   head = tail = new SecureQueueNode;
   SecureQueueNode* temp = input.head;
   while(temp)
      {
      write(&temp->buffer[temp->start], temp->end - temp->start);
      temp = temp->next;
      }
   return (*this);
   }
size_t Botan::SecureQueue::peek ( byte  out[],
size_t  length,
size_t  peek_offset = 0 
) const [virtual]

Read from the source but do not modify the internal offset. Consecutive calls to peek() will return portions of the source starting at the same position.

Parameters:
outthe byte array to write the output to
lengththe length of the byte array out
peek_offsetthe offset into the stream to read at
Returns:
length in bytes that was actually read and put into out

Implements Botan::DataSource.

Definition at line 163 of file secqueue.cpp.

References n.

Referenced by Botan::Output_Buffers::peek().

   {
   SecureQueueNode* current = head;

   while(offset && current)
      {
      if(offset >= current->size())
         {
         offset -= current->size();
         current = current->next;
         }
      else
         break;
      }

   size_t got = 0;
   while(length && current)
      {
      const size_t n = current->peek(output, length, offset);
      offset = 0;
      output += n;
      got += n;
      length -= n;
      current = current->next;
      }
   return got;
   }
size_t Botan::DataSource::peek_byte ( byte out) const [inherited]

Peek at one byte.

Parameters:
outan output byte
Returns:
length in bytes that was actually read and put into out

Definition at line 27 of file data_src.cpp.

References Botan::DataSource::peek().

Referenced by Botan::ASN1::maybe_BER().

   {
   return peek(&out, 1, 0);
   }
size_t Botan::SecureQueue::read ( byte  out[],
size_t  length 
) [virtual]

Read from the source. Moves the internal offset so that every call to read will return a new portion of the source.

Parameters:
outthe byte array to write the result to
lengththe length of the byte array out
Returns:
length in bytes that was actually read and put into out

Implements Botan::DataSource.

Definition at line 140 of file secqueue.cpp.

References n.

Referenced by Botan::Output_Buffers::read().

   {
   size_t got = 0;
   while(length && head)
      {
      const size_t n = head->read(output, length);
      output += n;
      got += n;
      length -= n;
      if(head->size() == 0)
         {
         SecureQueueNode* holder = head->next;
         delete head;
         head = holder;
         }
      }
   bytes_read += got;
   return got;
   }
size_t Botan::DataSource::read_byte ( byte out) [inherited]

Read one byte.

Parameters:
outthe byte to read to
Returns:
length in bytes that was actually read and put into out

Definition at line 19 of file data_src.cpp.

References Botan::DataSource::read().

Referenced by Botan::PEM_Code::decode(), Botan::DataSource::discard_next(), Botan::BER_Decoder::discard_remaining(), Botan::PGP_decode(), and Botan::BER_Decoder::raw_bytes().

   {
   return read(&out, 1);
   }
void Botan::Filter::send ( const byte  in[],
size_t  length 
) [protected, virtual, inherited]
Parameters:
insome input for the filter
lengththe length of in

Reimplemented in Botan::Threaded_Fork.

Definition at line 28 of file filter.cpp.

References Botan::Filter::write().

Referenced by Botan::Compression_Decompression_Filter::end_msg(), 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(), Botan::Compression_Decompression_Filter::flush(), Botan::Compression_Decompression_Filter::start_msg(), Botan::Compression_Decompression_Filter::write(), Botan::StreamCipher_Filter::write(), Botan::Hex_Decoder::write(), and Botan::Base64_Decoder::write().

   {
   if(!length)
      return;

   bool nothing_attached = true;
   for(size_t j = 0; j != total_ports(); ++j)
      if(next[j])
         {
         if(write_queue.size())
            next[j]->write(&write_queue[0], write_queue.size());
         next[j]->write(input, length);
         nothing_attached = false;
         }

   if(nothing_attached)
      write_queue += std::make_pair(input, length);
   else
      write_queue.clear();
   }
void Botan::Filter::send ( byte  in) [inline, protected, inherited]
Parameters:
insome input for the filter

Definition at line 65 of file filter.h.

References Botan::Filter::send().

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

{ send(&in, 1); }
void Botan::Filter::send ( const secure_vector< byte > &  in) [inline, protected, inherited]
Parameters:
insome input for the filter

Definition at line 70 of file filter.h.

References Botan::Filter::send().

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

{ send(&in[0], in.size()); }
void Botan::Filter::send ( const std::vector< byte > &  in) [inline, protected, inherited]
Parameters:
insome input for the filter

Definition at line 75 of file filter.h.

References Botan::Filter::send().

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

{ send(&in[0], in.size()); }
void Botan::Filter::send ( const secure_vector< byte > &  in,
size_t  length 
) [inline, protected, inherited]
Parameters:
insome input for the filter
lengththe number of bytes of in to send

Definition at line 81 of file filter.h.

         {
         send(&in[0], length);
         }
void Botan::Filter::send ( const std::vector< byte > &  in,
size_t  length 
) [inline, protected, inherited]
Parameters:
insome input for the filter
lengththe number of bytes of in to send

Definition at line 90 of file filter.h.

         {
         send(&in[0], length);
         }
void Botan::Fanout_Filter::set_next ( Filter filters[],
size_t  count 
) [inline, protected, inherited]
Parameters:
filtersthe filters to set
countnumber of items in filters

Reimplemented from Botan::Filter.

Reimplemented in Botan::Threaded_Fork.

Definition at line 162 of file filter.h.

Referenced by Botan::Fork::Fork(), and SecureQueue().

void Botan::Fanout_Filter::set_port ( size_t  new_port) [inline, protected, inherited]

Set the active port

Parameters:
new_portthe new value

Reimplemented from Botan::Filter.

Reimplemented in Botan::Fork.

Definition at line 160 of file filter.h.

Referenced by Botan::Fork::set_port().

size_t Botan::SecureQueue::size ( ) const
Returns:
number of bytes available in the queue

Definition at line 202 of file secqueue.cpp.

Referenced by empty(), end_of_data(), and Botan::Output_Buffers::remaining().

   {
   SecureQueueNode* current = head;
   size_t count = 0;

   while(current)
      {
      count += current->size();
      current = current->next;
      }
   return count;
   }
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.

Reimplemented in Botan::Compression_Decompression_Filter.

Definition at line 40 of file filter.h.

{}
void Botan::SecureQueue::write ( const byte  input[],
size_t  length 
) [virtual]

Write a portion of a message to this filter.

Parameters:
inputthe input as a byte array
lengththe length of the byte array input

Implements Botan::Filter.

Definition at line 120 of file secqueue.cpp.

References n.

Referenced by operator=(), and SecureQueue().

   {
   if(!head)
      head = tail = new SecureQueueNode;
   while(length)
      {
      const size_t n = tail->write(input, length);
      input += n;
      length -= n;
      if(length)
         {
         tail->next = new SecureQueueNode;
         tail = tail->next;
         }
      }
   }

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