An abstract cipher.
More...
#include <yateclass.h>
|
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) |
|
| GenObject () |
|
virtual | ~GenObject () |
|
virtual bool | alive () const |
|
virtual void | destruct () |
|
virtual const String & | toString () const |
|
virtual const String & | traceId () const |
|
virtual void * | getObject (const String &name) const |
|
NamedCounter * | getObjCounter () const |
|
NamedCounter * | setObjCounter (NamedCounter *counter) |
|
An abstract cipher.
The Cipher class provides an abstraction for data encryption classes
◆ Direction
◆ ~Cipher()
◆ blockSize()
virtual unsigned int blockSize |
( |
| ) |
const |
|
pure virtual |
Get the cipher block size
- Returns
- Cipher block size in bytes
◆ bufferFull()
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
◆ bufferSize()
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
◆ decrypt() [1/2]
◆ decrypt() [2/2]
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
◆ direction()
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
◆ directions()
Get the dictionary of cipher directions
- Returns
- Pointer to the dictionary of cipher directions
◆ encrypt() [1/2]
◆ encrypt() [2/2]
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
◆ getObject()
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.
◆ initVector() [1/2]
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(), and DataBlock::length().
◆ initVector() [2/2]
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
◆ initVectorSize()
virtual unsigned int initVectorSize |
( |
| ) |
const |
|
virtual |
Get the initialization vector size
- Returns
- Initialization vector size in bytes, 0 if not applicable
◆ setKey() [1/2]
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(), and DataBlock::length().
◆ setKey() [2/2]
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
◆ valid()
virtual bool valid |
( |
Direction |
dir = Bidir | ) |
const |
|
virtual |
Check if the cipher instance is valid for a specific direction
- Parameters
-
- Returns
- True if the cipher is able to perform operation on given direction
The documentation for this class was generated from the following file: