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 PROUD_API int GetEncryptSize (const CCryptoAesKey &key, int inputLength)
 
static PROUD_API 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 PROUD_API 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 PROUD_API 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

  • Operation Modes
  • The Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB) modes
  • are implemented.
  • In ECB mode if the same block is encrypted twice with the same key, the resulting
  • ciphertext blocks are the same.
  • In CBC Mode a ciphertext block is obtained by first xoring the
  • plaintext block with the previous ciphertext block, and encrypting the resulting value.
  • In CFB mode a ciphertext block is obtained by encrypting the previous ciphertext block
  • and xoring the resulting value with the plaintext.

Member Function Documentation

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

Parameters
outKeyExpand a user-supplied key material into a session key.
inputKeyThe 128/192/256-bit user-key to use.
keyLength16, 24 or 32 bytes
blockSizeThe block size in bytes of this Rijndael (16, 24 or 32 bytes).
static PROUD_API int Proud::CCryptoAes::GetEncryptSize ( const CCryptoAesKey key,
int  inputLength 
)
static
Parameters
keySymmetric key
inputLengthSize of plain text
Returns
Size of Encrypted result