encryption Class Referenceabstract

Inherited by aes128.

## Public Member Functions

| encryption ()
virtual | ~encryption ()
virtual bool | setKey (const unsigned char *key, size_t keysize)
virtual void | setRandomKey ()
virtual unsigned char * | getKey ()
virtual uint32_t | getKeySize ()=0
virtual bool | setIv (const unsigned char *iv, size_t ivsize)
virtual void | setRandomIv ()
virtual unsigned char * | getIv ()
virtual uint32_t | getIvSize ()=0
virtual bool | append (const unsigned char *data, uint32_t size)
virtual const unsigned char * | getEncryptedData ()=0
virtual uint64_t | getEncryptedDataSize ()
virtual const unsigned char * | getDecryptedData ()=0
virtual uint64_t | getDecryptedDataSize ()
virtual bool | clear ()
virtual encryptionerror_t | getError ()

## Detailed Description

The encryption class provides a simple encryption interface.

## Constructor & Destructor Documentation

## encryption()

encryption::encryption | ( |  | ) |

Creates an instance of the encryption class.

## ~encryption()

virtual encryption::~encryption | ( |  | ) |

virtual

Deletes this instance of the encryption class.

## Member Function Documentation

## append()

virtual bool encryption::append | ( | const unsigned char * | data,
|  | uint32_t | size
| ) |  |

virtual

Appends "size" bytes of "data" to the data to be encrypted/decrypted. Returns true on success or false if an error occurred.

## clear()

virtual bool encryption::clear | ( |  | ) |

virtual

Clears the current encrypted/decrypted data and any data that had previously been appended. Does not clear the key or initialization vector. Returns true on success or false if an error occurred.

## getDecryptedData()

virtual const unsigned char* encryption::getDecryptedData | ( |  | ) |

pure virtual

Interprets the current data as encrypted. Decrypts the current data. Returns the decrypted data on success or NULL if an error occurred. Note that the decrypted data returned will be an empty string if no data has been appended yet.

Implemented in aes128.

## getDecryptedDataSize()

virtual uint64_t encryption::getDecryptedDataSize | ( |  | ) |

virtual

Returns the number of bytes of decrypted data.

## getEncryptedData()

virtual const unsigned char* encryption::getEncryptedData | ( |  | ) |

pure virtual

Interprets the current data as unencrypted. Encrypts the current data. Returns the encrypted data on success or NULL if an error occurred. Note that the encrypted data returned will be an empty string if no data has been appended yet.

Implemented in aes128.

## getEncryptedDataSize()

virtual uint64_t encryption::getEncryptedDataSize | ( |  | ) |

virtual

Returns the number of bytes of encrypted data.

## getError()

virtual encryptionerror_t encryption::getError | ( |  | ) |

virtual

Returns the most recent error.

## getIv()

virtual unsigned char* encryption::getIv | ( |  | ) |

virtual

Returns the initialization vector currently used for encryption/decryption. If no initialization vector has been set, then this will be a block of 0's.

## getIvSize()

virtual uint32_t encryption::getIvSize | ( |  | ) |

pure virtual

Returns the number of bytes in the initialization vector.

Implemented in aes128.

## getKey()

virtual unsigned char* encryption::getKey | ( |  | ) |

virtual

Returns the key currently used for encryption/decryption. If no key has been set, then this will be a block of 0's.

## getKeySize()

virtual uint32_t encryption::getKeySize | ( |  | ) |

pure virtual

Returns the number of bytes in the key.

Implemented in aes128.

## setIv()

virtual bool encryption::setIv | ( | const unsigned char * | iv,
|  | size_t | ivsize
| ) |  |

virtual

Sets the initialization vector used for encryption/decryption to the first "ivsize" bytes of "iv". Returns true on success and false on failure. The most common failure is that "ivsize" is not the correct number of bytes. The method getKeySize() returns the correct number of bytes for the key.

## setKey()

virtual bool encryption::setKey | ( | const unsigned char * | key,
|  | size_t | keysize
| ) |  |

virtual

Sets the key used for encryption/decryption to the first "keysize" bytes of "key". Returns true on success and false on failure. The most common failure is that "keysize" is not the correct number of bytes. The method getKeySize() returns the correct number of bytes for the key.

## setRandomIv()

virtual void encryption::setRandomIv | ( |  | ) |

virtual

Sets the initialization vector used encryption/decryption to random data. The data used can be retrived using getKey().

## setRandomKey()

virtual void encryption::setRandomKey | ( |  | ) |

virtual

Sets the key used for encryption/decryption to random data. The data used can be retrived using getKey().