#include <crypt.h>
Public Member Functions | |
Crypt (const Crypt &c) | |
Crypt (const Key &k) throw (YAPETException) | |
Constructor. | |
template<class T> | |
Record< T > * | decrypt (const BDBuffer &data) throw (YAPETException, YAPETEncryptionException) |
Decrypts data. | |
template<class T> | |
BDBuffer * | encrypt (const Record< T > &data) throw (YAPETException, YAPETEncryptionException) |
Encrypts data. | |
uint32_t | getIVLength () const |
Returns the length of the initialization vector. | |
uint32_t | getKeyLength () const |
Returns the length of the key. | |
const Crypt & | operator= (const Crypt &c) |
~Crypt () | |
Private Attributes | |
const EVP_CIPHER * | cipher |
Pointer to the cipher used for encryption/decryption. | |
uint32_t | iv_length |
Length of the initialization vector. | |
Key | key |
the key used for encryption/decryption | |
uint32_t | key_length |
Length of the encryption/decryption key. |
Key
.
Encrypted data is returned in BDBuffer
. Decrypted data is returned as a struct as defined in structs.h
using the template Record
.
Currently, the blowfish algorithm in CBC mode from the openssl library is used for encryption and decryption. The class itself does not have any encryption/decryption logic.
Definition at line 57 of file crypt.h.
Crypt::Crypt | ( | const Key & | k | ) | throw (YAPETException) |
Initializes the class with the given key, which is used for encryption and decryption.
The constructor tries to set the key length of the cipher used to the length of the key provided. If this fails, a YAPETException
is thrown.
k | the key used for encryption/decryption. |
YAPETException | in case the key length of the cipher cannot be set to the length of the key provided. |
Record<T>* YAPET::Crypt::decrypt | ( | const BDBuffer & | data | ) | throw (YAPETException, YAPETEncryptionException) [inline] |
Decrypts the data supplied in the BDBuffer
. It returns the decrypted data as a Record
of the specified type.
The Record
has to be freed by the caller.
data | the BDBuffer to decrypt. |
Record
of the specified type, holding the decrypted data. The caller is responsible for freeing the memory occupied by the object returned.YAPETException | ||
YAPETEncryptionException |
Definition at line 216 of file crypt.h.
References YAPET::BDBuffer::at(), cipher, YAPET::Key::getIVec(), iv_length, YAPET::Key::ivec_size(), key, YAPET::BDBuffer::resize(), YAPET::BDBuffer::size(), and YAPET::Key::size().
Referenced by YAPET::File::getMasterPWSet(), YAPET::File::initFile(), YAPET::PartDec::PartDec(), PasswordRecord::refresh(), YAPET::File::setNewKey(), and YAPET::File::validateKey().
BDBuffer* YAPET::Crypt::encrypt | ( | const Record< T > & | data | ) | throw (YAPETException, YAPETEncryptionException) [inline] |
Encrypts the data provided in data
which has to be an instance of the Record
template.
The encrypted data is returned as BDBuffer
with the size set exactly to the size of the encrypted data. The memory occupied by this object has to be freed by the caller.
data | the data to be encrypted. |
BDBuffer
holding the encrypted data. The caller is responsible for freeing the memory occupied by the object returned.YAPETException | ||
YAPETEncryptionException |
Definition at line 139 of file crypt.h.
References YAPET::BDBuffer::at(), cipher, YAPET::Key::getIVec(), iv_length, YAPET::Key::ivec_size(), key, YAPET::BDBuffer::resize(), YAPET::BDBuffer::size(), and YAPET::Key::size().
Referenced by YAPET::File::setNewKey(), YAPET::PartDec::setRecord(), and YAPET::File::writeHeader().
uint32_t YAPET::Crypt::getIVLength | ( | ) | const [inline] |
uint32_t YAPET::Crypt::getKeyLength | ( | ) | const [inline] |
Returns the length in bytes of the key the cipher algorithm expects.
Definition at line 113 of file crypt.h.
References key_length.
const EVP_CIPHER* YAPET::Crypt::cipher [private] |
Pointer the cipher implemented in the openssl library. Currently, blowfish is used for encryption/decryption.
Definition at line 67 of file crypt.h.
Referenced by decrypt(), encrypt(), and operator=().
uint32_t YAPET::Crypt::iv_length [private] |
Length of the initialization vector as expected by the cipher implementation in bytes.
Definition at line 74 of file crypt.h.
Referenced by decrypt(), encrypt(), getIVLength(), and operator=().
Key YAPET::Crypt::key [private] |
The key used for encryption/decryption.
Definition at line 87 of file crypt.h.
Referenced by decrypt(), encrypt(), and operator=().
uint32_t YAPET::Crypt::key_length [private] |
Length of the encryption/decryption key as expected by the cipher implementation in bytes.
Definition at line 81 of file crypt.h.
Referenced by getKeyLength(), and operator=().