CryptMT3
1.0
|
CryptMT Stream Cipher. More...
#include <cryptmt.h>
Data Structures | |
class | stage_exception |
Error about calling sequence of methods. More... | |
Public Member Functions | |
CryptMT (const uint8_t *key, int keysize, int ivsize) throw (std::bad_alloc,std::invalid_argument) | |
keysize and ivsize should be multiple of keySizeUnit() and less or equal to maxKeySize(). More... | |
void | IVSetUp (const uint8_t *iv) |
Setup Initial Vector. More... | |
void | encrypt (const uint8_t *plaintext, uint8_t *ciphertext, uint64_t msglen) throw (stage_exception) |
Encrypts plaintext and set the result in ciphertext. More... | |
void | decrypt (const uint8_t *ciphertext, uint8_t *plaintext, uint64_t msglen) throw (stage_exception) |
Decrypt ciphertext and set the result in platintext. More... | |
void | encryptPacket (const uint8_t *iv, const uint8_t *plaintext, uint8_t *ciphertext, uint64_t msglen) |
First, call IVSetUp() using iv and then encrypts plaintext and set the result in ciphertext. More... | |
void | decryptPacket (const uint8_t *iv, const uint8_t *ciphertext, uint8_t *plaintext, uint64_t msglen) |
First, call IVSetUp() using iv and then decrypts ciphertext and set the result in plaintext. More... | |
void | encryptBlocks (const uint8_t *plaintext, uint8_t *ciphertext, uint32_t blocks) throw (stage_exception) |
Encrypts plaintext and set the result in ciphertext. More... | |
void | decryptBlocks (const uint8_t *ciphertext, uint8_t *plaintext, uint32_t blocks) throw (stage_exception) |
Decrypt ciphertext and set the result in platintext. More... | |
uint32_t | blockLength () |
Returns block length needed by encryptBlocks() and decryptBlocks(). More... | |
CryptMT Stream Cipher.
|
explicit |
keysize and ivsize should be multiple of keySizeUnit() and less or equal to maxKeySize().
Invalid_argument exception will be thrown when keysize or ivsize violate this condition. Bad_alloc exception will be thrown when fail to allocalte internal memory.
[in] | key | encryption key |
[in] | keysize | size of key measured by bits. |
[in] | ivsize | size of IV measured by bits. |
std::bad_alloc | when fails allocating internal memory. |
std::invalid_argument | keysize or ivsize is not appropriate. |
uint32_t cryptmt::CryptMT::blockLength | ( | ) |
Returns block length needed by encryptBlocks() and decryptBlocks().
|
inline |
Decrypt ciphertext and set the result in platintext.
the pointers of plaintext and ciphertext should be aligned. aligned_alloc() can be used to get aligned pointer.
After calling this method, following methods should not be called until IVSetUp() is called; encrypt(), decrypt(), encryptBlocks(), decryptBlocks().
[in] | ciphertext | plain text |
[out] | plaintext | encrypted text |
[in] | msglen | length of ciphertext in bytes. |
stage_exception | when IVSetUp() was not called before this method. |
References encrypt().
|
inline |
Decrypt ciphertext and set the result in platintext.
the pointers of plaintext and ciphertext should be aligned. aligned_alloc() can be used to get aligned pointer.
[in] | ciphertext | plain text |
[out] | plaintext | encrypted text |
[in] | blocks | length of ciphertext in blocks. |
stage_exception | when IVSetUp() was not called before this method. |
References encryptBlocks().
|
inline |
First, call IVSetUp() using iv and then decrypts ciphertext and set the result in plaintext.
the pointers of plaintext and ciphertext should be aligned. aligned_alloc() can be used to get aligned pointer.
After calling this method, following methods should not be called until IVSetUp() is called; encrypt(), decrypt(), encryptBlocks(), decryptBlocks().
[in] | iv | Initial Vector |
[in] | plaintext | plain text |
[out] | ciphertext | encrypted text |
[in] | msglen | length of plaintext in bytes. |
References encryptPacket().
void cryptmt::CryptMT::encrypt | ( | const uint8_t * | plaintext, |
uint8_t * | ciphertext, | ||
uint64_t | msglen | ||
) | throw (stage_exception) |
Encrypts plaintext and set the result in ciphertext.
the pointers of plaintext and ciphertext should be aligned. aligned_alloc() can be used to get aligned pointer.
After calling this method, following methods should not be called until IVSetUp() is called; encrypt(), decrypt(), encryptBlocks(), decryptBlocks().
[in] | plaintext | plain text |
[out] | ciphertext | encrypted text |
[in] | msglen | length of plaintext in bytes. |
stage_exception | when IVSetUp() was not called before this method. |
Referenced by decrypt(), and encryptPacket().
void cryptmt::CryptMT::encryptBlocks | ( | const uint8_t * | plaintext, |
uint8_t * | ciphertext, | ||
uint32_t | blocks | ||
) | throw (stage_exception) |
Encrypts plaintext and set the result in ciphertext.
the pointers of plaintext and ciphertext should be aligned. aligned_alloc() can be used to get aligned pointer.
[in] | plaintext | plain text |
[out] | ciphertext | encrypted text |
[in] | blocks | length of plaintext in blocks. |
stage_exception | when IVSetUp() was not called before this method. |
Referenced by decryptBlocks().
|
inline |
First, call IVSetUp() using iv and then encrypts plaintext and set the result in ciphertext.
the pointers of plaintext and ciphertext should be aligned. aligned_alloc() can be used to get aligned pointer.
After calling this method, following methods should not be called until IVSetUp() is called; encrypt(), decrypt(), encryptBlocks(), decryptBlocks().
[in] | iv | Initial Vector |
[in] | plaintext | plain text |
[out] | ciphertext | encrypted text |
[in] | msglen | length of plaintext in bytes. |
References encrypt(), and IVSetUp().
Referenced by decryptPacket().
void cryptmt::CryptMT::IVSetUp | ( | const uint8_t * | iv | ) |
Setup Initial Vector.
IVSetUp() should be called before encryption. stage_exception will be thrown when the condition is broken.
[in] | iv | Initial Vector |
Referenced by encryptPacket().