Yate

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | List of all members
Cipher Class Referenceabstract

An abstract cipher. More...

`#include <yateclass.h>`

Inheritance diagram for Cipher:

## 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)
Public Member Functions inherited from GenObject
| GenObject ()
virtual | ~GenObject ()
virtual bool | alive () const
virtual void | destruct ()
virtual const String & | toString () const
virtual const String & | traceId () const
NamedCounter * | getObjCounter () const
NamedCounter * | setObjCounter (NamedCounter *counter)

## Static Public Member Functions
static const TokenDict * | directions ()
static Direction | direction (const char *name, Direction defdir=Bidir)
Static Public Member Functions inherited from GenObject
static void * | getObject (const String &name, const GenObject *obj)
static bool | getObjCounting ()
static void | setObjCounting (bool enable)
static NamedCounter * | getObjCounter (const String &name, bool create=true)
static ObjList & | getObjCounters ()

## 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

  len | Length 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

  len | Length of data to encrypt or decrypt in bytes

Returns
  Length of required buffer in bytes

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

Decrypt data

Parameters

  outData | Pointer to buffer for output (decrypted) and possibly input data
  len | Length of output data, may not be multiple of block size
  inpData | Pointer to buffer containing input (encrypted) data, NULL to decrypt in place

Returns
  True if data was successfully decrypted

Referenced by Cipher::decrypt().

bool decrypt | ( | DataBlock & | data | ) |
| inline

Decrypt a DataBlock in place

Parameters

  data | Data block to decrypt

Returns
  True if data was successfully decrypted

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

static Direction direction | ( | const char * | name,
|  | Direction | defdir = `Bidir`
| ) |  |
| inline static

Get a direction from the dictionary given the name

Parameters

  name | Name of the direction
  defdir | Default 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

  outData | Pointer to buffer for output (encrypted) and possibly input data
  len | Length of output data, may not be multiple of block size
  inpData | Pointer to buffer containing input (unencrypted) data, NULL to encrypt in place

Returns
  True if data was successfully encrypted

Referenced by Cipher::encrypt().

bool encrypt | ( | DataBlock & | data | ) |
| inline

Encrypt a DataBlock in place

Parameters

  data | Data block to encrypt

Returns
  True if data was successfully encrypted

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

virtual void* getObject | ( | const String & | name | ) | const
| virtual

Get a pointer to a derived class given that class name

Parameters

  name | Name 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

  vect | Pointer to binary Initialization Vector data
  len | Length of Initialization Vector in bytes
  dir | Direction to set the Initialization Vector for

Returns
  True if the Initialization Vector was set successfully

Referenced by Cipher::initVector().

bool initVector | ( | const DataBlock & | vect,
|  | Direction | dir = `Bidir`
| ) |  |
| inline

Set the Initialization Vector is applicable

Parameters

  vect | Binary Initialization Vector
  dir | Direction to set the Initialization Vector for

Returns
  True if the Initialization Vector was set successfully

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

virtual unsigned int initVectorSize | ( |  | ) | const
| virtual

Get the initialization vector size

Returns
  Initialization vector size in bytes, 0 if not applicable

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

Set the key required to encrypt or decrypt data

Parameters

  key | Pointer to binary key data
  len | Length of key in bytes
  dir | Direction to set key for

Returns
  True if the key was set successfully

Referenced by Cipher::setKey().

bool setKey | ( | const DataBlock & | key,
|  | Direction | dir = `Bidir`
| ) |  |
| inline

Set the key required to encrypt or decrypt data

Parameters

  key | Binary key data block
  dir | Direction to set key for

Returns
  True if the key was set successfully

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

virtual bool valid | ( | Direction | dir = `Bidir` | ) | const
| virtual

Check if the cipher instance is valid for a specific direction

Parameters

  dir | Direction 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:

- yateclass.h