CryptMT3  1.0
Data Structures | Public Member Functions
cryptmt::CryptMT Class Reference

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...
 

Detailed Description

CryptMT Stream Cipher.

Constructor & Destructor Documentation

cryptmt::CryptMT::CryptMT ( const uint8_t *  key,
int  keysize,
int  ivsize 
) throw (std::bad_alloc,std::invalid_argument)
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.

Parameters
[in]keyencryption key
[in]keysizesize of key measured by bits.
[in]ivsizesize of IV measured by bits.
Exceptions
std::bad_allocwhen fails allocating internal memory.
std::invalid_argumentkeysize or ivsize is not appropriate.

Member Function Documentation

uint32_t cryptmt::CryptMT::blockLength ( )

Returns block length needed by encryptBlocks() and decryptBlocks().

Returns
block length
void cryptmt::CryptMT::decrypt ( const uint8_t *  ciphertext,
uint8_t *  plaintext,
uint64_t  msglen 
) throw (stage_exception)
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().

Parameters
[in]ciphertextplain text
[out]plaintextencrypted text
[in]msglenlength of ciphertext in bytes.
Exceptions
stage_exceptionwhen IVSetUp() was not called before this method.

References encrypt().

void cryptmt::CryptMT::decryptBlocks ( const uint8_t *  ciphertext,
uint8_t *  plaintext,
uint32_t  blocks 
) throw (stage_exception)
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.

Parameters
[in]ciphertextplain text
[out]plaintextencrypted text
[in]blockslength of ciphertext in blocks.
Exceptions
stage_exceptionwhen IVSetUp() was not called before this method.

References encryptBlocks().

void cryptmt::CryptMT::decryptPacket ( const uint8_t *  iv,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
uint64_t  msglen 
)
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().

Parameters
[in]ivInitial Vector
[in]plaintextplain text
[out]ciphertextencrypted text
[in]msglenlength 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().

Parameters
[in]plaintextplain text
[out]ciphertextencrypted text
[in]msglenlength of plaintext in bytes.
Exceptions
stage_exceptionwhen 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.

Parameters
[in]plaintextplain text
[out]ciphertextencrypted text
[in]blockslength of plaintext in blocks.
Exceptions
stage_exceptionwhen IVSetUp() was not called before this method.

Referenced by decryptBlocks().

void cryptmt::CryptMT::encryptPacket ( const uint8_t *  iv,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
uint64_t  msglen 
)
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().

Parameters
[in]ivInitial Vector
[in]plaintextplain text
[out]ciphertextencrypted text
[in]msglenlength 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.

Parameters
[in]ivInitial Vector

Referenced by encryptPacket().


The documentation for this class was generated from the following file: