Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BufferedTransformation Class Reference

abstract base class for buffered transformations. More...

#include <cryptlib.h>

Inheritance diagram for BufferedTransformation:

BufferedTransformationWithAutoSignal ByteQueue ChannelSwitch Filter Sink Inflator MessageQueue NonblockingSource RawIDA Store DERGeneralEncoder Base64Decoder Base64Encoder FilterWithBufferedInput FilterWithInputQueue HashFilter HexDecoder HexEncoder Inflator InformationDispersal LowFirstBitWriter OpaqueFilter RawIDA SecretSharing SignerFilter Source StreamCipherFilter TransparentFilter VerifierFilter WAKEEncryption ArraySink BitBucket FileSink MaurerRandomnessTest NonblockingSink RandomPool Redirector StringSinkTemplate List of all members.

ERRORS

enum  ErrorType {
  CANNOT_FLUSH, DATA_INTEGRITY_CHECK_FAILED, INVALID_DATA_FORMAT, INPUT_ERROR,
  OUTPUT_ERROR, OTHER_ERROR
}
 error types. More...


INPUT

virtual void Put (byte inByte)=0
 input a byte for processing. More...

virtual void Put (const byte *inString,unsigned int length)=0
 input multiple bytes. More...

void PutWord16 (word16 value,bool highFirst=true)
 input a 16-bit word, big-endian or little-endian depending on highFirst. More...

void PutWord32 (word32 value,bool highFirst=true)
 input a 32-bit word. More...


SIGNALS

virtual void Flush (bool completeFlush,int propagation=-1)
 process everything in internal buffers and output them. More...

virtual void MessageEnd (int propagation=-1)
 mark end of an input segment, message, or packet. More...

virtual void PutMessageEnd (const byte *inString,unsigned int length,int propagation=-1)
 same as Put() followed by MessageEnd() but may be more efficient. More...

virtual void MessageSeriesEnd (int propagation=-1)
 mark end of a series of messages. More...

virtual void SetAutoSignalPropagation (int propagation)
 set propagation of automatically generated and transfered signals. More...

virtual int GetAutoSignalPropagation ()const
void Close ()

RETRIEVAL OF ONE MESSAGE

virtual unsigned long MaxRetrievable ()const
 returns number of bytes that is currently ready for retrieval. More...

unsigned long MaxRetrieveable ()const
virtual bool AnyRetrievable ()const
 returns whether any bytes are currently ready for retrieval. More...

virtual unsigned int Get (byte &outByte)
 try to retrieve a single byte. More...

virtual unsigned int Get (byte *outString,unsigned int getMax)
 try to retrieve multiple bytes. More...

virtual unsigned int Peek (byte &outByte)const
 peek at the next byte without removing it from the output buffer. More...

virtual unsigned int Peek (byte *outString,unsigned int peekMax)const
 peek at multiple bytes without removing them from the output buffer. More...

unsigned int GetWord16 (word16 &value,bool highFirst=true)
 try to retrieve a 16-bit word, big-endian or little-endian depending on highFirst. More...

unsigned int GetWord32 (word32 &value,bool highFirst=true)
 try to retrieve a 32-bit word. More...

unsigned int PeekWord16 (word16 &value,bool highFirst=true)
 try to peek at a 16-bit word, big-endian or little-endian depending on highFirst. More...

unsigned int PeekWord32 (word32 &value,bool highFirst=true)
 try to peek at a 32-bit word. More...

virtual unsigned long TransferTo (BufferedTransformation &target,unsigned long transferMax=ULONG_MAX)
 move transferMax bytes of the buffered output to target as input. More...

virtual unsigned long Skip (unsigned long skipMax=ULONG_MAX)
 discard skipMax bytes from the output buffer. More...

virtual unsigned long CopyTo (BufferedTransformation &target,unsigned long copyMax=ULONG_MAX)const
 copy copyMax bytes of the buffered output to target as input. More...


RETRIEVAL OF MULTIPLE MESSAGES

virtual unsigned long TotalBytesRetrievable ()const
virtual unsigned int NumberOfMessages ()const
 number of times MessageEnd() has been received minus messages retrieved or skipped. More...

virtual bool AnyMessages ()const
 returns true if NumberOfMessages() > 0. More...

virtual bool GetNextMessage ()
 start retrieving the next message. More...

virtual unsigned int SkipMessages (unsigned int count=UINT_MAX)
 skip count number of messages. More...

virtual unsigned int TransferMessagesTo (BufferedTransformation &target,unsigned int count=UINT_MAX)
virtual unsigned int CopyMessagesTo (BufferedTransformation &target,unsigned int count=UINT_MAX)const
virtual void SkipAll ()
virtual void TransferAllTo (BufferedTransformation &target)
virtual void CopyAllTo (BufferedTransformation &target)const

CHANNELS

virtual void ChannelPut (const::string &channel,byte inByte)
virtual void ChannelPut (const::string &channel,const byte *inString,unsigned int length)
void ChannelPutWord16 (const::string &channel,word16 value,bool highFirst=true)
void ChannelPutWord32 (const::string &channel,word32 value,bool highFirst=true)
virtual void ChannelFlush (const::string &channel,bool completeFlush,int propagation=-1)
virtual void ChannelMessageEnd (const::string &channel,int propagation=-1)
virtual void ChannelPutMessageEnd (const::string &channel,const byte *inString,unsigned int length,int propagation=-1)
virtual void ChannelMessageSeriesEnd (const::string &channel,int propagation=-1)
virtual void SetRetrievalChannel (const::string &channel)
const ::string NULL_CHANNEL

ATTACHMENT

Some BufferedTransformation objects (e.g. Filter objects) allow other BufferedTransformation objects to be attached. When this is done, the first object instead of buffering its output, sents that output to the attached object as input. The entire attachment chain is deleted when the anchor object is destructed.

virtual bool Attachable ()
 returns whether this object allows attachment. More...

virtual BufferedTransformation* AttachedTransformation ()
 returns the object immediately attached to this object or NULL for no attachment. More...

virtual const BufferedTransformation* AttachedTransformation ()const
virtual void Detach (BufferedTransformation *newAttachment=0)
 delete the current attachment chain and replace it with newAttachment. More...

virtual void Attach (BufferedTransformation *newAttachment)
 add newAttachment to the end of attachment chain. More...


Public Methods

virtual ~BufferedTransformation ()

Detailed Description

abstract base class for buffered transformations.

BufferedTransformation is a generalization of BlockTransformation, StreamCipher, and HashModule.

A buffered transformation is an object that takes a stream of bytes as input (this may be done in stages), does some computation on them, and then places the result into an internal buffer for later retrieval. Any partial result already in the output buffer is not modified by further input.

Computation is generally done as soon as possible, but some buffering on the input may be done for performance reasons.

Definition at line 264 of file cryptlib.h.


Member Enumeration Documentation

enum BufferedTransformation::ErrorType
 

error types.

Enumeration values:
CANNOT_FLUSH   received a Flush(true) signal but can't flush buffers.
DATA_INTEGRITY_CHECK_FAILED   data integerity check (such as CRC or MAC) failed.
INVALID_DATA_FORMAT   received input data that doesn't conform to expected format.
INPUT_ERROR   error reading from input device.
OUTPUT_ERROR   error writing to output device.
OTHER_ERROR   some error not belong to any of the above categories.

Definition at line 315 of file cryptlib.h.


Constructor & Destructor Documentation

BufferedTransformation::~BufferedTransformation ( ) [inline, virtual]
 

Definition at line 268 of file cryptlib.h.


Member Function Documentation

bool BufferedTransformation::AnyMessages ( ) const [virtual]
 

returns true if NumberOfMessages() > 0.

Definition at line 261 of file cryptlib.cpp.

bool BufferedTransformation::AnyRetrievable ( ) const [virtual]
 

returns whether any bytes are currently ready for retrieval.

Reimplemented in MessageQueue, and ByteQueue.

Definition at line 172 of file cryptlib.cpp.

Referenced by Store::GetNextMessage().

void BufferedTransformation::Attach ( BufferedTransformation * bt ) [virtual]
 

add newAttachment to the end of attachment chain.

Definition at line 436 of file cryptlib.cpp.

bool BufferedTransformation::Attachable ( ) [inline, virtual]
 

returns whether this object allows attachment.

Reimplemented in Filter.

Definition at line 442 of file cryptlib.h.

Referenced by Attach().

const BufferedTransformation * BufferedTransformation::AttachedTransformation ( ) const [inline, virtual]
 

Definition at line 446 of file cryptlib.h.

BufferedTransformation * BufferedTransformation::AttachedTransformation ( ) [inline, virtual]
 

returns the object immediately attached to this object or NULL for no attachment.

Reimplemented in Filter.

Definition at line 444 of file cryptlib.h.

Referenced by AnyMessages(), AnyRetrievable(), Attach(), CopyTo(), Flush(), NetworkSource::GeneralPump(), Get(), GetNextMessage(), MaxRetrievable(), MessageEnd(), MessageSeriesEnd(), NumberOfMessages(), Peek(), StreamCipherFilter::Put(), TransparentFilter::Put(), Put(), Skip(), SkipMessages(), and TransferTo().

void BufferedTransformation::ChannelFlush ( const::string & channel,
bool completeFlush,
int propagation = -1 ) [virtual]
 

Definition at line 129 of file cryptlib.cpp.

void BufferedTransformation::ChannelMessageEnd ( const::string & channel,
int propagation = -1 ) [virtual]
 

Definition at line 137 of file cryptlib.cpp.

void BufferedTransformation::ChannelMessageSeriesEnd ( const::string & channel,
int propagation = -1 ) [virtual]
 

Definition at line 145 of file cryptlib.cpp.

void BufferedTransformation::ChannelPut ( const::string & channel,
const byte * inString,
unsigned int length ) [virtual]
 

Definition at line 356 of file cryptlib.cpp.

void BufferedTransformation::ChannelPut ( const::string & channel,
byte inByte ) [virtual]
 

Definition at line 350 of file cryptlib.cpp.

void BufferedTransformation::ChannelPutMessageEnd ( const::string & channel,
const byte * inString,
unsigned int length,
int propagation = -1 ) [virtual]
 

Definition at line 153 of file cryptlib.cpp.

void BufferedTransformation::ChannelPutWord16 ( const::string & channel,
word16 value,
bool highFirst = true )
 

Definition at line 362 of file cryptlib.cpp.

void BufferedTransformation::ChannelPutWord32 ( const::string & channel,
word32 value,
bool highFirst = true )
 

Definition at line 376 of file cryptlib.cpp.

void BufferedTransformation::Close ( ) [inline]
 

Definition at line 309 of file cryptlib.h.

void BufferedTransformation::CopyAllTo ( BufferedTransformation & target ) const [virtual]
 

Definition at line 333 of file cryptlib.cpp.

unsigned int BufferedTransformation::CopyMessagesTo ( BufferedTransformation & target,
unsigned int count = UINT_MAX ) const [virtual]
 

Definition at line 303 of file cryptlib.cpp.

unsigned long BufferedTransformation::CopyTo ( BufferedTransformation & target,
unsigned long copyMax = ULONG_MAX ) const [virtual]
 

copy copyMax bytes of the buffered output to target as input.

Reimplemented in BERGeneralDecoder, FileStore, Store, StringStore, RandomNumberStore, MessageQueue, and ByteQueue.

Definition at line 229 of file cryptlib.cpp.

Referenced by BERGeneralDecoder::CopyTo(), MaxRetrievable(), and Peek().

void BufferedTransformation::Detach ( BufferedTransformation * newOut = 0 ) [inline, virtual]
 

delete the current attachment chain and replace it with newAttachment.

Reimplemented in Filter.

Definition at line 449 of file cryptlib.h.

Referenced by Attach().

void BufferedTransformation::Flush ( bool completeFlush,
int propagation = -1 ) [virtual]
 

process everything in internal buffers and output them.

throws exception if completeFlush == true and it's not possible to flush everything

Reimplemented in ChannelSwitch, FileSink, Redirector, ProxyFilter, NonblockingSink, Deflator, and Inflator.

Definition at line 105 of file cryptlib.cpp.

Referenced by Inflator::Flush(), Deflator::Flush(), Redirector::Flush(), and ProxyFilter::Flush().

unsigned int BufferedTransformation::Get ( byte * outString,
unsigned int getMax ) [virtual]
 

try to retrieve multiple bytes.

Reimplemented in ByteQueue.

Definition at line 191 of file cryptlib.cpp.

unsigned int BufferedTransformation::Get ( byte & outByte ) [virtual]
 

try to retrieve a single byte.

Reimplemented in ByteQueue.

Definition at line 183 of file cryptlib.cpp.

Referenced by Get().

int BufferedTransformation::GetAutoSignalPropagation ( ) const [inline, virtual]
 

Definition at line 306 of file cryptlib.h.

bool BufferedTransformation::GetNextMessage ( ) [virtual]
 

start retrieving the next message.

Returns false if no more messages exist or this message is not completely retrieved.

Reimplemented in Store.

Definition at line 269 of file cryptlib.cpp.

unsigned int BufferedTransformation::GetWord16 ( word16 & value,
bool highFirst = true )
 

try to retrieve a 16-bit word, big-endian or little-endian depending on highFirst.

Definition at line 426 of file cryptlib.cpp.

Referenced by BERGeneralDecoder::MessageEnd().

unsigned int BufferedTransformation::GetWord32 ( word32 & value,
bool highFirst = true )
 

try to retrieve a 32-bit word.

Definition at line 431 of file cryptlib.cpp.

unsigned long BufferedTransformation::MaxRetrievable ( ) const [virtual]
 

returns number of bytes that is currently ready for retrieval.

All retrieval functions return the actual number of bytes retrieved, which is the lesser of the request number and MaxRetrievable().

Reimplemented in FileStore, MessageQueue, and ByteQueue.

Definition at line 164 of file cryptlib.cpp.

Referenced by MessageQueue::CopyTo(), and MessageQueue::TransferTo().

unsigned long BufferedTransformation::MaxRetrieveable ( ) const [inline]
 

Definition at line 351 of file cryptlib.h.

void BufferedTransformation::MessageEnd ( int propagation = -1 ) [virtual]
 

mark end of an input segment, message, or packet.

propagation != 0 means pass on the signal to attached BufferedTransformation objects, with propagation decremented at each step until it reaches 0. -1 means unlimited propagation.

Reimplemented in BERGeneralDecoder, DERGeneralEncoder, Base64Encoder, Base64Decoder, ChannelSwitch, FileSink, FilterWithBufferedInput, HashFilter, SignerFilter, VerifierFilter, Redirector, Source, HexDecoder, SecretSharing, InformationDispersal, MessageQueue, NetworkSink, WAKEEncryption, WAKEDecryption, Deflator, and Inflator.

Definition at line 111 of file cryptlib.cpp.

Referenced by Inflator::MessageEnd(), Deflator::MessageEnd(), WAKEDecryption::MessageEnd(), WAKEEncryption::MessageEnd(), HexDecoder::MessageEnd(), Redirector::MessageEnd(), VerifierFilter::MessageEnd(), SignerFilter::MessageEnd(), HashFilter::MessageEnd(), FilterWithBufferedInput::MessageEnd(), Base64Decoder::MessageEnd(), Base64Encoder::MessageEnd(), and PutMessageEnd().

void BufferedTransformation::MessageSeriesEnd ( int propagation = -1 ) [virtual]
 

mark end of a series of messages.

There should be a MessageEnd immediately before MessageSeriesEnd.

Reimplemented in ChannelSwitch, and Redirector.

Definition at line 117 of file cryptlib.cpp.

Referenced by Redirector::MessageSeriesEnd().

unsigned int BufferedTransformation::NumberOfMessages ( ) const [virtual]
 

number of times MessageEnd() has been received minus messages retrieved or skipped.

Reimplemented in Store, and MessageQueue.

Definition at line 253 of file cryptlib.cpp.

Referenced by AnyMessages().

unsigned int BufferedTransformation::Peek ( byte * outString,
unsigned int peekMax ) const [virtual]
 

peek at multiple bytes without removing them from the output buffer.

Reimplemented in ByteQueue.

Definition at line 210 of file cryptlib.cpp.

unsigned int BufferedTransformation::Peek ( byte & outByte ) const [virtual]
 

peek at the next byte without removing it from the output buffer.

Reimplemented in FileStore, and ByteQueue.

Definition at line 202 of file cryptlib.cpp.

Referenced by AnyRetrievable(), Peek(), PeekWord16(), and PeekWord32().

unsigned int BufferedTransformation::PeekWord16 ( word16 & value,
bool highFirst = true )
 

try to peek at a 16-bit word, big-endian or little-endian depending on highFirst.

Definition at line 400 of file cryptlib.cpp.

Referenced by GetWord16().

unsigned int BufferedTransformation::PeekWord32 ( word32 & value,
bool highFirst = true )
 

try to peek at a 32-bit word.

Definition at line 413 of file cryptlib.cpp.

Referenced by GetWord32().

void BufferedTransformation::Put ( const byte * inString,
unsigned int length ) [pure virtual]
 

input multiple bytes.

Reimplemented in Base64Encoder, Base64Decoder, ChannelSwitch, FileSink, TransparentFilter, OpaqueFilter, FilterWithBufferedInput, FilterWithInputQueue, StreamCipherFilter, HashFilter, SignerFilter, VerifierFilter, BitBucket, Redirector, StringSinkTemplate, ArraySink, ArrayXorSink, Store, Source, HexEncoder, HexDecoder, RawIDA, SecretSharing, InformationDispersal, MessageQueue, NetworkSink, ByteQueue, RandomPool, MaurerRandomnessTest, WAKEEncryption, Deflator, and Inflator.

Definition at line 99 of file cryptlib.cpp.

void BufferedTransformation::Put ( byte b ) [pure virtual]
 

input a byte for processing.

Reimplemented in Base64Encoder, Base64Decoder, ChannelSwitch, FileSink, TransparentFilter, OpaqueFilter, FilterWithBufferedInput, FilterWithInputQueue, StreamCipherFilter, HashFilter, SignerFilter, VerifierFilter, BitBucket, Redirector, StringSinkTemplate, ArraySink, ArrayXorSink, Store, Source, HexEncoder, HexDecoder, RawIDA, SecretSharing, InformationDispersal, MessageQueue, NetworkSink, ByteQueue, RandomPool, MaurerRandomnessTest, WAKEEncryption, Deflator, and Inflator.

Definition at line 93 of file cryptlib.cpp.

Referenced by ByteQueue::CopyTo(), RandomNumberStore::CopyTo(), StringStore::CopyTo(), DERGeneralEncoder::MessageEnd(), Inflator::Put(), Deflator::Put(), NetworkSink::Put(), InformationDispersal::Put(), SecretSharing::Put(), Redirector::Put(), Put(), PutMessageEnd(), ByteQueue::TransferTo(), and FileStore::TransferTo().

void BufferedTransformation::PutMessageEnd ( const byte * inString,
unsigned int length,
int propagation = -1 ) [virtual]
 

same as Put() followed by MessageEnd() but may be more efficient.

Reimplemented in ChannelSwitch.

Definition at line 123 of file cryptlib.cpp.

void BufferedTransformation::PutWord16 ( word16 value,
bool highFirst = true )
 

input a 16-bit word, big-endian or little-endian depending on highFirst.

Definition at line 390 of file cryptlib.cpp.

Referenced by Integer::OpenPGPEncode().

void BufferedTransformation::PutWord32 ( word32 value,
bool highFirst = true )
 

input a 32-bit word.

Definition at line 395 of file cryptlib.cpp.

void BufferedTransformation::SetAutoSignalPropagation ( int propagation ) [inline, virtual]
 

set propagation of automatically generated and transfered signals.

propagation == 0 means do not automaticly generate signals

Reimplemented in BufferedTransformationWithAutoSignal.

Definition at line 303 of file cryptlib.h.

void BufferedTransformation::SetRetrievalChannel ( const::string & channel ) [virtual]
 

Definition at line 344 of file cryptlib.cpp.

unsigned long BufferedTransformation::Skip ( unsigned long skipMax = ULONG_MAX ) [virtual]
 

discard skipMax bytes from the output buffer.

Reimplemented in ByteQueue.

Definition at line 221 of file cryptlib.cpp.

Referenced by GetWord16(), and GetWord32().

void BufferedTransformation::SkipAll ( ) [virtual]
 

Definition at line 311 of file cryptlib.cpp.

unsigned int BufferedTransformation::SkipMessages ( unsigned int count = UINT_MAX ) [virtual]
 

skip count number of messages.

Definition at line 277 of file cryptlib.cpp.

unsigned long BufferedTransformation::TotalBytesRetrievable ( ) const [virtual]
 

Definition at line 245 of file cryptlib.cpp.

void BufferedTransformation::TransferAllTo ( BufferedTransformation & target ) [virtual]
 

Definition at line 322 of file cryptlib.cpp.

unsigned int BufferedTransformation::TransferMessagesTo ( BufferedTransformation & target,
unsigned int count = UINT_MAX ) [virtual]
 

Definition at line 285 of file cryptlib.cpp.

unsigned long BufferedTransformation::TransferTo ( BufferedTransformation & target,
unsigned long transferMax = ULONG_MAX ) [virtual]
 

move transferMax bytes of the buffered output to target as input.

Reimplemented in BERGeneralDecoder, FileStore, Store, StringStore, RandomNumberStore, MessageQueue, and ByteQueue.

Definition at line 237 of file cryptlib.cpp.

Referenced by Get(), Skip(), and BERGeneralDecoder::TransferTo().


Member Data Documentation

const::string BufferedTransformation::NULL_CHANNEL [static]
 

Definition at line 430 of file cryptlib.h.


The documentation for this class was generated from the following files:
Generated at Mon Jan 15 01:16:42 2001 for Crypto++ by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000