Botan 3.6.1
Crypto and TLS for C&
|
#include <pipe.h>
Classes | |
class | Invalid_Message_Number |
Public Types | |
typedef size_t | message_id |
Public Member Functions | |
void | append (Filter *filt) |
void | append_filter (Filter *filt) |
bool | check_available (size_t n) override |
bool | check_available_msg (size_t n, message_id msg) const |
size_t | default_msg () const |
size_t | discard_next (size_t N) |
void | end_msg () |
bool | end_of_data () const override |
size_t | get_bytes_read () const override |
size_t | get_bytes_read (message_id msg) const |
virtual std::string | id () const |
message_id | message_count () const |
Pipe & | operator= (const Pipe &)=delete |
size_t | peek (uint8_t &output, size_t offset, message_id msg=DEFAULT_MESSAGE) const |
size_t | peek (uint8_t output[], size_t length, size_t offset) const override |
size_t | peek (uint8_t output[], size_t length, size_t offset, message_id msg) const |
size_t | peek_byte (uint8_t &out) const |
Pipe (const Pipe &)=delete | |
Pipe (Filter *=nullptr, Filter *=nullptr, Filter *=nullptr, Filter *=nullptr) | |
Pipe (std::initializer_list< Filter * > filters) | |
void | pop () |
void | prepend (Filter *filt) |
void | prepend_filter (Filter *filt) |
void | process_msg (const secure_vector< uint8_t > &in) |
void | process_msg (const std::vector< uint8_t > &in) |
void | process_msg (const uint8_t in[], size_t length) |
void | process_msg (DataSource &in) |
void | process_msg (std::string_view in) |
size_t | read (uint8_t &output, message_id msg=DEFAULT_MESSAGE) |
size_t | read (uint8_t output[], size_t length) override |
size_t | read (uint8_t output[], size_t length, message_id msg) |
secure_vector< uint8_t > | read_all (message_id msg=DEFAULT_MESSAGE) |
std::string | read_all_as_string (message_id msg=DEFAULT_MESSAGE) |
size_t | read_byte (uint8_t &out) |
size_t | remaining (message_id msg=DEFAULT_MESSAGE) const |
void | reset () |
void | set_default_msg (message_id msg) |
void | start_msg () |
void | write (const secure_vector< uint8_t > &in) |
void | write (const std::vector< uint8_t > &in) |
void | write (const uint8_t in[], size_t length) |
void | write (DataSource &in) |
void | write (std::string_view in) |
void | write (uint8_t in) |
~Pipe () override | |
Static Public Attributes | |
static const message_id | DEFAULT_MESSAGE = static_cast<Pipe::message_id>(-1) |
static const message_id | LAST_MESSAGE = static_cast<Pipe::message_id>(-2) |
This class represents pipe objects. A set of filters can be placed into a pipe, and information flows through the pipe until it reaches the end, where the output is collected for retrieval. If you're familiar with the Unix shell environment, this design will sound quite familiar.
size_t Botan::Pipe::message_id |
Botan::Pipe::Pipe | ( | Filter * | f1 = nullptr, |
Filter * | f2 = nullptr, | ||
Filter * | f3 = nullptr, | ||
Filter * | f4 = nullptr ) |
Construct a Pipe of up to four filters. The filters are set up in the same order as the arguments.
Definition at line 38 of file pipe.cpp.
|
explicit |
Construct a Pipe from a list of filters
filters | the set of filters to use |
Definition at line 43 of file pipe.cpp.
|
delete |
|
override |
void Botan::Pipe::append | ( | Filter * | filt | ) |
Insert a new filter at the back of the pipe Deprecated because runtime modification of Pipes is deprecated. You can instead use append_filter which only works before the first message is processed.
filt | the new filter to insert |
Definition at line 199 of file pipe.cpp.
void Botan::Pipe::append_filter | ( | Filter * | filt | ) |
Append a new filter onto the filter sequence. This may only be called immediately after initial construction, before any calls to start_msg have been made.
This function (unlike append) is not deprecated, as it allows only modification of the pipe at initialization (before use) rather than after messages have been processed.
Definition at line 203 of file pipe.cpp.
|
overridevirtual |
Implements Botan::DataSource.
Definition at line 157 of file pipe_rw.cpp.
References default_msg(), and remaining().
bool Botan::Pipe::check_available_msg | ( | size_t | n, |
message_id | msg ) const |
Definition at line 161 of file pipe_rw.cpp.
References remaining().
|
inline |
Definition at line 230 of file pipe.h.
Referenced by check_available(), get_bytes_read(), read_all(), and read_all_as_string().
|
inherited |
Discard the next N bytes of the data
N | the number of bytes to discard |
Definition at line 40 of file data_src.cpp.
References Botan::DataSource::read().
void Botan::Pipe::end_msg | ( | ) |
End the current message.
Definition at line 154 of file pipe.cpp.
Referenced by process_msg(), and process_msg().
|
overridevirtual |
Test whether this pipe has any data that can be read from.
Implements Botan::DataSource.
Definition at line 86 of file pipe.cpp.
References remaining().
|
overridevirtual |
Implements Botan::DataSource.
Definition at line 149 of file pipe_rw.cpp.
References default_msg().
size_t Botan::Pipe::get_bytes_read | ( | message_id | msg | ) | const |
Definition at line 153 of file pipe_rw.cpp.
|
inlinevirtualinherited |
return the id of this data source
Reimplemented in Botan::DataSource_Stream.
Definition at line 61 of file data_src.h.
Pipe::message_id Botan::Pipe::message_count | ( | ) | const |
Get the number of messages the are in this pipe.
Definition at line 302 of file pipe.cpp.
Referenced by set_default_msg().
|
nodiscard |
Read a single byte from the specified message but do not modify the internal offset. Consecutive calls to peek() will return portions of the message starting at the same position.
output | the byte to write the peeked message byte to |
offset | the offset from the current position in message |
msg | the number identifying the message to peek from |
Definition at line 145 of file pipe_rw.cpp.
References peek().
|
nodiscardoverridevirtual |
Read from the default message but do not modify the internal offset. Consecutive calls to peek() will return portions of the message starting at the same position.
output | the byte array to write the peeked message part to |
length | the length of the byte array output |
offset | the offset from the current position in message |
Implements Botan::DataSource.
Definition at line 138 of file pipe_rw.cpp.
References DEFAULT_MESSAGE, and peek().
|
nodiscard |
Read from the specified message but do not modify the internal offset. Consecutive calls to peek() will return portions of the message starting at the same position.
output | the byte array to write the peeked message part to |
length | the length of the byte array output |
offset | the offset from the current position in message |
msg | the number identifying the message to peek from |
Definition at line 131 of file pipe_rw.cpp.
|
inherited |
Peek at one byte.
out | an output byte |
Definition at line 33 of file data_src.cpp.
References Botan::DataSource::peek().
Referenced by Botan::ASN1::maybe_BER().
void Botan::Pipe::pop | ( | ) |
Remove the first filter at the front of the pipe.
Definition at line 278 of file pipe.cpp.
void Botan::Pipe::prepend | ( | Filter * | filt | ) |
Insert a new filter at the front of the pipe Deprecated because runtime modification of Pipes is deprecated. You can instead use prepend_filter which only works before the first message is processed.
filt | the new filter to insert |
Definition at line 211 of file pipe.cpp.
void Botan::Pipe::prepend_filter | ( | Filter * | filt | ) |
Prepend a new filter onto the filter sequence. This may only be called immediately after initial construction, before any calls to start_msg have been made.
This function (unlike prepend) is not deprecated, as it allows only modification of the pipe at initialization (before use) rather than after messages have been processed.
Definition at line 215 of file pipe.cpp.
void Botan::Pipe::process_msg | ( | const secure_vector< uint8_t > & | in | ) |
Perform start_msg(), write() and end_msg() sequentially.
in | the secure_vector containing the data to write |
Definition at line 112 of file pipe.cpp.
References process_msg().
void Botan::Pipe::process_msg | ( | const std::vector< uint8_t > & | in | ) |
Perform start_msg(), write() and end_msg() sequentially.
in | the secure_vector containing the data to write |
Definition at line 116 of file pipe.cpp.
References process_msg().
void Botan::Pipe::process_msg | ( | const uint8_t | in[], |
size_t | length ) |
Perform start_msg(), write() and end_msg() sequentially.
in | the byte array containing the data to write |
length | the length of the byte array to write |
Definition at line 103 of file pipe.cpp.
References end_msg(), start_msg(), and write().
Referenced by process_msg(), process_msg(), and process_msg().
void Botan::Pipe::process_msg | ( | DataSource & | in | ) |
Perform start_msg(), write() and end_msg() sequentially.
in | the DataSource providing the data to write |
Definition at line 130 of file pipe.cpp.
References end_msg(), start_msg(), and write().
void Botan::Pipe::process_msg | ( | std::string_view | in | ) |
Perform start_msg(), write() and end_msg() sequentially.
in | the string containing the data to write |
Definition at line 123 of file pipe.cpp.
References Botan::cast_char_ptr_to_uint8(), and process_msg().
|
nodiscard |
Read a single byte from the pipe. Moves the internal offset so that every call to read will return a new portion of the message.
output | the byte to write the result to |
msg | the message to read from |
Definition at line 86 of file pipe_rw.cpp.
References read().
|
nodiscardoverridevirtual |
Read the default message from the pipe. Moves the internal offset so that every call to read will return a new portion of the message.
output | the byte array to write the read bytes to |
length | the length of the byte array output |
Implements Botan::DataSource.
Definition at line 79 of file pipe_rw.cpp.
References DEFAULT_MESSAGE, and read().
Referenced by Botan::operator<<(), Botan::operator<<(), read(), read(), read_all(), and read_all_as_string().
|
nodiscard |
Read a specified message from the pipe. Moves the internal offset so that every call to read will return a new portion of the message.
output | the byte array to write the read bytes to |
length | the length of the byte array output |
msg | the number identifying the message to read from |
Definition at line 72 of file pipe_rw.cpp.
|
nodiscard |
Read the full contents of the pipe.
msg | the number identifying the message to read from |
Definition at line 93 of file pipe_rw.cpp.
References DEFAULT_MESSAGE, default_msg(), read(), and remaining().
|
nodiscard |
Read the full contents of the pipe.
msg | the number identifying the message to read from |
Definition at line 104 of file pipe_rw.cpp.
References BOTAN_DEFAULT_BUFFER_SIZE, Botan::cast_uint8_ptr_to_char(), DEFAULT_MESSAGE, default_msg(), read(), and remaining().
|
inherited |
Read one byte.
out | the byte to read to |
Definition at line 26 of file data_src.cpp.
References Botan::DataSource::read().
Referenced by Botan::PEM_Code::decode(), Botan::BER_Decoder::discard_remaining(), and Botan::ASN1::maybe_BER().
|
nodiscard |
Find out how many bytes are ready to read.
msg | the number identifying the message for which the information is desired |
Definition at line 124 of file pipe_rw.cpp.
Referenced by check_available(), check_available_msg(), end_of_data(), Botan::operator<<(), Botan::operator<<(), read_all(), and read_all_as_string().
void Botan::Pipe::reset | ( | ) |
void Botan::Pipe::set_default_msg | ( | message_id | msg | ) |
Set the default message
msg | the number identifying the message which is going to be the new default message |
Definition at line 93 of file pipe.cpp.
References message_count().
void Botan::Pipe::start_msg | ( | ) |
Start a new message in the pipe. A potential other message in this pipe must be closed with end_msg() before this function may be called.
Definition at line 139 of file pipe.cpp.
Referenced by process_msg(), and process_msg().
|
inline |
|
inline |
void Botan::Pipe::write | ( | const uint8_t | in[], |
size_t | length ) |
Write input to the pipe, i.e. to its first filter.
in | the byte array to write |
length | the length of the byte array in |
Definition at line 37 of file pipe_rw.cpp.
References Botan::Filter::write().
Referenced by Botan::operator>>(), Botan::operator>>(), process_msg(), process_msg(), write(), write(), and write().
void Botan::Pipe::write | ( | DataSource & | in | ) |
Write input to the pipe, i.e. to its first filter.
in | the DataSource to read the data from |
Definition at line 61 of file pipe_rw.cpp.
References BOTAN_DEFAULT_BUFFER_SIZE, Botan::DataSource::end_of_data(), Botan::DataSource::read(), and write().
void Botan::Pipe::write | ( | std::string_view | in | ) |
Write input to the pipe, i.e. to its first filter.
in | the string containing the data to write |
Definition at line 47 of file pipe_rw.cpp.
References Botan::cast_char_ptr_to_uint8(), and write().
void Botan::Pipe::write | ( | uint8_t | in | ) |
Write input to the pipe, i.e. to its first filter.
in | a single byte to be written |
Definition at line 54 of file pipe_rw.cpp.
References write().
|
static |
A meta-id for the default message (set with set_default_msg)
Definition at line 57 of file pipe.h.
Referenced by peek(), read(), read_all(), and read_all_as_string().
|
static |