libhomegear-base
0.7
Base library for Homegear and Homegear family modules.
|
#include <Gcrypt.h>
Public Member Functions | |
Gcrypt (int algorithm, int mode, unsigned int flags) | |
Constructor. More... | |
virtual | ~Gcrypt () |
Destructor. More... | |
void | reset () |
Resets everything. More... | |
gcry_cipher_hd_t | getHandle () |
Returns the underlying gcry_cipher_hd_t. More... | |
size_t | getBlockSize () |
Returns the block size of the algorithm used in bytes. More... | |
template<typename Data > | |
void | setIv (const Data &iv) |
Sets the IV to use. More... | |
void | setIv (const void *iv, const size_t length) |
Takes same parameters as gcry_cipher_setiv() except for the handle. More... | |
template<typename Data > | |
void | setCounter (const Data &counter) |
Sets the counter to use. More... | |
void | setCounter (const void *counter, const size_t length) |
Takes same parameters as gcry_cipher_setctr() except for the handle. More... | |
template<typename Data > | |
void | setKey (const Data &key) |
Sets the key to use. More... | |
void | setKey (const void *key, const size_t length) |
Takes same parameters as gcry_cipher_setkey() except for the handle. More... | |
void | encrypt (void *out, const size_t outLength, const void *in, const size_t inLength) |
Encrypts data. More... | |
template<typename DataOut , typename DataIn > | |
void | encrypt (DataOut &out, const DataIn &in) |
Encrypt data. More... | |
void | decrypt (void *out, const size_t outLength, const void *in, const size_t inLength) |
Decrypts data. More... | |
template<typename DataOut , typename DataIn > | |
void | decrypt (DataOut &out, const DataIn &in) |
Decrypt data. More... | |
bool | authenticate (const void *in, const size_t inLength) |
Authenticates encrypted data if supported by the algorithm. More... | |
template<typename DataIn > | |
bool | authenticate (const DataIn &in) |
Authenticates encrypted data. More... | |
Static Public Member Functions | |
static std::string | getError (int32_t errorCode) |
Gets the error message to a GCRYPT error code. More... | |
BaseLib::Security::Gcrypt::Gcrypt | ( | int | algorithm, |
int | mode, | ||
unsigned int | flags | ||
) |
Constructor.
Takes the same arguments as gcry_cipher_open().
algorithm | See https://www.gnupg.org/documentation/manuals/gcrypt/Available-ciphers.html#Available-ciphers for a list of ciphers and the according constants. |
mode | See https://www.gnupg.org/documentation/manuals/gcrypt/Available-cipher-modes.html#Available-cipher-modes. Note that the mode needs to be compatible to the algorithm used. |
flags | 0 or the bit-wise OR of the following constants: GCRY_CIPHER_SECURE (allocate everything in secure memory), GCRY_CIPHER_ENABLE_SYNC (CFB sync mode for OpenPGP), GCRY_CIPHER_CBC_CTS (Enable cipher text stealing for CBC), GCRY_CIPHER_CBC_MAC (compute CBC-MAC checksums, same as CBC but only outputs the last block) |
GcryptException | On error. |
|
virtual |
Destructor.
bool BaseLib::Security::Gcrypt::authenticate | ( | const void * | in, |
const size_t | inLength | ||
) |
Authenticates encrypted data if supported by the algorithm.
Takes same parameters as gcry_cipher_authenticate() except for the handle.
bool BaseLib::Security::Gcrypt::authenticate | ( | const DataIn & | in | ) |
Authenticates encrypted data.
void BaseLib::Security::Gcrypt::decrypt | ( | void * | out, |
const size_t | outLength, | ||
const void * | in, | ||
const size_t | inLength | ||
) |
Decrypts data.
Takes same parameters as gcry_cipher_decrypt() except for the handle.
GcryptException | On error. |
void BaseLib::Security::Gcrypt::decrypt | ( | DataOut & | out, |
const DataIn & | in | ||
) |
Decrypt data.
GcryptException | On error. |
void BaseLib::Security::Gcrypt::encrypt | ( | void * | out, |
const size_t | outLength, | ||
const void * | in, | ||
const size_t | inLength | ||
) |
Encrypts data.
Takes same parameters as gcry_cipher_encrypt() except for the handle.
GcryptException | On error. |
void BaseLib::Security::Gcrypt::encrypt | ( | DataOut & | out, |
const DataIn & | in | ||
) |
Encrypt data.
GcryptException | On error. |
size_t BaseLib::Security::Gcrypt::getBlockSize | ( | ) |
Returns the block size of the algorithm used in bytes.
|
static |
Gets the error message to a GCRYPT error code.
errorCode | The GCRYPT error code. |
|
inline |
Returns the underlying gcry_cipher_hd_t.
void BaseLib::Security::Gcrypt::reset | ( | ) |
Resets everything.
void BaseLib::Security::Gcrypt::setCounter | ( | const Data & | counter | ) |
Sets the counter to use.
GcryptException | On error. |
void BaseLib::Security::Gcrypt::setCounter | ( | const void * | counter, |
const size_t | length | ||
) |
Takes same parameters as gcry_cipher_setctr() except for the handle.
GcryptException | On error. |
void BaseLib::Security::Gcrypt::setIv | ( | const Data & | iv | ) |
Sets the IV to use.
GcryptException | On error. |
void BaseLib::Security::Gcrypt::setIv | ( | const void * | iv, |
const size_t | length | ||
) |
Takes same parameters as gcry_cipher_setiv() except for the handle.
GcryptException | On error. |
void BaseLib::Security::Gcrypt::setKey | ( | const Data & | key | ) |
Sets the key to use.
GcryptException | On error. |
void BaseLib::Security::Gcrypt::setKey | ( | const void * | key, |
const size_t | length | ||
) |
Takes same parameters as gcry_cipher_setkey() except for the handle.
GcryptException | On error. |