Yate
Public Types | Public Member Functions | Static Public Member Functions

Cipher Class Reference

An abstract cipher. More...

#include <yateclass.h>

Inheritance diagram for Cipher:
GenObject

List of all members.

Public Types

enum  Direction { Bidir, Encrypt, Decrypt }

Public Member Functions

virtual ~Cipher ()
virtual void * getObject (const String &name) const
virtual bool valid (Direction dir=Bidir) const
virtual unsigned int blockSize () const =0
virtual unsigned int initVectorSize () const
unsigned int bufferSize (unsigned int len) const
bool bufferFull (unsigned int len) const
virtual bool setKey (const void *key, unsigned int len, Direction dir=Bidir)=0
bool setKey (const DataBlock &key, Direction dir=Bidir)
virtual bool initVector (const void *vect, unsigned int len, Direction dir=Bidir)
bool initVector (const DataBlock &vect, Direction dir=Bidir)
virtual bool encrypt (void *outData, unsigned int len, const void *inpData=0)=0
bool encrypt (DataBlock &data)
virtual bool decrypt (void *outData, unsigned int len, const void *inpData=0)=0
bool decrypt (DataBlock &data)

Static Public Member Functions

static const TokenDictdirections ()
static Direction direction (const char *name, Direction defdir=Bidir)

Detailed Description

An abstract cipher.

The Cipher class provides an abstraction for data encryption classes


Member Enumeration Documentation

enum Direction

Cipher direction


Constructor & Destructor Documentation

virtual ~Cipher ( ) [virtual]

Destructor


Member Function Documentation

virtual unsigned int blockSize ( ) const [pure virtual]

Get the cipher block size

Returns:
Cipher block size in bytes
bool bufferFull ( unsigned int  len) const

Check if a buffer length is multiple of block size

Parameters:
lenLength of data to encrypt or decrypt in bytes
Returns:
True if buffer length is multiple of block size
unsigned int bufferSize ( unsigned int  len) const

Round up a buffer length to a multiple of block size

Parameters:
lenLength of data to encrypt or decrypt in bytes
Returns:
Length of required buffer in bytes
bool decrypt ( DataBlock data) [inline]

Decrypt a DataBlock in place

Parameters:
dataData block to decrypt
Returns:
True if data was successfully decrypted

References DataBlock::data(), Cipher::decrypt(), and DataBlock::length().

Referenced by Cipher::decrypt().

virtual bool decrypt ( void *  outData,
unsigned int  len,
const void *  inpData = 0 
) [pure virtual]

Decrypt data

Parameters:
outDataPointer to buffer for output (decrypted) and possibly input data
lenLength of output data, may not be multiple of block size
inpDataPointer to buffer containing input (encrypted) data, NULL to decrypt in place
Returns:
True if data was successfully decrypted
static Direction direction ( const char *  name,
Direction  defdir = Bidir 
) [inline, static]

Get a direction from the dictionary given the name

Parameters:
nameName of the direction
defdirDefault direction to return if name is empty or unknown
Returns:
Direction associated with the given name

References TelEngine::lookup().

static const TokenDict* directions ( ) [inline, static]

Get the dictionary of cipher directions

Returns:
Pointer to the dictionary of cipher directions
virtual bool encrypt ( void *  outData,
unsigned int  len,
const void *  inpData = 0 
) [pure virtual]

Encrypt data

Parameters:
outDataPointer to buffer for output (encrypted) and possibly input data
lenLength of output data, may not be multiple of block size
inpDataPointer to buffer containing input (unencrypted) data, NULL to encrypt in place
Returns:
True if data was successfully encrypted
bool encrypt ( DataBlock data) [inline]

Encrypt a DataBlock in place

Parameters:
dataData block to encrypt
Returns:
True if data was successfully encrypted

References DataBlock::data(), Cipher::encrypt(), and DataBlock::length().

Referenced by Cipher::encrypt().

virtual void* getObject ( const String name) const [virtual]

Get a pointer to a derived class given that class name

Parameters:
nameName of the class we are asking for
Returns:
Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from GenObject.

virtual bool initVector ( const void *  vect,
unsigned int  len,
Direction  dir = Bidir 
) [virtual]

Set the Initialization Vector if applicable

Parameters:
vectPointer to binary Initialization Vector data
lenLength of Initialization Vector in bytes
dirDirection to set the Initialization Vector for
Returns:
True if the Initialization Vector was set successfully
bool initVector ( const DataBlock vect,
Direction  dir = Bidir 
) [inline]

Set the Initialization Vector is applicable

Parameters:
vectBinary Initialization Vector
dirDirection to set the Initialization Vector for
Returns:
True if the Initialization Vector was set successfully

References DataBlock::data(), Cipher::initVector(), and DataBlock::length().

Referenced by Cipher::initVector().

virtual unsigned int initVectorSize ( ) const [virtual]

Get the initialization vector size

Returns:
Initialization vector size in bytes, 0 if not applicable
bool setKey ( const DataBlock key,
Direction  dir = Bidir 
) [inline]

Set the key required to encrypt or decrypt data

Parameters:
keyBinary key data block
dirDirection to set key for
Returns:
True if the key was set successfully

References DataBlock::data(), DataBlock::length(), and Cipher::setKey().

Referenced by Cipher::setKey().

virtual bool setKey ( const void *  key,
unsigned int  len,
Direction  dir = Bidir 
) [pure virtual]

Set the key required to encrypt or decrypt data

Parameters:
keyPointer to binary key data
lenLength of key in bytes
dirDirection to set key for
Returns:
True if the key was set successfully
virtual bool valid ( Direction  dir = Bidir) const [virtual]

Check if the cipher instance is valid for a specific direction

Parameters:
dirDirection to check
Returns:
True if the cipher is able to perform operation on given direction

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