Code base obscuration (for images) 1.0
It implements different obscuration methods on portable images (.pgm and .ppm)
Loading...
Searching...
No Matches
AES Class Reference

This class implements the AES encryption and decryption algorithms as specified in the FIPS 197 standard. More...

#include <AES.hpp>

Public Member Functions

 AES (const AESKeyLength keyLength=AESKeyLength::AES_256)
 Construct an AES object with a specified key length.
 
unsigned char * EncryptECB (const unsigned char in[], unsigned int inLen, const unsigned char key[])
 Encrypt data using the ECB mode of operation.
 
unsigned char * DecryptECB (const unsigned char in[], unsigned int inLen, const unsigned char key[])
 Decrypt data using the ECB mode of operation.
 
unsigned char * EncryptCBC (const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv)
 Encrypt data using the CBC mode of operation.
 
unsigned char * DecryptCBC (const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv)
 Decrypt data using the CBC mode of operation.
 
unsigned char * EncryptCFB (const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv)
 Encrypt data using the CFB mode of operation.
 
unsigned char * DecryptCFB (const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv)
 Decrypt data using the CFB mode of operation.
 
unsigned char * EncryptOFB (const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv)
 Encrypt data using the OFB mode of operation.
 
unsigned char * DecryptOFB (const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv)
 Decrypt data using the OFB mode of operation.
 
void IncrementCounter (unsigned char counter[blockBytesLen])
 Increment a counter used in the CTR mode of operation.
 
unsigned char * EncryptCTR (const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv)
 Encrypt data using the CTR mode of operation.
 
unsigned char * DecryptCTR (const unsigned char in[], unsigned int inLen, const unsigned char key[], const unsigned char *iv)
 Decrypt data using the CTR mode of operation.
 
std::vector< unsigned char > EncryptECB (std::vector< unsigned char > in, std::vector< unsigned char > key)
 Encrypt data using the ECB mode of operation and store the result in a vector of bytes.
 
std::vector< unsigned char > DecryptECB (std::vector< unsigned char > in, std::vector< unsigned char > key)
 Decrypt data using the ECB mode of operation and store the result in a vector of bytes.
 
std::vector< unsigned char > EncryptCBC (std::vector< unsigned char > in, std::vector< unsigned char > key, std::vector< unsigned char > iv)
 Encrypt data using the CBC mode of operation and store the result in a vector of bytes.
 
std::vector< unsigned char > DecryptCBC (std::vector< unsigned char > in, std::vector< unsigned char > key, std::vector< unsigned char > iv)
 Decrypt data using the CBC mode of operation and store the result in a vector of bytes.
 
std::vector< unsigned char > EncryptCFB (std::vector< unsigned char > in, std::vector< unsigned char > key, std::vector< unsigned char > iv)
 Encrypt data using the CFB mode of operation and store the result in a vector of bytes.
 
std::vector< unsigned char > DecryptCFB (std::vector< unsigned char > in, std::vector< unsigned char > key, std::vector< unsigned char > iv)
 Decrypt data using the CFB mode of operation and store the result in a vector of bytes.
 
void printHexArray (unsigned char a[], unsigned int n)
 Print an array of bytes in hexadecimal format.
 
void printHexVector (std::vector< unsigned char > a)
 Print a vector of bytes in hexadecimal format.
 

Detailed Description

This class implements the AES encryption and decryption algorithms as specified in the FIPS 197 standard.

It provides methods for encrypting and decrypting data using various modes of operation, including ECB, CBC, CFB, OFB, and CTR. It also provides methods for key expansion, sub byte substitution, shift rows, mix columns, and other internal operations required by the AES algorithm.

Author
Norman HUTTE

Constructor & Destructor Documentation

◆ AES()

AES::AES ( const AESKeyLength keyLength = AESKeyLength::AES_256)
explicit

Construct an AES object with a specified key length.

Parameters
keyLengthThe key length to be used.
Author
Norman HUTTE

Member Function Documentation

◆ DecryptCBC() [1/2]

unsigned char * AES::DecryptCBC ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[],
const unsigned char * iv )

Decrypt data using the CBC mode of operation.

Parameters
inThe input data to be decrypted.
inLenThe length of the input data.
keyThe key to be used for decryption.
ivThe initialization vector to be used for decryption.
Returns
The decrypted data.
Author
Norman HUTTE

◆ DecryptCBC() [2/2]

std::vector< unsigned char > AES::DecryptCBC ( std::vector< unsigned char > in,
std::vector< unsigned char > key,
std::vector< unsigned char > iv )

Decrypt data using the CBC mode of operation and store the result in a vector of bytes.

Parameters
inThe input data to be decrypted.
keyThe key to be used for decryption.
ivThe initialization vector to be used for decryption.
Returns
The decrypted data.
Author
Norman HUTTE

◆ DecryptCFB() [1/2]

unsigned char * AES::DecryptCFB ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[],
const unsigned char * iv )

Decrypt data using the CFB mode of operation.

Parameters
inThe input data to be decrypted.
inLenThe length of the input data.
keyThe key to be used for decryption.
ivThe initialization vector to be used for decryption.
Returns
The decrypted data.
Author
Norman HUTTE

◆ DecryptCFB() [2/2]

std::vector< unsigned char > AES::DecryptCFB ( std::vector< unsigned char > in,
std::vector< unsigned char > key,
std::vector< unsigned char > iv )

Decrypt data using the CFB mode of operation and store the result in a vector of bytes.

Parameters
inThe input data to be decrypted.
keyThe key to be used for decryption.
ivThe initialization vector to be used for decryption.
Returns
The decrypted data.
Author
Norman HUTTE

◆ DecryptCTR()

unsigned char * AES::DecryptCTR ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[],
const unsigned char * iv )

Decrypt data using the CTR mode of operation.

Parameters
inThe input data to be decrypted.
inLenThe length of the input data.
keyThe key to be used for decryption.
ivThe initialization vector to be used for decryption.
Returns
The decrypted data.
Author
Norman HUTTE

◆ DecryptECB() [1/2]

unsigned char * AES::DecryptECB ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[] )

Decrypt data using the ECB mode of operation.

Parameters
inThe input data to be decrypted.
inLenThe length of the input data.
keyThe key to be used for decryption.
Returns
The decrypted data.
Author
Norman HUTTE

◆ DecryptECB() [2/2]

std::vector< unsigned char > AES::DecryptECB ( std::vector< unsigned char > in,
std::vector< unsigned char > key )

Decrypt data using the ECB mode of operation and store the result in a vector of bytes.

Parameters
inThe input data to be decrypted.
keyThe key to be used for decryption.
Returns
The decrypted data.
Author
Norman HUTTE

◆ DecryptOFB()

unsigned char * AES::DecryptOFB ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[],
const unsigned char * iv )

Decrypt data using the OFB mode of operation.

Parameters
inThe input data to be decrypted.
inLenThe length of the input data.
keyThe key to be used for decryption.
ivThe initialization vector to be used for decryption.
Returns
The decrypted data.
Author
Norman HUTTE

◆ EncryptCBC() [1/2]

unsigned char * AES::EncryptCBC ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[],
const unsigned char * iv )

Encrypt data using the CBC mode of operation.

Parameters
inThe input data to be encrypted.
inLenThe length of the input data.
keyThe key to be used for encryption.
ivThe initialization vector to be used for encryption.
Returns
The encrypted data.
Author
Norman HUTTE

◆ EncryptCBC() [2/2]

std::vector< unsigned char > AES::EncryptCBC ( std::vector< unsigned char > in,
std::vector< unsigned char > key,
std::vector< unsigned char > iv )

Encrypt data using the CBC mode of operation and store the result in a vector of bytes.

Parameters
inThe input data to be encrypted.
keyThe key to be used for encryption.
ivThe initialization vector to be used for encryption.
Returns
The encrypted data.
Author
Norman HUTTE

◆ EncryptCFB() [1/2]

unsigned char * AES::EncryptCFB ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[],
const unsigned char * iv )

Encrypt data using the CFB mode of operation.

Parameters
inThe input data to be encrypted.
inLenThe length of the input data.
keyThe key to be used for encryption.
ivThe initialization vector to be used for encryption.
Returns
The encrypted data.
Author
Norman HUTTE

◆ EncryptCFB() [2/2]

std::vector< unsigned char > AES::EncryptCFB ( std::vector< unsigned char > in,
std::vector< unsigned char > key,
std::vector< unsigned char > iv )

Encrypt data using the CFB mode of operation and store the result in a vector of bytes.

Parameters
inThe input data to be encrypted.
keyThe key to be used for encryption.
ivThe initialization vector to be used for encryption.
Returns
The encrypted data.
Author
Norman HUTTE

◆ EncryptCTR()

unsigned char * AES::EncryptCTR ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[],
const unsigned char * iv )

Encrypt data using the CTR mode of operation.

Parameters
inThe input data to be encrypted.
inLenThe length of the input data.
keyThe key to be used for encryption.
ivThe initialization vector to be used for encryption.
Returns
The encrypted data.
Author
Norman HUTTE

◆ EncryptECB() [1/2]

unsigned char * AES::EncryptECB ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[] )

Encrypt data using the ECB mode of operation.

Parameters
inThe input data to be encrypted.
inLenThe length of the input data.
keyThe key to be used for encryption.
Returns
The encrypted data.
Author
Norman HUTTE

◆ EncryptECB() [2/2]

std::vector< unsigned char > AES::EncryptECB ( std::vector< unsigned char > in,
std::vector< unsigned char > key )

Encrypt data using the ECB mode of operation and store the result in a vector of bytes.

Parameters
inThe input data to be encrypted.
keyThe key to be used for encryption.
Returns
The encrypted data.
Author
Norman HUTTE

◆ EncryptOFB()

unsigned char * AES::EncryptOFB ( const unsigned char in[],
unsigned int inLen,
const unsigned char key[],
const unsigned char * iv )

Encrypt data using the OFB mode of operation.

Parameters
inThe input data to be encrypted.
inLenThe length of the input data.
keyThe key to be used for encryption.
ivThe initialization vector to be used for encryption.
Returns
The encrypted data.
Author
Norman HUTTE

◆ IncrementCounter()

void AES::IncrementCounter ( unsigned char counter[blockBytesLen])

Increment a counter used in the CTR mode of operation.

Parameters
counterThe counter to be incremented.
Author
Norman HUTTE

◆ printHexArray()

void AES::printHexArray ( unsigned char a[],
unsigned int n )

Print an array of bytes in hexadecimal format.

Parameters
aThe array of bytes to be printed.
nThe length of the array.
Author
Norman HUTTE

◆ printHexVector()

void AES::printHexVector ( std::vector< unsigned char > a)

Print a vector of bytes in hexadecimal format.

Parameters
aThe vector of bytes to be printed.
Author
Norman HUTTE