#include <wvblowfish.h>
Inherits WvEncoder.
Collaboration diagram for WvBlowfishEncoder:
Supports reset().
Definition at line 21 of file wvblowfish.h.
Public Types | |
enum | Mode { ECBEncrypt, ECBDecrypt, CFBEncrypt, CFBDecrypt } |
Public Member Functions | |
WvBlowfishEncoder (Mode mode, const void *key, size_t keysize) | |
Creates a new Blowfish cipher encoder. | |
virtual | ~WvBlowfishEncoder () |
void | setkey (const void *key, size_t keysize) |
Sets the current Blowfish key and resets the initialization vector to all nulls. | |
void | setiv (const void *iv) |
Sets the current Blowfish initialization vector. | |
bool | is_encrypting () const |
Return true if mode is encrypting or false if decrypting. | |
bool | isok () const |
Returns true if the encoder has not encountered an error. | |
bool | isfinished () const |
Returns true if the encoder can no longer encode data. | |
WvString | geterror () const |
Returns an error message if any is available. | |
bool | encode (WvBuf &inbuf, WvBuf &outbuf, bool flush=false, bool finish=false) |
Reads data from the input buffer, encodes it, and writes the result to the output buffer. | |
bool | flush (WvBuf &inbuf, WvBuf &outbuf, bool finish=false) |
Flushes the encoder and optionally finishes it. | |
bool | finish (WvBuf &outbuf) |
Tells the encoder that NO MORE DATA will ever be encoded. | |
bool | reset () |
Asks an encoder to reset itself to its initial state at creation time, if supported. | |
bool | flushstrbuf (WvStringParm instr, WvBuf &outbuf, bool finish=false) |
Flushes data through the encoder from a string to a buffer. | |
bool | flushstrstr (WvStringParm instr, WvString &outstr, bool finish=false) |
Flushes data through the encoder from a string to a string. | |
bool | encodebufstr (WvBuf &inbuf, WvString &outstr, bool flush=false, bool finish=false) |
Encodes data from a buffer to a string. | |
bool | flushbufstr (WvBuf &inbuf, WvString &outstr, bool finish=false) |
Flushes data through the encoder from a buffer to a string. | |
WvString | strflushstr (WvStringParm instr, bool finish=false) |
Flushes data through the encoder from a string to a string. | |
WvString | strflushbuf (WvBuf &inbuf, bool finish=false) |
Flushes data through the encoder from a buffer to a string. | |
bool | flushmembuf (const void *inmem, size_t inlen, WvBuf &outbuf, bool finish=false) |
Flushes data through the encoder from memory to a buffer. | |
bool | flushmemmem (const void *inmem, size_t inlen, void *outmem, size_t *outlen, bool finish=false) |
Flushes data through the encoder from memory to memory. | |
bool | encodebufmem (WvBuf &inbuf, void *outmem, size_t *outlen, bool flush=false, bool finish=false) |
Encodes data from a buffer to memory. | |
bool | flushbufmem (WvBuf &inbuf, void *outmem, size_t *outlen, bool finish=false) |
Flushes data through the encoder from a buffer to memory. | |
bool | flushstrmem (WvStringParm instr, void *outmem, size_t *outlen, bool finish=false) |
Flushes data through the encoder from a string to memory. | |
WvString | strflushmem (const void *inmem, size_t inlen, bool finish=false) |
Flushes data through the encoder from memory to a string. | |
Protected Member Functions | |
virtual bool | _encode (WvBuf &in, WvBuf &out, bool flush) |
Template method implementation of encode(). | |
virtual bool | _reset () |
Template method implementation of reset(). | |
void | preparekey () |
void | setnotok () |
Sets 'okay' to false explicitly. | |
void | seterror (WvStringParm message) |
Sets an error condition, then setnotok(). | |
void | seterror (WVSTRING_FORMAT_DECL) |
Sets an error condition, then setnotok(). | |
void | setfinished () |
Sets 'finished' to true explicitly. | |
virtual bool | _isok () const |
Template method implementation of isok(). | |
virtual bool | _isfinished () const |
Template method implementation of isfinished(). | |
virtual WvString | _geterror () const |
Template method implementation of geterror(). | |
virtual bool | _finish (WvBuf &outbuf) |
Template method implementation of finish(). | |
Protected Attributes | |
Mode | mode |
size_t | keysize |
unsigned char * | key |
bf_key_st * | bfkey |
unsigned char | ivec [8] |
int | ivecoff |
bool | okay |
bool | finished |
WvString | errstr |
|
Definition at line 24 of file wvblowfish.h. |
|
Creates a new Blowfish cipher encoder. "mode" is the encryption mode "key" is the initial key "keysize" is the initial key size in bytes Definition at line 14 of file wvblowfish.cc. References setkey(), and WvBlowfishEncoder(). Referenced by WvBlowfishEncoder(). |
|
Definition at line 22 of file wvblowfish.cc. |
|
Template method implementation of encode(). Not called if any of the following cases are true:
All implementations MUST define this. If you also override _isok() or _isfinished(), note that they will NOT be consulted when determining whether or not to invoke this function. This allows finer control over the semantics of isok() and isfinished() with respect to encode(). "inbuf" is the input buffer "outbuf" is the output buffer "flush" is if true, flushes the encoder Returns: true on success
Implements WvEncoder. Definition at line 63 of file wvblowfish.cc. References _encode(), WvBufBaseCommonImpl< unsigned char >::alloc(), bfkey, CFBDecrypt, CFBEncrypt, ECBDecrypt, ECBEncrypt, WvBufBaseCommonImpl< unsigned char >::get(), ivec, ivecoff, mode, WvBufBaseCommonImpl< unsigned char >::used(), and WvBuf. Referenced by _encode(). |
|
Template method implementation of finish(). Not called if any of the following cases are true:
The encoder is marked finished AFTER this function exits. Many implementations do not need to override this. If you also override _isok() or _isfinished(), note that they will NOT be consulted when determining whether or not to invoke this function. This allows finer control over the semantics of isok() and isfinished() with respect to finish(). "outbuf" is the output buffer Returns: true on success
Reimplemented in WvBase64Encoder, WvEVPMDDigest, WvHMACDigest, WvEncoderChain, WvGzipEncoder, WvTypedEncoder< unsigned char, float >, WvTypedEncoder< double, signed short >, WvTypedEncoder< signed short, double >, WvTypedEncoder< float, signed short >, WvTypedEncoder< signed short, float >, WvTypedEncoder< float, unsigned char >, WvTypedEncoder< double, double >, and WvTypedEncoder< IT, OT >. Definition at line 483 of file wvencoder.h. References WvEncoder::_finish(). Referenced by WvEncoder::_finish(), and WvEncoder::finish(). |
|
Template method implementation of geterror(). Not called if any of the following cases are true:
Most implementations do not need to override this. Returns: the error message, or the null string if _isok() == true
Reimplemented in WvEncoderChain, WvOggSpeexEncoder, and WvOggSpeexDecoder. Definition at line 433 of file wvencoder.h. Referenced by WvEncoder::geterror(). |
|
Template method implementation of isfinished(). Not called if any of the following cases are true:
Most implementations do not need to override this. Returns: true if the encoder is finished
Reimplemented in WvEncoderChain. Definition at line 416 of file wvencoder.h. Referenced by WvEncoder::isfinished(). |
|
Template method implementation of isok(). Not called if any of the following cases are true:
Most implementations do not need to override this. Returns: true if the encoder is ok
Reimplemented in WvEncoderChain, WvOggSpeexEncoder, and WvOggSpeexDecoder. Definition at line 400 of file wvencoder.h. Referenced by WvEncoder::isok(). |
|
Template method implementation of reset(). When this method is invoked, the current local state will be okay == true and finished == false. If false is returned, then okay will be set to false. May set a detailed error message if an error occurs. Returns: true on success, false on error or if not supported
Reimplemented from WvEncoder. Definition at line 29 of file wvblowfish.cc. References preparekey(). |
|
Reads data from the input buffer, encodes it, and writes the result to the output buffer. If flush == true, the input buffer will be drained and the output buffer will contain all of the encoded data including any that might have been buffered internally from previous calls. Thus it is possible that new data will be written to the output buffer even though the input buffer was empty when encode() was called. If the buffer could not be fully drained because there was insufficient data, this function returns false and leaves the remaining unflushed data in the buffer. If flush == false, the encoder will read and encode as much data as possible (or as it convenient) from the input buffer and store the results in the output buffer. Partial results may be buffered internally by the encoder to be written to the output buffer later when the encoder is flushed. If finish = true, the encode() will be followed up by a call to finish(). The return values will be ANDed together to yield the final result. Most useful when flush is also true. If a permanent error occurs, then isok() will return false, this function will return false and the input buffer will be left in an undefined state. If a recoverable error occurs, the encoder should discard the problematic data from the input buffer and return false from this function, but isok() will remain true. A stream might become isfinished() == true if an encoder- specific end-of-data marker was detected in the input. "inbuf" is the input buffer "outbuf" is the output buffer "flush" is if true, flushes the encoder "finish" is if true, calls finish() on success Returns: true on success
Reimplemented in WvTypedEncoder< unsigned char, float >, WvTypedEncoder< double, signed short >, WvTypedEncoder< signed short, double >, WvTypedEncoder< float, signed short >, WvTypedEncoder< signed short, float >, WvTypedEncoder< float, unsigned char >, WvTypedEncoder< double, double >, and WvTypedEncoder< IT, OT >. Definition at line 34 of file wvencoder.cc. References WvEncoder::_encode(), WvEncoder::encode(), WvEncoder::finish(), WvEncoder::finished, WvEncoder::okay, WvBufBaseCommonImpl< unsigned char >::used(), and WvBuf. Referenced by WvEncoderChain::_encode(), WvCounterModeEncoder::_encode(), WvEncoder::encode(), WvEncoder::encodebufmem(), WvEncoder::encodebufstr(), WvEncoder::flush(), WvEncoder::flushmembuf(), WvEncoder::flushstrbuf(), WvEncoder::flushstrstr(), main(), and WvDsp::uread(). |
|
Encodes data from a buffer to memory. The outlen parameter specifies by reference the length of the output buffer. It is updated in place to reflect the number of bytes copied to the output buffer. If the buffer was too small to hold the data, the overflow bytes will be discarded and false will be returned. "inmem" is the input data pointer "inlen" is the input data length "outmem" is the output data pointer "outlen" is the output data length, by reference "flush" is if true, flushes the encoder "finish" is if true, calls finish() on success Returns: true on success Definition at line 138 of file wvencoder.cc. References WvEncoder::encode(), WvEncoder::encodebufmem(), and WvBufBaseCommonImpl< unsigned >::used(). Referenced by WvEncoder::encodebufmem(), and WvEncoder::flushmemmem(). |
|
Encodes data from a buffer to a string. The output data is appended to the target string. "inbuf" is the input buffer "outstr" is the output string "flush" is if true, flushes the encoder "finish" is if true, calls finish() on success Returns: true on success Definition at line 95 of file wvencoder.cc. References WvString::append(), WvEncoder::encode(), and WvEncoder::encodebufstr(). Referenced by WvEncoder::encodebufstr(). |
|
Tells the encoder that NO MORE DATA will ever be encoded. The encoder will flush out any internally buffered data and write out whatever end-of-data marking it needs to the supplied output buffer before returning. Clients should invoke flush() on the input buffer before finish() if the input buffer was not yet empty. It is safe to call this function multiple times. The implementation will simply return isok() and do nothing else. "outbuf" is the output buffer Returns: true on success
Reimplemented in WvTypedEncoder< unsigned char, float >, WvTypedEncoder< double, signed short >, WvTypedEncoder< signed short, double >, WvTypedEncoder< float, signed short >, WvTypedEncoder< signed short, float >, WvTypedEncoder< float, unsigned char >, WvTypedEncoder< double, double >, and WvTypedEncoder< IT, OT >. Definition at line 47 of file wvencoder.cc. References WvEncoder::_finish(), WvEncoder::finish(), WvEncoder::finished, WvEncoder::okay, and WvEncoder::setfinished(). Referenced by WvEncoder::encode(), WvEncoder::finish(), WvEncoderStream::finish_read(), and WvEncoder::flush(). |
|
Flushes the encoder and optionally finishes it. "inbuf" is the input buffer "outbuf" is the output buffer "finish" is if true, calls finish() on success Returns: true on success Reimplemented in WvTypedEncoder< unsigned char, float >, WvTypedEncoder< double, signed short >, WvTypedEncoder< signed short, double >, WvTypedEncoder< float, signed short >, WvTypedEncoder< signed short, float >, WvTypedEncoder< float, unsigned char >, WvTypedEncoder< double, double >, and WvTypedEncoder< IT, OT >. Definition at line 163 of file wvencoder.h. References WvEncoder::encode(), and WvEncoder::finish(). Referenced by WvEncoderStream::finish_read(), and WvEncoderStream::flush_read(). |
|
Flushes data through the encoder from a buffer to memory. The outlen parameter specifies by reference the length of the output buffer. It is updated in place to reflect the number of bytes copied to the output buffer. If the buffer was too small to hold the data, the overflow bytes will be discarded and false will be returned. "inbuf" is the input buffer "outmem" is the output data pointer "outlen" is the output data length, by reference "finish" is if true, calls finish() on success Returns: true on success Definition at line 337 of file wvencoder.h. References WvEncoder::flushbufmem(). Referenced by WvEncoder::flushbufmem(), and WvEncoder::flushstrmem(). |
|
Flushes data through the encoder from a buffer to a string. The output data is appended to the target string. "inbuf" is the input buffer "outstr" is the output string "finish" is if true, calls finish() on success Returns: true on success Definition at line 249 of file wvencoder.h. References WvEncoder::flushbufstr(). Referenced by WvEncoder::flushbufstr(), and WvEncoder::strflushbuf(). |
|
Flushes data through the encoder from memory to a buffer. "inmem" is the input data pointer "inlen" is the input data length "outbuf" is the output buffer "finish" is if true, calls finish() on success Returns: true on success Definition at line 121 of file wvencoder.cc. References WvEncoder::encode(), and WvEncoder::flushmembuf(). Referenced by WvEncoder::flushmembuf(), and WvDsp::uwrite(). |
|
Flushes data through the encoder from memory to memory. The outlen parameter specifies by reference the length of the output buffer. It is updated in place to reflect the number of bytes copied to the output buffer. If the buffer was too small to hold the data, the overflow bytes will be discarded and false will be returned. "inmem" is the input data pointer "inlen" is the input data length "outmem" is the output data pointer "outlen" is the output data length, by reference "finish" is if true, calls finish() on success Returns: true on success Definition at line 130 of file wvencoder.cc. References WvEncoder::encodebufmem(), and WvEncoder::flushmemmem(). Referenced by WvEncoder::flushmemmem(). |
|
Flushes data through the encoder from a string to a buffer. "instr" is the input string "outbuf" is the output buffer "finish" is if true, calls finish() on success Returns: true on success Definition at line 75 of file wvencoder.cc. References WvEncoder::encode(), WvEncoder::flushstrbuf(), and WvStringParm. Referenced by WvEncoder::flushstrbuf(). |
|
Flushes data through the encoder from a string to memory. The outlen parameter specifies by reference the length of the output buffer. It is updated in place to reflect the number of bytes copied to the output buffer. If the buffer was too small to hold the data, the overflow bytes will be discarded and false will be returned. "instr" is the input string "outmem" is the output data pointer "outlen" is the output data length, by reference "finish" is if true, calls finish() on success Returns: true on success Definition at line 148 of file wvencoder.cc. References WvEncoder::flushbufmem(), and WvEncoder::flushstrmem(). Referenced by WvEncoder::flushstrmem(). |
|
Flushes data through the encoder from a string to a string. The output data is appended to the target string. "instr" is the input string "outstr" is the output string "finish" is if true, calls finish() on success Returns: true on success Definition at line 84 of file wvencoder.cc. References WvString::append(), WvEncoder::encode(), WvEncoder::flushstrstr(), and WvDynBuf. Referenced by encode64(), WvEncoder::flushstrstr(), and WvEncoder::strflushstr(). |
|
Returns an error message if any is available. Returns: the error message, or the null string is isok() == true Definition at line 21 of file wvencoder.cc. References WvEncoder::_geterror(), WvEncoder::errstr, and WvEncoder::isok(). Referenced by WvOggSpeexDecoder::_geterror(), and WvOggSpeexEncoder::_geterror(). |
|
Return true if mode is encrypting or false if decrypting.
Definition at line 58 of file wvblowfish.h. References CFBEncrypt, ECBEncrypt, and mode. |
|
Returns true if the encoder can no longer encode data. This will be set when the encoder detects and end-of-data mark in its input, or when finish() is called. Returns: true if the encoder is finished Definition at line 101 of file wvencoder.h. References WvEncoder::_isfinished(), and WvEncoder::finished. Referenced by WvSpeexDecoder::missing(). |
|
Returns true if the encoder has not encountered an error. This should only be used to record permanent failures. Transient errors (eg. bad block, but recoverable) should be detected in a different fashion. Returns: true if the encoder is ok Definition at line 90 of file wvencoder.h. References WvEncoder::_isok(), and WvEncoder::okay. Referenced by WvOggSpeexDecoder::_isok(), WvOggSpeexEncoder::_isok(), WvEncoder::geterror(), and WvSpeexDecoder::missing(). |
|
Definition at line 53 of file wvblowfish.cc. |
|
Asks an encoder to reset itself to its initial state at creation time, if supported. This function may be called at any time, even if isok() == false, or isfinished() == true. If the behaviour is not supported or an error occurs, then false is returned and afterwards isok() == false. Returns: true on success
Definition at line 58 of file wvencoder.cc. References WvEncoder::_reset(), WvEncoder::errstr, WvEncoder::finished, WvEncoder::okay, and WvEncoder::seterror(). |
|
Sets an error condition, then setnotok().
Definition at line 379 of file wvencoder.h. References WVSTRING_FORMAT_CALL. |
|
Sets an error condition, then setnotok().
Definition at line 375 of file wvencoder.h. References WvEncoder::errstr, WvEncoder::seterror(), and WvEncoder::setnotok(). Referenced by WvEncoder::reset(), and WvEncoder::seterror(). |
|
Sets 'finished' to true explicitly.
Definition at line 383 of file wvencoder.h. References WvEncoder::finished. Referenced by WvBase64Decoder::_encode(), WvOggVorbisDecoder::_typedencode(), WvOggSpeexDecoder::_typedencode(), and WvEncoder::finish(). |
|
Sets the current Blowfish initialization vector. "iv" is the new IV must be 8 bytes Definition at line 46 of file wvblowfish.cc. References ivec, ivecoff, and setiv(). Referenced by setiv(). |
|
Sets the current Blowfish key and resets the initialization vector to all nulls. "key" is the new key "keysize" is the key size in bytes Definition at line 36 of file wvblowfish.cc. References key, keysize, preparekey(), and setkey(). Referenced by setkey(), and WvBlowfishEncoder(). |
|
Sets 'okay' to false explicitly.
Definition at line 371 of file wvencoder.h. References WvEncoder::okay. Referenced by WvEncoder::seterror(). |
|
Flushes data through the encoder from a buffer to a string. "inbuf" is the input buffer "finish" is if true, calls finish() on success Returns: the resulting encoded string, does not signal errors Definition at line 113 of file wvencoder.cc. References WvEncoder::flushbufstr(), and WvEncoder::strflushbuf(). Referenced by WvEncoder::strflushbuf(), and WvEncoder::strflushmem(). |
|
Flushes data through the encoder from memory to a string. "inmem" is the input data pointer "inlen" is the input data length "finish" is if true, calls finish() on success Returns: the resulting encoded string, does not signal errors Definition at line 156 of file wvencoder.cc. References WvEncoder::strflushbuf(), and WvEncoder::strflushmem(). Referenced by WvEncoder::strflushmem(). |
|
Flushes data through the encoder from a string to a string. "inbuf" is the input buffer "finish" is if true, calls finish() on success Returns: the resulting encoded string, does not signal errors Definition at line 105 of file wvencoder.cc. References WvEncoder::flushstrstr(), and WvEncoder::strflushstr(). Referenced by WvEncoder::strflushstr(). |
|
Definition at line 70 of file wvblowfish.h. Referenced by _encode(), preparekey(), and ~WvBlowfishEncoder(). |
|
the error message Definition at line 72 of file wvencoder.h. Referenced by WvEncoder::geterror(), WvEncoder::reset(), and WvEncoder::seterror(). |
|
true iff setfinished()/finish() was called Definition at line 71 of file wvencoder.h. Referenced by WvEncoder::encode(), WvEncoder::finish(), WvEncoder::isfinished(), WvEncoder::reset(), and WvEncoder::setfinished(). |
|
Definition at line 71 of file wvblowfish.h. Referenced by _encode(), preparekey(), and setiv(). |
|
Definition at line 72 of file wvblowfish.h. Referenced by _encode(), preparekey(), and setiv(). |
|
Definition at line 69 of file wvblowfish.h. Referenced by preparekey(), setkey(), and ~WvBlowfishEncoder(). |
|
Definition at line 68 of file wvblowfish.h. Referenced by preparekey(), and setkey(). |
|
Definition at line 67 of file wvblowfish.h. Referenced by _encode(), and is_encrypting(). |
|
false iff setnotok() was called Definition at line 70 of file wvencoder.h. Referenced by WvEncoder::encode(), WvEncoder::finish(), WvEncoder::isok(), WvEncoder::reset(), and WvEncoder::setnotok(). |