cx::Encrypter Class Reference

Encryption version of AES Cipher. More...

#include <Encrypter.hpp>

Inheritance diagram for cx::Encrypter:
cx::AesCipher cx::Filter cx::ConcreteNode cx::NonCopyable

List of all members.

Public Member Functions

 Encrypter (const char(&key)[32])
 Constructor.
 Encrypter (const char(&key)[24])
 Constructor.
 Encrypter (const char(&key)[16])
 Constructor.
void pass (Chunk &chunk)
 Process a chunk of data.
void finish (Chunk &out)
 Finish data processing.
void apply (Chunk &chunk)
 Completelly filter the provided data.

Protected Types

typedef int(* setupFunct )(unsigned long *rk, const unsigned char *key, int keybits)
 Cipher setup function.
typedef void(* cipherFunct )(const unsigned long *rk, int nrounds, const unsigned char ciphertext[16], unsigned char plaintext[16])
 Cipher processing function.

Protected Member Functions

void wait ()
 Wait for the pipeline to terminate.
void beforeDestruction ()
 Handy cleanup.
void setStream (Stream *stream)
 Change the owning stream.

Detailed Description

Encryption version of AES Cipher.

This filter applies the Rijndael cipher to encrypt each chunk of data.

This cipher works with fixed sized blocks of 16 bytes, so if you try to cipher unstructured data (eg. plain text file or plain byte stream) extra padding may be added in the last block. So it is recommended to use this cipher with streams derived from cx::DataInputStream and cx::DataOutputStream only. Dealing with the padding for unstructured data may be part of a future release.

Example of using the Encrypter with a cx::FileOutputStream:

 cx::Encrypter cipher;
 cx::FileOutputStream stream(cipher, "encrypted.dat");
 // write some data
 stream << myData;
 ...
 stream.close();

Note: Remember to catch eventual exceptions when using pipeline components (Stream, filters, producers and consumers).

See also:
cx::Decrypter
cx::Filter
cx::DataInputStream
cx::DataoutputStream

Definition at line 40 of file Encrypter.hpp.


Member Typedef Documentation

typedef void(* cx::AesCipher::cipherFunct)(const unsigned long *rk, int nrounds, const unsigned char ciphertext[16], unsigned char plaintext[16]) [protected, inherited]

Cipher processing function.

Definition at line 120 of file AesCipher.hpp.

typedef int(* cx::AesCipher::setupFunct)(unsigned long *rk, const unsigned char *key, int keybits) [protected, inherited]

Cipher setup function.

Definition at line 109 of file AesCipher.hpp.


Constructor & Destructor Documentation

cx::Encrypter::Encrypter ( const char(&)  key[32]  )  [explicit]

Constructor.

Setup the cipher with a secret key of a fixed size.

Parameters:
key Secret symmetric key with 32 bytes.
cx::Encrypter::Encrypter ( const char(&)  key[24]  )  [explicit]

Constructor.

Setup the cipher with a secret key of a fixed size.

Parameters:
key Secret symmetric key with 24 bytes.
cx::Encrypter::Encrypter ( const char(&)  key[16]  )  [explicit]

Constructor.

Setup the cipher with a secret key of a fixed size.

Parameters:
key Secret symmetric key with 16 bytes.

Member Function Documentation

void cx::Filter::apply ( Chunk chunk  )  [inherited]

Completelly filter the provided data.

Parameters:
[in,out] chunk The data to be filtered. It is directly modified by the filter.
void cx::ConcreteNode::beforeDestruction (  )  [protected, inherited]

Handy cleanup.

This function safelly wait for the stream conclusion (if assigned), so that classes can finally clean up their resources. This function should be called on derived classes destructors before cleaning up their critical structures. Otherwise, a stream may try to access strucutures during their destruction.

void cx::AesCipher::finish ( Chunk out  )  [virtual, inherited]

Finish data processing.

Flush any buffered data to out.

See also:
cx::Filter::finish

Reimplemented from cx::Filter.

void cx::AesCipher::pass ( Chunk chunk  )  [virtual, inherited]

Process a chunk of data.

See also:
cx::Filter::pass

Implements cx::Filter.

void cx::ConcreteNode::setStream ( Stream stream  )  [protected, inherited]

Change the owning stream.

This function is called by Stream itself when being constructed.

void cx::ConcreteNode::wait (  )  [protected, inherited]

Wait for the pipeline to terminate.

If it's being used on a pipeline stream, it blocks execution until the stream finish.


The documentation for this class was generated from the following file: