Botan
1.10.9
|
#include <pipe.h>
Classes | |
struct | Invalid_Message_Number |
Public Types | |
typedef size_t | message_id |
Public Member Functions | |
void | append (Filter *filt) |
size_t | default_msg () const |
size_t | discard_next (size_t N) |
void | end_msg () |
bool | end_of_data () const |
virtual std::string | id () const |
message_id | message_count () const |
size_t | peek (byte output[], size_t length, size_t offset) const |
size_t | peek (byte output[], size_t length, size_t offset, message_id msg) const |
size_t | peek (byte &output, size_t offset, message_id msg=DEFAULT_MESSAGE) const |
size_t | peek_byte (byte &out) const |
Pipe (Filter *=0, Filter *=0, Filter *=0, Filter *=0) | |
Pipe (Filter *filters[], size_t count) | |
void | pop () |
void | prepend (Filter *filt) |
void | process_msg (const byte in[], size_t length) |
void | process_msg (const MemoryRegion< byte > &in) |
void | process_msg (const std::string &in) |
void | process_msg (DataSource &in) |
size_t | read (byte output[], size_t length) |
size_t | read (byte output[], size_t length, message_id msg) |
size_t | read (byte &output, message_id msg=DEFAULT_MESSAGE) |
SecureVector< byte > | read_all (message_id msg=DEFAULT_MESSAGE) |
std::string | read_all_as_string (message_id=DEFAULT_MESSAGE) |
size_t | read_byte (byte &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 byte in[], size_t length) |
void | write (const MemoryRegion< byte > &in) |
void | write (const std::string &in) |
void | write (DataSource &in) |
void | write (byte in) |
~Pipe () | |
Static Public Attributes | |
static const message_id | DEFAULT_MESSAGE |
static const message_id | LAST_MESSAGE |
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.
typedef size_t Botan::Pipe::message_id |
Botan::Pipe::Pipe | ( | Filter * | filters[], |
size_t | count | ||
) |
Botan::Pipe::~Pipe | ( | ) |
void Botan::Pipe::append | ( | Filter * | filt | ) |
Insert a new filter at the back of the pipe
filt | the new filter to insert |
Definition at line 215 of file pipe.cpp.
Referenced by Pipe(), Botan::Record_Writer::set_keys(), Botan::Record_Reader::set_keys(), Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().
|
inline |
Definition at line 206 of file pipe.h.
Referenced by read_all(), read_all_as_string(), Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().
|
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().
void Botan::Pipe::end_msg | ( | ) |
End the current message.
Definition at line 166 of file pipe.cpp.
References Botan::Output_Buffers::retire().
Referenced by Botan::EAC_Signed_Object::BER_encode(), Botan::check_passhash9(), Botan::PEM_Code::decode(), Botan::PBE_PKCS5v15::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::generate_passhash9(), Botan::EAC_Signed_Object::PEM_encode(), Botan::PGP_decode(), and process_msg().
|
virtual |
Test whether this pipe has any data that can be read from.
Implements Botan::DataSource.
Definition at line 98 of file pipe.cpp.
References remaining().
|
inlinevirtualinherited |
return the id of this data source
Reimplemented in Botan::DataSource_Stream, and Botan::DataSource_Command.
Definition at line 57 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 282 of file pipe.cpp.
References Botan::Output_Buffers::message_count().
Referenced by set_default_msg(), Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().
|
virtual |
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 155 of file pipe_rw.cpp.
References DEFAULT_MESSAGE.
Referenced by peek().
size_t Botan::Pipe::peek | ( | byte | output[], |
size_t | length, | ||
size_t | offset, | ||
message_id | msg | ||
) | const |
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 146 of file pipe_rw.cpp.
References Botan::Output_Buffers::peek().
size_t Botan::Pipe::peek | ( | byte & | output, |
size_t | offset, | ||
message_id | msg = DEFAULT_MESSAGE |
||
) | const |
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 163 of file pipe_rw.cpp.
References peek().
|
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().
void Botan::Pipe::pop | ( | ) |
void Botan::Pipe::prepend | ( | Filter * | filt | ) |
void Botan::Pipe::process_msg | ( | const byte | 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 116 of file pipe.cpp.
References end_msg(), start_msg(), and write().
Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::PKCS8::BER_encode(), Botan::CMS_Encoder::compress(), Botan::CryptoBox::decrypt(), Botan::PEM_Code::encode(), Botan::CryptoBox::encrypt(), Botan::Record_Reader::get_record(), Botan::PGP_encode(), and process_msg().
void Botan::Pipe::process_msg | ( | const MemoryRegion< byte > & | in | ) |
Perform start_msg(), write() and end_msg() sequentially.
in | the MemoryRegion containing the data to write |
Definition at line 126 of file pipe.cpp.
References process_msg(), and Botan::MemoryRegion< T >::size().
void Botan::Pipe::process_msg | ( | const std::string & | in | ) |
Perform start_msg(), write() and end_msg() sequentially.
in | the string containing the data to write |
Definition at line 134 of file pipe.cpp.
References 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 142 of file pipe.cpp.
References end_msg(), start_msg(), and write().
|
virtual |
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 89 of file pipe_rw.cpp.
References DEFAULT_MESSAGE.
Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::CryptoBox::decrypt(), Botan::CryptoBox::encrypt(), Botan::operator<<(), read(), read_all(), and read_all_as_string().
size_t Botan::Pipe::read | ( | byte | output[], |
size_t | length, | ||
message_id | msg | ||
) |
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 81 of file pipe_rw.cpp.
References Botan::Output_Buffers::read().
size_t Botan::Pipe::read | ( | byte & | output, |
message_id | msg = DEFAULT_MESSAGE |
||
) |
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 97 of file pipe_rw.cpp.
References read().
SecureVector< byte > Botan::Pipe::read_all | ( | message_id | msg = DEFAULT_MESSAGE | ) |
Read the full contents of the pipe.
msg | the number identifying the message to read from |
Definition at line 105 of file pipe_rw.cpp.
References DEFAULT_MESSAGE, default_msg(), read(), remaining(), Botan::MemoryRegion< T >::resize(), and Botan::MemoryRegion< T >::size().
Referenced by Botan::EAC_Signed_Object::BER_encode(), Botan::check_passhash9(), Botan::CMS_Encoder::compress(), Botan::PEM_Code::decode(), Botan::Record_Reader::get_record(), and Botan::PGP_decode().
std::string Botan::Pipe::read_all_as_string | ( | message_id | msg = DEFAULT_MESSAGE | ) |
Read the full contents of the pipe.
msg | the number identifying the message to read from |
Definition at line 117 of file pipe_rw.cpp.
References DEFAULT_MESSAGE, default_msg(), read(), remaining(), and Botan::MemoryRegion< T >::size().
Referenced by Botan::CryptoBox::decrypt(), Botan::PEM_Code::encode(), Botan::generate_passhash9(), Botan::EAC_Signed_Object::PEM_encode(), Botan::PGP_decode(), and Botan::PGP_encode().
|
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().
size_t Botan::Pipe::remaining | ( | message_id | msg = DEFAULT_MESSAGE | ) | const |
Find out how many bytes are ready to read.
msg | the number identifying the message for which the information is desired |
Definition at line 138 of file pipe_rw.cpp.
References Botan::Output_Buffers::remaining().
Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::CryptoBox::encrypt(), end_of_data(), Botan::operator<<(), read_all(), and read_all_as_string().
void Botan::Pipe::reset | ( | ) |
Reset this pipe to an empty pipe.
Definition at line 76 of file pipe.cpp.
Referenced by Botan::PBE_PKCS5v15::end_msg(), Botan::PBE_PKCS5v20::end_msg(), Botan::Record_Writer::reset(), Botan::Record_Reader::reset(), Botan::Record_Writer::set_keys(), and Botan::Record_Reader::set_keys().
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 106 of file pipe.cpp.
References message_count().
Referenced by Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().
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 152 of file pipe.cpp.
Referenced by Botan::EAC_Signed_Object::BER_encode(), Botan::check_passhash9(), Botan::PEM_Code::decode(), Botan::generate_passhash9(), Botan::EAC_Signed_Object::PEM_encode(), Botan::PGP_decode(), process_msg(), Botan::PBE_PKCS5v15::start_msg(), and Botan::PBE_PKCS5v20::start_msg().
void Botan::Pipe::write | ( | const byte | 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 34 of file pipe_rw.cpp.
References Botan::Filter::write().
Referenced by Botan::check_passhash9(), Botan::PEM_Code::decode(), Botan::EAC1_1_gen_CVC< Derived >::encode(), Botan::EAC1_1_ADO::encode(), Botan::X509_Object::encode(), Botan::generate_passhash9(), Botan::operator>>(), Botan::PGP_decode(), process_msg(), Botan::PBE_PKCS5v15::write(), Botan::PBE_PKCS5v20::write(), and write().
void Botan::Pipe::write | ( | const MemoryRegion< byte > & | in | ) |
Write input to the pipe, i.e. to its first filter.
in | the MemoryRegion containing the data to write |
Definition at line 44 of file pipe_rw.cpp.
References Botan::MemoryRegion< T >::size(), and write().
void Botan::Pipe::write | ( | const std::string & | in | ) |
Write input to the pipe, i.e. to its first filter.
in | the string containing the data to write |
Definition at line 52 of file pipe_rw.cpp.
References 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 68 of file pipe_rw.cpp.
References Botan::DataSource::end_of_data(), Botan::DataSource::read(), Botan::MemoryRegion< T >::size(), and write().
void Botan::Pipe::write | ( | byte | in | ) |
Write input to the pipe, i.e. to its first filter.
in | a single byte to be written |
Definition at line 60 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 |
A meta-id for whatever the last message is
Definition at line 52 of file pipe.h.
Referenced by Botan::Record_Reader::get_record().