Proud::CCryptoAes Class Reference

Public Types

enum  EncryptMode { ECB = 0, CBC = 1, CFB = 2 }
 
enum  { DEFAULT_BLOCK_SIZE = 16 }
 
enum  { MAX_BLOCK_SIZE = 32, MAX_ROUNDS = 14, MAX_KC = 8, MAX_BC = 8 }
 

Static Public Member Functions

static PROUD_API bool ExpandFrom (CCryptoAesKey &outKey, const uint8_t *const inputKey, int keyLength=DEFAULT_BLOCK_SIZE, int blockSize=DEFAULT_BLOCK_SIZE)
 
static int GetEncryptSize (const CCryptoAesKey &key, int inputLength)
 
static bool Encrypt (const CCryptoAesKey &key, const uint8_t *const input, int inputLength, uint8_t *output, int &outputLength, uint8_t *initializationVector=NULL, int initializationVectorLength=0, EncryptMode encryptMode=ECB)
 
static bool Decrypt (const CCryptoAesKey &key, const uint8_t *const input, int inputLength, uint8_t *output, int &outputLength, uint8_t *initializationVector=NULL, int initializationVectorLength=0, EncryptMode encryptMode=ECB)
 
static bool EncryptByteArray (const CCryptoAesKey &key, const ByteArray &input, ByteArray &output, uint8_t *initializationVector=NULL, int initializationVectorLength=0, EncryptMode encryptMode=ECB)
 
static PROUD_API bool DecryptByteArray (const CCryptoAesKey &key, const ByteArray &input, ByteArray &output, uint8_t *initializationVector=NULL, int initializationVectorLength=0, EncryptMode encryptMode=ECB)
 
static PROUD_API bool EncryptMessage (const CCryptoAesKey &key, const CMessage &input, CMessage &output, int offset, uint8_t *initializationVector=NULL, int initializationVectorLength=0, EncryptMode encryptMode=ECB)
 
static PROUD_API bool DecryptMessage (const CCryptoAesKey &key, const CMessage &input, CMessage &output, int offset, uint8_t *initializationVector=NULL, int initializationVectorLength=0, EncryptMode encryptMode=ECB)
 

Detailed Description

Rijndael (pronounced Reindaal) is a block cipher, designed by Joan Daemen and Vincent Rijmen as a candidate algorithm for the AES. The cipher has a variable block length and key length. The authors currently specify how to use keys with a length of 128, 192, or 256 bits to encrypt blocks with length of 128, 192 or 256 bits (all nine combinations of key length and block length are possible). Both block length and key length can be extended very easily to multiples of 32 bits.

Rijndael can be implemented very efficiently on a wide range of processors and in hardware.

This implementation is based on the Java Implementation used with the Cryptix toolkit found at: http://www.efgh.com/software/rijndael.zip

Java code authors: Raif S. Naffah, Paulo S. L. M. Barreto

This Implementation was tested against KAT test published by the authors of the method and the results were identical.

Member Enumeration Documentation

  • ECB, CBC, CFB Mode
  • ECB Mode: when the same block is encrypted twice, the original unencrypted test appears.
  • CBC mode: the previous block and xor calculation is encrypted afterwards.
  • CFB mode: after the block is encrypted, it does xor calculation with the previous block.

Member Function Documentation

static bool Proud::CCryptoAes::Decrypt ( const CCryptoAesKey key,
const uint8_t *const  input,
int  inputLength,
uint8_t *  output,
int &  outputLength,
uint8_t *  initializationVector = NULL,
int  initializationVectorLength = 0,
EncryptMode  encryptMode = ECB 
)
static

Decrypt data

Parameters
keySymmetric key
inputEncrypted message
inputLengthSize of Encrypted message
outputDecrypted result value
outputLengthSize of Decrypted text
initializationVectorInitialization Vector (IV) for CBC or CFB mode encryption.
initializationVectorLengthLength of initializationVector in bytes.
encryptModeEncryption mode. (ECB, CBC, CFB mode)
static PROUD_API bool Proud::CCryptoAes::DecryptByteArray ( const CCryptoAesKey key,
const ByteArray input,
ByteArray output,
uint8_t *  initializationVector = NULL,
int  initializationVectorLength = 0,
EncryptMode  encryptMode = ECB 
)
static

Decrypt ByteArray

Parameters
keySymmetric key
inputEncrypted message
outputDecrypted result value
initializationVectorInitialization Vector (IV) for CBC or CFB mode encryption.
initializationVectorLengthLength of initializationVector in bytes.
encryptModeEncryption mode. (ECB, CBC, CFB mode)
static PROUD_API bool Proud::CCryptoAes::DecryptMessage ( const CCryptoAesKey key,
const CMessage input,
CMessage output,
int  offset,
uint8_t *  initializationVector = NULL,
int  initializationVectorLength = 0,
EncryptMode  encryptMode = ECB 
)
static

Decrypt Message

Parameters
keySymmetric key
inputEncrypted message
outputDecrypted result value
offsetDecrypt start position at encrypted message
initializationVectorInitialization Vector (IV) for CBC or CFB mode encryption.
initializationVectorLengthLength of initializationVector in bytes.
encryptModeEncryption mode. (ECB, CBC, CFB mode)
static bool Proud::CCryptoAes::Encrypt ( const CCryptoAesKey key,
const uint8_t *const  input,
int  inputLength,
uint8_t *  output,
int &  outputLength,
uint8_t *  initializationVector = NULL,
int  initializationVectorLength = 0,
EncryptMode  encryptMode = ECB 
)
static

Encrypt data

Parameters
keySymmetric key
inputPlain text message
inputLengthSize of plain text
outputEncrypted result value
outputLengthSize of Encrypted result
initializationVectorInitialization Vector (IV) for CBC or CFB mode encryption.
initializationVectorLengthLength of initializationVector in bytes.
encryptModeEncryption mode. (ECB, CBC, CFB mode)
static bool Proud::CCryptoAes::EncryptByteArray ( const CCryptoAesKey key,
const ByteArray input,
ByteArray output,
uint8_t *  initializationVector = NULL,
int  initializationVectorLength = 0,
EncryptMode  encryptMode = ECB 
)
static

Encrypt ByteArray

Parameters
keySymmetric key
inputPlain text message
outputEncrypted result value
initializationVectorInitialization Vector (IV) for CBC or CFB mode encryption.
initializationVectorLengthLength of initializationVector in bytes.
encryptModeEncryption mode. (ECB, CBC, CFB mode)
static PROUD_API bool Proud::CCryptoAes::EncryptMessage ( const CCryptoAesKey key,
const CMessage input,
CMessage output,
int  offset,
uint8_t *  initializationVector = NULL,
int  initializationVectorLength = 0,
EncryptMode  encryptMode = ECB 
)
static

Encrypt Message

Parameters
keySymmetric key
inputPlain text message
outputEncrypted result value
offsetEncrypt start position at plain text message
initializationVectorInitialization Vector (IV) for CBC or CFB mode encryption.
initializationVectorLengthLength of initializationVector in bytes.
encryptModeEncryption mode. (ECB, CBC, CFB mode)
static PROUD_API bool Proud::CCryptoAes::ExpandFrom ( CCryptoAesKey outKey,
const uint8_t *const  inputKey,
int  keyLength = DEFAULT_BLOCK_SIZE,
int  blockSize = DEFAULT_BLOCK_SIZE 
)
static

TODO:translate needed. When the length of the key and the block is 128bit – 9 rounds

  • When the length of the key and the block is 192bit – 9 rounds
  • When the length of the key and the block is 256bit – 9 rounds
  • Block size: size that can be encrypted at once.
Parameters
outKeyGenerated encryption key is saved
inputKeyThe 128/192/256-bit can be used and this is the random block data to make the initial Aes key.
keyLengthIt’s either 16, 24 or 32 bytes
Thisis the block size within the Aes algorithm (16, 24 or 32 bytes).
static int Proud::CCryptoAes::GetEncryptSize ( const CCryptoAesKey key,
int  inputLength 
)
static
Parameters
keySymmetric key
inputLengthSize of plain text
Returns
Size of Encrypted result