|
Botan
1.11.15
|
#include <secqueue.h>
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 |
| SecureQueue & | operator= (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) |
A queue that knows how to zeroize itself
Definition at line 20 of file secqueue.h.
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;
}
| Botan::SecureQueue::SecureQueue | ( | const SecureQueue & | other | ) |
SecureQueue copy constructor
| other | the 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; } }
| Botan::SecureQueue::~SecureQueue | ( | ) | [inline] |
Definition at line 59 of file secqueue.h.
{ destroy(); }
| void Botan::Fanout_Filter::attach | ( | Filter * | f | ) | [inline, protected, inherited] |
Attach another filter to this one
| f | filter to attach |
Reimplemented from Botan::Filter.
Definition at line 164 of file filter.h.
Referenced by Botan::Chain::Chain().
{ Filter::attach(f); }
| bool Botan::SecureQueue::attachable | ( | ) | [inline, virtual] |
Check whether this filter is an attachable filter.
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
| N | the number of bytes to discard |
Definition at line 35 of file data_src.cpp.
References n, and Botan::DataSource::read_byte().
| bool Botan::SecureQueue::empty | ( | ) | const |
| 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.
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
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] |
Implements Botan::Filter.
Definition at line 23 of file secqueue.h.
{ return "Queue"; }
| SecureQueue & Botan::SecureQueue::operator= | ( | const SecureQueue & | other | ) |
SecureQueue assignment
| other | the 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.
| out | the byte array to write the output to |
| length | the length of the byte array out |
| peek_offset | the offset into the stream to read at |
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.
| out | an output byte |
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.
| out | the byte array to write the result to |
| length | the length of the byte array out |
Implements Botan::DataSource.
Definition at line 140 of file secqueue.cpp.
References n.
Referenced by Botan::Output_Buffers::read().
| size_t Botan::DataSource::read_byte | ( | byte & | out | ) | [inherited] |
Read one byte.
| out | the byte to read to |
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] |
| in | some input for the filter |
| length | the 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] |
| in | some 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] |
| in | some 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] |
| in | some 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] |
| void Botan::Filter::send | ( | const std::vector< byte > & | in, |
| size_t | length | ||
| ) | [inline, protected, inherited] |
| void Botan::Fanout_Filter::set_next | ( | Filter * | filters[], |
| size_t | count | ||
| ) | [inline, protected, inherited] |
| filters | the filters to set |
| count | number 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().
{ Filter::set_next(f, n); }
| void Botan::Fanout_Filter::set_port | ( | size_t | new_port | ) | [inline, protected, inherited] |
Set the active port
| new_port | the new value |
Reimplemented from Botan::Filter.
Reimplemented in Botan::Fork.
Definition at line 160 of file filter.h.
Referenced by Botan::Fork::set_port().
{ Filter::set_port(n); }
| size_t Botan::SecureQueue::size | ( | ) | const |
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.
| input | the input as a byte array |
| length | the length of the byte array input |
Implements Botan::Filter.
Definition at line 120 of file secqueue.cpp.
References n.
Referenced by operator=(), and SecureQueue().
1.7.6.1