|
Yate
|
An abstract cipher. More...
#include <yateclass.h>
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 TokenDict * | directions () |
| static Direction | direction (const char *name, Direction defdir=Bidir) |
An abstract cipher.
The Cipher class provides an abstraction for data encryption classes
| virtual ~Cipher | ( | ) | [virtual] |
Destructor
| virtual unsigned int blockSize | ( | ) | const [pure virtual] |
Get the cipher block size
| bool bufferFull | ( | unsigned int | len | ) | const |
Check if a buffer length is multiple of block size
| len | Length of data to encrypt or decrypt in bytes |
| unsigned int bufferSize | ( | unsigned int | len | ) | const |
Round up a buffer length to a multiple of block size
| len | Length of data to encrypt or decrypt in bytes |
| virtual bool decrypt | ( | void * | outData, |
| unsigned int | len, | ||
| const void * | inpData = 0 |
||
| ) | [pure virtual] |
Decrypt data
| 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 |
Decrypt a DataBlock in place
| data | Data block to decrypt |
References DataBlock::data(), Cipher::decrypt(), and DataBlock::length().
Referenced by Cipher::decrypt().
Get a direction from the dictionary given the name
| name | Name of the direction |
| defdir | Default direction to return if name is empty or unknown |
References TelEngine::lookup().
| static const TokenDict* directions | ( | ) | [inline, static] |
Get the dictionary of cipher directions
| virtual bool encrypt | ( | void * | outData, |
| unsigned int | len, | ||
| const void * | inpData = 0 |
||
| ) | [pure virtual] |
Encrypt data
| 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 |
Encrypt a DataBlock in place
| data | Data block to encrypt |
References DataBlock::data(), Cipher::encrypt(), and DataBlock::length().
Referenced by Cipher::encrypt().
Get a pointer to a derived class given that class name
| name | Name of the class we are asking for |
Reimplemented from GenObject.
| virtual bool initVector | ( | const void * | vect, |
| unsigned int | len, | ||
| Direction | dir = Bidir |
||
| ) | [virtual] |
Set the Initialization Vector if applicable
| vect | Pointer to binary Initialization Vector data |
| len | Length of Initialization Vector in bytes |
| dir | Direction to set the Initialization Vector for |
| bool initVector | ( | const DataBlock & | vect, |
| Direction | dir = Bidir |
||
| ) | [inline] |
Set the Initialization Vector is applicable
| vect | Binary Initialization Vector |
| dir | Direction to set the Initialization Vector for |
References DataBlock::data(), Cipher::initVector(), and DataBlock::length().
Referenced by Cipher::initVector().
| virtual unsigned int initVectorSize | ( | ) | const [virtual] |
Get the initialization vector size
Set the key required to encrypt or decrypt data
| key | Pointer to binary key data |
| len | Length of key in bytes |
| dir | Direction to set key for |
Set the key required to encrypt or decrypt data
| key | Binary key data block |
| dir | Direction to set key for |
References DataBlock::data(), DataBlock::length(), and Cipher::setKey().
Referenced by Cipher::setKey().
Check if the cipher instance is valid for a specific direction
| dir | Direction to check |
1.7.6.1